[lld] r222415 - [Mips] Configure GOTPLT entries in the corresponding constructor

Simon Atanasyan simon at atanasyan.com
Wed Nov 19 22:34:04 PST 2014


Author: atanasyan
Date: Thu Nov 20 00:34:04 2014
New Revision: 222415

URL: http://llvm.org/viewvc/llvm-project?rev=222415&view=rev
Log:
[Mips] Configure GOTPLT entries in the corresponding constructor

No functional changes.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=222415&r1=222414&r2=222415&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Thu Nov 20 00:34:04 2014
@@ -133,6 +133,13 @@ public:
 class GOTPLTAtom : public GOTAtom {
 public:
   GOTPLTAtom(const File &f) : GOTAtom(f, ".got.plt") {}
+  GOTPLTAtom(const PLTAtom *plt0, const Atom *a, const File &f)
+      : GOTAtom(f, ".got.plt") {
+    // Setup reference to assign initial value to the .got.plt entry.
+    addReferenceELF_Mips(R_MIPS_32, 0, plt0, 0);
+    // Create dynamic relocation to adjust the .got.plt entry at runtime.
+    addReferenceELF_Mips(R_MIPS_JUMP_SLOT, 0, a, 0);
+  }
 
   Alignment alignment() const override { return Alignment(2); }
 
@@ -676,18 +683,13 @@ const PLTAtom *RelocationPass<ELFT>::get
   if (_pltVector.empty())
     createPLTHeader();
 
-  auto ga = new (_file._alloc) GOTPLTAtom(_file);
+  auto ga = new (_file._alloc) GOTPLTAtom(_pltVector.front(), a, _file);
   _gotpltVector.push_back(ga);
 
   auto pa = new (_file._alloc) PLTAAtom(ga, _file);
   _pltMap[a] = pa;
   _pltVector.push_back(pa);
 
-  // Setup reference to assign initial value to the .got.plt entry.
-  ga->addReferenceELF_Mips(R_MIPS_32, 0, _pltVector.front(), 0);
-  // Create dynamic relocation to adjust the .got.plt entry at runtime.
-  ga->addReferenceELF_Mips(R_MIPS_JUMP_SLOT, 0, a, 0);
-
   // Check that 'a' dynamic symbol table record should point to the PLT.
   if (_hasStaticRelocations.count(a) && _requiresPtrEquality.count(a))
     pa->addReferenceELF_Mips(LLD_R_MIPS_STO_PLT, 0, a, 0);





More information about the llvm-commits mailing list