diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-01-12 09:00:17 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-01-12 09:00:17 +0000 |
commit | d5ba9b4c9f5fb0e167e44ad672d570da3bad105b (patch) | |
tree | 014bf341886719a7fd5918381d294388bc5dc425 | |
parent | 671c86fa062f8a014bc4a4cab855d0da60e6efcf (diff) |
[ELF] - Explicitly list supported relocations for x64 target.
The same we did for x86 earlier:
list supported relocations explicitly and error out on unknown.
Differential revision: https://reviews.llvm.org/D28564
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291751 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | ELF/Target.cpp | 12 | ||||
-rw-r--r-- | test/ELF/invalid/invalid-relocation-x64.s | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/ELF/Target.cpp b/ELF/Target.cpp index 749795f19..019bdf0b1 100644 --- a/ELF/Target.cpp +++ b/ELF/Target.cpp @@ -631,7 +631,11 @@ template <class ELFT> RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type, const SymbolBody &S) const { switch (Type) { - default: + case R_X86_64_32: + case R_X86_64_32S: + case R_X86_64_64: + case R_X86_64_DTPOFF32: + case R_X86_64_DTPOFF64: return R_ABS; case R_X86_64_TPOFF32: return R_TLS; @@ -657,6 +661,10 @@ RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type, return R_GOT_PC; case R_X86_64_NONE: return R_HINT; + default: + error("do not know how to handle relocation '" + toString(Type) + "' (" + + Twine(Type) + ")"); + return R_HINT; } } @@ -878,7 +886,7 @@ void X86_64TargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type, write64le(Loc, Val); break; default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + llvm_unreachable("unexpected relocation"); } } diff --git a/test/ELF/invalid/invalid-relocation-x64.s b/test/ELF/invalid/invalid-relocation-x64.s index 1ad9afa4c..4934874bf 100644 --- a/test/ELF/invalid/invalid-relocation-x64.s +++ b/test/ELF/invalid/invalid-relocation-x64.s @@ -26,5 +26,5 @@ Sections: Type: R_X86_64_NONE # RUN: not ld.lld %p/Inputs/invalid-relocation-x64.elf -o %t2 2>&1 | FileCheck %s -# CHECK: unrecognized reloc 152 -# CHECK: unrecognized reloc 153 +# CHECK: do not know how to handle relocation 'Unknown' (152) +# CHECK: do not know how to handle relocation 'Unknown' (153) |