Repository navigation
fix(ghidra): verify dense jump tables on an optimized fixture - #1374
Merged
morluto merged 1 commit intoOct 9, 2026
Merged
Conversation
The dense jump-table oracles (inspect-native-api CLI and the analyze_function dossier) ran against the -O0 debug fixture, which assumes the host compiler lowers dense switches to tables at -O0. GCC 16 and later expand them as compare chains instead, so on those hosts the lane rejected a correct provider and Ghidra build with empty jump_tables. Build the same inventory source once more at -O2 as a dedicated jump-table variant, run both strict dense oracles there, and keep the debug dossier at its complete generic shape. The dedicated switch lane already compiles at -O2 for the same reason.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Owner
|
Reviewed 9c49bd3 and found no actionable issues. The optimized fixture receives both dense-table checks, while the debug fixture retains its existing coverage. I verified compilation, the strict dossier check with real Ghidra 12.1.4 on macOS ARM64, and CLI output containing 40 mappings and one default target. I did not rerun the full host lane or the Linux GCC 16 reproduction. Thanks for the fix and the detailed reproduction and verification evidence! |
This was referenced Oct 9, 2026
darsrc
pushed a commit
to darsrc/rea
that referenced
this pull request
Oct 10, 2026
…o#1374) The dense jump-table oracles (inspect-native-api CLI and the analyze_function dossier) ran against the -O0 debug fixture, which assumes the host compiler lowers dense switches to tables at -O0. GCC 16 and later expand them as compare chains instead, so on those hosts the lane rejected a correct provider and Ghidra build with empty jump_tables. Build the same inventory source once more at -O2 as a dedicated jump-table variant, run both strict dense oracles there, and keep the debug dossier at its complete generic shape. The dedicated switch lane already compiles at -O2 for the same reason.
10 tasks done
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.
Summary
The real-Ghidra host lane demanded dense jump-table evidence from the
-O0debug fixture. GCC 16 and later lower dense switches to compare chains at-O0(empirically:rea_ghidra_inventory_dense_switchcompiles to acmpl/je/jatree with no indirect jump), so on those hosts both dense oracles failed against a correct provider and a correct Ghidra 12.1.4 analysis. The lane now compiles the same inventory source once more at-O2as a dedicatedjump-tablefixture variant and runs the strict dense oracles there; the debug fixture keeps its complete generic dossier shape and all its-O0-specific oracles.Problem and expected behavior
Smallest trigger:
npm run verify:ghidrawithcc= GCC 16.2 (reproduced on Kali rolling, glibc 2.43, node 24.19, Ghidra 12.1.4, JDK 21). Two sites rejected the run:scripts/verify-real-ghidra.mjsverifyNativeApiCli:The shipped inspect-native-api CLI did not preserve complete dense jump-table outputwith"jump_tables": []from the-O0debug build.scripts/verify-real-ghidra-assertions.mjsassertDenseSwitchDossier(viaverifyDebugFunctionOperations):Ghidra dense jump-table completeness drifted: [].Violated invariant: the dense-table oracle must observe a fixture that actually contains a table. Switch lowering is a host-toolchain decision:
-O0compare-chain expansion (GCC 16) versus table expansion (older GCC at-O0, and all tested compilers at-O2, where the same source produceslea table(%rip); movslq (%rdx,%rdi,4); add; jmp *%rax). The dedicatedverify:ghidra:switchlane already compiles at-O2for exactly this reason; the inventory lane was the inconsistent one.Change and scope
scripts/verify-real-ghidra.mjs: buildrea-ghidra-inventory-jumpfrom the same source with-O2 -g -fno-inline(plus the lane's-fno-pie -no-pieon ELF), verify it as thejump-tablevariant, routeverifyNativeApiCliand the newverifyJumpTableDenseSwitchprobe to it, and report it in the fixtures list andnative_api_clisummary.scripts/verify-real-ghidra-function.mjs:verifyDebugFunctionOperationsnow asserts the dense-switch dossier's complete generic shape (address, assembly, multi-block) on every platform, since-O0codegen is toolchain-dependent; the new exportedverifyJumpTableDenseSwitchcarries the strictassertDenseSwitchDossieragainst the optimized fixture.Not included: no product, bridge, provider, or contract changes; the debug fixture's build flags are untouched; cross-format and AArch64 lanes are unchanged (
crossArm64Elfkeeps its existing-O2cross builds).Contract and boundary impact
Evidence and regression coverage
GHIDRA_INSTALL_DIRat Ghidra 12.1.4 and JDK 21:jump_tables: []from the-O0debug fixture), and after that is bypassed, again at the dossier oracle.ok: true, four fixtures (debug, stripped, type-layout, jump-table),native_api_cli.mappings_returned = 40, the dense default-target oracle verified (mov eax, -1at the default address),residual_unknowns = 0, andcleanup: complete.-O0shows zero indirect jumps through tables in the disassembly while-O2shows the 40-entry relative table; the debug fixture's generic dossier assertions still pass at both optimization levels.