summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-06-07 18:03:05 +0000
committerRui Ueyama <ruiu@google.com>2016-06-07 18:03:05 +0000
commit45a873d64450e8096ebd33df2861d49168f019f1 (patch)
tree2c20ea6d4c03c7f74842a381ccd09f687d6c29e1
parent01fcbaf8e9a83130e0bc372a46ca0e4d37d6d33c (diff)
downloadbcm5719-llvm-45a873d64450e8096ebd33df2861d49168f019f1.tar.gz
bcm5719-llvm-45a873d64450e8096ebd33df2861d49168f019f1.zip
Merge duplicate code. NFC.
llvm-svn: 272032
-rw-r--r--lld/ELF/Target.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 562c9710517..b8db6f57b92 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -75,6 +75,11 @@ template <unsigned N> static void checkAlignment(uint64_t V, uint32_t Type) {
error("improper alignment for relocation " + S);
}
+static void warnDynRel(uint32_t Type) {
+ error("relocation " + getELFRelocationTypeName(Config->EMachine, Type) +
+ " cannot be used when making a shared object; recompile with -fPIC.");
+}
+
namespace {
class X86TargetInfo final : public TargetInfo {
public:
@@ -1195,10 +1200,8 @@ bool AArch64TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
uint32_t AArch64TargetInfo::getDynRel(uint32_t Type) const {
if (Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64)
return Type;
- StringRef S = getELFRelocationTypeName(EM_AARCH64, Type);
- error("relocation " + S + " cannot be used when making a shared object; "
- "recompile with -fPIC.");
// Keep it going with a dummy value so that we can find more reloc errors.
+ warnDynRel(Type);
return R_AARCH64_ABS32;
}
@@ -1487,10 +1490,8 @@ RelExpr ARMTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
uint32_t ARMTargetInfo::getDynRel(uint32_t Type) const {
if (Type == R_ARM_ABS32)
return Type;
- StringRef S = getELFRelocationTypeName(EM_ARM, Type);
- error("relocation " + S + " cannot be used when making a shared object; "
- "recompile with -fPIC.");
// Keep it going with a dummy value so that we can find more reloc errors.
+ warnDynRel(Type);
return R_ARM_ABS32;
}
@@ -1664,10 +1665,8 @@ template <class ELFT>
uint32_t MipsTargetInfo<ELFT>::getDynRel(uint32_t Type) const {
if (Type == R_MIPS_32 || Type == R_MIPS_64)
return RelativeRel;
- StringRef S = getELFRelocationTypeName(EM_MIPS, Type);
- error("relocation " + S + " cannot be used when making a shared object; "
- "recompile with -fPIC.");
// Keep it going with a dummy value so that we can find more reloc errors.
+ warnDynRel(Type);
return R_MIPS_32;
}
OpenPOWER on IntegriCloud