From 2ff78166a86bdc37ba531fd40e8420a292f91260 Mon Sep 17 00:00:00 2001 From: Guillaume Girol Date: Sun, 4 Jan 2026 12:00:00 +0000 Subject: [PATCH] psm: add .note.GNU-stack section as executable stack is not needed On GNU/Linux, when linking an executable comprising a static library created by cargo because Cargo.toml contains crate-type = ["staticlib"] the linker outputs the following warning: ``` /nix/store/dc9vaz50jg7mibk9xvqw5dqv89cxzla3-binutils-2.44/bin/ld: warning: 4f9a91766097c4c5-x86_64.o: missing .note.GNU-stack section implies executable stack /nix/store/dc9vaz50jg7mibk9xvqw5dqv89cxzla3-binutils-2.44/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker ``` (where 4f9a91766097c4c5-x86_64.o is the object corresponding to psm/src/arch/x86_64.s) Add the note requested by the linker. For some reason, executables linked directly by rustc do not seem affected. I only observed this with a c++ project linking a rust static library comprising psm (lnav). --- psm/src/arch/aarch_aapcs64.s | 1 + psm/src/arch/arm_aapcs.s | 1 + psm/src/arch/gnu_stack_note.s | 3 +++ psm/src/arch/loongarch64.s | 1 + psm/src/arch/mips64_eabi.s | 1 + psm/src/arch/mips_eabi.s | 1 + psm/src/arch/powerpc32.s | 1 + psm/src/arch/powerpc64.s | 1 + psm/src/arch/powerpc64_openpower.s | 1 + psm/src/arch/riscv.s | 1 + psm/src/arch/riscv64.s | 1 + psm/src/arch/sparc64.s | 1 + psm/src/arch/sparc_sysv.s | 1 + psm/src/arch/wasm32.s | 1 + psm/src/arch/x86.s | 1 + psm/src/arch/x86_64.s | 1 + psm/src/arch/x86_64_windows_gnu.s | 2 ++ psm/src/arch/zseries_linux.s | 1 + 18 files changed, 21 insertions(+) create mode 100644 psm/src/arch/gnu_stack_note.s diff --git a/psm/src/arch/aarch_aapcs64.s b/psm/src/arch/aarch_aapcs64.s index d2851a9..ee10f8a 100644 --- a/psm/src/arch/aarch_aapcs64.s +++ b/psm/src/arch/aarch_aapcs64.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" .text diff --git a/psm/src/arch/arm_aapcs.s b/psm/src/arch/arm_aapcs.s index c2fa9d8..8ab5cae 100644 --- a/psm/src/arch/arm_aapcs.s +++ b/psm/src/arch/arm_aapcs.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" .text .syntax unified diff --git a/psm/src/arch/gnu_stack_note.s b/psm/src/arch/gnu_stack_note.s new file mode 100644 index 0000000..965af94 --- /dev/null +++ b/psm/src/arch/gnu_stack_note.s @@ -0,0 +1,3 @@ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/psm/src/arch/loongarch64.s b/psm/src/arch/loongarch64.s index 3fc6549..e0046a9 100644 --- a/psm/src/arch/loongarch64.s +++ b/psm/src/arch/loongarch64.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" .text .globl rust_psm_stack_direction diff --git a/psm/src/arch/mips64_eabi.s b/psm/src/arch/mips64_eabi.s index 72bc01e..0437929 100644 --- a/psm/src/arch/mips64_eabi.s +++ b/psm/src/arch/mips64_eabi.s @@ -8,6 +8,7 @@ http://www.cygwin.com/ml/binutils/2003-06/msg00436.html */ #include "psm.h" +#include "gnu_stack_note.s" .set noreorder /* we’ll manage the delay slots on our own, thanks! */ diff --git a/psm/src/arch/mips_eabi.s b/psm/src/arch/mips_eabi.s index e08ed27..49390cc 100644 --- a/psm/src/arch/mips_eabi.s +++ b/psm/src/arch/mips_eabi.s @@ -8,6 +8,7 @@ http://www.cygwin.com/ml/binutils/2003-06/msg00436.html */ #include "psm.h" +#include "gnu_stack_note.s" .set noreorder /* we’ll manage the delay slots on our own, thanks! */ diff --git a/psm/src/arch/powerpc32.s b/psm/src/arch/powerpc32.s index 1f7a086..5d59786 100644 --- a/psm/src/arch/powerpc32.s +++ b/psm/src/arch/powerpc32.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" /* FIXME: this probably does not cover all ABIs? Tested with sysv only, possibly works for AIX as well? */ diff --git a/psm/src/arch/powerpc64.s b/psm/src/arch/powerpc64.s index 1504a8c..826f4bf 100644 --- a/psm/src/arch/powerpc64.s +++ b/psm/src/arch/powerpc64.s @@ -7,6 +7,7 @@ */ #include "psm.h" +#include "gnu_stack_note.s" .text .globl rust_psm_stack_direction diff --git a/psm/src/arch/powerpc64_openpower.s b/psm/src/arch/powerpc64_openpower.s index eb3c1c1..18b6139 100644 --- a/psm/src/arch/powerpc64_openpower.s +++ b/psm/src/arch/powerpc64_openpower.s @@ -6,6 +6,7 @@ */ #include "psm.h" +#include "gnu_stack_note.s" .text .abiversion 2 diff --git a/psm/src/arch/riscv.s b/psm/src/arch/riscv.s index f74779f..bb5bee9 100644 --- a/psm/src/arch/riscv.s +++ b/psm/src/arch/riscv.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" .text .globl rust_psm_stack_direction diff --git a/psm/src/arch/riscv64.s b/psm/src/arch/riscv64.s index 279f735..2b1a29f 100644 --- a/psm/src/arch/riscv64.s +++ b/psm/src/arch/riscv64.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" .text .globl rust_psm_stack_direction diff --git a/psm/src/arch/sparc64.s b/psm/src/arch/sparc64.s index a0db27d..d5c3a50 100644 --- a/psm/src/arch/sparc64.s +++ b/psm/src/arch/sparc64.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" .text .globl rust_psm_stack_direction diff --git a/psm/src/arch/sparc_sysv.s b/psm/src/arch/sparc_sysv.s index 27d95e9..1780ba3 100644 --- a/psm/src/arch/sparc_sysv.s +++ b/psm/src/arch/sparc_sysv.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" /* FIXME: this ABI has definitely not been verified at all */ diff --git a/psm/src/arch/wasm32.s b/psm/src/arch/wasm32.s index e3364e7..db85a0e 100644 --- a/psm/src/arch/wasm32.s +++ b/psm/src/arch/wasm32.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" # Note that this function is not compiled when this package is uploaded to # crates.io, this source is only here as a reference for how the corresponding diff --git a/psm/src/arch/x86.s b/psm/src/arch/x86.s index 2e38876..5eec45c 100644 --- a/psm/src/arch/x86.s +++ b/psm/src/arch/x86.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" /* NOTE: fastcall calling convention used on all x86 targets */ .text diff --git a/psm/src/arch/x86_64.s b/psm/src/arch/x86_64.s index 49ff031..9a9b531 100644 --- a/psm/src/arch/x86_64.s +++ b/psm/src/arch/x86_64.s @@ -1,4 +1,5 @@ #include "psm.h" +#include "gnu_stack_note.s" /* NOTE: sysv64 calling convention is used on all x86_64 targets, including Windows! */ .text diff --git a/psm/src/arch/x86_64_windows_gnu.s b/psm/src/arch/x86_64_windows_gnu.s index 8f12583..5904ffb 100644 --- a/psm/src/arch/x86_64_windows_gnu.s +++ b/psm/src/arch/x86_64_windows_gnu.s @@ -1,3 +1,5 @@ +#include "gnu_stack_note.s" + .text .def rust_psm_stack_direction diff --git a/psm/src/arch/zseries_linux.s b/psm/src/arch/zseries_linux.s index e2536a1..de29e8f 100644 --- a/psm/src/arch/zseries_linux.s +++ b/psm/src/arch/zseries_linux.s @@ -9,6 +9,7 @@ */ #include "psm.h" +#include "gnu_stack_note.s" .text