I need to determine the value of a specific macro the binary was compiled with.
The file is a Linux shared library file.
Is it possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Given that macros are handled by a preprocessor, even the actual compiler is not aware of them. The only option is to reverse engineer the cod, find the place where you know the macro is used and extract the value from there.
Edit: I’ve just checked DWARF specification, the standard defines
.debug_macinfosection especially to store debug info about macros, this section contains aDW_MACINFO_definerecord for each defined macro.So, if you have a debug version of the library, you can try to use
dwarfdump -morreadelf --debug-dump=macroto extract this info.However: I’ve tried it on a few libraries in my system, and none of them contained any macro records. By default
gccdoesn’t emit them, the library has to be compiled withgcc -g3(the switch increases the debug info level). This is sort of bad news for you, I suppose.