[ARM] Adjust how NEON shifts are lowered
[llvm-core.git] / test / ExecutionEngine / JITLink / X86 / MachO_x86-64_relocations.s
blob1958ae13b1ff518764b84fe838105992d05bbb37
1 # RUN: rm -rf %t && mkdir -p %t
2 # RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %t/macho_reloc.o %s
3 # RUN: llvm-jitlink -noexec -define-abs external_data=0xdeadbeef -define-abs external_func=0xcafef00d -check=%s %t/macho_reloc.o
5 .section __TEXT,__text,regular,pure_instructions
7 .align 4, 0x90
8 Lanon_func:
9 retq
11 .globl named_func
12 .align 4, 0x90
13 named_func:
14 xorq %rax, %rax
15 retq
17 # Check X86_64_RELOC_BRANCH handling with a call to a local function.
19 # jitlink-check: decode_operand(test_local_call, 0) = named_func - next_pc(test_local_call)
20 .globl test_local_call
21 .align 4, 0x90
22 test_local_call:
23 callq named_func
24 retq
26 .globl _main
27 .align 4, 0x90
28 _main:
29 retq
31 # Check X86_64_RELOC_GOTPCREL handling with a load from an external symbol.
32 # Validate both the reference to the GOT entry, and also the content of the GOT
33 # entry.
35 # jitlink-check: decode_operand(test_gotld, 4) = got_addr(macho_reloc.o, external_data) - next_pc(test_gotld)
36 # jitlink-check: *{8}(got_addr(macho_reloc.o, external_data)) = external_data
37 .globl test_gotld
38 .align 4, 0x90
39 test_gotld:
40 movq external_data@GOTPCREL(%rip), %rax
41 retq
43 # Check that calls to external functions trigger the generation of stubs and GOT
44 # entries.
46 # jitlink-check: decode_operand(test_external_call, 0) = stub_addr(macho_reloc.o, external_func) - next_pc(test_external_call)
47 # jitlink-check: *{8}(got_addr(macho_reloc.o, external_func)) = external_func
48 .globl test_external_call
49 .align 4, 0x90
50 test_external_call:
51 callq external_func
52 retq
54 # Check signed relocation handling:
56 # X86_64_RELOC_SIGNED / Extern -- movq address of linker global
57 # X86_64_RELOC_SIGNED1 / Extern -- movb immediate byte to linker global
58 # X86_64_RELOC_SIGNED2 / Extern -- movw immediate word to linker global
59 # X86_64_RELOC_SIGNED4 / Extern -- movl immediate long to linker global
61 # X86_64_RELOC_SIGNED / Anon -- movq address of linker private into register
62 # X86_64_RELOC_SIGNED1 / Anon -- movb immediate byte to linker private
63 # X86_64_RELOC_SIGNED2 / Anon -- movw immediate word to linker private
64 # X86_64_RELOC_SIGNED4 / Anon -- movl immediate long to linker private
65 signed_reloc_checks:
66 .globl signed
67 # jitlink-check: decode_operand(signed, 4) = named_data - next_pc(signed)
68 signed:
69 movq named_data(%rip), %rax
71 .globl signed1
72 # jitlink-check: decode_operand(signed1, 3) = named_data - next_pc(signed1)
73 signed1:
74 movb $0xAA, named_data(%rip)
76 .globl signed2
77 # jitlink-check: decode_operand(signed2, 3) = named_data - next_pc(signed2)
78 signed2:
79 movw $0xAAAA, named_data(%rip)
81 .globl signed4
82 # jitlink-check: decode_operand(signed4, 3) = named_data - next_pc(signed4)
83 signed4:
84 movl $0xAAAAAAAA, named_data(%rip)
86 .globl signedanon
87 # jitlink-check: decode_operand(signedanon, 4) = section_addr(macho_reloc.o, __data) - next_pc(signedanon)
88 signedanon:
89 movq Lanon_data(%rip), %rax
91 .globl signed1anon
92 # jitlink-check: decode_operand(signed1anon, 3) = section_addr(macho_reloc.o, __data) - next_pc(signed1anon)
93 signed1anon:
94 movb $0xAA, Lanon_data(%rip)
96 .globl signed2anon
97 # jitlink-check: decode_operand(signed2anon, 3) = section_addr(macho_reloc.o, __data) - next_pc(signed2anon)
98 signed2anon:
99 movw $0xAAAA, Lanon_data(%rip)
101 .globl signed4anon
102 # jitlink-check: decode_operand(signed4anon, 3) = section_addr(macho_reloc.o, __data) - next_pc(signed4anon)
103 signed4anon:
104 movl $0xAAAAAAAA, Lanon_data(%rip)
108 .section __DATA,__data
110 # Storage target for non-extern X86_64_RELOC_SIGNED_(1/2/4) relocs.
111 .p2align 3
112 Lanon_data:
113 .quad 0x1111111111111111
115 # Check X86_64_RELOC_SUBTRACTOR Quad/Long in anonymous storage with anonymous
116 # minuend: "LA: .quad LA - B + C". The anonymous subtrahend form
117 # "LA: .quad B - LA + C" is not tested as subtrahends are not permitted to be
118 # anonymous.
120 # Note: +8 offset in expression below to accounts for sizeof(Lanon_data).
121 # jitlink-check: *{8}(section_addr(macho_reloc.o, __data) + 8) = (section_addr(macho_reloc.o, __data) + 8) - named_data + 2
122 .p2align 3
123 Lanon_minuend_quad:
124 .quad Lanon_minuend_quad - named_data + 2
126 # Note: +16 offset in expression below to accounts for sizeof(Lanon_data) + sizeof(Lanon_minuend_long).
127 # jitlink-check: *{4}(section_addr(macho_reloc.o, __data) + 16) = ((section_addr(macho_reloc.o, __data) + 16) - named_data + 2)[31:0]
128 .p2align 2
129 Lanon_minuend_long:
130 .long Lanon_minuend_long - named_data + 2
132 # Check X86_64_RELOC_GOT handling.
133 # X86_64_RELOC_GOT is the data-section counterpart to X86_64_RELOC_GOTLD. It is
134 # handled exactly the same way, including having an implicit PC-rel offset of -4
135 # (despite this not making sense in a data section, and requiring an explicit
136 # +4 addend to cancel it out and get the correct result).
138 # jitlink-check: *{4}test_got = (got_addr(macho_reloc.o, external_data) - test_got)[31:0]
139 .globl test_got
140 .p2align 2
141 test_got:
142 .long external_data@GOTPCREL + 4
144 # Named quad storage target (first named atom in __data).
145 .globl named_data
146 .p2align 3
147 named_data:
148 .quad 0x2222222222222222
150 # An alt-entry point for named_data
151 .globl named_data_alt_entry
152 .p2align 3
153 .alt_entry named_data_alt_entry
154 named_data_alt_entry:
155 .quad 0
157 # Check X86_64_RELOC_UNSIGNED / extern handling by putting the address of a
158 # local named function in a pointer variable.
160 # jitlink-check: *{8}named_func_addr = named_func
161 .globl named_func_addr
162 .p2align 3
163 named_func_addr:
164 .quad named_func
166 # Check X86_64_RELOC_UNSIGNED / non-extern handling by putting the address of a
167 # local anonymous function in a pointer variable.
169 # jitlink-check: *{8}anon_func_addr = section_addr(macho_reloc.o, __text)
170 .globl anon_func_addr
171 .p2align 3
172 anon_func_addr:
173 .quad Lanon_func
175 # X86_64_RELOC_SUBTRACTOR Quad/Long in named storage with anonymous minuend
177 # jitlink-check: *{8}anon_minuend_quad1 = section_addr(macho_reloc.o, __data) - anon_minuend_quad1 + 2
178 # Only the form "B: .quad LA - B + C" is tested. The form "B: .quad B - LA + C" is
179 # invalid because the subtrahend can not be local.
180 .globl anon_minuend_quad1
181 .p2align 3
182 anon_minuend_quad1:
183 .quad Lanon_data - anon_minuend_quad1 + 2
185 # jitlink-check: *{4}anon_minuend_long1 = (section_addr(macho_reloc.o, __data) - anon_minuend_long1 + 2)[31:0]
186 .globl anon_minuend_long1
187 .p2align 2
188 anon_minuend_long1:
189 .long Lanon_data - anon_minuend_long1 + 2
191 # Check X86_64_RELOC_SUBTRACTOR Quad/Long in named storage with minuend and subtrahend.
192 # Both forms "A: .quad A - B + C" and "A: .quad B - A + C" are tested.
194 # Check "A: .quad B - A + C".
195 # jitlink-check: *{8}subtrahend_quad2 = (named_data - subtrahend_quad2 - 2)
196 .globl subtrahend_quad2
197 .p2align 3
198 subtrahend_quad2:
199 .quad named_data - subtrahend_quad2 - 2
201 # Check "A: .long B - A + C".
202 # jitlink-check: *{4}subtrahend_long2 = (named_data - subtrahend_long2 - 2)[31:0]
203 .globl subtrahend_long2
204 .p2align 2
205 subtrahend_long2:
206 .long named_data - subtrahend_long2 - 2
208 # Check "A: .quad A - B + C".
209 # jitlink-check: *{8}minuend_quad3 = (minuend_quad3 - named_data - 2)
210 .globl minuend_quad3
211 .p2align 3
212 minuend_quad3:
213 .quad minuend_quad3 - named_data - 2
215 # Check "A: .long B - A + C".
216 # jitlink-check: *{4}minuend_long3 = (minuend_long3 - named_data - 2)[31:0]
217 .globl minuend_long3
218 .p2align 2
219 minuend_long3:
220 .long minuend_long3 - named_data - 2
222 # Check X86_64_RELOC_SUBTRACTOR handling for exprs of the form
223 # "A: .quad/long B - C + D", where 'B' or 'C' is at a fixed offset from 'A'
224 # (i.e. is part of an alt_entry chain that includes 'A').
226 # Check "A: .long B - C + D" where 'B' is an alt_entry for 'A'.
227 # jitlink-check: *{4}subtractor_with_alt_entry_minuend_long = (subtractor_with_alt_entry_minuend_long_B - named_data + 2)[31:0]
228 .globl subtractor_with_alt_entry_minuend_long
229 .p2align 2
230 subtractor_with_alt_entry_minuend_long:
231 .long subtractor_with_alt_entry_minuend_long_B - named_data + 2
233 .globl subtractor_with_alt_entry_minuend_long_B
234 .p2align 2
235 .alt_entry subtractor_with_alt_entry_minuend_long_B
236 subtractor_with_alt_entry_minuend_long_B:
237 .long 0
239 # Check "A: .quad B - C + D" where 'B' is an alt_entry for 'A'.
240 # jitlink-check: *{8}subtractor_with_alt_entry_minuend_quad = (subtractor_with_alt_entry_minuend_quad_B - named_data + 2)
241 .globl subtractor_with_alt_entry_minuend_quad
242 .p2align 3
243 subtractor_with_alt_entry_minuend_quad:
244 .quad subtractor_with_alt_entry_minuend_quad_B - named_data + 2
246 .globl subtractor_with_alt_entry_minuend_quad_B
247 .p2align 3
248 .alt_entry subtractor_with_alt_entry_minuend_quad_B
249 subtractor_with_alt_entry_minuend_quad_B:
250 .quad 0
252 # Check "A: .long B - C + D" where 'C' is an alt_entry for 'A'.
253 # jitlink-check: *{4}subtractor_with_alt_entry_subtrahend_long = (named_data - subtractor_with_alt_entry_subtrahend_long_B + 2)[31:0]
254 .globl subtractor_with_alt_entry_subtrahend_long
255 .p2align 2
256 subtractor_with_alt_entry_subtrahend_long:
257 .long named_data - subtractor_with_alt_entry_subtrahend_long_B + 2
259 .globl subtractor_with_alt_entry_subtrahend_long_B
260 .p2align 2
261 .alt_entry subtractor_with_alt_entry_subtrahend_long_B
262 subtractor_with_alt_entry_subtrahend_long_B:
263 .long 0
265 # Check "A: .quad B - C + D" where 'B' is an alt_entry for 'A'.
266 # jitlink-check: *{8}subtractor_with_alt_entry_subtrahend_quad = (named_data - subtractor_with_alt_entry_subtrahend_quad_B + 2)
267 .globl subtractor_with_alt_entry_subtrahend_quad
268 .p2align 3
269 subtractor_with_alt_entry_subtrahend_quad:
270 .quad named_data - subtractor_with_alt_entry_subtrahend_quad_B + 2
272 .globl subtractor_with_alt_entry_subtrahend_quad_B
273 .p2align 3
274 .alt_entry subtractor_with_alt_entry_subtrahend_quad_B
275 subtractor_with_alt_entry_subtrahend_quad_B:
276 .quad 0
278 # Check that unreferenced atoms in no-dead-strip sections are not dead stripped.
279 # We need to use a local symbol for this as any named symbol will end up in the
280 # ORC responsibility set, which is automatically marked live and would couse
281 # spurious passes.
283 # jitlink-check: *{8}section_addr(macho_reloc.o, __nds_test_sect) = 0
284 .section __DATA,__nds_test_sect,regular,no_dead_strip
285 .quad 0
287 # Check that unreferenced local symbols that have been marked no-dead-strip are
288 # not dead-striped.
290 # jitlink-check: *{8}section_addr(macho_reloc.o, __nds_test_nlst) = 0
291 .section __DATA,__nds_test_nlst,regular
292 .no_dead_strip no_dead_strip_test_symbol
293 no_dead_strip_test_symbol:
294 .quad 0
296 # Check that explicit zero-fill symbols are supported
297 # jitlink-check: *{8}zero_fill_test = 0
298 .globl zero_fill_test
299 .zerofill __DATA,__zero_fill_test,zero_fill_test,8,3
301 # Check that section alignments are respected.
302 # We test this by introducing two segments with alignment 8, each containing one
303 # byte of data. We require both symbols to have an aligned address.
305 # jitlink-check: section_alignment_check1[2:0] = 0
306 # jitlink-check: section_alignment_check2[2:0] = 0
307 .section __DATA,__sec_align_chk1
308 .p2align 3
310 .globl section_alignment_check1
311 section_alignment_check1:
312 .byte 0
314 .section __DATA,__sec_align_chk2
315 .p2align 3
317 .globl section_alignment_check2
318 section_alignment_check2:
319 .byte 0
321 .subsections_via_symbols