1
/* -----------------------------------------------------------------------
2
sysv.S - Copyright (c) 1996, 1998, 2001, 2002, 2003, 2005 Red Hat, Inc.
4
X86 Foreign Function Interface
6
Permission is hereby granted, free of charge, to any person obtaining
7
a copy of this software and associated documentation files (the
8
``Software''), to deal in the Software without restriction, including
9
without limitation the rights to use, copy, modify, merge, publish,
10
distribute, sublicense, and/or sell copies of the Software, and to
11
permit persons to whom the Software is furnished to do so, subject to
12
the following conditions:
14
The above copyright notice and this permission notice shall be included
15
in all copies or substantial portions of the Software.
17
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
OTHER DEALINGS IN THE SOFTWARE.
24
----------------------------------------------------------------------- */
29
#include <fficonfig.h>
38
.type ffi_call_SYSV,@function
46
/* Make room for all of the new args. */
52
/* Place all of the ffi_prep_args in position */
57
/* Return stack to previous state and call the function */
62
/* Remove the space we pushed for the args */
66
/* Load %ecx with the return type code */
69
/* If the return value pointer is NULL, assume no return value. */
73
/* Even if there is no space for the return value, we are
74
obliged to handle floating-point values. */
75
cmpl $FFI_TYPE_FLOAT,%ecx
82
cmpl $FFI_TYPE_INT,%ecx
84
/* Load %ecx with the pointer to storage for the return value */
90
cmpl $FFI_TYPE_FLOAT,%ecx
92
/* Load %ecx with the pointer to storage for the return value */
98
cmpl $FFI_TYPE_DOUBLE,%ecx
100
/* Load %ecx with the pointer to storage for the return value */
106
cmpl $FFI_TYPE_LONGDOUBLE,%ecx
108
/* Load %ecx with the pointer to storage for the return value */
114
cmpl $FFI_TYPE_SINT64,%ecx
116
/* Load %ecx with the pointer to storage for the return value */
131
.size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
134
FFI_HIDDEN (ffi_closure_SYSV)
135
.globl ffi_closure_SYSV
136
.type ffi_closure_SYSV, @function
146
movl %edx, -12(%ebp) /* resp */
148
movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
150
movl %edx, (%esp) /* &resp */
151
#if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
152
call ffi_closure_SYSV_inner
158
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
159
call ffi_closure_SYSV_inner@PLT
163
cmpl $FFI_TYPE_INT, %eax
165
cmpl $FFI_TYPE_FLOAT, %eax
167
cmpl $FFI_TYPE_DOUBLE, %eax
169
cmpl $FFI_TYPE_LONGDOUBLE, %eax
171
cmpl $FFI_TYPE_SINT64, %eax
194
.size ffi_closure_SYSV, .-ffi_closure_SYSV
198
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
199
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
200
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
201
#define CIF_FLAGS_OFFSET 20
204
FFI_HIDDEN (ffi_closure_raw_SYSV)
205
.globl ffi_closure_raw_SYSV
206
.type ffi_closure_raw_SYSV, @function
208
ffi_closure_raw_SYSV:
217
movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
218
movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
219
movl %edx, 12(%esp) /* user_data */
220
leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
221
movl %edx, 8(%esp) /* raw_args */
223
movl %edx, 4(%esp) /* &res */
224
movl %esi, (%esp) /* cif */
225
call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
226
movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
227
cmpl $FFI_TYPE_INT, %eax
229
cmpl $FFI_TYPE_FLOAT, %eax
231
cmpl $FFI_TYPE_DOUBLE, %eax
233
cmpl $FFI_TYPE_LONGDOUBLE, %eax
235
cmpl $FFI_TYPE_SINT64, %eax
259
.size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
262
.section .eh_frame,EH_FRAME_FLAGS,@progbits
264
.long .LECIE1-.LSCIE1 /* Length of Common Information Entry */
266
.long 0x0 /* CIE Identifier Tag */
267
.byte 0x1 /* CIE Version */
269
.ascii "zR\0" /* CIE Augmentation */
271
.ascii "\0" /* CIE Augmentation */
273
.byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
274
.byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
275
.byte 0x8 /* CIE RA Column */
277
.byte 0x1 /* .uleb128 0x1; Augmentation size */
278
.byte 0x1b /* FDE Encoding (pcrel sdata4) */
280
.byte 0xc /* DW_CFA_def_cfa */
281
.byte 0x4 /* .uleb128 0x4 */
282
.byte 0x4 /* .uleb128 0x4 */
283
.byte 0x88 /* DW_CFA_offset, column 0x8 */
284
.byte 0x1 /* .uleb128 0x1 */
288
.long .LEFDE1-.LASFDE1 /* FDE Length */
290
.long .LASFDE1-.Lframe1 /* FDE CIE offset */
292
.long .LFB1-. /* FDE initial location */
294
.long .LFB1 /* FDE initial location */
296
.long .LFE1-.LFB1 /* FDE address range */
298
.byte 0x0 /* .uleb128 0x0; Augmentation size */
300
.byte 0x4 /* DW_CFA_advance_loc4 */
302
.byte 0xe /* DW_CFA_def_cfa_offset */
303
.byte 0x8 /* .uleb128 0x8 */
304
.byte 0x85 /* DW_CFA_offset, column 0x5 */
305
.byte 0x2 /* .uleb128 0x2 */
306
.byte 0x4 /* DW_CFA_advance_loc4 */
308
.byte 0xd /* DW_CFA_def_cfa_register */
309
.byte 0x5 /* .uleb128 0x5 */
313
.long .LEFDE2-.LASFDE2 /* FDE Length */
315
.long .LASFDE2-.Lframe1 /* FDE CIE offset */
317
.long .LFB2-. /* FDE initial location */
321
.long .LFE2-.LFB2 /* FDE address range */
323
.byte 0x0 /* .uleb128 0x0; Augmentation size */
325
.byte 0x4 /* DW_CFA_advance_loc4 */
327
.byte 0xe /* DW_CFA_def_cfa_offset */
328
.byte 0x8 /* .uleb128 0x8 */
329
.byte 0x85 /* DW_CFA_offset, column 0x5 */
330
.byte 0x2 /* .uleb128 0x2 */
331
.byte 0x4 /* DW_CFA_advance_loc4 */
333
.byte 0xd /* DW_CFA_def_cfa_register */
334
.byte 0x5 /* .uleb128 0x5 */
335
#if !defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE && defined __PIC__
336
.byte 0x4 /* DW_CFA_advance_loc4 */
338
.byte 0x83 /* DW_CFA_offset, column 0x3 */
339
.byte 0xa /* .uleb128 0xa */
347
.long .LEFDE3-.LASFDE3 /* FDE Length */
349
.long .LASFDE3-.Lframe1 /* FDE CIE offset */
351
.long .LFB3-. /* FDE initial location */
355
.long .LFE3-.LFB3 /* FDE address range */
357
.byte 0x0 /* .uleb128 0x0; Augmentation size */
359
.byte 0x4 /* DW_CFA_advance_loc4 */
361
.byte 0xe /* DW_CFA_def_cfa_offset */
362
.byte 0x8 /* .uleb128 0x8 */
363
.byte 0x85 /* DW_CFA_offset, column 0x5 */
364
.byte 0x2 /* .uleb128 0x2 */
365
.byte 0x4 /* DW_CFA_advance_loc4 */
367
.byte 0xd /* DW_CFA_def_cfa_register */
368
.byte 0x5 /* .uleb128 0x5 */
369
.byte 0x4 /* DW_CFA_advance_loc4 */
371
.byte 0x86 /* DW_CFA_offset, column 0x6 */
372
.byte 0x3 /* .uleb128 0x3 */
378
#endif /* ifndef __x86_64__ */