| ... | ... | @@ -181,6 +181,20 @@ public: |
| 181 | 181 | FindAddressForAtom addressForAtom, |
| 182 | 182 | normalized::Relocations &relocs) override; |
| 183 | 183 | |
| 184 | bool isDataInCodeTransition(Reference::KindValue refKind) override { |
| 185 | return refKind == modeCode || refKind == modeData; |
| 186 | } |
| 187 | |
| 188 | Reference::KindValue dataInCodeTransitionStart( |
| 189 | const MachODefinedAtom &atom) override { |
| 190 | return modeData; |
| 191 | } |
| 192 | |
| 193 | Reference::KindValue dataInCodeTransitionEnd( |
| 194 | const MachODefinedAtom &atom) override { |
| 195 | return modeCode; |
| 196 | } |
| 197 | |
| 184 | 198 | private: |
| 185 | 199 | static const Registry::KindStrings _sKindStrings[]; |
| 186 | 200 | static const StubInfo _sStubInfo; |
| ... | ... | @@ -188,6 +202,9 @@ private: |
| 188 | 202 | enum X86_64Kind: Reference::KindValue { |
| 189 | 203 | invalid, /// for error condition |
| 190 | 204 | |
| 205 | modeCode, /// Content starting at this offset is code. |
| 206 | modeData, /// Content starting at this offset is data. |
| 207 | |
| 191 | 208 | // Kinds found in mach-o .o files: |
| 192 | 209 | branch32, /// ex: call _foo |
| 193 | 210 | ripRel32, /// ex: movq _foo(%rip), %rax |
| ... | ... | @@ -242,24 +259,34 @@ private: |
| 242 | 259 | }; |
| 243 | 260 | |
| 244 | 261 | const Registry::KindStrings ArchHandler_x86_64::_sKindStrings[] = { |
| 245 | | LLD_KIND_STRING_ENTRY(invalid), LLD_KIND_STRING_ENTRY(branch32), |
| 246 | | LLD_KIND_STRING_ENTRY(ripRel32), LLD_KIND_STRING_ENTRY(ripRel32Minus1), |
| 247 | | LLD_KIND_STRING_ENTRY(ripRel32Minus2), LLD_KIND_STRING_ENTRY(ripRel32Minus4), |
| 262 | LLD_KIND_STRING_ENTRY(invalid), |
| 263 | LLD_KIND_STRING_ENTRY(modeCode), |
| 264 | LLD_KIND_STRING_ENTRY(modeData), |
| 265 | LLD_KIND_STRING_ENTRY(branch32), |
| 266 | LLD_KIND_STRING_ENTRY(ripRel32), |
| 267 | LLD_KIND_STRING_ENTRY(ripRel32Minus1), |
| 268 | LLD_KIND_STRING_ENTRY(ripRel32Minus2), |
| 269 | LLD_KIND_STRING_ENTRY(ripRel32Minus4), |
| 248 | 270 | LLD_KIND_STRING_ENTRY(ripRel32Anon), |
| 249 | 271 | LLD_KIND_STRING_ENTRY(ripRel32Minus1Anon), |
| 250 | 272 | LLD_KIND_STRING_ENTRY(ripRel32Minus2Anon), |
| 251 | 273 | LLD_KIND_STRING_ENTRY(ripRel32Minus4Anon), |
| 252 | 274 | LLD_KIND_STRING_ENTRY(ripRel32GotLoad), |
| 253 | 275 | LLD_KIND_STRING_ENTRY(ripRel32GotLoadNowLea), |
| 254 | | LLD_KIND_STRING_ENTRY(ripRel32Got), LLD_KIND_STRING_ENTRY(ripRel32Tlv), |
| 276 | LLD_KIND_STRING_ENTRY(ripRel32Got), |
| 277 | LLD_KIND_STRING_ENTRY(ripRel32Tlv), |
| 255 | 278 | LLD_KIND_STRING_ENTRY(lazyPointer), |
| 256 | 279 | LLD_KIND_STRING_ENTRY(lazyImmediateLocation), |
| 257 | | LLD_KIND_STRING_ENTRY(pointer64), LLD_KIND_STRING_ENTRY(pointer64Anon), |
| 258 | | LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(delta64), |
| 259 | | LLD_KIND_STRING_ENTRY(delta32Anon), LLD_KIND_STRING_ENTRY(delta64Anon), |
| 280 | LLD_KIND_STRING_ENTRY(pointer64), |
| 281 | LLD_KIND_STRING_ENTRY(pointer64Anon), |
| 282 | LLD_KIND_STRING_ENTRY(delta32), |
| 283 | LLD_KIND_STRING_ENTRY(delta64), |
| 284 | LLD_KIND_STRING_ENTRY(delta32Anon), |
| 285 | LLD_KIND_STRING_ENTRY(delta64Anon), |
| 260 | 286 | LLD_KIND_STRING_ENTRY(negDelta64), |
| 261 | 287 | LLD_KIND_STRING_ENTRY(negDelta32), |
| 262 | | LLD_KIND_STRING_ENTRY(imageOffset), LLD_KIND_STRING_ENTRY(imageOffsetGot), |
| 288 | LLD_KIND_STRING_ENTRY(imageOffset), |
| 289 | LLD_KIND_STRING_ENTRY(imageOffsetGot), |
| 263 | 290 | LLD_KIND_STRING_ENTRY(unwindFDEToFunction), |
| 264 | 291 | LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame), |
| 265 | 292 | LLD_KIND_STRING_ENTRY(tlvInitSectionOffset), |
| ... | ... | @@ -601,6 +628,8 @@ void ArchHandler_x86_64::applyFixupFinal( |
| 601 | 628 | case negDelta32: |
| 602 | 629 | *loc32 = fixupAddress - targetAddress + ref.addend(); |
| 603 | 630 | return; |
| 631 | case modeCode: |
| 632 | case modeData: |
| 604 | 633 | case lazyPointer: |
| 605 | 634 | // Do nothing |
| 606 | 635 | return; |
| ... | ... | @@ -720,6 +749,8 @@ void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, |
| 720 | 749 | case unwindInfoToEhFrame: |
| 721 | 750 | llvm_unreachable("fixup implies __unwind_info"); |
| 722 | 751 | return; |
| 752 | case modeCode: |
| 753 | case modeData: |
| 723 | 754 | case unwindFDEToFunction: |
| 724 | 755 | // Do nothing for now |
| 725 | 756 | return; |
| ... | ... | @@ -743,6 +774,9 @@ void ArchHandler_x86_64::appendSectionRelocations( |
| 743 | 774 | assert(ref.kindArch() == Reference::KindArch::x86_64); |
| 744 | 775 | uint32_t sectionOffset = atomSectionOffset + ref.offsetInAtom(); |
| 745 | 776 | switch (static_cast<X86_64Kind>(ref.kindValue())) { |
| 777 | case modeCode: |
| 778 | case modeData: |
| 779 | return; |
| 746 | 780 | case branch32: |
| 747 | 781 | appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0, |
| 748 | 782 | X86_64_RELOC_BRANCH | rPcRel | rExtern | rLength4); |