brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 3f2f4e9 Raw
89 lines · plain
1## This test verifies that the pair adrp + ldr is relaxed/not relaxed2## depending on the target symbol properties.3 4# REQUIRES: aarch645# RUN: rm -rf %t && split-file %s %t6 7# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/symbols.s -o %t/symbols.o8# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/abs.s -o %t/abs.o9 10# RUN: ld.lld -shared -T %t/linker.t %t/symbols.o %t/abs.o -o %t/symbols.so11# RUN: llvm-objdump --no-show-raw-insn -d %t/symbols.so | \12# RUN:   FileCheck --check-prefix=LIB %s13 14## Symbol 'hidden_sym' is nonpreemptible, the relaxation should be applied.15LIB:      adrp   x016LIB-NEXT: add    x017 18## Symbol 'global_sym' is preemptible, no relaxations should be applied.19LIB-NEXT: adrp   x120LIB-NEXT: ldr    x121 22## Symbol 'undefined_sym' is undefined, no relaxations should be applied.23LIB-NEXT: adrp   x224LIB-NEXT: ldr    x225 26## Symbol 'ifunc_sym' is STT_GNU_IFUNC, no relaxations should be applied.27LIB-NEXT: adrp   x328LIB-NEXT: ldr    x329 30## Symbol 'abs_sym' is absolute, no relaxations should be applied.31LIB-NEXT: adrp   x432LIB-NEXT: ldr    x433 34# RUN: ld.lld -T %t/linker.t -z undefs %t/symbols.o %t/abs.o -o %t/symbols35# RUN: llvm-objdump --no-show-raw-insn -d %t/symbols | \36# RUN:   FileCheck --check-prefix=EXE %s37 38## Symbol 'global_sym' is nonpreemptible, the relaxation should be applied.39EXE:      adrp   x140EXE-NEXT: add    x141 42## Symbol 'abs_sym' is absolute, relaxations may be applied in -no-pie mode.43EXE:      adrp   x444EXE-NEXT: add    x445 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.t49SECTIONS {50 .rodata 0x1000: { *(.rodata) }51 .text   0x300100: { *(.text) }52}53 54# This symbol is defined in a separate file to prevent the definition from55# being folded into the instructions that reference it.56#--- abs.s57.global abs_sym58.hidden abs_sym59abs_sym = 0x100060 61#--- symbols.s62.rodata63.hidden hidden_sym64hidden_sym:65.word 1066 67.global global_sym68global_sym:69.word 1070 71.text72.type ifunc_sym STT_GNU_IFUNC73.hidden ifunc_sym74ifunc_sym:75  nop76 77.global _start78_start:79  adrp    x0, :got:hidden_sym80  ldr     x0, [x0, #:got_lo12:hidden_sym]81  adrp    x1, :got:global_sym82  ldr     x1, [x1, #:got_lo12:global_sym]83  adrp    x2, :got:undefined_sym84  ldr     x2, [x2, #:got_lo12:undefined_sym]85  adrp    x3, :got:ifunc_sym86  ldr     x3, [x3, #:got_lo12:ifunc_sym]87  adrp    x4, :got:abs_sym88  ldr     x4, [x4, #:got_lo12:abs_sym]89