nm Command 参考

nm Command

Purpose

       Displays information about symbols in object files, executable files, and object-file libraries.

Syntax

       nm [ -A ] [ -C ] [ -X  {32|64|32_64|d64| any}] [ -f ] [ -h ] [ -l ] [ -p ] [ -r ] [ -T ] [ -v ] [ -B | -P ] [ -e | -g | -u ] [ -d | -o | -x | -t
       Format ] File ...

Description

       The nm command displays information about symbols in the specified File, which can be an object file, an executable file, or an object-file library.
       If the file contains no symbol information, the nm command reports the fact, but does not interpret it as an error condition. The nm command reports
       numerical values in decimal notation by default.

       The nm command writes the following symbol information to standard output:
       *    Library or Object Name

            The nm command reports either the library or the object name associated with the file only if you specify the -A option.
       *    Symbol Name
       *    Symbol Type

            The nm command represents the file's symbol type with one of the following characters (with weak symbols represented by the same characters as
            global symbols):
              A
                   Global absolute symbol.
              a
                   Local absolute symbol.
              B
                   Global bss symbol.
              b
                   Local bss symbol.
              D
                   Global data symbol.
              d
                   Local data symbol.
              f
                   Source file name symbol.
              L
                   Global thread-local symbol (TLS).
              l
                   Static thread-local symbol (TLS).
              T
                   Global text symbol.
              t
                   Local text symbol.
              U
                   Undefined symbol.
       *    Value
       *    Size

            The nm command reports the size associated with the symbol, if applicable.

Flags

       -A
            Displays either the full path name or library name of an object on each line.
       -B
            Displays output in the Berkeley Software Distribution (BSD) format:

            value   type   name
       -C
            Suppresses the demangling of C++ names. The default is to demangle all C++ symbol names. Note: Symbols from C++ object files have their names
            demangled before they are used.
       -d
            Displays a symbol's value and size as a decimal. This is the default.
       -e
            Displays only static and external (global) symbols.
       -f
            Displays full output, including redundant .text, .data, and .bss symbols, which are normally suppressed.
       -g
            Displays only external (global) symbols.
       -h
            Suppresses the display of output header data.
       -l
            Distinguishes between WEAK and GLOBAL symbols by appending a * to the key letter for WEAK symbols. If used with the -P option, the symbol type
            for weak symbols is represented as follows:
              V
                   Weak Data Symbol
              W
                   Weak Text Symbol
              w
                   Weak Undefined Symbol
              Z
                   Weak bss Symbol
       -o
            Displays a symbol's value and size as an octal rather than a decimal number.
       -p
            Does not sort. The ouput is printed in symbol-table order.
       -P
            Displays information in a standard portable output format:

            library/object name   name   type   value   size

            This format displays numerical values in hexadecimal notation, unless you specify a different format with the -t, -d, or -o flags.

            The -P flag displays the library/object name field only if you specify the -A flag. Also, the -P flag displays the size field only for symbols
            for which size is applicable.
       -r
            Sorts in reverse order.
       -t Format
            Displays numerical values in the specified format, where the Format parameter is one of the following notations:
              d
                   Decimal notation. This is the default format for the nm command.
              o
                   Octal notation.
              x
                   Hexadecimal notation.
       -T
            Truncates every name that would otherwise overflow its column, making the last character displayed in the name an asterisk. By default, nm
            displays the entire name of the symbols listed, and a name that is longer than the width of the column set aside for it causes every column
            after the name to be misaligned.
       -u

            Displays only undefined symbols.
       -v
            Sorts output by value instead of alphabetically.
       -x
            Displays a symbol's value and size as a hexadecimal rather than a decimal number.
       -X mode
            Specifies the type of object file nm should examine. The mode must be one of the following:
              32
                   Processes only 32-bit object files
              64
                   Processes only 64-bit object files
              32_64
                   Processes both 32-bit and 64-bit object files
              d64
                   Examines discontinued 64-bit XCOFF files (magic number == U803XTOCMAGIC).
              any
                   Processes all of the supported object files.
            The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For
            example, OBJECT_MODE=64 causes nm to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable.
            Note: The nm command supports the -- (double hyphen) flag. This flag distinguishes a File operand if the file name can be misinterpreted as an
            option. For example, to specify a file name that begins with a hyphen, use the -- flag.

Exit Status

       This command returns the following exit values:
       0
            Successful completion.
       >0
            An error occurred.

Examples
       1    To list the static and external symbols of the object file a.out, enter:

            nm -e a.out
       2    To display symbol sizes and values as hexadecimal and sort the symbols by value, enter:

            nm -xv a.out
       3    To display symbol of all 64-bit objects in libc.a, ignoring all 32-bit objects:

            nm -X64 /usr/lib/libc.a

Files

       /usr/ccs/bin/nm
            Contains the nm command.

Related Information

       The ar command, as command, ld command, size command, strip command.

       The a.out file, ar file.

       Commands in Operating system and device management.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值