How do I find where a symbol is defined among static libraries

前端 未结 3 1705
无人共我
无人共我 2021-02-01 23:22

Suppose you work with a codebase comprising several tools and libraries and you want to port (or resurrect) some component within such codebase but any clue about where symbols

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-01 23:36

    Using nm's --defined-only switch is helpful here since it will remove the undefined references. Below is a csh script that may be useful to others.

    #!/bin/csh
    #
    #recurse from current dir and output name of any .a files
    #that contain the desired symbol.
    echo "Search for: $1"
    foreach i (`find . -name '*.a'`)
        nm --defined-only $i | grep $1
        if ($status == 0) then
            echo $i
        endif
    end
    

提交回复
热议问题