2 * Copyright (c) 1999 Apple Computer, 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@
28 * This is the interface for the stub_binding_helper for i386:
29 * The caller has pushed the address of the a lazy pointer to be filled in with
30 * the value for the defined symbol and pushed the address of the the mach
31 * header this pointer comes from.
33 * sp+4 address of lazy pointer
34 * sp+0 address of mach header
36 * After the symbol has been resolved and the pointer filled in this is to pop
37 * these arguments off the stack and jump to the address of the defined symbol.
41 .globl _stub_binding_helper_interface
42 _stub_binding_helper_interface:
43 call __ZN4dyld14bindLazySymbolEPK11mach_headerPm
49 #if __ppc__ || __ppc64__
50 #include <architecture/ppc/mode_independent_asm.h>
52 * This is the interface for the stub_binding_helper for the ppc:
53 * The caller has placed in r11 the address of the a lazy pointer to be filled
54 * in with the value for the defined symbol and placed in r12 the address of
55 * the the mach header this pointer comes from.
57 * r11 address of lazy pointer
58 * r12 address of mach header
60 #define LRSAVE MODE_CHOICE(8,16)
61 #define STACK_SIZE MODE_CHOICE(144,288)
62 #define R3SAVE MODE_CHOICE(56,112)
63 #define R4SAVE MODE_CHOICE(60,120)
64 #define R5SAVE MODE_CHOICE(64,128)
65 #define R6SAVE MODE_CHOICE(68,136)
66 #define R7SAVE MODE_CHOICE(72,144)
67 #define R8SAVE MODE_CHOICE(76,152)
68 #define R9SAVE MODE_CHOICE(80,160)
69 #define R10SAVE MODE_CHOICE(84,168)
74 .globl _stub_binding_helper_interface
75 _stub_binding_helper_interface:
76 mflr r0 ; get link register value
77 stg r0,LRSAVE(r1) ; save link register value in the linkage area
78 stgu r1,-STACK_SIZE(r1) ; save stack pointer and update it
80 stg r3,R3SAVE(r1) ; save all registers that could contain
81 stg r4,R4SAVE(r1) ; parameters to the routine that is being
82 stg r5,R5SAVE(r1) ; bound.
89 mr r3,r12 ; move address of mach header to 1st parameter
90 mr r4,r11 ; move address of lazy pointer to 2nd parameter
91 ; call dyld::bindLazySymbol(mh, lazy_symbol_pointer_address)
92 bl __ZN4dyld14bindLazySymbolEPK11mach_headerPm
93 mr r12,r3 ; move the symbol`s address into r12
94 mtctr r12 ; move the symbol`s address into count register
96 lg r0,STACK_SIZE+LRSAVE(r1) ; get old link register value
98 lg r3,R3SAVE(r1) ; restore all registers that could contain
99 lg r4,R4SAVE(r1) ; parameters to the routine that was bound.
107 addi r1,r1,STACK_SIZE; restore old stack pointer
108 mtlr r0 ; restore link register
110 bctr ; jump to the symbol`s address that was bound