[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / aarch64-cortex-a53-843419-large.s
blobe4b0c0ff936851bcd14994e6f296e2b35b81cf3f
1 // REQUIRES: aarch64
2 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
3 // RUN: ld.lld --fix-cortex-a53-843419 -z separate-code %t.o -o %t2
4 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x210000 --stop-address=0x21000c | FileCheck --check-prefix=CHECK1 %s
5 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x211000 --stop-address=0x211004 | FileCheck --check-prefix=CHECK2 %s
6 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x211ff8 --stop-address=0x212008 | FileCheck --check-prefix=CHECK3 %s
7 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x4213ff8 --stop-address=0x4214008 | FileCheck --check-prefix=CHECK4 %s
8 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x6214008 --stop-address=0x6214018 | FileCheck --check-prefix=CHECK5 %s
9 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x821100c --stop-address=0x8211010 | FileCheck --check-prefix=CHECK6 %s
10 // RUN: llvm-objdump --triple=aarch64-linux-gnu -d %t2 --start-address=0x8211ffc --stop-address=0x8212014 | FileCheck --check-prefix=CHECK7 %s
11 // RUN: rm %t.o %t2
12 // Test case for Cortex-A53 Erratum 843419 in an OutputSection exceeding
13 // the maximum branch range. Both range extension thunks and patches are
14 // required.
16 // CHECK1: <__AArch64AbsLongThunk_need_thunk_after_patch>:
17 // CHECK1-NEXT: 210000: 50 00 00 58 ldr x16, 0x210008
18 // CHECK1-NEXT: 210004: 00 02 1f d6 br x16
19 // CHECK1: <$d>:
20 // CHECK1-NEXT: 210008: 0c 10 21 08 .word 0x0821100c
22 .section .text.01, "ax", %progbits
23 .balign 4096
24 .globl _start
25 .type _start, %function
26 _start:
27 // Expect thunk on pass 2
28 bl need_thunk_after_patch
29 .section .text.02, "ax", %progbits
30 .space 4096 - 12
32 // CHECK2: <_start>:
33 // CHECK2-NEXT: 211000: 00 fc ff 97 bl 0x210000
35 // Expect patch on pass 1
36 .section .text.03, "ax", %progbits
37 .globl t3_ff8_ldr
38 .type t3_ff8_ldr, %function
39 t3_ff8_ldr:
40 adrp x0, dat
41 ldr x1, [x1, #0]
42 ldr x0, [x0, :got_lo12:dat]
43 ret
45 // CHECK3: <t3_ff8_ldr>:
46 // CHECK3-NEXT: 211ff8: e0 00 04 f0 adrp x0, 0x8230000
47 // CHECK3-NEXT: 211ffc: 21 00 40 f9 ldr x1, [x1]
48 // CHECK3-NEXT: 212000: 02 08 80 15 b 0x6214008
49 // CHECK3-NEXT: 212004: c0 03 5f d6 ret
51 .section .text.04, "ax", %progbits
52 .space 64 * 1024 * 1024
54 // Expect patch on pass 1
55 .section .text.05, "ax", %progbits
56 .balign 4096
57 .space 4096 - 8
58 .globl t3_ff8_str
59 .type t3_ff8_str, %function
60 t3_ff8_str:
61 adrp x0, dat
62 ldr x1, [x1, #0]
63 str x0, [x0, :got_lo12:dat]
64 ret
66 // CHECK4: <t3_ff8_str>:
67 // CHECK4-NEXT: 4213ff8: e0 00 02 b0 adrp x0, 0x8230000
68 // CHECK4-NEXT: 4213ffc: 21 00 40 f9 ldr x1, [x1]
69 // CHECK4-NEXT: 4214000: 04 00 80 14 b 0x6214010
70 // CHECK4-NEXT: 4214004: c0 03 5f d6 ret
72 .section .text.06, "ax", %progbits
73 .space 32 * 1024 * 1024
75 // CHECK5: <__CortexA53843419_211000>:
76 // CHECK5-NEXT: 6214008: 00 00 40 f9 ldr x0, [x0]
77 // CHECK5-NEXT: 621400c: fe f7 7f 16 b 0x212004
78 // CHECK5: <__CortexA53843419_4213000>:
79 // CHECK5-NEXT: 6214010: 00 00 00 f9 str x0, [x0]
80 // CHECK5-NEXT: 6214014: fc ff 7f 17 b 0x4214004
82 .section .text.07, "ax", %progbits
83 .space (32 * 1024 * 1024) - 12300
85 .section .text.08, "ax", %progbits
86 .globl need_thunk_after_patch
87 .type need_thunk_after_patch, %function
88 need_thunk_after_patch:
89 ret
91 // CHECK6: <need_thunk_after_patch>:
92 // CHECK6-NEXT: 821100c: c0 03 5f d6 ret
94 // Will need a patch on pass 2
95 .section .text.09, "ax", %progbits
96 .space 4096 - 20
97 .globl t3_ffc_ldr
98 .type t3_ffc_ldr, %function
99 t3_ffc_ldr:
100 adrp x0, dat
101 ldr x1, [x1, #0]
102 ldr x0, [x0, :got_lo12:dat]
105 // CHECK7: <t3_ffc_ldr>:
106 // CHECK7-NEXT: 8211ffc: e0 00 00 f0 adrp x0, 0x8230000
107 // CHECK7-NEXT: 8212000: 21 00 40 f9 ldr x1, [x1]
108 // CHECK7-NEXT: 8212004: 02 00 00 14 b 0x821200c
109 // CHECK7-NEXT: 8212008: c0 03 5f d6 ret
110 // CHECK7: <__CortexA53843419_8212004>:
111 // CHECK7-NEXT: 821200c: 00 00 40 f9 ldr x0, [x0]
112 // CHECK7-NEXT: 8212010: fe ff ff 17 b 0x8212008
114 .section .data
115 .globl dat
116 dat: .quad 0