src


Log

Author Commit Date CI Message
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
Sergei Trofimovich fadf1eb5 2019-04-27T20:53:29 hppa: avoid TEXTREL in .eh_frame section (#447) Before the change hand-crafted .eh_frame section contained ABS relocation and caused TEXTREL tag to be emitted: ``` $ ./configure --host=hppa2.0-unknown-linux-gnu LDFLAGS=-Wl,-z,text $ make ... /usr/libexec/gcc/hppa2.0-unknown-linux-gnu/ld: read-only segment has dynamic relocations. ``` Link failure is caused by absolute address of FDEs encoded into .eh_frame entries. Fixed TEXTREL by using pcrel (instead of ABS) encoding for absolute addresses (__PIC__ code) by adding augmentation information ("zR" CIE type). All tests still pass on hppa2.0. The specific tests that still pass and exercise this code path: testsuite/libffi.call/unwindtest.cc testsuite/libffi.call/unwindtest_ffi_call.cc Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
driver1998 06bf1a9d 2019-04-28T03:21:44 fix x86/x64 MSVC build (#487)
Paul Monson db5706ff 2019-04-26T04:58:58 add support for 32-bit ARM on Windows (#477) * add support for 32-bit ARM on Windows * fix mismatched brace in appveyor.yml * remove arm platform from appveyor.yml for now * fix arm build * fix typo * fix assembler names * try Visual Studio 2017 * add windows arm32 to .appveyor.yml * update README.md
Dan Horák a7d6396f 2019-03-29T14:19:20 fix check for Linux/aarch64 fixes #473
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)
Florian Weimer 44a6c285 2019-02-19T12:55:11 aarch64: Flush code mapping in addition to data mapping (#471) This needs a new function, ffi_data_to_code_pointer, to translate from data pointers to code pointers. Fixes issue #470.
Martin Bektchiev 4a84df4a 2018-10-31T15:53:54 Fix Q registers parameter passing on ARM64 The second two quads are located at offset 32 not 16
Tom Tromey a5ea7527 2018-09-19T07:29:36 Merge pull request #443 from jeremyhu/master Update FFI_HIDDEN() to use .private_extern on Apple platforms and use the macro where appropriate
Gregory Pakosz e6eac786 2018-09-18T15:19:53 Prefix ALIGN_DOWN macro with FFI_
Andreas Schwab 4cb776bc 2018-08-09T12:12:29 RISC-V go closures This implements go closures for RISC-V. It has been tested on riscv64-suse-linux and against the libgo testsuite.
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.
Alan Modra ebf24166 2018-05-02T13:55:29 PowerPC64 ELFv1 fp arg fixes The ELFv1 ABI says: "Single precision floating point values are mapped to the second word in a single doubleword" and also "Floating point registers f1 through f13 are used consecutively to pass up to 13 floating point values, one member aggregates passed by value containing a floating point value, and to pass complex floating point values". libffi wasn't expecting float args in the second word, and wasn't passing one member aggregates in fp registers. This patch fixes those problems, making use of the existing ELFv2 homogeneous aggregate support since a one element fp struct is a special case of an homogeneous aggregate. I've also set a flag when returning pointers that might be used one day. This is just a tidy since the ppc64 assembly support code currently doesn't test FLAG_RETURNS_64BITS for integer types.. * src/powerpc/ffi_linux64.c (discover_homogeneous_aggregate): Compile for ELFv1 too, handling single element aggregates. (ffi_prep_cif_linux64_core): Call discover_homogeneous_aggregate for ELFv1. Set FLAG_RETURNS_64BITS for FFI_TYPE_POINTER return. (ffi_prep_args64): Call discover_homogeneous_aggregate for ELFv1, and handle single element structs containing float or double as if the element wasn't wrapped in a struct. Store floats in second word of doubleword slot when big-endian. (ffi_closure_helper_LINUX64): Similarly.
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.
Lucas Pluvinage 7d3cab79 2018-04-21T00:24:50 xtensa-linux: use cache flush instruction only if it is available (#426)
James Cowgill 159b94e5 2018-04-19T01:28:23 Various MIPS Fixes (#425) * mips: simplify closure #defines This commit should have no visible effect. * mips: add special handling of variadic functions MIPS requires special handling of variadic functions which pass floating point arguments: * In the o32 ABI, all float arguments are passed in integer registers. * In the n32/n64 ABIs, float arguments after the ellipsis are passed in integer registers. Implement this in libffi. To support this in n32/n64 closures, we need to add a new mips_nfixedargs field to ffi_cif which will break the libffi ABI. This fixes the libffi.call/cls_longdouble_va.c test which was failing on 64-bit MIPS. * mips: align argn for all 64-bit types in o32 closure handler Ensure that argn is pre-aligned for all 64-bit argument types (including doubles) and not just integer types. This fixes closures of the form "f(float, double, <some integer args>)". Previously the first integer argument would be read from a2 which is garbage at this point (the float arguments have already "consumed" a0-a3). After this commit, argn is correctly padded between the "float" and "double" arguments so that the first integer argument is read from the stack. Fixes "double f(float,double,int)" test in #371 * mips: do not read from floating point register if returning a struct In the o32 ABI, the pointer passed in a0 used to return structures indirectly is treated as the first argument for argument allocation purposes. This means that it should inhibit floating point registers the same way that other integer arguments do. Fixes "Double f(float,Double,double)" test in #371 * mips: fix pointer cast warnings Fix two pointer cast warnings when compiled on 64-bit mips by casting through uintptr_t. Fixes mips64el part of #404
Anthony Green e27f70b8 2018-04-08T18:25:34 Fix case where callback arg value is split across regs and stack
fwg af6773d6 2018-04-02T13:55:31 Fix appveyor windows build (#420) * Fix msvcc dll build by adding dllexport decorations to all API declarations * Fix appveyor build for VS 2013 Use the new -DFFI_BUILDING_DLL for producing a working DLL. Update the msvcc.sh wrapper script to successfully compile the testsuite files. * MSVC build: suppress warnings in testsuite * fix testsuite on appveyor
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
Ryan C. Underwood d4640608 2018-03-18T07:00:42 Fully allocate file backing writable maps (#389) When ftruncate() is used on a filesystem supporting sparse files, space in the file is not actually allocated. Then, when the file is mmap'd and libffi writes to the mapping, SIGBUS is thrown to the calling application. Instead, always fully allocate the file that will back writable maps.
Anthony Green 6a801d04 2018-03-16T17:53:33 Fix closure case where 8-byte value is partially passed in register. Fixes cls_many_mixed_float_double test case.
Anthony Green 01db31d9 2018-03-13T20:41:55 Update moxie sub opcode
Stef O'Rear 3840d49a 2018-03-11T05:55:15 New RISC-V port (#281) * Add RISC-V support This patch adds support for the RISC-V architecture (https://riscv.org). This patch has been tested using QEMU user-mode emulation and GCC 7.2.0 in the following configurations: * -march=rv32imac -mabi=ilp32 * -march=rv32g -mabi=ilp32d * -march=rv64imac -mabi=lp64 * -march=rv64g -mabi=lp64d The ABI currently can be found at https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md . * Add RISC-V to README * RISC-V: fix configure.host
Anthony Green dca52b55 2018-03-11T08:50:01 Merge pull request #406 from trofi/master ia64: fix variadic function closures with FP arguments
Anthony Green 83d9aba3 2018-03-11T08:48:42 Merge pull request #407 from trofi/ia64-small-struct ia64: fix small struct return
Andreas Schwab e66fd678 2018-02-20T10:47:09 Revert "Fix passing struct by value on aarch64" This reverts commit 482b37f00467325e3389bab322525099860dd9aa. That was actually a bug in python, see <https://bugs.python.org/issue30353>.
Sergei Trofimovich b58caef7 2018-02-17T19:00:40 ia64: fix small struct return This change fixes libffi.call/struct10.c failure on ia64: FAIL: libffi.call/struct10.c -W -Wall -Wno-psabi -O0 execution test .Lst_small_struct handles returns for structs less than 32 bytes (following ia64 return value ABI [1]). Subroutine does roughly the following: ``` mov [sp+0] = r8 mov [sp+8] = r9 mov [sp+16] = r10 mov [sp+24] = r11 memcpy(destination, source=sp, 12); ``` The problem: ia64 ABI guarantees that top 16 bytes of stack are scratch space for callee function. Thus it can clobber it. [1] says (7.1 Procedure Frames): """ * Scratch area. This 16-byte region is provided as scratch storage for procedures that are called by the current procedure. Leaf procedures do not need to allocate this region. A procedure may use the 16 bytes at the top of its own frame as scratch memory, but the contents of this area are not preserved by a procedure call. """ In our case 16 top bytes are clobbered by a PLT resolver when memcpy() is called for the first time. As a result memcpy implementation reads already clobbered data frop top of stack. The fix is simple: allocate 16 bytes of scrats space prior to memcpy() call. [1]: https://www.intel.com/content/dam/www/public/us/en/documents/guides/itanium-software-runtime-architecture-guide.pdf Bug: https://bugs.gentoo.org/634190 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Sergei Trofimovich 11de69dd 2018-02-11T11:29:39 ia64: fix variadic function closures with FP arguments libffi test framework already flagged failures as: ``` FAIL: libffi.call/cls_double_va.c -W -Wall -Wno-psabi -O0 output pattern test, is 7.0 res: 4 0.0 res: 4 ? should match 7.0 ?es: 4 ?.0 res: 4 ``` Failure happens here at ```c // testsuite/libffi.call/cls_double_va.c ... char* format = "%.1f\n"; double doubleArg = 7; ... CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK); res = ((int(*)(char*, ...))(code))(format, doubleArg); ``` libffi expects 'doubleArg' to be located in 'f9' (second FP argument) but gcc placed it to 'r33' (second GR). ia64 software [1] manual described argument passing ABI in "8.5.2 Register Parameters" as: """ If an actual parameter is known to correspond to a floating-point formal parameter, the following rules apply: a) The actual parameter is passed in the next available floating-point parameter register, if one is available. Floating-point parameter registers are allocated as needed from the range f8-f15, starting with f8. b) If all available floating-point parameter registers have been used, the actual parameter is passed in the appropriate general register(s). (This case can occur only as a result of homogeneous floating-point aggregates, described below.) If a floating-point actual parameter is known to correspond to a variable-argument specification in the formal parameter list, the following rule applies: c) The actual parameter is passed in the appropriate general register(s). If the compiler cannot determine, at the point of call, whether the corresponding formal parameter is a varargs parameter, it must generate code that satisfies both of the above conditions. (The compiler’s determination may be based on prototype declarations, language standard assumptions, analysis, or other user options or information.) """ We have [c] case here and gcc uses only GR for parameter passing. The change binds known variadic arguments ro GRs instead of FPs as those are always expected to be initialized for all variadic call types. This fixes all 10 failures on ia64-unknown-linux-gnu: ``` === libffi Summary === -# of expected passes 1945 -# of unexpected failures 10 + +# of expected passes 1955 ``` [1]: https://www.intel.com/content/dam/www/public/us/en/documents/guides/itanium-software-runtime-architecture-guide.pdf Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Anthony Green 9429968b 2018-02-10T23:23:33 Merge pull request #403 from frida/fix/x86-sysv-pic-closure-regression Fix x86 SysV closure in PIC mode
Andreas Schwab 482b37f0 2017-09-18T12:44:08 Fix passing struct by value on aarch64 This fixes the ctypes test in the python testsuite.
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.
Anthony Green bec6135d 2018-01-10T07:20:04 Merge pull request #393 from thejunkjon/master Linker error "recompile with -fPIC" for x86_64
YunQiang Su 746dbe3a 2018-01-03T10:07:41 mips/ffi.c: fix encoding for jr on r6 mips/ffi.c: instruction jr has a different encoding for r6
YunQiang Su 94c102aa 2017-12-10T14:25:01 Not set mips on mips r6 MIPS release changed encodes of some instructions, include ll/sc etc. if .set mips4 on mips r6, as will generate some wrong encode of some instructions.
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 4fdbb057 2017-11-03T07:05:31 Merge pull request #320 from 0-wiz-0/master Support NetBSD with mprotect.
Anthony Green b302bc3d 2017-11-03T07:03:55 Merge pull request #322 from compnerd/aarch64-base aarch64: fix index base register for AArch64
Yen Chi Hsuan 9fc9dc53 2017-10-27T16:12:56 Fix linux detection (closes #303)
Saleem Abdulrasool 1fb788ac 2017-10-10T11:37:00 aarch64: fix index base register for AArch64 The base is passed in `x3`, not in `x2`. This fixes the indexing base so that the right value is used.
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
Anthony Green a0455c03 2017-10-25T13:04:23 Merge pull request #383 from hjl-tools/hjl/master Hjl/master
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.
Saleem Abdulrasool 3c372c38 2017-10-24T13:53:56 arm: fix a level of indirection issue Rather than relying on the stack being 0'ed out always, do it manually. The stack generally happened to be zero, and because the compiler realizes that the tests are dealing with chars truncates the read value. However, the top 3 nibbles of the value are undefined and may be non-zero. The indirection level caused a null-pointer dereference. Explicitly scribbling on the stack during the allocation causes test failures without the original zexting behaviour.
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.
Sergei Trofimovich ed7488c0 2017-10-17T13:00:51 src/ia64/unix.S: unbreak small struct handling commit 6e8a4460833594d5af1b4539178025da0077df19 added FFI_TYPE_COMPLEX value type (comes after FFI_TYPE_POINTER) ia64 ffi_closure_unix reiles on the ordering of FFI_ enums as ia64 has ia64-specific FFI types: small struct and FPU extesions. As a result all tests handling small structs broke. The change fixes dispatch table by adding (no-op) FFI_TYPE_COMPLEX entry This has positive effect of unbreaking most tests on ia64: === libffi Summary === -# of expected passes 1595 -# of unexpected failures 295 +# of expected passes 1930 +# of unexpected failures 10 # of unsupported tests 30 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Saleem Abdulrasool 7ad0ae7f 2017-10-10T11:44:05 arm: zext return value parameters The closure function (invoked as closure->fun in ffi_closure_XXX_inner) will only populate the actual number of bytes for the true return type, which may be a character. This leaves garbage on the stack when the assembly closure function (i.e. ffi_closure_XXX) reads the return value off of the stack into r0 as a 4-byte value. ffi_closure_XXX always leaves room for at least 4 bytes here, so we can safely set them to 0. Otherwise, if there is garbage in any of these bytes, these end up in r0 and in the returned value as well.
Joerg Sonnenberger 2bfcd299 2017-10-02T15:34:03 Support NetBSD with mprotect. Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Anthony Green 93d8e7dd 2017-09-27T21:51:34 Fix #265
Anthony Green 02a5145a 2017-09-27T21:43:03 Merge pull request #263 from ksjogo/master fix ios builds
Anthony Green 10099d6c 2017-09-27T20:54:09 Merge pull request #271 from frida/fix/qnx-cache-flushing arm: Fix cache flushing on QNX
Anthony Green db4dad97 2017-09-27T20:47:08 Merge pull request #312 from fjricci/fix_ub Fix misaligned memory access in ffi_call_int
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
Tony Reix 0ff9419f 2017-05-17T14:57:53 This patch enables FFI Go Closure on AIX.
Gregory Pakosz bd72848c 2017-04-27T13:20:36 Prefix ALIGN macros with FFI_
Ole André Vadla Ravnås 57d8ff04 2017-03-15T01:43:11 Simplify iOS trampoline table allocation By using VM_FLAGS_OVERWRITE there is no need for speculatively allocating on a page we just deallocated. This approach eliminates the race-condition and gets rid of the retry logic.
Johannes Goslar 00406945 2016-07-12T16:08:42 Update Xcodeproj Include all currently relevent files. Call autogen is build script. Fix compiler settings. Fix mach include.