[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / lld / test / ELF / aarch64-adrp-ldr-got-symbols.s
blob3f2f4e953d7d2e1b4be76de2f8501e26dbd12e8f
1 ## This test verifies that the pair adrp + ldr is relaxed/not relaxed
2 ## depending on the target symbol properties.
4 # REQUIRES: aarch64
5 # RUN: rm -rf %t && split-file %s %t
7 # RUN: llvm-mc -filetype=obj -triple=aarch64 %t/symbols.s -o %t/symbols.o
8 # RUN: llvm-mc -filetype=obj -triple=aarch64 %t/abs.s -o %t/abs.o
10 # RUN: ld.lld -shared -T %t/linker.t %t/symbols.o %t/abs.o -o %t/symbols.so
11 # RUN: llvm-objdump --no-show-raw-insn -d %t/symbols.so | \
12 # RUN: FileCheck --check-prefix=LIB %s
14 ## Symbol 'hidden_sym' is nonpreemptible, the relaxation should be applied.
15 LIB: adrp x0
16 LIB-NEXT: add x0
18 ## Symbol 'global_sym' is preemptible, no relaxations should be applied.
19 LIB-NEXT: adrp x1
20 LIB-NEXT: ldr x1
22 ## Symbol 'undefined_sym' is undefined, no relaxations should be applied.
23 LIB-NEXT: adrp x2
24 LIB-NEXT: ldr x2
26 ## Symbol 'ifunc_sym' is STT_GNU_IFUNC, no relaxations should be applied.
27 LIB-NEXT: adrp x3
28 LIB-NEXT: ldr x3
30 ## Symbol 'abs_sym' is absolute, no relaxations should be applied.
31 LIB-NEXT: adrp x4
32 LIB-NEXT: ldr x4
34 # RUN: ld.lld -T %t/linker.t -z undefs %t/symbols.o %t/abs.o -o %t/symbols
35 # RUN: llvm-objdump --no-show-raw-insn -d %t/symbols | \
36 # RUN: FileCheck --check-prefix=EXE %s
38 ## Symbol 'global_sym' is nonpreemptible, the relaxation should be applied.
39 EXE: adrp x1
40 EXE-NEXT: add x1
42 ## Symbol 'abs_sym' is absolute, relaxations may be applied in -no-pie mode.
43 EXE: adrp x4
44 EXE-NEXT: add x4
46 ## The linker script ensures that .rodata and .text are sufficiently (>1MB)
47 ## far apart so that the adrp + ldr pair cannot be relaxed to adr + nop.
48 #--- linker.t
49 SECTIONS {
50 .rodata 0x1000: { *(.rodata) }
51 .text 0x300100: { *(.text) }
54 # This symbol is defined in a separate file to prevent the definition from
55 # being folded into the instructions that reference it.
56 #--- abs.s
57 .global abs_sym
58 .hidden abs_sym
59 abs_sym = 0x1000
61 #--- symbols.s
62 .rodata
63 .hidden hidden_sym
64 hidden_sym:
65 .word 10
67 .global global_sym
68 global_sym:
69 .word 10
71 .text
72 .type ifunc_sym STT_GNU_IFUNC
73 .hidden ifunc_sym
74 ifunc_sym:
75 nop
77 .global _start
78 _start:
79 adrp x0, :got:hidden_sym
80 ldr x0, [x0, #:got_lo12:hidden_sym]
81 adrp x1, :got:global_sym
82 ldr x1, [x1, #:got_lo12:global_sym]
83 adrp x2, :got:undefined_sym
84 ldr x2, [x2, #:got_lo12:undefined_sym]
85 adrp x3, :got:ifunc_sym
86 ldr x3, [x3, #:got_lo12:ifunc_sym]
87 adrp x4, :got:abs_sym
88 ldr x4, [x4, #:got_lo12:abs_sym]