diff options
| author | Nick Kledzik <kledzik@apple.com> | 2014-07-24 23:06:56 +0000 |
|---|---|---|
| committer | Nick Kledzik <kledzik@apple.com> | 2014-07-24 23:06:56 +0000 |
| commit | 21921375cc23d4958560b3280c2684c9c52baa62 (patch) | |
| tree | 0eb10637cd0350312f9a2d326b95f7b735c87e73 /lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp | |
| parent | 8ec1474f7f5f1673f6ea0bc47bdbded62fefde0e (diff) | |
| download | bcm5719-llvm-21921375cc23d4958560b3280c2684c9c52baa62.tar.gz bcm5719-llvm-21921375cc23d4958560b3280c2684c9c52baa62.zip | |
[mach-o] Add support for LC_DATA_IN_CODE
Sometimes compilers emit data into code sections (e.g. constant pools or
jump tables). These runs of data can throw off disassemblers. The solution
in mach-o is that ranges of data-in-code are encoded into a table pointed to
by the LC_DATA_IN_CODE load command.
The way the data-in-code information is encoded into lld's Atom model is that
that start and end of each data run is marked with a Reference whose offset
is the start/end of the data run. For arm, the switch back to code also marks
whether it is thumb or arm code.
llvm-svn: 213901
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp')
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp index cfd30d98de4..eae3b0145b2 100644 --- a/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp +++ b/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp @@ -69,6 +69,27 @@ public: FindAddressForAtom addressForAtom, normalized::Relocations &relocs) override; + bool isDataInCodeTransition(Reference::KindValue refKind) override { + switch (refKind) { + case modeCode: + case modeData: + return true; + default: + return false; + break; + } + } + + Reference::KindValue dataInCodeTransitionStart( + const MachODefinedAtom &atom) override { + return modeData; + } + + Reference::KindValue dataInCodeTransitionEnd( + const MachODefinedAtom &atom) override { + return modeCode; + } + private: static const Registry::KindStrings _sKindStrings[]; static const StubInfo _sStubInfo; @@ -76,6 +97,9 @@ private: enum : Reference::KindValue { invalid, /// for error condition + modeCode, /// Content starting at this offset is code. + modeData, /// Content starting at this offset is data. + // Kinds found in mach-o .o files: branch32, /// ex: call _foo branch16, /// ex: callw _foo @@ -115,6 +139,8 @@ ArchHandler_x86::~ArchHandler_x86() { } const Registry::KindStrings ArchHandler_x86::_sKindStrings[] = { LLD_KIND_STRING_ENTRY(invalid), + LLD_KIND_STRING_ENTRY(modeCode), + LLD_KIND_STRING_ENTRY(modeData), LLD_KIND_STRING_ENTRY(branch32), LLD_KIND_STRING_ENTRY(branch16), LLD_KIND_STRING_ENTRY(abs32), @@ -390,6 +416,8 @@ void ArchHandler_x86::applyFixupFinal(const Reference &ref, uint8_t *location, case negDelta32: write32(*loc32, _swap, fixupAddress - targetAddress + ref.addend()); break; + case modeCode: + case modeData: case lazyPointer: case lazyImmediateLocation: // do nothing @@ -434,6 +462,8 @@ void ArchHandler_x86::applyFixupRelocatable(const Reference &ref, case negDelta32: write32(*loc32, _swap, fixupAddress - targetAddress + ref.addend()); break; + case modeCode: + case modeData: case lazyPointer: case lazyImmediateLocation: // do nothing @@ -480,6 +510,9 @@ void ArchHandler_x86::appendSectionRelocations( uint32_t sectionOffset = atomSectionOffset + ref.offsetInAtom(); bool useExternalReloc = useExternalRelocationTo(*ref.target()); switch (ref.kindValue()) { + case modeCode: + case modeData: + break; case branch32: if (useExternalReloc) { appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0, |

