2 * Copyright (c) 2005-2010 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
42 @ sorta-absolute load of a
46 @ sorta-absolute load of c
50 @ sorta-absolute load of external
54 @ PIC load of a + addend ??
68 @ call internal + addend
69 bl _test_branches+0x19000
74 @ call external + addend
82 @ call internal + addend
85 @ call internal - addend
91 @ call external + addend
100 .weak_definition _test_weak
105 .globl _test_hidden_weak
106 .private_extern _test_hidden_weak
107 .weak_definition _test_hidden_weak
118 _test_weak_hidden_pointer_call:
124 .long _test_hidden_weak - L101
131 .long _test_branches-1b
132 .long _test_branches+3-1b
133 .long (_test_branches - _test_loads) + -2097152
134 .long (_test_calls - _test_loads) + -2097152
143 .weak_definition _arm3
145 .private_extern _arm3
148 .weak_definition _arm4
150 .private_extern _arm4
161 .weak_definition _thumb3
163 .private_extern _thumb3
167 .weak_definition _thumb4
169 .private_extern _thumb4
174 .thumb_func _thumb_func_ref_test
175 _thumb_func_ref_test:
188 L6: .long _thumb1-(L2+4)
189 L7: .long _thumb2-(L3+4)
190 L7a:.long _thumb3-(L3+4)
191 L7b:.long _thumb4-(L3+4)
192 L8: .long _arm1-(L4+4)
193 L9: .long _arm2-(L5+4)
194 L9a:.long _arm3-(L5+4)
195 L9b:.long _arm4-(L5+4)
212 L16: .long _thumb1-(L12+8)
213 L17: .long _thumb2-(L13+8)
214 L17a: .long _thumb3-(L13+8)
215 L17b: .long _thumb4-(L13+8)
216 L18: .long _arm1-(L14+8)
217 L19: .long _arm2-(L15+8)
218 L19a: .long _arm3-(L15+8)
219 L19b: .long _arm4-(L15+8)
221 .section __DATA,__const
233 movw r0, :lower16:_datahilo16
234 movt r0, :upper16:_datahilo16
235 movw r0, :lower16:_datahilo16+4
236 movt r0, :upper16:_datahilo16+4
237 movw r0, :lower16:_datahilo16alt
238 movt r0, :upper16:_datahilo16alt
239 movw r0, :lower16:_datahilo16alt+61440
240 movt r0, :upper16:_datahilo16alt+61440
241 movw r0, :lower16:_datahilo16alt+2048
242 movt r0, :upper16:_datahilo16alt+2048
243 movw r0, :lower16:_datahilo16alt+1792
244 movt r0, :upper16:_datahilo16alt+1792
245 movw r0, :lower16:_datahilo16alt+165
246 movt r0, :upper16:_datahilo16alt+165
248 movw r0, :lower16:_datahilo16 - Lpicbase
249 movt r0, :upper16:_datahilo16 - Lpicbase
250 movw r0, :lower16:_datahilo16+4 - Lpicbase
251 movt r0, :upper16:_datahilo16+4 - Lpicbase
252 movw r0, :lower16:_datahilo16alt - Lpicbase
253 movt r0, :upper16:_datahilo16alt - Lpicbase
254 movw r0, :lower16:_datahilo16alt+61440 - Lpicbase
255 movt r0, :upper16:_datahilo16alt+61440 - Lpicbase
256 movw r0, :lower16:_datahilo16alt+2048 - Lpicbase
257 movt r0, :upper16:_datahilo16alt+2048 - Lpicbase
258 movw r0, :lower16:_datahilo16alt+1792 - Lpicbase
259 movt r0, :upper16:_datahilo16alt+1792 - Lpicbase
260 movw r0, :lower16:_datahilo16alt+165 - Lpicbase
261 movt r0, :upper16:_datahilo16alt+165 - Lpicbase
265 .thumb_func _thumb16tests
267 movw r0, :lower16:_datahilo16
268 movt r0, :upper16:_datahilo16
269 movw r0, :lower16:_datahilo16+4
270 movt r0, :upper16:_datahilo16+4
271 movw r0, :lower16:_datahilo16alt
272 movt r0, :upper16:_datahilo16alt
273 movw r0, :lower16:_datahilo16alt+61440
274 movt r0, :upper16:_datahilo16alt+61440
275 movw r0, :lower16:_datahilo16alt+2048
276 movt r0, :upper16:_datahilo16alt+2048
277 movw r0, :lower16:_datahilo16alt+1792
278 movt r0, :upper16:_datahilo16alt+1792
279 movw r0, :lower16:_datahilo16alt+165
280 movt r0, :upper16:_datahilo16alt+165
282 movw r0, :lower16:_datahilo16 - Lpicbase2
283 movt r0, :upper16:_datahilo16 - Lpicbase2
284 movw r0, :lower16:_datahilo16+4 - Lpicbase2
285 movt r0, :upper16:_datahilo16+4 - Lpicbase2
286 movw r0, :lower16:_datahilo16alt - Lpicbase2
287 movt r0, :upper16:_datahilo16alt - Lpicbase2
288 movw r0, :lower16:_datahilo16alt+61440 - Lpicbase2
289 movt r0, :upper16:_datahilo16alt+61440 - Lpicbase2
290 movw r0, :lower16:_datahilo16alt+2048 - Lpicbase2
291 movt r0, :upper16:_datahilo16alt+2048 - Lpicbase2
292 movw r0, :lower16:_datahilo16alt+1792 - Lpicbase2
293 movt r0, :upper16:_datahilo16alt+1792 - Lpicbase2
294 movw r0, :lower16:_datahilo16alt+165 - Lpicbase2
295 movt r0, :upper16:_datahilo16alt+165 - Lpicbase2
300 _datahilo16alt: .long 0
306 #if __ppc__ || __ppc64__
318 addis r2,r10,ha16(_a-Lpicbase)
319 lwz r2,lo16(_a-Lpicbase)(r2)
322 addis r2,r10,ha16(_c-Lpicbase)
323 lwz r2,lo16(_c-Lpicbase)(r2)
333 ; absolute load of external
337 ; absolute lea of external
342 ; PIC load of a + addend
343 addis r2,r10,ha16(_a+0x19000-Lpicbase)
344 lwz r2,lo16(_a+0x19000-Lpicbase)(r2)
346 ; absolute load of a + addend
347 lis r2,ha16(_a+0x19000)
348 lwz r2,lo16(_a+0x19000)(r2)
351 lis r2,ha16(_a+0x19000)
352 addi r2,r2,lo16(_a+0x19000)
354 ; alt lea of a + addend
355 lis r2,hi16(_a+0x19000)
356 ori r2,r2,lo16(_a+0x19000)
358 ; absolute load of external + addend
359 lis r2,ha16(_ax+0x19000)
360 lwz r2,lo16(_ax+0x19000)(r2)
362 ; absolute lea of external + addend
363 lis r2,hi16(_ax+0x19000)
364 ori r2,r2,lo16(_ax+0x19000)
367 ; PIC load of a + addend
368 addis r2,r10,ha16(_a+0x09000-Lpicbase)
369 lwz r2,lo16(_a+0x09000-Lpicbase)(r2)
371 ; absolute load of a + addend
372 lis r2,ha16(_a+0x09000)
373 lwz r2,lo16(_a+0x09000)(r2)
376 lis r2,ha16(_a+0x09000)
377 addi r2,r2,lo16(_a+0x09000)
379 ; alt lea of a + addend
380 lis r2,hi16(_a+0x09000)
381 ori r2,r2,lo16(_a+0x09000)
383 ; absolute load of external + addend
384 lis r2,ha16(_ax+0x09000)
385 lwz r2,lo16(_ax+0x09000)(r2)
387 ; absolute lea of external + addend
388 lis r2,hi16(_ax+0x09000)
389 ori r2,r2,lo16(_ax+0x09000)
398 ; call internal + addend
399 bl _test_branches+0x19000
404 ; call external + addend
412 ; call internal + addend
418 ; call external + addend
422 .weak_definition _test_weak
450 movl _a-Lpicbase(%ebx), %eax
455 # absolute load of external
458 # absolute lea of external
462 # PIC load of a + addend
463 movl _a-Lpicbase+0x19000(%ebx), %eax
465 # absolute load of a + addend
466 movl _a+0x19000(%ebx), %eax
468 # absolute load of external + addend
469 movl _ax+0x19000(%ebx), %eax
471 # absolute lea of external + addend
472 leal _ax+0x1900, %eax
474 # absolute load of _test_data with negative addend and local label
475 movl Ltest_data-16(%edi),%eax
476 movq Ltest_data-16(%edi),%mm4
485 # call internal + addend
486 call _test_branches+0x19000
488 # 16-bit call internal
491 # 16-bit call internal + addend
492 callw _test_branches+13
497 # call external + addend
498 call _external+0x19000
505 # call internal + addend
511 # call external + addend
517 1: movl _foo-1b(%eax),%esi
518 movl _foo+10-1b(%eax),%esi
519 movl _test_branches-1b(%eax),%esi
520 movl _test_branches+3-1b(%eax),%esi
521 cmpl $(( (_test_branches - _test_loads) + -2097152 )),(%esp)
522 cmpl $(( (_test_calls - _test_loads) + -2097152 )),(%esp)
538 .weak_definition _test_weak
561 # PIC load of a + addend
562 movl _a+0x1234(%rip), %eax
567 # PIC lea through GOT
568 movq _a@GOTPCREL(%rip), %rax
571 pushq _a@GOTPCREL(%rip)
573 # PIC lea external through GOT
574 movq _ax@GOTPCREL(%rip), %rax
576 # PIC external access of GOT
577 pushq _ax@GOTPCREL(%rip)
581 movb $0x12, _a+2(%rip)
585 movl $0x12345678, _a(%rip)
586 movl $0x12345678, _a+4(%rip)
587 movl $0x12345678, L0(%rip)
600 # call internal + addend
601 call _test_branches+0x19000
606 # call external + addend
607 call _external+0x19000
614 # call internal + addend
620 # call external + addend
624 # nonsense loop that creates byte branch relocation
631 .weak_definition _test_weak
644 # test that pointer-diff relocs are preserved
650 .long Llocal2-_test_branches
651 .long . - _test_branches
652 .long . - _test_branches + 8
653 .long _test_branches - .
654 .long _test_branches - . + 8
655 .long _test_branches - . - 8
659 .quad Llocal2-_test_branches
678 .long _foo - _distance_to_here
679 .long _foo - _distance_to_here - 4
680 .long _foo - _distance_to_here - 12
681 .long Lfoo - _distance_to_here
684 .long Lfoo - Ltohere - 4
690 L0: .quad _test_branches
692 .quad _test_branches+4
693 L1: .quad _test_branches - _test_diffs
694 .quad _test_branches - _test_diffs + 4
695 .long _test_branches - _test_diffs
696 # .long LCL0-. ### assembler bug: should SUB/UNSIGNED with content= LCL0-24, or single pc-rel SIGNED reloc with content = LCL0-.+4
699 .quad _test_branches - .
700 .quad _test_branches - L1
702 .quad _prev+100 - _test_branches
703 #tests support for 32-bit absolute pointers
707 # the following generates: _foo cannot be undefined in a subtraction expression
708 # but it should be ok (it will be a linker error if _foo and _bar are not in same linkage unit)
709 # .quad _foo - _bar ### assembler bug
711 .section __DATA,__data2
723 #if __ppc__ || __i386__ || __arm__
730 #elif __ppc64__ || __x86_64__
739 # test that reloc sizes are the same
746 .long Llocal4-Llocal3