Repository navigation
Review fixes; reject bad arm64 operands - #13
Merged
Merged
Conversation
…, arm64 wildcards - README: X<n> is the bytes left in the instruction (for /d); the operand size is /d1 /r2 /r8... The jb short example read 4 bytes instead of 1. - RuntimePattern(p, len) read flags and X<n> past len on unterminated text. - Builds with -fno-exceptions: errors are compile errors at compile time, a trap at runtime. - arm64 /d on an instruction it can't decode returns nullptr instead of throwing from find(); the IDA plugin reports such hits as unresolved. - C++17: negative ADR/ADRP offsets failed to compile; the /d decoders shifted negative values. - ADD/SUB/CMP #imm, LSL #? matched only LSL #0. - Bitmask immediates and MOV with a bare ? Rd encoded only the 32-bit form; MOV truncated 64-bit values (MOV ?, #0xFFFFFFFF00000000 matched MOV X0, #0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A bad operand (garbage or out-of-range register, wrong register kind or width, out-of-range or misaligned immediate, missing/extra operands, unknown shift/extend/condition, trailing text) is now a compile error for _armpattern/ARM_PATTERN and a throw naming the line for RuntimeArmPattern. Only an unknown mnemonic stays a wildcard. - ';' comments are stripped from lines - BIC/BICS/ORN/EON immediates encode as AND/ANDS/ORR/EOR of the inverse - negative W logical immediates encode - parse tables are inline constexpr: GCC -O0 (-fkeep-static-consts) emitted them unreferenced, pulling every parser and mnemonic into binaries using only compile-time patterns - test_arm_compile_time: bad operand must fail to compile; -O0 binary must not contain encoder strings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ond offsets at runtime Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s in comments - A hex immediate past INT64_MAX wrapped negative (ADD X0, X1, #0xFFFFFFFFFFFFFFFF encoded SUB #1; LDR [X1, #0xFFFFFFFFFFFFFFF8] became LDUR #-8), and a negative one past -2^63 wrapped positive (MOV X0, #-0xFFFFFFFFFFFFFFFF was MOV #1). Both fail now. - ADRP takes a page distance: an offset that isn't a multiple of 0x1000 fails instead of being truncated (ADRP X0, #0x1234 matched page 1). - BIC/BICS/ORN/EON #? and immediates with ? registers pinned immr's top bit to 0, missing 64-bit immediates like AND X0, X1, #0xFFFFFFFF00000000. - The flags line ends at a ';' comment or newline: "/a ; done" turned on /d. - The two _bad compile tests build in the same build directory: RESOURCE_LOCK, so ctest -j doesn't run two ninjas there at once (a failed build would pass). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Two commits:
9456e1c: review fixes
a36d7f6: strict arm64 operands
A bad operand is now a compile error for
_armpattern/ARM_PATTERN.RuntimeArmPatternthrows instead, and the message names the line. Bad operands include:X31,X32)Before, the line silently became a wildcard, or an out-of-range value was truncated into the wrong encoding. Only an unknown mnemonic still becomes a wildcard.
;comments are stripped, so lines copied from IDA or lldb with trailing comments still parse.BIC/BICS/ORN/EONwith an immediate encode asAND/ANDS/ORR/EORwith the inverted value. Checked against clang.Negative W logical immediates encode (
AND W0, W1, #-0x1000).Fix for an existing leak: GCC
-O0(-fkeep-static-consts) emitted the unreferenced parse tables, which pulled every parser and mnemonic into binaries that only use compile-time patterns. The tables are nowinline constexpr.Testing
test_arm_compile_time_cpp{17,20}: the bad build must fail to compile, and the encoder must not end up in the-O0binary.test_armpasses natively on an Apple arm64 machine.asas the reference:asrejects is accepted.ason purpose in three places, matching the Arm spec and LLVM:astruncates large values to 32 bits.asallows mismatched register widths with an extend.asaccepts a!after a non-memory operand.Not tested on MSVC.
🤖 Generated with Claude Code