[lld] r260980 - Don't create multiple .got.plt entries for the same symbol.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 08:46:31 PST 2016


Author: rafael
Date: Tue Feb 16 10:46:31 2016
New Revision: 260980

URL: http://llvm.org/viewvc/llvm-project?rev=260980&view=rev
Log:
Don't create multiple .got.plt entries for the same symbol.

We were doing it for ifunc symbols.

Added:
    lld/trunk/test/ELF/Inputs/duplicated-plt-entry.s
    lld/trunk/test/ELF/duplicated-plt-entry.s
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=260980&r1=260979&r2=260980&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Feb 16 10:46:31 2016
@@ -339,7 +339,7 @@ void Writer<ELFT>::scanRelocs(
     // 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)) {
-      if (Body->isInGot())
+      if (Body->isInPlt())
         continue;
       Out<ELFT>::Plt->addEntry(Body);
       bool CBP = canBePreempted(Body, /*NeedsGot=*/true);

Added: lld/trunk/test/ELF/Inputs/duplicated-plt-entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/duplicated-plt-entry.s?rev=260980&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/duplicated-plt-entry.s (added)
+++ lld/trunk/test/ELF/Inputs/duplicated-plt-entry.s Tue Feb 16 10:46:31 2016
@@ -0,0 +1,3 @@
+.global bar
+.type bar, @gnu_indirect_function
+bar:

Added: lld/trunk/test/ELF/duplicated-plt-entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/duplicated-plt-entry.s?rev=260980&view=auto
==============================================================================
--- lld/trunk/test/ELF/duplicated-plt-entry.s (added)
+++ lld/trunk/test/ELF/duplicated-plt-entry.s Tue Feb 16 10:46:31 2016
@@ -0,0 +1,17 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/duplicated-plt-entry.s -o %t.o
+// RUN: ld.lld -shared %t.o -o %t.so
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o
+// RUN: ld.lld %t2.o %t.so -o %t2.so -shared
+
+// RUN: llvm-readobj -r %t2.so | FileCheck %s
+// CHECK:      Relocations [
+// CHECK-NEXT:   Section ({{.*}}) .rela.plt {
+// CHECK-NEXT:       R_X86_64_JUMP_SLOT bar 0x0
+// CHECK-NEXT:   }
+// CHECK-NEXT: ]
+
+callq bar at PLT
+callq bar at PLT




More information about the llvm-commits mailing list