toolchain/share/doc/binutils.html/nm.html

311 lines
21 KiB
HTML

<html lang="en">
<head>
<title>nm - GNU Binary Utilities</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Binary Utilities">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="ar.html#ar" title="ar">
<link rel="next" href="objcopy.html#objcopy" title="objcopy">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1991-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="nm"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="objcopy.html#objcopy">objcopy</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="ar.html#ar">ar</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">2 nm</h2>
<p><a name="index-symbols-38"></a><a name="index-nm-39"></a>
<!-- man title nm list symbols from object files -->
<pre class="smallexample"> <!-- man begin SYNOPSIS nm -->
nm [<samp><span class="option">-A</span></samp>|<samp><span class="option">-o</span></samp>|<samp><span class="option">--print-file-name</span></samp>] [<samp><span class="option">-a</span></samp>|<samp><span class="option">--debug-syms</span></samp>]
[<samp><span class="option">-B</span></samp>|<samp><span class="option">--format=bsd</span></samp>] [<samp><span class="option">-C</span></samp>|<samp><span class="option">--demangle</span></samp>[=<var>style</var>]]
[<samp><span class="option">-D</span></samp>|<samp><span class="option">--dynamic</span></samp>] [<samp><span class="option">-f</span></samp><var>format</var>|<samp><span class="option">--format=</span></samp><var>format</var>]
[<samp><span class="option">-g</span></samp>|<samp><span class="option">--extern-only</span></samp>] [<samp><span class="option">-h</span></samp>|<samp><span class="option">--help</span></samp>]
[<samp><span class="option">-l</span></samp>|<samp><span class="option">--line-numbers</span></samp>] [<samp><span class="option">--inlines</span></samp>]
[<samp><span class="option">-n</span></samp>|<samp><span class="option">-v</span></samp>|<samp><span class="option">--numeric-sort</span></samp>]
[<samp><span class="option">-P</span></samp>|<samp><span class="option">--portability</span></samp>] [<samp><span class="option">-p</span></samp>|<samp><span class="option">--no-sort</span></samp>]
[<samp><span class="option">-r</span></samp>|<samp><span class="option">--reverse-sort</span></samp>] [<samp><span class="option">-S</span></samp>|<samp><span class="option">--print-size</span></samp>]
[<samp><span class="option">-s</span></samp>|<samp><span class="option">--print-armap</span></samp>] [<samp><span class="option">-t</span></samp> <var>radix</var>|<samp><span class="option">--radix=</span></samp><var>radix</var>]
[<samp><span class="option">-u</span></samp>|<samp><span class="option">--undefined-only</span></samp>] [<samp><span class="option">-V</span></samp>|<samp><span class="option">--version</span></samp>]
[<samp><span class="option">-X 32_64</span></samp>] [<samp><span class="option">--defined-only</span></samp>] [<samp><span class="option">--no-demangle</span></samp>]
[<samp><span class="option">--plugin</span></samp> <var>name</var>]
[<samp><span class="option">--no-recurse-limit</span></samp>|<samp><span class="option">--recurse-limit</span></samp>]]
[<samp><span class="option">--size-sort</span></samp>] [<samp><span class="option">--special-syms</span></samp>]
[<samp><span class="option">--synthetic</span></samp>] [<samp><span class="option">--with-symbol-versions</span></samp>] [<samp><span class="option">--target=</span></samp><var>bfdname</var>]
[<var>objfile</var>...]
<!-- man end -->
</pre>
<!-- man begin DESCRIPTION nm -->
<p><span class="sc">gnu</span> <samp><span class="command">nm</span></samp> lists the symbols from object files <var>objfile</var><small class="dots">...</small>.
If no object files are listed as arguments, <samp><span class="command">nm</span></samp> assumes the file
<samp><span class="file">a.out</span></samp>.
<p>For each symbol, <samp><span class="command">nm</span></samp> shows:
<ul>
<li>The symbol value, in the radix selected by options (see below), or
hexadecimal by default.
<li>The symbol type. At least the following types are used; others are, as
well, depending on the object file format. If lowercase, the symbol is
usually local; if uppercase, the symbol is global (external). There
are however a few lowercase symbols that are shown for special global
symbols (<code>u</code>, <code>v</code> and <code>w</code>).
<!-- Some more detail on exactly what these symbol types are used for -->
<!-- would be nice. -->
<dl>
<dt><code>A</code><dd>The symbol's value is absolute, and will not be changed by further
linking.
<br><dt><code>B</code><dt><code>b</code><dd>The symbol is in the BSS data section. This section typically
contains zero-initialized or uninitialized data, although the exact
behavior is system dependent.
<br><dt><code>C</code><dd>The symbol is common. Common symbols are uninitialized data. When
linking, multiple common symbols may appear with the same name. If the
symbol is defined anywhere, the common symbols are treated as undefined
references.
For more details on common symbols, see the discussion of
&ndash;warn-common in <a href="../ld/Options.html#Options">Linker options</a>.
<br><dt><code>D</code><dt><code>d</code><dd>The symbol is in the initialized data section.
<br><dt><code>G</code><dt><code>g</code><dd>The symbol is in an initialized data section for small objects. Some
object file formats permit more efficient access to small data objects,
such as a global int variable as opposed to a large global array.
<br><dt><code>i</code><dd>For PE format files this indicates that the symbol is in a section
specific to the implementation of DLLs. For ELF format files this
indicates that the symbol is an indirect function. This is a GNU
extension to the standard set of ELF symbol types. It indicates a
symbol which if referenced by a relocation does not evaluate to its
address, but instead must be invoked at runtime. The runtime
execution will then return the value to be used in the relocation.
<br><dt><code>I</code><dd>The symbol is an indirect reference to another symbol.
<br><dt><code>N</code><dd>The symbol is a debugging symbol.
<br><dt><code>n</code><dd>The symbol is in the read-only data section.
<br><dt><code>p</code><dd>The symbol is in a stack unwind section.
<br><dt><code>R</code><dt><code>r</code><dd>The symbol is in a read only data section.
<br><dt><code>S</code><dt><code>s</code><dd>The symbol is in an uninitialized or zero-initialized data section
for small objects.
<br><dt><code>T</code><dt><code>t</code><dd>The symbol is in the text (code) section.
<br><dt><code>U</code><dd>The symbol is undefined.
<br><dt><code>u</code><dd>The symbol is a unique global symbol. This is a GNU extension to the
standard set of ELF symbol bindings. For such a symbol the dynamic linker
will make sure that in the entire process there is just one symbol with
this name and type in use.
<br><dt><code>V</code><dt><code>v</code><dd>The symbol is a weak object. When a weak defined symbol is linked with
a normal defined symbol, the normal defined symbol is used with no error.
When a weak undefined symbol is linked and the symbol is not defined,
the value of the weak symbol becomes zero with no error. On some
systems, uppercase indicates that a default value has been specified.
<br><dt><code>W</code><dt><code>w</code><dd>The symbol is a weak symbol that has not been specifically tagged as a
weak object symbol. When a weak defined symbol is linked with a normal
defined symbol, the normal defined symbol is used with no error.
When a weak undefined symbol is linked and the symbol is not defined,
the value of the symbol is determined in a system-specific manner without
error. On some systems, uppercase indicates that a default value has been
specified.
<br><dt><code>-</code><dd>The symbol is a stabs symbol in an a.out object file. In this case, the
next values printed are the stabs other field, the stabs desc field, and
the stab type. Stabs symbols are used to hold debugging information.
<br><dt><code>?</code><dd>The symbol type is unknown, or object file format specific.
</dl>
<li>The symbol name.
</ul>
<!-- man end -->
<!-- man begin OPTIONS nm -->
<p>The long and short forms of options, shown here as alternatives, are
equivalent.
<dl>
<dt><samp><span class="env">-A</span></samp><dt><samp><span class="env">-o</span></samp><dt><samp><span class="env">--print-file-name</span></samp><dd><a name="index-input-file-name-40"></a><a name="index-file-name-41"></a><a name="index-source-file-name-42"></a>Precede each symbol by the name of the input file (or archive member)
in which it was found, rather than identifying the input file once only,
before all of its symbols.
<br><dt><samp><span class="env">-a</span></samp><dt><samp><span class="env">--debug-syms</span></samp><dd><a name="index-debugging-symbols-43"></a>Display all symbols, even debugger-only symbols; normally these are not
listed.
<br><dt><samp><span class="env">-B</span></samp><dd><a name="index-g_t_0040command_007bnm_007d-format-44"></a><a name="index-g_t_0040command_007bnm_007d-compatibility-45"></a>The same as <samp><span class="option">--format=bsd</span></samp> (for compatibility with the MIPS <samp><span class="command">nm</span></samp>).
<br><dt><samp><span class="env">-C</span></samp><dt><samp><span class="env">--demangle[=</span><var>style</var><span class="env">]</span></samp><dd><a name="index-demangling-in-nm-46"></a>Decode (<dfn>demangle</dfn>) low-level symbol names into user-level names.
Besides removing any initial underscore prepended by the system, this
makes C++ function names readable. Different compilers have different
mangling styles. The optional demangling style argument can be used to
choose an appropriate demangling style for your compiler. See <a href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>,
for more information on demangling.
<br><dt><samp><span class="env">--no-demangle</span></samp><dd>Do not demangle low-level symbol names. This is the default.
<br><dt><samp><span class="env">--recurse-limit</span></samp><dt><samp><span class="env">--no-recurse-limit</span></samp><dt><samp><span class="env">--recursion-limit</span></samp><dt><samp><span class="env">--no-recursion-limit</span></samp><dd>Enables or disables a limit on the amount of recursion performed
whilst demangling strings. Since the name mangling formats allow for
an inifinite level of recursion it is possible to create strings whose
decoding will exhaust the amount of stack space available on the host
machine, triggering a memory fault. The limit tries to prevent this
from happening by restricting recursion to 2048 levels of nesting.
<p>The default is for this limit to be enabled, but disabling it may be
necessary in order to demangle truly complicated names. Note however
that if the recursion limit is disabled then stack exhaustion is
possible and any bug reports about such an event will be rejected.
<br><dt><samp><span class="env">-D</span></samp><dt><samp><span class="env">--dynamic</span></samp><dd><a name="index-dynamic-symbols-47"></a>Display the dynamic symbols rather than the normal symbols. This is
only meaningful for dynamic objects, such as certain types of shared
libraries.
<br><dt><samp><span class="env">-f </span><var>format</var></samp><dt><samp><span class="env">--format=</span><var>format</var></samp><dd><a name="index-g_t_0040command_007bnm_007d-format-48"></a><a name="index-g_t_0040command_007bnm_007d-compatibility-49"></a>Use the output format <var>format</var>, which can be <code>bsd</code>,
<code>sysv</code>, or <code>posix</code>. The default is <code>bsd</code>.
Only the first character of <var>format</var> is significant; it can be
either upper or lower case.
<br><dt><samp><span class="env">-g</span></samp><dt><samp><span class="env">--extern-only</span></samp><dd><a name="index-external-symbols-50"></a>Display only external symbols.
<br><dt><samp><span class="env">-h</span></samp><dt><samp><span class="env">--help</span></samp><dd>Show a summary of the options to <samp><span class="command">nm</span></samp> and exit.
<br><dt><samp><span class="env">-l</span></samp><dt><samp><span class="env">--line-numbers</span></samp><dd><a name="index-symbol-line-numbers-51"></a>For each symbol, use debugging information to try to find a filename and
line number. For a defined symbol, look for the line number of the
address of the symbol. For an undefined symbol, look for the line
number of a relocation entry which refers to the symbol. If line number
information can be found, print it after the other symbol information.
<br><dt><samp><span class="env">--inlines</span></samp><dd><a name="index-objdump-inlines-52"></a>When option <samp><span class="option">-l</span></samp> is active, if the address belongs to a
function that was inlined, then this option causes the source
information for all enclosing scopes back to the first non-inlined
function to be printed as well. For example, if <code>main</code> inlines
<code>callee1</code> which inlines <code>callee2</code>, and address is from
<code>callee2</code>, the source information for <code>callee1</code> and <code>main</code>
will also be printed.
<br><dt><samp><span class="env">-n</span></samp><dt><samp><span class="env">-v</span></samp><dt><samp><span class="env">--numeric-sort</span></samp><dd>Sort symbols numerically by their addresses, rather than alphabetically
by their names.
<br><dt><samp><span class="env">-p</span></samp><dt><samp><span class="env">--no-sort</span></samp><dd><a name="index-sorting-symbols-53"></a>Do not bother to sort the symbols in any order; print them in the order
encountered.
<br><dt><samp><span class="env">-P</span></samp><dt><samp><span class="env">--portability</span></samp><dd>Use the POSIX.2 standard output format instead of the default format.
Equivalent to &lsquo;<samp><span class="samp">-f posix</span></samp>&rsquo;.
<br><dt><samp><span class="env">-r</span></samp><dt><samp><span class="env">--reverse-sort</span></samp><dd>Reverse the order of the sort (whether numeric or alphabetic); let the
last come first.
<br><dt><samp><span class="env">-S</span></samp><dt><samp><span class="env">--print-size</span></samp><dd>Print both value and size of defined symbols for the <code>bsd</code> output style.
This option has no effect for object formats that do not record symbol
sizes, unless &lsquo;<samp><span class="samp">--size-sort</span></samp>&rsquo; is also used in which case a
calculated size is displayed.
<br><dt><samp><span class="env">-s</span></samp><dt><samp><span class="env">--print-armap</span></samp><dd><a name="index-symbol-index_002c-listing-54"></a>When listing symbols from archive members, include the index: a mapping
(stored in the archive by <samp><span class="command">ar</span></samp> or <samp><span class="command">ranlib</span></samp>) of which modules
contain definitions for which names.
<br><dt><samp><span class="env">-t </span><var>radix</var></samp><dt><samp><span class="env">--radix=</span><var>radix</var></samp><dd>Use <var>radix</var> as the radix for printing the symbol values. It must be
&lsquo;<samp><span class="samp">d</span></samp>&rsquo; for decimal, &lsquo;<samp><span class="samp">o</span></samp>&rsquo; for octal, or &lsquo;<samp><span class="samp">x</span></samp>&rsquo; for hexadecimal.
<br><dt><samp><span class="env">-u</span></samp><dt><samp><span class="env">--undefined-only</span></samp><dd><a name="index-external-symbols-55"></a><a name="index-undefined-symbols-56"></a>Display only undefined symbols (those external to each object file).
<br><dt><samp><span class="env">-V</span></samp><dt><samp><span class="env">--version</span></samp><dd>Show the version number of <samp><span class="command">nm</span></samp> and exit.
<br><dt><samp><span class="env">-X</span></samp><dd>This option is ignored for compatibility with the AIX version of
<samp><span class="command">nm</span></samp>. It takes one parameter which must be the string
<samp><span class="option">32_64</span></samp>. The default mode of AIX <samp><span class="command">nm</span></samp> corresponds
to <samp><span class="option">-X 32</span></samp>, which is not supported by <span class="sc">gnu</span> <samp><span class="command">nm</span></samp>.
<br><dt><samp><span class="env">--defined-only</span></samp><dd><a name="index-external-symbols-57"></a><a name="index-undefined-symbols-58"></a>Display only defined symbols for each object file.
<br><dt><samp><span class="env">--plugin </span><var>name</var></samp><dd><a name="index-plugins-59"></a>Load the plugin called <var>name</var> to add support for extra target
types. This option is only available if the toolchain has been built
with plugin support enabled.
<p>If <samp><span class="option">--plugin</span></samp> is not provided, but plugin support has been
enabled then <samp><span class="command">nm</span></samp> iterates over the files in
<samp><span class="file">${libdir}/bfd-plugins</span></samp> in alphabetic order and the first
plugin that claims the object in question is used.
<p>Please note that this plugin search directory is <em>not</em> the one
used by <samp><span class="command">ld</span></samp>'s <samp><span class="option">-plugin</span></samp> option. In order to make
<samp><span class="command">nm</span></samp> use the linker plugin it must be copied into the
<samp><span class="file">${libdir}/bfd-plugins</span></samp> directory. For GCC based compilations
the linker plugin is called <samp><span class="file">liblto_plugin.so.0.0.0</span></samp>. For Clang
based compilations it is called <samp><span class="file">LLVMgold.so</span></samp>. The GCC plugin
is always backwards compatible with earlier versions, so it is
sufficient to just copy the newest one.
<br><dt><samp><span class="env">--size-sort</span></samp><dd>Sort symbols by size. For ELF objects symbol sizes are read from the
ELF, for other object types the symbol sizes are computed as the
difference between the value of the symbol and the value of the symbol
with the next higher value. If the <code>bsd</code> output format is used
the size of the symbol is printed, rather than the value, and
&lsquo;<samp><span class="samp">-S</span></samp>&rsquo; must be used in order both size and value to be printed.
<br><dt><samp><span class="env">--special-syms</span></samp><dd>Display symbols which have a target-specific special meaning. These
symbols are usually used by the target for some special processing and
are not normally helpful when included in the normal symbol lists.
For example for ARM targets this option would skip the mapping symbols
used to mark transitions between ARM code, THUMB code and data.
<br><dt><samp><span class="env">--synthetic</span></samp><dd>Include synthetic symbols in the output. These are special symbols
created by the linker for various purposes. They are not shown by
default since they are not part of the binary's original source code.
<br><dt><samp><span class="env">--with-symbol-versions</span></samp><dd>Enables the display of symbol version information if any exists. The
version string is displayed as a suffix to the symbol name, preceeded by
an @ character. For example &lsquo;<samp><span class="samp">foo@VER_1</span></samp>&rsquo;. If the version is
the default version to be used when resolving unversioned references
to the symbol then it is displayed as a suffix preceeded by two @
characters. For example &lsquo;<samp><span class="samp">foo@@VER_2</span></samp>&rsquo;.
<br><dt><samp><span class="env">--target=</span><var>bfdname</var></samp><dd><a name="index-object-code-format-60"></a>Specify an object code format other than your system's default format.
See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
</dl>
<!-- man end -->
</body></html>