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
97 .long _test_branches-1b
98 .long _test_branches+3-1b
99 .long (_test_branches - _test_loads) + -2097152
100 .long (_test_calls - _test_loads) + -2097152
104 #if __ppc__ || __ppc64__
116 addis r2,r10,ha16(_a-Lpicbase)
117 lwz r2,lo16(_a-Lpicbase)(r2)
120 addis r2,r10,ha16(_c-Lpicbase)
121 lwz r2,lo16(_c-Lpicbase)(r2)
131 ; absolute load of external
135 ; absolute lea of external
140 ; PIC load of a + addend
141 addis r2,r10,ha16(_a+0x19000-Lpicbase)
142 lwz r2,lo16(_a+0x19000-Lpicbase)(r2)
144 ; absolute load of a + addend
145 lis r2,ha16(_a+0x19000)
146 lwz r2,lo16(_a+0x19000)(r2)
149 lis r2,ha16(_a+0x19000)
150 addi r2,r2,lo16(_a+0x19000)
152 ; alt lea of a + addend
153 lis r2,hi16(_a+0x19000)
154 ori r2,r2,lo16(_a+0x19000)
156 ; absolute load of external + addend
157 lis r2,ha16(_ax+0x19000)
158 lwz r2,lo16(_ax+0x19000)(r2)
160 ; absolute lea of external + addend
161 lis r2,hi16(_ax+0x19000)
162 ori r2,r2,lo16(_ax+0x19000)
165 ; PIC load of a + addend
166 addis r2,r10,ha16(_a+0x09000-Lpicbase)
167 lwz r2,lo16(_a+0x09000-Lpicbase)(r2)
169 ; absolute load of a + addend
170 lis r2,ha16(_a+0x09000)
171 lwz r2,lo16(_a+0x09000)(r2)
174 lis r2,ha16(_a+0x09000)
175 addi r2,r2,lo16(_a+0x09000)
177 ; alt lea of a + addend
178 lis r2,hi16(_a+0x09000)
179 ori r2,r2,lo16(_a+0x09000)
181 ; absolute load of external + addend
182 lis r2,ha16(_ax+0x09000)
183 lwz r2,lo16(_ax+0x09000)(r2)
185 ; absolute lea of external + addend
186 lis r2,hi16(_ax+0x09000)
187 ori r2,r2,lo16(_ax+0x09000)
196 ; call internal + addend
197 bl _test_branches+0x19000
202 ; call external + addend
210 ; call internal + addend
216 ; call external + addend
232 movl _a-Lpicbase(%ebx), %eax
237 # absolute load of external
240 # absolute lea of external
244 # PIC load of a + addend
245 movl _a-Lpicbase+0x19000(%ebx), %eax
247 # absolute load of a + addend
248 movl _a+0x19000(%ebx), %eax
250 # absolute load of external + addend
251 movl _ax+0x19000(%ebx), %eax
253 # absolute lea of external + addend
254 leal _ax+0x1900, %eax
263 # call internal + addend
264 call _test_branches+0x19000
266 # 16-bit call internal
269 # 16-bit call internal + addend
270 callw _test_branches+13
275 # call external + addend
276 call _external+0x19000
283 # call internal + addend
289 # call external + addend
295 1: movl _foo-1b(%eax),%esi
296 movl _foo+10-1b(%eax),%esi
297 movl _test_branches-1b(%eax),%esi
298 movl _test_branches+3-1b(%eax),%esi
299 cmpl $(( (_test_branches - _test_loads) + -2097152 )),(%esp)
300 cmpl $(( (_test_calls - _test_loads) + -2097152 )),(%esp)
329 # PIC load of a + addend
330 movl _a+0x1234(%rip), %eax
335 # PIC lea through GOT
336 movq _a@GOTPCREL(%rip), %rax
339 pushq _a@GOTPCREL(%rip)
341 # PIC lea external through GOT
342 movq _ax@GOTPCREL(%rip), %rax
344 # PIC external access of GOT
345 pushq _ax@GOTPCREL(%rip)
349 movb $0x12, _a+2(%rip)
353 movl $0x12345678, _a(%rip)
354 movl $0x12345678, _a+4(%rip)
355 movl $0x12345678, L0(%rip)
368 # call internal + addend
369 call _test_branches+0x19000
374 # call external + addend
375 call _external+0x19000
382 # call internal + addend
388 # call external + addend
401 # test that pointer-diff relocs are preserved
407 .long Llocal2-_test_branches
408 .long . - _test_branches
409 .long . - _test_branches + 8
410 .long _test_branches - .
411 .long _test_branches - . + 8
412 .long _test_branches - . - 8
414 .quad Llocal2-_test_branches
432 .long _foo - _distance_to_here
433 .long _foo - _distance_to_here - 4
434 .long _foo - _distance_to_here - 12
440 L0: .quad _test_branches
442 .quad _test_branches+4
443 L1: .quad _test_branches - _test_diffs
444 .quad _test_branches - _test_diffs + 4
445 .long _test_branches - _test_diffs
446 # .long LCL0-. ### assembler bug: should SUB/UNSIGNED with content= LCL0-24, or single pc-rel SIGNED reloc with content = LCL0-.+4
449 .quad _test_branches - .
450 .quad _test_branches - L1
452 #tests support for 32-bit absolute pointers
456 # the following generates: _foo cannot be undefined in a subtraction expression
457 # but it should be ok (it will be a linker error if _foo and _bar are not in same linkage unit)
458 # .quad _foo - _bar ### assembler bug
460 .section __DATA,__data2
472 #if __ppc__ || __i386__ || __arm__
477 #elif __ppc64__ || __x86_64__
484 # test that reloc sizes are the same
491 .long Llocal4-Llocal3