diff options
| author | Rui Ueyama <ruiu@google.com> | 2013-12-20 07:48:29 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2013-12-20 07:48:29 +0000 |
| commit | 170a1a892e687791b8bbba302ca29f5ff11c0b99 (patch) | |
| tree | 0b784f557368f24f3555bb6a6ce10127ca133c45 /lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp | |
| parent | 6e6c239e338c91e8d429882a2cb307fa67054ed4 (diff) | |
| download | bcm5719-llvm-170a1a892e687791b8bbba302ca29f5ff11c0b99.tar.gz bcm5719-llvm-170a1a892e687791b8bbba302ca29f5ff11c0b99.zip | |
Run clang-format on r197727.
llvm-svn: 197788
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp')
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp | 176 |
1 files changed, 84 insertions, 92 deletions
diff --git a/lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp b/lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp index 8d2515089e5..0e87fb579d4 100644 --- a/lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp +++ b/lld/lib/ReaderWriter/MachO/ReferenceKinds.cpp @@ -55,22 +55,21 @@ KindHandler::create(MachOLinkingContext::Arch arch) { KindHandler_x86_64::~KindHandler_x86_64() { } - const Registry::KindStrings KindHandler_x86_64::kindStrings[] = { - LLD_KIND_STRING_ENTRY(X86_64_RELOC_UNSIGNED), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_BRANCH), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED_1), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED_2), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED_4), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_GOT_LOAD), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_GOT), - LLD_KIND_STRING_ENTRY(X86_64_RELOC_TLV), - LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_GOT_LOAD_NOW_LEA), - LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_TLV_NOW_LEA), - LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_LAZY_TARGET), - LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_LAZY_IMMEDIATE), - LLD_KIND_STRING_END + LLD_KIND_STRING_ENTRY(X86_64_RELOC_UNSIGNED), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_BRANCH), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED_1), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED_2), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_SIGNED_4), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_GOT_LOAD), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_GOT), + LLD_KIND_STRING_ENTRY(X86_64_RELOC_TLV), + LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_GOT_LOAD_NOW_LEA), + LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_TLV_NOW_LEA), + LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_LAZY_TARGET), + LLD_KIND_STRING_ENTRY(LLD_X86_64_RELOC_LAZY_IMMEDIATE), + LLD_KIND_STRING_END }; bool KindHandler_x86_64::isCallSite(const Reference &ref) { @@ -89,54 +88,53 @@ bool KindHandler_x86_64::isLazyTarget(const Reference &ref) { return (ref.kindValue() == LLD_X86_64_RELOC_LAZY_TARGET); } - -void KindHandler_x86_64::applyFixup(Reference::KindNamespace ns, - Reference::KindArch arch, - Reference::KindValue kindValue, - uint64_t addend, - uint8_t *location, uint64_t fixupAddress, +void KindHandler_x86_64::applyFixup(Reference::KindNamespace ns, + Reference::KindArch arch, + Reference::KindValue kindValue, + uint64_t addend, uint8_t *location, + uint64_t fixupAddress, uint64_t targetAddress) { if (ns != Reference::KindNamespace::mach_o) return; assert(arch == Reference::KindArch::x86_64); int32_t *loc32 = reinterpret_cast<int32_t*>(location); uint64_t* loc64 = reinterpret_cast<uint64_t*>(location); - switch ( kindValue ) { - case X86_64_RELOC_BRANCH: - case X86_64_RELOC_SIGNED: - case X86_64_RELOC_GOT_LOAD: - case X86_64_RELOC_GOT: - case X86_64_RELOC_TLV: + switch (kindValue) { + case X86_64_RELOC_BRANCH: + case X86_64_RELOC_SIGNED: + case X86_64_RELOC_GOT_LOAD: + case X86_64_RELOC_GOT: + case X86_64_RELOC_TLV: *loc32 = (targetAddress - (fixupAddress+4)) + addend; break; - case X86_64_RELOC_UNSIGNED: + case X86_64_RELOC_UNSIGNED: *loc64 = targetAddress + addend; break; - case X86_64_RELOC_SIGNED_1: + case X86_64_RELOC_SIGNED_1: *loc32 = (targetAddress - (fixupAddress+5)) + addend; break; - case X86_64_RELOC_SIGNED_2: + case X86_64_RELOC_SIGNED_2: *loc32 = (targetAddress - (fixupAddress+6)) + addend; break; - case X86_64_RELOC_SIGNED_4: + case X86_64_RELOC_SIGNED_4: *loc32 = (targetAddress - (fixupAddress+8)) + addend; break; - case LLD_X86_64_RELOC_SIGNED_32: + case LLD_X86_64_RELOC_SIGNED_32: *loc32 = (targetAddress - fixupAddress) + addend; break; - case LLD_X86_64_RELOC_GOT_LOAD_NOW_LEA: - case LLD_X86_64_RELOC_TLV_NOW_LEA: + case LLD_X86_64_RELOC_GOT_LOAD_NOW_LEA: + case LLD_X86_64_RELOC_TLV_NOW_LEA: // Change MOVQ to LEA assert(location[-2] == 0x8B); location[-2] = 0x8D; *loc32 = (targetAddress - (fixupAddress+4)) + addend; break; - case LLD_X86_64_RELOC_LAZY_TARGET: - case LLD_X86_64_RELOC_LAZY_IMMEDIATE: + case LLD_X86_64_RELOC_LAZY_TARGET: + case LLD_X86_64_RELOC_LAZY_IMMEDIATE: // do nothing break; - default: - llvm_unreachable("invalid x86_64 Reference Kind"); + default: + llvm_unreachable("invalid x86_64 Reference Kind"); break; } } @@ -150,13 +148,13 @@ KindHandler_x86::~KindHandler_x86() { } const Registry::KindStrings KindHandler_x86::kindStrings[] = { - LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_BRANCH32), - LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_ABS32), - LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_FUNC_REL32), - LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_POINTER32), - LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_LAZY_TARGET), - LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_LAZY_IMMEDIATE), - LLD_KIND_STRING_END + LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_BRANCH32), + LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_ABS32), + LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_FUNC_REL32), + LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_POINTER32), + LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_LAZY_TARGET), + LLD_KIND_STRING_ENTRY(LLD_X86_RELOC_LAZY_IMMEDIATE), + LLD_KIND_STRING_END }; bool KindHandler_x86::isCallSite(const Reference &ref) { @@ -167,44 +165,41 @@ bool KindHandler_x86::isPointer(const Reference &ref) { return (ref.kindValue() == LLD_X86_RELOC_POINTER32); } - bool KindHandler_x86::isLazyImmediate(const Reference &ref) { return (ref.kindValue() == LLD_X86_RELOC_LAZY_TARGET); } - bool KindHandler_x86::isLazyTarget(const Reference &ref) { return (ref.kindValue() == LLD_X86_RELOC_LAZY_TARGET); } - -void KindHandler_x86::applyFixup(Reference::KindNamespace ns, - Reference::KindArch arch, - Reference::KindValue kindValue, +void KindHandler_x86::applyFixup(Reference::KindNamespace ns, + Reference::KindArch arch, + Reference::KindValue kindValue, uint64_t addend, uint8_t *location, - uint64_t fixupAddress, + uint64_t fixupAddress, uint64_t targetAddress) { if (ns != Reference::KindNamespace::mach_o) return; assert(arch == Reference::KindArch::x86); int32_t *loc32 = reinterpret_cast<int32_t*>(location); switch (kindValue) { - case LLD_X86_RELOC_BRANCH32: + case LLD_X86_RELOC_BRANCH32: *loc32 = (targetAddress - (fixupAddress+4)) + addend; break; - case LLD_X86_RELOC_POINTER32: - case LLD_X86_RELOC_ABS32: + case LLD_X86_RELOC_POINTER32: + case LLD_X86_RELOC_ABS32: *loc32 = targetAddress + addend; break; - case LLD_X86_RELOC_FUNC_REL32: + case LLD_X86_RELOC_FUNC_REL32: *loc32 = targetAddress + addend; break; - case LLD_X86_RELOC_LAZY_TARGET: - case LLD_X86_RELOC_LAZY_IMMEDIATE: + case LLD_X86_RELOC_LAZY_TARGET: + case LLD_X86_RELOC_LAZY_IMMEDIATE: // do nothing break; - default: - llvm_unreachable("invalid x86 Reference Kind"); + default: + llvm_unreachable("invalid x86 Reference Kind"); break; } } @@ -218,21 +213,21 @@ KindHandler_arm::~KindHandler_arm() { } const Registry::KindStrings KindHandler_arm::kindStrings[] = { - LLD_KIND_STRING_ENTRY(ARM_RELOC_BR24), - LLD_KIND_STRING_ENTRY(ARM_THUMB_RELOC_BR22), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_ABS_LO16), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_ABS_HI16), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_REL_LO16), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_REL_HI16), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_ABS32), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_POINTER32), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_LAZY_TARGET), - LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_LAZY_IMMEDIATE), - LLD_KIND_STRING_END + LLD_KIND_STRING_ENTRY(ARM_RELOC_BR24), + LLD_KIND_STRING_ENTRY(ARM_THUMB_RELOC_BR22), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_ABS_LO16), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_ABS_HI16), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_REL_LO16), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_THUMB_REL_HI16), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_ABS32), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_POINTER32), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_LAZY_TARGET), + LLD_KIND_STRING_ENTRY(LLD_ARM_RELOC_LAZY_IMMEDIATE), + LLD_KIND_STRING_END }; bool KindHandler_arm::isCallSite(const Reference &ref) { - return (ref.kindValue() == ARM_THUMB_RELOC_BR22) || + return (ref.kindValue() == ARM_THUMB_RELOC_BR22) || (ref.kindValue() == ARM_RELOC_BR24); } @@ -240,58 +235,55 @@ bool KindHandler_arm::isPointer(const Reference &ref) { return (ref.kindValue() == LLD_ARM_RELOC_POINTER32); } - bool KindHandler_arm::isLazyImmediate(const Reference &ref) { return (ref.kindValue() == LLD_ARM_RELOC_LAZY_IMMEDIATE); } - bool KindHandler_arm::isLazyTarget(const Reference &ref) { return (ref.kindValue() == LLD_ARM_RELOC_LAZY_TARGET); } - -void KindHandler_arm::applyFixup(Reference::KindNamespace ns, - Reference::KindArch arch, - Reference::KindValue kindValue, +void KindHandler_arm::applyFixup(Reference::KindNamespace ns, + Reference::KindArch arch, + Reference::KindValue kindValue, uint64_t addend, uint8_t *location, - uint64_t fixupAddress, + uint64_t fixupAddress, uint64_t targetAddress) { if (ns != Reference::KindNamespace::mach_o) return; assert(arch == Reference::KindArch::ARM); //int32_t *loc32 = reinterpret_cast<int32_t*>(location); - switch ( kindValue ) { - case ARM_THUMB_RELOC_BR22: + switch (kindValue) { + case ARM_THUMB_RELOC_BR22: // FIXME break; - case ARM_RELOC_BR24: + case ARM_RELOC_BR24: // FIXME break; - case LLD_ARM_RELOC_THUMB_ABS_LO16: + case LLD_ARM_RELOC_THUMB_ABS_LO16: // FIXME break; - case LLD_ARM_RELOC_THUMB_ABS_HI16: + case LLD_ARM_RELOC_THUMB_ABS_HI16: // FIXME break; - case LLD_ARM_RELOC_THUMB_REL_LO16: + case LLD_ARM_RELOC_THUMB_REL_LO16: // FIXME break; - case LLD_ARM_RELOC_THUMB_REL_HI16: + case LLD_ARM_RELOC_THUMB_REL_HI16: // FIXME break; - case LLD_ARM_RELOC_ABS32: + case LLD_ARM_RELOC_ABS32: // FIXME break; - case LLD_ARM_RELOC_POINTER32: + case LLD_ARM_RELOC_POINTER32: // FIXME break; - case LLD_ARM_RELOC_LAZY_TARGET: - case LLD_ARM_RELOC_LAZY_IMMEDIATE: + case LLD_ARM_RELOC_LAZY_TARGET: + case LLD_ARM_RELOC_LAZY_IMMEDIATE: // do nothing break; - default: - llvm_unreachable("invalid ARM Reference Kind"); + default: + llvm_unreachable("invalid ARM Reference Kind"); break; } } |

