2 * Copyright (c) 2006-2008 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@
25 #if __ppc__ && __PIC__
27 // Force stub section next to __text section to minimize chance that
28 // a bl to
a stub will
be out of range.
31 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
34 ////////////////////////////////////////////////////////////////////
36 // The dyld_stub_binding_helper adds the mach_header parameter
37 // and then jumps into dyld via
a pointer in __dyld section
39 ////////////////////////////////////////////////////////////////////
41 .private_extern dyld_stub_binding_helper
43 dyld_stub_binding_helper
:
46 // for ppc the mach_header parameter is place in
r12
47 // and the lazy_pointer is already in
r11
54 addis r12,r12,ha16
(Ldyld_content_lazy_binder-L1
)
55 lwz r12,lo16
(Ldyld_content_lazy_binder-L1
)(r12)
58 addis r12,r12,ha16
(dyld__mach_header-L1
)
59 lwz r12,lo16
(dyld__mach_header-L1
)(r12)
62 lis r12,ha16
(Ldyld_content_lazy_binder
)
63 lwz r12,lo16
(Ldyld_content_lazy_binder
)(r12)
65 lis r12,ha16
(___dso_handle
)
66 la r12,lo16
(___dso_handle
)(r12)
71 // for ppc the mach_header parameter is place in
r12
72 // and the lazy_pointer is already in
r11
73 // always use PIC code so we can have
4GB zero page
79 addis r12,r12,ha16
(Ldyld_content_lazy_binder-L1
)
80 ld r12,lo16
(Ldyld_content_lazy_binder-L1
)(r12)
83 addis r12,r12,ha16
(dyld__mach_header-L1
)
84 ld r12,lo16
(dyld__mach_header-L1
)(r12)
88 // for i386 the mach_header parameter is pushed on the stack
89 // and the lazy_pointer is already on the stack
96 movl dyld__mach_header-L1
(%eax
),%ecx
98 movl Ldyld_content_lazy_binder-L1
(%eax
),%ecx
102 ret
// jumps into dyld with lp
and mh on the stack
105 jmpl
*Ldyld_content_lazy_binder
109 // for x86_64 the mach_header parameter is pushed on the stack
110 // and the lazy_pointer was in
r11 and is pushed on the stack
112 leaq ___dso_handle
(%rip
), %r11
114 jmp
*Ldyld_content_lazy_binder
(%rip
)
117 str ip
, [sp
, #-4]! // push address of lazy pointer
118 ldr ip
, Ldyld__mach_header_pointer
120 Ldyld__mach_header_pointer_base
:
123 str ip
, [sp
, #-4]! // push address of mach header
124 ldr ip
, Ldyld_lazy_symbol_binding_entry_point
126 Ldyld_lazy_symbol_binding_entry_point_base
:
127 ldr pc
, [pc
, ip
] // jump to dyld_lazy_symbol_binding_entry_point
132 Ldyld__mach_header_pointer
:
134 .long dyld__mach_header - (Ldyld__mach_header_pointer_base + 8)
138 Ldyld_lazy_symbol_binding_entry_point
:
140 .long Ldyld_content_lazy_binder - (Ldyld_lazy_symbol_binding_entry_point_base + 8)
142 .long Ldyld_content_lazy_binder
148 ////////////////////////////////////////////////////////////////////
150 // cfm_stub_binding_helper
152 // only needed by ppc dylibs which support CFM clients
154 ////////////////////////////////////////////////////////////////////
155 #if __ppc__ && CFM_GLUE
158 .private_extern cfm_stub_binding_helper
159 cfm_stub_binding_helper
:
160 mr r11, r12 ; The TVector address is the binding pointer address.
161 b dyld_stub_binding_helper ; Let the normal code handle the rest.
166 ////////////////////////////////////////////////////////////////////
168 // __dyld_func_lookup
(const char
*, void
**)
170 // jumps into dyld via
a pointer in __dyld section
172 ////////////////////////////////////////////////////////////////////
174 .private_extern __dyld_func_lookup
184 addis r11,r11,ha16
(Ldyld_content_func_lookup-L2
)
185 lwz r11,lo16
(Ldyld_content_func_lookup-L2
)(r11)
189 lis r11,ha16
(Ldyld_content_func_lookup
)
190 lwz r11,lo16
(Ldyld_content_func_lookup
)(r11)
200 addis r11,r11,ha16
(Ldyld_content_func_lookup-L2
)
201 ld r11,lo16
(Ldyld_content_func_lookup-L2
)(r11)
209 movl Ldyld_content_func_lookup-L2
(%eax
),%eax
212 jmpl
*Ldyld_content_func_lookup
216 jmp
*Ldyld_content_func_lookup
(%rip
)
219 ldr ip
, L__dyld_func_lookup_pointer
221 L__dyld_func_lookup_pointer_base
:
226 L__dyld_func_lookup_pointer
:
228 .long Ldyld_content_func_lookup - (L__dyld_func_lookup_pointer_base + 8)
230 .long Ldyld_content_func_lookup
237 #define align_pointer align 3
240 #define align_pointer align 2
246 #if __ppc64__ || ((__i386__ || __ppc__ || __arm__) && __PIC__)
247 ////////////////////////////////////////////////////////////////////
250 // contains
a pointer to the mach_header for this linkage unit
251 // only needed for some code models
253 ////////////////////////////////////////////////////////////////////
257 .pointer ___dso_handle
261 ////////////////////////////////////////////////////////////////////
263 // __dyld section content
265 // 0: pointer to lazy symbol binder in dyld
266 // 1: pointer to dyld_func_lookup implementation in dyld
268 ////////////////////////////////////////////////////////////////////
270 Ldyld_base_addr
= 0x8fe00000
272 Ldyld_base_addr
= 0x00007fff5fc00000
274 Ldyld_base_addr
= 0x8fe00000
276 Ldyld_base_addr
= 0x00007fff5fc00000
278 Ldyld_base_addr
= 0x2fe00000
281 #error unknown architecture
287 Ldyld_content_lazy_binder
:
288 .pointer Ldyld_base_addr + 0x1000
289 Ldyld_content_func_lookup
:
290 .pointer Ldyld_base_addr + 0x1008
291 #if CRT && !OLD_LIBSYSTEM_SUPPORT
292 .pointer ___dso_handle
300 // This code has
be written to allow dead code stripping
301 .subsections_via_symbols