[ELF][x86-64] Handle PLT32 relocations to IFUNC.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 5 Feb 2013 19:15:03 +0000 (19:15 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 5 Feb 2013 19:15:03 +0000 (19:15 +0000)
llvm-svn: 174428

lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
lld/test/elf/Inputs/ifunc.S
lld/test/elf/Inputs/ifunc.x86-64
lld/test/elf/ifunc.test

index 2f53709c88eadff7054c9679afe760b40f293e31..518be30bc66bbb1ba651468de189639ea0ea899c 100644 (file)
@@ -138,12 +138,14 @@ class GOTPLTPass LLVM_FINAL : public Pass {
     switch (ref.kind()) {
     case R_X86_64_PLT32:
       // __tls_get_addr is handled elsewhere.
-      if (ref.target() && ref.target()->name() == "__tls_get_addr")
+      if (ref.target() && ref.target()->name() == "__tls_get_addr") {
         const_cast<Reference &>(ref).setKind(R_X86_64_NONE);
+        break;
+      }
       else
         // Static code doesn't need PLTs.
         const_cast<Reference &>(ref).setKind(R_X86_64_PC32);
-      break;
+      // Fall through.
     case R_X86_64_PC32: // IFUNC
       if (da && da->contentType() == DefinedAtom::typeResolver)
         handlePC32IFUNC(ref, *da);
index ff9ac2dfc0eea052b8f4a27e57acbf28239c67ca..0ac1f5a5b0bba46a71a5d5b3d51c41417f1d120a 100644 (file)
@@ -12,3 +12,10 @@ hey:
 __hey_1:
   movq $42, %rax
   ret
+
+  .text
+  .type plt, @function;
+  .globl plt;
+plt:
+  call hey@PLT
+  ret
index 273c75eca04f76305eb1e4f40c31628a71cdd342..36c8e04ca837fa97276e4a266da79b5b38ae1a7a 100644 (file)
Binary files a/lld/test/elf/Inputs/ifunc.x86-64 and b/lld/test/elf/Inputs/ifunc.x86-64 differ
index a53a5b5c7ac2c332d9a479fe4274264b073d6d17..fb7e2c854e411c9e0c4294ca8e7274769bdd55bb 100644 (file)
@@ -1,23 +1,28 @@
-RUN: lld -core -target x86_64-linux -emit-yaml -output=- %p/Inputs/ifunc.x86-64 \
-RUN: | FileCheck %s
+RUN: lld -core -target x86_64-linux -emit-yaml -output=- \
+RUN:   %p/Inputs/ifunc.x86-64 -noinhibit-exec | FileCheck %s
 
-RUN: lld -core -target x86_64-linux -emit-yaml -output=- %p/Inputs/ifunc.x86-64 \
-RUN: %p/Inputs/ifunc.cpp.x86-64 | FileCheck %s --check-prefix=PLT
+RUN: lld -core -target x86_64-linux -emit-yaml -output=- \
+RUN:   %p/Inputs/ifunc.x86-64 -noinhibit-exec %p/Inputs/ifunc.cpp.x86-64 \
+RUN: | FileCheck %s --check-prefix=PLT
 
-RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/ifunc.x86-64 \
-RUN: -noinhibit-exec %p/Inputs/ifunc.cpp.x86-64 && llvm-objdump -d -s %t| FileCheck %s \
+RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/ifunc.x86-64 -entry=main \
+RUN:   %p/Inputs/ifunc.cpp.x86-64 && llvm-objdump -d -s %t| FileCheck %s \
 RUN:   --check-prefix=BIN
 
 CHECK: name: hey
 CHECK: scope: global
 CHECK: type: resolver
 
-// Get the target that main references.
+PLT: name: plt
+PLT: scope: global
+PLT: kind: R_X86_64_PC32
+PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
+
 PLT: name: main
 PLT: scope: global
 PLT: references
 PLT: kind: R_X86_64_PC32
-PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
+PLT: target: [[PLTNAME]]
 
 // Make sure there's a got entry with a IRELATIVE relocation.
 PLT: type: got
@@ -33,6 +38,6 @@ PLT: kind: R_X86_64_PC32
 
 // This is a horribly brittle test. We need a way to do arithmetic on captured
 // variables.
-BIN: 40011c: ff 25 de 0e 00 00 jmpq *3806(%rip)
+BIN: 40012c: ff 25 ce 0e 00 00 jmpq *3790(%rip)
 BIN: .got.plt:
 BIN-NEXT: 401000 00000000 00000000