]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/aarch64-cortex-a53-843419-address.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / aarch64-cortex-a53-843419-address.s
1 // REQUIRES: aarch64
2 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
3 // RUN: echo "SECTIONS { \
4 // RUN:          .text : { *(.text) *(.text.*) *(.newisd) } \
5 // RUN:          .text2 : { *.(newos) } \
6 // RUN:          .data : { *(.data) } }" > %t.script
7 // RUN: ld.lld --script %t.script -fix-cortex-a53-843419 -verbose %t.o -o %t2 2>&1 \
8 // RUN:   | FileCheck -check-prefix=CHECK-PRINT %s
9 // RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s
10
11 // Test cases for Cortex-A53 Erratum 843419 that involve interactions
12 // between the generated patches and the address of sections.
13
14 // See ARM-EPM-048406 Cortex_A53_MPCore_Software_Developers_Errata_Notice.pdf
15 // for full erratum details.
16 // In Summary
17 // 1.)
18 // ADRP (0xff8 or 0xffc).
19 // 2.)
20 // - load or store single register or either integer or vector registers.
21 // - STP or STNP of either vector or vector registers.
22 // - Advanced SIMD ST1 store instruction.
23 // - Must not write Rn.
24 // 3.) optional instruction, can't be a branch, must not write Rn, may read Rn.
25 // 4.) A load or store instruction from the Load/Store register unsigned
26 // immediate class using Rn as the base register.
27
28 // An aarch64 section can contain ranges of literal data embedded within the
29 // code, these ranges are encoded with mapping symbols. This tests that we
30 // can match the erratum sequence in code, but not data.
31 // - We can handle more than one patch per code range (denoted by mapping
32 //   symbols).
33 // - We can handle a patch in more than range of code, with literal data
34 //   inbetween.
35 // - We can handle redundant mapping symbols (two or more consecutive mapping
36 //   symbols with the same type).
37 // - We can ignore erratum sequences in multiple literal data ranges.
38
39 // CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at FF8 in unpatched output.
40 // CHECK: t3_ff8_ldr:
41 // CHECK-NEXT:      ff8:        20 00 00 d0     adrp    x0, #24576
42 // CHECK-NEXT:      ffc:        21 00 40 f9     ldr             x1, [x1]
43 // CHECK-NEXT:     1000:        f9 0f 00 14     b       #16356
44 // CHECK-NEXT:     1004:        c0 03 5f d6     ret
45         .section .text.01, "ax", %progbits
46         .balign 4096
47         .space 4096 - 8
48         .globl t3_ff8_ldr
49         .type t3_ff8_ldr, %function
50 t3_ff8_ldr:
51         adrp x0, dat
52         ldr x1, [x1, #0]
53         ldr x0, [x0, :got_lo12:dat]
54         ret
55
56         // create a redundant mapping symbol as we are already in a $x range
57         // some object producers unconditionally generate a mapping symbol on
58         // every symbol so we need to handle the case of $x $x.
59         .local $x.999
60 $x.999:
61 // CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 1FFC in unpatched output.
62 // CHECK: t3_ffc_ldrsimd:
63 // CHECK-NEXT:     1ffc:        20 00 00 b0     adrp    x0, #20480
64 // CHECK-NEXT:     2000:        21 00 40 bd     ldr             s1, [x1]
65 // CHECK-NEXT:     2004:        fa 0b 00 14     b       #12264
66 // CHECK-NEXT:     2008:        c0 03 5f d6     ret
67         .globl t3_ffc_ldrsimd
68         .type t3_ffc_ldrsimd, %function
69         .space 4096 - 12
70 t3_ffc_ldrsimd:
71         adrp x0, dat
72         ldr s1, [x1, #0]
73         ldr x2, [x0, :got_lo12:dat]
74         ret
75
76 // Inline data containing bit pattern of erratum sequence, expect no patch.
77         .globl t3_ffc_ldralldata
78         .type t3_ff8_ldralldata, %function
79         .space 4096 - 20
80 t3_ff8_ldralldata:
81         // 0x90000000 = adrp x0, #0
82         .byte 0x00
83         .byte 0x00
84         .byte 0x00
85         .byte 0x90
86         // 0xf9400021 = ldr x1, [x1]
87         .byte 0x21
88         .byte 0x00
89         .byte 0x40
90         .byte 0xf9
91         // 0xf9400000 = ldr x0, [x0]
92         .byte 0x00
93         .byte 0x00
94         .byte 0x40
95         .byte 0xf9
96         // Check that we can recognise the erratum sequence post literal data.
97
98 // CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 3FF8 in unpatched output.
99 // CHECK: t3_ffc_ldr:
100 // CHECK-NEXT:     3ff8:        00 00 00 f0     adrp    x0, #12288
101 // CHECK-NEXT:     3ffc:        21 00 40 f9     ldr             x1, [x1]
102 // CHECK-NEXT:     4000:        fd 03 00 14     b       #4084
103 // CHECK-NEXT:     4004:        c0 03 5f d6     ret
104         .space 4096 - 12
105         .globl t3_ffc_ldr
106         .type t3_ffc_ldr, %function
107  t3_ffc_ldr:
108         adrp x0, dat
109         ldr x1, [x1, #0]
110         ldr x0, [x0, :got_lo12:dat]
111         ret
112
113 // CHECK: __CortexA53843419_1000:
114 // CHECK-NEXT:     4fe4:        00 0c 40 f9     ldr     x0, [x0, #24]
115 // CHECK-NEXT:     4fe8:        07 f0 ff 17     b       #-16356
116 // CHECK: __CortexA53843419_2004:
117 // CHECK-NEXT:     4fec:        02 0c 40 f9     ldr     x2, [x0, #24]
118 // CHECK-NEXT:     4ff0:        06 f4 ff 17     b       #-12264
119 // CHECK: __CortexA53843419_4000:
120 // CHECK-NEXT:     4ff4:        00 0c 40 f9     ldr     x0, [x0, #24]
121 // CHECK-NEXT:     4ff8:        03 fc ff 17     b       #-4084
122
123         .section .text.02, "ax", %progbits
124         .space 4096 - 36
125
126         // Start a new InputSectionDescription (see Linker Script) so the
127         // start address will be affected by any patches added to previous
128         // InputSectionDescription.
129
130 // CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 4FFC in unpatched output
131 // CHECK: t3_ffc_str:
132 // CHECK-NEXT:     4ffc:        00 00 00 d0     adrp    x0, #8192
133 // CHECK-NEXT:     5000:        21 00 00 f9     str             x1, [x1]
134 // CHECK-NEXT:     5004:        fb 03 00 14     b       #4076
135 // CHECK-NEXT:     5008:        c0 03 5f d6     ret
136
137         .section .newisd, "ax", %progbits
138         .globl t3_ffc_str
139         .type t3_ffc_str, %function
140 t3_ffc_str:
141         adrp x0, dat
142         str x1, [x1, #0]
143         ldr x0, [x0, :got_lo12:dat]
144         ret
145         .space 4096 - 28
146
147 // CHECK: __CortexA53843419_5004:
148 // CHECK-NEXT:     5ff0:        00 0c 40 f9     ldr     x0, [x0, #24]
149 // CHECK-NEXT:     5ff4:        05 fc ff 17     b       #-4076
150
151         // Start a new OutputSection (see Linker Script) so the
152         // start address will be affected by any patches added to previous
153         // InputSectionDescription.
154
155 //CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 5FF8 in unpatched output
156 // CHECK: t3_ff8_str:
157 // CHECK-NEXT:     5ff8:        00 00 00 b0     adrp    x0, #4096
158 // CHECK-NEXT:     5ffc:        21 00 00 f9     str             x1, [x1]
159 // CHECK-NEXT:     6000:        03 00 00 14     b       #12
160 // CHECK-NEXT:     6004:        c0 03 5f d6     ret
161
162         .section .newos, "ax", %progbits
163         .globl t3_ff8_str
164         .type t3_ff8_str, %function
165 t3_ff8_str:
166         adrp x0, dat
167         str x1, [x1, #0]
168         ldr x0, [x0, :got_lo12:dat]
169         ret
170         .globl _start
171         .type _start, %function
172 _start:
173         ret
174
175 // CHECK: __CortexA53843419_6000:
176 // CHECK-NEXT:     600c:        00 0c 40 f9     ldr     x0, [x0, #24]
177 // CHECK-NEXT:     6010:        fd ff ff 17     b       #-12
178
179         .data
180         .globl dat
181 dat:    .word 0