-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BSim 'Compare Matching Callees': {...} is outside the current listing's view
#6159
Comments
The thunk analyzer should have picked that up and marked as such. Ghidra/Processors/AARCH64/data/aarch64-pltThunks.xml I don't know why this is not in the pattern/ directory like other processor modules, so there might be an analyzer you have to enable for |
The only analyzer I see that seems related is I have found a related issue here, but it isn't clear to me what I'm missing. I tried seeing if this analyzer is available as a one-shot option or even running auto-analysis twice, first with it disabled and then with it enabled, but it still has no effect. |
Upon closer inspection, it seems that the analyzer attempts to run first (coincidentally, it's also first in alphabetical order), when the PLT section has not yet been disassembled. However, it seems the analyzer requires the PLT section to be disassembled first. Lines 57 to 63 in e73d208
Is there any way for me to control the analyzer run order so as to allow this to function normally? |
As @mumbel pointed out, the above function should have been identified as a thunk which hopefully would remov it from consideration on your first navigation. Because of this issue the comparison panels are out-of-sync, one is showing an unidentifed thunk which should be skipped over if it been marked as such. What section is the address Could you please try to manually establish the thunk at |
Let us know if you are running in a development enviorment where you could tryout a code change. |
This does not seem to have an effect. The comparison does not descend past the thunk even when it is declared as such. I removed the label, then
I can set one up. The instructions in the README seem simple enough. |
Does declaring the function as a thunk possibly require a complete BSim |
@fkelava For some reason your images are private and I get an error when I click on them to show them in a larger readable form. Do you have default enablement for all your analyzers? I am assuming they all ran properly. Is this a readily available binary we could try analyzer ourselves? |
Specifying the thunked function can be done without additional analysis. Which file was ingested into BSim? The DLL or the ELF AARCH64 binary? If it was the ELF binary it is possible that it would need to be updated in the BSim database to update the function callgraph. |
Issue seems to be resolved |
It is also curious why the |
This would seem to imply the ELF binary is the one which was ingested into the BSim database where the callgraph was retained. This callgraph is stale since it will still identify the thunk as the called destination. The intent is that thunks shuold be ignored in a callgraph. The BSim data would need to be updated, although we should probably understand why the thunk was not created during analysis. Our access to a similar binary is key to us resolving this. Is this binary from a AARCH64 Linux distribution you could provide a link to? |
I have set one up in case you would like me to try any changes.
Yes. However, see comment above - I have noticed the Perhaps the Nintendo Switch binary loader being used violates the analyzer's assumption that If that is indeed the case, I will raise this issue with them instead. My apologies for not realizing this sooner.
As I've noted above, this is a commercially available game; "readily available" may therefore be a stretch.
The ELF binary. Just in case, I decided to completely regenerate the signatures after checking in a version where the thunk is marked, commit them, then try again. This, too, does not resolve the issue. I have just noticed that I can continue using
Yes. It seems to be as devoid of markings as |
I will attempt to find a binary which exhibits the same issue that I can freely share and attach it as soon as I can. |
Okay, I've worked it out- sort of. Your comments finally led me to the right idea.
So that merits no further investigation- I will raise that issue with them instead. What still concerns me is that even a manually set thunk, after a full regeneration of signatures, did not resolve the issue in the function comparison; even if the thunk was not detected as such by the analyzer due to the aforementioned situation, should it not have been fixed by me manually declaring the function a thunk? |
Did not realize this was a game binary - they tend to be rather non-conforming and I don't have much experience with them. I imported an AARCH64 binary from an Ubuntu distribution and the Nintendo Switch may rely on hardcoded relocation processing within there |
I am not really familiar with how the BSim comparison panels are managed and how they handle navigation. However, as I mentioned above, I suspect the callgraph data that is stored within the BSim DB is not in-sync with the thunk change you applied manually. BSim still believes it is a valid called function - while thunks would not be contained with the callgraph. |
Unfortunately, the Nintendo Switch Loader is out of our control. It would be its responsibility for handling all relocations properly - which it may without marking them up. Never having used it, it is difficult to say why the analysis does not properly establish the thunks within the .plt section. You could attempt to debug the |
Yeah, that's fair. It took a few of your comments for me to realize it was a loader fault; thank you for the time regardless. Apologies that I didn't figure that one out sooner. In the event that I "fix" or at least adapt the PLT analyzer to my use-case, I will update you on whether that resolved the comparison issue. In the event that it still occurs, I'll update you with a (hopefully) better repro. |
Does your use case currently disable many of the analyzers? If so, did you try to run any of the analyzers as a one shot (or re-analyze with these enabled) to see if the identify the thunk(s)? i.e., |
It does not. I would hazard a guess that if it did, this could be resolved by simply re-running it once initial auto-analysis completes. Could I make a code change to enable one-shot capability for it? I have a build environment set up. |
Is the analyzer enabled in the list of auto-analyzers? If it runs you can try to debug since it should get a pattern match on the thunk in question. The one-shot simply indicates if it will appear in GUI menu. It can always be forced to run via the API : |
I've continued investigating this. I've managed to resolve the issue where the thunks are not marked as such. However, even once the
Here is a link to GZF exports of both executables. A comparison that exhibits the issue is To clarify and spare you the effort of re-reading the thread, when Please let me know if you need the files uploaded in some other place or way, or if anything is missing. If you require any output from my BSim server, please let me know. I've also updated to 11.0.1, to no avail. |
We will look into the comparison panel navigation concern. |
Fixed by 5ee04b2 |
Describe the bug
I apologize in advance for the unclear title and lengthy explanation: I lack the expertise to describe this issue succinctly.
I am currently reversing two binaries. One is a 32-bit executable, the other an ARMv8 64-bit (specifically, Nintendo Switch) binary, but they're both compiled from almost identical source. The latter has unstripped function names, while the former does not. I am attempting to use BSim to match functions between the two.
Consider the following two matching (minus MSVC Control-Flow Guard in the former) functions. I have manually identified them as identical, and BSim agrees.
Raise a comparison between these two functions, then try raising 'Compare Matching Callees' for the first pair of callees-
FUN_009237e0
andrcdtTm2Init
. See attached images and function listings.These are the same function, but in the ARM executable there is another stub in-between. However, I cannot actually navigate past the stub call because
"710054aff0" is outside the current listing's view.
This is proving quite the blocker, because every call in the ARM executable has this prologue of sorts between the base function and the actual "contents", so to say.I can circumvent this by having another CodeBrowser open and manually inspecting the function, but this adds quite a lot of hassle to the whole process. Is there any way 'Compare Matching Callees' can permit me to descend past this 'stub' and see the 'real'
rcdtTm2Init
(the one at710054aff0
) in this case?Expected behavior
'Compare Matching Callees` does not force me to stay at the same "level" in both listings.
Environment (please complete the following information):
Additional context
The executable in question is a commercially available game, Final Fantasy X/X-2 HD Remaster. I do not think it would be proper to share the executables in this case, so I hope the function listings suffice to explain the issue.
If I can provide any other relevant info, please let me know.
The text was updated successfully, but these errors were encountered: