Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / aarch64-gnu-ifunc-plt.s
blob065aa3b36281fc6359d6f7039450ad60ceaae550
1 // REQUIRES: aarch64
2 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %S/Inputs/shared2.s -o %t1.o
3 // RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so
4 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
5 // RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout
6 // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
7 // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
8 // RUN: llvm-readobj --dynamic-table -r %tout | FileCheck %s
10 // RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/shared2.s -o %t1.be.o
11 // RUN: ld.lld %t1.be.o --shared --soname=t.so -o %t.be.so
12 // RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
13 // RUN: ld.lld --hash-style=sysv %t.be.so %t.be.o -o %t.be
14 // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.be | FileCheck %s --check-prefix=DISASM
15 // RUN: llvm-objdump -s %t.be | FileCheck %s --check-prefix=GOTPLT_BE
16 // RUN: llvm-readobj --dynamic-table -r %t.be | FileCheck %s
18 // Check that the PLTRELSZ tag does not include the IRELATIVE relocations
19 // CHECK: DynamicSection [
20 // CHECK: 0x0000000000000008 RELASZ 48 (bytes)
21 // CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes)
23 // Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
24 // CHECK: Relocations [
25 // CHECK-NEXT: Section (4) .rela.dyn {
26 // CHECK-NEXT: 0x230468 R_AARCH64_IRELATIVE - 0x2102D8
27 // CHECK-NEXT: 0x230470 R_AARCH64_IRELATIVE - 0x2102DC
28 // CHECK-NEXT: }
29 // CHECK-NEXT: Section (5) .rela.plt {
30 // CHECK-NEXT: 0x230458 R_AARCH64_JUMP_SLOT bar2 0x0
31 // CHECK-NEXT: 0x230460 R_AARCH64_JUMP_SLOT zed2 0x0
32 // CHECK-NEXT: }
33 // CHECK-NEXT: ]
35 // Check that .got.plt entries point back to PLT header
36 // GOTPLT: Contents of section .got.plt:
37 // GOTPLT-NEXT: 230440 00000000 00000000 00000000 00000000
38 // GOTPLT-NEXT: 230450 00000000 00000000 f0022100 00000000
39 // GOTPLT-NEXT: 230460 f0022100 00000000 00000000 00000000
40 // GOTPLT-NEXT: 230470 00000000 00000000
42 // GOTPLT_BE: Contents of section .got.plt:
43 // GOTPLT_BE-NEXT: 230440 00000000 00000000 00000000 00000000
44 // GOTPLT_BE-NEXT: 230450 00000000 00000000 00000000 002102f0
45 // GOTPLT_BE-NEXT: 230460 00000000 002102f0 00000000 00000000
46 // GOTPLT_BE-NEXT: 230470 00000000 00000000
48 // Check that a PLT header is written and the ifunc entries appear last
49 // DISASM: Disassembly of section .text:
50 // DISASM-EMPTY:
51 // DISASM-NEXT: <foo>:
52 // DISASM-NEXT: 2102d8: ret
53 // DISASM: <bar>:
54 // DISASM-NEXT: 2102dc: ret
55 // DISASM: <_start>:
56 // DISASM-NEXT: 2102e0: bl 0x210330 <zed2+0x210330>
57 // DISASM-NEXT: 2102e4: bl 0x210340 <zed2+0x210340>
58 // DISASM-NEXT: 2102e8: bl 0x210310 <bar2@plt>
59 // DISASM-NEXT: 2102ec: bl 0x210320 <zed2@plt>
60 // DISASM-EMPTY:
61 // DISASM-NEXT: Disassembly of section .plt:
62 // DISASM-EMPTY:
63 // DISASM-NEXT: <.plt>:
64 // DISASM-NEXT: 2102f0: stp x16, x30, [sp, #-16]!
65 // DISASM-NEXT: 2102f4: adrp x16, 0x230000
66 // DISASM-NEXT: 2102f8: ldr x17, [x16, #1104]
67 // DISASM-NEXT: 2102fc: add x16, x16, #1104
68 // DISASM-NEXT: 210300: br x17
69 // DISASM-NEXT: 210304: nop
70 // DISASM-NEXT: 210308: nop
71 // DISASM-NEXT: 21030c: nop
72 // DISASM-EMPTY:
73 // DISASM-NEXT: <bar2@plt>:
74 // DISASM-NEXT: 210310: adrp x16, 0x230000
75 // DISASM-NEXT: 210314: ldr x17, [x16, #1112]
76 // DISASM-NEXT: 210318: add x16, x16, #1112
77 // DISASM-NEXT: 21031c: br x17
78 // DISASM-EMPTY:
79 // DISASM-NEXT: <zed2@plt>:
80 // DISASM-NEXT: 210320: adrp x16, 0x230000
81 // DISASM-NEXT: 210324: ldr x17, [x16, #1120]
82 // DISASM-NEXT: 210328: add x16, x16, #1120
83 // DISASM-NEXT: 21032c: br x17
84 // DISASM-EMPTY:
85 // DISASM-NEXT: Disassembly of section .iplt:
86 // DISASM-EMPTY:
87 // DISASM-NEXT: <.iplt>:
88 // DISASM-NEXT: 210330: adrp x16, 0x230000
89 // DISASM-NEXT: 210334: ldr x17, [x16, #1128]
90 // DISASM-NEXT: 210338: add x16, x16, #1128
91 // DISASM-NEXT: 21033c: br x17
92 // DISASM-NEXT: 210340: adrp x16, 0x230000
93 // DISASM-NEXT: 210344: ldr x17, [x16, #1136]
94 // DISASM-NEXT: 210348: add x16, x16, #1136
95 // DISASM-NEXT: 21034c: br x17
97 .text
98 .type foo STT_GNU_IFUNC
99 .globl foo
100 foo:
103 .type bar STT_GNU_IFUNC
104 .globl bar
105 bar:
108 .globl _start
109 _start:
110 bl foo
111 bl bar
112 bl bar2
113 bl zed2