[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / gnu-ifunc-plt.s
blob58fae803a0e52db4e67644d317f4564165fd6cbe
1 // REQUIRES: x86
3 /// For non-preemptable ifunc, place ifunc PLT entries to the .iplt section.
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 --print-imm-hex %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
13 /// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
14 // CHECK: DynamicSection [
15 // CHECK: 0x0000000000000008 RELASZ 72 (bytes)
16 // CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes)
18 /// Check that the IRELATIVE relocations are placed to the .rela.dyn section after
19 /// other regular relocations (e.g. GLOB_DAT).
20 // CHECK: Relocations [
21 // CHECK-NEXT: Section (4) .rela.dyn {
22 // CHECK-NEXT: 0x202480 R_X86_64_GLOB_DAT bar3 0x0
23 // CHECK-NEXT: 0x2034B0 R_X86_64_IRELATIVE - 0x201318
24 // CHECK-NEXT: 0x2034B8 R_X86_64_IRELATIVE - 0x201319
25 // CHECK-NEXT: }
26 // CHECK-NEXT: Section (5) .rela.plt {
27 // CHECK-NEXT: 0x2034A0 R_X86_64_JUMP_SLOT bar2 0x0
28 // CHECK-NEXT: 0x2034A8 R_X86_64_JUMP_SLOT zed2 0x0
29 // CHECK-NEXT: }
31 /// Check that .got.plt entries point back to PLT header
32 // GOTPLT: Contents of section .got.plt:
33 // GOTPLT-NEXT: 203488 90232000 00000000 00000000 00000000
34 // GOTPLT-NEXT: 203498 00000000 00000000 56132000 00000000
35 // GOTPLT-NEXT: 2034a8 66132000 00000000 00000000 00000000
36 // GOTPLT-NEXT: 2034b8 00000000 00000000
38 /// Check that we have 2 PLT sections: one regular .plt section and one
39 /// .iplt section for ifunc entries.
40 // DISASM: Disassembly of section .text:
41 // DISASM-EMPTY:
42 // DISASM-NEXT: <foo>:
43 // DISASM-NEXT: 201318: retq
44 // DISASM: <bar>:
45 // DISASM-NEXT: 201319: retq
46 // DISASM: <_start>:
47 // DISASM-NEXT: 20131a: callq 0x201370
48 // DISASM-NEXT: 20131f: callq 0x201380
49 // DISASM-NEXT: callq {{.*}} <bar2@plt>
50 // DISASM-NEXT: callq {{.*}} <zed2@plt>
51 // DISASM-NEXT: jmpq *0x114c(%rip)
52 // DISASM-EMPTY:
53 // DISASM-NEXT: Disassembly of section .plt:
54 // DISASM-EMPTY:
55 // DISASM-NEXT: <.plt>:
56 // DISASM-NEXT: 201340: pushq 0x214a(%rip)
57 // DISASM-NEXT: 201346: jmpq *0x214c(%rip)
58 // DISASM-NEXT: 20134c: nopl (%rax)
59 // DISASM-EMPTY:
60 // DISASM-NEXT: <bar2@plt>:
61 // DISASM-NEXT: 201350: jmpq *0x214a(%rip)
62 // DISASM-NEXT: 201356: pushq $0x0
63 // DISASM-NEXT: 20135b: jmp 0x201340 <.plt>
64 // DISASM-EMPTY:
65 // DISASM-NEXT: <zed2@plt>:
66 // DISASM-NEXT: 201360: jmpq *0x2142(%rip)
67 // DISASM-NEXT: 201366: pushq $0x1
68 // DISASM-NEXT: 20136b: jmp 0x201340 <.plt>
69 // DISASM-EMPTY:
70 // DISASM-NEXT: Disassembly of section .iplt:
71 // DISASM-EMPTY:
72 // DISASM-NEXT: <.iplt>:
73 // DISASM-NEXT: 201370: jmpq *0x213a(%rip)
74 // DISASM-NEXT: 201376: pushq $0x0
75 // DISASM-NEXT: 20137b: jmp 0x201340 <.plt>
76 // DISASM-NEXT: 201380: jmpq *0x2132(%rip)
77 // DISASM-NEXT: 201386: pushq $0x1
78 // DISASM-NEXT: 20138b: jmp 0x201340 <.plt>
80 // Test that --shuffle-sections does not affect the order of relocations and that
81 // we still place IRELATIVE relocations last. Check both random seed (0) and an
82 // arbitrary seed that was known to break the order of relocations previously (3).
83 // RUN: ld.lld --shuffle-sections='*=3' %t.so %t.o -o %tout2
84 // RUN: llvm-readobj --relocations %tout2 | FileCheck %s --check-prefix=SHUFFLE
85 // RUN: ld.lld --shuffle-sections='*=0' %t.so %t.o -o %tout3
86 // RUN: llvm-readobj --relocations %tout3 | FileCheck %s --check-prefix=SHUFFLE
88 // SHUFFLE: Section {{.*}} .rela.dyn {
89 // SHUFFLE-NEXT: R_X86_64_GLOB_DAT
90 // SHUFFLE-NEXT: R_X86_64_IRELATIVE
91 // SHUFFLE-NEXT: R_X86_64_IRELATIVE
92 // SHUFFLE-NEXT: }
94 .text
95 .type foo STT_GNU_IFUNC
96 .globl foo
97 foo:
98 ret
100 .type bar STT_GNU_IFUNC
101 .globl bar
102 bar:
105 .globl _start
106 _start:
107 call foo
108 call bar
109 call bar2
110 call zed2
111 jmp *bar3@GOTPCREL(%rip)