Skip to content

Thumb2 ASM: fix out-of-range narrow branches with IAR compiler#10939

Open
mattia-moffa wants to merge 1 commit into
wolfSSL:masterfrom
mattia-moffa:20260717-fix-iar-narrow-branch
Open

Thumb2 ASM: fix out-of-range narrow branches with IAR compiler#10939
mattia-moffa wants to merge 1 commit into
wolfSSL:masterfrom
mattia-moffa:20260717-fix-iar-narrow-branch

Conversation

@mattia-moffa

Copy link
Copy Markdown
Member

Applies wolfssl/scripts#629

IAR reports "Branch offset too long" on branches that force the narrow instruction encoding (.N) but whose targets are beyond the byte range of a 16-bit branch.

This uses the .W variant for branches that exceed the limit.

Fixes ZD#22040

Applies wolfSSL/scripts#629

IAR reports "Branch offset too long" on branches that force the narrow
instruction encoding (.N) but whose targets are beyond the byte range of
a 16-bit branch.

This uses the .W variant for branches that exceed the limit.
@mattia-moffa mattia-moffa self-assigned this Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 04:12

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.

Pull request overview

This PR updates several Thumb-2 assembly sources (and their corresponding inline-asm C fallbacks) to avoid IAR’s “Branch offset too long” errors caused by forcing narrow conditional-branch encodings (.N) when the branch target is outside the 16-bit range. It does so by switching the affected conditional branches to the wide (.W) encoding where the narrow form can overflow.

Changes:

  • Replace forced narrow conditional branches (Bxx.N) with wide conditional branches (Bxx.W) in selected Thumb-2 .S sources.
  • Make the same .N.W updates in the corresponding *_asm_c.c inline-assembly strings (including the IAR < 9 label-compatibility path).
  • Keep the GNU/ICC/IAR compiler-specific paths intact (only adjusting the problematic narrow-forced variants).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wolfcrypt/src/port/arm/thumb2-poly1305-asm.S Switches a forced-narrow conditional branch to wide to avoid out-of-range failures.
wolfcrypt/src/port/arm/thumb2-poly1305-asm_c.c Updates the inline-asm conditional branch to use .W for IAR/non-GNU paths.
wolfcrypt/src/port/arm/thumb2-mlkem-asm.S Converts several loop conditional branches from .N to .W in non-GNU/ICC/IAR paths.
wolfcrypt/src/port/arm/thumb2-mlkem-asm_c.c Mirrors the .W conditional-branch updates in the inline-asm implementation.
wolfcrypt/src/port/arm/thumb2-curve25519.S Changes the affected loop conditional branch to .W to avoid narrow range overflow.
wolfcrypt/src/port/arm/thumb2-curve25519_c.c Updates the corresponding inline-asm branch to .W for IAR/non-GNU paths.
wolfcrypt/src/port/arm/thumb2-chacha-asm.S Switches selected conditional branches in the non-GNU/ICC/IAR path to .W.
wolfcrypt/src/port/arm/thumb2-chacha-asm_c.c Applies the same .W updates in the inline-asm strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

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.

2 participants