summaryrefslogtreecommitdiff
path: root/configure.ac
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fix expr error in Solaris 10 when using gcc.Mișu Moldovan2015-01-071-5/+7
|
* s390: Use pc-relative insns in 31-bit modeRichard Henderson2014-12-181-0/+17
| | | | | | It's silly to stick to esa/390 features when the compiler won't. Detect when brasl and larl are used by the compiler and then use them in the assembly.
* configure: Move target source selection into configure.hostRichard Henderson2014-11-141-44/+11
| | | | | | | | This eliminates the AM_CONDITIONAL ugliness, which eliminates just a bit of extra boilerplate for a new target. At the same time, properly categorize the EXTRA_DIST files into SOURCES and HEADERS, for the generation of ctags.
* configure: Split out configure.hostRichard Henderson2014-11-131-216/+1
| | | | | Split out the host case statement to a separate file, so that we don't have to regenerate configure.in for changes therein.
* Update in preparation for next releaseAnthony Green2014-11-121-1/+1
|
* Fix for AArch64. Release as 3.2.1.v3.2.1Anthony Green2014-11-121-1/+1
|
* Add OpenRISC supportSebastian Macke2014-09-271-0/+5
| | | | | | | | | | | | | | | | | | | This patch adds support for the OpenRISC architecture. (http://opencores.org/or1k/Main_Page) This patch has been tested under Linux with QEMU-user emulation support. - 32 Bit - big endian - delayed instructions This is the only available configuration under Linux. The description of the ABI can be found on the official website. Is passes the testsuite except of the unwindtest_ffi_call.cc testcase, which seems to be a problem of gcc and not libffi. Some testcases of the gcc testsuite still fail. Signed-off-by: Sebastian Macke <sebastian@macke.de>
* Update version to 3.2Anthony Green2014-09-201-1/+1
|
* Fix paths in libffi.pc.inSamuli Suominen2014-06-121-5/+5
|
* Prepare for libffi 3.1.1Anthony Green2014-05-311-1/+1
|
* closures: Check for mkostemp(3)Mickaël Salaün2014-05-191-1/+1
|
* Update to version 3.1Anthony Green2014-05-111-1/+1
|
* Use to get correct dirDominik Vogt2014-05-111-1/+1
|
* Use the proper C++ compiler to run C++ testsJosh Triplett2014-03-271-0/+2
| | | | | Running the C compiler with -shared-libgcc -lstdc++ does not work on non-GCC compilers.