I would like to find the symbol "start" for example in all object files recursively down from the directory I'm in. I think I can use nm or readelf, but I'm new to shell and not understanding how to do this from the manual.
Asked
Active
Viewed 1,850 times
0
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164
Andrew Cina
- 67
- 4
-
1Is the symbol `start` a string (literal) used in the code? – ss_iwe Sep 20 '19 at 05:19
1 Answers
2
You could use something like this:
find . -type f \( -executable -o -name \*.o \) -exec nm -A {} + | grep start
This will find all executable files, or object files, and run nm -A on them, piping the results to grep.
You can adjust this to look for other files. For libraries (.so etc.) you should use nm -A -D (to list dynamic symbols). The -A option makes nm repeat the file name on every line, so that the filtered output is still useful.
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164