Using nm , you can enumerate characters defined in binary format, and the --defined-only key ignores undefined references.
Option 1: find
In one team:
find $path -name \*.a -exec bash -c "nm --defined-only {} 2>/dev/null | grep $symbol && echo {}" \;
where $path is the root of the file tree containing the binaries, and $symbol is the name of the character you are looking for.
Option 2: find + GNU parallel
Running nm for all files may take some time, so it may be useful to process find results in parallel (using parallel GNU):
find $path -name \*.a | parallel "nm --defined-only {} 2>/dev/null | grep $symbol && echo {}"
Option 3: fd
And finally, my favorite. Using the fd tool, which has a simpler syntax than find , is usually faster and processes the results in parallel by default:
fd '.*\.a$' -x bash -c "nm --defined-only {} 2>/dev/null | grep $symbol && echo {}"
Simple test
Search for the gz_write character in /usr/lib on a laptop with i7-6560U:
find takes about 23 secondsfind | parallel find | parallel find | parallel find | parallel takes about 10 secondsfd takes about 8 seconds
m-pilia
source share