1

たとえば、次のマクロを定義します。

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

VERSIONオブジェクトファイルに存在するかどうかを確認するにはどうすればよいですか? で逆アセンブルしようとしobjdumpましたが、マクロの実際の値が見つかりませんでしたVERSIONVERSIONMakefile で定義されています。

4

2 に答える 2

6

-g3のオプションを付けてコンパイルしてみてくださいgcc。マクロ情報も生成された ELF ファイルに保存します。

この後、出力実行可能ファイルまたはオブジェクトファイルでマクロを定義した場合MACRO_NAMEgrep例えば、

$ grep MACRO_NAME a.out # any object file will do instead of a.out
Binary file a.out matches

または、試すこともできます。

$ strings -a -n 1 a.out | grep MACRO_NAME

 -a Do not scan only the initialized and loaded sections of object files; 
    scan the whole files.

 -n min-len Print sequences of characters that are at least min-len characters long,
    instead of the default 4.
于 2012-04-11T09:01:48.433 に答える