[lld] r222320 - [Mips] Move setup of LLD_R_MIPS_STO_PLT relocation to the getPLTEntry() routine

Simon Atanasyan simon at atanasyan.com
Tue Nov 18 21:50:48 PST 2014


Author: atanasyan
Date: Tue Nov 18 23:50:47 2014
New Revision: 222320

URL: http://llvm.org/viewvc/llvm-project?rev=222320&view=rev
Log:
[Mips] Move setup of LLD_R_MIPS_STO_PLT relocation to the getPLTEntry() routine

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=222320&r1=222319&r2=222320&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Tue Nov 18 23:50:47 2014
@@ -252,9 +252,6 @@ private:
   void createPLTHeader();
   bool mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
                       const Reference &ref) const;
-
-  static void addSingleReference(SimpleELFDefinedAtom *src, const Atom *tgt,
-                                 uint16_t relocType);
 };
 
 template <typename ELFT>
@@ -483,13 +480,8 @@ bool RelocationPass<ELFT>::requireCopy(R
 
 template <typename ELFT>
 void RelocationPass<ELFT>::configurePLTReference(Reference &ref) {
-  const Atom *atom = ref.target();
-
-  auto *plt = getPLTEntry(atom);
+  auto *plt = getPLTEntry(ref.target());
   ref.setTarget(plt);
-
-  if (_hasStaticRelocations.count(atom) && _requiresPtrEquality.count(atom))
-    addSingleReference(plt, atom, LLD_R_MIPS_STO_PLT);
 }
 
 template <typename ELFT>
@@ -702,17 +694,6 @@ template <typename ELFT> void Relocation
 }
 
 template <typename ELFT>
-void RelocationPass<ELFT>::addSingleReference(SimpleELFDefinedAtom *src,
-                                              const Atom *tgt,
-                                              uint16_t relocType) {
-  for (const auto &r : *src)
-    if (r->kindNamespace() == lld::Reference::KindNamespace::ELF &&
-        r->kindValue() == relocType && r->target() == tgt)
-      break;
-  src->addReferenceELF_Mips(relocType, 0, tgt, 0);
-}
-
-template <typename ELFT>
 PLTAtom *RelocationPass<ELFT>::getPLTEntry(const Atom *a) {
   auto plt = _pltMap.find(a);
   if (plt != _pltMap.end())
@@ -738,6 +719,10 @@ PLTAtom *RelocationPass<ELFT>::getPLTEnt
   // 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);
+
   DEBUG_WITH_TYPE("MipsGOT", {
     pa->_name = "__plt_";
     pa->_name += a->name();





More information about the llvm-commits mailing list