Commit | Line | Data |
---|---|---|
a06ea964 NC |
1 | // Test file for AArch64 GAS -- instructions with relocation operators. |
2 | ||
3 | func: | |
4 | // BFD_RELOC_AARCH64_MOVW_G0 | |
5 | // immediate | |
6 | movz x0,#:abs_g0:u12 | |
7 | ||
8 | // BFD_RELOC_AARCH64_MOVW_G0_S | |
9 | // immediate | |
10 | movz x0,#:abs_g0_s:s12 | |
11 | ||
12 | // BFD_RELOC_AARCH64_MOVW_G1 | |
13 | // immediate | |
14 | movz x1,#:abs_g1:u32 | |
15 | movk x1,#:abs_g0_nc:u32 | |
16 | ||
17 | // BFD_RELOC_AARCH64_MOVW_G1_S | |
18 | // immediate | |
19 | movz x1,#:abs_g1_s:s12 | |
20 | movk x1,#:abs_g0_nc:s12 | |
21 | ||
22 | // BFD_RELOC_AARCH64_MOVW_G2 | |
23 | // immediate | |
24 | movz x1,#:abs_g2:u48 | |
25 | movk x1,#:abs_g1_nc:u48 | |
26 | movk x1,#:abs_g0_nc:u48 | |
27 | ||
28 | // local data (section relative) | |
29 | movz x1,#:abs_g2:ldata | |
30 | movk x1,#:abs_g1_nc:ldata | |
31 | movk x1,#:abs_g0_nc:ldata | |
32 | ||
33 | // external data | |
34 | movz x1,#:abs_g2:xdata | |
35 | movk x1,#:abs_g1_nc:xdata | |
36 | movk x1,#:abs_g0_nc:xdata | |
37 | ||
38 | // BFD_RELOC_AARCH64_MOVW_G2_S | |
39 | // immediate | |
40 | movz x1,#:abs_g2_s:s12 | |
41 | movk x1,#:abs_g1_nc:s12 | |
42 | movk x1,#:abs_g0_nc:s12 | |
43 | ||
44 | // BFD_RELOC_AARCH64_MOVW_G3 | |
45 | // immediate | |
46 | movz x1,#:abs_g3:s12 | |
47 | movk x1,#:abs_g2_nc:s12 | |
48 | movk x1,#:abs_g1_nc:s12 | |
49 | movk x1,#:abs_g0_nc:s12 | |
50 | ||
51 | movz x1,#:abs_g3:u64 | |
52 | movk x1,#:abs_g2_nc:u64 | |
53 | movk x1,#:abs_g1_nc:u64 | |
54 | movk x1,#:abs_g0_nc:u64 | |
55 | ||
56 | // BFD_RELOC_AARCH64_LD_LO19_PCREL | |
57 | ldr x0,llit | |
58 | ldr x1,ldata | |
59 | ldr x2,xdata+12 | |
60 | ||
61 | // BFD_RELOC_AARCH64_ADR_LO21_PCREL | |
62 | // AARCH64 ADR instruction, holding a simple 21 bit pc-relative byte offset. | |
63 | adr x0,llit | |
64 | adr x1,ldata | |
65 | adr x2,ldata+4088 | |
66 | adr x3,xlit | |
67 | adr x4,xdata+16 | |
68 | adr x5,xdata+4088 | |
69 | ||
70 | // BFD_RELOC_AARCH64_ADR_HI21_PCREL | |
71 | adrp x0,llit | |
72 | adrp x1,ldata | |
73 | adrp x2,ldata+4088 | |
74 | adrp x3,xlit | |
75 | adrp x4,xdata+16 | |
76 | adrp x5,xdata+4088 | |
77 | ||
78 | // BFD_RELOC_AARCH64_ADR_HI21_PCREL | |
79 | adrp x0,:pg_hi21:llit | |
80 | adrp x1,:pg_hi21:ldata | |
81 | adrp x2,:pg_hi21:ldata+4088 | |
82 | adrp x3,:pg_hi21:xlit | |
83 | adrp x4,:pg_hi21:xdata+16 | |
84 | adrp x5,:pg_hi21:xdata+4088 | |
85 | ||
86 | // BFD_RELOC_AARCH64_ADD_LO12 | |
87 | add x0,x0,#:lo12:llit | |
88 | add x1,x1,#:lo12:ldata | |
89 | add x2,x2,#:lo12:ldata+4088 | |
90 | add x3,x3,#:lo12:xlit | |
91 | add x4,x4,#:lo12:xdata+16 | |
92 | add x5,x5,#:lo12:xdata+4088 | |
93 | add x6,x6,u12 | |
94 | ||
95 | // BFD_RELOC_AARCH64_LDST8_LO12 | |
96 | ldrb w0, [x0, #:lo12:llit] | |
97 | ldrb w1, [x1, #:lo12:ldata] | |
98 | ldrb w2, [x2, #:lo12:ldata+4088] | |
99 | ldrb w3, [x3, #:lo12:xlit] | |
100 | ldrb w4, [x4, #:lo12:xdata+16] | |
101 | ldrb w5, [x5, #:lo12:xdata+4088] | |
102 | ldrb w6, [x6, u12] | |
103 | ||
104 | // BFD_RELOC_AARCH64_TSTBR14 | |
105 | tbz x0,#0,lab | |
106 | tbz x1,#63,xlab | |
107 | tbnz x2,#8,lab | |
108 | tbnz x2,#47,xlab | |
109 | ||
110 | // BFD_RELOC_AARCH64_BRANCH19 | |
111 | b.eq lab | |
112 | b.eq xlab | |
113 | ||
114 | // BFD_RELOC_AARCH64_COMPARE19 | |
115 | cbz x0,lab | |
116 | cbnz x30,xlab | |
117 | ||
118 | // BFD_RELOC_AARCH64_JUMP26 | |
119 | b lab | |
120 | b xlab | |
121 | ||
122 | // BFD_RELOC_AARCH64_CALL26 | |
123 | bl lab | |
124 | bl xlab | |
125 | ||
126 | // BFD_RELOC_AARCH64_MOVW_IMM | |
127 | movz x0, #0x1234, lsl #48 | |
128 | movk x0, #0x5678, lsl #32 | |
129 | movk x0, #0x9abc, lsl #16 | |
130 | movk x0, #0xdef0, lsl #0 | |
131 | ||
132 | movz x0, (u64>>48)&0xffff, lsl #48 | |
133 | movk x0, (u64>>32)&0xffff, lsl #32 | |
134 | movk x0, (u64>>16)&0xffff, lsl #16 | |
135 | movk x0, (u64>>0)&0xffff, lsl #0 | |
136 | ||
137 | // BFD_RELOC_AARCH64_BIT_IMM | |
138 | orr x0,x0,bit1 | |
139 | and x0,x0,bit2 | |
140 | and w0,w0,bit2 | |
141 | ||
142 | // BFD_RELOC_AARCH64_ADD_U12 | |
143 | add x0,x0,s12 | |
144 | add x0,x0,u12 | |
145 | sub x0,x0,s12 | |
146 | sub x0,x0,u12 | |
147 | ||
148 | // BFD_RELOC_AARCH64_EXC_U16 | |
149 | svc u16 | |
150 | ||
151 | // BFD_RELOC_AARCH64_LDST_I9 | |
152 | // Signed 9-bit byte offset for load/store single item with writeback options. | |
153 | // Used internally by the AARCH64 assembler and not (currently) | |
154 | // written to any object files. | |
155 | ldr x0,[x1],#s9 | |
156 | ldr x0,[x1,#s9]! | |
157 | ||
158 | // No writeback, but a negative offset should cause this | |
159 | // to be converted to a LDST_I9 relocation | |
160 | ldr x0,[x1,#s9] | |
161 | ||
162 | // BFD_RELOC_AARCH64_LDST_U12 | |
163 | // Unsigned 12-bit byte offset for load/store single item without options. | |
164 | // Used internally by the AARCH64 assembler and not (currently) | |
165 | // written to any object files. | |
166 | ldr x0,[x1,#(u12*8)] | |
167 | ||
168 | // BFD_RELOC_AARCH64_LDST16_LO12 | |
169 | ldrh w0, [x0, #:lo12:llit] | |
170 | // BFD_RELOC_AARCH64_LDST32_LO12 | |
171 | ldr w1, [x1, #:lo12:ldata] | |
172 | // BFD_RELOC_AARCH64_LDST64_LO12 | |
173 | ldr x2, [x2, #:lo12:ldata+4088] | |
174 | // BFD_RELOC_AARCH64_LDST128_LO12 | |
175 | ldr q3, [x3, #:lo12:xlit] | |
176 | ||
177 | // BFD_RELOC_AARCH64_LDST64_LO12 | |
178 | prfm pstl1keep, [x7, #:lo12:ldata+4100] | |
f41aef5f RE |
179 | |
180 | // BFD_RELOC_AARCH64_GOT_LD_PREL19 | |
4aa2c5e2 | 181 | ldr x0, :got:cdata |
f41aef5f | 182 | ldrb w1, [x0] |
a06ea964 NC |
183 | |
184 | ret | |
185 | ||
a921b5bd JW |
186 | // BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15 |
187 | ldr x28, [x13, #:gotpage_lo15:dummy] | |
87f5fbcc RL |
188 | // BFD_RELOC_AARCH64_LD64_GOTOFF_LO15 |
189 | ldr x0, [x0, #:gotoff_lo15:dummy] | |
a921b5bd | 190 | |
a06ea964 NC |
191 | llit: .word 0xdeadf00d |
192 | ||
193 | lab: | |
194 | ||
195 | .data | |
196 | .align 8 | |
197 | ||
198 | dummy: .xword 0 | |
199 | ||
200 | ldata: .xword 0x1122334455667788 | |
201 | .space 8184 | |
202 | ||
203 | .set u8, 248 | |
204 | .set s9, -256 | |
205 | .set s12, -2048 | |
206 | .set u12, 4095 | |
207 | .set u16, 65535 | |
208 | .set u32, 0x12345678 | |
209 | .set u48, 0xaabbccddeeff | |
210 | .set u64, 0xfedcba9876543210 | |
211 | .set bit1,0xf000000000000000 | |
212 | .set bit2,~0xf | |
f41aef5f RE |
213 | |
214 | .comm cdata,1,8 |