-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
PLT stub names not being resolved properly #17523
Comments
Added plt_fixup.py to bandaid the issue reported @ radareorg/radare2#17523 Will only work on ARM. Tried to make it generic but aav strikes again. Also added r2p_helpers.py, which provides some function decorators for r2pipe scripts. They will wrap a function and automatically save & restore certain parts of the r2 state. For example, using the @preserve_position decorator will return you to the original file position after the function runs.
@XVilka Yep again the same bug, i am writing a python script to see if an analysis cmd could fix this |
You may find this script useful maybe: https://github.com/haystack-ia/radare-funhouse/blob/master/plt_fixup.py This is how I bandaid-ed the problem for my own analysis. I don't have an architecture-agnostic solution though. |
@haystack-ia Yep your analysis is a good entry Thanks |
If you want to look at the implementation. |
Wonder if this was fixed |
yep its fixed |
@trufae is it in 5.8.8? Cannot find it. |
Yes. There are tests too |
What commit on I looked at the diffs of the commits that GH list above as referencing this issue, but I don't see their proposed changes in For example, in |
cc: @trufae |
its referenced in the issue already |
@trufae Where? I can't find it :( |
I'm quite sure that there is no commit on |
@trufae Did you have time to take a look at the above comment? I think you forgot to merge the fix commits to master. I'm not joking. There's no occurence of the string I found the commit that adds the test (e219383). But there's no commit that adds a fix. I think the test passes by chance. |
git log shows that this test was marked as FIXED in 93dbc62 why the string "is_internal" should matter? can you share the library you are building instead of sharing the steps? because i'm compiling it on an ubuntu-x64 (because i assume this is your environment) and what i get is exactly your output, and if you look at the code generated by GCC there's no direct call from add to add2. but instead, it's calling a stub that calls add2. this stub depends on a reloc to be patched, so i'm afraid the callgraph is correct and the elf parsing is also correct. But there are still other issues to be fixed in the elf parser as well as in the relocs patching like this one: #21117 but i dont think that's the same issue as the one you are refering |
you are indeed correct that the commit you are referencing was not merged. i just pushed a pr with the rebased change to see what happens. but im unsure of the reason the change wasn't included. |
ive improved the autonaming implementation to make the callgraph look better here. #23806 |
By the way, regarding the example with In the sense that an internal call to a public symbol By the way, am I right to expect that the public callgraph should contain nodes for both In my understanding, the global callgraphs should show all available symbols (== potential "entrypoints" from external code) in the library (either local or public) and any calls they make. |
i think the callgraph needs some love. and part of it would be to add support for tailcall optimization rendered as nodes. right now iirc it's only following CALLs, but not those jumps. i think you should open a separate issue to track this, but the fix should be relatively simple in case you want to contribute that can be a good easy issue to tackle. btw, ive added the add.so in the testbins repo . im using it for testing the autonaming and the callgraph issue you mentioned. i can try to find some time to do it later this week or so, but rn im busy with other fronts |
I'm trying to verify that I've understood what the expected output of Should the global callgraph also contain nodes that don't make calls? (in this case |
when a function just calls another function and returns the result of that other function, compilers do this "tailcall" optimization, which basically means, replacing a CALL with a JMP and remove the the code that constructs the callgraph is just following CALL instructions for that, it may be also taking into account those tailcalls jumps. so yeah, i think that the graph should look like this at the end: flowchart TB
add --> fcn.1050
fcn.1050 -->add2
add2
|
Ok, but even when there's no tailcall, (i.e.,
Compile:
In this case, Which faces the exact same problems:
|
Work environment
Expected behavior
When a function exported by a shared object file is called from within that shared object file, the function name for the stub in the
plt
section should be named properly.Example: in
libcurl
, the functionCurl_getaddrinfo_ex
is called from the functionCurl_ipv4_resolve_r
. That function call should appear assym.imp.Curl_getaddrinfo_ex
.Actual behavior
Instead of
sym.imp.Curl_getaddrinfo_ex
, the function is flaggedfcn.000074fc
. This makes analysis a bit painful.The address that the
plt
stub points to is correctly identified asreloc.Curl_getaddrinfo_ex
, so the relocation is being correctly ID'd (I've also double-checked with Ghidra).Steps to reproduce the behavior
Asciinema: https://asciinema.org/a/o4UkBFPskH5rhJZ8lwjuNTKJC
Representative file here: libcurl.zip
Here is a screenshot from ghidra showing the same address (though, interestingly, it's mapped at 0x174fc instead of 0x74fc):

The text was updated successfully, but these errors were encountered: