1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 1991-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3
7or any later version published by the Free Software Foundation;
8with no Invariant Sections, with no Front-Cover Texts, and with no
9Back-Cover Texts.  A copy of the license is included in the
10section entitled "GNU Free Documentation License".
11 -->
12<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
13<head>
14<title>GNU Binary Utilities: nm</title>
15
16<meta name="description" content="GNU Binary Utilities: nm">
17<meta name="keywords" content="GNU Binary Utilities: nm">
18<meta name="resource-type" content="document">
19<meta name="distribution" content="global">
20<meta name="Generator" content="makeinfo">
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<link href="index.html#Top" rel="start" title="Top">
23<link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
24<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
25<link href="index.html#Top" rel="up" title="Top">
26<link href="objcopy.html#objcopy" rel="next" title="objcopy">
27<link href="ar-scripts.html#ar-scripts" rel="previous" title="ar scripts">
28<style type="text/css">
29<!--
30a.summary-letter {text-decoration: none}
31blockquote.smallquotation {font-size: smaller}
32div.display {margin-left: 3.2em}
33div.example {margin-left: 3.2em}
34div.indentedblock {margin-left: 3.2em}
35div.lisp {margin-left: 3.2em}
36div.smalldisplay {margin-left: 3.2em}
37div.smallexample {margin-left: 3.2em}
38div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
39div.smalllisp {margin-left: 3.2em}
40kbd {font-style:oblique}
41pre.display {font-family: inherit}
42pre.format {font-family: inherit}
43pre.menu-comment {font-family: serif}
44pre.menu-preformatted {font-family: serif}
45pre.smalldisplay {font-family: inherit; font-size: smaller}
46pre.smallexample {font-size: smaller}
47pre.smallformat {font-family: inherit; font-size: smaller}
48pre.smalllisp {font-size: smaller}
49span.nocodebreak {white-space:nowrap}
50span.nolinebreak {white-space:nowrap}
51span.roman {font-family:serif; font-weight:normal}
52span.sansserif {font-family:sans-serif; font-weight:normal}
53ul.no-bullet {list-style: none}
54-->
55</style>
56
57
58</head>
59
60<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
61<a name="nm"></a>
62<div class="header">
63<p>
64Next: <a href="objcopy.html#objcopy" accesskey="n" rel="next">objcopy</a>, Previous: <a href="ar.html#ar" accesskey="p" rel="previous">ar</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
65</div>
66<hr>
67<a name="nm-1"></a>
68<h2 class="chapter">2 nm</h2>
69<a name="index-symbols"></a>
70<a name="index-nm"></a>
71
72
73<div class="smallexample">
74<pre class="smallexample">nm [<samp>-A</samp>|<samp>-o</samp>|<samp>--print-file-name</samp>] [<samp>-a</samp>|<samp>--debug-syms</samp>]
75   [<samp>-B</samp>|<samp>--format=bsd</samp>] [<samp>-C</samp>|<samp>--demangle</samp>[=<var>style</var>]]
76   [<samp>-D</samp>|<samp>--dynamic</samp>] [<samp>-f</samp><var>format</var>|<samp>--format=</samp><var>format</var>]
77   [<samp>-g</samp>|<samp>--extern-only</samp>] [<samp>-h</samp>|<samp>--help</samp>]
78   [<samp>--ifunc-chars=<var>CHARS</var></samp>]
79   [<samp>-l</samp>|<samp>--line-numbers</samp>] [<samp>--inlines</samp>]
80   [<samp>-n</samp>|<samp>-v</samp>|<samp>--numeric-sort</samp>]
81   [<samp>-P</samp>|<samp>--portability</samp>] [<samp>-p</samp>|<samp>--no-sort</samp>]
82   [<samp>-r</samp>|<samp>--reverse-sort</samp>] [<samp>-S</samp>|<samp>--print-size</samp>]
83   [<samp>-s</samp>|<samp>--print-armap</samp>] [<samp>-t</samp> <var>radix</var>|<samp>--radix=</samp><var>radix</var>]
84   [<samp>-u</samp>|<samp>--undefined-only</samp>] [<samp>-V</samp>|<samp>--version</samp>]
85   [<samp>-X 32_64</samp>] [<samp>--defined-only</samp>] [<samp>--no-demangle</samp>]
86   [<samp>--plugin</samp> <var>name</var>]
87   [<samp>--no-recurse-limit</samp>|<samp>--recurse-limit</samp>]]
88   [<samp>--size-sort</samp>] [<samp>--special-syms</samp>]
89   [<samp>--synthetic</samp>] [<samp>--target=</samp><var>bfdname</var>]
90   [<var>objfile</var>&hellip;]
91</pre></div>
92
93<p><small>GNU</small> <code>nm</code> lists the symbols from object files <var>objfile</var>&hellip;.
94If no object files are listed as arguments, <code>nm</code> assumes the file
95<samp>a.out</samp>.
96</p>
97<p>For each symbol, <code>nm</code> shows:
98</p>
99<ul>
100<li> The symbol value, in the radix selected by options (see below), or
101hexadecimal by default.
102
103</li><li> The symbol type.  At least the following types are used; others are, as
104well, depending on the object file format.  If lowercase, the symbol is
105usually local; if uppercase, the symbol is global (external).  There
106are however a few lowercase symbols that are shown for special global
107symbols (<code>u</code>, <code>v</code> and <code>w</code>).
108
109<dl compact="compact">
110<dt><code>A</code></dt>
111<dd><p>The symbol&rsquo;s value is absolute, and will not be changed by further
112linking.
113</p>
114</dd>
115<dt><code>B</code></dt>
116<dt><code>b</code></dt>
117<dd><p>The symbol is in the BSS data section.  This section typically
118contains zero-initialized or uninitialized data, although the exact
119behavior is system dependent.
120</p>
121</dd>
122<dt><code>C</code></dt>
123<dt><code>c</code></dt>
124<dd><p>The symbol is common.  Common symbols are uninitialized data.  When
125linking, multiple common symbols may appear with the same name.  If the
126symbol is defined anywhere, the common symbols are treated as undefined
127references.
128For more details on common symbols, see the discussion of
129&ndash;warn-common in <a href="http://sourceware.org/binutils/docs/ld/Options.html#Options">Linker options</a> in <cite>The GNU linker</cite>.
130The lower case <var>c</var> character is used when the symbol is in a
131special section for small commons.
132</p>
133</dd>
134<dt><code>D</code></dt>
135<dt><code>d</code></dt>
136<dd><p>The symbol is in the initialized data section.
137</p>
138</dd>
139<dt><code>G</code></dt>
140<dt><code>g</code></dt>
141<dd><p>The symbol is in an initialized data section for small objects.  Some
142object file formats permit more efficient access to small data objects,
143such as a global int variable as opposed to a large global array.
144</p>
145</dd>
146<dt><code>i</code></dt>
147<dd><p>For PE format files this indicates that the symbol is in a section
148specific to the implementation of DLLs.
149</p>
150<p>For ELF format files this indicates that the symbol is an indirect
151function.  This is a GNU extension to the standard set of ELF symbol
152types.  It indicates a symbol which if referenced by a relocation does
153not evaluate to its address, but instead must be invoked at runtime.
154The runtime execution will then return the value to be used in the
155relocation.
156</p>
157<p>Note - the actual symbols display for GNU indirect symbols is
158controlled by the <samp>--ifunc-chars</samp> command line option.  If this
159option has been provided then the first character in the string will
160be used for global indirect function symbols.  If the string contains
161a second character then that will be used for local indirect function
162symbols.
163</p>
164</dd>
165<dt><code>I</code></dt>
166<dd><p>The symbol is an indirect reference to another symbol.
167</p>
168</dd>
169<dt><code>N</code></dt>
170<dd><p>The symbol is a debugging symbol.
171</p>
172</dd>
173<dt><code>n</code></dt>
174<dd><p>The symbol is in the read-only data section.
175</p>
176</dd>
177<dt><code>p</code></dt>
178<dd><p>The symbol is in a stack unwind section.
179</p>
180</dd>
181<dt><code>R</code></dt>
182<dt><code>r</code></dt>
183<dd><p>The symbol is in a read only data section.
184</p>
185</dd>
186<dt><code>S</code></dt>
187<dt><code>s</code></dt>
188<dd><p>The symbol is in an uninitialized or zero-initialized data section
189for small objects.
190</p>
191</dd>
192<dt><code>T</code></dt>
193<dt><code>t</code></dt>
194<dd><p>The symbol is in the text (code) section.
195</p>
196</dd>
197<dt><code>U</code></dt>
198<dd><p>The symbol is undefined.
199</p>
200</dd>
201<dt><code>u</code></dt>
202<dd><p>The symbol is a unique global symbol.  This is a GNU extension to the
203standard set of ELF symbol bindings.  For such a symbol the dynamic linker
204will make sure that in the entire process there is just one symbol with
205this name and type in use.
206</p>
207</dd>
208<dt><code>V</code></dt>
209<dt><code>v</code></dt>
210<dd><p>The symbol is a weak object.  When a weak defined symbol is linked with
211a normal defined symbol, the normal defined symbol is used with no error.
212When a weak undefined symbol is linked and the symbol is not defined,
213the value of the weak symbol becomes zero with no error.  On some
214systems, uppercase indicates that a default value has been specified.
215</p>
216</dd>
217<dt><code>W</code></dt>
218<dt><code>w</code></dt>
219<dd><p>The symbol is a weak symbol that has not been specifically tagged as a
220weak object symbol.  When a weak defined symbol is linked with a normal
221defined symbol, the normal defined symbol is used with no error.
222When a weak undefined symbol is linked and the symbol is not defined,
223the value of the symbol is determined in a system-specific manner without
224error.  On some systems, uppercase indicates that a default value has been
225specified.
226</p>
227</dd>
228<dt><code>-</code></dt>
229<dd><p>The symbol is a stabs symbol in an a.out object file.  In this case, the
230next values printed are the stabs other field, the stabs desc field, and
231the stab type.  Stabs symbols are used to hold debugging information.
232</p>
233</dd>
234<dt><code>?</code></dt>
235<dd><p>The symbol type is unknown, or object file format specific.
236</p></dd>
237</dl>
238
239</li><li> The symbol name.  If a symbol has version information associated with it,
240then the version information is displayed as well.  If the versioned
241symbol is undefined or hidden from linker, the version string is displayed
242as a suffix to the symbol name, preceded by an @ character.  For example
243&lsquo;<samp>foo@VER_1</samp>&rsquo;.  If the version is the default version to be used when
244resolving unversioned references to the symbol, then it is displayed as a
245suffix preceded by two @ characters.  For example &lsquo;<samp>foo@@VER_2</samp>&rsquo;.
246</li></ul>
247
248
249<p>The long and short forms of options, shown here as alternatives, are
250equivalent.
251</p>
252<dl compact="compact">
253<dt><code>-A</code></dt>
254<dt><code>-o</code></dt>
255<dt><code>--print-file-name</code></dt>
256<dd><a name="index-input-file-name"></a>
257<a name="index-file-name"></a>
258<a name="index-source-file-name"></a>
259<p>Precede each symbol by the name of the input file (or archive member)
260in which it was found, rather than identifying the input file once only,
261before all of its symbols.
262</p>
263</dd>
264<dt><code>-a</code></dt>
265<dt><code>--debug-syms</code></dt>
266<dd><a name="index-debugging-symbols"></a>
267<p>Display all symbols, even debugger-only symbols; normally these are not
268listed.
269</p>
270</dd>
271<dt><code>-B</code></dt>
272<dd><a name="index-nm-format"></a>
273<a name="index-nm-compatibility"></a>
274<p>The same as <samp>--format=bsd</samp> (for compatibility with the MIPS <code>nm</code>).
275</p>
276</dd>
277<dt><code>-C</code></dt>
278<dt><code>--demangle[=<var>style</var>]</code></dt>
279<dd><a name="index-demangling-in-nm"></a>
280<p>Decode (<em>demangle</em>) low-level symbol names into user-level names.
281Besides removing any initial underscore prepended by the system, this
282makes C++ function names readable. Different compilers have different
283mangling styles. The optional demangling style argument can be used to
284choose an appropriate demangling style for your compiler. See <a href="c_002b_002bfilt.html#c_002b_002bfilt">c++filt</a>,
285for more information on demangling.
286</p>
287</dd>
288<dt><code>--no-demangle</code></dt>
289<dd><p>Do not demangle low-level symbol names.  This is the default.
290</p>
291</dd>
292<dt><code>--recurse-limit</code></dt>
293<dt><code>--no-recurse-limit</code></dt>
294<dt><code>--recursion-limit</code></dt>
295<dt><code>--no-recursion-limit</code></dt>
296<dd><p>Enables or disables a limit on the amount of recursion performed
297whilst demangling strings.  Since the name mangling formats allow for
298an infinite level of recursion it is possible to create strings whose
299decoding will exhaust the amount of stack space available on the host
300machine, triggering a memory fault.  The limit tries to prevent this
301from happening by restricting recursion to 2048 levels of nesting.
302</p>
303<p>The default is for this limit to be enabled, but disabling it may be
304necessary in order to demangle truly complicated names.  Note however
305that if the recursion limit is disabled then stack exhaustion is
306possible and any bug reports about such an event will be rejected.
307</p>
308</dd>
309<dt><code>-D</code></dt>
310<dt><code>--dynamic</code></dt>
311<dd><a name="index-dynamic-symbols"></a>
312<p>Display the dynamic symbols rather than the normal symbols.  This is
313only meaningful for dynamic objects, such as certain types of shared
314libraries.
315</p>
316</dd>
317<dt><code>-f <var>format</var></code></dt>
318<dt><code>--format=<var>format</var></code></dt>
319<dd><a name="index-nm-format-1"></a>
320<a name="index-nm-compatibility-1"></a>
321<p>Use the output format <var>format</var>, which can be <code>bsd</code>,
322<code>sysv</code>, or <code>posix</code>.  The default is <code>bsd</code>.
323Only the first character of <var>format</var> is significant; it can be
324either upper or lower case.
325</p>
326</dd>
327<dt><code>-g</code></dt>
328<dt><code>--extern-only</code></dt>
329<dd><a name="index-external-symbols"></a>
330<p>Display only external symbols.
331</p>
332</dd>
333<dt><code>-h</code></dt>
334<dt><code>--help</code></dt>
335<dd><p>Show a summary of the options to <code>nm</code> and exit.
336</p>
337</dd>
338<dt><code>--ifunc-chars=<var>CHARS</var></code></dt>
339<dd><p>When display GNU indirect function symbols <code>nm</code> will default
340to using the <code>i</code> character for both local indirect functions and
341global indirect functions.  The <samp>--ifunc-chars</samp> option allows
342the user to specify a string containing one or two characters. The
343first character will be used for global indirect function symbols and
344the second character, if present, will be used for local indirect
345function symbols.
346</p>
347</dd>
348<dt><code>-l</code></dt>
349<dt><code>--line-numbers</code></dt>
350<dd><a name="index-symbol-line-numbers"></a>
351<p>For each symbol, use debugging information to try to find a filename and
352line number.  For a defined symbol, look for the line number of the
353address of the symbol.  For an undefined symbol, look for the line
354number of a relocation entry which refers to the symbol.  If line number
355information can be found, print it after the other symbol information.
356</p>
357</dd>
358<dt><code>--inlines</code></dt>
359<dd><a name="index-objdump-inlines"></a>
360<p>When option <samp>-l</samp> is active, if the address belongs to a
361function that was inlined, then this option causes the source
362information for all enclosing scopes back to the first non-inlined
363function to be printed as well.  For example, if <code>main</code> inlines
364<code>callee1</code> which inlines <code>callee2</code>, and address is from
365<code>callee2</code>, the source information for <code>callee1</code> and <code>main</code>
366will also be printed.
367</p>
368</dd>
369<dt><code>-n</code></dt>
370<dt><code>-v</code></dt>
371<dt><code>--numeric-sort</code></dt>
372<dd><p>Sort symbols numerically by their addresses, rather than alphabetically
373by their names.
374</p>
375</dd>
376<dt><code>-p</code></dt>
377<dt><code>--no-sort</code></dt>
378<dd><a name="index-sorting-symbols"></a>
379<p>Do not bother to sort the symbols in any order; print them in the order
380encountered.
381</p>
382</dd>
383<dt><code>-P</code></dt>
384<dt><code>--portability</code></dt>
385<dd><p>Use the POSIX.2 standard output format instead of the default format.
386Equivalent to &lsquo;<samp>-f posix</samp>&rsquo;.
387</p>
388</dd>
389<dt><code>-r</code></dt>
390<dt><code>--reverse-sort</code></dt>
391<dd><p>Reverse the order of the sort (whether numeric or alphabetic); let the
392last come first.
393</p>
394</dd>
395<dt><code>-S</code></dt>
396<dt><code>--print-size</code></dt>
397<dd><p>Print both value and size of defined symbols for the <code>bsd</code> output style.
398This option has no effect for object formats that do not record symbol
399sizes, unless &lsquo;<samp>--size-sort</samp>&rsquo; is also used in which case a
400calculated size is displayed.
401</p>
402</dd>
403<dt><code>-s</code></dt>
404<dt><code>--print-armap</code></dt>
405<dd><a name="index-symbol-index_002c-listing"></a>
406<p>When listing symbols from archive members, include the index: a mapping
407(stored in the archive by <code>ar</code> or <code>ranlib</code>) of which modules
408contain definitions for which names.
409</p>
410</dd>
411<dt><code>-t <var>radix</var></code></dt>
412<dt><code>--radix=<var>radix</var></code></dt>
413<dd><p>Use <var>radix</var> as the radix for printing the symbol values.  It must be
414&lsquo;<samp>d</samp>&rsquo; for decimal, &lsquo;<samp>o</samp>&rsquo; for octal, or &lsquo;<samp>x</samp>&rsquo; for hexadecimal.
415</p>
416</dd>
417<dt><code>-u</code></dt>
418<dt><code>--undefined-only</code></dt>
419<dd><a name="index-external-symbols-1"></a>
420<a name="index-undefined-symbols"></a>
421<p>Display only undefined symbols (those external to each object file).
422</p>
423</dd>
424<dt><code>-V</code></dt>
425<dt><code>--version</code></dt>
426<dd><p>Show the version number of <code>nm</code> and exit.
427</p>
428</dd>
429<dt><code>-X</code></dt>
430<dd><p>This option is ignored for compatibility with the AIX version of
431<code>nm</code>.  It takes one parameter which must be the string
432<samp>32_64</samp>.  The default mode of AIX <code>nm</code> corresponds
433to <samp>-X 32</samp>, which is not supported by <small>GNU</small> <code>nm</code>.
434</p>
435</dd>
436<dt><code>--defined-only</code></dt>
437<dd><a name="index-external-symbols-2"></a>
438<a name="index-undefined-symbols-1"></a>
439<p>Display only defined symbols for each object file.
440</p>
441</dd>
442<dt><code>--plugin <var>name</var></code></dt>
443<dd><a name="index-plugins-1"></a>
444<p>Load the plugin called <var>name</var> to add support for extra target
445types.  This option is only available if the toolchain has been built
446with plugin support enabled.
447</p>
448<p>If <samp>--plugin</samp> is not provided, but plugin support has been
449enabled then <code>nm</code> iterates over the files in
450<samp>${libdir}/bfd-plugins</samp> in alphabetic order and the first
451plugin that claims the object in question is used.
452</p>
453<p>Please note that this plugin search directory is <em>not</em> the one
454used by <code>ld</code>&rsquo;s <samp>-plugin</samp> option.  In order to make
455<code>nm</code> use the  linker plugin it must be copied into the
456<samp>${libdir}/bfd-plugins</samp> directory.  For GCC based compilations
457the linker plugin is called <samp>liblto_plugin.so.0.0.0</samp>.  For Clang
458based compilations it is called <samp>LLVMgold.so</samp>.  The GCC plugin
459is always backwards compatible with earlier versions, so it is
460sufficient to just copy the newest one.
461</p>
462</dd>
463<dt><code>--size-sort</code></dt>
464<dd><p>Sort symbols by size.  For ELF objects symbol sizes are read from the
465ELF, for other object types the symbol sizes are computed as the
466difference between the value of the symbol and the value of the symbol
467with the next higher value.  If the <code>bsd</code> output format is used
468the size of the symbol is printed, rather than the value, and
469&lsquo;<samp>-S</samp>&rsquo; must be used in order both size and value to be printed.
470</p>
471</dd>
472<dt><code>--special-syms</code></dt>
473<dd><p>Display symbols which have a target-specific special meaning.  These
474symbols are usually used by the target for some special processing and
475are not normally helpful when included in the normal symbol lists.
476For example for ARM targets this option would skip the mapping symbols
477used to mark transitions between ARM code, THUMB code and data.
478</p>
479</dd>
480<dt><code>--synthetic</code></dt>
481<dd><p>Include synthetic symbols in the output.  These are special symbols
482created by the linker for various purposes.  They are not shown by
483default since they are not part of the binary&rsquo;s original source code.
484</p>
485</dd>
486<dt><code>--target=<var>bfdname</var></code></dt>
487<dd><a name="index-object-code-format"></a>
488<p>Specify an object code format other than your system&rsquo;s default format.
489See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
490</p>
491</dd>
492</dl>
493
494
495
496<hr>
497<div class="header">
498<p>
499Next: <a href="objcopy.html#objcopy" accesskey="n" rel="next">objcopy</a>, Previous: <a href="ar.html#ar" accesskey="p" rel="previous">ar</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
500</div>
501
502
503
504</body>
505</html>
506