[fix] Preserve typed external data references in decompiler#9241
Open
sampletext32 wants to merge 1 commit into
Open
[fix] Preserve typed external data references in decompiler#9241sampletext32 wants to merge 1 commit into
sampletext32 wants to merge 1 commit into
Conversation
c20755d to
f90694e
Compare
Author
|
rebased onto latest master |
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.
Hi.
While I was reversing an old game engine consisting of several dlls I've encountered an annoying quirk.
Ghidra does a decent job of creating thunks, crossreferencing them etc. But dlls (and not only them) can actually export and import variables, and unfortunately Ghidra did pretty bad there.
Essentially what I've encountered was a giant vtable of math functions focusing on SSE and processor support, and that vtable is heavily used outside of the declaring dll. I had to manually comment and override signature for all callsights. Pretty annoying huh.
The 12.1 version produces this:

Setting a type for this global did absolutely nothing.
So I spun up codex with the research task.
Turns out, while Ghidra did allow setting a datatype to the global, it never passed the datatype to the decompiler engine.
After a few iterations I got this:

Now I just have to create like a hundred funcdefs, but that's another story.
I made sure to follow the contribution guide, checked the code (it seems reasonable enough to me), compiled locally on windows, and stripped the pr of everything unrelated.
Open to comments and suggestions)
relates to #2206, #5711
below is ai description
Summary
Motivation
Imported external data references can carry useful user-applied types on the local pointer data item, while the ExternalLocation remains untyped. Without passing that type through, the decompiler falls back to generic code-pointer casts for imported function tables.
Validation
.\gradlew.bat assembleAll -x ip