summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/ReferenceKinds.h
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/ReferenceKinds.h')
-rw-r--r--lld/lib/ReaderWriter/MachO/ReferenceKinds.h151
1 files changed, 70 insertions, 81 deletions
diff --git a/lld/lib/ReaderWriter/MachO/ReferenceKinds.h b/lld/lib/ReaderWriter/MachO/ReferenceKinds.h
index df4945e13f7..159bbc61cc7 100644
--- a/lld/lib/ReaderWriter/MachO/ReferenceKinds.h
+++ b/lld/lib/ReaderWriter/MachO/ReferenceKinds.h
@@ -20,6 +20,32 @@
namespace lld {
namespace mach_o {
+// Additional Reference Kind values used internally.
+enum {
+ LLD_X86_64_RELOC_GOT_LOAD_NOW_LEA = 100,
+ LLD_X86_64_RELOC_TLV_NOW_LEA = 101,
+ LLD_X86_64_RELOC_LAZY_TARGET = 102,
+ LLD_X86_64_RELOC_LAZY_IMMEDIATE = 103,
+ LLD_X86_64_RELOC_SIGNED_32 = 104,
+};
+enum {
+ LLD_X86_RELOC_BRANCH32 = 100, // CALL or JMP 32-bit pc-rel
+ LLD_X86_RELOC_ABS32 = 101, // 32-bit absolute addr in instruction
+ LLD_X86_RELOC_FUNC_REL32 = 102, // 32-bit target from start of func
+ LLD_X86_RELOC_POINTER32 = 103, // 32-bit data pointer
+ LLD_X86_RELOC_LAZY_TARGET = 104,
+ LLD_X86_RELOC_LAZY_IMMEDIATE = 105
+};
+enum {
+ LLD_ARM_RELOC_THUMB_ABS_LO16 = 100, // thumb movw of absolute address
+ LLD_ARM_RELOC_THUMB_ABS_HI16 = 101, // thumb movt of absolute address
+ LLD_ARM_RELOC_THUMB_REL_LO16 = 102, // thumb movw of (target - pc)
+ LLD_ARM_RELOC_THUMB_REL_HI16 = 103, // thumb movt of (target - pc)
+ LLD_ARM_RELOC_ABS32 = 104, // 32-bit constant pointer
+ LLD_ARM_RELOC_POINTER32 = 105, // 32-bit data pointer
+ LLD_ARM_RELOC_LAZY_TARGET = 106,
+ LLD_ARM_RELOC_LAZY_IMMEDIATE = 107,
+};
///
/// The KindHandler class is the abstract interface to Reference::Kind
@@ -28,18 +54,20 @@ namespace mach_o {
///
class KindHandler {
public:
- typedef Reference::Kind Kind;
static std::unique_ptr<mach_o::KindHandler> create(MachOLinkingContext::Arch);
virtual ~KindHandler();
- virtual Kind stringToKind(StringRef str) = 0;
- virtual StringRef kindToString(Kind) = 0;
- virtual bool isCallSite(Kind) = 0;
- virtual bool isPointer(Kind) = 0;
- virtual bool isLazyImmediate(Kind) = 0;
- virtual bool isLazyTarget(Kind) = 0;
- virtual void applyFixup(Kind kind, uint64_t addend, uint8_t *location,
- uint64_t fixupAddress, uint64_t targetAddress) = 0;
+
+ virtual bool isCallSite(const Reference&) = 0;
+ virtual bool isPointer(const Reference&) = 0;
+ virtual bool isLazyImmediate(const Reference&) = 0;
+ virtual bool isLazyTarget(const Reference&) = 0;
+ virtual void applyFixup(Reference::KindNamespace ns,
+ Reference::KindArch arch,
+ Reference::KindValue kindValue,
+ uint64_t addend, uint8_t *location,
+ uint64_t fixupAddress,
+ uint64_t targetAddress) = 0;
protected:
KindHandler();
@@ -49,94 +77,55 @@ protected:
class KindHandler_x86_64 : public KindHandler {
public:
- enum Kinds {
- invalid, // used to denote an error creating a Reference
- none,
- branch32, // CALL or JMP 32-bit pc-rel
- ripRel32, // RIP-rel access pc-rel to fix up location
- ripRel32_1, // RIP-rel access pc-rel to fix up location + 1
- ripRel32_2, // RIP-rel access pc-rel to fix up location + 2
- ripRel32_4, // RIP-rel access pc-rel to fix up location + 4
- gotLoadRipRel32, // RIP-rel load of GOT slot (can be optimized)
- gotLoadRipRel32NowLea, // RIP-rel movq load of GOT slot optimized to LEA
- gotUseRipRel32, // RIP-rel non-load of GOT slot (not a movq load of GOT)
- tlvLoadRipRel32, // RIP-rel load of thread local pointer (can be optimized)
- tlvLoadRipRel32NowLea, // RIP-rel movq load of TLV pointer optimized to LEA
- pointer64, // 64-bit data pointer
- pointerRel32, // 32-bit pc-rel offset
- lazyTarget, // Used in lazy pointers to reference ultimate target
- lazyImmediate, // Location in stub where lazy info offset to be stored
- subordinateFDE, // Reference to unwind info for this function
- subordinateLSDA // Reference to excecption info for this function
- };
+ static const Registry::KindStrings kindStrings[];
+
virtual ~KindHandler_x86_64();
- virtual Kind stringToKind(StringRef str);
- virtual StringRef kindToString(Kind);
- virtual bool isCallSite(Kind);
- virtual bool isPointer(Kind);
- virtual bool isLazyImmediate(Kind);
- virtual bool isLazyTarget(Kind);
- virtual void applyFixup(Kind kind, uint64_t addend, uint8_t *location,
- uint64_t fixupAddress, uint64_t targetAddress);
-
+ virtual bool isCallSite(const Reference&);
+ virtual bool isPointer(const Reference&);
+ virtual bool isLazyImmediate(const Reference&);
+ virtual bool isLazyTarget(const Reference&);
+ virtual void applyFixup(Reference::KindNamespace ns,
+ Reference::KindArch arch,
+ Reference::KindValue kindValue,
+ uint64_t addend, uint8_t *location,
+ uint64_t fixupAddress, uint64_t targetAddress);
};
class KindHandler_x86 : public KindHandler {
public:
- enum Kinds {
- invalid, // used to denote an error creating a Reference
- none,
- branch32, // CALL or JMP 32-bit pc-rel
- abs32, // 32-bit absolute address embedded in instruction
- funcRel32, // 32-bit offset to target from start of function
- pointer32, // 32-bit data pointer
- lazyTarget, // Used in lazy pointers to reference ultimate target
- lazyImmediate, // Location in stub where lazy info offset to be stored
- subordinateFDE, // Reference to unwind info for this function
- subordinateLSDA // Reference to excecption info for this function
- };
+
+ static const Registry::KindStrings kindStrings[];
virtual ~KindHandler_x86();
- virtual Kind stringToKind(StringRef str);
- virtual StringRef kindToString(Kind);
- virtual bool isCallSite(Kind);
- virtual bool isPointer(Kind);
- virtual bool isLazyImmediate(Kind);
- virtual bool isLazyTarget(Kind);
- virtual void applyFixup(Kind kind, uint64_t addend, uint8_t *location,
- uint64_t fixupAddress, uint64_t targetAddress);
+ virtual bool isCallSite(const Reference&);
+ virtual bool isPointer(const Reference&);
+ virtual bool isLazyImmediate(const Reference&);
+ virtual bool isLazyTarget(const Reference&);
+ virtual void applyFixup(Reference::KindNamespace ns,
+ Reference::KindArch arch,
+ Reference::KindValue kindValue,
+ uint64_t addend, uint8_t *location,
+ uint64_t fixupAddress, uint64_t targetAddress);
};
class KindHandler_arm : public KindHandler {
public:
- enum Kinds {
- invalid, // used to denote an error creating a Reference
- none,
- thumbBranch22, // thumb b or bl with 22/24-bits of displacement
- armBranch24, // arm b or bl with 24-bits of displacement
- thumbAbsLow16, // thumb movw of absolute address
- thumbAbsHigh16, // thumb movt of absolute address
- thumbPcRelLow16, // thumb movw of (target - pc)
- thumbPcRelHigh16,// thumb movt of (target - pc)
- abs32, // 32-bit absolute address embedded in instructions
- pointer32, // 32-bit data pointer
- lazyTarget, // Used in lazy pointers to reference ultimate target
- lazyImmediate, // Location in stub where lazy info offset to be stored
- subordinateLSDA // Reference to excecption info for this function
- };
+
+ static const Registry::KindStrings kindStrings[];
virtual ~KindHandler_arm();
- virtual Kind stringToKind(StringRef str);
- virtual StringRef kindToString(Kind);
- virtual bool isCallSite(Kind);
- virtual bool isPointer(Kind);
- virtual bool isLazyImmediate(Kind);
- virtual bool isLazyTarget(Kind);
- virtual void applyFixup(Kind kind, uint64_t addend, uint8_t *location,
- uint64_t fixupAddress, uint64_t targetAddress);
+ virtual bool isCallSite(const Reference&);
+ virtual bool isPointer(const Reference&);
+ virtual bool isLazyImmediate(const Reference&);
+ virtual bool isLazyTarget(const Reference&);
+ virtual void applyFixup(Reference::KindNamespace ns,
+ Reference::KindArch arch,
+ Reference::KindValue kindValue,
+ uint64_t addend, uint8_t *location,
+ uint64_t fixupAddress, uint64_t targetAddress);
};
OpenPOWER on IntegriCloud