src


Log

Author Commit Date CI Message
Icecream95 af0f14cd 2022-10-24T04:08:10 Fix types of temporary variables in aarch64 extend_integer_type (#745) Fixes truncated values in weston-info output.
Anthony Green 93cfb655 2022-10-10T14:32:35 Correction for older compilers
Andreas Schwab 3874fd98 2022-10-10T17:58:48 Fix strict aliasing problem in aarch64 ffi_call (#739) The assignment a = &dest in ffi_call_int may be moved after the call to extend_integer_type because that function accesses the assigned value with a different type. Co-authored-by: Andreas Schwab <schwab@suse.de>
Andreas Schwab 4b0c358e 2022-10-10T17:57:47 riscv: make copies of structs passed by reference (#738) Co-authored-by: Andreas Schwab <schwab@suse.de>
Anthony Green 963c4a96 2022-09-27T22:05:42 Remove nested comments
Anthony Green a2473cde 2022-09-24T21:41:02 or1k: All struct args are passed in memory
Anthony Green f93224d3 2022-09-24T21:38:57 moxie: All struct args are passed in memory
Anthony Green ff34df23 2022-09-19T06:45:19 Update comment about platform support
Anthony Green fc6b9390 2022-09-19T06:42:29 Standardize temp exec file creation
Anthony Green 4c2984c4 2022-09-18T15:06:57 Handle win32 ABIs for struct return
Anthony Green b05dc51b 2022-09-18T13:03:10 Debug x86
Anthony Green cafdb837 2022-09-18T12:05:12 Revert
Anthony Green 735e7be4 2022-09-18T08:21:34 X86 is never defined.
Hans ee22ecbd 2022-09-18T01:56:25 Add MSYS configuration files (#728) * Add MSYS configuration files MSYS behaves very similiar to Cygwin, e.g. also __CYGWIN__ is defined. Now 'make check' passes on MSYS without extra patches. * Fix warning extra tokens at end of #endif in closures.c Extra tokens converted into a comment. Also nearby indentations corrected. * Fix missing prototype warning mkostemp() on Cygwin Cygwin requires also _GNU_SOURCE to be defined to enable mkostemp() prototype. * Fix warning label ‘out’ defined but not used in ffi functions Define same preprocessor conditions for goto and label visibility. * Fix warning label ‘out’ defined but not used and related indentations. Define same preprocessor conditions for goto and label visibility. Correct also related indentations. Co-authored-by: Hannes Müller <>
Anthony Green 05785caf 2022-09-15T15:18:09 Fix arg alignment for STDCALL
Anthony Green 4b54a647 2022-09-12T09:02:08 Fix limits.h inclusion for cygwin
Anthony Green a1130f37 2022-09-12T08:53:06 Add static trampoline support for Cygwin
Anthony Green da905276 2022-09-06T21:15:58 dlmmap fix and always check for PaX MPROTECT on linux Also make EMUTRAMP experimental From Stefan Bühler https://github.com/libffi/libffi/pull/282
Anthony Green e4c5d46b 2022-09-05T12:19:57 Pass large structs by value
Clément Chigot 80912f2f 2022-09-01T14:47:16 Makefile: enable target overridings. (#661) This patch allows target to provide extra files enabling the override of Makefile rules. This patch is not needed for libffi itself but only for GCC on AIX. The t-aix file which is here empty will be replaced in GCC repository. We cannot include GCC version directly here because it has no sense for a standalone libffi. Co-authored-by: Clement <clement.chigot@atos.net>
Anthony Green 0eb91425 2022-08-31T20:46:24 Change comment style
Xi Ruoyao 5a4774cd 2022-07-22T05:56:30 static trampoline for LoongArch (#723) For the benefit and technical details of static trampoline, see https://github.com/libffi/libffi/pull/624. As a new architecture, let's be "safer" from the start. The change survived libffi testsuite on loongarch64-linux-gnu.
Anthony Green fc8c8c1e 2022-06-25T11:06:00 Fix ILP32 for aarch64
Russell Keith-Magee 1f14b3fa 2022-06-03T02:46:35 Ensure that VM_PROT_EXECUTE is set on the trampoline page. (#718)
Sergei Trofimovich 000ecd01 2022-06-02T18:43:53 powerpc64: fix build on gcc-12 (assembly requires AltiVec) (#719) Without the change build fails on powerpc64-gcc-12 as: src/powerpc/linux64_closure.S: Assembler messages: src/powerpc/linux64_closure.S:363: Error: unrecognized opcode: `lvx' It's a 90205f67 "rs6000: Fix bootstrap (libffi)" patch by Segher Boessenkool from gcc upstream repository. It's enough to get libffi build on powerpc64.
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 36b265ae 2022-05-29T10:12:30 m32r: pass copies of large structs
Martin Storsjö fd1fe195 2022-05-29T14:16:49 Fix building on aarch64 after e409225b41b60c490a094bb068e639a2364202fd (#716) The ALIGN_DOWN macro was renamed in 2018 in e6eac7863e2bf1a009ea863041b354bdb4af6b67.
Anthony Green c1e237b2 2022-05-28T20:46:14 Pass large structs by value on the stack
Anthony Green 769b7366 2022-05-28T19:59:35 Fix for MS x64 ABI
Anthony Green faafcb9d 2022-05-28T17:24:43 Fix moxie struct passing
Anthony Green f55d7ff1 2022-05-28T14:30:13 moxie: structs > 8 go on stack
Anthony Green 72c31927 2022-05-28T13:53:26 Pass copies of large structs on the stack
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
zhangwenlong f259a6f6 2022-05-25T09:31:08 Support loongarch64 (#678) * update config.{guess,sub} * Support loongarch64 Co-Authored-By: Cheng Lulu <chenglulu@loongson.cn> Co-Authored-By: Xi Ruoyao <xry111@mengyan1223.wang> Co-Authored-By: Xu Hao Co-Authored-By: Zhang Wenlong <zhangwenlong@loongson.cn> Co-Authored-By: Pan Xuefeng <panxuefeng@loongson.cn> Co-authored-by: panxuefeng <panxuefeng@loongson.cn> Co-authored-by: Cheng Lulu <chenglulu@loongson.cn> Co-authored-by: Xi Ruoyao <xry111@mengyan1223.wang>
Anthony Green 7e93ded9 2022-05-23T21:42:52 Revert "Don't dereference beyond the last array entry. (#667)" (#715) This reverts commit 92d77d0e87a5f2a8c9c9b2431ffd264cb664e17a.
Kevin Bowling 9af445fd 2022-05-23T18:05:01 Upstream FreeBSD riscv patch (#708) Like 8276f812a99b10d1f2c387dbd6ef2ca4f597c733 commit message: > devel/libffi: Fix abort() on ARM related to __clear_cache() > > The current FreeBSD __clear_cache() implementation does nothing #if > __i386__ || __x86_64__ #else abort(); > > cognet@ advises this is an issue for anything !Apple that is using the > libcompiler_rt provided by Clang on ARM, and requires upstreaming. Co-authored-by: Kristof Provost <kp@FreeBSD.org>
Roland Schatz de95947a 2022-05-24T03:04:43 Fix check for invalid varargs arguments. (#707)
Anthony Green 92d77d0e 2022-05-23T21:03:00 Don't dereference beyond the last array entry. (#667)
YunQiang Su 2e825e21 2022-05-16T09:47:11 MIPS: fix some N32 test failure (#701) Some go closure and pointer testcase fails. These failures is not introduced by the complex support code.
YunQiang Su 1f1c3375 2022-05-16T09:45:27 MIPS: fix O32 softfloat support (#702)
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.
YunQiang Su e67697c3 2022-03-31T20:44:49 MIPS: add Complex support (#698)
Ole André Vadla Ravnås e3cf8b80 2022-03-31T14:42:03 Allow system to have overlapping mallopt defines (#700) Which is the case on some OSes, such as QNX.
Ole André Vadla Ravnås c086cacb 2022-03-31T14:40:59 Clean up the QNX ARM bits (#699) - Add missing include. - Use constants instead of magic values.
Max Filippov ab167710 2022-02-20T16:01:38 Xtensa cleanups and XEA3 support (#677) * xtensa: clean up stack usage in ffi_trampoline call Space for outgoing call arguments reserved in the stack frame of the function ffi_trampoline overlaps register spill overflow area at the top of the frame. In xtensa XEA2 exception architecture the layout of overlapping areas is identical so that even if the ffi_trampoline registers frame gets spilled the memory contents doesn't change. This is not so with the xtensa XEA3 exception architecture, where registers a0 - a7 of a different function are spilled in that location. Reserve spill area for 8 registers to avoid overlapping of the spill area with the outgoing call arguments area in the ffi_trampoline. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> * xtensa: support xtensa XEA3 exception architecture XEA3 requires that 32 bytes of register spill area is reserved in all functions. Fix ffi_cacheflush entry instruction to satisfy this requirement. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> * xtensa: maintain stack alignment xtensa ABI requires stack alignment on 16 byte boundary and passing up to 6 arguments in registers. To simplify stack alignment maintenance fixed amount of stack space is reserved for arguments passed in registers and variable but correctly aligned amount is reserved for the remaining arguments. After copying arguments to the stack and loading registers the fixed part of the stack reservation is freed. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> * xtensa: fix err_bad_abi tests Check ffi_cif::abi value in the ffi_prep_closure_loc and return FFI_BAD_ABI error if it's not one of the supported values. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Andreas Schwab aa3fce08 2022-02-13T21:04:33 riscv: extend return types smaller than ffi_arg (#680) Co-authored-by: Andreas Schwab <schwab@suse.de>
Dan Horák 464b4b66 2022-01-31T14:08:09 powerpc64: fix handling of homogeneous float128 structs (#689) If there is a homogeneous struct with float128 members, they should be copied to vector register save area. The current code incorrectly copies only the value of the first member, not increasing the pointer with each iteration. Fix this.
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.
Anthony Green ee1263f7 2021-07-29T17:46:17 Fix 'type'-o
Anthony Green 86d5ecc5 2021-07-29T16:58:32 Fix struct arg passing
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.
vhankala ff059dd9 2021-06-10T18:41:02 Fix build on OpenBSD/mips64 (#638) The build fails on OpenBSD/mips64 because clang 11's integrated assembler expects read-only .eh_frame: ../src/mips/n32.S:585:9: error: changed section flags for .eh_frame, expected: 0x2 .section .eh_frame,"aw",@progbits ^ Use EH_FRAME_FLAGS to get matching flags for the section.
Martin Storsjö dd5bd030 2021-04-07T05:42:10 Fix building for arm windows with mingw toolchains (#631) * arm: Check _WIN32 instead of _M_ARM or _MSC_VER for detecting windows This matches what was done for ARM64 in c06468fa6674d3783a0edb1d0fae9afc8bc28513. * arm: Only use armasm source when building with MSVC When building for windows/arm with clang, the normal gas style .S source works fine (if fixed up to support thumb and other windows specifics). This matches what was done for ARM64 in c06468fa6674d3783a0edb1d0fae9afc8bc28513. * arm: Fix sysv.S to work in thumb mode Align cases in jump tables (adding nop padding to make sure each case starts where expected). Rewrite instructions that add directly to the pc register. For ffi_closure_ret, factor out a call_epilogue subroutine that restores both sp and pc from the stack; the thumb version of ldm can't load into the sp register. To avoid excessive ifdeffing, keep using call_epilogue in arm mode, but keep the shorter "ldm sp, {sp, pc}" epilogue in that case. * arm: Add win32 version of trampoline to sysv.S This matches the version of it in sysv_msvc_arm32.S. The calling C code expects a specific form of the trampoline on windows; make sure these work the same on windows regardless of the form of assembly used. * arm: Avoid optimizing out clearing the thumb bit of ffi_arm_trampoline We clear the thumb bit of ffi_arm_trampoline with a bitmask before memcpying its instructions into closure->tramp. If the bit isn't cleared, the memcpy of the trampoline function copies the wrong instructions. If the ffi_arm_trampoline symbol is declared as an array of int, the compiler can assume that it is aligned to a 4 byte boundary and the bitmask operation is a no-op, and optimize it out. See https://godbolt.org/z/dE3jE1WTz; both Clang and GCC optimize out the bitmask as it is, while MSVC doesn't. By declaring the trampoline as an array of unsigned char, the bitmask works as intended.
Jeremy Huddleston Sequoia eafab235 2021-03-24T11:38:36 arm64e: Pull in pointer authentication code from Apple's arm64e libffi port (#565) NOTES: This changes the ptrauth support from #548 to match what Apple is shipping in its libffi-27 tag. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
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>
DJ Delorie 70ea259c 2021-03-23T19:03:45 Search $LIBFFI_TMPDIR also (#605) Most temp file directories need to be hardened against execution, but libffi needs execute privileges. Add a libffi-specific temp directory that can be set up by sysadmins as needed with suitable permissions. This both ensures that libffi will have a valid temp directory to use as well as preventing attempts to access other directories.
AndreRH f58e5ee6 2021-03-23T23:54:00 aarch64: Fix closures for win64 (#606)
Anthony Green 205cf01b 2021-03-23T11:31:08 Bug #680. Don't accept floats or small ints as var args. (#628) * Bug #680. Don't accept floats or small ints as var args. * Bug #680. Don't accept floats or small ints as var args. * Bug #680. Don't accept floats or small ints as var args.
Jeremy Huddleston Sequoia d271dbe0 2021-03-20T06:06:28 Add some missing #if conditionals from Apple's code drop (#620) * arm/aarch64: Add FFI_CLOSURES conditionals where appropriate Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch64: Don't emit the do_closure label when building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.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>
DJ Delorie 5c63b463 2020-12-02T16:14:27 Use memfd_create() (#604) memfd_create creates a file in a memory-only filesystem that may bypass strict security protocols in filesystem-based temporary files.
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"
AndreRH 56f7df71 2020-11-10T12:27:59 aarch64: Allow FFI_WIN64 for winelib (#593)
Ken 484c1a0d 2020-10-27T07:07:07 darwin powerpc: use go closures only if enabled (#583) SHA: 0ff9419f2e75652426469e256cb7d0748064ad58 added go closures for darwin powerpc AIX, but these have not yet been implemented for non-AIX systems use the go closures only if enabled
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.
Alan Modra f4435980 2020-10-27T23:36:21 Power10 libffi fixes (#585) Power10 pc-relative code doesn't use or preserve r2 as a TOC pointer. That means calling between pc-relative and TOC using code can't be done without intervening linker stubs, and a call from TOC code to pc-relative code must have a nop after the bl in order to restore r2. Now the PowerPC libffi assembly code doesn't use r2 except for the implicit use when making calls back to C, ffi_closure_helper_LINUX64 and ffi_prep_args64. So changing the assembly to interoperate with pc-relative code without stubs is easily done. * src/powerpc/linux64.S (ffi_call_LINUX64): Don't emit global entry when __PCREL__. Call using @notoc. Add nops. * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise. (ffi_go_closure_linux64): Likewise.
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`.
Niclas Zeising 8276f812 2020-08-07T21:05:23 Upstream local FreeBSD patches (#567) * Add support for FreeBSD mips Add support for FreeBSD mips, this has been a local patch in the FreeBSD ports tree for quite some time. Originally submitted by sson, and committed by sbruno AT FreeBSD DOT org See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191909 for background details. Signed-off-by: Niclas Zeising <zeising@daemonic.se> * Add support for FreeBSD powerpcspe Add support for powerpcspe on FreeBSD This has been in the FreeBSD ports tree for some time. Originally submitted by jhibbits AT FreeBSD DOT org. Signed-off-by: Niclas Zeising <zeising@daemonic.se> * Fix abort() on FreeBSD arm related to __clear_cache() This patch has been in the FreeBSD ports tree for a number of years. Original commit by koobs AT FreeBSD DOT org Original commit message: > devel/libffi: Fix abort() on ARM related to __clear_cache() > > The current FreeBSD/ARM __clear_cache() implementation does nothing #if > __i386__ || __x86_64__ #else abort(); > > cognet@ advises this is an issue for anything !Apple that is using the > libcompiler_rt provided by Clang on ARM, and requires upstreaming. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=149167 for some background details. Signed-off-by: Niclas Zeising <zeising@daemonic.se>
Jakub Wilk 8e58f88d 2020-06-30T22:59:28 aarch64: Fix typo
Ma Jun fbd1de85 2020-06-29T08:02:20 Add support for csky
Yann Sionneau 5e6ca054 2020-05-01T13:59:11 Add support for Kalray KVX architecture (#559)
Andrew Geissler 4f9e20ac 2020-05-01T06:58:30 ffi_powerpc.h: fix build failure with powerpc7 (#561) This is a patch pulled down from the following: https://github.com/buildroot/buildroot/blob/78926f610b1411b03464152472fd430012deb9ac/package/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch This issue is being hit on OpenBMC code when pulling the latest libffi tag and building on a P8 ppc64le machine. I verified this patch fixes the issue we are seeing. Below is the original commit message: Sicne commit 73dd43afc8a447ba98ea02e9aad4c6898dc77fb0, build on powerpc7 fails on: In file included from ../src/powerpc/ffi.c:33:0: ../src/powerpc/ffi_powerpc.h:61:9: error: '_Float128' is not supported on this target typedef _Float128 float128; ^~~~~~~~~ Fix this build failure by checking for __HAVE_FLOAT128 before using _Float128, as _Float128 is enabled only on specific conditions, see output/host/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/floatn.h: /* Defined to 1 if the current compiler invocation provides a floating-point type with the IEEE 754 binary128 format, and this glibc includes corresponding *f128 interfaces for it. */ #if defined _ARCH_PWR8 && defined __LITTLE_ENDIAN__ && (_CALL_ELF == 2) \ && defined __FLOAT128__ && !defined __NO_LONG_DOUBLE_MATH # define __HAVE_FLOAT128 1 #else # define __HAVE_FLOAT128 0 #endif Fixes: - http://autobuild.buildroot.org/results/5c9dd8fb3b6a128882b6250f197c80232d8a3b53 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Andrew Geissler <geissonator@yahoo.com> Co-authored-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Martin Storsjö 053b04c5 2020-04-26T05:02:14 arm: Fix the clang specific version of the assembly (#556) Also fix the same error in the comment for the non-clang case. That typo there seems to have existed since the code was written in that form, in e7f15f60e86 - and when the clang specific codepath was added in e3d2812ce43, the typo in the comment made it into the actual code.
Martin Storsjö c543849c 2020-04-26T05:01:03 win64_armasm: Fix the spelling of ALIGN (#553)
Martin Storsjö 15d3ea31 2020-04-26T04:59:35 Use __builtin_ffs instead of ffs (#554) USE_BUILTIN_FFS is defined to 1 within __GNUC__, and the __builtin_ffs function is available since GCC 3.x at least, while the ffs function only exists on some OSes. This fixes compilation for non-x86 mingw platforms. For x86, USE_BUILTIN_FFS is explicitly disabled for windows targets - but if USE_BUILTIN_FFS is enabled based on __GNUC__, it should also use the builtin which actually is available correspondingly, not dependent on the target OS.
Martin Storsjö c06468fa 2020-04-26T04:58:33 Fix building for aarch64 windows with mingw toolchains (#555) * aarch64: Check _WIN32 instead of _M_ARM64 for detecting windows This fixes building for aarch64 with mingw toolchains. _M_ARM64 is predefined by MSVC, while mingw compilers predefine __aarch64__. In aarch64 specific code, change checks for _M_ARM64 into checks for _WIN32. In arch independent code, check for (defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32) instead of just _M_ARM64. In src/closures.c, coalesce checks like defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) into plain defined(_WIN32). Technically, this enables code for ARM32 windows where it wasn't, but as far as I can see it, those codepaths should be fine for that architecture variant as well. * aarch64: Only use armasm source when building with MSVC When building for windows/arm64 with clang, the normal gas style .S source works fine. sysv.S and win64_armasm.S seem to be functionally equivalent, with only differences being due to assembler syntax.
Ole André Vadla Ravnås 4c7bde32 2020-03-10T02:05:42 Port to iOS/arm64e (#548)
Moxie Bot 8eb2d2b0 2020-02-24T10:29:20 Revamp PA_LINUX and PA_HPUX target closures to use function descriptors. 2020-02-23 John David Anglin <danglin@gcc.gnu.org> * include/ffi.h.in (FFI_CLOSURE_PTR, FFI_RESTORE_PTR): Define. * src/closures.c (ffi_closure_alloc): Convert closure pointer return by malloc to function pointer. (ffi_closure_free): Convert function pointer back to malloc pointer. * src/pa/ffi.c (ffi_closure_inner_pa32): Use union to double word align return address on stack. Adjust statements referencing return address. Convert closure argument from function pointer to standard closure pointer. (ffi_prep_closure_loc): Likewise convert closure argument back to closure pointer. Remove assembler trampolines. Setup simulated function descriptor as on ia64. src/pa/ffitarget.h (FFI_TRAMPOLINE_SIZE): Reduce to 12. src/pa/hpux32.S (ffi_closure_pa32): Retrieve closure pointer and real gp from fake gp value in register %r19. src/pa/linux.S (ffi_closure_pa32): Likewise.
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.
Samuel Holland 4d6d2866 2020-02-21T21:06:15 Update powerpc sysv assembly for ffi_powerpc.h changes (#541) Some of the flag bits were moved when adding powerpc64 vector support. Fixes #536
Khem Raj e50b9ef8 2019-12-07T02:34:14 powerpc64: Use memcpy to help platforms with no __int128. (#534) Signed-off-by: Khem Raj <raj.khem@gmail.com>
Carl Hurd 76c0cfea 2019-11-29T14:46:11 Fixed missed #ifndef for __mips_soft_float (#442) Thank you!
Anthony Green 6663047f 2019-11-29T07:00:35 Address platforms with no __int128.
Sergei Trofimovich 01a75ed7 2019-11-28T12:42:41 powerpc: fix build failure on power7 and older (#532) Build failure looks as: ``` libtool: compile: powerpc-unknown-linux-gnu-gcc \ -O2 -mcpu=powerpc -mtune=powerpc -pipe ... -c src/powerpc/ffi.c ... In file included from src/powerpc/ffi.c:33: src/powerpc/ffi_powerpc.h:65:9: error: '__int128' is not supported on this target 65 | typedef __int128 float128; | ^~~~~~~~ ``` The fix avoids using __int128 in favour of aligned char[16]. Closes: https://github.com/libffi/libffi/issues/531 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Anthony Green 31543c79 2019-11-20T06:15:55 Add work-around for users who manage their own closure memory As suggested by DJ
Samuel Holland 73dd43af 2019-11-17T07:22:25 IEEE754 binary128 long double support for PowerPC64 (#526) * powerpc: Adjust flags to make room for vector types * powerpc64 ELFv2 IEEE128 long double support
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
pnallan 55c22092 2019-10-08T18:46:47 handle compilation warnings with ftruncate API (#508) * fix me: avoid warning while handle ftruncate API Signed-off-by: Prasad Nallani <prasad.nallani@intel.com> * Update closures.c
John Ericson e5f0eb15 2019-10-08T06:58:52 Clean up line endings (#509) The CLRF visual studio files can be kept that way, but recognized as text. The assembly file can be converted to LF.
Samuel Holland ea9b6639 2019-10-08T05:57:28 PowerPC bugfixes (#520) * powerpc: Silence warnings about unused labels * powerpc: Fix a couple of comments * powerpc: Fix alignment after float structs * powerpc: Don't pad rvalues copied from FP regs * powerpc: Add missing check in struct alignment * powerpc: Support homogeneous long double structs
Paul Monson c2a68590 2019-08-07T11:57:45 fix mingw build and crashing bugs for Python Windows ARM64 (#496) * fix mingw build and crashing bugs for Python Windows ARM64 * Fix issues found in PR review
ossdev07 d856743e 2019-06-26T07:31:22 libffi: added ARM64 support for Windows (#486) * libffi: added ARM64 support for Windows 1. ported sysv.S to win64_armasm.S for armasm64 assembler 2. added msvc_build folder for visual studio solution 3. updated README.md for the same 4. MSVC solution created with the changes, and below test suites are tested with test script written in python. libffi.bhaible libffi.call 5. Basic functionality of above test suites are getting passed Signed-off-by: ossdev07 <ossdev@puresoftware.com> * Update README.md