Repository navigation
Fix negative offsets in arm32 ldr and str ##arch - #27137
Merged
trufae merged 1 commit intoOct 23, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 22, 2026
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.
Description
negative offsets in arm32
ldr/straddressing were assembled as a different instruction without an error :ldr r0, [r1, #-4]ldr r0, [r1, #4092]040011e5str r0, [r1], #-8str r0, [r1], #4088080001e4str r0, [r1, #-8]!str r0, [r1, #4088]!080021e5strb r3, [fp, #-0xfff]strb r3, [r11, #1]ff3f4be5ldr r0, [r1, -r2]adds r0, r1, r0020011e7str lr, [r0, -r6, lsl #31]add lr, r0, r086ef00e7ldr r0, [r1, #-4096]ldr r0, [r1]the immediate was masked with
0xfffas is , so-4became4092with the U bit still set , and a-in front of a register madegetregfail and fall through to a data processing encoding . the offset now drops a leading-, clears the U bit (0x8000in the swapped word ) and encodes the magnitude , for both the immediate and the register forms . an immediate that does not fit in 12 bits is refused instead of wrapping .found by decoding random words with llvm-mc (
-triple=armv7) , assembling the text withrasm2 -a arm -b 32and decoding the result again . same as llvm went from 618 to 738 of 3459 , nothing that was right changed . the 7 new lines indb/asm/arm_32fail before the change , and 6 lines that were marked broken there (ldreq r0, [fp, -180],streq r3, [r5, -4]and friends ) pass now , so they are unmarked .db/asmanddb/tools/rasm2have no failures .