7

我正在努力使用正确的命令来执行以下操作:

查找所有包含特定符号的共享库 (*.so)。

这是我尝试过的:

find -iname '*.so*' -exec nm {} \; | grep -H _ZN6QDebugD1Ev

上面给出了一些找到符号的输出,但没有查明出现符号的文件名。我给 grep 告诉它打印文件名的任何标志都丢失了,因为 grep 是从 stdin 提供的。

(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):0015e928 T _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev
(standard input):         U _ZN6QDebugD1Ev

另一种尝试:

find -iname '*.so*' -exec nm {} \; -exec grep _ZN6QDebugD1Ev {} \;

这是行不通的,因为这两个 exec 是完全独立的。

我应该怎么办?

4

1 回答 1

13

Pass the "-A" option to nm which will prefix its output with the filename. Then just grep for the symbol you're interested in, for example:

find -iname '*.so*' -exec nm -A {} \; | grep _ZN6QDebugD1Ev
于 2015-04-20T22:48:55.923 回答