When testing a patch to enable libgo on FreeBSD/x86 (PR go/86535) with a
gcc configured to use GNU ld, the libffi tests FAILed:

Excess errors:
gld-2.46: warning: win64.o: missing .note.GNU-stack section implies executable 
stack
gld-2.46: NOTE: This behaviour is deprecated and will be removed in a future 
version of the linker

This is fixed by upstream pull request

        Include .note.GNU-stack on FreeBSD/x86
        https://github.com/libffi/libffi/pull/991

Tested on amd64-pc-freebsd15.1.

Ok to cherry-pick into trunk?

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2026-07-06  Rainer Orth  <[email protected]>

        libffi:
        * src/x86/sysv.S (.note.GNU-stack): Also emit on FreeBSD.
        * src/x86/sysv_intel.S: Likewise.
        * src/x86/unix64.S: Likewise.
        * src/x86/win64.S: Likewise.
        * src/x86/win64_intel.S: Likewise.

        Cherry-picked from upstream commit 854df63.

# HG changeset patch
# Parent  278e64c86a5f1c130a03d6e5b170feee4a0f51a3
libffi: Include .note.GNU-stack on FreeBSD/x86

diff --git a/libffi/src/x86/sysv.S b/libffi/src/x86/sysv.S
--- a/libffi/src/x86/sysv.S
+++ b/libffi/src/x86/sysv.S
@@ -1267,6 +1267,6 @@ L(EFDE9):
 
 #endif /* ifdef __i386__ */
 
-#if defined __ELF__ && defined __linux__
+#if defined __ELF__ && (defined __linux__ || defined __FreeBSD__)
 	.section	.note.GNU-stack,"",@progbits
 #endif
diff --git a/libffi/src/x86/sysv_intel.S b/libffi/src/x86/sysv_intel.S
--- a/libffi/src/x86/sysv_intel.S
+++ b/libffi/src/x86/sysv_intel.S
@@ -990,7 +990,7 @@ L(EFDE9):
 #endif /* ifndef _MSC_VER */
 #endif /* ifndef __x86_64__ */
 
-#if defined __ELF__ && defined __linux__
+#if defined __ELF__ && (defined __linux__ || defined __FreeBSD__)
 	.section	.note.GNU-stack,"",@progbits
 #endif
 #endif
diff --git a/libffi/src/x86/unix64.S b/libffi/src/x86/unix64.S
--- a/libffi/src/x86/unix64.S
+++ b/libffi/src/x86/unix64.S
@@ -706,6 +706,6 @@ L(EFDE5):
 #endif
 
 #endif /* __x86_64__ */
-#if defined __ELF__ && defined __linux__
+#if defined __ELF__ && (defined __linux__ || defined __FreeBSD__)
 	.section	.note.GNU-stack,"",@progbits
 #endif
diff --git a/libffi/src/x86/win64.S b/libffi/src/x86/win64.S
--- a/libffi/src/x86/win64.S
+++ b/libffi/src/x86/win64.S
@@ -249,6 +249,6 @@ C(ffi_closure_win64_alt):
 #endif
 #endif /* __x86_64__ */
 
-#if defined __ELF__ && defined __linux__
+#if defined __ELF__ && (defined __linux__ || defined __FreeBSD__)
 	.section	.note.GNU-stack,"",@progbits
 #endif
diff --git a/libffi/src/x86/win64_intel.S b/libffi/src/x86/win64_intel.S
--- a/libffi/src/x86/win64_intel.S
+++ b/libffi/src/x86/win64_intel.S
@@ -231,8 +231,8 @@ ffi_closure_win64_2 LABEL near
 	cfi_endproc
 	C(ffi_closure_win64) endp
 
-#if defined __ELF__ && defined __linux__
+#if defined __ELF__ && (defined __linux__ || defined __FreeBSD__)
 	.section	.note.GNU-stack,"",@progbits
 #endif
 _text ends
-end
\ No newline at end of file
+end

Reply via email to