[PATCH] D19517: ELF: Treat IFunc definitions in DSOs as functions.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 25 17:43:18 PDT 2016
pcc created this revision.
pcc added reviewers: rafael, ruiu.
pcc added a subscriber: llvm-commits.
http://reviews.llvm.org/D19517
Files:
ELF/Symbols.h
test/ELF/Inputs/gnu-ifunc-gotpcrel.s
test/ELF/gnu-ifunc-gotpcrel.s
Index: test/ELF/gnu-ifunc-gotpcrel.s
===================================================================
--- /dev/null
+++ test/ELF/gnu-ifunc-gotpcrel.s
@@ -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
Index: test/ELF/Inputs/gnu-ifunc-gotpcrel.s
===================================================================
--- /dev/null
+++ test/ELF/Inputs/gnu-ifunc-gotpcrel.s
@@ -0,0 +1,5 @@
+.type foo STT_GNU_IFUNC
+.globl foo
+.type foo, @function
+foo:
+ret
Index: ELF/Symbols.h
===================================================================
--- ELF/Symbols.h
+++ ELF/Symbols.h
@@ -340,7 +340,11 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19517.54953.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160426/4a6b5e97/attachment.bin>
More information about the llvm-commits
mailing list