[lld] r174428 - [ELF][x86-64] Handle PLT32 relocations to IFUNC.
Michael J. Spencer
bigcheesegs at gmail.com
Tue Feb 5 11:15:04 PST 2013
Author: mspencer
Date: Tue Feb 5 13:15:03 2013
New Revision: 174428
URL: http://llvm.org/viewvc/llvm-project?rev=174428&view=rev
Log:
[ELF][x86-64] Handle PLT32 relocations to IFUNC.
Modified:
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
lld/trunk/test/elf/Inputs/ifunc.S
lld/trunk/test/elf/Inputs/ifunc.x86-64
lld/trunk/test/elf/ifunc.test
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp?rev=174428&r1=174427&r2=174428&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp Tue Feb 5 13:15:03 2013
@@ -138,12 +138,14 @@ class GOTPLTPass LLVM_FINAL : public Pas
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);
Modified: lld/trunk/test/elf/Inputs/ifunc.S
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/ifunc.S?rev=174428&r1=174427&r2=174428&view=diff
==============================================================================
--- lld/trunk/test/elf/Inputs/ifunc.S (original)
+++ lld/trunk/test/elf/Inputs/ifunc.S Tue Feb 5 13:15:03 2013
@@ -12,3 +12,10 @@ hey:
__hey_1:
movq $42, %rax
ret
+
+ .text
+ .type plt, @function;
+ .globl plt;
+plt:
+ call hey at PLT
+ ret
Modified: lld/trunk/test/elf/Inputs/ifunc.x86-64
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/ifunc.x86-64?rev=174428&r1=174427&r2=174428&view=diff
==============================================================================
Binary files lld/trunk/test/elf/Inputs/ifunc.x86-64 (original) and lld/trunk/test/elf/Inputs/ifunc.x86-64 Tue Feb 5 13:15:03 2013 differ
Modified: lld/trunk/test/elf/ifunc.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ifunc.test?rev=174428&r1=174427&r2=174428&view=diff
==============================================================================
--- lld/trunk/test/elf/ifunc.test (original)
+++ lld/trunk/test/elf/ifunc.test Tue Feb 5 13:15:03 2013
@@ -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
More information about the llvm-commits
mailing list