[lld] r259466 - ELF: Move code for MIPS local GOT entries to one place. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 21:55:28 PST 2016


Author: ruiu
Date: Mon Feb  1 23:55:28 2016
New Revision: 259466

URL: http://llvm.org/viewvc/llvm-project?rev=259466&view=rev
Log:
ELF: Move code for MIPS local GOT entries to one place. NFC.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259466&r1=259465&r2=259466&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Feb  1 23:55:28 2016
@@ -284,14 +284,19 @@ void Writer<ELFT>::scanRelocs(
       Out<ELFT>::RelaDyn->addReloc({&C, Rel});
     }
 
-    bool NeedsGot = false;
-    bool NeedsMipsLocalGot = false;
-    bool NeedsPlt = false;
+    // MIPS has a special rule to create GOTs for local symbols.
     if (Config->EMachine == EM_MIPS && needsMipsLocalGot(Type, Body)) {
-      NeedsMipsLocalGot = true;
       // FIXME (simon): Do not add so many redundant entries.
       Out<ELFT>::Got->addMipsLocalEntry();
-    } else if (Body) {
+      if (Body)
+        Body->setUsedInDynamicReloc();
+      continue;
+    }
+
+    bool NeedsGot = false;
+    bool NeedsPlt = false;
+
+    if (Body) {
       if (auto *E = dyn_cast<SharedSymbol<ELFT>>(Body)) {
         if (E->NeedsCopy)
           continue;
@@ -335,14 +340,13 @@ void Writer<ELFT>::scanRelocs(
         // relocation too because that case is possible for executable file
         // linking only.
         continue;
-      if (NeedsGot || NeedsMipsLocalGot) {
+      if (NeedsGot) {
         // MIPS ABI has special rules to process GOT entries
         // and doesn't require relocation entries for them.
         // See "Global Offset Table" in Chapter 5 in the following document
         // for detailed description:
         // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
-        if (NeedsGot)
-          Body->setUsedInDynamicReloc();
+        Body->setUsedInDynamicReloc();
         continue;
       }
       if (Body == Config->MipsGpDisp)




More information about the llvm-commits mailing list