Quantcast
Viewing all articles
Browse latest Browse all 22157

Is it possible to get clang or gcc to generate a list of global variables, their types and addresses within a compiled executable? [duplicate]

I have seen in the past output from a compiler where it would "unzip" nested global structs and variables into a file, along with their variable types and size - this allowed us to give human readable output later for a given binary instead of addresses of functions etc, and also allowed us to reach in and directly modify or read values in our firmware from our simulator at runtime.

Is this at all possible to do with clang or gcc? I'm talking about output like the following, where globalStructVariable is a struct with nested structs and variables, and we also have functions mixed in:

LOCATION                 VARIABLE NAME                                   TYPE
0x2000000                globalStructVariable                            struct
0x2000002                globalStructVariable->blah                      uint
0x2000522                someFunction                                    function

Has anyone here seen this before, and know how to implement it?


Viewing all articles
Browse latest Browse all 22157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>