99 lines · plain
1// REQUIRES: aarch642// RUN: split-file %s %t3// RUN: llvm-mc -filetype=obj -triple=aarch64 --asm-macro-max-nesting-depth=40000 %t/asm -o %t.o4// RUN: ld.lld -T %t/lds -fix-cortex-a53-843419 %t.o -o %t2 --print-map 2>&1 | FileCheck %s5/// %t2 is more than 128MiB. Delete it early.6// RUN: rm %t.o %t27 8//--- asm9/// We use %(\parameter) to evaluate expression, which requires .altmacro.10 .altmacro11 12/// Test to reproduce the conditions that trigger R_AARCH64_JUMP26 out of range13/// errors in pr44071. We create a large number of patches and thunks, with an14/// LLD with the fault, the patches will be inserted after the thunks and due15/// 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 sequence22 .macro ERRATA from, to23 .balign 409624 .space 4096 - 825 adrp x0, dat126 ldr x1, [x1, #0]27 ldr x0, [x0, :got_lo12:dat1]28 ret29 .if (\to-\from)30 ERRATA %(\from+1),\to31 .endif32 .endm33 34 .section .text.01, "ax", %progbits35 .balign 409636 .globl _start37 .type _start, %function38 .space 4096 - 839_start:40/// Generate lots of patches.41 ERRATA 0, 400042 43 .macro CALLS from, to44 bl far\from45 .if (\to-\from)46 CALLS %(\from+1),\to47 .endif48 .endm49 50 /// Generate long range thunks. These are inserted before the patches. Generate51 /// a sufficient number such that the patches must be placed before the52 /// .text.thunk section, and if they aren't some of the patches go out of53 /// range.54 .section .text.02, "ax", %progbits55 .global func56 .type func, %function57func:58 CALLS 0, 2000059 60 .section .text.03, "ax", %progbits61 .global space162space1:63 .space (1024 * 1024 * 96) + (120 * 4 * 1024)64 .balign 409665 66 .section .text.04, "ax", %progbits67 .global space268space2:69 .space 1024 * 102470 71 .macro DEFS from, to72 .global far\from73 .type far\from, %function74far\from:75 ret76 .if (\to-\from)77 DEFS %(\from+1),\to78 .endif79 .endm80 81 /// Define the thunk targets82 .section .target, "ax", %progbits83 DEFS 0, 2000084 85 .data86 .global dat187dat1:88 .xword 089 90//--- lds91PHDRS {92 low PT_LOAD FLAGS(0x1 | 0x4);93 high PT_LOAD FLAGS(0x1 | 0x4);94}95SECTIONS {96 .text1 0x10000 : { *(.text.*) } :low97 .text2 0xf010000 : { *(.target) } :high98}99