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