Log

Author Commit Date CI Message
Anthony Green bfb5b005 2025-04-09T10:32:42 feat: Update version of libffi to 3.4.8 with various fixes and enhancements
Peter Bergner 3429ed6b 2025-04-08T05:52:37 powerpc: Add static trampoline support (#894) (#895) Add static trampoline support to all three powerpc Linux ABIs, specifically powerpc-linux (32-bit SYSV BE), powerpc64-linux (64-bit ELFv1 BE) and powerpc64le-linux (64-bit ELFv2 LE). This follows the s390x implementation and does not introduce a ffi_closure_*_alt function, but rather jumps directly to the ffi_closure_* function itself. If compiling with --with-gcc-arch=power10 and pc-relative is enabled, we use a simpler and smaller trampoline that utilizes Power10's new pc-relative load instructions.
mikulas-patocka bb1a84ed 2025-03-30T12:07:59 Add the "ABI_ATTR" attribute to called functions (#891) (#892) I accidentally omitted the "ABI_ATTR" attribute, so that the testsuite fails when testing the Microsoft ABI. Fixes: fe203ffbb2bd ("Fix bugs in the x86-64 and x32 target (#887) (#889)") Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
mikulas-patocka fe203ffb 2025-03-27T01:31:49 Fix bugs in the x86-64 and x32 target (#887) (#889) This commit fixes two bugs in ffi in the x86-64 target. The bugs were introduced by the commit d21881f55ed4a44d464c9091871e69b0bb47611a ("Fix x86/ffi64 calls with 6 gp and some sse registers"). The first bug is that when we pass an argument with less than 8 bytes, ffi will read memory beyond argument end, causing a crash if the argument is located just before the end of the mapped region. The second bug is in the x32 ABI - pointers in x32 are 4-byte, but GCC assumes that the pointer values in the registers are zero-extended. ffi doesn't respect this assumption, causing crashes in the called library. For example, when we compile this function for x32: int fn(int *a) { if (a) return *a; return -1; } we get this code: fn: testq %rdi, %rdi je .L3 movl (%edi), %eax ret .L3: movl $-1, %eax ret When we call this function using ffi with the argument NULL, the function crashes because top 4 bytes of the RDI register are not cleared. Fixes: d21881f55ed4 ("Fix x86/ffi64 calls with 6 gp and some sse registers (#848)") Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
Nikita Samusev cf69efab 2025-03-08T14:41:02 Update the Simple Example to fix a compile error (#886) Fixes the following error: candidate function not viable: no known conversion from 'int (const char *)' to 'void (*)()' for 2nd argument
fossdd 89c99d73 2025-02-28T22:10:10 MIPS: Dont import asm/sgidefs.h on linux (#885) Removed from Linux since Linux 3.7 Ref: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=61730c538f8281efa7ac12596da9f3f9a31b9272
Bill Roberts 5ceddf40 2025-02-20T04:25:21 aarch64: add PAC to GNU Notes (#882) While PAC was enabled, the bit to indicate support in the GNU Notes section of the ELF was missing. Before: readelf -n ./aarch64-unknown-linux-gnu/.libs/libffi.so Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: BTI This was caused by this file not having PAC indicated in GNU Notes and the linker discarding it: File: ./aarch64-unknown-linux-gnu/src/aarch64/sysv.o Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: BTI Now it has it: File: ./aarch64-unknown-linux-gnu/src/aarch64/sysv.o Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: BTI, PAC As well as the output shared object: readelf -n ./aarch64-unknown-linux-gnu/.libs/libffi.so Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: BTI, PAC Fixes: #881 Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Anthony Green 1716f81e 2025-02-08T11:32:05 feat: remove nios2 support Acked-by: Anthony Green <green@moxielogic.com>
Anthony Green 252c0f46 2025-02-08T09:37:31 chore: Bump version to 3.4.7 and update change log
Kleis Auke Wolthuizen adfe4489 2025-01-31T21:41:56 Emscripten: remove support for `-sWASM_BIGINT=0` (#874) * Emscripten: cleanup * Emscripten: remove support for `-sWASM_BIGINT=0` * Emscripten: remove redundant CircleCI config * Emscripten: modernize CI * Ensure test helper methods are static Similar to #644. * Fix test failures in `cls_multi_{s,u}shortchar`
Matthew Flatt 2f34cf63 2025-01-31T13:40:40 x86 Darwin returns structs of size 1, 2, 4, and 8 in registers (#876)
zye2-sc a0d8074a 2025-01-31T21:40:00 Disable go closures on Android (#877) * x18 register shouldn't be used on Android due to the shadow call stack feature in llvm * https://source.android.com/docs/security/test/shadow-call-stack
杨萧玉 d77b9fef 2024-12-13T18:38:01 Fix config.sub on Apple platforms (#860) * update config.sub * update config.sub
Satadru Pramanik, DO, MPH, MEng 593cb01a 2024-12-13T05:37:15 Add mold linker to linker checks. (#866) Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Icenowy Zheng f515eac0 2024-12-13T18:36:02 MIPS: add .note.GNU-stack section to assembly sources (#872) To build ELF shared libraries that do not require executable stack on MIPS, every object file linked should have a .note.GNU-stack section, otherwise the linker defaults to executable stack. As libffi shouldn't require executable stack, add the .note.GNU-stack section to the assembly source files under src/mips, like other architectures. Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Eddy S. 458b2ae2 2024-11-16T13:03:24 Add static trampoline support for s390 (#862) * added static trampoline support for s390 * enable static tramp only for s390x 64bit
Joseph Myers 0859f843 2024-10-24T18:26:58 Fix testsuite for C23 `va_start` (#861) In the C23 revision of the C standard, `va_start` ignores its second argument, which is no longer required (previously the last named function parameter - which the compiler knows anyway, so it's redundant information). This has the consequence for the libffi testsuite, when making GCC default to `-std=gnu23`, of making two tests fail with warnings about an unused function argument (only passed to `va_start` and not otherwise used). Fix those test failures by explicitly casting the argument to `void`.
Ivan Tadeu Ferreira Antunes Filho 8308bed5 2024-09-20T06:01:23 Move cfi_startproc after CNAME(label) (#857) This is a fix for https://github.com/libffi/libffi/issues/852: error: invalid CFI advance_loc expression on apple targets. The CFI for darwin arm64 was broken because the CNAME macro was being used after the cfi_startproc macro.
KJ Tsanaktsidis 01db744b 2024-09-20T20:00:49 Disable ASAN in ffi_call_int functions (#858) The pattern for several of the architectures is for ffi_call_int to stack-allocate some arguments + the registers, and then ffi_call_$ARCH will pop the top of that structure into registers, and then adjust the stack pointer such that the alloca'd buffer _becomes_ the stack-passed arguments for the function being called. If libffi is compiled with ASAN, then there will be a redzone inserted after the alloca'd buffer which is marked as poisoned. This redzone appears beyond the end of $sp upon entry to the called function. If the called function does anything to use this stack memory, ASAN will notice that it's poisoned and report an error. This commit fixes the situation (on the architectures that I have access to) disabling instrumentation for ffi_call_int; that means there will be no alloca redzone left on the shadow-stack.
Sam James f7e49927 2024-09-20T10:58:06 testsuite: fix dejagnu directive typo (#859)
Anthony Green 084f3690 2024-09-15T12:32:58 Merge remote-tracking branch 'refs/remotes/origin/master'
Anthony Green 92d384df 2024-09-15T12:32:29 Fix floating point compare
Richard Barnes 348e70ef 2024-09-15T07:39:51 Suppress unused variable warning in dlmalloc.c (#843) Allows `-Wunused-but-set-variable` to pass
Yuriy Kolerov 30e887f8 2024-09-15T14:39:01 A series of fixes for ARC port (#844) * arc: Fix warnings These warnings are fixed: 1. A series of "unused variables". 2. Implicit conversion from a pointer to uint32_t. Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com> * arc: Do not use mov_s and movl_s instructions mov_s and movl_s instructions use a restricted set of registers. However, a list of available registers for such instructions for one ARC target may not match a list for another ARC targets. For example, it is applicable to ARC700 and ARC HS3x/4x - build fails because mov_s formats may be incompatible in some cases. The easiest and the most straightforward way to fix this issue is to use mov and movl instead of mov_s and movl_s. Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com> --------- Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
dependabot[bot] 377a1369 2024-09-15T07:38:22 Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows (#856) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Yury V. Zaytsev c7437f67 2024-09-15T13:37:28 configure: fix shared build on Solaris 10 (#846) GNU tools are often installed with g-prefix on Solaris. Unfortunately, a check in configure was using grep directly instead of through a variable, which lead to wrong results due to missing option `-q`. Additionally, the check will fail silently if `readelf` is not on `PATH` instead of trying `greadelf`.
Anthony Green 63b925fe 2024-09-15T07:32:50 feat(testsuite): add struct_int_float.c to Makefile.am
Anthony Green efb98a72 2024-09-15T07:31:33 Robustify floating point comparison in test
kellda d21881f5 2024-09-15T13:29:42 Fix x86/ffi64 calls with 6 gp and some sse registers (#848) * Fix x86/ffi64 calls with 6 gp and some sse registers * Add test demonstating issue when mixing gp and sse registers
Thomas Petazzoni 8a0d0292 2024-09-15T13:22:36 OpenRISC/or1k build fixes (#854) * src/or1k/ffi.c: fix prototype of ffi_call_SYSV() The current code base of libffi on OpenRISC (or1k) fails to build with GCC 14.x with the following error: ../src/or1k/ffi.c: In function 'ffi_call': ../src/or1k/ffi.c:167:34: error: passing argument 3 of 'ffi_call_SYSV' from incompatible pointer type [-Wincompatible-pointer-types] 167 | ffi_call_SYSV(size, &ecif, ffi_prep_args, rvalue, fn, cif->flags); | ^~~~~~~~~~~~~ | | | void * (*)(char *, extended_cif *) ../src/or1k/ffi.c:113:27: note: expected 'void * (*)(int *, extended_cif *)' but argument is of type 'void * (*)(char *, extended_cif *)' 113 | void *(*)(int *, extended_cif *), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is due to the fact that ffi_prep_args() is in fact defined as: void* ffi_prep_args(char *stack, extended_cif *ecif) so, let's fix the prototype of the function pointer, which anyway gets passed to assembly code, so the typing gets lost. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> * src/or1k/ffi.c: fix incompatible pointer type The current code base of libffi on OpenRISC (or1k) fails to build with GCC 14.x with the following error: ../src/or1k/ffi.c: In function 'ffi_closure_SYSV': ../src/or1k/ffi.c:183:22: error: initialization of 'char *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types] 183 | char *stack_args = sp; | ^~ Indeed: register int *sp __asm__ ("r17"); [..] char *stack_args = sp; Adopt the same logic used for: char *ptr = (char *) register_args; which consists in casting to the desired pointer type. Indeed, later in the code stack_args is assigned to ptr (so they need to be the same pointer type), and some arithmetic is done on ptr, so changing its pointer type would change the behavior. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> --------- Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Anthony Green 8e3ef965 2024-06-28T04:07:09 Fix struct args (Rainer Orth)
Martin Storsjö 9c9e8368 2024-06-04T14:13:08 aarch64: Add a missing no-op define of SIGN_LR_LINUX_ONLY (#838) This is needed at least if building for Linux, with a toolchain that doesn't default to having PAC enabled, fixing build errors since 45d284f2d066cc3a080c5be88e51b4d934349797.
Anthony Green 6993bc14 2024-06-01T13:42:29 Import from upstream
Florian 00bf6e67 2024-06-01T19:39:24 A fix to the struct type example (#837) Section 2.3.2 Structures of the docs declare `ffi_type`'s `elements` field to be of type `ffi_type **`.
Bill Roberts 45d284f2 2024-06-01T12:34:53 aarch64: support pointer authentication (#834) * aarch64: fix callstack in ffi_call_SYSV The debug stack gets corrupted between the frame and stack pivots, update the CFI directives so the call stack stays correct in the debugger. str x9, [x1, #32] // stack is ffi_call_SYSV() -> ffi_call_int() -> ffi_call_int() -> main() (good) mov x29, x1 // stack is ffi_call_SYSV() -> ffi_call_int() -> ffi_call_int() -> ffi_call() -> main() (bad) mov sp, x0 // stack is ffi_call_SYSV() -> ffi_call_int() -> ffi_call_int() -> main() (good) The CFA data needs to be updated around the pivots, after this patch the callstack stays correct. Signed-off-by: Bill Roberts <bill.roberts@arm.com> * aarch64: remove uneeded CFI directive This directive doesn't actually set the CFA to anything valid, and during unwinding this isn't even used. Note that the PAC/Darwin usage is quite suspect as well, as the CFA is either x1 or x29 after the frame pivot, and the CFA address is what's used as the modifier when verifying the PAC. At least this is the behavior on Linux with PAC, I need to verify ARME ABI unwinding. So for now leave Darwin as is. Signed-off-by: Bill Roberts <bill.roberts@arm.com> * ptrauth: rename define for clarity Rename the HAVE_PTRAUTH define for clarity that its associated with the ARM64E ABI and not the ARM64 ABI that can be supported on Linux and enabled with -mbranch-protection=standard. Signed-off-by: Bill Roberts <bill.roberts@arm.com> * aarch64: add PAC support to ffi_call_SYSV Support AARCH64 Pointer Authentication Codes (PAC) within ffi_call_SYSV and support exception unwinding. The Linux ABI for PAC is to use paciasp/autiasp instructions which also have hint space equivelent instructions. They sign the LR (x30) with the A key and the current stack pointer as the salt. Note that this can also be configured to use the B key and will use pacibsp/autibsp hint instructions. The Linux ABI for exception frame data when PAC is enabled assumes that the Connonical Frame Address, or CFA is equal to the stack pointer. I.E sp is equal to x29 (fp). When the unwinder is invoked the cfa will point to the frame which will include the *signed* return address from the LR. This will then be passed to __builtin_aarch64_autia1716 where the CFA will be used as the salt and stored to register x16 and register x17 will contain the signed address to demangle. This can be noted in: - https://github.com/gcc-mirror/gcc/blob/d6d7afcdbc04adb0ec42a44b2d7e05600945af42/libgcc/config/aarch64/aarch64-unwind.h#L56 The other required portion of this is to indicate to the unwinder that this is a signed address that needs to go the special demangle route in the unwinder. This is accomplished by using CFI directive "cfi_window_save" which marks that frame as being signed. Putting all of this together is a bit tricky, as the internals of ffi_call_SYSV the callee allocates its stack and frame and passes it in arg1 (x0) and arg2 (x1) to the called function, where that function pivots its stack, so care must be taken to get the sp == fp before paciasp is called and also restore that state before autiasp is called. Signed-off-by: Bill Roberts <bill.roberts@arm.com> --------- Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Bill Roberts 38732240 2024-06-01T12:33:28 ffi: fix spelling mistake (#833) Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Bill Roberts f64141ee 2024-03-19T11:44:55 Fix bti support (#830) * bti: add identifier to ffi_closure_SYSV_V_alt This was missing BTI_C identifier. Old Code: ffi_closure_SYSV_V_alt: 0000fffff7f70500: ldr x17, [sp, #8] Signed-off-by: Bill Roberts <bill.roberts@arm.com> * testsuite: fix whitespace in Makefile.am Signed-off-by: Bill Roberts <bill.roberts@arm.com> * aarch64: correct comment describing BTI The comment is incorrect, BTI is enabled per mapping via mprotect with PROT_BTI flag set, not per-process. When the loader loads the library, if the GNU Notes section is missing this, PROT_BTI will not be enabled for that mapping, but is independent of other mappings. Signed-off-by: Bill Roberts <bill.roberts@arm.com> --------- Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Anthony Green 3d0ce1e6 2024-02-18T09:22:51 chore: update version to 3.4.6 and fix long double regression on mips64 and alpha
Anthony Green 94eaedb4 2024-02-18T08:41:04 Update sparc64 host
Anthony Green e1dcf03b 2024-02-18T08:02:45 Update cfarm hostnames
Anthony Green cd78b539 2024-02-18T07:48:51 Always define long double types.
Anthony Green 012fcaf9 2024-02-15T08:35:02 Update
Anthony Green d1597239 2024-02-15T08:32:42 update copyright year in libffi.texi
Anthony Green 91739a1a 2024-02-15T08:30:09 Update version, copyright and testsuite info.
Anthony Green 9752a622 2024-02-15T08:03:21 Fix test filename reference
Anthony Green 40435531 2024-02-15T08:01:43 docs(README): update release details for libffi-3.4.5
Xi Ruoyao 04f6fa31 2024-02-15T20:52:13 mips: Fix N32 ABI return value handling (#813) In N32 ABI, 8-bit or 16-bit integers should be extended following the signedness of the integer, but 32-bit integers should always be sign-extended to 64-bit (note that N32 ABI only works on 64-bit CPUs). So handling this in everything using libffi would be nasty. And the libffi code for architectures with a similar rule (LoongArch & RISC-V) also properly handle this. Let's do this work in libffi for MIPS N32 too. This fixes two failures in Python 3.12.1 ctypes test.
杨屿杰 00c0c877 2024-02-15T20:51:40 Fix loongarch64 soft-float build (#816) (#817)
Hood Chatham b3091029 2024-02-15T04:51:12 Emscripten: Don't unbox single element structs if they are larger than 16 bytes (#818) This arguably is a compensation for a Python ctypes bug / strange behavior described here: https://github.com/python/cpython/blob/a16a9f978f42b8a09297c1efbf33877f6388c403/Modules/_ctypes/stgdict.c#L718-L779 If a struct is larger than 16 bytes, Python does not bother to accurately report its contents figuring that we don't need to know.
Bill Roberts 98881ecb 2024-02-15T06:50:40 aarch64: add BTI flag to ELF notes (#822) When a program is loaded and linked, the first ELF file that doesn't declare that BTI is supported in the GNU NOTES section disables BTI support. Example: readelf -n ./aarch64-unknown-linux-gnu/.libs/libffi.so Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: BTI Fixes: #823 Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Dan Horák f9da12e9 2024-02-15T13:50:13 don't skip ffi_type_longdouble symbols (#814) (#824) Seems there are configurations (ppc64 or ppc64le) that define HAVE_LONG_DOUBLE_VARIANT in fficonfig.h, but do not define HAVE_LONG_DOUBLE, and still want ffi_type_{,complex_}longdouble symbols. Update the condition in libffi.map.in accordingly.
Xi Ruoyao f8ed78f1 2024-02-15T20:49:27 LoongArch: Fix a build error with GCC 14 (#825) Fix the build error with GCC 14: ../src/loongarch64/ffi.c: In function 'ffi_prep_closure_loc': ../src/loongarch64/ffi.c:525:7: error: implicit declaration of function 'ffi_tramp_set_parms' [-Wimplicit-function-declaration]
bartoli 0b1dd62b 2024-02-01T04:54:57 Update README.md (#820) For cygwin/MSVC build, CXXCPP is also needed to pass configure checks
Anthony Green c07c40ee 2024-01-31T22:43:38 `feat(github-actions): add new build workflow for warp`
Chongyun Lee 622caabc 2023-12-24T23:38:32 Put more optional symbols behind ifdefs (#812)
Виктор Чернякин a1c391bd 2023-12-22T03:30:50 Fix a variety of warnings (#811)
Anthony Green 3a62a08a 2023-12-21T15:19:44 Remove warnings
Anthony Green d96fa211 2023-12-21T14:04:19 Eliminate warning
Martin Storsjö 5b1944b4 2023-11-29T00:38:13 aarch64: Write the BTI instructions as "hint" instructions (#810) GNU binutils refuses to assemble the direct BTI instructions unless the target architecture explicitly supports BTI, ending up with errors such as ../src/aarch64/sysv.S: Assembler messages: ../src/aarch64/sysv.S:87: Error: selected processor does not support `bti c' ../src/aarch64/sysv.S:156: Error: selected processor does not support `bti j' Building with -march=armv8.5-a fixes building this. However, the BTI instructions assemble into hint instructions, that are ignored by processors that don't implement them. Therefore it is possible to assemble them for the baseline armv8.0-a target as well, by replacing "bti j" with "hint #36", "bti c" with "hint #34" and "bti jc" with "hint #38"; this assembles into the same instruction bits.
Anthony Green 11af2196 2023-11-23T09:22:20 Reference recent changes
David Tenty d7f5e98b 2023-11-23T09:16:56 Fix visibility check for AIX (#804)
David Tenty 7f960d9a 2023-11-23T09:16:35 [powerpc][AIX] fix layout issues for nested struct types (#805) * [powerpc][AIX] fix layout issues for nested struct types On AIX under the default power alignment rules, the layout of struct types which are nested inside other structs may be different than the layout of those types on their own. Specifically the first member double rules which would apply an eight byte alignment if that type appears in the first position of a struct: 1) apply recursively if the struct appear in the first member of another struct 2) do not apply if that struct is itself a member of another struct and not the first member. The current implementation of the rules in libffi doesn't handle these cases, causing a mismatch with the compiler and causing some crashes we see when OpenJ9 is used with libffi on AIX. This PR corrects this and adds some representative test cases. * Fix code style * Add a size check * Add additional test * Fix padding in internal structs * Flip condition back to original form * Add a comment
Tobias Heider d93c0be8 2023-11-23T15:15:29 Add bti intructions to aarch64 assembly to work with strict (#808) BTI enforcement on OpenBSD.
Daily Price Depot Droid adbcf2b2 2023-10-21T09:58:28 Disable firefox testing
Daily Price Depot Droid 357755ee 2023-10-21T09:05:48 Try logging
Nobuyoshi Nakada c23e9a1c 2023-10-21T20:44:24 Check if FFI_GO_CLOSURES is defined (#796) This macro is always defined to 1 if defined, or undefined. With `-Wundef` option, checking the value without checking if it is defined causes warnings: ``` /opt/local/include/ffi.h:477:5: warning: 'FFI_GO_CLOSURES' is not defined, evaluates to 0 [-Wundef] #if FFI_GO_CLOSURES ^ ```
Yn0ga a4be0b72 2023-10-21T13:43:43 Add support for Haikuos on PowerPC (#799)
Petr Sumbera dd907495 2023-10-21T13:42:11 Fix passing floating point arguments on 64bits SPARC (libffi#778) (#802)
Alfred Wingate 44f6fa3e 2023-10-20T15:02:37 Put optional symbols behind ifdefs (#800) Signed-off-by: Alfred Wingate <parona@protonmail.com>
Michael Osipov 5c6e53db 2023-09-04T13:27:01 Fix build failures on HP-UX (#792) This fixes #328 Co-authored-by: Chris Hunt <chrahunt@gmail.com>
Russell Keith-Magee 1b3e7569 2023-09-04T19:26:11 Replace use of triple with target, and explicitly specify build host to force cross-compilation (#794)
Anthony Green 22b50e89 2023-08-31T16:31:42 Fix python and pyodide version
Anthony Green 4467a3bc 2023-08-31T08:48:50 Upgrade pyodide version to match newer selenium API
Ivan Tadeu Ferreira Antunes Filho 1d0a28ab 2023-08-12T09:02:39 Make label private on apple (#788) Private labels on apple must start with L prefix, while on ELF they start with .L prefix. This makes the label start with L on apple instead of .L.
Hood Chatham 9e8f1bd8 2023-06-20T21:17:04 Emscripten build: Remove -sSTRICT_JS (#781) This rasies errors on newer versions of the emscripten compiler.
Anthony Green ac598b7f 2023-04-03T08:20:32 Merge branch 'master' of github.com:/libffi/libffi
Anthony Green 2d63cee0 2023-04-03T08:18:23 Add tests with homogeneous aggregate types
Hood Chatham 8bdd4716 2023-04-02T19:54:22 More accurate explanation of wasm32 state in readme (#776) There are three main wasm32 target triples: * wasm32-unknown-unknown * wasm32-unknown-emscripten * wasm32-unknown-wasi The wasm32 port is only for the wasm32-unknown-emscripten target triple. (The other triples have no dynamic linking support so libffi would be both hard to port and of limited utility.)
Anthony Green f08493d2 2023-02-17T20:35:44 Mention ARCv3 work
Claudiu Zissulescu c4df19c9 2023-02-18T03:33:47 Update ARC's libffi port (#771) * Add support for ARC and ARC64 Add support for ARC/ARC32/ARC64 * Implementation of GO Closure for ARC/ARC32/ARC64 Architectures --------- Co-authored-by: Nuno Cardoso <cardoso@synopsys.com> Co-authored-by: Luis Silva <luiss@synopsys.com>
Anthony Green 23752064 2023-02-09T12:23:35 Normalize libffi labels
Anthony Green ca268015 2023-02-09T10:31:22 Use rlgl
Hood Chatham 7d23c2d2 2023-02-09T06:01:37 Add emscripten gha workflow (#768) Resolves issue #767
Anthony Green 883f5ae6 2023-02-05T09:51:37 Rename label
Hood Chatham 678dad5a 2023-02-02T14:48:07 Use libffi-dg-prune to handle Emscripten INFO messages rather than patching emcc.py (#766)
Anthony Green 7d03d3a3 2023-02-02T16:09:14 Mention wasm32
Anthony Green c267c72f 2023-02-02T16:04:34 Modernize
Hood Chatham 2687cfc5 2023-02-02T09:10:00 Add wasm32 emscripten support (#763) * added build script * Apply libffi-emscripten patch * Some changes to wasm32/ffi.c * Remove exit(0); from test suites * Fix LONGDOUBLE argument type * Use more macros in ffi.c * Use switch statements instead of if chains * Implemented struct args * Finish struct implementation * Partially working closures * Got closures working (most of closures test suite passes) * Revert changes to test suite * Update .gitignore * Apply code formatter * Use stackSave and stackRestore rather than directly adjusting stack pointer * Add missing break * Fix visibility of ffi_closure_alloc and ffi_closure_free * Fix FFI_TYPE_STRUCT and FFI_TYPE_LONGDOUBLE when WASM_BIGINT is not used sig needs to be vi here for FFI_TYPE_STRUCT and FFI_TYPE_LONGDOUBLE, noticed this while running the test suite without WASM_BIGINT support. * Always use dynCall rather than direct wasmTable lookup (function pointer cast emulation changes dynCall) * Prevent closures.c from duplicating symbols * Try to set up CI * Add test with bigint * Make test methods static * Remove BigInt shorthand because it messes up terser * Add selenium tests * Update tests a bit to try to make CI work * WASM_BIGINT is a linker flag not a compile flag * Finish getting CI working (#1) * update gitignore * Avoid adding "use strict;" to generated JS This should be controlled by -s STRICT_JS in Emscripten. * Make JavaScript ES5 compliant * Remove redundant EXPORTED_RUNTIME_METHODS settings * Fix definition of DEREF_I16 * Avoid marshalling FFI_TYPE_LONGDOUBLE when WASM_BIGINT is not used * Add missing FFI_TYPE_STRUCT signature * Improve test scripts * Remove redundant EXPORTED_RUNTIME_METHODS settings * Add missing EOL * Add struct unpacking tests * Update ci config to try to actually use WASM_BIGINT * Revert "Avoid marshalling FFI_TYPE_LONGDOUBLE when WASM_BIGINT is not used" This reverts commit 61bd5a3e20891623715604581b6e872ab3dfab80. * Fix single_entry_structs tests * Fix return from closure call * Fix 64 bit return from closures * only allocate as much space on stack for return pointer as needed * Revert "only allocate as much space on stack for return pointer as needed" This reverts commit e54a30faea3803e7ac33eed191bde9e573850fc1. * xfail two tests * Fix err_bad_abi test * Remove test logging junk * Try to set up long double marshalling for closures * xfail err_bad_abi * Fix reference errors in previous commit * Add missing argument pointer assignment * Fix signature of function pointer in cls_dbls_struct * Fix longdouble argument * Try some changes to bigint handling * Fix BigInt handling * Fix cls_longdouble test * Fix long double closure arg with no WASM_BIGINT * Use EM_JS to factor out js helpers * Support for varargs closure calls * Fix varargs calls * Fix err_bad_abi test * Fix typo in previous commit * Add more assertions to closures test suite * Fix some asserts * Add assertions to a few more tests * Fix some tests * Fix more floating point assertions * Update more tests * Var args for ffi_call * Don't do node tests * Macro for allocating on stack * Add some comments, simplify struct handling * Try again to fix varargs calls, add comments * Consolidate WASM_BIGINT conditionals into LOAD_U64 and STORE_U64 macros * A bit of cleanup * Fix another typo * Some fixes to the testsuite * Another testsuite fix * Fix varags with closures? * Another attempt at getting closure varargs to work * sig is initialized later * Allow libffi.closures tests to be run * Improve build script * Remove redundant semicolons * Fix a few libffi.closures test failures * Cleanup * Legacy dynCall API is no longer used * Fix FFI_TYPE_LONGDOUBLE offset * xfail 2 tests for WASM - closure_loc_fn0; not applicable -- codeloc doesn't point to closure. - huge_struct; function signature too long. * Revert some redundant dg-output/printf statements Helps Node. * Revert "Don't do node tests" This reverts commit a341ef4b. * Fix assertions in cls_24byte * More tiny formating fixes to test suite * Revert "Revert "Don't do node tests"" This reverts commit 7722e685ea04e2420e042886816d8c4dd31f5dcb. * Fix 64 bit returns when WASM_BIGINT is absent * Fix print statement in cls_24byte * Add CALL_FUNC_PTR macro to allow pyodide to define custom calling behavior to handle fpcast * Update single_entry_structs tests * More explanations * Fix compile error in last commit * Add more support for pyodide fpcast emulation, update CI to try to test it * Clone via https * Fix path to pyodide emsdk_env * Add asserts to the rest of the test suite * Fix test compile errors * Fix some tests * Fix cls_ulonglong * Fix alignment of <4 byte args * fix cls_ulonglong again * Use snprintf instead of sprintf * Should assert than strncmp returned 0 * Fix va_struct1 and va_struct3 * Change double and long double tests These tests are failing because of a strange bug with prinft and doubles, but I am not convinced it necessarily has anything to do with libffi. This version casts the double to int before printing it and avoids the issue * Enable node tests * Revert "Change double and long double tests" This reverts commit 8f3ff89c6577dc99564181cd9974f2f1ba21f1e9. * Fix PYODIDE_FPCAST flag * add conftest.py back in * Fix emcc error: setting `EXPORTED_FUNCTIONS` expects `<class 'list'>` but got `<class 'str'>` See discussion on https://github.com/pyodide/pyodide/pull/1596 * Remove test.html * Remove duplicate test file * More changes from upstream * Fix some whitespace * Add some basic debug logging statements * Reapply libffi.exp changes * Don't build docs (#7) Works around build issue makeinfo: command not found. * Update long double alignment Emscripten 2.0.26 reduces the aligmnet of long double to 8. Quoting from `ChangeLog.md`: > The alignment of `long double`, which is a 128-bit floating-point > value implemented in software, is reduced from 16 to 8. The lower > alignment allows `max_align_t` to properly match the alignment we > use for malloc, which is 8 (raising malloc's alignment to achieve > correctness the other way would come with a performance regression). > (#10072) * Update long double alignment Emscripten 2.0.26 reduces the aligmnet of long double to 8. Quoting from `ChangeLog.md`: > The alignment of `long double`, which is a 128-bit floating-point > value implemented in software, is reduced from 16 to 8. The lower > alignment allows `max_align_t` to properly match the alignment we > use for malloc, which is 8 (raising malloc's alignment to achieve > correctness the other way would come with a performance regression). > (#10072) * Improve error handling a bit (#8) * Fix handling of signed arguments to ffi_call (#11) * Fix struct argument handling in ffi_call (#10) * Remove fpcast emulation tests * Align the stack to MAX_ALIGN before making call (#12) * Increase MAX_ARGS * Cleanup (#14) * Fix Closure compiler error with -sASSERTIONS=1 (#15) * Remove function pointer cast emulation (#13) This reverts commit 593b402 and cbc54da, as it's no longer needed after PR pyodide/pyodide#2019. * Prefer the `__EMSCRIPTEN__` definition over `EMSCRIPTEN` (#18) "The preprocessor define EMSCRIPTEN is deprecated. Don't pass it to code in strict mode. Code should use the define __EMSCRIPTEN__ instead." https://github.com/emscripten-core/emscripten/blob/84a634167a1cd9e8c47d37a559688153a4ceace6/emcc.py#L887-L890 * Install autoconf 2.71 * Try again with installing autoconf 2.71 * Fix compatibility with Emscripten 3.1.28 * CI: remove use of `EM_CONFIG` env See commit: https://github.com/emscripten-core/emsdk/commit/3d87d5ea8143b3636f872fb05b896eb4a19a070b * Fix cls_multi_schar: cast rest_call to signed char * Remove test xfails (#17) * Fix long double when used as a varargs argument * Enable unwindtest and fix it * Add EM_JS_DEPS * Also require convertJsFunctionToWasm * Run tests very very verbose * Echo the .emscripten file * Remove --experimental-wasm-bigint insertion * Build with assertions * Move verbosity flags back out of LDFLAGS * Remove debug print statement * Use up to date pyodide docker image * Explicitly cast res_call to fix test failure * Put back name of main function in cls_longdouble_va.c * Fix alignment The stack pointer apparently needs to be aligned to 16. There were some terrible subtle bugs caused by not respecting this. stackAlloc knows that the stack should be 16 aligned, so we can use stackAlloc(0) to enforce this. This way if alignment requirements change, as long as Emscripten updates stackAlloc to continue to enforce them we should be okay. * Fix handling of systems with no Js bigint integration When we run the node tests we use node v14 tests (since node v14 is vendored with Emscripten). Node v14 has no Js bigint integration unless the --experimental-wasm-bigint flag is passed. So only the node tests really notice if we get this right. Turns out, it didn't work. We can't call a JavaScript function with 64 bit integer arguments without bigint integration. In ffi_call, we are trying to call a wasm function that takes 64 bit integer arguments. dynCall is designed to do this. We need to go back to tracking the signature when we don't have WASM_BIGINT, and then use dynCall. This works better now that emscripten can dynamically fill in extra dynCall wrappers: https://github.com/emscripten-core/emscripten/pull/17328 On the other hand, for the closures we are not getting a function pointer as a first argument. We need to make our own wasm legalizer adaptor that splits 64 bit integer arguments and then calls the JavaScript trampoline, then the JavaScript trampoline reassembles them, calls the closure, then splits the result (if it's a 64 bit integer) and the adaptor puts it back together. * Improvements to emscripten test shell scripts (#21) This fixes the C++ unwinding tests and makes other minor improvements to the Emscripten test shell scripts. * Rename the test folder and move test files into emscripten test folder * Use docker image that has autoconf-2.71 * Cleanup * Pin emscripten 3.1.30 * Fix build.sh path * Rearrange ci pipeline * Fix bpo_38748 test * Cleanup * Improvements to comments, add static asserts, and update copyright * Use `*_js` instead of `*_helper` for EM_JS functions (#22) * Minor code simplification * Xfail first dejagnu test to work around emscripten cache messages See https://github.com/emscripten-core/emscripten/issues/18607 * Remove unneeded xfails * Shorten conftest.py by using pytest-pyodide * Apply formatters and linters to emscripten directory * Fix Emscripten xfail hack * Fix build-tests script * Patch emscripten to quiet info messages * Clean up compiler flags in scripts and remove some settings from circleci config * Rename emscripten quiet script * Add missing export * Don't remove go.exp * Add reference to emscripten logging issue --------- Co-authored-by: Kleis Auke Wolthuizen <info@kleisauke.nl> Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl> Co-authored-by: Christian Heimes <christian@python.org>
serge-sans-paille ce077e55 2023-02-02T14:46:29 Forward declare open_temp_exec_file (#764) It's defined in closures.c and used in tramp.c. Also declare it as an hidden symbol, as it should be. Co-authored-by: serge-sans-paille <sguelton@mozilla.com>
Anthony Green abf211d1 2023-02-02T07:06:02 Mention HPPA fixes
Anthony Green 222abd0c 2023-02-02T07:04:55 From Dave Anglin: This patch is derived from the work done in implementing libffi for 64-bit hppa64-hpux target. Currently, the 32-bit hppa targets do a linear search for the return type of an ffi_call. This is slow and inefficient. A jump table can used to jump directly to the code used to process the return value. In most common cases, the return value can be processed in the jump table itself. The patch also fixes return handling for FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16 and FFI_TYPE_SINT16.
Anthony Green e58e22b2 2023-02-02T07:02:53 From Dave Anglin: A couple of years ago the 32-bit hppa targets were converted from using a trampoline executed on the stack to the function descriptor technique used by ia64. This is more efficient and avoids having to have an executable stack. However, function pointers on 32-bit need the PLABEL bit set in the pointer. It distinguishes between pointers that point directly to the executable code and pointer that point to a function descriptor. We need the later for libffi. But as a result, it is not possible to convert using casts data pointers to function pointers. The solution at the time was to set the PLABEL bit in hppa closure pointers using FFI_CLOSURE_PTR. However, I realized recently that this was a bad choice. Packages like python-cffi allocate their own closure pointers, so this isn't going to work well there. A better solution is to leave closure pointers unchanged and only set the PLABEL bit in pointers used to point to executable code. The attached patch drops the FFI_CLOSURE_PTR and FFI_RESTORE_PTR defines. This allows some cleanup in the hppa closure routines. The FFI_FN define is now used to set the PLABEL bit on hppa. ffi_closure_alloc is modified to set the PLABEL bit in the value set in *code. I also added a FFI_CL define to convert a function pointer to a closure pointer. It is only used in one test case.
Anthony Green baa6bbbc 2023-02-02T06:59:46 Add HPPA64 support
Iain Sandoe e70dd1aa 2023-02-02T11:44:13 libffi: Fix X86 32b Darwin build and EH frames. (#757) This addresses a number of issues in the X86 Darwin 32b port for libffi. 1. The pic symbol stubs are weak definitions; the correct section placement for these depends on the linker version in use. We do not have access to that information, but we can use the target OS version (assumes that the user has installed the latest version of xcode available). When a coalesced section is in use (OS versions earlier than Darwin12 / OSX 10.8), its name must differ from __TEXT,__text since otherwise that would correspond to altering the attributes of the .text section (which produces a diagnostic from the assembler). Here we use __TEXT, __textcoal_nt for this which is what GCC emits for these stubs. For later versions than Darwin 12 (OS X 10.8) we can place the stubs in the .text section (if we do not we get a diagnostic from clang -cc1as saying that the use of coalesced sections for this is deprecated). 2. The EH frame is specified manually, since there is no support for .cfi_ directives in 'cctools' assemblers. The implementation needs to provide offsets for CFA advance, code size and to the CIE as signed values rather than relocations. However the cctools assembler will produce a relocation for expressions like ' .long Lxx-Lyy' which then leads to a link-time error. We correct this by forming the offset values using ' .set' directives and then assigning the results of them. 3. The register numbering used by m32 X86 Darwin EH frames is not the same as the DWARF debug numbering (the Frame and Stack pointer numbers are swapped). 4. The FDE address encoding used by the system tools is '0x10' (PCrel + abs) where the value provided was PCrel + sdata4. 5. GCC does not use compact unwind at present, and it was not implemented until Darwin10 / OSX 10.6. There were some issues with function location in 10.6 so that the solution here suppresses emitting the compact unwind section until Darwin11 / OSX 10.7.
Iain Sandoe 7effe999 2023-02-02T11:42:46 Darwin: Search for both shared and convenience libraries in each path. (#761) For several Darwin linker versions, the default behaviour is to first traverse the set of library paths, looking for shared libraries, and then a second time looking for archives. This means that if the library is configured --disable-shared the installed system version /usr/lib/libffi.dylib will be found before the archive under test. Using the linker option '-search-paths-first' alters the strategy to search each path for dylib and then archive before moving on to the next.
serge-sans-paille ebbc5e14 2023-02-02T11:40:17 Fix signed vs unsigned comparison (#765) As reported by -Wsign-compare. In the case of getting the result of comparing the result of sysconf (_SC_PAGESIZE) to other value, this also correctly handles edge cases where the above fails and returns -1. Co-authored-by: serge-sans-paille <sguelton@mozilla.com>
Anthony Green 7611bb4c 2023-01-08T09:01:00 Use checkout@v3, with nodejs 16
YongKang Zhou 3a8bb6bb 2023-01-08T21:56:34 fix typo (#758) `mingW` -> `MinGW`
Alexander Kanavin 00116b6d 2022-12-05T03:20:09 arm/sysv: reverted clang VFP mitigation (#747) Since commit e3d2812ce43940aacae5bab2d0e965278cb1e7ea, seperate instructions were used when compiling under clang, as clang didn't allow the directives at the time. This mitigation now causes compilation to fail under clang 10, as described by https://github.com/libffi/libffi/issues/607. Now that clang supports the LDC and SDC instructions, this mitigation has been reverted. Co-authored-by: Brett Warren <brett.warren@arm.com>
Anthony Green c50c16d0 2022-11-20T12:20:40 Fix large struct passing on PA-RISC