Clamp same-start functions to Ghidra map boundaries - #236
Closed
hedgeg0d wants to merge 1 commit into
Closed
Conversation
Author
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.
When a Ghidra CSV and the analyzer heuristics both produce a function at the same start address, the analyzer's wider span wins. Both names are auto-generated on stripped retail binaries (sub_ vs FUN_), so the merge comparator falls through to the larger end, and the authoritative-boundary pass skips auto names entirely. The result is that Ghidra's accurate boundaries never override the heuristic spans, and data blobs inside those spans get decoded as instructions.
Measured on Katamari Damacy (SLUS_210.08): 893k spurious decode errors with the Ghidra map loaded, 0 after this fix.
The change records the CSV end for every map start and uses it as the authoritative end, regardless of the auto-generated name. The analyzer fallback-only starts are still removed when they are not in the map.
Added a regression test that builds a minimal ELF where the JAL-fallback scan widens a function span, then checks the Ghidra map end clamps it.