-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Wrong output of getCallingFunctions and getCalledFunctions #7532
Comments
This is likely a difference between Ghidra 11.2 and Ghidra 11.3. The behavior of getCallingFunctions and getCalledFunction was corrected. In your example, does _start actually call main? Or does _start call _libc_start_main and pass _libc_start_main the address of _main as an argument? |
Indeed it is passed as an argument, but the graphs in both ghidra gui and IDA show main as a "child" of _start. |
In the function call tree, the "link" icon (immediately to the left of the "5") controls whether non-call references are excluded. Toggling that should determine whether main appears as an outgoing reference for start. For a call tree entry, the link icon means that the reference is not a call reference. The purple f for _libc_start_main means that it is a call reference. To re-create the old behavior, you could make a method in your script based on the implementation of getCallingFunctions Line 2731 in aaf910b
Basically, you iterate over all references whose "from" address is in the function's body. If the "to" address of a reference is the entry point of a function, add the referenced function to a set. You would omit the check on line 2748, which restricts to call references. |
Ok, that sounds nice, I'll look into it. Thanks a lot! |
Describe the bug
I am using the methods getCallingFunctions and getCalledFunctions to create a callgraph of the functions and it seams like their output is wrong.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I have this example, using a dummy executable that prints a string, and by using the methods above and creating a dictionary representing the hierarchy i get:
Issue is that _start calls main, which the old version outputs correctly, but not the new one.
Environment (please complete the following information):
Additional context
I have double checked with the ghidra gui and also IDA and can confirm that _start calls main.
The text was updated successfully, but these errors were encountered: