[lld] r315552 - Remove one parameter from Target::getRelExpr.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 20:14:07 PDT 2017


Author: ruiu
Date: Wed Oct 11 20:14:06 2017
New Revision: 315552

URL: http://llvm.org/viewvc/llvm-project?rev=315552&view=rev
Log:
Remove one parameter from Target::getRelExpr.

A section was passed to getRelExpr just to create an error message.
But if there's an invalid relocation, we would eventually report it
in relocateOne. So we don't have to pass a section to getRelExpr.

Modified:
    lld/trunk/ELF/Arch/AArch64.cpp
    lld/trunk/ELF/Arch/AMDGPU.cpp
    lld/trunk/ELF/Arch/ARM.cpp
    lld/trunk/ELF/Arch/AVR.cpp
    lld/trunk/ELF/Arch/Mips.cpp
    lld/trunk/ELF/Arch/PPC.cpp
    lld/trunk/ELF/Arch/PPC64.cpp
    lld/trunk/ELF/Arch/SPARCV9.cpp
    lld/trunk/ELF/Arch/X86.cpp
    lld/trunk/ELF/Arch/X86_64.cpp
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/ELF/Relocations.h
    lld/trunk/ELF/Target.h
    lld/trunk/test/ELF/got32-i386.s
    lld/trunk/test/ELF/got32x-i386.s
    lld/trunk/test/ELF/invalid/invalid-debug-relocations.test
    lld/trunk/test/ELF/invalid/invalid-relocation-x64.test

Modified: lld/trunk/ELF/Arch/AArch64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/AArch64.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/AArch64.cpp (original)
+++ lld/trunk/ELF/Arch/AArch64.cpp Wed Oct 11 20:14:06 2017
@@ -32,7 +32,7 @@ namespace {
 class AArch64 final : public TargetInfo {
 public:
   AArch64();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   bool isPicRel(RelType Type) const override;
   void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
@@ -69,10 +69,8 @@ AArch64::AArch64() {
 }
 
 RelExpr AArch64::getRelExpr(RelType Type, const SymbolBody &S,
-                            const InputFile &File, const uint8_t *Loc) const {
+                            const uint8_t *Loc) const {
   switch (Type) {
-  default:
-    return R_ABS;
   case R_AARCH64_TLSDESC_ADR_PAGE21:
     return R_TLSDESC_PAGE;
   case R_AARCH64_TLSDESC_LD64_LO12:
@@ -104,6 +102,8 @@ RelExpr AArch64::getRelExpr(RelType Type
     return R_GOT_PAGE_PC;
   case R_AARCH64_NONE:
     return R_NONE;
+  default:
+    return R_ABS;
   }
 }
 

Modified: lld/trunk/ELF/Arch/AMDGPU.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/AMDGPU.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/AMDGPU.cpp (original)
+++ lld/trunk/ELF/Arch/AMDGPU.cpp Wed Oct 11 20:14:06 2017
@@ -26,7 +26,7 @@ class AMDGPU final : public TargetInfo {
 public:
   AMDGPU();
   void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
 };
 } // namespace
@@ -59,7 +59,7 @@ void AMDGPU::relocateOne(uint8_t *Loc, R
 }
 
 RelExpr AMDGPU::getRelExpr(RelType Type, const SymbolBody &S,
-                           const InputFile &File, const uint8_t *Loc) const {
+                           const uint8_t *Loc) const {
   switch (Type) {
   case R_AMDGPU_ABS32:
   case R_AMDGPU_ABS64:
@@ -73,8 +73,7 @@ RelExpr AMDGPU::getRelExpr(RelType Type,
   case R_AMDGPU_GOTPCREL32_HI:
     return R_GOT_PC;
   default:
-    error(toString(&File) + ": unknown relocation type: " + toString(Type));
-    return R_HINT;
+    return R_INVALID;
   }
 }
 

Modified: lld/trunk/ELF/Arch/ARM.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/ARM.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/ARM.cpp (original)
+++ lld/trunk/ELF/Arch/ARM.cpp Wed Oct 11 20:14:06 2017
@@ -26,7 +26,7 @@ namespace {
 class ARM final : public TargetInfo {
 public:
   ARM();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   bool isPicRel(RelType Type) const override;
   RelType getDynRel(RelType Type) const override;
@@ -65,10 +65,8 @@ ARM::ARM() {
 }
 
 RelExpr ARM::getRelExpr(RelType Type, const SymbolBody &S,
-                        const InputFile &File, const uint8_t *Loc) const {
+                        const uint8_t *Loc) const {
   switch (Type) {
-  default:
-    return R_ABS;
   case R_ARM_THM_JUMP11:
     return R_PC;
   case R_ARM_CALL:
@@ -119,6 +117,8 @@ RelExpr ARM::getRelExpr(RelType Type, co
     return R_NONE;
   case R_ARM_TLS_LE32:
     return R_TLS;
+  default:
+    return R_ABS;
   }
 }
 

Modified: lld/trunk/ELF/Arch/AVR.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/AVR.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/AVR.cpp (original)
+++ lld/trunk/ELF/Arch/AVR.cpp Wed Oct 11 20:14:06 2017
@@ -43,21 +43,15 @@ using namespace lld::elf;
 namespace {
 class AVR final : public TargetInfo {
 public:
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
 };
 } // namespace
 
 RelExpr AVR::getRelExpr(RelType Type, const SymbolBody &S,
-                        const InputFile &File, const uint8_t *Loc) const {
-  switch (Type) {
-  case R_AVR_CALL:
-    return R_ABS;
-  default:
-    error(toString(&File) + ": unknown relocation type: " + toString(Type));
-    return R_HINT;
-  }
+                        const uint8_t *Loc) const {
+  return R_ABS;
 }
 
 void AVR::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {

Modified: lld/trunk/ELF/Arch/Mips.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/Mips.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/Mips.cpp (original)
+++ lld/trunk/ELF/Arch/Mips.cpp Wed Oct 11 20:14:06 2017
@@ -28,7 +28,7 @@ namespace {
 template <class ELFT> class MIPS final : public TargetInfo {
 public:
   MIPS();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   int64_t getImplicitAddend(const uint8_t *Buf, RelType Type) const override;
   bool isPicRel(RelType Type) const override;
@@ -71,11 +71,11 @@ template <class ELFT> MIPS<ELFT>::MIPS()
 
 template <class ELFT>
 RelExpr MIPS<ELFT>::getRelExpr(RelType Type, const SymbolBody &S,
-                               const InputFile &File,
                                const uint8_t *Loc) const {
   // See comment in the calculateMipsRelChain.
   if (ELFT::Is64Bits || Config->MipsN32Abi)
     Type &= 0xff;
+
   switch (Type) {
   case R_MIPS_JALR:
   case R_MICROMIPS_JALR:
@@ -174,9 +174,7 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType T
   case R_MIPS_NONE:
     return R_NONE;
   default:
-    error("do not know how to handle relocation '" + toString(Type) + "' (" +
-          Twine(Type) + ")");
-    return R_HINT;
+    return R_INVALID;
   }
 }
 
@@ -353,8 +351,6 @@ template <class ELFT>
 int64_t MIPS<ELFT>::getImplicitAddend(const uint8_t *Buf, RelType Type) const {
   const endianness E = ELFT::TargetEndianness;
   switch (Type) {
-  default:
-    return 0;
   case R_MIPS_32:
   case R_MIPS_GPREL32:
   case R_MIPS_TLS_DTPREL32:
@@ -417,6 +413,8 @@ int64_t MIPS<ELFT>::getImplicitAddend(co
     return SignExtend64<25>(readShuffle<E>(Buf) << 2);
   case R_MICROMIPS_PC26_S1:
     return SignExtend64<27>(readShuffle<E>(Buf) << 1);
+  default:
+    return 0;
   }
 }
 
@@ -453,20 +451,24 @@ calculateMipsRelChain(uint8_t *Loc, RelT
 template <class ELFT>
 void MIPS<ELFT>::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
   const endianness E = ELFT::TargetEndianness;
+
   // Thread pointer and DRP offsets from the start of TLS data area.
   // https://www.linux-mips.org/wiki/NPTL
   if (Type == R_MIPS_TLS_DTPREL_HI16 || Type == R_MIPS_TLS_DTPREL_LO16 ||
       Type == R_MIPS_TLS_DTPREL32 || Type == R_MIPS_TLS_DTPREL64 ||
       Type == R_MICROMIPS_TLS_DTPREL_HI16 ||
-      Type == R_MICROMIPS_TLS_DTPREL_LO16)
+      Type == R_MICROMIPS_TLS_DTPREL_LO16) {
     Val -= 0x8000;
-  else if (Type == R_MIPS_TLS_TPREL_HI16 || Type == R_MIPS_TLS_TPREL_LO16 ||
-           Type == R_MIPS_TLS_TPREL32 || Type == R_MIPS_TLS_TPREL64 ||
-           Type == R_MICROMIPS_TLS_TPREL_HI16 ||
-           Type == R_MICROMIPS_TLS_TPREL_LO16)
+  } else if (Type == R_MIPS_TLS_TPREL_HI16 || Type == R_MIPS_TLS_TPREL_LO16 ||
+             Type == R_MIPS_TLS_TPREL32 || Type == R_MIPS_TLS_TPREL64 ||
+             Type == R_MICROMIPS_TLS_TPREL_HI16 ||
+             Type == R_MICROMIPS_TLS_TPREL_LO16) {
     Val -= 0x7000;
+  }
+
   if (ELFT::Is64Bits || Config->MipsN32Abi)
     std::tie(Type, Val) = calculateMipsRelChain(Loc, Type, Val);
+
   switch (Type) {
   case R_MIPS_32:
   case R_MIPS_GPREL32:

Modified: lld/trunk/ELF/Arch/PPC.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/PPC.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/PPC.cpp (original)
+++ lld/trunk/ELF/Arch/PPC.cpp Wed Oct 11 20:14:06 2017
@@ -23,11 +23,22 @@ class PPC final : public TargetInfo {
 public:
   PPC() { GotBaseSymOff = 0x8000; }
   void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
 };
 } // namespace
 
+RelExpr PPC::getRelExpr(RelType Type, const SymbolBody &S,
+                        const uint8_t *Loc) const {
+  switch (Type) {
+  case R_PPC_REL24:
+  case R_PPC_REL32:
+    return R_PC;
+  default:
+    return R_ABS;
+  }
+}
+
 void PPC::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
   switch (Type) {
   case R_PPC_ADDR16_HA:
@@ -48,17 +59,6 @@ void PPC::relocateOne(uint8_t *Loc, RelT
   }
 }
 
-RelExpr PPC::getRelExpr(RelType Type, const SymbolBody &S,
-                        const InputFile &File, const uint8_t *Loc) const {
-  switch (Type) {
-  case R_PPC_REL24:
-  case R_PPC_REL32:
-    return R_PC;
-  default:
-    return R_ABS;
-  }
-}
-
 TargetInfo *elf::getPPCTargetInfo() {
   static PPC Target;
   return &Target;

Modified: lld/trunk/ELF/Arch/PPC64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/PPC64.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/PPC64.cpp (original)
+++ lld/trunk/ELF/Arch/PPC64.cpp Wed Oct 11 20:14:06 2017
@@ -39,7 +39,7 @@ namespace {
 class PPC64 final : public TargetInfo {
 public:
   PPC64();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   void writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, uint64_t PltEntryAddr,
                 int32_t Index, unsigned RelOff) const override;
@@ -83,10 +83,8 @@ PPC64::PPC64() {
 }
 
 RelExpr PPC64::getRelExpr(RelType Type, const SymbolBody &S,
-                          const InputFile &File, const uint8_t *Loc) const {
+                          const uint8_t *Loc) const {
   switch (Type) {
-  default:
-    return R_ABS;
   case R_PPC64_TOC16:
   case R_PPC64_TOC16_DS:
   case R_PPC64_TOC16_HA:
@@ -98,6 +96,8 @@ RelExpr PPC64::getRelExpr(RelType Type,
     return R_PPC_TOC;
   case R_PPC64_REL24:
     return R_PPC_PLT_OPD;
+  default:
+    return R_ABS;
   }
 }
 

Modified: lld/trunk/ELF/Arch/SPARCV9.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/SPARCV9.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/SPARCV9.cpp (original)
+++ lld/trunk/ELF/Arch/SPARCV9.cpp Wed Oct 11 20:14:06 2017
@@ -24,7 +24,7 @@ namespace {
 class SPARCV9 final : public TargetInfo {
 public:
   SPARCV9();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
                 int32_t Index, unsigned RelOff) const override;
@@ -47,7 +47,7 @@ SPARCV9::SPARCV9() {
 }
 
 RelExpr SPARCV9::getRelExpr(RelType Type, const SymbolBody &S,
-                            const InputFile &File, const uint8_t *Loc) const {
+                            const uint8_t *Loc) const {
   switch (Type) {
   case R_SPARC_32:
   case R_SPARC_UA32:
@@ -68,8 +68,7 @@ RelExpr SPARCV9::getRelExpr(RelType Type
   case R_SPARC_NONE:
     return R_NONE;
   default:
-    error(toString(&File) + ": unknown relocation type: " + toString(Type));
-    return R_HINT;
+    return R_INVALID;
   }
 }
 

Modified: lld/trunk/ELF/Arch/X86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86.cpp (original)
+++ lld/trunk/ELF/Arch/X86.cpp Wed Oct 11 20:14:06 2017
@@ -24,7 +24,7 @@ namespace {
 class X86 final : public TargetInfo {
 public:
   X86();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   int64_t getImplicitAddend(const uint8_t *Buf, RelType Type) const override;
   void writeGotPltHeader(uint8_t *Buf) const override;
@@ -63,8 +63,10 @@ X86::X86() {
   TrapInstr = 0xcccccccc; // 0xcc = INT3
 }
 
+static bool hasBaseReg(uint8_t ModRM) { return (ModRM & 0xc7) != 0x5; }
+
 RelExpr X86::getRelExpr(RelType Type, const SymbolBody &S,
-                        const InputFile &File, const uint8_t *Loc) const {
+                        const uint8_t *Loc) const {
   switch (Type) {
   case R_386_8:
   case R_386_16:
@@ -122,13 +124,7 @@ RelExpr X86::getRelExpr(RelType Type, co
     // instruction. That means a ModRM byte is at Loc[-1]. By taking a look at
     // the byte, we can determine whether the instruction is register-relative
     // (i.e. it was generated for foo at GOT(%reg)) or absolute (i.e. foo at GOT).
-    if ((Loc[-1] & 0xc7) != 0x5)
-      return R_GOT_FROM_END;
-    if (Config->Pic)
-      error(toString(&File) + ": relocation " + toString(Type) + " against '" +
-            S.getName() +
-            "' without base register can not be used when PIC enabled");
-    return R_GOT;
+    return hasBaseReg(Loc[-1]) ? R_GOT_FROM_END : R_GOT;
   case R_386_TLS_GOTIE:
     return R_GOT_FROM_END;
   case R_386_GOTOFF:
@@ -140,8 +136,7 @@ RelExpr X86::getRelExpr(RelType Type, co
   case R_386_NONE:
     return R_NONE;
   default:
-    error(toString(&File) + ": unknown relocation type: " + toString(Type));
-    return R_HINT;
+    return R_INVALID;
   }
 }
 
@@ -234,8 +229,6 @@ void X86::writePlt(uint8_t *Buf, uint64_
 
 int64_t X86::getImplicitAddend(const uint8_t *Buf, RelType Type) const {
   switch (Type) {
-  default:
-    return 0;
   case R_386_8:
   case R_386_PC8:
     return SignExtend64<8>(*Buf);
@@ -252,6 +245,8 @@ int64_t X86::getImplicitAddend(const uin
   case R_386_TLS_LDO_32:
   case R_386_TLS_LE:
     return SignExtend64<32>(read32le(Buf));
+  default:
+    return 0;
   }
 }
 
@@ -286,9 +281,27 @@ void X86::relocateOne(uint8_t *Loc, RelT
     checkInt<17>(Loc, Val, Type);
     write16le(Loc, Val);
     break;
-  default:
+  case R_386_32:
+  case R_386_GLOB_DAT:
+  case R_386_GOT32:
+  case R_386_GOT32X:
+  case R_386_GOTOFF:
+  case R_386_GOTPC:
+  case R_386_PC32:
+  case R_386_PLT32:
+  case R_386_RELATIVE:
+  case R_386_TLS_GD:
+  case R_386_TLS_GOTIE:
+  case R_386_TLS_IE:
+  case R_386_TLS_LDM:
+  case R_386_TLS_LDO_32:
+  case R_386_TLS_LE:
+  case R_386_TLS_LE_32:
     checkInt<32>(Loc, Val, Type);
     write32le(Loc, Val);
+    break;
+  default:
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 

Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Wed Oct 11 20:14:06 2017
@@ -26,7 +26,7 @@ namespace {
 template <class ELFT> class X86_64 final : public TargetInfo {
 public:
   X86_64();
-  RelExpr getRelExpr(RelType Type, const SymbolBody &S, const InputFile &File,
+  RelExpr getRelExpr(RelType Type, const SymbolBody &S,
                      const uint8_t *Loc) const override;
   bool isPicRel(RelType Type) const override;
   void writeGotPltHeader(uint8_t *Buf) const override;
@@ -74,7 +74,6 @@ template <class ELFT> X86_64<ELFT>::X86_
 
 template <class ELFT>
 RelExpr X86_64<ELFT>::getRelExpr(RelType Type, const SymbolBody &S,
-                                 const InputFile &File,
                                  const uint8_t *Loc) const {
   switch (Type) {
   case R_X86_64_8:
@@ -110,8 +109,7 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType
   case R_X86_64_NONE:
     return R_NONE;
   default:
-    error(toString(&File) + ": unknown relocation type: " + toString(Type));
-    return R_HINT;
+    return R_INVALID;
   }
 }
 
@@ -323,7 +321,7 @@ void X86_64<ELFT>::relocateOne(uint8_t *
     write64le(Loc, Val);
     break;
   default:
-    llvm_unreachable("unexpected relocation");
+    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
   }
 }
 

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Oct 11 20:14:06 2017
@@ -488,6 +488,8 @@ static uint64_t getARMStaticBase(const S
 static uint64_t getRelocTargetVA(RelType Type, int64_t A, uint64_t P,
                                  const SymbolBody &Body, RelExpr Expr) {
   switch (Expr) {
+  case R_INVALID:
+    return 0;
   case R_ABS:
   case R_RELAX_GOT_PC_NOPIC:
     return Body.getVA(A);
@@ -661,7 +663,7 @@ void InputSection::relocateNonAlloc(uint
       Addend += Target->getImplicitAddend(BufLoc, Type);
 
     SymbolBody &Sym = this->getFile<ELFT>()->getRelocTargetSym(Rel);
-    RelExpr Expr = Target->getRelExpr(Type, Sym, *File, BufLoc);
+    RelExpr Expr = Target->getRelExpr(Type, Sym, BufLoc);
     if (Expr == R_NONE)
       continue;
     if (Expr != R_ABS) {

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Oct 11 20:14:06 2017
@@ -864,8 +864,8 @@ static void scanRelocs(InputSectionBase
         continue;
     }
 
-    RelExpr Expr = Target->getRelExpr(Type, Body, *Sec.File,
-                                      Sec.Data.begin() + Rel.r_offset);
+    RelExpr Expr =
+        Target->getRelExpr(Type, Body, Sec.Data.begin() + Rel.r_offset);
 
     // Ignore "hint" relocations because they are only markers for relaxation.
     if (isRelExprOneOf<R_HINT, R_NONE>(Expr))

Modified: lld/trunk/ELF/Relocations.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.h?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.h (original)
+++ lld/trunk/ELF/Relocations.h Wed Oct 11 20:14:06 2017
@@ -30,6 +30,7 @@ typedef uint32_t RelType;
 // from files are converted to these types so that the main code
 // doesn't have to know about architecture-specific details.
 enum RelExpr {
+  R_INVALID,
   R_ABS,
   R_ARM_SBREL,
   R_GOT,

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Wed Oct 11 20:14:06 2017
@@ -57,7 +57,6 @@ public:
   virtual bool inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const;
 
   virtual RelExpr getRelExpr(RelType Type, const SymbolBody &S,
-                             const InputFile &File,
                              const uint8_t *Loc) const = 0;
 
   virtual void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const = 0;

Modified: lld/trunk/test/ELF/got32-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/got32-i386.s?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/test/ELF/got32-i386.s (original)
+++ lld/trunk/test/ELF/got32-i386.s Wed Oct 11 20:14:06 2017
@@ -20,4 +20,4 @@ _start:
 # CHECK:  .got 00000004 0000000000012000
 
 # RUN: not ld.lld %t.o -o %t -pie 2>&1 | FileCheck %s --check-prefix=ERR
-# ERR: relocation R_386_GOT32 against 'foo' without base register can not be used when PIC enabled
+# ERR: error: can't create dynamic relocation R_386_GOT32 against symbol: foo in readonly segment; recompile object files with -fPIC

Modified: lld/trunk/test/ELF/got32x-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/got32x-i386.s?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/test/ELF/got32x-i386.s (original)
+++ lld/trunk/test/ELF/got32x-i386.s Wed Oct 11 20:14:06 2017
@@ -43,5 +43,5 @@
 
 # RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \
 # RUN:   FileCheck %s --check-prefix=ERR
-# ERR: relocation R_386_GOT32X against 'foo' without base register can not be used when PIC enabled
-# ERR: relocation R_386_GOT32X against 'foo' without base register can not be used when PIC enabled
+# ERR: error: can't create dynamic relocation R_386_GOT32X against symbol: foo in readonly segment; recompile object files with -fPIC
+# ERR: error: can't create dynamic relocation R_386_GOT32X against symbol: foo in readonly segment; recompile object files with -fPIC

Modified: lld/trunk/test/ELF/invalid/invalid-debug-relocations.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-debug-relocations.test?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-debug-relocations.test (original)
+++ lld/trunk/test/ELF/invalid/invalid-debug-relocations.test Wed Oct 11 20:14:06 2017
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s -o %t.o
 # RUN: not ld.lld -gdb-index %t.o -o %t.exe 2>&1 | FileCheck %s
 
-# CHECK: error: {{.*}}invalid-debug-relocations.test.tmp.o: unknown relocation type: Unknown (255)
+# CHECK: error: {{.*}}invalid-debug-relocations.test.tmp.o:(.debug_info+0x0): has non-ABS relocation Unknown (255) against symbol '_start'
 
 !ELF
 FileHeader:

Modified: lld/trunk/test/ELF/invalid/invalid-relocation-x64.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-relocation-x64.test?rev=315552&r1=315551&r2=315552&view=diff
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-relocation-x64.test (original)
+++ lld/trunk/test/ELF/invalid/invalid-relocation-x64.test Wed Oct 11 20:14:06 2017
@@ -3,8 +3,8 @@
 # RUN: echo ".global foo; foo:" > %t2.s
 # RUN: llvm-mc %t2.s -o %t2.o -filetype=obj -triple x86_64-pc-linux
 # RUN: not ld.lld %t1.o %t2.o -o /dev/null 2>&1 | FileCheck %s
-# CHECK: {{.*}}1.o: unknown relocation type: Unknown (152)
-# CHECK: {{.*}}1.o: unknown relocation type: Unknown (153)
+# CHECK: error: unrecognized reloc 152
+# CHECK: error: unrecognized reloc 153
 
 !ELF
 FileHeader:




More information about the llvm-commits mailing list