Skip to content

Resolve sleigh language id by the processor's available endianness#391

Open
Scottcjn wants to merge 1 commit into
rizinorg:devfrom
Scottcjn:fix-be-sleigh-endian
Open

Resolve sleigh language id by the processor's available endianness#391
Scottcjn wants to merge 1 commit into
rizinorg:devfrom
Scottcjn:fix-be-sleigh-endian

Conversation

@Scottcjn

Copy link
Copy Markdown

Fixes #389.

Problem

SleighIdFromSleighAsmConfig builds the language id as proc:(bigendian?BE:LE):bits straight 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 as invalid (the v850load and v850cmp tests 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_ghidra v850load / v850cmp cases that produced V850:BE:32 should 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).

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.
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.

3 tests failed on the big-endian machine

2 participants