From: Mounir IDRASSI Date: Tue, 7 Jul 2026 06:45:07 +0000 (+0900) Subject: Fix SM2 RISC-V64 crash from functions emitted into .rodata X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5b3f8863fcefe98c0baeaf954f84a1f8017eba2;p=thirdparty%2Fopenssl.git Fix SM2 RISC-V64 crash from functions emitted into .rodata The ecp_sm2p256-riscv64.pl generator switches to .section .rodata to emit constant data (.Lpoly, .Lord, .Lpoly_div_2, .Lord_div_2), but never switches back before emitting function code. As a result, the function symbols defined by this file are assembled into .rodata instead of executable .text. On systems enforcing NX for .rodata, calling the RISC-V64 SM2 assembly faults immediately. Fix this by adding .previous after the constant block, restoring the initial .text section before function emission. Verified with readelf: before the fix, .text is empty and the function symbols are in .rodata; after the fix, constants remain in .rodata and the function symbols are in executable .text. Introduced in commit 05301b100f (PR #25918). Reviewed-by: Paul Yang Reviewed-by: Saša Nedvědický MergeDate: Mon Jul 20 09:47:35 2026 (Merged from https://github.com/openssl/openssl/pull/31874) --- diff --git a/crypto/ec/asm/ecp_sm2p256-riscv64.pl b/crypto/ec/asm/ecp_sm2p256-riscv64.pl index 2a17e124dc4..40938e75c06 100644 --- a/crypto/ec/asm/ecp_sm2p256-riscv64.pl +++ b/crypto/ec/asm/ecp_sm2p256-riscv64.pl @@ -366,7 +366,7 @@ $code.=<<___; .type .Lord_div_2,\@object .Lord_div_2: .dword 0xa9ddfa049ceaa092,0xb901efb590e30295,0xffffffffffffffff,0x7fffffff7fffffff - +.previous // void bn_rshift1(BN_ULONG *a); .globl bn_rshift1