diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-12-16 15:42:31 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-12-16 15:42:31 +0000 |
commit | 7e06af85d11fd5c5b458b7044e73fd9c9da08112 (patch) | |
tree | ddb74b0a9db47ecfb246a56131db74125937b874 /lib/MC/MachObjectWriter.cpp | |
parent | b8810a38865974ed41420ce85f21495e77990a80 (diff) |
MC/Mach-O: Use fixup info instead of hard coded list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MachObjectWriter.cpp')
-rw-r--r-- | lib/MC/MachObjectWriter.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp index 1eb7c1ceea..96867e45a4 100644 --- a/lib/MC/MachObjectWriter.cpp +++ b/lib/MC/MachObjectWriter.cpp @@ -50,24 +50,6 @@ static unsigned getFixupKindLog2Size(unsigned Kind) { } } -static bool isFixupKindPCRel(unsigned Kind) { - switch (Kind) { - default: - return false; - case FK_PCRel_1: - case FK_PCRel_2: - case FK_PCRel_4: - case X86::reloc_riprel_4byte: - case X86::reloc_riprel_4byte_movq_load: - return true; - } -} - -static bool isFixupKindRIPRel(unsigned Kind) { - return Kind == X86::reloc_riprel_4byte || - Kind == X86::reloc_riprel_4byte_movq_load; -} - static bool doesSymbolRequireExternRelocation(MCSymbolData *SD) { // Undefined symbols are always extern. if (SD->Symbol->isUndefined()) @@ -179,6 +161,18 @@ class MachObjectWriter : public MCObjectWriter { } }; + /// @name Utility Methods + /// @{ + + bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind) { + const MCFixupKindInfo &FKI = Asm.getBackend().getFixupKindInfo( + (MCFixupKind) Kind); + + return FKI.Flags & MCFixupKindInfo::FKF_IsPCRel; + } + + /// @} + /// @name Relocation Data /// @{ @@ -489,11 +483,15 @@ public: // - Input errors, where something cannot be correctly encoded. 'as' allows // these through in many cases. + static bool isFixupKindRIPRel(unsigned Kind) { + return Kind == X86::reloc_riprel_4byte || + Kind == X86::reloc_riprel_4byte_movq_load; + } void RecordX86_64Relocation(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) { - unsigned IsPCRel = isFixupKindPCRel(Fixup.getKind()); + unsigned IsPCRel = isFixupKindPCRel(Asm, Fixup.getKind()); unsigned IsRIPRel = isFixupKindRIPRel(Fixup.getKind()); unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind()); @@ -731,7 +729,7 @@ public: const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) { uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset(); - unsigned IsPCRel = isFixupKindPCRel(Fixup.getKind()); + unsigned IsPCRel = isFixupKindPCRel(Asm, Fixup.getKind()); unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind()); unsigned Type = macho::RIT_Vanilla; @@ -841,7 +839,7 @@ public: return; } - unsigned IsPCRel = isFixupKindPCRel(Fixup.getKind()); + unsigned IsPCRel = isFixupKindPCRel(Asm, Fixup.getKind()); unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind()); // If this is a 32-bit TLVP reloc it's handled a bit differently. |