1 ## This test verifies that the pair adrp + ldr is relaxed/not relaxed
2 ## depending on the target symbol properties.
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.
18 ## Symbol 'global_sym' is preemptible, no relaxations should be applied.
22 ## Symbol 'undefined_sym' is undefined, no relaxations should be applied.
26 ## Symbol 'ifunc_sym' is STT_GNU_IFUNC, no relaxations should be applied.
30 ## Symbol 'abs_sym' is absolute, no relaxations should be applied.
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.
42 ## Symbol 'abs_sym' is absolute, relaxations may be applied in -no-pie mode.
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.
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.
72 .type ifunc_sym STT_GNU_IFUNC
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]
88 ldr x4
, [x4
, #:got_lo12:abs_sym]