How I can find function in shared object files using objdump and bash functions in linux?
32,182
Solution 1
nm
is simpler than objdump
, for this task.
nm -A *.so | grep func
should work. The -A
flag tells nm
to print the file name.
Solution 2
You can use also use,
find <path> -name "*.so" -exec nm {} \; | grep func1
Comments
-
G-71 almost 2 years
I've got a folder in linux, which is contained several shared object files (*.so). How I can find function in shared object files using objdump and bash functions in linux?
For instance, the following example is found me function
func1
in mylib.so:objdump -d mylib.so | grep func1
But i want to find
func1
in folder which is contained shared object files. I don't know bash language and how to combinate linux terminal commands. -
ugoren about 12 years
grep func1 nm {}
?? Do you meannm {} | grep func1
? -
Deepak about 12 yearsYou would run nm | grep func1, the execution is from left to right if you are using it without exec. But with exec the execution is from right to left and {} specifies the input from the find command, so the above command means 'run the grep on the result of the nm for all the files from find'.
-
ugoren about 12 yearsI tried your line - it just doesn't work. It just runs
grep func1 nm xxx.so
per file, which searches forfunc1
in a file called "nm" and in the binary (without running nm). -
jørgensen about 12 yearsYou need the
-D
option as well to actually look in the list of exported symbols. -
ugoren about 12 years@jørgensen, it isn't clear from the question whether he wants an exported function. Maybe he wants to know what library he needs to rebuild after changing a function.
-
Deepak about 12 yearsYes, you are right. I did not notice that too closely last time. I have edited my answer.