View the NM command program Symbol Information

Source: Internet
Author: User

Original article link

Purpose

Displays the object file, executable file, and Symbol Information in the object file library.

Syntax

Nm [ - ] [ -C ] [ -X { 32 | 64 | 32_64 }] [ -F ] [ -H ] [ -L ] [ -P ] [ -R ] [ -T ] [ -V ] [ -B | -P ] [ -E | -G | -U ] [ -D | -O | -X | -T Format ] File ...

Description

NmCommand to displayFileSymbol Information. The file can be an object file, an executable file, or an object file library. If the file does not contain symbolic information,NmCommand to report this situation, but does not interpret it as an error condition.NmThe Command reports numeric values in decimal notation by default.

NmCommand to write the following symbol information to the standard output:

  • LibraryOrObject Name

    If you specify-Option, thenNmThe command only reports the name of the database or object related to the file.

  • Symbol name
  • Symbol type

    NmThe command uses one of the following symbols (the weak symbol in the same region table is used as the global symbol) to represent the file symbol type:

    A global absolute symbol.
    A the local absolute symbol.
    B the global BSS symbol.
    B the local BSS symbol.
    d the global data symbol.
    d the local data symbol.
    F source file name symbol.
    T the Global Text symbol.
    T the local text symbol.
    U undefined symbol.
  • Value
  • Size

    If it can be applied,NmThe Command reports the size related to the symbol.

Flag

 

- Each line or full path name or object library name is displayed.
-B Display the output in the Berkeley Software Distribution (BSD) format:

 

Value Type name
-C Demangle (demangle) C ++ name. By default, all c ++ symbolic names are decoded.

Note: The symbols in the C ++ object file have been decoded before they are used.
-D The value and size of the symbol are displayed in decimal format. This is the default value.
-E Only static and external (global) symbols are displayed.
-F Display complete output, including redundant. Text,. Data, And. BSS symbols, which are usually restricted.
-G Only external (global) symbols are displayed.
-H Restrict the display of output header data.
-L The weak and global symbols are distinguished by attaching a * to the encoding key of the weak symbol. If and-PThe weak symbol type is shown as follows:
V
Weak data symbol
W
Weak text symbol
W
Weak undefined symbol
Z
Weak BSS symbol
-O The value and size of the symbol are displayed in octal instead of decimal.
-P Display Information in standard portable output format:

 

Library/Object Name type value size

This format displays numeric values in hexadecimal notation unless you use-T,-DOr-OThe flag specifies a different format.

If you specify-Flag-PThe flag is displayed only.Database/Object NameField. Similarly,-PThe flag only displays symbols of the size.SizeField.

-P Not sorted. Output is printed in the order of symbol tables.
-R Sort in reverse order.
-T Truncates each name of a column that may overflow it, so that the last character of the displayed name is an asterisk (*). By default,NmDisplay the full name of the listed symbols, and a name longer than the width of the column set for it will cause each column after the name to be unable to be aligned.
-TFormat Displays the numeric values in the specified format.FormatA parameter is one of the following symbolic Notation:
D
Decimal notation. This is NmThe default format of the command.
O
Octal notation.
X
Hexadecimal notation.
-U Only undefined characters are displayed.
-V Outputs are sorted by value rather than by alphabetic order.
-X The value and size of the symbol are displayed in hexadecimal notation instead of decimal notation.
-XMode SpecifyNmType of the object file to be checked.ModeMust be one of the following:
32
Only 32-bit object files are processed
64
Only 64-bit object files are processed
32_64
Process 32-bit and 64-bit object files

By default, 32-bit object files are processed (64-bit objects are ignored ).ModeYes.Object_modeEnvironment variables. For example,Object_mode = 64EnableNmProcess any 64-bit object and ignore the 32-bit object.-XFlag coverageObject_modeVariable.

Note: Nm Command support -- . If the file name is misinterpreted as an option, this flag is different from File Operand. For example, to specify a file name that starts with a hyphen, use -- Flag.

Exit status

This command returns the following export values:

0 Completed successfully.
> 0 An error occurred.

Example
    1. List . out static and external symbols of the object file. Enter:

       nm-e. out 
    2. the symbol size and value are displayed in hexadecimal notation and sorted by value. Enter:

       nm-xv. out 
    3. display libc. all 64-bit object symbols in a , ignoring all 32-bit objects:

       nm-x64/usr/lib/libc. A 

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.