How to check if a macro exists in an object file in C?

前端 未结 2 1556
粉色の甜心
粉色の甜心 2021-01-15 20:26

For example, I define a macro:

#ifdef VERSION
 //.... do something
#endif

How can I check if VERSION exist in my object file o

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 21:23

    The following command displays contents of .debug_macro DWARF section:

    $ readelf --debug-dump=macro path/to/binary
    

    or

    $ objdump --dwarf=macro path/to/binary
    

    You can also use dwarfdump path/to/binary, but it's not easy to leave only .debug_macro section in the output.

提交回复
热议问题