-
Notifications
You must be signed in to change notification settings - Fork 20
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
pltStubSymbols
's treatment of the .plt.got
section miscalculates the number of PLT stubs
#375
Comments
Perhaps a silly question: Why doesn't [EDIT]: Perhaps this is just a hard problem, as indicated by this comment in the angr source code |
Your EDIT hits the nail on the head: the The only reason our heuristics for detecting PLT stubs in the |
Aren't PLT stubs highly stylized though? I have never tangled with the x86_64 ones but back in 386 days they had a very definite layout. also, even failing that it seems like it should be possible to extract all the jump targets (whether they're absolute like in your example or the result of relocations) and join that list (in the relational sense) to the dynamic symbol table. maybe I'm missing something... |
You are correct. While it's not straightforward to identify PLT stub addresses as I had hoped, they do tend to exhibit some predictable layout patterns. As such, it should be possible to identify them by performing some modest analysis of the assembly code. Reading the code which identifies PLT stubs in The current approach in Macaw does in fact assume that each PLT stub is always the same size. This allows us to get away with a very simple, heuristics-based implementation of PLT stub detection in Macaw, but the downside is that these heuristics don't work for every binary (see the caveats mentioned here). If we improve our PLT stub analysis, I'd hope that we can cover these cases as well.
Yes. If we improve our analysis, then I suspect that we will need to do something quite like this. |
If you compile this simple C program using
clang
:You'll see that it has exactly one PLT stub in its
.plt.got
section:However,
pltStubSymbols
claims that it has more PLT stubs than this! Here is what you see if you debug-print the output ofpltStubSymbols
on this program:What is going on here?
Ultimately,
pltStubsSymbols
consults the.rela.dyn
section to figure out what the contents of the.plt.got
are. In this case,.rela.dyn
contains five entries:But only one of them (
__cxa_finalize
) is actually a PLT stub. However, their presence throws off the heuristics thatpltStubSymbols
uses.I'm not quite sure what to do about this. It would be convenient if there were a convenient mechanism to distinguish
__cxa_finalize
apart from the other entries in.got
, but I'm not sure what that would be. My first inclination was to filter out any symbols that aren't function symbols, but even that isn't enough, as__libc_start_main
is also a function symbol:It's also tempting to think that the combination of
FUNC
andWEAK
would uniquely identify PLT stubs, but that is also not true. If you call a function via a function pointer, e.g.,Then
malloc
will also be called via a PLT stub, but its function symbol will beFUNC
andGLOBAL
.The text was updated successfully, but these errors were encountered: