Resolve sleigh language id by the processor's available endianness#391
Open
Scottcjn wants to merge 1 commit into
Open
Resolve sleigh language id by the processor's available endianness#391Scottcjn wants to merge 1 commit into
Scottcjn wants to merge 1 commit into
Conversation
SleighIdFromSleighAsmConfig built the language id as proc:(bigendian?BE:LE):bits from the host/config endianness without checking that the combination exists. For single-endian processors this produces an unusable id on the wrong host. For example V850 is little-endian only, so on a big-endian host the id came out as V850:BE:32, there is no sleigh spec for it, and disassembly returned invalid for every instruction. Match the requested cpu against the available language descriptions and, when the requested endianness has no spec but the opposite one does, use the one that exists. When the requested endianness is available the result is unchanged, so little-endian hosts behave exactly as before. Fixes rizinorg#389.
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.
Fixes #389.
Problem
SleighIdFromSleighAsmConfigbuilds the language id asproc:(bigendian?BE:LE):bitsstraight from the host/config endianness, without checking that the combination has a sleigh spec. For single-endian processors this yields an unusable id on the wrong host.Concretely, V850 is little-endian only, so on a big-endian host the id resolves to
V850:BE:32, there is no spec for it (SleighInit No sleigh specification for V850:BE:32), and every instruction decodes asinvalid(thev850loadandv850cmptests that flagged this).Fix
Match the requested cpu against the available
LanguageDescriptions and, when the requested endianness has no spec but the opposite one does, use the one that actually exists. When the requested endianness is available the result is unchanged, so little-endian hosts behave exactly as before (no behavior change there).Verification
This is the path your big-endian CI exercised in #389, so the
extras/analysis_ghidrav850load/v850cmpcases that producedV850:BE:32should go from failing to passing once CI runs on a big-endian runner. I diagnosed it from the failing trace and the language-resolution logic; happy to adjust if you'd prefer a stricter match (e.g. also keying on variant).