summaryrefslogtreecommitdiff
path: root/configure.ac
Commit message (Collapse)AuthorAgeFilesLines
* Revert to previous cfi check.Anthony Green2022-09-281-14/+1
|
* Update version to 3.4.4-experimentalAnthony Green2022-09-191-1/+1
|
* Suppress error console output duing configure in case not an ELF file (#729)Hans2022-09-191-1/+1
| | | | | | | | | | | On Cygwin, MSYS and MinGW readelf is available, but files generated are no ELF files. This results in an Error output on console: 'checking whether .eh_frame section should be read-only... readelf: Error: Not an ELF file - it has the wrong magic bytes at the start yes' With this patch the error output is suppressed resulting in only 'checking whether .eh_frame section should be read-only... yes' Setting of related variables is not changed. Co-authored-by: Hannes Müller <>
* Update version to 3.4.3Anthony Green2022-09-191-1/+1
|
* Add MSYS configuration files (#728)Hans2022-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * 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 <>
* Add static trampoline support for CygwinAnthony Green2022-09-121-0/+6
|
* Remove bogus sparc compiler flagAnthony Green2022-09-071-3/+0
|
* Fix typoAnthony Green2022-09-071-0/+3
|
* dlmmap fix and always check for PaX MPROTECT on linuxAnthony Green2022-09-061-3/+8
| | | | | | Also make EMUTRAMP experimental From Stefan Bühler https://github.com/libffi/libffi/pull/282
* GCC_AS_CFI_PSEUDO_OP passes on msvc, although it's not sufficient.Anthony Green2022-09-011-2/+0
|
* Makefile: enable target overridings. (#661)Clément Chigot2022-09-011-0/+10
| | | | | | | | | | 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>
* Don't use cached configure test resultAnthony Green2022-09-011-4/+4
|
* Fix .cfi pseudo-ops test.Anthony Green2022-09-011-2/+17
| | | | | | | | The existing tests were failing because the GCC was wrapping the test asm in cfi directives, which gas doesn't like. So now we test if the compiler emits them first, and assume that the assembler will accept them. If that doesn't work, then we test if the assembler will accept them assuming the compiler doesn't emit them.
* static trampoline for LoongArch (#723)Xi Ruoyao2022-07-211-1/+1
| | | | | | | 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.
* Update configuryAnthony Green2022-06-251-17/+18
|
* configure.ac: use grep -E instead of egrep if possible (#720)Xi Ruoyao2022-06-251-1/+2
| | | | | | | | Upstream will start to emit a warning if egrep is invoked in the next grep release. Stop invoking it explicitly. Use AC_PROG_EGREP to try "grep -E" first, and fallback to egrep if "grep -E" does not work. We need this fallback for some non-GNU grep implementations (like Solaris). Url: https://git.savannah.gnu.org/cgit/grep.git/commit/?id=a951562
* Update version to 3.4.2v3.4.2Anthony Green2021-06-281-1/+1
|
* Version 3.4.1Anthony Green2021-06-281-1/+1
|
* Update version to 3.4.0v3.4.1v3.4.0Anthony Green2021-06-281-1/+1
|
* 3.4.0 release candidate 2v3.4.0-rc2Anthony Green2021-06-281-1/+1
|
* configure.ac: add --disable-exec-static-tramp flag (#647)Sergei Trofimovich2021-06-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some projects like GHC (Glasgow Haskell Compiler) and gobject-introspection use `ffi_closure_alloc()` as a way to allocate executable memory. exec static tramp interferes with it (unclear how exactly yet). GHC symptom: ffi closure freeing cimplains about unexpected trampoline (GHC manually fills one): ``` $ ghci GHCi, version 8.10.5: https://www.haskell.org/ghc/ :? for help ghc: freeHaskellFunctionPtr: not for me, guv! 0x7f0417a1efe8 ghc: freeHaskellFunctionPtr: not for me, guv! 0x7f0417a1efc8 ``` gobject-introspection symptom: ``` $ meld Segmentation fault (core dumped) $ gdb --args /usr/bin/python3.9 /usr/bin/meld (gdb) run ... Thread 1 "python3.9" received signal SIGSEGV, Segmentation fault. 0x00007fffe9ac1ae8 in g_callable_info_free_closure ( callable_info=0x555555d45990, closure=0x7fffe9e70c20) at ../gobject-introspection-1.68.0/girepository/girffi.c:428 428 g_free (wrapper->ffi_closure.cif->arg_types); (gdb) bt callable_info=0x555555d45990, closure=0x7fffe9e70c20) at ../gobject-introspection-1.68.0/girepository/girffi.c:428 data=0x555555d252d0) at ../pygobject-3.40.1/gi/pygi-closure.c:635 ... ``` To ease downstreams narrowing down the actual problem let's provide a knob to disable exec static trampolines. The change for not affect current default. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* configure.ac: allow user to specify READELF (#646)Sergei Trofimovich2021-06-261-1/+3
| | | | | | | | | | | | | | | | | | Before the change with x86_64-pc-linux-gnu cross-compiler installed the configure was not able to find cross-readelf: ``` $ ./configure --host=x86_64-pc-linux-gnu ... checking whether .eh_frame section should be read-only... .././configure: line 19540: readelf: command not found yes ... ``` The change uses AC_CHECK_TOOL to automatically seatch for ${host}-readelf, readelf. And as a bonus it also allows user to override readelf with something like READELF=llvm-readelf. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Make 3.4 release candidate 1v3.4-rc1Anthony Green2021-06-261-1/+1
|
* testsuite: fix compiler vendor detection on dash as /bin/sh (#594)Sergei Trofimovich2021-03-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | In https://bugs.gentoo.org/753299 Paolo Pedroni reported a single test failure out of all libffi. Here is the minimal reproducer: ``` $ ./autogen $ CONFIG_SHELL=/bin/dash ./configure --host=x86_64-pc-linux-gnu $ make check RUNTESTFLAGS='complex.exp' ... FAIL: libffi.complex/cls_align_complex_float.c (test for excess errors) ``` This happens because under 'dash' shell autoconf generates slightly different style of string quotation in `config.log`: - on bash: `ax_cv_c_compiler_vendor=gnu` - on dash: `ax_cv_c_compiler_vendor='gnu'` To avoid shell quotation parsing the change just embeds `compiler_vendor` into `local.exp` at configure time. Reported-by: Paolo Pedroni Bug: https://bugs.gentoo.org/753299 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Static tramp v5 (#624)Madhavan T. Venkataraman2021-03-051-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Use memfd_create() (#604)DJ Delorie2020-12-021-0/+3
| | | | | memfd_create creates a file in a memory-only filesystem that may bypass strict security protocols in filesystem-based temporary files.
* Fix read-only .eh_frame section test when CFLAGS contains -flto. (#590)jacobly02020-10-271-1/+3
|
* Improve read-write .eh_frame check (#546)Fangrui Song2020-03-101-9/+3
| | | | | | | llvm-objdump -h does not print BFD SEC_* constants like "READONLY", so the check will consider .eh_frame writable. clang 11 (since https://reviews.llvm.org/D73999) will error for mismatching section flags. Use readelf -S and check "WA" instead.
* Port to iOS/arm64e (#548)Ole André Vadla Ravnås2020-03-091-0/+22
|
* Version 3.3Anthony Green2019-11-231-1/+1
|
* rc2. hack as per: https://github.com/travis-ci/travis-ci/issues/6934Anthony Green2019-11-031-1/+1
|
* Update versions to 3.3-rc1v3.3-rc1v3.3-rc1Anthony Green2019-10-241-1/+1
|
* fix(configure): Correctly detect visibility("hidden") support on DarwinMartin Bektchiev2018-12-191-1/+1
|
* Update FFI_HIDDEN() to use .private_extern on Apple platforms and use the ↵Jeremy Huddleston Sequoia2018-07-211-0/+4
| | | | | | | | macro where appropriate Fix issue #439 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
* build: fix subst toolexecdir, toolexeclibdirYousong Zhou2018-04-271-5/+5
| | | | | | | | | | | | | On CentOS 7.4, configure script generated by autogen.sh will output the following values when compiling GCC source code toolexecdir='NONE/$(target_alias)' toolexeclibdir='NONE/$(target_alias)/lib' and cause build error ... -o libffi.la -rpath NONE/riscv64-bs-linux-gnu/lib ... checking for shl_load in -ldld... libtool: link: only absolute run-paths are allowed
* 3.3 release candidate 0v3.3-rc0Anthony Green2018-04-021-1/+1
|
* Copy - don't symlink - to support msvc buildsAnthony Green2018-03-271-2/+4
|
* Update version number to next pre-releaseAnthony Green2018-03-131-1/+1
|
* Fix #265Anthony Green2017-09-271-1/+1
|
* Support -ios tripleMoritz Angermann2017-05-161-2/+2
| | | | | | | | | | | | | | | | | Autoconf hasn’t had an update since 2014, and it doesn’t look like it will soon[1] This updates config.{guess,sub} It adds support for e.g. `-ios`, which allows to have targets like `aarch64-apple-ios`. It basically does exactly what the config.guess script says: > It is advised that you download the most up to date version of the config scripts from The configure.ac script has been updated to relax `*-apple-darwin*` to `*-apple-*`. Similarly the `.gitignore` and `autogen.sh` needed to be updated to respect the newer `config.{sub,guess}` — [1]: http://lists.gnu.org/archive/html/autoconf/2016-07/msg00017.html
* [Darwin, configure] Allow configure to work for <arch>-*-darwin.Iain Sandoe2016-05-261-1/+1
| | | | The exec configury is appropriate for all current targets (including using older tools on them).
* Merge pull request #230 from rth7680/symverRichard Henderson2016-05-181-0/+3
|\ | | | | Use ELF symbol versioning
| * Use ELF symbol versioningRichard Henderson2016-05-041-0/+3
| | | | | | | | | | | | At the same time, we must bump the (major) ABI version. This needed to be done anyway due to ABI breakage in the AArch64 port (see 12cf89ee and the corresponding GCC PR70024).
* | Update project URLs to use libffi/libffiBerker Peksag2016-05-181-1/+1
|/
* fix documentation buildingTom Tromey2016-02-221-1/+1
| | | | | | | | | | | | An earlier patch added --disable-docs, but went too far, making it impossible to build the docs. It turns out that Automake seemingly has a bug preventing the conditional build of an info file. So, this patch works around the bug by putting the info_TEXINFOS rule into a new doc/Makefile.am. Tested by building with and without --disable-docs and looking for the existence of doc/libffi.info.
* Merge pull request #190 from havardgraff/masterAnthony Green2016-02-201-0/+7
|\ | | | | Add configure-option to disable building docs
| * Add configure-option to disable building docsHavard Graff2015-05-121-0/+7
| |
* | Add configure flag to disable multi-os-directory supportCarl Perry2015-10-291-5/+11
|/ | | | | | | | | | | | | In some environments, installing the library to GCC's multi-os-directory is not perferable. This patch adds a switch to configure "--disable-multi-os-directory" which will disable that check, typically falling back to ${libdir} unless cross-compiling. Original patch was written by Stewart Brodie, and was found at https://sourceware.org/ml/libffi-discuss/2013/msg00144.html I've just updated it to work with the current version.
* configure: Run HAVE_AS_X86_PCREL for all X86 targetsRichard Henderson2015-01-271-32/+8
|
* aarch64: implement the trampoline table workaround for ffi closures on Apple ↵Yavor Georgiev2015-01-161-1/+1
| | | | | | systems This is a direct copy/paste port of the ARM code, with changes because of Aarch64 pc-relative addressing restrictions.