108 lines · plain
1# REQUIRES: aarch642# RUN: rm -rf %t && split-file %s %t3 4# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o5# RUN: ld.lld %t/a.o -T %t/out-of-adr-range-low.t -o %t/a-low6# RUN: llvm-objdump --no-show-raw-insn -d %t/a-low | FileCheck %s --check-prefix=OUT-OF-RANGE7# RUN: ld.lld %t/a.o -T %t/out-of-adr-range-high.t -o %t/a-high8# RUN: llvm-objdump --no-show-raw-insn -d %t/a-high | FileCheck %s --check-prefix=OUT-OF-RANGE9 10# OUT-OF-RANGE: adrp x3011# OUT-OF-RANGE-NEXT: add x30, x3012 13# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o14# RUN: ld.lld %t/a.o -T %t/within-adr-range-low.t -o %t/a-low15# RUN: llvm-objdump --no-show-raw-insn -d %t/a-low | FileCheck %s --check-prefix=IN-RANGE-LOW16 17# IN-RANGE-LOW: nop18# IN-RANGE-LOW-NEXT: adr x3019# IN-RANGE-LOW-NEXT: adrp x120# IN-RANGE-LOW-NEXT: add x121# IN-RANGE-LOW-NEXT: adrp x1522# IN-RANGE-LOW-NEXT: add x1523 24## ADRP and ADD use different registers, no relaxations should be applied.25# IN-RANGE-LOW-NEXT: adrp x226# IN-RANGE-LOW-NEXT: add x3, x227 28## ADRP and ADD use different registers, no relaxations should be applied.29# IN-RANGE-LOW-NEXT: adrp x230# IN-RANGE-LOW-NEXT: add x2, x331 32# RUN: ld.lld %t/a.o -T %t/within-adr-range-high.t -o %t/a-high33# RUN: llvm-objdump --no-show-raw-insn -d %t/a-high | FileCheck %s --check-prefix=IN-RANGE-HIGH34 35# IN-RANGE-HIGH: nop36# IN-RANGE-HIGH-NEXT: adr x3037# IN-RANGE-HIGH-NEXT: nop38# IN-RANGE-HIGH-NEXT: adr x139# IN-RANGE-HIGH-NEXT: nop40# IN-RANGE-HIGH-NEXT: adr x1541 42## ADRP and ADD use different registers, no relaxations should be applied.43# IN-RANGE-HIGH-NEXT: adrp x244# IN-RANGE-HIGH-NEXT: add x3, x245 46## ADRP and ADD use different registers, no relaxations should be applied.47# IN-RANGE-HIGH-NEXT: adrp x248# IN-RANGE-HIGH-NEXT: add x2, x349 50# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o51# RUN: ld.lld %t/a.o -T %t/within-adr-range-low.t --no-relax -o %t/a52## --no-relax disables relaxations.53# RUN: llvm-objdump --no-show-raw-insn -d %t/a | FileCheck %s --check-prefix=OUT-OF-RANGE54 55## .rodata and .text are close to each other,56## the adrp + add pair can be relaxed to nop + adr, moreover, the address difference57## is equal to the lowest allowed value.58#--- within-adr-range-low.t59SECTIONS {60 .rodata 0x1000: { *(.rodata) }61 .text 0x100ffc: { *(.text) }62}63 64## .rodata and .text are far apart,65## the adrp + add pair cannot be relaxed to nop + adr, moreover, the address difference66## is equal to the lowest allowed value minus one.67#--- out-of-adr-range-low.t68SECTIONS {69 .rodata 0x1000: { *(.rodata) }70 .text 0x100ffd: { *(.text) }71}72 73## .rodata and .text are close to each other,74## the adrp + add pair can be relaxed to nop + adr, moreover, the address difference75## is equal to the highest allowed value.76#--- within-adr-range-high.t77SECTIONS {78 .text 0x1000: { *(.text) }79 .rodata 0x101003: { *(.rodata) }80}81 82## .rodata and .text are far apart,83## the adrp + add pair cannot be relaxed to nop + adr, moreover, the address difference84## is equal to the highest allowed value plus one.85#--- out-of-adr-range-high.t86SECTIONS {87 .text 0x1000: { *(.text) }88 .rodata 0x101004: { *(.rodata) }89}90 91#--- a.s92.rodata93x:94.word 1095.text96.global _start97_start:98 adrp x30, x99 add x30, x30, :lo12:x100 adrp x1, x101 add x1, x1, :lo12:x102 adrp x15, x103 add x15, x15, :lo12:x104 adrp x2, x105 add x3, x2, :lo12:x106 adrp x2, x107 add x2, x3, :lo12:x108