libffi: add a patch for NetBSD/aarch64

The patch is suggested by Stas Boukarev and taken from
https://github.com/NetBSD/pkgsrc/blob/trunk/devel/libffi/patches/patch-src_aarch64_ffi.c

Fixes #817.
This commit is contained in:
Daniel Kochmański 2026-03-20 08:58:00 +01:00
parent 3116592d16
commit b765013374
2 changed files with 21 additions and 1 deletions

View file

@ -0,0 +1,19 @@
$NetBSD: patch-src_aarch64_ffi.c,v 1.4 2022/09/26 18:43:48 adam Exp $
For closures, aarch64 needs explicit invalidation of the code segments
i-cache after data is written through the data mapping.
But we don't have any way to look up the address of the code segment
right now so for now skip doing the cache flush.
--- src/aarch64/ffi.c.orig 2022-09-19 09:57:23.000000000 +0000
+++ src/aarch64/ffi.c
@@ -869,7 +869,8 @@ ffi_prep_closure_loc (ffi_closure *closu
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
/* Also flush the cache for code mapping. */
-# ifdef _WIN32
+# if defined(_WIN32) || defined(__NetBSD__)
+ // ffi_data_to_code_pointer is broken on NetBSD
// Not using dlmalloc.c for Windows ARM64 builds
// so calling ffi_data_to_code_pointer() isn't necessary
unsigned char *tramp_code = tramp;

View file

@ -916,7 +916,8 @@ ffi_prep_closure_loc (ffi_closure *closure,
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
/* Also flush the cache for code mapping. */
# ifdef _WIN32
# if defined(_WIN32) || defined(__NetBSD__)
// ffi_data_to_code_pointer is broken on NetBSD
// Not using dlmalloc.c for Windows ARM64 builds
// so calling ffi_data_to_code_pointer() isn't necessary
unsigned char *tramp_code = tramp;