Unix‎ > ‎Solaris‎ > ‎Solaris man pages‎ > ‎1‎ > ‎


     nm - print name list of an object file

     /usr/ccs/bin/nm [-ACDhlnPprRsTuVv] [-efox]  [-g  |  -u]   [-
     t format] file...

     /usr/xpg4/bin/nm [-ACDhlnPprRsTuVv] [-efox] [-g  |  -u]   [-
     t format] file...

     The nm utility displays the symbol table of each ELF  object
     file that is specified by file.

     If no symbolic information is available for  a  valid  input
     file, the nm utility will report that fact, but not consider
     it an error condition.

     The output of nm  may  be  controlled  using  the  following

     -A              Writes the full path name or library name of
                     an object on each line.

     -C              Demangles C++ symbol names  before  printing
                     them out.

     -D              Displays the SHT_DYNSYM symbol  information.
                     This is the symbol table used by ld.so.1 and
                     is present even in stripped dynamic  execut-
                     ables.  By  default,  the  SHT_SYMTAB symbol
                     table is displayed.

     -e              See NOTES below.

     -f              See NOTES below.

     -g              Writes only external (global) symbol  infor-

     -h              Does not display the output heading data.

     -l              Distinguishes between WEAK and  GLOBAL  sym-
                     bols  by appending a * to the key letter for
                     WEAK symbols.

     -n              Sorts external symbols by name  before  they
                     are printed.

     -o              Prints the value and size  of  a  symbol  in
                     octal  instead  of decimal (equivalent to -t

     -p              Produces easy to parse, terse  output.  Each
                     symbol name is preceded by its value (blanks
                     if undefined) and one of the letters:

                     A        Absolute symbol.

                     B        bss (uninitialized data space) sym-

                     C        COMMON symbol.

                     D        Data object symbol.

                     F        File symbol.

                     N        Symbol has no type.

                     L        Thread-Local storage symbol.

                     S        Section symbol.

                     T        Text symbol.

                     U        Undefined.

                     If the symbol's binding attribute is:

                     LOCAL           The  key  letter  is   lower

                     WEAK            The  key  letter  is   upper
                                     case.  If the -l modifier is
                                     specified,  the  upper  case
                                     key  letter is followed by a

                     GLOBAL          The  key  letter  is   upper

     -P              Writes information in a portable output for-
                     mat, as specified in Standard Output.

     -r              Prepends the name  of  the  object  file  or
                     archive to each output line.

     -R              Prints the archive name (if  present),  fol-
                     lowed by the object file and symbol name. If
                     the -r option is also specified, this option
                     is ignored.

     -s              Prints  section  name  instead  of   section

     -t format       Writes each numeric value in  the  specified
                     format.  The format is dependent on the sin-
                     gle character used  as  the  format  option-

                     d        The offset is  written  in  decimal

                     o        The offset is written in octal.

                     x        The offset is  written  in  hexade-

     -T              See NOTES below.

     -u              Prints undefined symbols only.

     -u              Prints long listing for each undefined  sym-
                     bol. See OUTPUT below.

     -v              Sorts external symbols by value before  they
                     are printed.

     -V              Prints the version of the nm command execut-
                     ing on the standard error output.

     -x              Prints the value and size  of  a  symbol  in
                     hexadecimal  instead  of decimal (equivalent
                     to -t x).

     Options may be used in any order, either singly or in combi-
     nation,  and  may  appear anywhere in the command line. When
     conflicting options are specified (such as -v and -n, or  -o
     and  -x)  the  first  is taken and the second ignored with a
     warning message to the user. (See -R for exception.)

     The following operand is supported:

     file     A path name of an object file, executable  file  or
              object-file library.

     This section describes the nm utility's output options.

  Standard Output
     For each symbol, the following information will be printed:

     Index           The index of the symbol. (The index  appears
                     in brackets.)

     Value           The value of the symbol is one of  the  fol-

                       o  A section offset for defined symbols in
                          a relocatable file.

                       o  Alignment constraints for symbols whose
                          section index is SHN_COMMON.

                       o  A virtual  address  in  executable  and
                          dynamic library files.

     Size            The size in bytes of the associated object.

     Type            A symbol is of one of the following types:

                     NOTYPE          No type was specified.

                     OBJECT          A data  object  such  as  an
                                     array or variable.

                     FUNC            A function or other  execut-
                                     able code.

                     REGI            A  register  symbol   (SPARC

                     SECTION         A section symbol.

                     FILE            Name of the source file.

                     COMMON          An   uninitialized    common

                     TLS             A variable  associated  with
                                     Thread-Local storage.

     Bind            The symbol's binding attributes.

                     LOCAL symbols           Have a scope limited
                                             to  the  object file
                                             containing     their

                     GLOBAL symbols          Are visible  to  all
                                             object  files  being

                     WEAK symbols            Are essentially glo-
                                             bal  symbols  with a
                                             lower     precedence
                                             than GLOBAL.

     Other           A symbol's visibility.

                     The lower 3 bits of the st_other  member  of
                     the   Elf32_Sym   structure,    defined   in
                     <sys/elf.h>, are currently used and  can  be
                     one of:

                     #define STV_DEFAULT     0
                     #define STV_INTERNAL    1
                     #define STV_HIDDEN      2
                     #define STV_PROTECTED   3

     Shndx           Except for three special values, this is the
                     section  header  table  index in relation to
                     which the symbol is defined.  The  following
                     special values exist:

                     ABS             Indicates the symbol's value
                                     will   not   change  through

                     COMMON          Indicates   an   unallocated
                                     block and the value provides
                                     alignment constraints.

                     UNDEF           Indicates an undefined  sym-

     Name            The name of the symbol.

     Object Name     The name of the object or library if  -A  is

     If the -P option is specified, the previous  information  is
     displayed  using  the  following  portable format. The three
     versions differ depending on whether -t d, -t o, or -t x was
     specified, respectively:

     "%s%s %s %d %d\n", library/object name, name,  type,  value,
     size  "%s%s  %s  %o %o\n", library/object name, name , type,
     value , size "%s%s %s %x %x\n", library/object  name,  name,
     type, value, size

     where library/object name is formatted as follows:

       o  If -A is not specified, library/object name is an empty

       o  If -A is specified and the corresponding  file  operand
          does not name a library:

          "%s: ", file

       o  If -A is specified and the corresponding  file  operand
          names  a  library.  In this case, object file names the
          object file in the library containing the symbol  being

          "%s[%s]: ", file, object file

     If -A is not specified, then if more than one  file  operand
     is specified or if only one file operand is specified and it
     names a library, nm will write a line identifying the object
     containing the following symbols before the lines containing
     those symbols, in the form:

       o  If the corresponding  file  operand  does  not  name  a

          "%s:\n", file

       o  If the corresponding file operand names a  library;  in
          this  case,  object file is the name of the file in the
          library containing the following symbols:
          "%s[%s]:\n", file, object file

     If -P is specified, but -t is not, the format is as if -t  x
     had been specified.

     See environ(5) for descriptions of the following environment
     variables  that  affect  the  execution of nm: LANG, LC_ALL,

     The following exit values are returned:

     0        Successful completion.

     >0       An error occurred.

     See attributes(5) for descriptions of the  following  attri-

    |       ATTRIBUTE TYPE        |       ATTRIBUTE VALUE       |
    | Availability                | SUNWbtool                   |

    |       ATTRIBUTE TYPE        |       ATTRIBUTE VALUE       |
    | Availability                | SUNWxcu4                    |
    | Interface Stability         | Standard                    |

     ar(1),  as(1),  dump(1),  ld(1),  ld.so.1(1),   ar.h(3HEAD),
     a.out(4), attributes(5), environ(5), standards(5)

     The following options are obsolete because of changes to the
     object file format and will be deleted in a future release.

     -e       Prints only external and static symbols. The symbol
              table  now  contains  only static and external sym-
              bols. Automatic symbols no  longer  appear  in  the
              symbol  table.  They  do  appear  in  the debugging
              information produced by cc -g, which may  be  exam-
              ined using dump(1).

     -f       Produces full output. Redundant  symbols  (such  as
              .text,  .data,  and so forth), which existed previ-
              ously, do not exist and producing full output  will
              be identical to the default output.

     -T       By default, nm prints the entire name of  the  sym-
              bols  listed. Since symbol names have been moved to
              the last column, the problem of overflow is removed
              and  it is no longer necessary to truncate the sym-
              bol name.

Man pages from Solaris 10 Update 8. See docs.sun.com and www.oracle.com for further documentation and Solaris information.