[lld] r249756 - [ELF2] Make the .plt entry size target dependent

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 14:51:32 PDT 2015


Author: hfinkel
Date: Thu Oct  8 16:51:31 2015
New Revision: 249756

URL: http://llvm.org/viewvc/llvm-project?rev=249756&view=rev
Log:
[ELF2] Make the .plt entry size target dependent

The size of a .plt entry is different on different targets (it is,
specifically, much larger than 8 on all PPC ABIs). There is no functional
change here (later patches to create .plt entries for PPC64 will depend on this
change).

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h
    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=249756&r1=249755&r2=249756&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Oct  8 16:51:31 2015
@@ -119,7 +119,7 @@ template <class ELFT> void PltSection<EL
     uintptr_t InstPos = reinterpret_cast<uintptr_t>(Buf);
     uint64_t PltEntryAddr = (InstPos - Start) + this->getVA();
     Target->writePltEntry(Buf, GotEntryAddr, PltEntryAddr);
-    Buf += EntrySize;
+    Buf += Target->getPltEntrySize();
   }
 }
 
@@ -131,7 +131,12 @@ template <class ELFT> void PltSection<EL
 template <class ELFT>
 typename PltSection<ELFT>::uintX_t
 PltSection<ELFT>::getEntryAddr(const SymbolBody &B) const {
-  return this->getVA() + B.getPltIndex() * EntrySize;
+  return this->getVA() + B.getPltIndex() * Target->getPltEntrySize();
+}
+
+template <class ELFT>
+void PltSection<ELFT>::finalize() {
+  this->Header.sh_size = Entries.size() * Target->getPltEntrySize();
 }
 
 template <class ELFT>

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=249756&r1=249755&r2=249756&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Thu Oct  8 16:51:31 2015
@@ -122,14 +122,11 @@ class PltSection final : public OutputSe
 
 public:
   PltSection();
-  void finalize() override {
-    this->Header.sh_size = Entries.size() * EntrySize;
-  }
+  void finalize() override;
   void writeTo(uint8_t *Buf) override;
   void addEntry(SymbolBody *Sym);
   bool empty() const { return Entries.empty(); }
   uintX_t getEntryAddr(const SymbolBody &B) const;
-  static const unsigned EntrySize = 8;
 
 private:
   std::vector<const SymbolBody *> Entries;

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=249756&r1=249755&r2=249756&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Oct  8 16:51:31 2015
@@ -201,6 +201,7 @@ void X86_64TargetInfo::relocateOne(uint8
 PPC64TargetInfo::PPC64TargetInfo() {
   // PCRelReloc = FIXME
   // GotReloc = FIXME
+  PltEntrySize = 32;
   VAStart = 0x10000000;
 }
 void PPC64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=249756&r1=249755&r2=249756&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Oct  8 16:51:31 2015
@@ -26,6 +26,7 @@ public:
   unsigned getGotReloc() const { return GotReloc; }
   unsigned getGotRefReloc() const { return GotRefReloc; }
   unsigned getRelativeReloc() const { return RelativeReloc; }
+  unsigned getPltEntrySize() const { return PltEntrySize; }
   virtual void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
                              uint64_t PltEntryAddr) const = 0;
   virtual bool isRelRelative(uint32_t Type) const;
@@ -43,6 +44,7 @@ protected:
   unsigned GotRefReloc;
   unsigned GotReloc;
   unsigned RelativeReloc;
+  unsigned PltEntrySize = 8;
   llvm::StringRef DefaultEntry = "_start";
 };
 




More information about the llvm-commits mailing list