MadHatter
MadHatter

Reputation: 351

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

I have linking errors that I suspected from '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'

I tried nm commands to figure it out:

>> 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

From what I understand by the above (with help of nm man), simint_copy_shell function is mentioned in code but __intel_ssse3_rep_memcpy is not defined in some other libray our libsimint is compiled with. Can anybody verify this or add any clarification? Thanks

(I'm compiling and linking a large code using gcc, that was compiled with icpc but instead.)

Upvotes: 4

Views: 7744

Answers (2)

Eray Xx
Eray Xx

Reputation: 313

ELF symbols are symbolic references to some type of data or code such as a global variable or function. "nm" (name mangling [1]) allows us to print out all of the symbols in an ELF file. In its default invocation "nm"s output includes three columns and for each symbol it shows following information with the same order given below:

  • Symbol Value: In hexadecimal format by default.
  • Symbol Type: We can see some of the symbol types below. If the symbol type is lowercase the symbol usually is local, if uppercase the symbol is global (external).
    • "B" / "b": Symbol is in the BSS (Block Starting Symbol) data section.
    • "D" / "d": Symbol is in the initialized data section.
    • "R" / "r": Symbol is in a read only data section.
    • "T" / "t": Symbol is in the text (code) section.
    • "N": Symbol is a debugging symbol.
    • "U": The symbol is undefined
  • Symbol Name: The symbol name. Version strings are displayed as a suffix to symbol name. Version string can be appended with "@" or "@@". A version string appended with "@" represents the version of the symbol; if that version string represents also the default version of the symbol then it is appended by "@@", which means that version of the symbol is used when that symbol is invoked without indicating a version explicitly.

Example output of the utility "nm":

    $ 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
    ...

For more information you can refer to man page of nm [2]

Upvotes: 0

Chris Dodd
Chris Dodd

Reputation: 126338

U means "undefined" -- the object has a reference to the symbol but no definition

T means globally defined in the text segment -- the object defines and exports the symbol

The manual page (man nm) lists all these type codes.

Upvotes: 7

Related Questions