diff options
Diffstat (limited to 'libffi/src/x86/ffi64.c')
-rw-r--r-- | libffi/src/x86/ffi64.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libffi/src/x86/ffi64.c b/libffi/src/x86/ffi64.c index bd907d7208c..defd7744cce 100644 --- a/libffi/src/x86/ffi64.c +++ b/libffi/src/x86/ffi64.c @@ -1,7 +1,8 @@ /* ----------------------------------------------------------------------- - ffi64.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de> + ffi64.c - Copyright (c) 20011 Anthony Green Copyright (c) 2008, 2010 Red Hat, Inc. - + Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de> + x86-64 Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining @@ -426,7 +427,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) /* If the return value is passed in memory, add the pointer as the first integer argument. */ if (ret_in_memory) - reg_args->gpr[gprcount++] = (long) rvalue; + reg_args->gpr[gprcount++] = (unsigned long) rvalue; avn = cif->nargs; arg_types = cif->arg_types; @@ -498,12 +499,21 @@ ffi_prep_closure_loc (ffi_closure* closure, { volatile unsigned short *tramp; + /* Sanity check on the cif ABI. */ + { + int abi = cif->abi; + if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI))) + return FFI_BAD_ABI; + } + tramp = (volatile unsigned short *) &closure->tramp[0]; tramp[0] = 0xbb49; /* mov <code>, %r11 */ - *(void * volatile *) &tramp[1] = ffi_closure_unix64; + *((unsigned long long * volatile) &tramp[1]) + = (unsigned long) ffi_closure_unix64; tramp[5] = 0xba49; /* mov <data>, %r10 */ - *(void * volatile *) &tramp[6] = codeloc; + *((unsigned long long * volatile) &tramp[6]) + = (unsigned long) codeloc; /* Set the carry bit iff the function uses any sse registers. This is clc or stc, together with the first byte of the jmp. */ @@ -542,7 +552,7 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue, { /* The return value goes in memory. Arrange for the closure return value to go directly back to the original caller. */ - rvalue = (void *) reg_args->gpr[gprcount++]; + rvalue = (void *) (unsigned long) reg_args->gpr[gprcount++]; /* We don't have to do anything in asm for the return. */ ret = FFI_TYPE_VOID; } |