[ELF] - Fix functionality treating IFunc definitions in DSOs as functions.
authorGeorge Rimar <grimar@accesssoftek.com>
Tue, 11 Jul 2017 11:40:59 +0000 (11:40 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Tue, 11 Jul 2017 11:40:59 +0000 (11:40 +0000)
It was intially implemented in D19517 but then broken.
Patch fixes PR33707, testcase is based on PR's case.

Differential revision: https://reviews.llvm.org/D35119

llvm-svn: 307652

lld/ELF/Symbols.h
lld/test/ELF/Inputs/gnu-ifunc-dso.s [new file with mode: 0644]
lld/test/ELF/gnu-ifunc-dso.s [new file with mode: 0644]

index 773e1ad..b9c1477 100644 (file)
@@ -218,7 +218,7 @@ public:
         Verdef(Verdef), ElfSym(ElfSym) {
     // IFuncs defined in DSOs are treated as functions by the static linker.
     if (isGnuIFunc())
-      Type = llvm::ELF::STT_FUNC;
+      this->Type = llvm::ELF::STT_FUNC;
     this->File = File;
   }
 
diff --git a/lld/test/ELF/Inputs/gnu-ifunc-dso.s b/lld/test/ELF/Inputs/gnu-ifunc-dso.s
new file mode 100644 (file)
index 0000000..bd82718
--- /dev/null
@@ -0,0 +1,3 @@
+.type foo STT_GNU_IFUNC
+.globl foo
+foo:
diff --git a/lld/test/ELF/gnu-ifunc-dso.s b/lld/test/ELF/gnu-ifunc-dso.s
new file mode 100644 (file)
index 0000000..6ceff3b
--- /dev/null
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/gnu-ifunc-dso.s -o %t1.o
+# RUN: ld.lld -shared %t1.o -o %t.so
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o
+# RUN: ld.lld -shared %t2.o %t.so -o %t
+# RUN: llvm-readobj -dyn-relocations %t | FileCheck %s
+
+# CHECK:      Dynamic Relocations {
+# CHECK-NEXT:   0x1000 R_X86_64_64 foo 0x0
+# CHECK-NEXT: }
+
+.data
+ .quad foo