Skip to content

mldsa: load the ARM32 NTT zetas table PC-relative, no text relocation - #12193

Open
kaleb-himes wants to merge 1 commit into
wolfSSL:masterfrom
kaleb-himes:kh-mldsa-arm32-no-textrel
Open

kaleb-himes wants to merge 1 commit into
wolfSSL:masterfrom
kaleb-himes:kh-mldsa-arm32-no-textrel

Conversation

@kaleb-himes

Copy link
Copy Markdown
Contributor

Pairs with: https://github.com/wolfSSL/scripts/pull/722

Description

mldsa_ntt_neon and mldsa_invntt_neon in armv8-32-mldsa-asm.S reach their
zetas table through a 32-bit word in .text that held the table's absolute
address. That word needs an R_ARM_ABS32 relocation at load time, so a shared
libwolfssl built with --enable-armasm --enable-mldsa on 32-bit ARM gets
DT_TEXTREL from this object.

The word now holds the table's offset from the word itself, and the code adds
that offset to the address that ADR already gives. The assembler resolves the
difference within the section, so the object has no relocation for it. The
inline-asm file (armv8-32-mldsa-asm_c.c) does not change.

The .S file is generated by wolfSSL/scripts. The generator change is in
wolfSSL/scripts#, which should merge with or before this PR. Otherwise the
next regeneration puts the absolute .long back.

Testing

armv7, non-FIPS, --host=arm-linux-gnueabihf --enable-armasm --enable-mldsa --enable-mlkem --enable-shared --enable-sp=yes --enable-sp-asm, GCC 13.3.0
(arm-linux-gnueabihf), run under qemu-arm 8.2.2.

  • Relocations: readelf -r on the ML-DSA asm object shows 2 R_ARM_ABS32 in
    .rel.text on master and none on this branch.
  • testwolfcrypt: ML-DSA and ML-KEM pass on both master and this branch.
  • Negative control: breaking the inverse NTT's pointer add makes testwolfcrypt
    report ML-DSA test failed!, so the test does run mldsa_invntt_neon.
  • Generator: wolfSSL/scripts# reproduces this file byte for byte, and
    scripts master reproduces master's file byte for byte.

Note: the shared library still has DT_TEXTREL on both master and this branch.
All of it comes from armv8-32-aes-asm.o, which is outside this PR.

Copilot AI balanced review requested due to automatic review settings November 19, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The companion generator PR returned 404, so a maintainer must verify it reproduces the assembly changes and merges before or alongside this PR to prevent regeneration from restoring absolute-address words.

No open issues 🎉

What changed in this PR

Updates wolfCrypt’s ARM32 ML-DSA assembly to address NTT zetas tables PC-relatively, removing their absolute-address relocations without changing the inline-assembly implementation.

Changes:

  • Stores relative table offsets for both forward and inverse NTT routines.
  • Reconstructs table addresses at runtime using the existing ADR result. Unrelated AES text relocations remain outside this PR.
File Description
wolfcrypt/​src/​port/​arm/​armv8-32-mldsa-asm.S Replaces absolute zetas pointers with relative offsets and updates both NTT address-loading sequences.

Review effort: Balanced

@kaleb-himes
kaleb-himes marked this pull request as ready for review November 19, 2026 18:02
@github-actions

Copy link
Copy Markdown

retest this please

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12193

Scan targets checked: wolfssl-pr-general
Review type: general (no scan target covers the changed files)
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,496 B (+4.8%, 296,076 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants