[lld] r291751 - [ELF] - Explicitly list supported relocations for x64 target.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 12 01:00:18 PST 2017
Author: grimar
Date: Thu Jan 12 03:00:17 2017
New Revision: 291751
URL: http://llvm.org/viewvc/llvm-project?rev=291751&view=rev
Log:
[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
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/test/ELF/invalid/invalid-relocation-x64.s
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=291751&r1=291750&r2=291751&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Jan 12 03:00:17 2017
@@ -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>::getRelEx
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
write64le(Loc, Val);
break;
default:
- error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+ llvm_unreachable("unexpected relocation");
}
}
Modified: lld/trunk/test/ELF/invalid/invalid-relocation-x64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-relocation-x64.s?rev=291751&r1=291750&r2=291751&view=diff
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-relocation-x64.s (original)
+++ lld/trunk/test/ELF/invalid/invalid-relocation-x64.s Thu Jan 12 03:00:17 2017
@@ -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)
More information about the llvm-commits
mailing list