|
| 1 | +// REQUIRES: aarch64 |
| 2 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o |
| 3 | +// RUN: echo "SECTIONS { \ |
| 4 | +// RUN: .text 0x10000 : { \ |
| 5 | +// RUN: *(.text.01) ; \ |
| 6 | +// RUN: . += 0x8000000 ; \ |
| 7 | +// RUN: *(.text.02) } \ |
| 8 | +// RUN: .foo : { *(.foo_sec) } } " > %t.script |
| 9 | +// RUN: ld.lld -pie --fix-cortex-a53-843419 --script=%t.script %t.o -o %t2 |
| 10 | +// RUN: llvm-objdump --no-show-raw-insn -triple=aarch64-linux-gnu -d %t2 |
| 11 | + |
| 12 | + |
| 13 | +/// %t2 is > 128 Megabytes, so delete it early. |
| 14 | +// RUN: rm %t2 |
| 15 | + |
| 16 | +/// Test case that for an OutputSection larger than the ThunkSectionSpacing |
| 17 | +/// --fix-cortex-a53-843419 will cause the size of the ThunkSection to be |
| 18 | +/// rounded up to the nearest 4KiB |
| 19 | + |
| 20 | + .section .text.01, "ax", %progbits |
| 21 | + .balign 4096 |
| 22 | + .globl _start |
| 23 | + .type _start, %function |
| 24 | +_start: |
| 25 | +/// Range extension thunk needed, due to linker script |
| 26 | + bl far_away |
| 27 | + .space 4096 - 12 |
| 28 | + |
| 29 | +/// Erratum sequence |
| 30 | + .globl t3_ff8_ldr |
| 31 | + .type t3_ff8_ldr, %function |
| 32 | +t3_ff8_ldr: |
| 33 | + adrp x0, dat |
| 34 | + ldr x1, [x1, #0] |
| 35 | + ldr x0, [x0, :lo12:dat] |
| 36 | + ret |
| 37 | + |
| 38 | +/// Expect thunk and patch to be inserted here |
| 39 | +// CHECK: 0000000000011008 __AArch64ADRPThunk_far_away: |
| 40 | +// CHECK-NEXT: 11008: adrp x16, #134221824 |
| 41 | +// CHECK-NEXT: add x16, x16, #16 |
| 42 | +// CHECK-NEXT: br x16 |
| 43 | +// CHECK: 0000000000012008 __CortexA53843419_11000: |
| 44 | +// CHECK-NEXT: 12008: ldr x0, [x0, #168] |
| 45 | +// CHECK-NEXT: b #-4104 <t3_ff8_ldr+0xc> |
| 46 | + |
| 47 | + .section .text.02, "ax", %progbits |
| 48 | + .globl far_away |
| 49 | + .type far_away, function |
| 50 | +far_away: |
| 51 | + bl _start |
| 52 | + ret |
| 53 | +/// Expect thunk for _start not to have size rounded up to 4KiB as it is at |
| 54 | +/// the end of the OutputSection |
| 55 | +// CHECK: 0000000008012010 far_away: |
| 56 | +// CHECK-NEXT: 8012010: bl #8 |
| 57 | +// CHECK-NEXT: ret |
| 58 | +// CHECK: 0000000008012018 __AArch64ADRPThunk__start: |
| 59 | +// CHECK-NEXT: 8012018: adrp x16, #-134225920 |
| 60 | +// CHECK-NEXT: add x16, x16, #0 |
| 61 | +// CHECK-NEXT: br x16 |
| 62 | +// CHECK: 0000000008012024 foo: |
| 63 | +// CHECK-NEXT: 8012024: ret |
| 64 | + .section .foo_sec, "ax", %progbits |
| 65 | + .globl foo |
| 66 | + .type foo, function |
| 67 | +foo: |
| 68 | + ret |
| 69 | + |
| 70 | + |
| 71 | + .section .data |
| 72 | + .balign 8 |
| 73 | + .globl dat |
| 74 | +dat: .quad 0 |
0 commit comments