[lld] r259158 - Remove a parameter from Target::writePlt.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 20:15:02 PST 2016


Author: ruiu
Date: Thu Jan 28 22:15:02 2016
New Revision: 259158

URL: http://llvm.org/viewvc/llvm-project?rev=259158&view=rev
Log:
Remove a parameter from Target::writePlt.

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=259158&r1=259157&r2=259158&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Jan 28 22:15:02 2016
@@ -189,21 +189,18 @@ PltSection<ELFT>::PltSection()
 
 template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) {
   size_t Off = 0;
-  bool LazyReloc = Target->UseLazyBinding;
-  if (LazyReloc) {
+  if (Target->UseLazyBinding) {
     // First write PLT[0] entry which is special.
     Target->writePltZero(Buf);
     Off += Target->PltZeroSize;
   }
   for (auto &I : Entries) {
-    const SymbolBody *E = I.first;
+    const SymbolBody *B = I.first;
     unsigned RelOff = I.second;
-    uint64_t GotVA =
-        LazyReloc ? Out<ELFT>::GotPlt->getVA() : Out<ELFT>::Got->getVA();
-    uint64_t GotE = LazyReloc ? Out<ELFT>::GotPlt->getEntryAddr(*E)
-                              : Out<ELFT>::Got->getEntryAddr(*E);
+    uint64_t Got = Target->UseLazyBinding ? Out<ELFT>::GotPlt->getEntryAddr(*B)
+                                          : Out<ELFT>::Got->getEntryAddr(*B);
     uint64_t Plt = this->getVA() + Off;
-    Target->writePlt(Buf + Off, GotVA, GotE, Plt, E->PltIndex, RelOff);
+    Target->writePlt(Buf + Off, Got, Plt, B->PltIndex, RelOff);
     Off += Target->PltEntrySize;
   }
 }

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259158&r1=259157&r2=259158&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Jan 28 22:15:02 2016
@@ -91,9 +91,8 @@ public:
   bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
   void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
   void writePltZero(uint8_t *Buf) const override;
-  void writePlt(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,
-                uint64_t PltEntryAddr, int32_t Index,
-                unsigned RelOff) const override;
+  void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
+                int32_t Index, unsigned RelOff) const override;
   bool needsCopyRel(uint32_t Type, const SymbolBody &S) const override;
   bool needsDynRelative(unsigned Type) const override;
   bool needsGot(uint32_t Type, const SymbolBody &S) const override;
@@ -124,9 +123,8 @@ public:
   void writeGotPltHeader(uint8_t *Buf) const override;
   void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
   void writePltZero(uint8_t *Buf) const override;
-  void writePlt(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,
-                uint64_t PltEntryAddr, int32_t Index,
-                unsigned RelOff) const override;
+  void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
+                int32_t Index, unsigned RelOff) const override;
   bool needsCopyRel(uint32_t Type, const SymbolBody &S) const override;
   bool needsGot(uint32_t Type, const SymbolBody &S) const override;
   bool needsPlt(uint32_t Type, const SymbolBody &S) const override;
@@ -162,9 +160,8 @@ public:
 class PPC64TargetInfo final : public TargetInfo {
 public:
   PPC64TargetInfo();
-  void writePlt(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,
-                uint64_t PltEntryAddr, int32_t Index,
-                unsigned RelOff) const override;
+  void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
+                int32_t Index, unsigned RelOff) const override;
   bool needsGot(uint32_t Type, const SymbolBody &S) const override;
   bool needsPlt(uint32_t Type, const SymbolBody &S) const override;
   void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
@@ -179,9 +176,8 @@ public:
   unsigned getDynRel(unsigned Type) const override;
   void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
   void writePltZero(uint8_t *Buf) const override;
-  void writePlt(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,
-                uint64_t PltEntryAddr, int32_t Index,
-                unsigned RelOff) const override;
+  void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
+                int32_t Index, unsigned RelOff) const override;
   unsigned getTlsGotRel(unsigned Type = -1) const override;
   bool isTlsDynRel(unsigned Type, const SymbolBody &S) const override;
   bool needsCopyRel(uint32_t Type, const SymbolBody &S) const override;
@@ -357,18 +353,21 @@ void X86TargetInfo::writePltZero(uint8_t
   write32le(Buf + 8, Got + 8); // GOT+8
 }
 
-void X86TargetInfo::writePlt(uint8_t *Buf, uint64_t GotAddr,
-                             uint64_t GotEntryAddr, uint64_t PltEntryAddr,
-                             int32_t Index, unsigned RelOff) const {
+void X86TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
+                             uint64_t PltEntryAddr, int32_t Index,
+                             unsigned RelOff) const {
   const uint8_t Inst[] = {
       0xff, 0x00, 0x00, 0x00, 0x00, 0x00, // jmp *foo_in_GOT|*foo at GOT(%ebx)
       0x68, 0x00, 0x00, 0x00, 0x00,       // pushl $reloc_offset
       0xe9, 0x00, 0x00, 0x00, 0x00        // jmp .PLT0 at PC
   };
   memcpy(Buf, Inst, sizeof(Inst));
+
   // jmp *foo at GOT(%ebx) or jmp *foo_in_GOT
   Buf[1] = Config->Shared ? 0xa3 : 0x25;
-  write32le(Buf + 2, Config->Shared ? (GotEntryAddr - GotAddr) : GotEntryAddr);
+  uint32_t Got = UseLazyBinding ? Out<ELF32LE>::GotPlt->getVA()
+                                : Out<ELF32LE>::Got->getVA();
+  write32le(Buf + 2, Config->Shared ? GotEntryAddr - Got : GotEntryAddr);
   write32le(Buf + 7, RelOff);
   write32le(Buf + 12, -Index * PltEntrySize - PltZeroSize - 16);
 }
@@ -627,9 +626,9 @@ void X86_64TargetInfo::writePltZero(uint
   write32le(Buf + 8, Got - Plt + 4); // GOT+16
 }
 
-void X86_64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotAddr,
-                                uint64_t GotEntryAddr, uint64_t PltEntryAddr,
-                                int32_t Index, unsigned RelOff) const {
+void X86_64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
+                                uint64_t PltEntryAddr, int32_t Index,
+                                unsigned RelOff) const {
   const uint8_t Inst[] = {
       0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmpq *got(%rip)
       0x68, 0x00, 0x00, 0x00, 0x00,       // pushq <relocation index>
@@ -975,9 +974,9 @@ uint64_t getPPC64TocBase() {
   return TocVA + 0x8000;
 }
 
-void PPC64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotAddr,
-                               uint64_t GotEntryAddr, uint64_t PltEntryAddr,
-                               int32_t Index, unsigned RelOff) const {
+void PPC64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
+                               uint64_t PltEntryAddr, int32_t Index,
+                               unsigned RelOff) const {
   uint64_t Off = GotEntryAddr - getPPC64TocBase();
 
   // FIXME: What we should do, in theory, is get the offset of the function
@@ -1191,9 +1190,9 @@ void AArch64TargetInfo::writePltZero(uin
               Got + 16);
 }
 
-void AArch64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotAddr,
-                                 uint64_t GotEntryAddr, uint64_t PltEntryAddr,
-                                 int32_t Index, unsigned RelOff) const {
+void AArch64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
+                                 uint64_t PltEntryAddr, int32_t Index,
+                                 unsigned RelOff) const {
   const uint8_t Inst[] = {
       0x10, 0x00, 0x00, 0x90, // adrp x16, Page(&(.plt.got[n]))
       0x11, 0x02, 0x40, 0xf9, // ldr  x17, [x16, Offset(&(.plt.got[n]))]

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=259158&r1=259157&r2=259158&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Jan 28 22:15:02 2016
@@ -36,7 +36,7 @@ public:
   // they are called. This function writes that code.
   virtual void writePltZero(uint8_t *Buf) const {}
 
-  virtual void writePlt(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,
+  virtual void writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
                         uint64_t PltEntryAddr, int32_t Index,
                         unsigned RelOff) const {}
 




More information about the llvm-commits mailing list