From 83eb79808f5ef5524af510c6911a98038c341f7a Mon Sep 17 00:00:00 2001 From: Kyungwoo Lee Date: Fri, 12 Dec 2025 23:14:12 -0800 Subject: [PATCH] Fix AArch64 assembly syntax causing clang-21 crash The wolfssl ARM assembly files were mixing ELF syntax (:lo12:) with Darwin syntax (@PAGEOFF) in the same instruction, which causes a clang-21 assembler crash with the error "cannot apply another specifier to MCSpecifierExpr". On Darwin/Apple platforms, @PAGEOFF already represents the low 12 bits of the address, so the :lo12: prefix is redundant and incorrect. This was causing UNREACHABLE assertion failures in AsmParser.cpp when building with pika-26.3-staging toolchain. The fix removes the :lo12: prefix from instructions using @PAGEOFF on Apple platforms in both armv8-sha3-asm.S and armv8-sha512-asm.S. --- wolfcrypt/src/port/arm/armv8-sha3-asm.S | 4 ++-- wolfcrypt/src/port/arm/armv8-sha512-asm.S | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/port/arm/armv8-sha3-asm.S b/wolfcrypt/src/port/arm/armv8-sha3-asm.S index 5414ba713e5..e45626386b0 100644 --- a/wolfcrypt/src/port/arm/armv8-sha3-asm.S +++ b/wolfcrypt/src/port/arm/armv8-sha3-asm.S @@ -92,7 +92,7 @@ _BlockSha3_crypto: add x1, x1, :lo12:L_SHA3_transform_crypto_r #else adrp x1, L_SHA3_transform_crypto_r@PAGE - add x1, x1, :lo12:L_SHA3_transform_crypto_r@PAGEOFF + add x1, x1, L_SHA3_transform_crypto_r@PAGEOFF #endif /* __APPLE__ */ #ifdef __APPLE__ .arch_extension sha3 @@ -268,7 +268,7 @@ _BlockSha3_base: add x27, x27, :lo12:L_SHA3_transform_base_r #else adrp x27, L_SHA3_transform_base_r@PAGE - add x27, x27, :lo12:L_SHA3_transform_base_r@PAGEOFF + add x27, x27, L_SHA3_transform_base_r@PAGEOFF #endif /* __APPLE__ */ ldp x1, x2, [x0] ldp x3, x4, [x0, #16] diff --git a/wolfcrypt/src/port/arm/armv8-sha512-asm.S b/wolfcrypt/src/port/arm/armv8-sha512-asm.S index fde25d54e5c..c6f47826fb3 100644 --- a/wolfcrypt/src/port/arm/armv8-sha512-asm.S +++ b/wolfcrypt/src/port/arm/armv8-sha512-asm.S @@ -165,14 +165,14 @@ _Transform_Sha512_Len_neon: add x3, x3, :lo12:L_SHA512_transform_neon_len_k #else adrp x3, L_SHA512_transform_neon_len_k@PAGE - add x3, x3, :lo12:L_SHA512_transform_neon_len_k@PAGEOFF + add x3, x3, L_SHA512_transform_neon_len_k@PAGEOFF #endif /* __APPLE__ */ #ifndef __APPLE__ adrp x27, L_SHA512_transform_neon_len_r8 add x27, x27, :lo12:L_SHA512_transform_neon_len_r8 #else adrp x27, L_SHA512_transform_neon_len_r8@PAGE - add x27, x27, :lo12:L_SHA512_transform_neon_len_r8@PAGEOFF + add x27, x27, L_SHA512_transform_neon_len_r8@PAGEOFF #endif /* __APPLE__ */ ld1 {v11.16b}, [x27] # Load digest into working vars