| 1 |
732 |
jeremybenn |
/* -----------------------------------------------------------------------
|
| 2 |
|
|
win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
|
| 3 |
|
|
Copyright (c) 2001 John Beniton
|
| 4 |
|
|
Copyright (c) 2002 Ranjit Mathew
|
| 5 |
|
|
Copyright (c) 2009 Daniel Witte
|
| 6 |
|
|
|
| 7 |
|
|
|
| 8 |
|
|
X86 Foreign Function Interface
|
| 9 |
|
|
|
| 10 |
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
| 11 |
|
|
a copy of this software and associated documentation files (the
|
| 12 |
|
|
``Software''), to deal in the Software without restriction, including
|
| 13 |
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
| 14 |
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
| 15 |
|
|
permit persons to whom the Software is furnished to do so, subject to
|
| 16 |
|
|
the following conditions:
|
| 17 |
|
|
|
| 18 |
|
|
The above copyright notice and this permission notice shall be included
|
| 19 |
|
|
in all copies or substantial portions of the Software.
|
| 20 |
|
|
|
| 21 |
|
|
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
| 22 |
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 23 |
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 24 |
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 25 |
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
| 26 |
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 27 |
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 28 |
|
|
DEALINGS IN THE SOFTWARE.
|
| 29 |
|
|
-----------------------------------------------------------------------
|
| 30 |
|
|
*/
|
| 31 |
|
|
|
| 32 |
|
|
#define LIBFFI_ASM
|
| 33 |
|
|
#include
|
| 34 |
|
|
#include
|
| 35 |
|
|
|
| 36 |
|
|
#ifdef _MSC_VER
|
| 37 |
|
|
|
| 38 |
|
|
.386
|
| 39 |
|
|
.MODEL FLAT, C
|
| 40 |
|
|
|
| 41 |
|
|
EXTRN ffi_closure_SYSV_inner:NEAR
|
| 42 |
|
|
|
| 43 |
|
|
_TEXT SEGMENT
|
| 44 |
|
|
|
| 45 |
|
|
ffi_call_win32 PROC NEAR,
|
| 46 |
|
|
ffi_prep_args : NEAR PTR DWORD,
|
| 47 |
|
|
ecif : NEAR PTR DWORD,
|
| 48 |
|
|
cif_abi : DWORD,
|
| 49 |
|
|
cif_bytes : DWORD,
|
| 50 |
|
|
cif_flags : DWORD,
|
| 51 |
|
|
rvalue : NEAR PTR DWORD,
|
| 52 |
|
|
fn : NEAR PTR DWORD
|
| 53 |
|
|
|
| 54 |
|
|
;; Make room for all of the new args.
|
| 55 |
|
|
mov ecx, cif_bytes
|
| 56 |
|
|
sub esp, ecx
|
| 57 |
|
|
|
| 58 |
|
|
mov eax, esp
|
| 59 |
|
|
|
| 60 |
|
|
;; Place all of the ffi_prep_args in position
|
| 61 |
|
|
push ecif
|
| 62 |
|
|
push eax
|
| 63 |
|
|
call ffi_prep_args
|
| 64 |
|
|
|
| 65 |
|
|
;; Return stack to previous state and call the function
|
| 66 |
|
|
add esp, 8
|
| 67 |
|
|
|
| 68 |
|
|
;; Handle thiscall and fastcall
|
| 69 |
|
|
cmp cif_abi, 3 ;; FFI_THISCALL
|
| 70 |
|
|
jz do_thiscall
|
| 71 |
|
|
cmp cif_abi, 4 ;; FFI_FASTCALL
|
| 72 |
|
|
jnz do_stdcall
|
| 73 |
|
|
mov ecx, DWORD PTR [esp]
|
| 74 |
|
|
mov edx, DWORD PTR [esp+4]
|
| 75 |
|
|
add esp, 8
|
| 76 |
|
|
jmp do_stdcall
|
| 77 |
|
|
do_thiscall:
|
| 78 |
|
|
mov ecx, DWORD PTR [esp]
|
| 79 |
|
|
add esp, 4
|
| 80 |
|
|
do_stdcall:
|
| 81 |
|
|
call fn
|
| 82 |
|
|
|
| 83 |
|
|
;; cdecl: we restore esp in the epilogue, so there's no need to
|
| 84 |
|
|
;; remove the space we pushed for the args.
|
| 85 |
|
|
;; stdcall: the callee has already cleaned the stack.
|
| 86 |
|
|
|
| 87 |
|
|
;; Load ecx with the return type code
|
| 88 |
|
|
mov ecx, cif_flags
|
| 89 |
|
|
|
| 90 |
|
|
;; If the return value pointer is NULL, assume no return value.
|
| 91 |
|
|
cmp rvalue, 0
|
| 92 |
|
|
jne ca_jumptable
|
| 93 |
|
|
|
| 94 |
|
|
;; Even if there is no space for the return value, we are
|
| 95 |
|
|
;; obliged to handle floating-point values.
|
| 96 |
|
|
cmp ecx, FFI_TYPE_FLOAT
|
| 97 |
|
|
jne ca_epilogue
|
| 98 |
|
|
fstp st(0)
|
| 99 |
|
|
|
| 100 |
|
|
jmp ca_epilogue
|
| 101 |
|
|
|
| 102 |
|
|
ca_jumptable:
|
| 103 |
|
|
jmp [ca_jumpdata + 4 * ecx]
|
| 104 |
|
|
ca_jumpdata:
|
| 105 |
|
|
;; Do not insert anything here between label and jump table.
|
| 106 |
|
|
dd offset ca_epilogue ;; FFI_TYPE_VOID
|
| 107 |
|
|
dd offset ca_retint ;; FFI_TYPE_INT
|
| 108 |
|
|
dd offset ca_retfloat ;; FFI_TYPE_FLOAT
|
| 109 |
|
|
dd offset ca_retdouble ;; FFI_TYPE_DOUBLE
|
| 110 |
|
|
dd offset ca_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
| 111 |
|
|
dd offset ca_retint8 ;; FFI_TYPE_UINT8
|
| 112 |
|
|
dd offset ca_retint8 ;; FFI_TYPE_SINT8
|
| 113 |
|
|
dd offset ca_retint16 ;; FFI_TYPE_UINT16
|
| 114 |
|
|
dd offset ca_retint16 ;; FFI_TYPE_SINT16
|
| 115 |
|
|
dd offset ca_retint ;; FFI_TYPE_UINT32
|
| 116 |
|
|
dd offset ca_retint ;; FFI_TYPE_SINT32
|
| 117 |
|
|
dd offset ca_retint64 ;; FFI_TYPE_UINT64
|
| 118 |
|
|
dd offset ca_retint64 ;; FFI_TYPE_SINT64
|
| 119 |
|
|
dd offset ca_epilogue ;; FFI_TYPE_STRUCT
|
| 120 |
|
|
dd offset ca_retint ;; FFI_TYPE_POINTER
|
| 121 |
|
|
dd offset ca_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
| 122 |
|
|
dd offset ca_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
| 123 |
|
|
dd offset ca_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
| 124 |
|
|
|
| 125 |
|
|
ca_retint8:
|
| 126 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 127 |
|
|
mov ecx, rvalue
|
| 128 |
|
|
mov [ecx + 0], al
|
| 129 |
|
|
jmp ca_epilogue
|
| 130 |
|
|
|
| 131 |
|
|
ca_retint16:
|
| 132 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 133 |
|
|
mov ecx, rvalue
|
| 134 |
|
|
mov [ecx + 0], ax
|
| 135 |
|
|
jmp ca_epilogue
|
| 136 |
|
|
|
| 137 |
|
|
ca_retint:
|
| 138 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 139 |
|
|
mov ecx, rvalue
|
| 140 |
|
|
mov [ecx + 0], eax
|
| 141 |
|
|
jmp ca_epilogue
|
| 142 |
|
|
|
| 143 |
|
|
ca_retint64:
|
| 144 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 145 |
|
|
mov ecx, rvalue
|
| 146 |
|
|
mov [ecx + 0], eax
|
| 147 |
|
|
mov [ecx + 4], edx
|
| 148 |
|
|
jmp ca_epilogue
|
| 149 |
|
|
|
| 150 |
|
|
ca_retfloat:
|
| 151 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 152 |
|
|
mov ecx, rvalue
|
| 153 |
|
|
fstp DWORD PTR [ecx]
|
| 154 |
|
|
jmp ca_epilogue
|
| 155 |
|
|
|
| 156 |
|
|
ca_retdouble:
|
| 157 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 158 |
|
|
mov ecx, rvalue
|
| 159 |
|
|
fstp QWORD PTR [ecx]
|
| 160 |
|
|
jmp ca_epilogue
|
| 161 |
|
|
|
| 162 |
|
|
ca_retlongdouble:
|
| 163 |
|
|
;; Load %ecx with the pointer to storage for the return value
|
| 164 |
|
|
mov ecx, rvalue
|
| 165 |
|
|
fstp TBYTE PTR [ecx]
|
| 166 |
|
|
jmp ca_epilogue
|
| 167 |
|
|
|
| 168 |
|
|
ca_epilogue:
|
| 169 |
|
|
;; Epilogue code is autogenerated.
|
| 170 |
|
|
ret
|
| 171 |
|
|
ffi_call_win32 ENDP
|
| 172 |
|
|
|
| 173 |
|
|
ffi_closure_THISCALL PROC NEAR FORCEFRAME
|
| 174 |
|
|
push ebp
|
| 175 |
|
|
mov ebp, esp
|
| 176 |
|
|
sub esp, 40
|
| 177 |
|
|
lea edx, [ebp -24]
|
| 178 |
|
|
mov [ebp - 12], edx /* resp */
|
| 179 |
|
|
lea edx, [ebp + 12] /* account for stub return address on stack */
|
| 180 |
|
|
jmp stub
|
| 181 |
|
|
ffi_closure_THISCALL ENDP
|
| 182 |
|
|
|
| 183 |
|
|
ffi_closure_SYSV PROC NEAR FORCEFRAME
|
| 184 |
|
|
;; the ffi_closure ctx is passed in eax by the trampoline.
|
| 185 |
|
|
|
| 186 |
|
|
sub esp, 40
|
| 187 |
|
|
lea edx, [ebp - 24]
|
| 188 |
|
|
mov [ebp - 12], edx ;; resp
|
| 189 |
|
|
lea edx, [ebp + 8]
|
| 190 |
|
|
stub:
|
| 191 |
|
|
mov [esp + 8], edx ;; args
|
| 192 |
|
|
lea edx, [ebp - 12]
|
| 193 |
|
|
mov [esp + 4], edx ;; &resp
|
| 194 |
|
|
mov [esp], eax ;; closure
|
| 195 |
|
|
call ffi_closure_SYSV_inner
|
| 196 |
|
|
mov ecx, [ebp - 12]
|
| 197 |
|
|
|
| 198 |
|
|
cs_jumptable:
|
| 199 |
|
|
jmp [cs_jumpdata + 4 * eax]
|
| 200 |
|
|
cs_jumpdata:
|
| 201 |
|
|
;; Do not insert anything here between the label and jump table.
|
| 202 |
|
|
dd offset cs_epilogue ;; FFI_TYPE_VOID
|
| 203 |
|
|
dd offset cs_retint ;; FFI_TYPE_INT
|
| 204 |
|
|
dd offset cs_retfloat ;; FFI_TYPE_FLOAT
|
| 205 |
|
|
dd offset cs_retdouble ;; FFI_TYPE_DOUBLE
|
| 206 |
|
|
dd offset cs_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
| 207 |
|
|
dd offset cs_retint8 ;; FFI_TYPE_UINT8
|
| 208 |
|
|
dd offset cs_retint8 ;; FFI_TYPE_SINT8
|
| 209 |
|
|
dd offset cs_retint16 ;; FFI_TYPE_UINT16
|
| 210 |
|
|
dd offset cs_retint16 ;; FFI_TYPE_SINT16
|
| 211 |
|
|
dd offset cs_retint ;; FFI_TYPE_UINT32
|
| 212 |
|
|
dd offset cs_retint ;; FFI_TYPE_SINT32
|
| 213 |
|
|
dd offset cs_retint64 ;; FFI_TYPE_UINT64
|
| 214 |
|
|
dd offset cs_retint64 ;; FFI_TYPE_SINT64
|
| 215 |
|
|
dd offset cs_retstruct ;; FFI_TYPE_STRUCT
|
| 216 |
|
|
dd offset cs_retint ;; FFI_TYPE_POINTER
|
| 217 |
|
|
dd offset cs_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
| 218 |
|
|
dd offset cs_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
| 219 |
|
|
dd offset cs_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
| 220 |
|
|
|
| 221 |
|
|
cs_retint8:
|
| 222 |
|
|
mov al, [ecx]
|
| 223 |
|
|
jmp cs_epilogue
|
| 224 |
|
|
|
| 225 |
|
|
cs_retint16:
|
| 226 |
|
|
mov ax, [ecx]
|
| 227 |
|
|
jmp cs_epilogue
|
| 228 |
|
|
|
| 229 |
|
|
cs_retint:
|
| 230 |
|
|
mov eax, [ecx]
|
| 231 |
|
|
jmp cs_epilogue
|
| 232 |
|
|
|
| 233 |
|
|
cs_retint64:
|
| 234 |
|
|
mov eax, [ecx + 0]
|
| 235 |
|
|
mov edx, [ecx + 4]
|
| 236 |
|
|
jmp cs_epilogue
|
| 237 |
|
|
|
| 238 |
|
|
cs_retfloat:
|
| 239 |
|
|
fld DWORD PTR [ecx]
|
| 240 |
|
|
jmp cs_epilogue
|
| 241 |
|
|
|
| 242 |
|
|
cs_retdouble:
|
| 243 |
|
|
fld QWORD PTR [ecx]
|
| 244 |
|
|
jmp cs_epilogue
|
| 245 |
|
|
|
| 246 |
|
|
cs_retlongdouble:
|
| 247 |
|
|
fld TBYTE PTR [ecx]
|
| 248 |
|
|
jmp cs_epilogue
|
| 249 |
|
|
|
| 250 |
|
|
cs_retstruct:
|
| 251 |
|
|
;; Caller expects us to pop struct return value pointer hidden arg.
|
| 252 |
|
|
;; Epilogue code is autogenerated.
|
| 253 |
|
|
ret 4
|
| 254 |
|
|
|
| 255 |
|
|
cs_epilogue:
|
| 256 |
|
|
;; Epilogue code is autogenerated.
|
| 257 |
|
|
ret
|
| 258 |
|
|
ffi_closure_SYSV ENDP
|
| 259 |
|
|
|
| 260 |
|
|
#if !FFI_NO_RAW_API
|
| 261 |
|
|
|
| 262 |
|
|
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
|
| 263 |
|
|
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
|
| 264 |
|
|
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
|
| 265 |
|
|
#define CIF_FLAGS_OFFSET 20
|
| 266 |
|
|
|
| 267 |
|
|
ffi_closure_raw_THISCALL PROC NEAR
|
| 268 |
|
|
push ebp
|
| 269 |
|
|
mov ebp, esp
|
| 270 |
|
|
push esi
|
| 271 |
|
|
sub esp, 36
|
| 272 |
|
|
mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
|
| 273 |
|
|
mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
|
| 274 |
|
|
mov [esp + 12], edx
|
| 275 |
|
|
lea edx, [ebp + 12], edx
|
| 276 |
|
|
jmp stubraw
|
| 277 |
|
|
ffi_closure_raw_SYSV ENDP
|
| 278 |
|
|
|
| 279 |
|
|
ffi_closure_raw_SYSV PROC NEAR USES esi
|
| 280 |
|
|
;; the ffi_closure ctx is passed in eax by the trampoline.
|
| 281 |
|
|
|
| 282 |
|
|
sub esp, 40
|
| 283 |
|
|
mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
|
| 284 |
|
|
mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
|
| 285 |
|
|
mov [esp + 12], edx ;; user_data
|
| 286 |
|
|
lea edx, [ebp + 8]
|
| 287 |
|
|
stubraw:
|
| 288 |
|
|
mov [esp + 8], edx ;; raw_args
|
| 289 |
|
|
lea edx, [ebp - 24]
|
| 290 |
|
|
mov [esp + 4], edx ;; &res
|
| 291 |
|
|
mov [esp], esi ;; cif
|
| 292 |
|
|
call DWORD PTR [eax + RAW_CLOSURE_FUN_OFFSET] ;; closure->fun
|
| 293 |
|
|
mov eax, [esi + CIF_FLAGS_OFFSET] ;; cif->flags
|
| 294 |
|
|
lea ecx, [ebp - 24]
|
| 295 |
|
|
|
| 296 |
|
|
cr_jumptable:
|
| 297 |
|
|
jmp [cr_jumpdata + 4 * eax]
|
| 298 |
|
|
cr_jumpdata:
|
| 299 |
|
|
;; Do not insert anything here between the label and jump table.
|
| 300 |
|
|
dd offset cr_epilogue ;; FFI_TYPE_VOID
|
| 301 |
|
|
dd offset cr_retint ;; FFI_TYPE_INT
|
| 302 |
|
|
dd offset cr_retfloat ;; FFI_TYPE_FLOAT
|
| 303 |
|
|
dd offset cr_retdouble ;; FFI_TYPE_DOUBLE
|
| 304 |
|
|
dd offset cr_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
| 305 |
|
|
dd offset cr_retint8 ;; FFI_TYPE_UINT8
|
| 306 |
|
|
dd offset cr_retint8 ;; FFI_TYPE_SINT8
|
| 307 |
|
|
dd offset cr_retint16 ;; FFI_TYPE_UINT16
|
| 308 |
|
|
dd offset cr_retint16 ;; FFI_TYPE_SINT16
|
| 309 |
|
|
dd offset cr_retint ;; FFI_TYPE_UINT32
|
| 310 |
|
|
dd offset cr_retint ;; FFI_TYPE_SINT32
|
| 311 |
|
|
dd offset cr_retint64 ;; FFI_TYPE_UINT64
|
| 312 |
|
|
dd offset cr_retint64 ;; FFI_TYPE_SINT64
|
| 313 |
|
|
dd offset cr_epilogue ;; FFI_TYPE_STRUCT
|
| 314 |
|
|
dd offset cr_retint ;; FFI_TYPE_POINTER
|
| 315 |
|
|
dd offset cr_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
| 316 |
|
|
dd offset cr_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
| 317 |
|
|
dd offset cr_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
| 318 |
|
|
|
| 319 |
|
|
cr_retint8:
|
| 320 |
|
|
mov al, [ecx]
|
| 321 |
|
|
jmp cr_epilogue
|
| 322 |
|
|
|
| 323 |
|
|
cr_retint16:
|
| 324 |
|
|
mov ax, [ecx]
|
| 325 |
|
|
jmp cr_epilogue
|
| 326 |
|
|
|
| 327 |
|
|
cr_retint:
|
| 328 |
|
|
mov eax, [ecx]
|
| 329 |
|
|
jmp cr_epilogue
|
| 330 |
|
|
|
| 331 |
|
|
cr_retint64:
|
| 332 |
|
|
mov eax, [ecx + 0]
|
| 333 |
|
|
mov edx, [ecx + 4]
|
| 334 |
|
|
jmp cr_epilogue
|
| 335 |
|
|
|
| 336 |
|
|
cr_retfloat:
|
| 337 |
|
|
fld DWORD PTR [ecx]
|
| 338 |
|
|
jmp cr_epilogue
|
| 339 |
|
|
|
| 340 |
|
|
cr_retdouble:
|
| 341 |
|
|
fld QWORD PTR [ecx]
|
| 342 |
|
|
jmp cr_epilogue
|
| 343 |
|
|
|
| 344 |
|
|
cr_retlongdouble:
|
| 345 |
|
|
fld TBYTE PTR [ecx]
|
| 346 |
|
|
jmp cr_epilogue
|
| 347 |
|
|
|
| 348 |
|
|
cr_epilogue:
|
| 349 |
|
|
;; Epilogue code is autogenerated.
|
| 350 |
|
|
ret
|
| 351 |
|
|
ffi_closure_raw_SYSV ENDP
|
| 352 |
|
|
|
| 353 |
|
|
#endif /* !FFI_NO_RAW_API */
|
| 354 |
|
|
|
| 355 |
|
|
ffi_closure_STDCALL PROC NEAR FORCEFRAME
|
| 356 |
|
|
;; the ffi_closure ctx is passed in eax by the trampoline.
|
| 357 |
|
|
|
| 358 |
|
|
sub esp, 40
|
| 359 |
|
|
lea edx, [ebp - 24]
|
| 360 |
|
|
mov [ebp - 12], edx ;; resp
|
| 361 |
|
|
lea edx, [ebp + 12] ;; account for stub return address on stack
|
| 362 |
|
|
mov [esp + 8], edx ;; args
|
| 363 |
|
|
lea edx, [ebp - 12]
|
| 364 |
|
|
mov [esp + 4], edx ;; &resp
|
| 365 |
|
|
mov [esp], eax ;; closure
|
| 366 |
|
|
call ffi_closure_SYSV_inner
|
| 367 |
|
|
mov ecx, [ebp - 12]
|
| 368 |
|
|
|
| 369 |
|
|
cd_jumptable:
|
| 370 |
|
|
jmp [cd_jumpdata + 4 * eax]
|
| 371 |
|
|
cd_jumpdata:
|
| 372 |
|
|
;; Do not insert anything here between the label and jump table.
|
| 373 |
|
|
dd offset cd_epilogue ;; FFI_TYPE_VOID
|
| 374 |
|
|
dd offset cd_retint ;; FFI_TYPE_INT
|
| 375 |
|
|
dd offset cd_retfloat ;; FFI_TYPE_FLOAT
|
| 376 |
|
|
dd offset cd_retdouble ;; FFI_TYPE_DOUBLE
|
| 377 |
|
|
dd offset cd_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
| 378 |
|
|
dd offset cd_retint8 ;; FFI_TYPE_UINT8
|
| 379 |
|
|
dd offset cd_retint8 ;; FFI_TYPE_SINT8
|
| 380 |
|
|
dd offset cd_retint16 ;; FFI_TYPE_UINT16
|
| 381 |
|
|
dd offset cd_retint16 ;; FFI_TYPE_SINT16
|
| 382 |
|
|
dd offset cd_retint ;; FFI_TYPE_UINT32
|
| 383 |
|
|
dd offset cd_retint ;; FFI_TYPE_SINT32
|
| 384 |
|
|
dd offset cd_retint64 ;; FFI_TYPE_UINT64
|
| 385 |
|
|
dd offset cd_retint64 ;; FFI_TYPE_SINT64
|
| 386 |
|
|
dd offset cd_epilogue ;; FFI_TYPE_STRUCT
|
| 387 |
|
|
dd offset cd_retint ;; FFI_TYPE_POINTER
|
| 388 |
|
|
dd offset cd_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
| 389 |
|
|
dd offset cd_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
| 390 |
|
|
dd offset cd_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
| 391 |
|
|
|
| 392 |
|
|
cd_retint8:
|
| 393 |
|
|
mov al, [ecx]
|
| 394 |
|
|
jmp cd_epilogue
|
| 395 |
|
|
|
| 396 |
|
|
cd_retint16:
|
| 397 |
|
|
mov ax, [ecx]
|
| 398 |
|
|
jmp cd_epilogue
|
| 399 |
|
|
|
| 400 |
|
|
cd_retint:
|
| 401 |
|
|
mov eax, [ecx]
|
| 402 |
|
|
jmp cd_epilogue
|
| 403 |
|
|
|
| 404 |
|
|
cd_retint64:
|
| 405 |
|
|
mov eax, [ecx + 0]
|
| 406 |
|
|
mov edx, [ecx + 4]
|
| 407 |
|
|
jmp cd_epilogue
|
| 408 |
|
|
|
| 409 |
|
|
cd_retfloat:
|
| 410 |
|
|
fld DWORD PTR [ecx]
|
| 411 |
|
|
jmp cd_epilogue
|
| 412 |
|
|
|
| 413 |
|
|
cd_retdouble:
|
| 414 |
|
|
fld QWORD PTR [ecx]
|
| 415 |
|
|
jmp cd_epilogue
|
| 416 |
|
|
|
| 417 |
|
|
cd_retlongdouble:
|
| 418 |
|
|
fld TBYTE PTR [ecx]
|
| 419 |
|
|
jmp cd_epilogue
|
| 420 |
|
|
|
| 421 |
|
|
cd_epilogue:
|
| 422 |
|
|
;; Epilogue code is autogenerated.
|
| 423 |
|
|
ret
|
| 424 |
|
|
ffi_closure_STDCALL ENDP
|
| 425 |
|
|
|
| 426 |
|
|
_TEXT ENDS
|
| 427 |
|
|
END
|
| 428 |
|
|
|
| 429 |
|
|
#else
|
| 430 |
|
|
|
| 431 |
|
|
.text
|
| 432 |
|
|
|
| 433 |
|
|
# This assumes we are using gas.
|
| 434 |
|
|
.balign 16
|
| 435 |
|
|
.globl _ffi_call_win32
|
| 436 |
|
|
#ifndef __OS2__
|
| 437 |
|
|
.def _ffi_call_win32; .scl 2; .type 32; .endef
|
| 438 |
|
|
#endif
|
| 439 |
|
|
_ffi_call_win32:
|
| 440 |
|
|
.LFB1:
|
| 441 |
|
|
pushl %ebp
|
| 442 |
|
|
.LCFI0:
|
| 443 |
|
|
movl %esp,%ebp
|
| 444 |
|
|
.LCFI1:
|
| 445 |
|
|
# Make room for all of the new args.
|
| 446 |
|
|
movl 20(%ebp),%ecx
|
| 447 |
|
|
subl %ecx,%esp
|
| 448 |
|
|
|
| 449 |
|
|
movl %esp,%eax
|
| 450 |
|
|
|
| 451 |
|
|
# Place all of the ffi_prep_args in position
|
| 452 |
|
|
pushl 12(%ebp)
|
| 453 |
|
|
pushl %eax
|
| 454 |
|
|
call *8(%ebp)
|
| 455 |
|
|
|
| 456 |
|
|
# Return stack to previous state and call the function
|
| 457 |
|
|
addl $8,%esp
|
| 458 |
|
|
|
| 459 |
|
|
# Handle fastcall and thiscall
|
| 460 |
|
|
cmpl $3, 16(%ebp) # FFI_THISCALL
|
| 461 |
|
|
jz .do_thiscall
|
| 462 |
|
|
cmpl $4, 16(%ebp) # FFI_FASTCALL
|
| 463 |
|
|
jnz .do_fncall
|
| 464 |
|
|
movl (%esp), %ecx
|
| 465 |
|
|
movl 4(%esp), %edx
|
| 466 |
|
|
addl $8, %esp
|
| 467 |
|
|
jmp .do_fncall
|
| 468 |
|
|
.do_thiscall:
|
| 469 |
|
|
movl (%esp), %ecx
|
| 470 |
|
|
addl $4, %esp
|
| 471 |
|
|
|
| 472 |
|
|
.do_fncall:
|
| 473 |
|
|
|
| 474 |
|
|
# FIXME: Align the stack to a 128-bit boundary to avoid
|
| 475 |
|
|
# potential performance hits.
|
| 476 |
|
|
|
| 477 |
|
|
call *32(%ebp)
|
| 478 |
|
|
|
| 479 |
|
|
# stdcall functions pop arguments off the stack themselves
|
| 480 |
|
|
|
| 481 |
|
|
# Load %ecx with the return type code
|
| 482 |
|
|
movl 24(%ebp),%ecx
|
| 483 |
|
|
|
| 484 |
|
|
# If the return value pointer is NULL, assume no return value.
|
| 485 |
|
|
cmpl $0,28(%ebp)
|
| 486 |
|
|
jne 0f
|
| 487 |
|
|
|
| 488 |
|
|
# Even if there is no space for the return value, we are
|
| 489 |
|
|
# obliged to handle floating-point values.
|
| 490 |
|
|
cmpl $FFI_TYPE_FLOAT,%ecx
|
| 491 |
|
|
jne .Lnoretval
|
| 492 |
|
|
fstp %st(0)
|
| 493 |
|
|
|
| 494 |
|
|
jmp .Lepilogue
|
| 495 |
|
|
|
| 496 |
|
|
0:
|
| 497 |
|
|
call 1f
|
| 498 |
|
|
# Do not insert anything here between the call and the jump table.
|
| 499 |
|
|
.Lstore_table:
|
| 500 |
|
|
.long .Lnoretval /* FFI_TYPE_VOID */
|
| 501 |
|
|
.long .Lretint /* FFI_TYPE_INT */
|
| 502 |
|
|
.long .Lretfloat /* FFI_TYPE_FLOAT */
|
| 503 |
|
|
.long .Lretdouble /* FFI_TYPE_DOUBLE */
|
| 504 |
|
|
.long .Lretlongdouble /* FFI_TYPE_LONGDOUBLE */
|
| 505 |
|
|
.long .Lretuint8 /* FFI_TYPE_UINT8 */
|
| 506 |
|
|
.long .Lretsint8 /* FFI_TYPE_SINT8 */
|
| 507 |
|
|
.long .Lretuint16 /* FFI_TYPE_UINT16 */
|
| 508 |
|
|
.long .Lretsint16 /* FFI_TYPE_SINT16 */
|
| 509 |
|
|
.long .Lretint /* FFI_TYPE_UINT32 */
|
| 510 |
|
|
.long .Lretint /* FFI_TYPE_SINT32 */
|
| 511 |
|
|
.long .Lretint64 /* FFI_TYPE_UINT64 */
|
| 512 |
|
|
.long .Lretint64 /* FFI_TYPE_SINT64 */
|
| 513 |
|
|
.long .Lretstruct /* FFI_TYPE_STRUCT */
|
| 514 |
|
|
.long .Lretint /* FFI_TYPE_POINTER */
|
| 515 |
|
|
.long .Lretstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */
|
| 516 |
|
|
.long .Lretstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */
|
| 517 |
|
|
.long .Lretstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */
|
| 518 |
|
|
1:
|
| 519 |
|
|
add %ecx, %ecx
|
| 520 |
|
|
add %ecx, %ecx
|
| 521 |
|
|
add (%esp),%ecx
|
| 522 |
|
|
add $4, %esp
|
| 523 |
|
|
jmp *(%ecx)
|
| 524 |
|
|
|
| 525 |
|
|
/* Sign/zero extend as appropriate. */
|
| 526 |
|
|
.Lretsint8:
|
| 527 |
|
|
movsbl %al, %eax
|
| 528 |
|
|
jmp .Lretint
|
| 529 |
|
|
|
| 530 |
|
|
.Lretsint16:
|
| 531 |
|
|
movswl %ax, %eax
|
| 532 |
|
|
jmp .Lretint
|
| 533 |
|
|
|
| 534 |
|
|
.Lretuint8:
|
| 535 |
|
|
movzbl %al, %eax
|
| 536 |
|
|
jmp .Lretint
|
| 537 |
|
|
|
| 538 |
|
|
.Lretuint16:
|
| 539 |
|
|
movzwl %ax, %eax
|
| 540 |
|
|
jmp .Lretint
|
| 541 |
|
|
|
| 542 |
|
|
.Lretint:
|
| 543 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 544 |
|
|
movl 28(%ebp),%ecx
|
| 545 |
|
|
movl %eax,0(%ecx)
|
| 546 |
|
|
jmp .Lepilogue
|
| 547 |
|
|
|
| 548 |
|
|
.Lretfloat:
|
| 549 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 550 |
|
|
movl 28(%ebp),%ecx
|
| 551 |
|
|
fstps (%ecx)
|
| 552 |
|
|
jmp .Lepilogue
|
| 553 |
|
|
|
| 554 |
|
|
.Lretdouble:
|
| 555 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 556 |
|
|
movl 28(%ebp),%ecx
|
| 557 |
|
|
fstpl (%ecx)
|
| 558 |
|
|
jmp .Lepilogue
|
| 559 |
|
|
|
| 560 |
|
|
.Lretlongdouble:
|
| 561 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 562 |
|
|
movl 28(%ebp),%ecx
|
| 563 |
|
|
fstpt (%ecx)
|
| 564 |
|
|
jmp .Lepilogue
|
| 565 |
|
|
|
| 566 |
|
|
.Lretint64:
|
| 567 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 568 |
|
|
movl 28(%ebp),%ecx
|
| 569 |
|
|
movl %eax,0(%ecx)
|
| 570 |
|
|
movl %edx,4(%ecx)
|
| 571 |
|
|
jmp .Lepilogue
|
| 572 |
|
|
|
| 573 |
|
|
.Lretstruct1b:
|
| 574 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 575 |
|
|
movl 28(%ebp),%ecx
|
| 576 |
|
|
movb %al,0(%ecx)
|
| 577 |
|
|
jmp .Lepilogue
|
| 578 |
|
|
|
| 579 |
|
|
.Lretstruct2b:
|
| 580 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 581 |
|
|
movl 28(%ebp),%ecx
|
| 582 |
|
|
movw %ax,0(%ecx)
|
| 583 |
|
|
jmp .Lepilogue
|
| 584 |
|
|
|
| 585 |
|
|
.Lretstruct4b:
|
| 586 |
|
|
# Load %ecx with the pointer to storage for the return value
|
| 587 |
|
|
movl 28(%ebp),%ecx
|
| 588 |
|
|
movl %eax,0(%ecx)
|
| 589 |
|
|
jmp .Lepilogue
|
| 590 |
|
|
|
| 591 |
|
|
.Lretstruct:
|
| 592 |
|
|
# Nothing to do!
|
| 593 |
|
|
|
| 594 |
|
|
.Lnoretval:
|
| 595 |
|
|
.Lepilogue:
|
| 596 |
|
|
movl %ebp,%esp
|
| 597 |
|
|
popl %ebp
|
| 598 |
|
|
ret
|
| 599 |
|
|
.ffi_call_win32_end:
|
| 600 |
|
|
.balign 16
|
| 601 |
|
|
.globl _ffi_closure_THISCALL
|
| 602 |
|
|
#ifndef __OS2__
|
| 603 |
|
|
.def _ffi_closure_THISCALL; .scl 2; .type 32; .endef
|
| 604 |
|
|
#endif
|
| 605 |
|
|
_ffi_closure_THISCALL:
|
| 606 |
|
|
pushl %ebp
|
| 607 |
|
|
movl %esp, %ebp
|
| 608 |
|
|
subl $40, %esp
|
| 609 |
|
|
leal -24(%ebp), %edx
|
| 610 |
|
|
movl %edx, -12(%ebp) /* resp */
|
| 611 |
|
|
leal 12(%ebp), %edx /* account for stub return address on stack */
|
| 612 |
|
|
jmp .stub
|
| 613 |
|
|
.LFE1:
|
| 614 |
|
|
|
| 615 |
|
|
# This assumes we are using gas.
|
| 616 |
|
|
.balign 16
|
| 617 |
|
|
.globl _ffi_closure_SYSV
|
| 618 |
|
|
#ifndef __OS2__
|
| 619 |
|
|
.def _ffi_closure_SYSV; .scl 2; .type 32; .endef
|
| 620 |
|
|
#endif
|
| 621 |
|
|
_ffi_closure_SYSV:
|
| 622 |
|
|
.LFB3:
|
| 623 |
|
|
pushl %ebp
|
| 624 |
|
|
.LCFI4:
|
| 625 |
|
|
movl %esp, %ebp
|
| 626 |
|
|
.LCFI5:
|
| 627 |
|
|
subl $40, %esp
|
| 628 |
|
|
leal -24(%ebp), %edx
|
| 629 |
|
|
movl %edx, -12(%ebp) /* resp */
|
| 630 |
|
|
leal 8(%ebp), %edx
|
| 631 |
|
|
.stub:
|
| 632 |
|
|
movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
|
| 633 |
|
|
leal -12(%ebp), %edx
|
| 634 |
|
|
movl %edx, (%esp) /* &resp */
|
| 635 |
|
|
call _ffi_closure_SYSV_inner
|
| 636 |
|
|
movl -12(%ebp), %ecx
|
| 637 |
|
|
|
| 638 |
|
|
0:
|
| 639 |
|
|
call 1f
|
| 640 |
|
|
# Do not insert anything here between the call and the jump table.
|
| 641 |
|
|
.Lcls_store_table:
|
| 642 |
|
|
.long .Lcls_noretval /* FFI_TYPE_VOID */
|
| 643 |
|
|
.long .Lcls_retint /* FFI_TYPE_INT */
|
| 644 |
|
|
.long .Lcls_retfloat /* FFI_TYPE_FLOAT */
|
| 645 |
|
|
.long .Lcls_retdouble /* FFI_TYPE_DOUBLE */
|
| 646 |
|
|
.long .Lcls_retldouble /* FFI_TYPE_LONGDOUBLE */
|
| 647 |
|
|
.long .Lcls_retuint8 /* FFI_TYPE_UINT8 */
|
| 648 |
|
|
.long .Lcls_retsint8 /* FFI_TYPE_SINT8 */
|
| 649 |
|
|
.long .Lcls_retuint16 /* FFI_TYPE_UINT16 */
|
| 650 |
|
|
.long .Lcls_retsint16 /* FFI_TYPE_SINT16 */
|
| 651 |
|
|
.long .Lcls_retint /* FFI_TYPE_UINT32 */
|
| 652 |
|
|
.long .Lcls_retint /* FFI_TYPE_SINT32 */
|
| 653 |
|
|
.long .Lcls_retllong /* FFI_TYPE_UINT64 */
|
| 654 |
|
|
.long .Lcls_retllong /* FFI_TYPE_SINT64 */
|
| 655 |
|
|
.long .Lcls_retstruct /* FFI_TYPE_STRUCT */
|
| 656 |
|
|
.long .Lcls_retint /* FFI_TYPE_POINTER */
|
| 657 |
|
|
.long .Lcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
|
| 658 |
|
|
.long .Lcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
|
| 659 |
|
|
.long .Lcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
|
| 660 |
|
|
|
| 661 |
|
|
1:
|
| 662 |
|
|
add %eax, %eax
|
| 663 |
|
|
add %eax, %eax
|
| 664 |
|
|
add (%esp),%eax
|
| 665 |
|
|
add $4, %esp
|
| 666 |
|
|
jmp *(%eax)
|
| 667 |
|
|
|
| 668 |
|
|
/* Sign/zero extend as appropriate. */
|
| 669 |
|
|
.Lcls_retsint8:
|
| 670 |
|
|
movsbl (%ecx), %eax
|
| 671 |
|
|
jmp .Lcls_epilogue
|
| 672 |
|
|
|
| 673 |
|
|
.Lcls_retsint16:
|
| 674 |
|
|
movswl (%ecx), %eax
|
| 675 |
|
|
jmp .Lcls_epilogue
|
| 676 |
|
|
|
| 677 |
|
|
.Lcls_retuint8:
|
| 678 |
|
|
movzbl (%ecx), %eax
|
| 679 |
|
|
jmp .Lcls_epilogue
|
| 680 |
|
|
|
| 681 |
|
|
.Lcls_retuint16:
|
| 682 |
|
|
movzwl (%ecx), %eax
|
| 683 |
|
|
jmp .Lcls_epilogue
|
| 684 |
|
|
|
| 685 |
|
|
.Lcls_retint:
|
| 686 |
|
|
movl (%ecx), %eax
|
| 687 |
|
|
jmp .Lcls_epilogue
|
| 688 |
|
|
|
| 689 |
|
|
.Lcls_retfloat:
|
| 690 |
|
|
flds (%ecx)
|
| 691 |
|
|
jmp .Lcls_epilogue
|
| 692 |
|
|
|
| 693 |
|
|
.Lcls_retdouble:
|
| 694 |
|
|
fldl (%ecx)
|
| 695 |
|
|
jmp .Lcls_epilogue
|
| 696 |
|
|
|
| 697 |
|
|
.Lcls_retldouble:
|
| 698 |
|
|
fldt (%ecx)
|
| 699 |
|
|
jmp .Lcls_epilogue
|
| 700 |
|
|
|
| 701 |
|
|
.Lcls_retllong:
|
| 702 |
|
|
movl (%ecx), %eax
|
| 703 |
|
|
movl 4(%ecx), %edx
|
| 704 |
|
|
jmp .Lcls_epilogue
|
| 705 |
|
|
|
| 706 |
|
|
.Lcls_retstruct1:
|
| 707 |
|
|
movsbl (%ecx), %eax
|
| 708 |
|
|
jmp .Lcls_epilogue
|
| 709 |
|
|
|
| 710 |
|
|
.Lcls_retstruct2:
|
| 711 |
|
|
movswl (%ecx), %eax
|
| 712 |
|
|
jmp .Lcls_epilogue
|
| 713 |
|
|
|
| 714 |
|
|
.Lcls_retstruct4:
|
| 715 |
|
|
movl (%ecx), %eax
|
| 716 |
|
|
jmp .Lcls_epilogue
|
| 717 |
|
|
|
| 718 |
|
|
.Lcls_retstruct:
|
| 719 |
|
|
# Caller expects us to pop struct return value pointer hidden arg.
|
| 720 |
|
|
movl %ebp, %esp
|
| 721 |
|
|
popl %ebp
|
| 722 |
|
|
ret $0x4
|
| 723 |
|
|
|
| 724 |
|
|
.Lcls_noretval:
|
| 725 |
|
|
.Lcls_epilogue:
|
| 726 |
|
|
movl %ebp, %esp
|
| 727 |
|
|
popl %ebp
|
| 728 |
|
|
ret
|
| 729 |
|
|
.ffi_closure_SYSV_end:
|
| 730 |
|
|
.LFE3:
|
| 731 |
|
|
|
| 732 |
|
|
#if !FFI_NO_RAW_API
|
| 733 |
|
|
|
| 734 |
|
|
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
|
| 735 |
|
|
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
|
| 736 |
|
|
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
|
| 737 |
|
|
#define CIF_FLAGS_OFFSET 20
|
| 738 |
|
|
.balign 16
|
| 739 |
|
|
.globl _ffi_closure_raw_THISCALL
|
| 740 |
|
|
#ifndef __OS2__
|
| 741 |
|
|
.def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef
|
| 742 |
|
|
#endif
|
| 743 |
|
|
_ffi_closure_raw_THISCALL:
|
| 744 |
|
|
pushl %ebp
|
| 745 |
|
|
movl %esp, %ebp
|
| 746 |
|
|
pushl %esi
|
| 747 |
|
|
subl $36, %esp
|
| 748 |
|
|
movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
|
| 749 |
|
|
movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
|
| 750 |
|
|
movl %edx, 12(%esp) /* user_data */
|
| 751 |
|
|
leal 12(%ebp), %edx /* __builtin_dwarf_cfa () */
|
| 752 |
|
|
jmp .stubraw
|
| 753 |
|
|
# This assumes we are using gas.
|
| 754 |
|
|
.balign 16
|
| 755 |
|
|
.globl _ffi_closure_raw_SYSV
|
| 756 |
|
|
#ifndef __OS2__
|
| 757 |
|
|
.def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
|
| 758 |
|
|
#endif
|
| 759 |
|
|
_ffi_closure_raw_SYSV:
|
| 760 |
|
|
.LFB4:
|
| 761 |
|
|
pushl %ebp
|
| 762 |
|
|
.LCFI6:
|
| 763 |
|
|
movl %esp, %ebp
|
| 764 |
|
|
.LCFI7:
|
| 765 |
|
|
pushl %esi
|
| 766 |
|
|
.LCFI8:
|
| 767 |
|
|
subl $36, %esp
|
| 768 |
|
|
movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
|
| 769 |
|
|
movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
|
| 770 |
|
|
movl %edx, 12(%esp) /* user_data */
|
| 771 |
|
|
leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
|
| 772 |
|
|
.stubraw:
|
| 773 |
|
|
movl %edx, 8(%esp) /* raw_args */
|
| 774 |
|
|
leal -24(%ebp), %edx
|
| 775 |
|
|
movl %edx, 4(%esp) /* &res */
|
| 776 |
|
|
movl %esi, (%esp) /* cif */
|
| 777 |
|
|
call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
|
| 778 |
|
|
movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
|
| 779 |
|
|
0:
|
| 780 |
|
|
call 1f
|
| 781 |
|
|
# Do not insert anything here between the call and the jump table.
|
| 782 |
|
|
.Lrcls_store_table:
|
| 783 |
|
|
.long .Lrcls_noretval /* FFI_TYPE_VOID */
|
| 784 |
|
|
.long .Lrcls_retint /* FFI_TYPE_INT */
|
| 785 |
|
|
.long .Lrcls_retfloat /* FFI_TYPE_FLOAT */
|
| 786 |
|
|
.long .Lrcls_retdouble /* FFI_TYPE_DOUBLE */
|
| 787 |
|
|
.long .Lrcls_retldouble /* FFI_TYPE_LONGDOUBLE */
|
| 788 |
|
|
.long .Lrcls_retuint8 /* FFI_TYPE_UINT8 */
|
| 789 |
|
|
.long .Lrcls_retsint8 /* FFI_TYPE_SINT8 */
|
| 790 |
|
|
.long .Lrcls_retuint16 /* FFI_TYPE_UINT16 */
|
| 791 |
|
|
.long .Lrcls_retsint16 /* FFI_TYPE_SINT16 */
|
| 792 |
|
|
.long .Lrcls_retint /* FFI_TYPE_UINT32 */
|
| 793 |
|
|
.long .Lrcls_retint /* FFI_TYPE_SINT32 */
|
| 794 |
|
|
.long .Lrcls_retllong /* FFI_TYPE_UINT64 */
|
| 795 |
|
|
.long .Lrcls_retllong /* FFI_TYPE_SINT64 */
|
| 796 |
|
|
.long .Lrcls_retstruct /* FFI_TYPE_STRUCT */
|
| 797 |
|
|
.long .Lrcls_retint /* FFI_TYPE_POINTER */
|
| 798 |
|
|
.long .Lrcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
|
| 799 |
|
|
.long .Lrcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
|
| 800 |
|
|
.long .Lrcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
|
| 801 |
|
|
1:
|
| 802 |
|
|
add %eax, %eax
|
| 803 |
|
|
add %eax, %eax
|
| 804 |
|
|
add (%esp),%eax
|
| 805 |
|
|
add $4, %esp
|
| 806 |
|
|
jmp *(%eax)
|
| 807 |
|
|
|
| 808 |
|
|
/* Sign/zero extend as appropriate. */
|
| 809 |
|
|
.Lrcls_retsint8:
|
| 810 |
|
|
movsbl -24(%ebp), %eax
|
| 811 |
|
|
jmp .Lrcls_epilogue
|
| 812 |
|
|
|
| 813 |
|
|
.Lrcls_retsint16:
|
| 814 |
|
|
movswl -24(%ebp), %eax
|
| 815 |
|
|
jmp .Lrcls_epilogue
|
| 816 |
|
|
|
| 817 |
|
|
.Lrcls_retuint8:
|
| 818 |
|
|
movzbl -24(%ebp), %eax
|
| 819 |
|
|
jmp .Lrcls_epilogue
|
| 820 |
|
|
|
| 821 |
|
|
.Lrcls_retuint16:
|
| 822 |
|
|
movzwl -24(%ebp), %eax
|
| 823 |
|
|
jmp .Lrcls_epilogue
|
| 824 |
|
|
|
| 825 |
|
|
.Lrcls_retint:
|
| 826 |
|
|
movl -24(%ebp), %eax
|
| 827 |
|
|
jmp .Lrcls_epilogue
|
| 828 |
|
|
|
| 829 |
|
|
.Lrcls_retfloat:
|
| 830 |
|
|
flds -24(%ebp)
|
| 831 |
|
|
jmp .Lrcls_epilogue
|
| 832 |
|
|
|
| 833 |
|
|
.Lrcls_retdouble:
|
| 834 |
|
|
fldl -24(%ebp)
|
| 835 |
|
|
jmp .Lrcls_epilogue
|
| 836 |
|
|
|
| 837 |
|
|
.Lrcls_retldouble:
|
| 838 |
|
|
fldt -24(%ebp)
|
| 839 |
|
|
jmp .Lrcls_epilogue
|
| 840 |
|
|
|
| 841 |
|
|
.Lrcls_retllong:
|
| 842 |
|
|
movl -24(%ebp), %eax
|
| 843 |
|
|
movl -20(%ebp), %edx
|
| 844 |
|
|
jmp .Lrcls_epilogue
|
| 845 |
|
|
|
| 846 |
|
|
.Lrcls_retstruct1:
|
| 847 |
|
|
movsbl -24(%ebp), %eax
|
| 848 |
|
|
jmp .Lrcls_epilogue
|
| 849 |
|
|
|
| 850 |
|
|
.Lrcls_retstruct2:
|
| 851 |
|
|
movswl -24(%ebp), %eax
|
| 852 |
|
|
jmp .Lrcls_epilogue
|
| 853 |
|
|
|
| 854 |
|
|
.Lrcls_retstruct4:
|
| 855 |
|
|
movl -24(%ebp), %eax
|
| 856 |
|
|
jmp .Lrcls_epilogue
|
| 857 |
|
|
|
| 858 |
|
|
.Lrcls_retstruct:
|
| 859 |
|
|
# Nothing to do!
|
| 860 |
|
|
|
| 861 |
|
|
.Lrcls_noretval:
|
| 862 |
|
|
.Lrcls_epilogue:
|
| 863 |
|
|
addl $36, %esp
|
| 864 |
|
|
popl %esi
|
| 865 |
|
|
popl %ebp
|
| 866 |
|
|
ret
|
| 867 |
|
|
.ffi_closure_raw_SYSV_end:
|
| 868 |
|
|
.LFE4:
|
| 869 |
|
|
|
| 870 |
|
|
#endif /* !FFI_NO_RAW_API */
|
| 871 |
|
|
|
| 872 |
|
|
# This assumes we are using gas.
|
| 873 |
|
|
.balign 16
|
| 874 |
|
|
.globl _ffi_closure_STDCALL
|
| 875 |
|
|
#ifndef __OS2__
|
| 876 |
|
|
.def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
|
| 877 |
|
|
#endif
|
| 878 |
|
|
_ffi_closure_STDCALL:
|
| 879 |
|
|
.LFB5:
|
| 880 |
|
|
pushl %ebp
|
| 881 |
|
|
.LCFI9:
|
| 882 |
|
|
movl %esp, %ebp
|
| 883 |
|
|
.LCFI10:
|
| 884 |
|
|
subl $40, %esp
|
| 885 |
|
|
leal -24(%ebp), %edx
|
| 886 |
|
|
movl %edx, -12(%ebp) /* resp */
|
| 887 |
|
|
leal 12(%ebp), %edx /* account for stub return address on stack */
|
| 888 |
|
|
movl %edx, 4(%esp) /* args */
|
| 889 |
|
|
leal -12(%ebp), %edx
|
| 890 |
|
|
movl %edx, (%esp) /* &resp */
|
| 891 |
|
|
call _ffi_closure_SYSV_inner
|
| 892 |
|
|
movl -12(%ebp), %ecx
|
| 893 |
|
|
0:
|
| 894 |
|
|
call 1f
|
| 895 |
|
|
# Do not insert anything here between the call and the jump table.
|
| 896 |
|
|
.Lscls_store_table:
|
| 897 |
|
|
.long .Lscls_noretval /* FFI_TYPE_VOID */
|
| 898 |
|
|
.long .Lscls_retint /* FFI_TYPE_INT */
|
| 899 |
|
|
.long .Lscls_retfloat /* FFI_TYPE_FLOAT */
|
| 900 |
|
|
.long .Lscls_retdouble /* FFI_TYPE_DOUBLE */
|
| 901 |
|
|
.long .Lscls_retldouble /* FFI_TYPE_LONGDOUBLE */
|
| 902 |
|
|
.long .Lscls_retuint8 /* FFI_TYPE_UINT8 */
|
| 903 |
|
|
.long .Lscls_retsint8 /* FFI_TYPE_SINT8 */
|
| 904 |
|
|
.long .Lscls_retuint16 /* FFI_TYPE_UINT16 */
|
| 905 |
|
|
.long .Lscls_retsint16 /* FFI_TYPE_SINT16 */
|
| 906 |
|
|
.long .Lscls_retint /* FFI_TYPE_UINT32 */
|
| 907 |
|
|
.long .Lscls_retint /* FFI_TYPE_SINT32 */
|
| 908 |
|
|
.long .Lscls_retllong /* FFI_TYPE_UINT64 */
|
| 909 |
|
|
.long .Lscls_retllong /* FFI_TYPE_SINT64 */
|
| 910 |
|
|
.long .Lscls_retstruct /* FFI_TYPE_STRUCT */
|
| 911 |
|
|
.long .Lscls_retint /* FFI_TYPE_POINTER */
|
| 912 |
|
|
.long .Lscls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
|
| 913 |
|
|
.long .Lscls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
|
| 914 |
|
|
.long .Lscls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
|
| 915 |
|
|
1:
|
| 916 |
|
|
add %eax, %eax
|
| 917 |
|
|
add %eax, %eax
|
| 918 |
|
|
add (%esp),%eax
|
| 919 |
|
|
add $4, %esp
|
| 920 |
|
|
jmp *(%eax)
|
| 921 |
|
|
|
| 922 |
|
|
/* Sign/zero extend as appropriate. */
|
| 923 |
|
|
.Lscls_retsint8:
|
| 924 |
|
|
movsbl (%ecx), %eax
|
| 925 |
|
|
jmp .Lscls_epilogue
|
| 926 |
|
|
|
| 927 |
|
|
.Lscls_retsint16:
|
| 928 |
|
|
movswl (%ecx), %eax
|
| 929 |
|
|
jmp .Lscls_epilogue
|
| 930 |
|
|
|
| 931 |
|
|
.Lscls_retuint8:
|
| 932 |
|
|
movzbl (%ecx), %eax
|
| 933 |
|
|
jmp .Lscls_epilogue
|
| 934 |
|
|
|
| 935 |
|
|
.Lscls_retuint16:
|
| 936 |
|
|
movzwl (%ecx), %eax
|
| 937 |
|
|
jmp .Lscls_epilogue
|
| 938 |
|
|
|
| 939 |
|
|
.Lscls_retint:
|
| 940 |
|
|
movl (%ecx), %eax
|
| 941 |
|
|
jmp .Lscls_epilogue
|
| 942 |
|
|
|
| 943 |
|
|
.Lscls_retfloat:
|
| 944 |
|
|
flds (%ecx)
|
| 945 |
|
|
jmp .Lscls_epilogue
|
| 946 |
|
|
|
| 947 |
|
|
.Lscls_retdouble:
|
| 948 |
|
|
fldl (%ecx)
|
| 949 |
|
|
jmp .Lscls_epilogue
|
| 950 |
|
|
|
| 951 |
|
|
.Lscls_retldouble:
|
| 952 |
|
|
fldt (%ecx)
|
| 953 |
|
|
jmp .Lscls_epilogue
|
| 954 |
|
|
|
| 955 |
|
|
.Lscls_retllong:
|
| 956 |
|
|
movl (%ecx), %eax
|
| 957 |
|
|
movl 4(%ecx), %edx
|
| 958 |
|
|
jmp .Lscls_epilogue
|
| 959 |
|
|
|
| 960 |
|
|
.Lscls_retstruct1:
|
| 961 |
|
|
movsbl (%ecx), %eax
|
| 962 |
|
|
jmp .Lscls_epilogue
|
| 963 |
|
|
|
| 964 |
|
|
.Lscls_retstruct2:
|
| 965 |
|
|
movswl (%ecx), %eax
|
| 966 |
|
|
jmp .Lscls_epilogue
|
| 967 |
|
|
|
| 968 |
|
|
.Lscls_retstruct4:
|
| 969 |
|
|
movl (%ecx), %eax
|
| 970 |
|
|
jmp .Lscls_epilogue
|
| 971 |
|
|
|
| 972 |
|
|
.Lscls_retstruct:
|
| 973 |
|
|
# Nothing to do!
|
| 974 |
|
|
|
| 975 |
|
|
.Lscls_noretval:
|
| 976 |
|
|
.Lscls_epilogue:
|
| 977 |
|
|
movl %ebp, %esp
|
| 978 |
|
|
popl %ebp
|
| 979 |
|
|
ret
|
| 980 |
|
|
.ffi_closure_STDCALL_end:
|
| 981 |
|
|
.LFE5:
|
| 982 |
|
|
|
| 983 |
|
|
#ifndef __OS2__
|
| 984 |
|
|
.section .eh_frame,"w"
|
| 985 |
|
|
#endif
|
| 986 |
|
|
.Lframe1:
|
| 987 |
|
|
.LSCIE1:
|
| 988 |
|
|
.long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
|
| 989 |
|
|
.LASCIE1:
|
| 990 |
|
|
.long 0x0 /* CIE Identifier Tag */
|
| 991 |
|
|
.byte 0x1 /* CIE Version */
|
| 992 |
|
|
#ifdef __PIC__
|
| 993 |
|
|
.ascii "zR\0" /* CIE Augmentation */
|
| 994 |
|
|
#else
|
| 995 |
|
|
.ascii "\0" /* CIE Augmentation */
|
| 996 |
|
|
#endif
|
| 997 |
|
|
.byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
|
| 998 |
|
|
.byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
|
| 999 |
|
|
.byte 0x8 /* CIE RA Column */
|
| 1000 |
|
|
#ifdef __PIC__
|
| 1001 |
|
|
.byte 0x1 /* .uleb128 0x1; Augmentation size */
|
| 1002 |
|
|
.byte 0x1b /* FDE Encoding (pcrel sdata4) */
|
| 1003 |
|
|
#endif
|
| 1004 |
|
|
.byte 0xc /* DW_CFA_def_cfa CFA = r4 + 4 = 4(%esp) */
|
| 1005 |
|
|
.byte 0x4 /* .uleb128 0x4 */
|
| 1006 |
|
|
.byte 0x4 /* .uleb128 0x4 */
|
| 1007 |
|
|
.byte 0x88 /* DW_CFA_offset, column 0x8 %eip at CFA + 1 * -4 */
|
| 1008 |
|
|
.byte 0x1 /* .uleb128 0x1 */
|
| 1009 |
|
|
.align 4
|
| 1010 |
|
|
.LECIE1:
|
| 1011 |
|
|
|
| 1012 |
|
|
.LSFDE1:
|
| 1013 |
|
|
.long .LEFDE1-.LASFDE1 /* FDE Length */
|
| 1014 |
|
|
.LASFDE1:
|
| 1015 |
|
|
.long .LASFDE1-.Lframe1 /* FDE CIE offset */
|
| 1016 |
|
|
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
| 1017 |
|
|
.long .LFB1-. /* FDE initial location */
|
| 1018 |
|
|
#else
|
| 1019 |
|
|
.long .LFB1
|
| 1020 |
|
|
#endif
|
| 1021 |
|
|
.long .LFE1-.LFB1 /* FDE address range */
|
| 1022 |
|
|
#ifdef __PIC__
|
| 1023 |
|
|
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
| 1024 |
|
|
#endif
|
| 1025 |
|
|
/* DW_CFA_xxx CFI instructions go here. */
|
| 1026 |
|
|
|
| 1027 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1028 |
|
|
.long .LCFI0-.LFB1
|
| 1029 |
|
|
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
| 1030 |
|
|
.byte 0x8 /* .uleb128 0x8 */
|
| 1031 |
|
|
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
| 1032 |
|
|
.byte 0x2 /* .uleb128 0x2 */
|
| 1033 |
|
|
|
| 1034 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1035 |
|
|
.long .LCFI1-.LCFI0
|
| 1036 |
|
|
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
| 1037 |
|
|
.byte 0x5 /* .uleb128 0x5 */
|
| 1038 |
|
|
|
| 1039 |
|
|
/* End of DW_CFA_xxx CFI instructions. */
|
| 1040 |
|
|
.align 4
|
| 1041 |
|
|
.LEFDE1:
|
| 1042 |
|
|
|
| 1043 |
|
|
|
| 1044 |
|
|
.LSFDE3:
|
| 1045 |
|
|
.long .LEFDE3-.LASFDE3 /* FDE Length */
|
| 1046 |
|
|
.LASFDE3:
|
| 1047 |
|
|
.long .LASFDE3-.Lframe1 /* FDE CIE offset */
|
| 1048 |
|
|
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
| 1049 |
|
|
.long .LFB3-. /* FDE initial location */
|
| 1050 |
|
|
#else
|
| 1051 |
|
|
.long .LFB3
|
| 1052 |
|
|
#endif
|
| 1053 |
|
|
.long .LFE3-.LFB3 /* FDE address range */
|
| 1054 |
|
|
#ifdef __PIC__
|
| 1055 |
|
|
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
| 1056 |
|
|
#endif
|
| 1057 |
|
|
/* DW_CFA_xxx CFI instructions go here. */
|
| 1058 |
|
|
|
| 1059 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1060 |
|
|
.long .LCFI4-.LFB3
|
| 1061 |
|
|
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
| 1062 |
|
|
.byte 0x8 /* .uleb128 0x8 */
|
| 1063 |
|
|
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
| 1064 |
|
|
.byte 0x2 /* .uleb128 0x2 */
|
| 1065 |
|
|
|
| 1066 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1067 |
|
|
.long .LCFI5-.LCFI4
|
| 1068 |
|
|
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
| 1069 |
|
|
.byte 0x5 /* .uleb128 0x5 */
|
| 1070 |
|
|
|
| 1071 |
|
|
/* End of DW_CFA_xxx CFI instructions. */
|
| 1072 |
|
|
.align 4
|
| 1073 |
|
|
.LEFDE3:
|
| 1074 |
|
|
|
| 1075 |
|
|
#if !FFI_NO_RAW_API
|
| 1076 |
|
|
|
| 1077 |
|
|
.LSFDE4:
|
| 1078 |
|
|
.long .LEFDE4-.LASFDE4 /* FDE Length */
|
| 1079 |
|
|
.LASFDE4:
|
| 1080 |
|
|
.long .LASFDE4-.Lframe1 /* FDE CIE offset */
|
| 1081 |
|
|
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
| 1082 |
|
|
.long .LFB4-. /* FDE initial location */
|
| 1083 |
|
|
#else
|
| 1084 |
|
|
.long .LFB4
|
| 1085 |
|
|
#endif
|
| 1086 |
|
|
.long .LFE4-.LFB4 /* FDE address range */
|
| 1087 |
|
|
#ifdef __PIC__
|
| 1088 |
|
|
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
| 1089 |
|
|
#endif
|
| 1090 |
|
|
/* DW_CFA_xxx CFI instructions go here. */
|
| 1091 |
|
|
|
| 1092 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1093 |
|
|
.long .LCFI6-.LFB4
|
| 1094 |
|
|
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
| 1095 |
|
|
.byte 0x8 /* .uleb128 0x8 */
|
| 1096 |
|
|
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
| 1097 |
|
|
.byte 0x2 /* .uleb128 0x2 */
|
| 1098 |
|
|
|
| 1099 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1100 |
|
|
.long .LCFI7-.LCFI6
|
| 1101 |
|
|
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
| 1102 |
|
|
.byte 0x5 /* .uleb128 0x5 */
|
| 1103 |
|
|
|
| 1104 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1105 |
|
|
.long .LCFI8-.LCFI7
|
| 1106 |
|
|
.byte 0x86 /* DW_CFA_offset, column 0x6 %esi at CFA + 3 * -4 */
|
| 1107 |
|
|
.byte 0x3 /* .uleb128 0x3 */
|
| 1108 |
|
|
|
| 1109 |
|
|
/* End of DW_CFA_xxx CFI instructions. */
|
| 1110 |
|
|
.align 4
|
| 1111 |
|
|
.LEFDE4:
|
| 1112 |
|
|
|
| 1113 |
|
|
#endif /* !FFI_NO_RAW_API */
|
| 1114 |
|
|
|
| 1115 |
|
|
.LSFDE5:
|
| 1116 |
|
|
.long .LEFDE5-.LASFDE5 /* FDE Length */
|
| 1117 |
|
|
.LASFDE5:
|
| 1118 |
|
|
.long .LASFDE5-.Lframe1 /* FDE CIE offset */
|
| 1119 |
|
|
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
| 1120 |
|
|
.long .LFB5-. /* FDE initial location */
|
| 1121 |
|
|
#else
|
| 1122 |
|
|
.long .LFB5
|
| 1123 |
|
|
#endif
|
| 1124 |
|
|
.long .LFE5-.LFB5 /* FDE address range */
|
| 1125 |
|
|
#ifdef __PIC__
|
| 1126 |
|
|
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
| 1127 |
|
|
#endif
|
| 1128 |
|
|
/* DW_CFA_xxx CFI instructions go here. */
|
| 1129 |
|
|
|
| 1130 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1131 |
|
|
.long .LCFI9-.LFB5
|
| 1132 |
|
|
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
| 1133 |
|
|
.byte 0x8 /* .uleb128 0x8 */
|
| 1134 |
|
|
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
| 1135 |
|
|
.byte 0x2 /* .uleb128 0x2 */
|
| 1136 |
|
|
|
| 1137 |
|
|
.byte 0x4 /* DW_CFA_advance_loc4 */
|
| 1138 |
|
|
.long .LCFI10-.LCFI9
|
| 1139 |
|
|
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
| 1140 |
|
|
.byte 0x5 /* .uleb128 0x5 */
|
| 1141 |
|
|
|
| 1142 |
|
|
/* End of DW_CFA_xxx CFI instructions. */
|
| 1143 |
|
|
.align 4
|
| 1144 |
|
|
.LEFDE5:
|
| 1145 |
|
|
|
| 1146 |
|
|
#endif /* !_MSC_VER */
|
| 1147 |
|
|
|