Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

485 lines
19KB

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