From e72f183c39debb630b36f034756a98bb6a7fbecc Mon Sep 17 00:00:00 2001 From: hrimfaxi Date: Thu, 18 Jun 2026 10:07:52 +0800 Subject: [PATCH] asm: add missing .note.GNU-stack markers Add .note.GNU-stack section declarations to hand-written assembly sources so ELF builds do not produce executables or libraries with an executable stack. These assembly implementations do not require an executable stack. Adding the marker restores normal non-executable stack/NX hardening. Signed-off-by: hrimfaxi --- src/gf128_arm64.S | 4 +++- src/sm2_z256_amd64.S | 3 +++ src/sm2_z256_arm64.S | 3 +++ src/sm9_z256_arm64.S | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gf128_arm64.S b/src/gf128_arm64.S index 302347a5..36af9a29 100644 --- a/src/gf128_arm64.S +++ b/src/gf128_arm64.S @@ -99,4 +99,6 @@ func(gf128_mul): ret - +#ifdef __ELF__ +.section .note.GNU-stack,"",@progbits +#endif diff --git a/src/sm2_z256_amd64.S b/src/sm2_z256_amd64.S index 4db694aa..f11bcc80 100644 --- a/src/sm2_z256_amd64.S +++ b/src/sm2_z256_amd64.S @@ -2139,3 +2139,6 @@ func(sm2_z256_point_add_affine): popq %rbp .byte 0xf3,0xc3 +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",@progbits +#endif diff --git a/src/sm2_z256_arm64.S b/src/sm2_z256_arm64.S index b6138563..1d4d9b41 100644 --- a/src/sm2_z256_arm64.S +++ b/src/sm2_z256_arm64.S @@ -2210,3 +2210,6 @@ func(sm2_z256_modn_mont_sqr): ldp x29,x30,[sp],#64 ret +#ifdef __ELF__ +.section .note.GNU-stack,"",@progbits +#endif diff --git a/src/sm9_z256_arm64.S b/src/sm9_z256_arm64.S index ff728234..8583f4fe 100644 --- a/src/sm9_z256_arm64.S +++ b/src/sm9_z256_arm64.S @@ -895,3 +895,6 @@ func(sm9_z256_modp_mont_sqr): ldp x29,x30,[sp],#64 ret +#ifdef __ELF__ +.section .note.GNU-stack,"",@progbits +#endif