|
| 1 | +// REQUIRES: aarch64 |
| 2 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux --asm-macro-max-nesting-depth=40000 %s -o %t.o |
| 3 | +// RUN: echo "SECTIONS { \ |
| 4 | +// RUN: .text1 0x10000 : { *(.text.*) } \ |
| 5 | +// RUN: .text2 0xf010000 : { *(.target) } } " > %t.script |
| 6 | +// RUN: ld.lld --script %t.script -fix-cortex-a53-843419 %t.o -o %t2 --print-map 2>&1 | FileCheck %s |
| 7 | + |
| 8 | +/// We use %(\parameter) to evaluate expression, which requires .altmacro. |
| 9 | + .altmacro |
| 10 | + |
| 11 | +/// Test to reproduce the conditions that trigger R_AARCH64_JUMP26 out of range |
| 12 | +/// errors in pr44071. We create a large number of patches and thunks, with an |
| 13 | +/// LLD with the fault, the patches will be inserted after the thunks and due |
| 14 | +/// to the size of the thunk section some of the patches go out of range. |
| 15 | +/// With a fixed LLD the patches are inserted before the thunks. |
| 16 | + |
| 17 | +// CHECK: <internal>:(.text.patch) |
| 18 | +// CHECK: <internal>:(.text.thunk) |
| 19 | + |
| 20 | +/// Macro to generate the cortex-a53-843419 patch sequence |
| 21 | + .macro ERRATA from, to |
| 22 | + .balign 4096 |
| 23 | + .space 4096 - 8 |
| 24 | + adrp x0, dat1 |
| 25 | + ldr x1, [x1, #0] |
| 26 | + ldr x0, [x0, :got_lo12:dat1] |
| 27 | + ret |
| 28 | + .if (\to-\from) |
| 29 | + ERRATA %(\from+1),\to |
| 30 | + .endif |
| 31 | + .endm |
| 32 | + |
| 33 | + .section .text.01, "ax", %progbits |
| 34 | + .balign 4096 |
| 35 | + .globl _start |
| 36 | + .type _start, %function |
| 37 | + .space 4096 - 8 |
| 38 | +_start: |
| 39 | +/// Generate lots of patches. |
| 40 | + ERRATA 0, 4000 |
| 41 | + |
| 42 | + .macro CALLS from, to |
| 43 | + bl far\from |
| 44 | + .if (\to-\from) |
| 45 | + CALLS %(\from+1),\to |
| 46 | + .endif |
| 47 | + .endm |
| 48 | + |
| 49 | + /// Generate long range thunks. These are inserted before the patches. Generate |
| 50 | + /// a sufficient number such that the patches must be placed before the |
| 51 | + /// .text.thunk section, and if they aren't some of the patches go out of |
| 52 | + /// range. |
| 53 | + .section .text.02, "ax", %progbits |
| 54 | + .global func |
| 55 | + .type func, %function |
| 56 | +func: |
| 57 | + CALLS 0, 20000 |
| 58 | + |
| 59 | + .section .text.03, "ax", %progbits |
| 60 | + .global space1 |
| 61 | +space1: |
| 62 | + .space (1024 * 1024 * 96) + (120 * 4 * 1024) |
| 63 | + .balign 4096 |
| 64 | + |
| 65 | + .section .text.04, "ax", %progbits |
| 66 | + .global space2 |
| 67 | +space2: |
| 68 | + .space 1024 * 1024 |
| 69 | + |
| 70 | + .macro DEFS from, to |
| 71 | + .global far\from |
| 72 | + .type far\from, %function |
| 73 | +far\from: |
| 74 | + ret |
| 75 | + .if (\to-\from) |
| 76 | + DEFS %(\from+1),\to |
| 77 | + .endif |
| 78 | + .endm |
| 79 | + |
| 80 | + /// Define the thunk targets |
| 81 | + .section .target, "ax", %progbits |
| 82 | + DEFS 0, 20000 |
| 83 | + |
| 84 | + .data |
| 85 | + .global dat1 |
| 86 | +dat1: |
| 87 | + .xword 0 |
0 commit comments