When to use --dynamic option in nm

后端 未结 2 1866
谎友^
谎友^ 2021-01-31 10:28

Sometimes when I do nm on a .so file (for example, libstdc++.so.6), it says no symbols, and I need to use nm --dynamic. But for some other .so files, I can see the symbols with

2条回答
  •  面向向阳花
    2021-01-31 11:23

    You need to use --dynamic or -D option on a shared library if it is stripped and thus only contains a dynamic symbol table.

    You may want to use this option for other shared libraries to explicitly display the dynamic symbol table as this is the table that is consulted by the dynamic linker.

    The file utility indicates whether a shared library is stripped or not. Example:

    $ file /usr/lib64/libcrypt-nss-2.26.so
    [..] ELF 64-bit LSB shared object, x86-64 [..], not stripped
    $ file /usr/lib64/libxml2.so.2.9.7
    [..] ELF 64-bit LSB shared object, x86-64 [..], stripped
    

    Example for how the different symbol tables may contain different symbols:

    $ nm -D /usr/lib64/libcrypt-nss-2.26.so | wc -l
    39
    $ nm /usr/lib64/libcrypt-nss-2.26.so | wc -l 
    112
    

提交回复
热议问题