Skip to content
Open
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
1 change: 1 addition & 0 deletions psm/src/arch/aarch_aapcs64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

.text

Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/arm_aapcs.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

.text
.syntax unified
Expand Down
3 changes: 3 additions & 0 deletions psm/src/arch/gnu_stack_note.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if defined(__linux__) && defined(__ELF__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be checking for __gnu_linux__ or __GNUC__ (which despite having "C" in its name) is defined when compiling assembly and is going to be specific for gnu targets where this matters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, lets rename the file to be more self-descriptive (e.g. gnu_stack_note.s)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gentoo wiki recommends it this way. https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart#Patching

I suspect it covers the case where the assembler is not gnu but the linker is (as this note is directed to the linker, as far as I understand)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, lets rename the file to be more self-descriptive (e.g. gnu_stack_note.s)

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, having done some more research, I think this check could drop the linux check altogether and just condition on just the

defined(__ELF__)

https://github.com/llvm/llvm-project/blob/66df6cceea001a2082bc78678305a86b9bb29ecb/llvm/lib/MC/MCAsmInfoELF.cpp#L30-L37 does not emit this section on solaris, but psm does not need to worry too much about creating that one superfluous mini-section on targets that might not use it.

.section .note.GNU-stack,"",%progbits
#endif
1 change: 1 addition & 0 deletions psm/src/arch/loongarch64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

.text
.globl rust_psm_stack_direction
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/mips64_eabi.s
Original file line number Diff line number Diff line change
Expand Up @@ -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! */

Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/mips_eabi.s
Original file line number Diff line number Diff line change
Expand Up @@ -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! */

Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/powerpc32.s
Original file line number Diff line number Diff line change
@@ -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?
*/
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/powerpc64.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "psm.h"
#include "gnu_stack_note.s"

.text
.globl rust_psm_stack_direction
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/powerpc64_openpower.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "psm.h"
#include "gnu_stack_note.s"

.text
.abiversion 2
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/riscv.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

.text
.globl rust_psm_stack_direction
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/riscv64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

.text
.globl rust_psm_stack_direction
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/sparc64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

.text
.globl rust_psm_stack_direction
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/sparc_sysv.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"

/* FIXME: this ABI has definitely not been verified at all */

Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/wasm32.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/x86.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "psm.h"
#include "gnu_stack_note.s"
/* NOTE: fastcall calling convention used on all x86 targets */

.text
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/x86_64.s
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions psm/src/arch/x86_64_windows_gnu.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "gnu_stack_note.s"

.text

.def rust_psm_stack_direction
Expand Down
1 change: 1 addition & 0 deletions psm/src/arch/zseries_linux.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include "psm.h"
#include "gnu_stack_note.s"

.text

Expand Down
Loading