Skip to content

Commit fc8de68

Browse files
authored
psm: add .note.GNU-stack section as executable stack is not needed (#136)
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).
1 parent ef073d4 commit fc8de68

18 files changed

Lines changed: 21 additions & 0 deletions

psm/src/arch/aarch_aapcs64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "psm.h"
2+
#include "gnu_stack_note.s"
23

34
.text
45

psm/src/arch/arm_aapcs.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "psm.h"
2+
#include "gnu_stack_note.s"
23

34
.text
45
.syntax unified

psm/src/arch/gnu_stack_note.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#if defined(__linux__) && defined(__ELF__)
2+
.section .note.GNU-stack,"",%progbits
3+
#endif

psm/src/arch/loongarch64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "psm.h"
2+
#include "gnu_stack_note.s"
23

34
.text
45
.globl rust_psm_stack_direction

psm/src/arch/mips64_eabi.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ http://www.cygwin.com/ml/binutils/2003-06/msg00436.html
88
*/
99

1010
#include "psm.h"
11+
#include "gnu_stack_note.s"
1112

1213
.set noreorder /* we’ll manage the delay slots on our own, thanks! */
1314

psm/src/arch/mips_eabi.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ http://www.cygwin.com/ml/binutils/2003-06/msg00436.html
88
*/
99

1010
#include "psm.h"
11+
#include "gnu_stack_note.s"
1112

1213
.set noreorder /* we’ll manage the delay slots on our own, thanks! */
1314

psm/src/arch/powerpc32.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "psm.h"
2+
#include "gnu_stack_note.s"
23
/* FIXME: this probably does not cover all ABIs? Tested with sysv only, possibly works for AIX as
34
well?
45
*/

psm/src/arch/powerpc64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include "psm.h"
10+
#include "gnu_stack_note.s"
1011

1112
.text
1213
.globl rust_psm_stack_direction

psm/src/arch/powerpc64_openpower.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "psm.h"
9+
#include "gnu_stack_note.s"
910

1011
.text
1112
.abiversion 2

psm/src/arch/riscv.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "psm.h"
2+
#include "gnu_stack_note.s"
23

34
.text
45
.globl rust_psm_stack_direction

0 commit comments

Comments
 (0)