2 * Copyright (c) 2005-2007 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
88 @ call external + addend
99 .long _test_branches-1b
100 .long _test_branches+3-1b
101 .long (_test_branches - _test_loads) + -2097152
102 .long (_test_calls - _test_loads) + -2097152
110 .weak_definition _arm3
112 .private_extern _arm3
115 .weak_definition _arm4
117 .private_extern _arm4
128 .weak_definition _thumb3
130 .private_extern _thumb3
134 .weak_definition _thumb4
136 .private_extern _thumb4
141 .thumb_func _thumb_func_ref_test
142 _thumb_func_ref_test:
155 L6: .long _thumb1-(L2+4)
156 L7: .long _thumb2-(L3+4)
157 L7a:.long _thumb3-(L3+4)
158 L7b:.long _thumb4-(L3+4)
159 L8: .long _arm1-(L4+4)
160 L9: .long _arm2-(L5+4)
161 L9a:.long _arm3-(L5+4)
162 L9b:.long _arm4-(L5+4)
179 L16: .long _thumb1-(L12+8)
180 L17: .long _thumb2-(L13+8)
181 L17a: .long _thumb3-(L3+8)
182 L17b: .long _thumb4-(L3+8)
183 L18: .long _arm1-(L14+8)
184 L19: .long _arm2-(L15+8)
185 L19a: .long _arm3-(L15+8)
186 L19b: .long _arm4-(L15+8)
188 .section __DATA,__const
198 #if __ppc__ || __ppc64__
210 addis r2,r10,ha16(_a-Lpicbase)
211 lwz r2,lo16(_a-Lpicbase)(r2)
214 addis r2,r10,ha16(_c-Lpicbase)
215 lwz r2,lo16(_c-Lpicbase)(r2)
225 ; absolute load of external
229 ; absolute lea of external
234 ; PIC load of a + addend
235 addis r2,r10,ha16(_a+0x19000-Lpicbase)
236 lwz r2,lo16(_a+0x19000-Lpicbase)(r2)
238 ; absolute load of a + addend
239 lis r2,ha16(_a+0x19000)
240 lwz r2,lo16(_a+0x19000)(r2)
243 lis r2,ha16(_a+0x19000)
244 addi r2,r2,lo16(_a+0x19000)
246 ; alt lea of a + addend
247 lis r2,hi16(_a+0x19000)
248 ori r2,r2,lo16(_a+0x19000)
250 ; absolute load of external + addend
251 lis r2,ha16(_ax+0x19000)
252 lwz r2,lo16(_ax+0x19000)(r2)
254 ; absolute lea of external + addend
255 lis r2,hi16(_ax+0x19000)
256 ori r2,r2,lo16(_ax+0x19000)
259 ; PIC load of a + addend
260 addis r2,r10,ha16(_a+0x09000-Lpicbase)
261 lwz r2,lo16(_a+0x09000-Lpicbase)(r2)
263 ; absolute load of a + addend
264 lis r2,ha16(_a+0x09000)
265 lwz r2,lo16(_a+0x09000)(r2)
268 lis r2,ha16(_a+0x09000)
269 addi r2,r2,lo16(_a+0x09000)
271 ; alt lea of a + addend
272 lis r2,hi16(_a+0x09000)
273 ori r2,r2,lo16(_a+0x09000)
275 ; absolute load of external + addend
276 lis r2,ha16(_ax+0x09000)
277 lwz r2,lo16(_ax+0x09000)(r2)
279 ; absolute lea of external + addend
280 lis r2,hi16(_ax+0x09000)
281 ori r2,r2,lo16(_ax+0x09000)
290 ; call internal + addend
291 bl _test_branches+0x19000
296 ; call external + addend
304 ; call internal + addend
310 ; call external + addend
326 movl _a-Lpicbase(%ebx), %eax
331 # absolute load of external
334 # absolute lea of external
338 # PIC load of a + addend
339 movl _a-Lpicbase+0x19000(%ebx), %eax
341 # absolute load of a + addend
342 movl _a+0x19000(%ebx), %eax
344 # absolute load of external + addend
345 movl _ax+0x19000(%ebx), %eax
347 # absolute lea of external + addend
348 leal _ax+0x1900, %eax
357 # call internal + addend
358 call _test_branches+0x19000
360 # 16-bit call internal
363 # 16-bit call internal + addend
364 callw _test_branches+13
369 # call external + addend
370 call _external+0x19000
377 # call internal + addend
383 # call external + addend
389 1: movl _foo-1b(%eax),%esi
390 movl _foo+10-1b(%eax),%esi
391 movl _test_branches-1b(%eax),%esi
392 movl _test_branches+3-1b(%eax),%esi
393 cmpl $(( (_test_branches - _test_loads) + -2097152 )),(%esp)
394 cmpl $(( (_test_calls - _test_loads) + -2097152 )),(%esp)
423 # PIC load of a + addend
424 movl _a+0x1234(%rip), %eax
429 # PIC lea through GOT
430 movq _a@GOTPCREL(%rip), %rax
433 pushq _a@GOTPCREL(%rip)
435 # PIC lea external through GOT
436 movq _ax@GOTPCREL(%rip), %rax
438 # PIC external access of GOT
439 pushq _ax@GOTPCREL(%rip)
443 movb $0x12, _a+2(%rip)
447 movl $0x12345678, _a(%rip)
448 movl $0x12345678, _a+4(%rip)
449 movl $0x12345678, L0(%rip)
462 # call internal + addend
463 call _test_branches+0x19000
468 # call external + addend
469 call _external+0x19000
476 # call internal + addend
482 # call external + addend
495 # test that pointer-diff relocs are preserved
501 .long Llocal2-_test_branches
502 .long . - _test_branches
503 .long . - _test_branches + 8
504 .long _test_branches - .
505 .long _test_branches - . + 8
506 .long _test_branches - . - 8
510 .quad Llocal2-_test_branches
528 .long _foo - _distance_to_here
529 .long _foo - _distance_to_here - 4
530 .long _foo - _distance_to_here - 12
536 L0: .quad _test_branches
538 .quad _test_branches+4
539 L1: .quad _test_branches - _test_diffs
540 .quad _test_branches - _test_diffs + 4
541 .long _test_branches - _test_diffs
542 # .long LCL0-. ### assembler bug: should SUB/UNSIGNED with content= LCL0-24, or single pc-rel SIGNED reloc with content = LCL0-.+4
545 .quad _test_branches - .
546 .quad _test_branches - L1
548 #tests support for 32-bit absolute pointers
552 # the following generates: _foo cannot be undefined in a subtraction expression
553 # but it should be ok (it will be a linker error if _foo and _bar are not in same linkage unit)
554 # .quad _foo - _bar ### assembler bug
556 .section __DATA,__data2
568 #if __ppc__ || __i386__ || __arm__
573 #elif __ppc64__ || __x86_64__
580 # test that reloc sizes are the same
587 .long Llocal4-Llocal3