-
Notifications
You must be signed in to change notification settings - Fork 514
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
How to use this tool to retrieve global variables #385
Comments
Use https://github.com/eliben/pyelftools/blob/master/examples/dwarf_die_tree.py as the starting point. The example scrolls through all CUs and DIEs in the file; you'd have to write a condition that would identify a variable (start with Variables inside functions are not globals. I don't know if function scoped static variables qualify for your case. |
Thank you for your hint. I have tried to explore into DIE to assemble variables, but blocked by some variables with a mix of structure and array involving multiple recursion. |
function scoped variables are not my interest. My debuginfo seems containing only global variables defined outside the functions |
I take it, you are interested in datatypes, too. In general, spelling out the datatype of a C++ variable from DWARF data is a very tricky task. Between classes, templates, namespaces, typedefs, const-ness, and function pointers (where you have to spell out the type of each argument), it's a major pain. I have a semi-working piece of Python code that sort of spells the datatype for the subset of DWARF that is relevant to me, but it's a work in progress and it isn't public. |
Update: a version of that logic found its way into pyelftools proper. See It was tested on the small corpus of binaries that we have. Needless say, not nearly exhaustive. Also, it stops on typedefs (in line with what |
@Plyees is still an issue? |
I am looking to retrieve all global variables from debuginfo that is generated for C application under Ubuntu. Could anyone please kindly give me a hint?
The text was updated successfully, but these errors were encountered: