[lld] r272032 - Merge duplicate code. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 11:03:05 PDT 2016
Author: ruiu
Date: Tue Jun 7 13:03:05 2016
New Revision: 272032
URL: http://llvm.org/viewvc/llvm-project?rev=272032&view=rev
Log:
Merge duplicate code. NFC.
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272032&r1=272031&r2=272032&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Jun 7 13:03:05 2016
@@ -75,6 +75,11 @@ template <unsigned N> static void checkA
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::isTlsInitialExec
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
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;
}
More information about the llvm-commits
mailing list