nm.html 17 KB

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