1<html lang="en"> 2<head> 3<title>nm - GNU Binary Utilities</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="GNU Binary Utilities"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="prev" href="ar.html#ar" title="ar"> 9<link rel="next" href="objcopy.html#objcopy" title="objcopy"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 132000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 14Free Software Foundation, Inc. 15 16Permission is granted to copy, distribute and/or modify this document 17under the terms of the GNU Free Documentation License, Version 1.3 18or any later version published by the Free Software Foundation; 19with no Invariant Sections, with no Front-Cover Texts, and with no 20Back-Cover Texts. A copy of the license is included in the 21section entitled ``GNU Free Documentation License''. 22 23--> 24<meta http-equiv="Content-Style-Type" content="text/css"> 25<style type="text/css"><!-- 26 pre.display { font-family:inherit } 27 pre.format { font-family:inherit } 28 pre.smalldisplay { font-family:inherit; font-size:smaller } 29 pre.smallformat { font-family:inherit; font-size:smaller } 30 pre.smallexample { font-size:smaller } 31 pre.smalllisp { font-size:smaller } 32 span.sc { font-variant:small-caps } 33 span.roman { font-family:serif; font-weight:normal; } 34 span.sansserif { font-family:sans-serif; font-weight:normal; } 35--></style> 36<link rel="stylesheet" type="text/css" href="../cs.css"> 37</head> 38<body> 39<div class="node"> 40<a name="nm"></a> 41<p> 42Next: <a rel="next" accesskey="n" href="objcopy.html#objcopy">objcopy</a>, 43Previous: <a rel="previous" accesskey="p" href="ar.html#ar">ar</a>, 44Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> 45<hr> 46</div> 47 48<h2 class="chapter">2 nm</h2> 49 50<p><a name="index-symbols-33"></a><a name="index-nm-34"></a> 51<!-- man title nm list symbols from object files --> 52 53<pre class="smallexample"> <!-- man begin SYNOPSIS nm --> 54 nm [<samp><span class="option">-a</span></samp>|<samp><span class="option">--debug-syms</span></samp>] 55 [<samp><span class="option">-g</span></samp>|<samp><span class="option">--extern-only</span></samp>][<samp><span class="option">--plugin</span></samp> <var>name</var>] 56 [<samp><span class="option">-B</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>] 57 [<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>] 58 [<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">--special-syms</span></samp>] 59 [<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">--no-sort</span></samp>] 60 [<samp><span class="option">-r</span></samp>|<samp><span class="option">--reverse-sort</span></samp>] [<samp><span class="option">--size-sort</span></samp>] [<samp><span class="option">-u</span></samp>|<samp><span class="option">--undefined-only</span></samp>] 61 [<samp><span class="option">-t</span></samp> <var>radix</var>|<samp><span class="option">--radix=</span></samp><var>radix</var>] [<samp><span class="option">-P</span></samp>|<samp><span class="option">--portability</span></samp>] 62 [<samp><span class="option">--target=</span></samp><var>bfdname</var>] [<samp><span class="option">-f</span></samp><var>format</var>|<samp><span class="option">--format=</span></samp><var>format</var>] 63 [<samp><span class="option">--defined-only</span></samp>] [<samp><span class="option">-l</span></samp>|<samp><span class="option">--line-numbers</span></samp>] [<samp><span class="option">--no-demangle</span></samp>] 64 [<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">--help</span></samp>] [<var>objfile</var>...] 65 <!-- man end --> 66</pre> 67 <!-- man begin DESCRIPTION nm --> 68 <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>. 69If no object files are listed as arguments, <samp><span class="command">nm</span></samp> assumes the file 70<samp><span class="file">a.out</span></samp>. 71 72 <p>For each symbol, <samp><span class="command">nm</span></samp> shows: 73 74 <ul> 75<li>The symbol value, in the radix selected by options (see below), or 76hexadecimal by default. 77 78 <li>The symbol type. At least the following types are used; others are, as 79well, depending on the object file format. If lowercase, the symbol is 80usually local; if uppercase, the symbol is global (external). There 81are however a few lowercase symbols that are shown for special global 82symbols (<code>u</code>, <code>v</code> and <code>w</code>). 83 84 <!-- Some more detail on exactly what these symbol types are used for --> 85 <!-- would be nice. --> 86 <dl> 87<dt><code>A</code><dd>The symbol's value is absolute, and will not be changed by further 88linking. 89 90 <br><dt><code>B</code><dt><code>b</code><dd>The symbol is in the uninitialized data section (known as BSS). 91 92 <br><dt><code>C</code><dd>The symbol is common. Common symbols are uninitialized data. When 93linking, multiple common symbols may appear with the same name. If the 94symbol is defined anywhere, the common symbols are treated as undefined 95references. 96For more details on common symbols, see the discussion of 97–warn-common in <a href="../ld/Options.html#Options">Linker options</a>. 98 99 <br><dt><code>D</code><dt><code>d</code><dd>The symbol is in the initialized data section. 100 101 <br><dt><code>G</code><dt><code>g</code><dd>The symbol is in an initialized data section for small objects. Some 102object file formats permit more efficient access to small data objects, 103such as a global int variable as opposed to a large global array. 104 105 <br><dt><code>i</code><dd>For PE format files this indicates that the symbol is in a section 106specific to the implementation of DLLs. For ELF format files this 107indicates that the symbol is an indirect function. This is a GNU 108extension to the standard set of ELF symbol types. It indicates a 109symbol which if referenced by a relocation does not evaluate to its 110address, but instead must be invoked at runtime. The runtime 111execution will then return the value to be used in the relocation. 112 113 <br><dt><code>N</code><dd>The symbol is a debugging symbol. 114 115 <br><dt><code>p</code><dd>The symbols is in a stack unwind section. 116 117 <br><dt><code>R</code><dt><code>r</code><dd>The symbol is in a read only data section. 118 119 <br><dt><code>S</code><dt><code>s</code><dd>The symbol is in an uninitialized data section for small objects. 120 121 <br><dt><code>T</code><dt><code>t</code><dd>The symbol is in the text (code) section. 122 123 <br><dt><code>U</code><dd>The symbol is undefined. 124 125 <br><dt><code>u</code><dd>The symbol is a unique global symbol. This is a GNU extension to the 126standard set of ELF symbol bindings. For such a symbol the dynamic linker 127will make sure that in the entire process there is just one symbol with 128this name and type in use. 129 130 <br><dt><code>V</code><dt><code>v</code><dd>The symbol is a weak object. When a weak defined symbol is linked with 131a normal defined symbol, the normal defined symbol is used with no error. 132When a weak undefined symbol is linked and the symbol is not defined, 133the value of the weak symbol becomes zero with no error. On some 134systems, uppercase indicates that a default value has been specified. 135 136 <br><dt><code>W</code><dt><code>w</code><dd>The symbol is a weak symbol that has not been specifically tagged as a 137weak object symbol. When a weak defined symbol is linked with a normal 138defined symbol, the normal defined symbol is used with no error. 139When a weak undefined symbol is linked and the symbol is not defined, 140the value of the symbol is determined in a system-specific manner without 141error. On some systems, uppercase indicates that a default value has been 142specified. 143 144 <br><dt><code>-</code><dd>The symbol is a stabs symbol in an a.out object file. In this case, the 145next values printed are the stabs other field, the stabs desc field, and 146the stab type. Stabs symbols are used to hold debugging information. 147For more information, see <a href="../stabs/index.html#Top">Stabs</a>. 148 149 <br><dt><code>?</code><dd>The symbol type is unknown, or object file format specific. 150</dl> 151 152 <li>The symbol name. 153</ul> 154 155<!-- man end --> 156<!-- man begin OPTIONS nm --> 157 <p>The long and short forms of options, shown here as alternatives, are 158equivalent. 159 160 <dl> 161<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-35"></a><a name="index-file-name-36"></a><a name="index-source-file-name-37"></a>Precede each symbol by the name of the input file (or archive member) 162in which it was found, rather than identifying the input file once only, 163before all of its symbols. 164 165 <br><dt><samp><span class="env">-a</span></samp><dt><samp><span class="env">--debug-syms</span></samp><dd><a name="index-debugging-symbols-38"></a>Display all symbols, even debugger-only symbols; normally these are not 166listed. 167 168 <br><dt><samp><span class="env">-B</span></samp><dd><a name="index-g_t_0040command_007bnm_007d-format-39"></a><a name="index-g_t_0040command_007bnm_007d-compatibility-40"></a>The same as <samp><span class="option">--format=bsd</span></samp> (for compatibility with the MIPS <samp><span class="command">nm</span></samp>). 169 170 <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-41"></a>Decode (<dfn>demangle</dfn>) low-level symbol names into user-level names. 171Besides removing any initial underscore prepended by the system, this 172makes C++ function names readable. Different compilers have different 173mangling styles. The optional demangling style argument can be used to 174choose an appropriate demangling style for your compiler. See <a href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>, 175for more information on demangling. 176 177 <br><dt><samp><span class="env">--no-demangle</span></samp><dd>Do not demangle low-level symbol names. This is the default. 178 179 <br><dt><samp><span class="env">-D</span></samp><dt><samp><span class="env">--dynamic</span></samp><dd><a name="index-dynamic-symbols-42"></a>Display the dynamic symbols rather than the normal symbols. This is 180only meaningful for dynamic objects, such as certain types of shared 181libraries. 182 183 <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-43"></a><a name="index-g_t_0040command_007bnm_007d-compatibility-44"></a>Use the output format <var>format</var>, which can be <code>bsd</code>, 184<code>sysv</code>, or <code>posix</code>. The default is <code>bsd</code>. 185Only the first character of <var>format</var> is significant; it can be 186either upper or lower case. 187 188 <br><dt><samp><span class="env">-g</span></samp><dt><samp><span class="env">--extern-only</span></samp><dd><a name="index-external-symbols-45"></a>Display only external symbols. 189 190 <br><dt><samp><span class="env">--plugin </span><var>name</var></samp><dd><a name="index-load-plugin-46"></a>Load the plugin called <var>name</var> to add support for extra target 191types. This option is only available if the toolchain has been built 192with plugin support enabled. 193 194 <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-47"></a>For each symbol, use debugging information to try to find a filename and 195line number. For a defined symbol, look for the line number of the 196address of the symbol. For an undefined symbol, look for the line 197number of a relocation entry which refers to the symbol. If line number 198information can be found, print it after the other symbol information. 199 200 <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 201by their names. 202 203 <br><dt><samp><span class="env">-p</span></samp><dt><samp><span class="env">--no-sort</span></samp><dd><a name="index-sorting-symbols-48"></a>Do not bother to sort the symbols in any order; print them in the order 204encountered. 205 206 <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. 207Equivalent to ‘<samp><span class="samp">-f posix</span></samp>’. 208 209 <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. 210This option has no effect for object formats that do not record symbol 211sizes, unless ‘<samp><span class="samp">--size-sort</span></samp>’ is also used in which case a 212calculated size is displayed. 213 214 <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-49"></a>When listing symbols from archive members, include the index: a mapping 215(stored in the archive by <samp><span class="command">ar</span></samp> or <samp><span class="command">ranlib</span></samp>) of which modules 216contain definitions for which names. 217 218 <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 219last come first. 220 221 <br><dt><samp><span class="env">--size-sort</span></samp><dd>Sort symbols by size. The size is computed as the difference between 222the value of the symbol and the value of the symbol with the next higher 223value. If the <code>bsd</code> output format is used the size of the symbol 224is printed, rather than the value, and ‘<samp><span class="samp">-S</span></samp>’ must be used in order 225both size and value to be printed. 226 227 <br><dt><samp><span class="env">--special-syms</span></samp><dd>Display symbols which have a target-specific special meaning. These 228symbols are usually used by the target for some special processing and 229are not normally helpful when included included in the normal symbol 230lists. For example for ARM targets this option would skip the mapping 231symbols used to mark transitions between ARM code, THUMB code and 232data. 233 234 <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 235‘<samp><span class="samp">d</span></samp>’ for decimal, ‘<samp><span class="samp">o</span></samp>’ for octal, or ‘<samp><span class="samp">x</span></samp>’ for hexadecimal. 236 237 <br><dt><samp><span class="env">--target=</span><var>bfdname</var></samp><dd><a name="index-object-code-format-50"></a>Specify an object code format other than your system's default format. 238See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information. 239 240 <br><dt><samp><span class="env">-u</span></samp><dt><samp><span class="env">--undefined-only</span></samp><dd><a name="index-external-symbols-51"></a><a name="index-undefined-symbols-52"></a>Display only undefined symbols (those external to each object file). 241 242 <br><dt><samp><span class="env">--defined-only</span></samp><dd><a name="index-external-symbols-53"></a><a name="index-undefined-symbols-54"></a>Display only defined symbols for each object file. 243 244 <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. 245 246 <br><dt><samp><span class="env">-X</span></samp><dd>This option is ignored for compatibility with the AIX version of 247<samp><span class="command">nm</span></samp>. It takes one parameter which must be the string 248<samp><span class="option">32_64</span></samp>. The default mode of AIX <samp><span class="command">nm</span></samp> corresponds 249to <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>. 250 251 <br><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. 252</dl> 253 254<!-- man end --> 255 </body></html> 256 257