Thumb2 ASM: fix out-of-range narrow branches with IAR compiler#10939
Open
mattia-moffa wants to merge 1 commit into
Open
Thumb2 ASM: fix out-of-range narrow branches with IAR compiler#10939mattia-moffa wants to merge 1 commit into
mattia-moffa wants to merge 1 commit into
Conversation
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.
Contributor
There was a problem hiding this comment.
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.Ssources. - Make the same
.N→.Wupdates in the corresponding*_asm_c.cinline-assembly strings (including the IAR< 9label-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.
Member
Author
|
Jenkins retest this please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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