gnu-ifunc-plt.s
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// REQUIRES: x86
/// For non-preemptable ifunc, place ifunc PLT entries after regular PLT entries.
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o
// RUN: ld.lld %t1.o --shared -soname=so -o %t.so
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
// RUN: llvm-readobj -r --dynamic-table %tout | FileCheck %s
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
// CHECK: Relocations [
// CHECK-NEXT: Section (4) .rela.dyn {
// CHECK-NEXT: 0x203458 R_X86_64_IRELATIVE - 0x2012D8
// CHECK-NEXT: 0x203460 R_X86_64_IRELATIVE - 0x2012D9
// CHECK-NEXT: }
// CHECK-NEXT: Section (5) .rela.plt {
// CHECK-NEXT: 0x203448 R_X86_64_JUMP_SLOT bar2 0x0
// CHECK-NEXT: 0x203450 R_X86_64_JUMP_SLOT zed2 0x0
// CHECK-NEXT: }
// Check that .got.plt entries point back to PLT header
// GOTPLT: Contents of section .got.plt:
// GOTPLT-NEXT: 203430 40232000 00000000 00000000 00000000
// GOTPLT-NEXT: 203440 00000000 00000000 06132000 00000000
// GOTPLT-NEXT: 203450 16132000 00000000 00000000 00000000
// GOTPLT-NEXT: 203460 00000000 00000000
// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
// CHECK: DynamicSection [
// CHECK: 0x0000000000000008 RELASZ 48 (bytes)
// CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes)
// Check that a PLT header is written and the ifunc entries appear last
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: foo:
// DISASM-NEXT: 2012d8: retq
// DISASM: bar:
// DISASM-NEXT: 2012d9: retq
// DISASM: _start:
// DISASM-NEXT: 2012da: callq 65
// DISASM-NEXT: 2012df: callq 76
// DISASM-NEXT: callq {{.*}} <bar2@plt>
// DISASM-NEXT: callq {{.*}} <zed2@plt>
// DISASM-EMPTY:
// DISASM-NEXT: Disassembly of section .plt:
// DISASM-EMPTY:
// DISASM-NEXT: .plt:
// DISASM-NEXT: 2012f0: pushq 8514(%rip)
// DISASM-NEXT: 2012f6: jmpq *8516(%rip)
// DISASM-NEXT: 2012fc: nopl (%rax)
// DISASM-EMPTY:
// DISASM-NEXT: bar2@plt:
// DISASM-NEXT: 201300: jmpq *8514(%rip)
// DISASM-NEXT: 201306: pushq $0
// DISASM-NEXT: 20130b: jmp -32 <.plt>
// DISASM-EMPTY:
// DISASM-NEXT: zed2@plt:
// DISASM-NEXT: 201310: jmpq *8506(%rip)
// DISASM-NEXT: 201316: pushq $1
// DISASM-NEXT: 20131b: jmp -48 <.plt>
// DISASM-EMPTY:
// DISASM-NEXT: Disassembly of section .iplt:
// DISASM-EMPTY:
// DISASM-NEXT: .iplt:
// DISASM-NEXT: 201320: jmpq *8498(%rip)
// DISASM-NEXT: 201326: pushq $0
// DISASM-NEXT: 20132b: jmp -64 <.plt>
// DISASM-NEXT: 201330: jmpq *8490(%rip)
// DISASM-NEXT: 201336: pushq $1
// DISASM-NEXT: 20133b: jmp -80 <.plt>
.text
.type foo STT_GNU_IFUNC
.globl foo
foo:
ret
.type bar STT_GNU_IFUNC
.globl bar
bar:
ret
.globl _start
_start:
call foo
call bar
call bar2
call zed2