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@
40 @ sorta-absolute load of a
44 @ sorta-absolute load of c
48 @ sorta-absolute load of external
52 @ PIC load of a + addend ??
66 @ call internal + addend
67 bl _test_branches+0x19000
72 @ call external + addend
80 @ call internal + addend
86 @ call external + addend
90 #if __ppc__ || __ppc64__
102 addis r2,r10,ha16(_a-Lpicbase)
103 lwz r2,lo16(_a-Lpicbase)(r2)
106 addis r2,r10,ha16(_c-Lpicbase)
107 lwz r2,lo16(_c-Lpicbase)(r2)
117 ; absolute load of external
121 ; absolute lea of external
126 ; PIC load of a + addend
127 addis r2,r10,ha16(_a+0x19000-Lpicbase)
128 lwz r2,lo16(_a+0x19000-Lpicbase)(r2)
130 ; absolute load of a + addend
131 lis r2,ha16(_a+0x19000)
132 lwz r2,lo16(_a+0x19000)(r2)
135 lis r2,ha16(_a+0x19000)
136 addi r2,r2,lo16(_a+0x19000)
138 ; alt lea of a + addend
139 lis r2,hi16(_a+0x19000)
140 ori r2,r2,lo16(_a+0x19000)
142 ; absolute load of external + addend
143 lis r2,ha16(_ax+0x19000)
144 lwz r2,lo16(_ax+0x19000)(r2)
146 ; absolute lea of external + addend
147 lis r2,hi16(_ax+0x19000)
148 ori r2,r2,lo16(_ax+0x19000)
151 ; PIC load of a + addend
152 addis r2,r10,ha16(_a+0x09000-Lpicbase)
153 lwz r2,lo16(_a+0x09000-Lpicbase)(r2)
155 ; absolute load of a + addend
156 lis r2,ha16(_a+0x09000)
157 lwz r2,lo16(_a+0x09000)(r2)
160 lis r2,ha16(_a+0x09000)
161 addi r2,r2,lo16(_a+0x09000)
163 ; alt lea of a + addend
164 lis r2,hi16(_a+0x09000)
165 ori r2,r2,lo16(_a+0x09000)
167 ; absolute load of external + addend
168 lis r2,ha16(_ax+0x09000)
169 lwz r2,lo16(_ax+0x09000)(r2)
171 ; absolute lea of external + addend
172 lis r2,hi16(_ax+0x09000)
173 ori r2,r2,lo16(_ax+0x09000)
182 ; call internal + addend
183 bl _test_branches+0x19000
188 ; call external + addend
196 ; call internal + addend
202 ; call external + addend
218 movl _a-Lpicbase(%ebx), %eax
223 # absolute load of external
226 # absolute lea of external
230 # PIC load of a + addend
231 movl _a-Lpicbase+0x19000(%ebx), %eax
233 # absolute load of a + addend
234 movl _a+0x19000(%ebx), %eax
236 # absolute load of external + addend
237 movl _ax+0x19000(%ebx), %eax
239 # absolute lea of external + addend
240 leal _ax+0x1900, %eax
249 # call internal + addend
250 call _test_branches+0x19000
255 # call external + addend
256 call _external+0x19000
263 # call internal + addend
269 # call external + addend
275 1: movl _foo-1b(%eax),%esi
276 movl _foo+10-1b(%eax),%esi
277 movl _test_branches-1b(%eax),%esi
278 movl _test_branches+3-1b(%eax),%esi
306 # PIC load of a + addend
307 movl _a+0x1234(%rip), %eax
312 # PIC lea through GOT
313 movq _a@GOTPCREL(%rip), %rax
316 pushq _a@GOTPCREL(%rip)
318 # PIC lea external through GOT
319 movq _ax@GOTPCREL(%rip), %rax
321 # PIC external access of GOT
322 pushq _ax@GOTPCREL(%rip)
326 movb $0x12, _a+2(%rip)
330 movl $0x12345678, _a(%rip)
331 movl $0x12345678, _a+4(%rip)
332 movl $0x12345678, L0(%rip)
345 # call internal + addend
346 call _test_branches+0x19000
351 # call external + addend
352 call _external+0x19000
359 # call internal + addend
365 # call external + addend
378 # test that pointer-diff relocs are preserved
384 .long Llocal2-_test_branches
385 .long . - _test_branches
386 .long . - _test_branches + 8
387 .long _test_branches - .
388 .long _test_branches - . + 8
389 .long _test_branches - . - 8
391 .quad Llocal2-_test_branches
409 .long _foo - _distance_to_here
410 .long _foo - _distance_to_here - 4
411 .long _foo - _distance_to_here - 12
417 L0: .quad _test_branches
419 .quad _test_branches+4
420 L1: .quad _test_branches - _test_diffs
421 .quad _test_branches - _test_diffs + 4
422 .long _test_branches - _test_diffs
423 # .long LCL0-. ### assembler bug: should SUB/UNSIGNED with content= LCL0-24, or single pc-rel SIGNED reloc with content = LCL0-.+4
426 .quad _test_branches - .
427 .quad _test_branches - L1
430 # the following generates: _foo cannot be undefined in a subtraction expression
431 # but it should be ok (it will be a linker error if _foo and _bar are not in same linkage unit)
432 # .quad _foo - _bar ### assembler bug
434 .section __DATA,__data2
446 #if __ppc__ || __i386__ || __arm__
451 #elif __ppc64__ || __x86_64__
458 # test that reloc sizes are the same
465 .long Llocal4-Llocal3