2015-01-24 11:55:22 +08:00
|
|
|
# REQUIRES: x86
|
2015-01-24 06:32:12 +08:00
|
|
|
|
2014-01-27 11:09:26 +08:00
|
|
|
# This test checks that IRELATIVE relocations are created for symbols that
|
|
|
|
# need relocation even for static links.
|
2013-09-23 12:24:15 +08:00
|
|
|
RUN: lld -flavor gnu -target x86_64-linux --output-filetype=yaml -r \
|
2013-04-05 02:59:24 +08:00
|
|
|
RUN: %p/Inputs/ifunc.x86-64 | FileCheck %s
|
2013-02-01 17:14:21 +08:00
|
|
|
|
2013-09-23 12:24:15 +08:00
|
|
|
RUN: lld -flavor gnu -target x86_64-linux --output-filetype=yaml --noinhibit-exec \
|
2013-04-05 02:59:24 +08:00
|
|
|
RUN: %p/Inputs/ifunc.x86-64 %p/Inputs/ifunc.cpp.x86-64 \
|
2013-02-06 03:15:03 +08:00
|
|
|
RUN: | FileCheck %s --check-prefix=PLT
|
2013-01-24 06:08:46 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
RUN: lld -flavor gnu -target x86_64-linux -o %t %p/Inputs/ifunc.x86-64 \
|
2013-06-05 09:38:12 +08:00
|
|
|
RUN: -e main -static %p/Inputs/ifunc.cpp.x86-64
|
|
|
|
RUN: llvm-objdump -d -s %t| FileCheck %s --check-prefix=BIN
|
|
|
|
RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=RELATIVEADDEND
|
2013-04-05 02:59:24 +08:00
|
|
|
|
2013-09-28 05:30:04 +08:00
|
|
|
# Test that STT_GNU_IFUNC symbols have type Code in SharedLibraryAtom.
|
|
|
|
RUN: lld -flavor gnu -target x86_64-linux --output-filetype=yaml \
|
|
|
|
RUN: --noinhibit-exec %p/Inputs/ifunc.cpp.x86-64 -L%p/Inputs -lifunc.x86-64 \
|
|
|
|
RUN: | FileCheck %s --check-prefix=SHARED
|
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
PLT: defined-atoms:
|
|
|
|
|
2013-10-11 09:50:04 +08:00
|
|
|
PLT: name: plt
|
2013-02-06 03:15:03 +08:00
|
|
|
PLT: scope: global
|
2013-04-05 02:59:24 +08:00
|
|
|
PLT: references:
|
2013-10-11 09:50:04 +08:00
|
|
|
PLT: kind: R_X86_64_PC32
|
2013-04-05 02:59:24 +08:00
|
|
|
PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
|
2013-05-11 00:44:02 +08:00
|
|
|
|
2013-10-11 09:50:04 +08:00
|
|
|
PLT: name: main
|
2013-01-30 00:38:03 +08:00
|
|
|
PLT: scope: global
|
2013-04-05 02:59:24 +08:00
|
|
|
PLT: references:
|
2013-10-11 09:50:04 +08:00
|
|
|
PLT: kind: R_X86_64_PC32
|
2013-04-05 02:59:24 +08:00
|
|
|
PLT: target: [[PLTNAME]]
|
2013-01-30 00:38:03 +08:00
|
|
|
|
|
|
|
// Make sure the target of main's relocation is a stub with a PC32 relocation.
|
|
|
|
// This relocation is to the got atom, but you can't really write that check in
|
|
|
|
// FileCheck.
|
2014-01-27 11:09:26 +08:00
|
|
|
PLT: name:
|
2013-01-30 00:38:03 +08:00
|
|
|
PLT: type: stub
|
|
|
|
PLT: references
|
2013-04-05 02:59:24 +08:00
|
|
|
PLT: kind: R_X86_64_PC32
|
|
|
|
|
ELF: Don't use LayoutPass.
Previously we applied the LayoutPass to order atoms and then
apply elf::ArrayOrderPass to sort them again. The first pass is
basically supposed to sort atoms in the normal fashion (which
is to sort symbols in the same order as the input files).
The second pass sorts atoms in {init,fini}_array.<priority> by
priority.
The problem is that the LayoutPass is overkill. It analyzes
references between atoms to make a decision how to sort them.
It's slow, hard to understand, and above all, it doesn't seem
that we need its feature for ELF in the first place.
This patch remove the LayoutPass from ELF pass list. Now all
reordering is done in elf::OrderPass. That pass sorts atoms by
{init,fini}_array, and if they are not in the special section,
they are ordered as the same order as they appear in the command
line. The new code is far easier to understand, faster, and
still able to create valid executables.
Unlike the previous layout pass, elf::OrderPass doesn't count
any attributes of an atom (e.g. permissions) except its
position. It's OK because the writer takes care of them if we
have to.
This patch changes the order of final output, although that's
benign. Tests are updated.
http://reviews.llvm.org/D7278
llvm-svn: 227666
2015-01-31 10:05:01 +08:00
|
|
|
// Make sure there's a got entry with a IRELATIVE relocation.
|
|
|
|
PLT: type: got
|
|
|
|
PLT: references:
|
|
|
|
PLT: kind: R_X86_64_IRELATIVE
|
|
|
|
PLT: target: hey
|
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
CHECK: name: hey
|
|
|
|
CHECK: scope: global
|
|
|
|
CHECK: type: resolver
|
|
|
|
|
2013-02-01 17:14:21 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
// This is a horribly brittle test. We need a way to do arithmetic on captured
|
|
|
|
// variables.
|
2013-03-01 04:04:32 +08:00
|
|
|
BIN: {{[0-9a-f]+}}: ff 25 {{[0-9a-f]+}} {{[0-9a-f]+}} 00 00 jmpq *{{[0-9]+}}(%rip)
|
2013-02-01 17:14:21 +08:00
|
|
|
BIN: .got.plt:
|
2013-03-01 04:04:32 +08:00
|
|
|
BIN-NEXT: {{[0-9a-f]+}} 00000000 00000000
|
2013-06-05 09:38:12 +08:00
|
|
|
|
|
|
|
RELATIVEADDEND: Relocations [
|
|
|
|
RELATIVEADDEND-NEXT: Section (1) .rela.plt {
|
2014-11-14 12:57:21 +08:00
|
|
|
RELATIVEADDEND-NEXT: 0x401000 R_X86_64_IRELATIVE - 0x400110
|
2013-06-05 09:38:12 +08:00
|
|
|
RELATIVEADDEND-NEXT: }
|
|
|
|
RELATIVEADDEND-NEXT: ]
|
2013-09-28 05:30:04 +08:00
|
|
|
|
|
|
|
SHARED: shared-library-atoms
|
|
|
|
SHARED: name: hey
|
|
|
|
SHARED-NOT: data
|