[lld] r259468 - ELF: Move GNU_IFUNC relocation handler to one place. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 22:29:11 PST 2016


Author: ruiu
Date: Tue Feb  2 00:29:10 2016
New Revision: 259468

URL: http://llvm.org/viewvc/llvm-project?rev=259468&view=rev
Log:
ELF: Move GNU_IFUNC relocation handler 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=259468&r1=259467&r2=259468&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Feb  2 00:29:10 2016
@@ -306,6 +306,24 @@ void Writer<ELFT>::scanRelocs(
       }
     }
 
+    // An STT_GNU_IFUNC symbol always uses a PLT entry, and all references
+    // to the symbol go through the PLT. This is true even for a local
+    // symbol, although local symbols normally do not require PLT entries.
+    if (Body && isGnuIFunc<ELFT>(*Body)) {
+      Body->setUsedInDynamicReloc();
+      if (Body->isInGot())
+        continue;
+      Out<ELFT>::Plt->addEntry(Body);
+      if (Target->UseLazyBinding) {
+        Out<ELFT>::GotPlt->addEntry(Body);
+        Out<ELFT>::RelaPlt->addReloc({&C, &RI});
+      } else {
+        Out<ELFT>::Got->addEntry(Body);
+        Out<ELFT>::RelaDyn->addReloc({&C, &RI});
+      }
+      continue;
+    }
+
     bool NeedsGot = false;
     bool NeedsPlt = false;
 
@@ -328,15 +346,6 @@ void Writer<ELFT>::scanRelocs(
       }
     }
 
-    // An STT_GNU_IFUNC symbol always uses a PLT entry, and all references
-    // to the symbol go through the PLT. This is true even for a local
-    // symbol, although local symbols normally do not require PLT entries.
-    if (Body && isGnuIFunc<ELFT>(*Body)) {
-      Body->setUsedInDynamicReloc();
-      Out<ELFT>::RelaPlt->addReloc({&C, &RI});
-      continue;
-    }
-
     if (Config->EMachine == EM_MIPS) {
       if (Type == R_MIPS_LO16)
         // Ignore R_MIPS_LO16 relocation. If it is a pair for R_MIPS_GOT16 we




More information about the llvm-commits mailing list