[lld] r248326 - Move the last remaining hard coded relocations to Target.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 14:35:52 PDT 2015


Author: rafael
Date: Tue Sep 22 16:35:51 2015
New Revision: 248326

URL: http://llvm.org/viewvc/llvm-project?rev=248326&view=rev
Log:
Move the last remaining hard coded relocations to Target.

Unfortunately the i386 and x86_64 relocation have the same numerical value
and it is a probably a bit much to add got support for another architecture
just to test this.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Target.h

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=248326&r1=248325&r2=248326&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Sep 22 16:35:51 2015
@@ -77,8 +77,8 @@ template <class ELFT> void RelocationSec
     uint32_t Type = RI.getType(IsMips64EL);
     if (Target->relocNeedsGot(Type)) {
       P->r_offset = GotSec.getEntryAddr(*Body);
-      P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), R_X86_64_GLOB_DAT,
-                          IsMips64EL);
+      P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
+                          Target->getGotReloc(), IsMips64EL);
     } else {
       P->r_offset = RI.r_offset + C.getOutputSectionOff() + Out->getVA();
       P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type, IsMips64EL);

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=248326&r1=248325&r2=248326&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Sep 22 16:35:51 2015
@@ -26,7 +26,10 @@ std::unique_ptr<TargetInfo> Target;
 
 TargetInfo::~TargetInfo() {}
 
-X86TargetInfo::X86TargetInfo() { PCRelReloc = R_386_PC32; }
+X86TargetInfo::X86TargetInfo() {
+  PCRelReloc = R_386_PC32;
+  GotReloc = R_386_GLOB_DAT;
+}
 
 void X86TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                                   uint64_t PltEntryAddr) const {
@@ -83,7 +86,10 @@ void X86TargetInfo::relocateOne(uint8_t
   }
 }
 
-X86_64TargetInfo::X86_64TargetInfo() { PCRelReloc = R_X86_64_PC32; }
+X86_64TargetInfo::X86_64TargetInfo() {
+  PCRelReloc = R_X86_64_PC32;
+  GotReloc = R_X86_64_GLOB_DAT;
+}
 
 void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                                      uint64_t PltEntryAddr) const {
@@ -156,6 +162,7 @@ void X86_64TargetInfo::relocateOne(uint8
 
 PPC64TargetInfo::PPC64TargetInfo() {
   // PCRelReloc = FIXME
+  // GotReloc = FIXME
 }
 void PPC64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                                     uint64_t PltEntryAddr) const {}
@@ -183,6 +190,7 @@ void PPC64TargetInfo::relocateOne(uint8_
 
 PPCTargetInfo::PPCTargetInfo() {
   // PCRelReloc = FIXME
+  // GotReloc = FIXME
 }
 void PPCTargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                                   uint64_t PltEntryAddr) const {}
@@ -193,6 +201,7 @@ void PPCTargetInfo::relocateOne(uint8_t
 
 ARMTargetInfo::ARMTargetInfo() {
   // PCRelReloc = FIXME
+  // GotReloc = FIXME
 }
 void ARMTargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                                   uint64_t PltEntryAddr) const {}

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=248326&r1=248325&r2=248326&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Tue Sep 22 16:35:51 2015
@@ -19,6 +19,7 @@ class SymbolBody;
 class TargetInfo {
 public:
   unsigned getPCRelReloc() const { return PCRelReloc; }
+  unsigned getGotReloc() const { return GotReloc; }
   virtual void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                              uint64_t PltEntryAddr) const = 0;
   virtual bool relocNeedsGot(uint32_t Type) const = 0;
@@ -30,6 +31,7 @@ public:
 
 protected:
   unsigned PCRelReloc;
+  unsigned GotReloc;
 };
 
 class X86TargetInfo final : public TargetInfo {




More information about the llvm-commits mailing list