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@
24 #if __ppc__ || __ppc64__
36 addis r2,r10,ha16(_a-Lpicbase)
37 lwz r2,lo16(_a-Lpicbase)(r2)
40 addis r2,r10,ha16(_c-Lpicbase)
41 lwz r2,lo16(_c-Lpicbase)(r2)
51 ; absolute load of external
55 ; absolute lea of external
60 ; PIC load of a + addend
61 addis r2,r10,ha16(_a+0x19000-Lpicbase)
62 lwz r2,lo16(_a+0x19000-Lpicbase)(r2)
64 ; absolute load of a + addend
65 lis r2,ha16(_a+0x19000)
66 lwz r2,lo16(_a+0x19000)(r2)
68 ; absolute load of external + addend
69 lis r2,ha16(_ax+0x19000)
70 lwz r2,lo16(_ax+0x19000)(r2)
72 ; absolute lea of external + addend
73 lis r2,hi16(_ax+0x19000)
74 ori r2,r2,lo16(_ax+0x19000)
77 ; PIC load of a + addend
78 addis r2,r10,ha16(_a+0x09000-Lpicbase)
79 lwz r2,lo16(_a+0x09000-Lpicbase)(r2)
81 ; absolute load of a + addend
82 lis r2,ha16(_a+0x09000)
83 lwz r2,lo16(_a+0x09000)(r2)
85 ; absolute load of external + addend
86 lis r2,ha16(_ax+0x09000)
87 lwz r2,lo16(_ax+0x09000)(r2)
89 ; absolute lea of external + addend
90 lis r2,hi16(_ax+0x09000)
91 ori r2,r2,lo16(_ax+0x09000)
100 ; call internal + addend
101 bl _test_branches+0x19000
106 ; call external + addend
114 ; call internal + addend
120 ; call external + addend
136 movl _a-Lpicbase(%ebx), %eax
141 # absolute load of external
144 # absolute lea of external
148 # PIC load of a + addend
149 movl _a-Lpicbase+0x19000(%ebx), %eax
151 # absolute load of a + addend
152 movl _a+0x19000(%ebx), %eax
154 # absolute load of external + addend
155 movl _ax+0x19000(%ebx), %eax
157 # absolute lea of external + addend
158 leal _ax+0x1900, %eax
167 # call internal + addend
168 call _test_branches+0x19000
173 # call external + addend
174 call _external+0x19000
181 # call internal + addend
187 # call external + addend
193 1: movl _foo-1b(%eax),%esi
194 movl _foo+10-1b(%eax),%esi
195 movl _test_branches-1b(%eax),%esi
196 movl _test_branches+3-1b(%eax),%esi
215 # PIC load of a + addend
216 movl _a+0x1234(%rip), %eax
221 # PIC lea through GOT
222 movq _a@GOTPCREL(%rip), %rax
225 pushq _a@GOTPCREL(%rip)
227 # PIC lea external through GOT
228 movq _ax@GOTPCREL(%rip), %rax
230 # PIC external access of GOT
231 pushq _ax@GOTPCREL(%rip)
235 movb $0x12, _a+2(%rip)
239 movl $0x12345678, _a(%rip)
240 movl $0x12345678, _a+4(%rip)
241 movl $0x12345678, L0(%rip)
254 # call internal + addend
255 call _test_branches+0x19000
260 # call external + addend
261 call _external+0x19000
268 # call internal + addend
274 # call external + addend
280 # test that pointer-diff relocs are preserved
286 .long Llocal2-_test_branches
287 .long . - _test_branches
288 .long . - _test_branches + 8
289 .long _test_branches - .
290 .long _test_branches - . + 8
291 .long _test_branches - . - 8
293 .quad Llocal2-_test_branches
311 .long _foo - _distance_to_here
312 .long _foo - _distance_to_here - 4
313 .long _foo - _distance_to_here - 12
319 L0: .quad _test_branches
321 .quad _test_branches+4
322 L1: .quad _test_branches - _test_diffs
323 .quad _test_branches - _test_diffs + 4
324 .long _test_branches - _test_diffs
325 # .long LCL0-. ### assembler bug: should SUB/UNSIGNED with content= LCL0-24, or single pc-rel SIGNED reloc with content = LCL0-.+4
328 .quad _test_branches - .
329 .quad _test_branches - L1
332 # the following generates: _foo cannot be undefined in a subtraction expression
333 # but it should be ok (it will be a linker error if _foo and _bar are not in same linkage unit)
334 # .quad _foo - _bar ### assembler bug
336 .section __DATA,__data2
348 #if __ppc__ || __i386__
353 #elif __ppc64__ || __x86_64__
360 # test that reloc sizes are the same
367 .long Llocal4-Llocal3