如何读取NM命令:NM选项-T和-U(未定义)是什么意思

How to read nm commands : What does nm options -T and -U (undefined) mean?

本文关键字:NM 未定义 意思 是什么 命令 何读取 读取 选项      更新时间:2023-10-16

我有我怀疑从'libsimint.a'的链接错误。

Linker messages (if any) follow...
/home/.../simint/lib/libsimint.a(shell.c.o): In function `simint_copy_shell':
shell.c:(.text+0x126): undefined reference to `__intel_ssse3_rep_memcpy'
/home/.../simint/lib/libsimint.a(shell.c.o): In function`simint_normalize_shells':
shell.c:(.text+0x4e3): undefined reference to `__svml_pow4'

我尝试了NM命令来弄清楚它:

>> nm libsimint.a |grep __intel_ssse3_rep_memcpy
U __intel_ssse3_rep_memcpy
>> nm libsimint.a |grep simint_copy_shell
0000000000000090 T simint_copy_shell

根据我所理解的(在NM MAN的帮助(中,Simint_copy_shell函数在代码中提到,但是__intel_ssse3_rep_memcpy在其他一些库中未定义我们的libsimint。有人可以验证这一点还是添加任何澄清?谢谢

(我正在使用ICPC编译的GCC编译和链接大型代码。(

U表示"未定义" - 对象具有对符号的引用,但没有定义

T表示文本段中的全球定义 - 对象定义和导出符号

手册页(man nm(列出了所有这些类型代码。

ELF符号是对某些类型的数据或代码(例如全局变量或函数(的符号引用。&quot nm&quot(名称Mangling [1](允许我们打印出精灵文件中的所有符号。在其默认调用中," nm&quot"的输出包含三列,对于每个符号,它显示以下信息,其中包含以下相同顺序:

  • 符号值:在十六进制格式中默认情况下。
  • 符号类型:我们可以看到下面的一些符号类型。如果符号类型是小写,则符号通常是局部的,如果大写,则符号为全局(外部(。
    • 'B&quot/&quort" b&quot:符号在BSS(块启动符号(数据部分。
    • 'd&quot/&quot" d&quot:符号在初始化的数据部分中。
    • 'r&quot/&quot" r&quot:符号仅在读取数据部分中。
    • 't&quot/&quot" t&quot:符号在文本(代码(部分中。
    • ; n&quot:符号是调试符号。
    • '
  • 符号名称:符号名称。版本字符串显示为符号名称的后缀。可以将版本字符串附加到>'@@&quort'>或>&quot @@&quort&quort&quort&quort&quort&quort&quort。一个版本的字符串附加了>'@@&quot'表示符号的版本;如果该版本字符串也代表该符号的默认版本,则由 @@ @@&quot'附加,这意味着当该符号被调用而无需明确指示版本时使用该符号的版本。

实用程序的示例输出" nm&quort":

    $ nm 'example_program'
    000005d4    t    print_error_message
    --------    U    strlen@@GLIBC_2.4
    --------    U    syscall@@GLIBC_2.4
    00011008    b    device_list
    000005f9    t    send_message_to_device
    000006e5    T    main
    ...

有关更多信息,您可以参考NM [2]

的人页面