diff options
| author | Tim Northover <tnorthover@apple.com> | 2014-10-15 20:26:24 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2014-10-15 20:26:24 +0000 |
| commit | 995abe34f9127cbea4b1679176ed7480f2cfbe91 (patch) | |
| tree | a49bddc2200eced2d12be8562a3317aa9f0f0a80 /lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | |
| parent | ae5804f3d70dc995b42eea35f483105f31a40199 (diff) | |
| download | bcm5719-llvm-995abe34f9127cbea4b1679176ed7480f2cfbe91.tar.gz bcm5719-llvm-995abe34f9127cbea4b1679176ed7480f2cfbe91.zip | |
[mach-o] avoid overly clever std::find_if
The bots were complaining (possibly because of a lack of traits on the iterator
I was trying to use). No functional change.
llvm-svn: 219843
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp')
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp index 03fcf056157..d52af892b94 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp @@ -660,15 +660,30 @@ std::error_code addEHFrameReferences(const NormalizedFile &normalizedFile, const uint8_t *frameData = atom->rawContent().data(); uint32_t size = read32(swap, *(uint32_t *)frameData); - uint64_t rangeFieldInFDE = size == 0xffffffffU - ? 2 * sizeof(uint32_t) + sizeof(uint64_t) - : 2 * sizeof(uint32_t); + uint64_t cieFieldInFDE = size == 0xffffffffU + ? sizeof(uint32_t) + sizeof(uint64_t) + : sizeof(uint32_t); + + // Linker needs to fixup a reference from the FDE to its parent CIE (a + // 32-bit byte offset backwards in the __eh_frame section). + uint32_t cieDelta = read32(swap, *(uint32_t *)(frameData + cieFieldInFDE)); + uint64_t cieAddress = ehFrameSection->address + offset + cieFieldInFDE; + cieAddress -= cieDelta; + + Reference::Addend addend; + const Atom *cie = + findAtomCoveringAddress(normalizedFile, file, cieAddress, &addend); + atom->addReference(cieFieldInFDE, handler.unwindRefToCIEKind(), cie, + addend, handler.kindArch()); + + // Linker needs to fixup reference from the FDE to the function it's + // describing. + uint64_t rangeFieldInFDE = cieFieldInFDE + sizeof(uint32_t); int64_t functionFromFDE = readSPtr(is64, swap, frameData + rangeFieldInFDE); uint64_t rangeStart = ehFrameSection->address + offset + rangeFieldInFDE; rangeStart += functionFromFDE; - Reference::Addend addend; const Atom *func = findAtomCoveringAddress(normalizedFile, file, rangeStart, &addend); atom->addReference(rangeFieldInFDE, handler.unwindRefToFunctionKind(), func, |

