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