1 /* -----------------------------------------------------------------------
2 darwin_closure.S - Copyright (c) 2002, 2003, 2004, Free Software Foundation,
3 Inc. based on ppc_closure.S
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 ``Software''), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
30 .file "darwin_closure.S"
33 .globl _ffi_closure_ASM
39 mflr r0 /* extract return address */
40 stw r0, 8(r1) /* save the return address */
42 /* 24 Bytes (Linkage Area)
43 32 Bytes (outgoing parameter area, always reserved)
44 104 Bytes (13*8 from FPR)
48 stwu r1,-176(r1) /* skip over caller save area
49 keep stack aligned to 16. */
51 /* We want to build up an area for the parameters passed
52 in registers. (both floating point and integer) */
54 /* We store gpr 3 to gpr 10 (aligned to 4)
55 in the parents outgoing area. */
65 /* We save fpr 1 to fpr 13. (aligned to 8) */
80 /* Set up registers for the routine that actually does the work
81 get the context pointer from the trampoline. */
84 /* Now load up the pointer to the result storage. */
87 /* Now load up the pointer to the saved gpr registers. */
90 /* Now load up the pointer to the saved fpr registers. */
94 bl Lffi_closure_helper_DARWIN$stub
96 /* Now r3 contains the return type
97 so use it to look up in a table
98 so we know how to deal with each type. */
100 /* Look up the proper starting point in table
101 by using return type as offset. */
102 addi r5,r1,160 /* Get pointer to results area. */
103 bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */
104 mflr r4 /* Move to r4. */
105 slwi r3,r3,4 /* Now multiply return type by 16. */
106 add r3,r3,r4 /* Add contents of table to table address. */
108 bctr /* Jump to it. */
110 /* Each of the ret_typeX code fragments has to be exactly 16 bytes long
111 (4 instructions). For cache effectiveness we align to a 16 byte boundary
122 /* case FFI_TYPE_VOID */
129 /* case FFI_TYPE_INT */
136 /* case FFI_TYPE_FLOAT */
143 /* case FFI_TYPE_DOUBLE */
150 /* case FFI_TYPE_LONGDOUBLE */
157 /* case FFI_TYPE_UINT8 */
164 /* case FFI_TYPE_SINT8 */
171 /* case FFI_TYPE_UINT16 */
178 /* case FFI_TYPE_SINT16 */
185 /* case FFI_TYPE_UINT32 */
192 /* case FFI_TYPE_SINT32 */
199 /* case FFI_TYPE_UINT64 */
206 /* case FFI_TYPE_SINT64 */
213 /* case FFI_TYPE_STRUCT */
220 /* case FFI_TYPE_POINTER */
229 addi r1,r1,176 /* Restore stack pointer. */
230 lwz r0,8(r1) /* Get return address. */
231 mtlr r0 /* Reset link register. */
234 /* END(ffi_closure_ASM) */
237 .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms
239 .set L$set$0,LECIE1-LSCIE1
240 .long L$set$0 ; Length of Common Information Entry
242 .long 0x0 ; CIE Identifier Tag
243 .byte 0x1 ; CIE Version
244 .ascii "zR\0" ; CIE Augmentation
245 .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
246 .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor
247 .byte 0x41 ; CIE RA Column
248 .byte 0x1 ; uleb128 0x1; Augmentation size
249 .byte 0x90 ; FDE Encoding (indirect pcrel)
250 .byte 0xc ; DW_CFA_def_cfa
251 .byte 0x1 ; uleb128 0x1
252 .byte 0x0 ; uleb128 0x0
255 .globl _ffi_closure_ASM.eh
258 .set L$set$1,LEFDE1-LASFDE1
259 .long L$set$1 ; FDE Length
262 .long LASFDE1-EH_frame1 ; FDE CIE offset
263 .long LLFB1$non_lazy_ptr-. ; FDE initial location
264 .set L$set$3,LFE1-LFB1
265 .long L$set$3 ; FDE address range
266 .byte 0x0 ; uleb128 0x0; Augmentation size
267 .byte 0x4 ; DW_CFA_advance_loc4
268 .set L$set$3,LCFI1-LCFI0
270 .byte 0xe ; DW_CFA_def_cfa_offset
271 .byte 176,1 ; uleb128 176
272 .byte 0x4 ; DW_CFA_advance_loc4
273 .set L$set$4,LCFI0-LFB1
275 .byte 0x11 ; DW_CFA_offset_extended_sf
276 .byte 0x41 ; uleb128 0x41
277 .byte 0x7e ; sleb128 -2
283 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
285 Lffi_closure_helper_DARWIN$stub:
286 .indirect_symbol _ffi_closure_helper_DARWIN
288 bcl 20,31,LO$ffi_closure_helper_DARWIN
289 LO$ffi_closure_helper_DARWIN:
291 addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)
293 lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)(r11)
298 L_ffi_closure_helper_DARWIN$lazy_ptr:
299 .indirect_symbol _ffi_closure_helper_DARWIN
300 .long dyld_stub_binding_helper