How to find function from lib .so files?

mrgloom picture mrgloom · Aug 24, 2016 · Viewed 9.4k times · Source

I can print list of exported function of one *.so file like

nm -C lib/libopencv_ml.so

and then find my function like

nm -C lib/libopencv_ml.so | grep myfunction

but when I want to find function from all .so files how to determine which .so contain my function?

This just print all entries of function but I need to know from which .so file it appear.

nm -C lib/*.so | grep cvSetZero

Seems -H option also not helped. -H, --with-filename print the file name for each match

nm -C lib/*.so | grep -Hn cvSetZero

Generate output like:

(standard input):98:                 U cvSetZero
(standard input):796:                 U cvSetZero
(standard input):2564:00000000000b2540 T cvSetZero
(standard input):8673:                 U cvSetZero
(standard input):12233:                 U cvSetZero
(standard input):15503:                 U cvSetZero
(standard input):17460:                 U cvSetZero
(standard input):18727:                 U cvSetZero
(standard input):20865:                 U cvSetZero

Answer

mrgloom picture mrgloom · Aug 24, 2016

I found solution

nm -C -A lib/*.so | grep cvSetZero

It produce this kind of output:

lib/libopencv_calib3d.so:                 U cvSetZero
lib/libopencv_contrib.so:                 U cvSetZero
lib/libopencv_core.so:00000000000b2540 T cvSetZero
lib/libopencv_highgui.so:                 U cvSetZero
lib/libopencv_imgproc.so:                 U cvSetZero
lib/libopencv_legacy.so:                 U cvSetZero
lib/libopencv_ml.so:                 U cvSetZero
lib/libopencv_objdetect.so:                 U cvSetZero
lib/libopencv_video.so:                 U cvSetZero