src/x86


Log

Author Commit Date CI Message
Anthony Green 0eb91425 2022-08-31T20:46:24 Change comment style
Anthony Green c528d5b4 2022-05-29T11:22:38 Fix windows arg passing
Anthony Green aa2c4141 2022-05-29T10:28:10 64-bit cygwin: fix struct args. Document change.
Anthony Green 769b7366 2022-05-28T19:59:35 Fix for MS x64 ABI
Anthony Green e409225b 2022-05-28T09:42:13 Pass large structs by value for Linux x86_64 and Aarch64. Aarch patch by Andreas Schwab. https://github.com/libffi/libffi/commit/482b37f00467325e3389bab322525099860dd9aa
hjl-tools 3ac265d5 2022-05-15T18:43:56 x86-64: Always double jump table slot size for CET (#710) (#711) When CET is enabled, double jump table slot size to add 4 bytes of ENDBR64 for CET. Since CET enabled clang doesn't have the LLVM assembler bug: https://bugs.llvm.org/show_bug.cgi?id=21501 fixed by commit 04d39260d64e08b8bfb3844109ad43d4055b2e8d Author: Rafael Espindola <rafael.espindola@gmail.com> Date: Wed Nov 4 23:50:29 2015 +0000 Simplify .org processing and make it a bit more powerful. we can use .org to allocate jump table slot size to 16 bytes.
rorth b60d4fc7 2021-12-23T14:32:46 src/x86/win64.S: Use #define instead of .macro (#665) (#669) The Solaris/x86 assembler doesn't support .macro/.endm, so use #define since win64.S is passed through cpp anyway.
Harald van Dijk 07f826fd 2021-07-25T02:39:37 Fix trampoline_code_table for x32. (#657) x32's struct tramp_parm has 32-bit pointers. This change adjusts the loads and offsets accordingly.
Jakub Jelinek 5651bea2 2021-06-15T15:19:26 2021-06-15 Jakub Jelinek <jakub@redhat.com> * src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words to number of words needed for type->size + byte_offset bytes rather than just type->size bytes. Compute pos before the loop and check total size of the structure. * testsuite/libffi.call/nested_struct12.c: New test.
Ole André Vadla Ravnås 1aeb2671 2021-03-24T12:16:12 x86: Fix thiscall and fastcall stack cleanup behavior (#611) These are meant to use callee clean-up.
Ole André Vadla Ravnås f88add14 2021-03-24T12:04:51 x86: Fix MSVC runtime checks interop (#612) MSVC can add runtime code that checks if a stack frame is mismanaged, however our custom assembly deliberately accesses and modifies the parent stack frame. Fortunately we can disable that specific check for the function call so do that. Co-authored-by: Matthew Waters <matthew@centricular.com>
Madhavan T. Venkataraman 9ba55921 2021-03-05T10:07:30 Static tramp v5 (#624) * Static Trampolines Closure Trampoline Security Issue ================================= Currently, the trampoline code used in libffi is not statically defined in a source file (except for MACH). The trampoline is either pre-defined machine code in a data buffer. Or, it is generated at runtime. In order to execute a trampoline, it needs to be placed in a page with executable permissions. Executable data pages are attack surfaces for attackers who may try to inject their own code into the page and contrive to have it executed. The security settings in a system may prevent various tricks used in user land to write code into a page and to have it executed somehow. On such systems, libffi trampolines would not be able to run. Static Trampoline ================= To solve this problem, the trampoline code needs to be defined statically in a source file, compiled and placed in the text segment so it can be mapped and executed naturally without any tricks. However, the trampoline needs to be able to access the closure pointer at runtime. PC-relative data referencing ============================ The solution implemented in this patch set uses PC-relative data references. The trampoline is mapped in a code page. Adjacent to the code page, a data page is mapped that contains the parameters of the trampoline: - the closure pointer - pointer to the ABI handler to jump to The trampoline code uses an offset relative to its current PC to access its data. Some architectures support PC-relative data references in the ISA itself. E.g., X64 supports RIP-relative references. For others, the PC has to somehow be loaded into a general purpose register to do PC-relative data referencing. To do this, we need to define a get_pc() kind of function and call it to load the PC in a desired register. There are two cases: 1. The call instruction pushes the return address on the stack. In this case, get_pc() will extract the return address from the stack and load it in the desired register and return. 2. The call instruction stores the return address in a designated register. In this case, get_pc() will copy the return address to the desired register and return. Either way, the PC next to the call instruction is obtained. Scratch register ================ In order to do its job, the trampoline code would need to use a scratch register. Depending on the ABI, there may not be a register available for scratch. This problem needs to be solved so that all ABIs will work. The trampoline will save two values on the stack: - the closure pointer - the original value of the scratch register This is what the stack will look like: sp before trampoline ------> -------------------- | closure pointer | -------------------- | scratch register | sp after trampoline -------> -------------------- The ABI handler can do the following as needed by the ABI: - the closure pointer can be loaded in a desired register - the scratch register can be restored to its original value - the stack pointer can be restored to its original value (the value when the trampoline was invoked) To do this, I have defined prolog code for each ABI handler. The legacy trampoline jumps to the ABI handler directly. But the static trampoline defined in this patch jumps tp the prolog code which performs the above actions before jumping to the ABI handler. Trampoline Table ================ In order to reduce the trampoline memory footprint, the trampoline code would be defined as a code array in the text segment. This array would be mapped into the address space of the caller. The mapping would, therefore, contain a trampoline table. Adjacent to the trampoline table mapping, there will be a data mapping that contains a parameter table, one parameter block for each trampoline. The parameter block will contain: - a pointer to the closure - a pointer to the ABI handler The static trampoline code would finally look like this: - Make space on the stack for the closure and the scratch register by moving the stack pointer down - Store the original value of the scratch register on the stack - Using PC-relative reference, get the closure pointer - Store the closure pointer on the stack - Using PC-relative reference, get the ABI handler pointer - Jump to the ABI handler Mapping size ============ The size of the code mapping that contains the trampoline table needs to be determined on a per architecture basis. If a particular architecture supports multiple base page sizes, then the largest supported base page size needs to be chosen. E.g., we choose 16K for ARM64. Trampoline allocation and free ============================== Static trampolines are allocated in ffi_closure_alloc() and freed in ffi_closure_free(). Normally, applications use these functions. But there are some cases out there where the user of libffi allocates and manages its own closure memory. In such cases, static trampolines cannot be used. These will fall back to using legacy trampolines. The user has to make sure that the memory is executable. ffi_closure structure ===================== I did not want to make any changes to the size of the closure structure for this feature to guarantee compatibility. But the opaque static trampoline handle needs to be stored in the closure. I have defined it as follows: - char tramp[FFI_TRAMPOLINE_SIZE]; + union { + char tramp[FFI_TRAMPOLINE_SIZE]; + void *ftramp; + }; If static trampolines are used, then tramp[] is not needed to store a dynamic trampoline. That space can be reused to store the handle. Hence, the union. Architecture Support ==================== Support has been added for x64, i386, aarch64 and arm. Support for other architectures can be added very easily in the future. OS Support ========== Support has been added for Linux. Support for other OSes can be added very easily. Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com> * x86: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code mapping and data mapping sizes. - Define the trampoline code table statically. Define two tables, actually, one with CET and one without. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_unix64 - ffi_closure_unix64_sse - ffi_closure_win64 The prolog functions are called: - ffi_closure_unix64_alt - ffi_closure_unix64_sse_alt - ffi_closure_win64_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com> * i386: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code table statically. Define two tables, actually, one with CET and one without. - Define the trampoline code table statically. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_i386 - ffi_closure_STDCALL - ffi_closure_REGISTER The prolog functions are called: - ffi_closure_i386_alt - ffi_closure_STDCALL_alt - ffi_closure_REGISTER_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com> * arm64: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code mapping and data mapping sizes. - Define the trampoline code table statically. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_SYSV - ffi_closure_SYSV_V The prolog functions are called: - ffi_closure_SYSV_alt - ffi_closure_SYSV_V_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com> * arm: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code mapping and data mapping sizes. - Define the trampoline code table statically. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_SYSV - ffi_closure_VFP The prolog functions are called: - ffi_closure_SYSV_alt - ffi_closure_VFP_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
Mike Hommey 8cc8f446 2020-11-10T20:41:33 Allow to build with mingw-clang (#579) For some reason, compiling sysv.S with mingw-clang fails with: ``` error: invalid variant 'ffi_closure_inner@8' ``` This can be fixed (worked around?) by quoting the symbol. This works fine with mingw-gcc too.
Mike Hommey d817d0da 2020-11-10T20:39:25 Don't use FFI_TYPE_LONGDOUBLE in the jump table in win64*.S (#580) It may have the same value as FFI_TYPE_DOUBLE per ffi.h, which possibly can make things go wrong with .org/ORG. For instance, GCC complains about "Error: attempt to move .org backwards"
Jeremy Huddleston Sequoia 032b3cd6 2020-10-27T07:06:21 Support building x86 and arm64 without FFI_GO_CLOSURES (#586) * x86: Support building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * arm: Support building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
petersn c78fcf88 2020-10-27T07:02:36 Removing unnecessary instruction from ffi_call_unix64 (#588) unix64.S's `ffi_call_unix64` looks like it used to take six parameters, where the sixth said the number of SSE register arguments. However, currently the function only takes five parameters, and the number of SSE register arguments is encoded in the `struct register_args *` passed as the first parameter to `ffi_call_unix64`. This change removes an instruction that tries to use this missing sixth parameter as the number of SSE arguments. This fix should not change any behavior, nor fix any bugs, because a few instructions later the value moved from %r9d into %eax is overwritten by the correct value anyway. This change merely makes the code a tad less confusing, because currently the assembly moves from a register (r9) whose value is never set.
Tim Gates 407394c0 2020-10-11T15:07:40 docs: fix simple typo, paramters -> parameters (#589) There is a small typo in src/x86/ffi.c. Should read `parameters` rather than `paramters`.
hjl-tools d9abffea 2020-02-22T06:32:22 x86: Fix ffi_prep_closure_loc (#542) Since FFI_TRAMPOLINE_SIZE is increased by 4 bytes to add ENDBR32, adjust jump displacement by 4 bytes.
hjl-tools 78556561 2020-02-21T19:08:06 x86: Add indirect branch tracking support (#540) Intel Control-flow Enforcement Technology (CET): https://software.intel.com/en-us/articles/intel-sdm contains shadow stack (SHSTK) and indirect branch tracking (IBT). When CET is enabled, ELF object files must be marked with .note.gnu.property section. When Intel CET is enabled, include <cet.h> in assembly codes to mark Intel CET support. Also when IBT is enabled, all indirect branch targets must start with ENDBR instruction and notrack prefix can be used to disable IBT on indirect branch. <cet.h> defines _CET_ENDBR which can be used in assembly codes for ENDBR instruction. If <cet.h> isn't included, define _CET_ENDBR as empty so that _CET_ENDBR can be used in assembly codes. Trampoline must be enlarged to add ENDBR instruction unconditionally, which is NOP on non-CET processors. This is required regardless if libffi is enabled with CET since libffi.so will be marked in legacy bitmap, but trampoline won't. Update library version for larger FFI_TRAMPOLINE_SIZE. This fixed: https://github.com/libffi/libffi/issues/474 Tested with $ CC="gcc -Wl,-z,cet-report=error -fcf-protection" CXX="g++ -Wl,-z,cet-report=error -fcf-protection" .../configure on Linux CET machines in i686, x32 and x86-64 modes.
Andreas Schwab a8efc2f7 2019-10-26T14:57:05 Fix FFI_STDCALL ABI (#514) Even for a stdcall function, the stack alignment is still the responsibility of the caller. Remember the original, not stack-aligned argument size, but align when setting up a stack frame. In ffi_closure_inner, return the true argument size, so that ffi_[go_]closure_STDCALL doesn't adjust too much.
zhanhb c4f61240 2019-10-09T18:59:32 Add long double test (#492) Required to fix build error on macos with gcc-9
driver1998 06bf1a9d 2019-04-28T03:21:44 fix x86/x64 MSVC build (#487)
Jeremy Huddleston Sequoia 05a17964 2019-02-19T04:11:28 Cleanup symbol exports on darwin and add architecture preprocessor checks to assist in building fat binaries (eg: i386+x86_64 on macOS or arm+aarch64 on iOS) (#450) * x86: Ensure _efi64 suffixed symbols are not exported * x86: Ensure we do not export ffi_prep_cif_machdep Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * x86: Ensure we don't export ffi_call_win64, ffi_closure_win64, or ffi_go_closure_win64 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * closures: Silence a semantic warning libffi/src/closures.c:175:23: This function declaration is not a prototype Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch64: Ensure we don't export ffi_prep_cif_machdep Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * arm: Ensure we don't export ffi_prep_cif_machdep Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch64, arm, x86: Add architecture preprocessor checks to support easier fat builds (eg: iOS) Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * x86: Silence some static analysis warnings libffi/src/x86/ffi64.c:286:21: The left operand of '!=' is a garbage value due to array index out of bounds libffi/src/x86/ffi64.c:297:22: The left operand of '!=' is a garbage value due to array index out of bounds Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch: Use FFI_HIDDEN rather than .hidden Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * ffi.h: Don't advertise ffi_java_rvalue_to_raw, ffi_prep_java_raw_closure, and ffi_prep_java_raw_closure_loc when FFI_NATIVE_RAW_API is 0 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Paul Monson e1118af5 2019-02-19T03:58:25 changes for win32 on windows (#468)
Jeremy Huddleston Sequoia ba73a671 2018-07-20T09:37:43 Update FFI_HIDDEN() to use .private_extern on Apple platforms and use the macro where appropriate Fix issue #439 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
Jeremy Huddleston Sequoia 65da63ab 2018-06-25T04:38:58 Add compact unwind for darwin/i386 (#440) * x86: Add implementation of compact unwind for ffi_call_i386, et al. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * x86: Use __text as the section name to avoid deprecated section name warnings. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * darwin: Add missing regular,debug attributes for compact unwind sections Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
Shoaib Meenai 2309b584 2018-06-17T17:04:24 Mark sysv.S as SafeSEH compatible (#438) It contains no exception handler, so we can just emit the special @feat.00 symbol to indicate that it's trivially SafeSEH compatible. SafeSEH only applies to x86 and not x86-64, hence its inclusion in the x86-specific block. See [1] for details. [1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx#the_.sxdata_section_
Jeremy Huddleston Sequoia 1d704051 2018-06-17T17:01:50 i386: Fix missing break; in case statement leading to incorrectly returned FFI_BAD_ABI (#437) * i386: Add missing break triggering dead store static analyzer checks. Register calling sequence is being reported as bad ABI instead of working as intended. Found-by: Clang Static Analysis Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * Mark ffi arm sysv entry points as private_extern. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * x86_64: Add implementation of compact unwind for ffi_call_unix64. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Anthony Green b55baf0b 2018-05-09T13:21:02 Handle FFI_GNUW64 on non-Windows systems (EFI)
Anthony Green b5ee3957 2018-05-05T07:41:53 Revert "Remove some symbol exports and cleanup newline warnings (#433)" This reverts commit a5a0f3cf36dfb4d64316414a872288c3170e6c1d.
Jeremy Huddleston Sequoia a5a0f3cf 2018-05-05T03:44:33 Remove some symbol exports and cleanup newline warnings (#433) * build: Ensure darwin generated sources end with a new line Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org> * build: Use .private_extern where missing to prevent exporting symbols that are not API Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
hjl-tools d3c54cf3 2018-05-02T06:19:58 Re-enable msabi testing (#436) * Revert "disable msabi testing for now" This reverts commit 7b7638eb0eac2adfa72f7ec9f254ba287c9947e2. * x86: Correct testing for 64-bit x86-64 Since passing -m32 to x86-64 compiler will generate i386 code, we need to check both __ILP32__ and __i386__ for 64-bit x86-64. * x86: Check __i386__ instead of i?86-*-* targets Since passing -m32 to x86-64 compiler will generate i386 code, we need to check __i386__ instead of i?86-*-* targets for i386 targets. * i386: Properly passing integer parameters in registers For thiscall and fastcall, if the paramter passed as 64-bit integer or struct, all following integer paramters will be passed on stack. * test: Add ABI_ATTR to callback_code Add ABI_ATTR to callback_code to properly test different ABIs.
Tom Tromey 4c2206ac 2018-04-28T04:46:10 Fix two "return" issues in x86/ffi64.c (#431) Issue #70 pointed out that at least one compiler didn't like: return ffi_call_efi64(cif, fn, rvalue, avalue); ... where the return type is "void". This patch splits the statement into two. I also noticed that ffi_call_go here seems to do a double call. I suspect a "return" is missing here, so this patch adds it as well.
Anthony Green 369ef49f 2018-03-18T12:53:42 Add missing FFI_GNUW64 enum
Anthony Green 43980dd1 2018-03-18T12:32:10 Add FFI_GNUW64 ABI for GNU 80-bit long double support
Anthony Green 9bc40d87 2018-03-18T12:32:10 Add FFI_GWIN64 ABI for GNU 80-bit long double support
Ole André Vadla Ravnås 28d3b61b 2018-01-20T23:56:17 Fix x86 SysV closure in PIC mode The assembly single-line comments swallowed up the remaining assembly code of the macros due to lack of line-endings. This is a regression introduced in b7f6d7a.
jon d15581c6 2017-12-01T00:34:30 Updating calls to ffi_closure_unix64_inner and ffi_closure_win64_inner to use PLT. Without this fix, statically linking libffi causes the linker error i.e. 'requires dynamic R_X86_64_PC32 reloc against ffi_closure_unix64_inner which may overflow at runtime; recompile with -fPIC)'
Anthony Green dc2ff5ba 2017-10-25T13:11:40 Merge pull request #323 from compnerd/x86-alloca-alignment x86: align alloca to 16-byte boundary
Anthony Green 927da716 2017-10-25T13:05:53 Merge pull request #379 from jlj/master Xcode build improvements
H.J. Lu 9d9d92b4 2017-10-25T04:59:31 Skip WIN64/EFI64 support for x32 Since x32 doesn't support WIN64/EFI64, skip it if __ILP32__ is defined.
Jean-Luc Jumpertz 181fc4cc 2017-10-23T15:02:29 Merge branch 'master' based on ksjogo/libffi Added a tvOS target in Xcode project. Misc Xcode project cleanup. Fix macOS build target in Xcode project. # Conflicts: # src/aarch64/ffi.c # src/x86/ffi64.c
Saleem Abdulrasool 79d1509c 2017-10-10T11:39:45 x86: align alloca to 16-byte boundary Align the stack allocation to a 16-byte boundary. This ensures that the stack parameters are 16-byte aligned which is needed for some instructions.
Jean-Luc Jumpertz a78da739 2017-09-04T15:55:34 Fix macOS build target in Xcode project. - Add missing files for desktop platforms in generate-darwin-source-and-headers.py, and in the Xcode project. - Add a static library target for macOS. - Fix "implicit conversion loses integer precision" warnings for iOS mad macOS targets.
Francis Ricci 9c12209d 2017-08-03T10:46:28 Fix misaligned memory access in ffi_call_int
Gregory Pakosz bd72848c 2017-04-27T13:20:36 Prefix ALIGN macros with FFI_
Anthony Green a94c999b 2017-03-19T07:36:07 Handle fastcall declaration differently for some Microsoft compilers
Ramón García Fernández 1e0d107b 2017-01-08T20:12:59 Modify configure.host to detect compilation with Microsoft Visual C++ and use assembly with Intel syntax in that case
Richard Henderson 794a54d4 2016-06-05T14:57:00 Mark win64.S with GNU-stack note
Iain Sandoe 92810b4b 2016-05-26T08:56:51 [Darwin-x86, build] Fix up label prefixes, remove .purgem Darwin uses a label prefix of _. cctools assembler will not accept .purgem as a directive.
Berker Peksag 4a677a42 2016-03-05T09:58:38 Fix -Wsign-compare warnings in x86/ffi64.c This was originally reported on the Python tracker: httpa://bugs.python.org/issue23958 The original patch was written by Steve R. Hastings. I've updated it to current master of libffi.
Richard Henderson e5843a3a 2016-04-15T16:10:08 x86: Fix calling convention for ffi_closure_win64_inner Also enable testing for the cross-abi calls.
Richard Henderson d0675197 2016-03-07T12:14:22 x86: Copy fix for clang .org from unix64.S Clang doesn't understand .org with symbolic operands.
Josh Triplett 1f6b5a91 2015-07-26T16:27:34 Support the WIN64/EFI64 calling convention on all X86_64 platforms Add a new calling convention FFI_EFI64, alias FFI_WIN64, on all X86_64 platforms. This allows libffi compiled on a 64-bit x86 platform to call EFI functions. Compile in ffiw64.c and win64.S on all X86_64 platforms. When compiled for a platform other than X86_WIN64, ffiw64.c suffixes its functions with _efi64, to avoid conflict with the platform's actual implementations of those functions.
Josh Triplett 6de51f3e 2015-07-26T16:23:55 src/x86/ffiw64.c: Don't assign a "char *" to an "unsigned char *" Declare a local variable to match the type of the struct field assigned to it, rather than adding unsigned to the type. Fixes a -Wpointer-sign warning.
Josh Triplett eaa59755 2015-07-26T17:17:16 src/x86/win64.S: Handle name mangling and PIC Move the macros from unix64.S into a shared header asmnames.h and use them in win64.S too.
Josh Triplett c8e82d9f 2015-07-26T16:18:57 src/x86/win64.S: Support compiling on non-WIN64 platforms Non-WIN64 versions of the GNU assembler don't support the .seh_* directives for structured exception handling, so wrap them in a macro that compiles to nothing. Handle the registers used for the non-Windows x86-64 calling convention when on a non-Windows platform. Distinguish between cases that should refer to the native argument registers (defined as arg0, arg1, arg2, and arg3) and cases that should always refer to the Windows argument registers.
Richard Henderson 3ac1610a 2015-01-19T20:48:40 x86: Fix cygwin32 build The section syntax is just that little bit different.
Rainer Orth f1560b7b 2015-01-16T11:31:37 x86: Solaris fixes * Solaris/x86 /bin/as doesn't support .org, so I've just disabled the uses in src/x86/{sysv, unix64}.S, as on Darwin. * Solaris/x86 needs to use EH_FRAME_FLAGS so manually and compiler generated .eh_frame sections match, otherwise libffi.so fails to link: * Solaris/x86 /bin/as has different COMDAT syntax; I've disabled it for the moment.
Richard Henderson f27c4e46 2015-01-13T07:22:07 x86: Fix thinko in ffi_raw_call Missed structure initialization for raw path. Apparently there are no tests for this outside gcc.
Anthony Green 1c61e73a 2015-01-10T09:23:30 Merge pull request #165 from rth7680/pcc Support PCC as producer and consumer
Anthony Green dd0b59a5 2015-01-10T09:22:55 Merge pull request #164 from rth7680/darwin Fix build on darwin
Anthony Green 9131039c 2015-01-10T09:22:42 Merge pull request #160 from nobu/msvc-no-complex x86: MSVC does not support Complex type
Richard Henderson 3fa5d70c 2015-01-05T13:03:06 x86: Avoid fastcall when building with pcc Apparently, PCC doesn't support the fastcall calling convention. Nor does it issue a warning or error for the attribute that it does not understand.
Richard Henderson a03d2310 2014-12-24T16:03:34 x86: Load structure return address into eax
Richard Henderson b7f6d7aa 2014-12-10T13:37:36 x86: Reinstate hand-written unwind info for sysv.S
Richard Henderson 6cedf81c 2014-12-10T09:43:58 x86: Expand FFI_GO_CLOSURE If we're going to have to hand-write unwind info for darwin, these macros make the job harder.
Iain Sandoe ae842a51 2014-11-25T11:43:40 x86: More Darwin unwind fixups EHFrame{N} IIRC is a special cue to ld64 that it should treat the unwind in the object as "special/legacy" .. [these days everything is .cfi_xxxx (except, cctools-as, as you noted)] .. without that much confusion arises with ld64's atom-isation of the eh_frame section. xxxx.eh labels are not needed for darwin ld64 >= 85.2.1 (i.e. darwin9, xcode 3.1.4) to all intents and purposes, that's all that matters now, since I think that anyone trying to build on 10.4/darwin8/xcode2.5 would have to use a later ld64 (from odcctools) for other reasons.
Richard Henderson 8fa3c9f2 2014-11-25T09:27:54 x86: Reinstate hand-written unwind info for unix64.S One more try to get default Darwin to work.
Richard Henderson 5f35e0ff 2014-11-24T16:26:50 x86: Avoid using gas local labels Which are unsupported by Darwin cctools as. Thankfully this doesn't uglify the source too much.
Richard Henderson ed1ca277 2014-11-24T13:02:03 x86: Remove use of .cfi_escape The unwind info isn't 100% correct at all points during the epilogue, and not annotating is just as incorrect as the annotation. This works better on systems that do not support DW_OP_call_frame_cfa.
Richard Henderson 1b12593d 2014-11-24T12:55:43 x86: Honor alignment of arguments Darwin aligns long-double to 16, and thus all of the long double tests were failing due to not honoring that. We ought to be able to devise a test case for GCC using __attribute__((aligned)) that would have failed too.
Richard Henderson 042b8daf 2014-11-24T11:24:02 x86: Use .balign not .align The Apple assembler defaults to power of two alignment, rather than byte alignment like everyone else. Force byte alignment by using the proper directive.
Richard Henderson 0172bc02 2014-11-24T10:42:02 x86: Disable .org for Darwin
Richard Henderson 9f112619 2014-11-22T20:02:43 x86: Best guess at update for Darwin
Nobuyoshi Nakada 7282d328 2014-12-22T17:14:40 x86: MSVC does not support Complex type
Nobuyoshi Nakada 5f8881a5 2014-12-22T17:08:08 x86: Fix void pointer arithmetic
Richard Henderson 2f652469 2014-12-11T14:16:00 x86: Handle void arguments as if an empty structure Since libffi currently doesn't allow empty structures, libgo currently maps them to ffi_type_void. Given that we'll abort on this case, handle it gracefully.
Richard Henderson 097ccfd6 2014-12-10T13:25:14 x86: Fix some unwind errors
Richard Henderson dea49e20 2014-11-14T13:05:14 x86: Fix typo in ffi_prep_go_closure Used the wrong register for THISCALL and FASTCALL.
Richard Henderson 0e303c06 2014-11-12T03:58:58 x86: Work around clang bugs http://llvm.org/bugs/show_bug.cgi?21500 http://llvm.org/bugs/show_bug.cgi?21501 http://llvm.org/bugs/show_bug.cgi?21515
Richard Henderson 2650f47f 2014-11-06T10:57:04 x86: Use win32 name mangling for fastcall functions
Richard Henderson f8c64e24 2014-11-05T17:04:29 x86: Add support for Go closures
Richard Henderson 198f469e 2014-11-05T16:34:41 x86: Add support for Complex
Richard Henderson b21ec1ce 2014-11-05T10:15:25 x86: Rewrite closures Move everything into sysv.S, removing win32.S and freebsd.S. Handle all abis with a single ffi_closure_inner function. Move complexity of the raw THISCALL trampoline into assembly instead of the trampoline itself. Only push the context for the REGISTER abi; let the rest receive it in a register.
Richard Henderson 99db4d42 2014-10-23T14:12:18 win64: Rewrite It's way too different from the 32-bit ABIs with which it is currently associated. As seen from all of the existing XFAILs.
Richard Henderson 4b2fad8f 2014-10-30T12:41:31 x86: Remove some conditional compilation Removal of ifdefs made possible to due to ffi_abi unification.
Richard Henderson b9ac94f3 2014-11-01T15:10:34 x86: Rewrite ffi_call Decouple the assembly from FFI_TYPE_*. Merge prep_args with ffi_call, passing the frame and the stack to the assembly. Note that this patch isn't really standalone, as this breaks closures.
Richard Henderson 159d3788 2014-10-31T12:07:02 x86: Convert to gas generated unwind info
Richard Henderson e7b0056d 2014-10-30T13:57:39 x86: Force FFI_TYPE_LONGDOUBLE different from FFI_TYPE_DOUBLE There are few abis that set double = long double. Eliminate the conditional compilation and let this code simply be unused there.
Richard Henderson ef762056 2014-10-30T12:13:31 x86: Tidy ffi_abi The x86_64 unix port only handles one ABI; don't define all of the other symbols. The UNIX64 symbol retains the same value. The i386 ports ought to have the same symbols, even if we can't yet unify the values without incrementing the libffi soname.
Richard Henderson 610c90bf 2014-10-28T11:21:50 x86_64: Add support for complex types
Richard Henderson 32c56831 2014-10-28T11:17:35 x86_64: Decouple return types from FFI_TYPE constants We can better support structure returns, and as prep for complex types.
Richard Henderson 2e9dc165 2014-10-27T13:41:39 x86_64: Fixups for x32
Richard Henderson ebd82769 2014-10-23T23:57:06 win64: Remove support from ffi.c
Richard Henderson 6b62fb4a 2014-10-17T11:11:58 x86-64: Support go closures Dumps all of the hand-coded unwind info for gas generated. Move jump table data into .rodata. Adjust ffi_call_unix64 to load the static chain. Split out sse portions of ffi_closure_unix64 to ffi_closure_unix64_sse rather than test cif->flags at runtime.
Anthony Green a0bdc525 2014-11-11T09:43:01 Fix typo
Anthony Green 6695983d 2014-09-20T07:44:37 Add complex type support. Mostly broken right now
Bernd Edlinger bfcbf329 2014-09-20T06:51:45 2014-05-11 Bernd Edlinger <bernd.edlinger@hotmail.de> Fix current cygwin-64 build problems. * src/java_raw_api.c: Remove if !defined(FFI_NO_RAW_API). * src/x86/ffi.c: Add if defined(__CYGWIN__). * src/x86/win64.S (ffi_closure_win64, ffi_call_win64): Added handling for FFI_TYPE_UINT64, FFI_TYPE_POINTER and FFI_TYPE_INT. Added SEH information. Fixed formatting.
Dominik Vogt 6e8a4460 2014-09-20T06:21:19 2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com> * src/types.c (FFI_TYPEDEF, FFI_NONCONST_TYPEDEF): Merge the macros by adding another argument that controls whether the result is const or not (FFI_LDBL_CONST): Temporary macro to reduce ifdef confusion * src/prep_cif.c (ffi_prep_cif_core): Replace list of systems with new macro FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION * src/pa/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION): Define. * src/s390/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION): Define. * src/x86/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION): Define. 2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com> * doc/libffi.texi (Primitive Types): Document ffi_type_complex_float, ffi_type_complex_double and ffi_type_complex_longdouble (Complex Types): New subsection. (Complex Type Example): Ditto. * testsuite/libffi.call/cls_align_complex_double.c: New FFI_TYPE_COMPLEX test. * testsuite/libffi.call/cls_align_complex_float.c: Ditto. * testsuite/libffi.call/cls_align_complex_longdouble.c: Ditto. * testsuite/libffi.call/cls_complex_double.c: Ditto. * testsuite/libffi.call/cls_complex_float.c: Ditto. * testsuite/libffi.call/cls_complex_longdouble.c: Ditto. * testsuite/libffi.call/cls_complex_struct_double.c: Ditto. * testsuite/libffi.call/cls_complex_struct_float.c: Ditto. * testsuite/libffi.call/cls_complex_struct_longdouble.c: Ditto. * testsuite/libffi.call/cls_complex_va_double.c: Ditto. * testsuite/libffi.call/cls_complex_va_float.c: Ditto. * testsuite/libffi.call/cls_complex_va_longdouble.c: Ditto. * testsuite/libffi.call/complex_double.c: Ditto. * testsuite/libffi.call/complex_defs_double.c: Ditto. * testsuite/libffi.call/complex_float.c: Ditto. * testsuite/libffi.call/complex_defs_float.c: Ditto. * testsuite/libffi.call/complex_longdouble.c: Ditto. * testsuite/libffi.call/complex_defs_longdouble.c: Ditto. * testsuite/libffi.call/complex_int.c: Ditto. * testsuite/libffi.call/many_complex_double.c: Ditto. * testsuite/libffi.call/many_complex_float.c: Ditto. * testsuite/libffi.call/many_complex_longdouble.c: Ditto. * testsuite/libffi.call/return_complex1_double.c: Ditto. * testsuite/libffi.call/return_complex1_float.c: Ditto. * testsuite/libffi.call/return_complex1_longdouble.c: Ditto. * testsuite/libffi.call/return_complex2_double.c: Ditto. * testsuite/libffi.call/return_complex2_float.c: Ditto. * testsuite/libffi.call/return_complex2_longdouble.c: Ditto. * testsuite/libffi.call/return_complex_double.c: Ditto. * testsuite/libffi.call/return_complex_float.c: Ditto. * testsuite/libffi.call/return_complex_longdouble.c: Ditto. * src/raw_api.c (ffi_raw_to_ptrarray): Handle FFI_TYPE_COMPLEX (ffi_ptrarray_to_raw): Ditto. * src/prep_cif.c (ffi_prep_cif_core): Abort if FFI_TYPE_COMPLEX is not implemented in libffi for the target. * src/java_raw_api.c (ffi_java_raw_size): FFI_TYPE_COMPLEX not supported yet (abort). (ffi_java_raw_to_ptrarray): Ditto. (ffi_java_rvalue_to_raw): Ditto. (ffi_java_raw_to_rvalue): Ditto. * src/debug.c (ffi_type_test): Add debug tests for complex types. * include/ffi.h.in (FFI_TYPE_COMPLEX): Add new FFI_TYPE_COMPLEX. (FFI_TYPE_LAST): Bump. (ffi_type_complex_float): Add new ffi_type_.... (ffi_type_complex_double): Ditto. (ffi_type_complex_longdouble): Ditto. 2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com> * src/s390/ffitarget.h (FFI_TARGET_HAS_COMPLEX_TYPE): Define to provide FFI_TYPE_COMPLEX support. * src/s390/ffi.c (ffi_check_struct_type): Implement FFI_TYPE_COMPLEX (ffi_prep_args): Ditto. (ffi_prep_cif_machdep): Ditto. (ffi_closure_helper_SYSV): Ditto.