Linux nm view symbols in dynamic and static libraries

Source: Internet
Author: User

Lists the symbolic information in. O. A, including values such as symbols, symbol types, and symbol names. The so-called symbols, usually refers to defined functions, global variables and so on.

Use

NM [option (s)] [file (s)]

Useful Options:

    • -A prints the name of the object file in front of each symbol information;
    • -C output demangle the symbol name;
    • -D print dynamic symbols;
    • -L Print out the source file and line number using debugging information in object file;
    • -N is sorted by address/symbol value;
    • -U prints out those undefined symbols;

Common symbol Types :

    • A the value of the symbol will no longer change in future links;
    • B the symbol is placed in the BSS section, usually those uninitialized global variables;
    • D the symbol is placed in a normal data segment, usually those that have already been initialized in the global variable;
    • T This symbol is placed in the code snippet, usually those global non-static functions;
    • U This symbol is undefined and needs to be linked in from other object files;
    • W does not explicitly specify a weak link symbol, and the other object file with the link has its definition, otherwise it is specified with a system-specific default value.

Note the points:

    • -C is always available for C + + compiled object files. Remember that there are overloads in C + +? To differentiate between overloaded functions, the C + + compiler appends information such as function return values/parameters to the function name to form a mangle symbol, which, when listed with this option, does an inverse operation, outputting the original, understandable symbol names.
    • When you use-l, you must ensure that your object file has symbolic-mode information, which generally requires you to specify a-G option when compiling, see LINUX:GCC.
    • Before using NM, it is a good idea to use Linux:file to view the processor architecture of the object file and then use the corresponding cross-version of the NM tool.

Example

See the man page for more details. Here are some examples:

nm-u hello.o
displays undefined symbols in the hello.o and needs to be linked to other object files.
nm-a/usr/lib/* 2>/dev/null | grep "T memset"

Find out which library file defines the Memset function in the/usr/lib/directory.

transferred from:http://itech.cnblogs.com/

Linux nm view symbols in dynamic and static libraries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.