LoginSignup
0
0

More than 3 years have passed since last update.

Linux で, 複数 .a, .so のどこに C++ シンボルが定義されているか調べる

Posted at

背景

llvm や tensorflow など, たくさん .so, .a などがあるプロジェクトで, どのライブラリにどのシンボルが定義されているか調べたい(リンクで必要なライブラリをリストアップするなど用).

環境は Linux とする.

方法

こんな感じになりました.

$ find ./ -name "*.a" -print | xargs nm -A | c++filt | grep -e 'tensorflow::GraphDef::~GraphDef' | grep T
  • find でまずはファイルを列挙
  • xargs でそれぞれのファイルに対して nm をよぶ. このとき -A をつけておくとファイル名を表示してくれる
  • c++filt でシンボルのデマングルを行う
  • あとは grep し, シンボルが T になっているものを探す(T = 実体が定義されている)

TODO

  • シンボルが strip された .a or .so だと動かない. この場合readelf あたりでいけるか?
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0