[lld] r267566 - ELF: Treat IFunc definitions in DSOs as functions.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 09:22:52 PDT 2016


Author: pcc
Date: Tue Apr 26 11:22:51 2016
New Revision: 267566

URL: http://llvm.org/viewvc/llvm-project?rev=267566&view=rev
Log:
ELF: Treat IFunc definitions in DSOs as functions.

Differential Revision: http://reviews.llvm.org/D19517

Added:
    lld/trunk/test/ELF/Inputs/gnu-ifunc-gotpcrel.s
    lld/trunk/test/ELF/gnu-ifunc-gotpcrel.s
Modified:
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=267566&r1=267565&r2=267566&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Apr 26 11:22:51 2016
@@ -349,7 +349,11 @@ public:
   SharedSymbol(SharedFile<ELFT> *F, StringRef Name, const Elf_Sym &Sym)
       : Defined(SymbolBody::SharedKind, Name, Sym.getBinding(), Sym.st_other,
                 Sym.getType()),
-        File(F), Sym(Sym) {}
+        File(F), Sym(Sym) {
+    // IFuncs defined in DSOs are treated as functions by the static linker.
+    if (isGnuIFunc())
+      Type = llvm::ELF::STT_FUNC;
+  }
 
   SharedFile<ELFT> *File;
   const Elf_Sym &Sym;

Added: lld/trunk/test/ELF/Inputs/gnu-ifunc-gotpcrel.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/gnu-ifunc-gotpcrel.s?rev=267566&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/gnu-ifunc-gotpcrel.s (added)
+++ lld/trunk/test/ELF/Inputs/gnu-ifunc-gotpcrel.s Tue Apr 26 11:22:51 2016
@@ -0,0 +1,4 @@
+.type foo STT_GNU_IFUNC
+.globl foo
+foo:
+ret

Added: lld/trunk/test/ELF/gnu-ifunc-gotpcrel.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-ifunc-gotpcrel.s?rev=267566&view=auto
==============================================================================
--- lld/trunk/test/ELF/gnu-ifunc-gotpcrel.s (added)
+++ lld/trunk/test/ELF/gnu-ifunc-gotpcrel.s Tue Apr 26 11:22:51 2016
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/gnu-ifunc-gotpcrel.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t2.so
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o %t2.so -o %t
+# RUN: llvm-readobj -dyn-relocations %t | FileCheck %s
+
+# CHECK:      Dynamic Relocations {
+# CHECK-NEXT:   0x120B0 R_X86_64_GLOB_DAT foo 0x0
+# CHECK-NEXT: }
+
+.globl _start
+_start:
+mov foo at gotpcrel(%rip), %rax




More information about the llvm-commits mailing list