Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
745 changes: 745 additions & 0 deletions deps/libffi/ChangeLog

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion deps/libffi/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

libffi-3.8.1 was released on November 14, 2026.
libffi-3.8.2 was released on November 25, 2026.


What is libffi?
Expand Down Expand Up @@ -201,6 +201,40 @@ History

See the git log for details at http://github.com/libffi/libffi.

3.8.2 November-25-2026
x86-64: reject vector types under the Win64 ABIs on non-Windows
builds, as documented (GHSA-v9rw-6cxm-q6rf).
CRIS: reject vector types (GHSA-j9pv-w354-7fg2).
aarch64: reserve enough stack for large by-value structs mixed
with 16-byte-aligned arguments (GHSA-wc36-xxj4-cxh5).
Pass by-value aggregates aligned beyond the stack alignment
correctly on x86-64, i386, ARM, MIPS, m88k and AArch64
(GHSA-rwpw-56v4-44r3).
powerpc64 ELFv2: fix closures overwriting the caller's frame
with float structs and _Complex arguments
(GHSA-p8c7-j6j7-h7vg), and stop padding IBM long double
aggregates (GHSA-34hv-975q-7p7w).
RISC-V, LoongArch: fix one-float structs passed after the FP
argument registers run out (GHSA-2xrh-7r9c-rwmf).
Static trampolines: make the temporary code-table file
immutable, so a forked child cannot rewrite its parent's
closures (GHSA-7qx4-vhpx-x6qm).
i386: fix ffi_raw_call argument placement and refuse raw
closures with in-memory results (GHSA-qgq7-fxgw-wrp4,
GHSA-64xf-g9qc-vf93).
MIPS: fix O32 closures returning _Complex long long
(GHSA-xh8m-x7vg-ww5m) and N32/N64 complex arguments at the
end of the argument registers (GHSA-p8w7-v539-c775).
Refuse oversized signatures instead of truncating them
(GHSA-qpm4-52vm-3xff, GHSA-j4q2-5r23-67rj,
GHSA-76jh-g582-v8x4).
SPARC: fix ffi_call with a NULL rvalue for large struct results
(GHSA-v569-599f-q4hr).
AIX: make struct layout independent of prior ffi_prep_cif calls
(GHSA-f45x-cg8q-3q9w).
LoongArch: do not write to the result buffer of a void call
(#1083).

3.8.1 November-14-2026
Improve ABI conformance and test coverage for complex-number
calls, closures, and small aggregates across ARM, x86, PowerPC,
Expand Down
28 changes: 14 additions & 14 deletions deps/libffi/configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.72 for libffi 3.8.1.
# Generated by GNU Autoconf 2.72 for libffi 3.8.2.
#
# Report bugs to <http://github.com/libffi/libffi/issues>.
#
Expand Down Expand Up @@ -614,8 +614,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libffi'
PACKAGE_TARNAME='libffi'
PACKAGE_VERSION='3.8.1'
PACKAGE_STRING='libffi 3.8.1'
PACKAGE_VERSION='3.8.2'
PACKAGE_STRING='libffi 3.8.2'
PACKAGE_BUGREPORT='http://github.com/libffi/libffi/issues'
PACKAGE_URL=''

Expand Down Expand Up @@ -1414,7 +1414,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
'configure' configures libffi 3.8.1 to adapt to many kinds of systems.
'configure' configures libffi 3.8.2 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1486,7 +1486,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libffi 3.8.1:";;
short | recursive ) echo "Configuration of libffi 3.8.2:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1625,7 +1625,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libffi configure 3.8.1
libffi configure 3.8.2
generated by GNU Autoconf 2.72

Copyright (C) 2023 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2274,7 +2274,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by libffi $as_me 3.8.1, which was
It was created by libffi $as_me 3.8.2, which was
generated by GNU Autoconf 2.72. Invocation command line was

$ $0$ac_configure_args_raw
Expand Down Expand Up @@ -3266,10 +3266,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers fficonfig.h"


FFI_VERSION_STRING="3.8.1"
ffi_version_major=`echo "3.8.1" | cut -d. -f1`
ffi_version_minor=`echo "3.8.1" | cut -d. -f2 | sed 's/[^0-9].*//'`
ffi_version_micro=`echo "3.8.1" | cut -d. -f3 | sed 's/[^0-9].*//'`
FFI_VERSION_STRING="3.8.2"
ffi_version_major=`echo "3.8.2" | cut -d. -f1`
ffi_version_minor=`echo "3.8.2" | cut -d. -f2 | sed 's/[^0-9].*//'`
ffi_version_micro=`echo "3.8.2" | cut -d. -f3 | sed 's/[^0-9].*//'`
FFI_VERSION_NUMBER=`expr ${ffi_version_major:-0} \* 10000 + ${ffi_version_minor:-0} \* 100 + ${ffi_version_micro:-0}`


Expand Down Expand Up @@ -4214,7 +4214,7 @@ fi

# Define the identity of the package.
PACKAGE='libffi'
VERSION='3.8.1'
VERSION='3.8.2'


printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
Expand Down Expand Up @@ -22472,7 +22472,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libffi $as_me 3.8.1, which was
This file was extended by libffi $as_me 3.8.2, which was
generated by GNU Autoconf 2.72. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -22540,7 +22540,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
libffi config.status 3.8.1
libffi config.status 3.8.2
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"

Expand Down
2 changes: 1 addition & 1 deletion deps/libffi/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure

AC_PREREQ([2.68])

AC_INIT([libffi],[3.8.1],[http://github.com/libffi/libffi/issues])
AC_INIT([libffi],[3.8.2],[http://github.com/libffi/libffi/issues])
AC_CONFIG_HEADERS([fficonfig.h])

dnl Derive the version macros from AC_INIT so they cannot drift when the
Expand Down
4 changes: 2 additions & 2 deletions deps/libffi/generate-headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pathlib import Path


LIBFFI_VERSION = '3.8.1'
LIBFFI_VERSION_NUMBER = '30801'
LIBFFI_VERSION = '3.8.2'
LIBFFI_VERSION_NUMBER = '30802'

def normalize_arch(target_arch):
aliases = {
Expand Down
19 changes: 19 additions & 0 deletions deps/libffi/include/ffi_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ void ffi_type_test(ffi_type *a, const char *file, int line);
/* v cast to size_t and aligned down to a multiple of a */
#define FFI_ALIGN_DOWN(v, a) (((size_t) (v)) & -a)

/* Upper bound on the size of an aggregate laid out by ffi_prep_cif.
Summing member sizes must not wrap, and the call code adds the size of
the return type to its frame and argument block (an alloca), so the
bound leaves headroom for those additions even where size_t is 32
bits. No real object comes anywhere near it. */
#define FFI_MAX_TYPE_SIZE (((size_t) -1) / 4)

/* Upper bounds on a signature, checked by ffi_prep_cif_core before any
port sees it. Several ports keep argument counts in an int and the
size of the argument area in the 32-bit cif->bytes, and compute that
size in ways that can wrap; no call can use an argument area larger
than a thread's stack anyway, so refuse signatures far beyond that
rather than let any port truncate them. */
#define FFI_MAX_ARG_BYTES ((size_t) 256 << 20)
#define FFI_MAX_NARGS (FFI_MAX_ARG_BYTES / 8)

/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
Expand All @@ -139,6 +155,9 @@ ffi_status ffi_prep_cif_core(ffi_cif *cif,
ffi_type *rtype,
ffi_type **atypes);

/* Nonzero if TY is, or contains, a vector (SIMD) type. */
int ffi_type_contains_vector (ffi_type *ty) FFI_HIDDEN;

/* Translate a data pointer to a code pointer. Needed for closures on
some targets. */
void *ffi_data_to_code_pointer (void *data) FFI_HIDDEN;
Expand Down
2 changes: 1 addition & 1 deletion deps/libffi/libtool-version
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# release, then set age to 0.
#
# CURRENT:REVISION:AGE
13:1:5
13:2:5
37 changes: 28 additions & 9 deletions deps/libffi/src/aarch64/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,16 @@ static void *
allocate_and_copy_struct_to_stack (struct arg_state *state, void *stack,
size_t alignment, size_t size, void *value)
{
size_t dest = state->next_struct_area - size;
char *dest = (char *) stack + state->next_struct_area - size;

/* Round down to the natural alignment of the value. */
dest = FFI_ALIGN_DOWN (dest, alignment);
state->next_struct_area = dest;
/* Round down to the natural alignment of the value. Round the address,
not the offset: the slab is only 16-byte aligned, and the callee may
rely on the full alignment of the copy. ffi_prep_cif_machdep reserves
what this can skip for alignments above 16. */
dest = (char *) FFI_ALIGN_DOWN (dest, alignment);
state->next_struct_area = (size_t) (dest - (char *) stack);

return memcpy ((char *) stack + dest, value, size);
return memcpy (dest, value, size);
}

static ffi_arg
Expand Down Expand Up @@ -660,16 +663,32 @@ ffi_prep_cif_machdep (ffi_cif *cif)
NSAA, growing up). The generic prep_cif accounting in cif->bytes
only charges the payload copy, not that 8-byte pointer slot, so the
two regions can collide and a later struct copy can overwrite an
already-spilled pointer with the copied payload bytes. Reserve an
extra 8 bytes per such argument so the slab is always large enough
for both. */
already-spilled pointer with the copied payload bytes. Nor does it
charge the alignment padding that only arises because the payload and
the pointer live in different regions: the 8-byte pointer slot can
leave the NSAA at an odd doubleword where the generic layout (which
placed the payload there instead) did not, so a following 16-byte
aligned stack argument (__int128, long double, ...) needs 8 bytes of
padding, and a 16-byte aligned payload copied below an odd-doubleword
next_struct_area needs another 8. Reserve an extra 16 bytes per such
argument so the slab is always large enough for all of it. */
for (i = 0, n = cif->nargs; i < n; i++)
{
ffi_type *ty = cif->arg_types[i];
if (ty->size > 16 && !is_vfp_type (ty))
bytes += 8;
{
bytes += 16;
/* Rounding the copy's address down to an alignment above the
slab's 16 can skip up to alignment - 1 more bytes. */
if (ty->alignment > 16)
bytes += ty->alignment;
}
}

/* cif->bytes is an unsigned int: refuse a total it cannot hold. */
if (bytes > INT_MAX)
return FFI_BAD_TYPEDEF;

/* Round the stack up to a multiple of the stack alignment requirement. */
cif->bytes = (unsigned) FFI_ALIGN(bytes, 16);
cif->flags = flags;
Expand Down
17 changes: 17 additions & 0 deletions deps/libffi/src/arm/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ ffi_align (ffi_type *ty, void *p)
alignment = 4;
#else
alignment = ty->alignment;
/* An aggregate aligned beyond a doubleword can only have got that from
the alignment of the type itself (an attribute on the type, or a
caller-set alignment), which the AAPCS ignores when passing it: it
uses the largest member alignment, and never more than a doubleword.
The argument area is only doubleword aligned anyway. */
if (alignment > 8)
{
ffi_type **p;

alignment = 4;
if (ty->elements != NULL)
for (p = ty->elements; *p != NULL; p++)
if ((*p)->alignment > alignment)
alignment = (*p)->alignment;
if (alignment > 8)
alignment = 8;
}
if (alignment < 4)
alignment = 4;
#endif
Expand Down
5 changes: 5 additions & 0 deletions deps/libffi/src/closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,12 @@ static int
open_temp_exec_file_memfd (const char *name)
{
int fd;
#ifdef MFD_ALLOW_SEALING
/* Let ffi_tramp_get_temp_file () seal the file once it has been filled. */
fd = memfd_create (name, MFD_CLOEXEC | MFD_ALLOW_SEALING);
#else
fd = memfd_create (name, MFD_CLOEXEC);
#endif
return fd;
}
#endif
Expand Down
33 changes: 33 additions & 0 deletions deps/libffi/src/cris/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <ffi.h>
#include <ffi_common.h>

#include <stdlib.h>

#define STACK_ARG_SIZE(x) FFI_ALIGN(x, FFI_SIZEOF_ARG)

static ffi_status
Expand All @@ -52,6 +54,8 @@ initialize_aggregate_packed_struct (ffi_type * arg)

FFI_ASSERT (ffi_type_test ((*ptr)));

if ((*ptr)->size > FFI_MAX_TYPE_SIZE - arg->size)
return FFI_BAD_TYPEDEF;
arg->size += (*ptr)->size;

arg->alignment = (arg->alignment > (*ptr)->alignment) ?
Expand Down Expand Up @@ -160,6 +164,7 @@ ffi_prep_cif_core (ffi_cif * cif,
ffi_type * rtype, ffi_type ** atypes)
{
unsigned bytes = 0;
size_t arg_bytes = 0;
unsigned int i;
ffi_type **ptr;

Expand All @@ -173,22 +178,50 @@ ffi_prep_cif_core (ffi_cif * cif,
cif->nargs = ntotalargs;
cif->rtype = rtype;

if (ntotalargs > FFI_MAX_NARGS)
return FFI_BAD_TYPEDEF;

#ifndef FFI_TARGET_HAS_VECTOR_TYPE
/* Vector (SIMD) types are only marshalled on ports that opt in. */
if (ffi_type_contains_vector (rtype))
return FFI_BAD_TYPEDEF;
for (i = 0; i < ntotalargs; i++)
if (ffi_type_contains_vector (atypes[i]))
return FFI_BAD_TYPEDEF;
#endif

cif->flags = 0;

if ((cif->rtype->size == 0)
&& (initialize_aggregate_packed_struct (cif->rtype) != FFI_OK))
return FFI_BAD_TYPEDEF;

#ifndef FFI_TARGET_HAS_COMPLEX_TYPE
if (rtype->type == FFI_TYPE_COMPLEX)
abort ();
#endif
FFI_ASSERT_VALID_TYPE (cif->rtype);
if (cif->rtype->size > FFI_MAX_ARG_BYTES)
return FFI_BAD_TYPEDEF;

for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
{
if (((*ptr)->size == 0)
&& (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK))
return FFI_BAD_TYPEDEF;

#ifndef FFI_TARGET_HAS_COMPLEX_TYPE
if ((*ptr)->type == FFI_TYPE_COMPLEX)
abort ();
#endif
FFI_ASSERT_VALID_TYPE (*ptr);

/* Bound the whole argument list, as ffi_prep_cif_core does. */
if ((*ptr)->size > FFI_MAX_ARG_BYTES
|| FFI_ALIGN ((*ptr)->size, 16) > FFI_MAX_ARG_BYTES - arg_bytes)
return FFI_BAD_TYPEDEF;
arg_bytes += FFI_ALIGN ((*ptr)->size, 16);

if (((*ptr)->alignment - 1) & bytes)
bytes = FFI_ALIGN (bytes, (*ptr)->alignment);
if ((*ptr)->type == FFI_TYPE_STRUCT)
Expand Down
4 changes: 2 additions & 2 deletions deps/libffi/src/loongarch/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ struct_passed_as_elements (call_builder *cb, ffi_type *top)

if (num_fields == 1)
{
if (IS_FLOAT (fields[0]->type))
if (IS_FLOAT (fields[0]->type) && cb->used_float < NARGREG)
{
ret.as_elements = 1;
ret.type1 = fields[0]->type;
Expand Down Expand Up @@ -507,7 +507,7 @@ ffi_call_int (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
ffi_call_asm ((void *) alloc_base, cb.aregs, fn, closure);

cb.used_float = cb.used_integer = 0;
if (!return_by_ref && rvalue)
if (!return_by_ref && rvalue && cif->rtype->type != FFI_TYPE_VOID)
unmarshal (&cb, cif->rtype, 0, rvalue);
}

Expand Down
Loading
Loading