Files
oldlinux-files/Ref-docs/POSIX/susv3/utilities/nm.html
2024-02-19 00:21:47 -05:00

464 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>nm</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="nm"></a> <a name="tag_04_94"></a><!-- nm -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_04_94_01"></a>NAME</h4>
<blockquote>nm - write the name list of an object file (<b>DEVELOPMENT</b>)</blockquote>
<h4><a name="tag_04_94_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('UP SD XSI')">UP SD XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> nm</tt> <b>[</b><tt>-APv</tt><b>][</b><tt>-efox</tt><b>][</b> <tt>-g| -u</tt><b>][</b><tt>-t</tt>
<i>format</i><b>]</b> <i>file</i><tt>... <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
</blockquote>
<h4><a name="tag_04_94_03"></a>DESCRIPTION</h4>
<blockquote>
<p>This utility shall be provided on systems that support both the User Portability Utilities option and the Software Development
Utilities option. On other systems it is optional. Certain options are only available on XSI-conformant systems.</p>
<p>The <i>nm</i> utility shall display symbolic information appearing in the object file, executable file, or object-file library
named by <i>file</i>. If no symbolic information is available for a valid input file, the <i>nm</i> utility shall report that fact,
but not consider it an error condition.</p>
<p>The default base used when numeric values are written is unspecified. <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup>
<img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;On XSI-conformant systems, it shall be decimal. <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
</blockquote>
<h4><a name="tag_04_94_04"></a>OPTIONS</h4>
<blockquote>
<p>The <i>nm</i> utility shall conform to the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
<p>The following options shall be supported:</p>
<dl compact>
<dt><b>-A</b></dt>
<dd>Write the full pathname or library name of an object on each line.</dd>
<dt><b>-e</b></dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Write only external (global) and static symbol information. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt><b>-f</b></dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Produce full output. Write redundant symbols ( <b>.text</b>, <b>.data</b>, and <b>.bss</b>), normally suppressed. <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt><b>-g</b></dt>
<dd>Write only external (global) symbol information.</dd>
<dt><b>-o</b></dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Write numeric values in octal (equivalent to <b>-t&nbsp;o</b>). <img src="../images/opt-end.gif" alt="[Option End]" border=
"0"></dd>
<dt><b>-P</b></dt>
<dd>Write information in a portable output format, as specified in the STDOUT section.</dd>
<dt><b>-t&nbsp;</b> <i>format</i></dt>
<dd>Write each numeric value in the specified format. The format shall be dependent on the single character used as the
<i>format</i> option-argument:
<dl compact>
<dt><tt>d</tt></dt>
<dd>The offset is written in decimal <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif"
alt="[Option Start]" border="0"> &nbsp;(default). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt><tt>o</tt></dt>
<dd>The offset is written in octal.</dd>
<dt><tt>x</tt></dt>
<dd>The offset is written in hexadecimal.</dd>
</dl>
</dd>
<dt><b>-u</b></dt>
<dd>Write only undefined symbols.</dd>
<dt><b>-v</b></dt>
<dd>Sort output by value instead of alphabetically.</dd>
<dt><b>-x</b></dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Write numeric values in hexadecimal (equivalent to <b>-t&nbsp;x</b>). <img src="../images/opt-end.gif" alt="[Option End]" border=
"0"></dd>
</dl>
</blockquote>
<h4><a name="tag_04_94_05"></a>OPERANDS</h4>
<blockquote>
<p>The following operand shall be supported:</p>
<dl compact>
<dt><i>file</i></dt>
<dd>A pathname of an object file, executable file, or object-file library.</dd>
</dl>
</blockquote>
<h4><a name="tag_04_94_06"></a>STDIN</h4>
<blockquote>
<p>See the INPUT FILES section.</p>
</blockquote>
<h4><a name="tag_04_94_07"></a>INPUT FILES</h4>
<blockquote>
<p>The input file shall be an object file, an object-file library whose format is the same as those produced by the <a href=
"../utilities/ar.html"><i>ar</i></a> utility for link editing, or an executable file. The <i>nm</i> utility may accept additional
implementation-defined object library formats for the input file.</p>
</blockquote>
<h4><a name="tag_04_94_08"></a>ENVIRONMENT VARIABLES</h4>
<blockquote>
<p>The following environment variables shall affect the execution of <i>nm</i>:</p>
<dl compact>
<dt><i>LANG</i></dt>
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
<dt><i>LC_ALL</i></dt>
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
<dt><i>LC_COLLATE</i></dt>
<dd><br>
Determine the locale for character collation information for the symbol-name and symbol-value collation sequences.</dd>
<dt><i>LC_CTYPE</i></dt>
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
opposed to multi-byte characters in arguments).</dd>
<dt><i>LC_MESSAGES</i></dt>
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
error.</dd>
<dt><i>NLSPATH</i></dt>
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
"[Option End]" border="0"></dd>
</dl>
</blockquote>
<h4><a name="tag_04_94_09"></a>ASYNCHRONOUS EVENTS</h4>
<blockquote>
<p>Default.</p>
</blockquote>
<h4><a name="tag_04_94_10"></a>STDOUT</h4>
<blockquote>
<p>If symbolic information is present in the input files, then for each file or for each member of an archive, the <i>nm</i>
utility shall write the following information to standard output. By default, the format is unspecified, but the output shall be
sorted alphabetically by symbol name:</p>
<ul>
<li>
<p>Library or object name, if <b>-A</b> is specified</p>
</li>
<li>
<p>Symbol name</p>
</li>
<li>
<p>Symbol type, which shall either be one of the following single characters or an implementation-defined type represented by a
single character:</p>
<dl compact>
<dt><tt>A</tt></dt>
<dd>Global absolute symbol.</dd>
<dt><tt>a</tt></dt>
<dd>Local absolute symbol.</dd>
<dt><tt>B</tt></dt>
<dd>Global &quot;bss&quot; (that is, uninitialized data space) symbol.</dd>
<dt><tt>b</tt></dt>
<dd>Local bss symbol.</dd>
<dt><tt>D</tt></dt>
<dd>Global data symbol.</dd>
<dt><tt>d</tt></dt>
<dd>Local data symbol.</dd>
<dt><tt>T</tt></dt>
<dd>Global text symbol.</dd>
<dt><tt>t</tt></dt>
<dd>Local text symbol.</dd>
<dt><tt>U</tt></dt>
<dd>Undefined symbol.</dd>
</dl>
</li>
<li>
<p>Value of the symbol</p>
</li>
<li>
<p>The size associated with the symbol, if applicable</p>
</li>
</ul>
<p>This information may be supplemented by additional information specific to the implementation.</p>
<p>If the <b>-P</b> option is specified, the previous information shall be displayed using the following portable format. The three
versions differ depending on whether <b>-t&nbsp;d</b>, <b>-t&nbsp;o</b>, or <b>-t&nbsp;x</b> was specified, respectively:</p>
<pre>
<tt>"%s%s %s %d %d\n", &lt;</tt><i>library/object name</i><tt>&gt;, &lt;</tt><i>name</i><tt>&gt;, &lt;</tt><i>type</i><tt>&gt;,
&lt;</tt><i>value</i><tt>&gt;, &lt;</tt><i>size</i><tt>&gt;
<br>
"%s%s %s %o %o\n", &lt;</tt><i>library/object name</i><tt>&gt;, &lt;</tt><i>name</i><tt>&gt;, &lt;</tt><i>type</i><tt>&gt;,
&lt;</tt><i>value</i><tt>&gt;, &lt;</tt><i>size</i><tt>&gt;
<br>
"%s%s %s %x %x\n", &lt;</tt><i>library/object name</i><tt>&gt;, &lt;</tt><i>name</i><tt>&gt;, &lt;</tt><i>type</i><tt>&gt;,
&lt;</tt><i>value</i><tt>&gt;, &lt;</tt><i>size</i><tt>&gt;
</tt>
</pre>
where &lt;<i>library/object&nbsp;name</i>&gt; shall be formatted as follows:
<ul>
<li>
<p>If <b>-A</b> is not specified, &lt;<i>library/object&nbsp;name</i>&gt; shall be an empty string.</p>
</li>
<li>
<p>If <b>-A</b> is specified and the corresponding <i>file</i> operand does not name a library:</p>
<pre>
<tt>"%s: ", &lt;</tt><i>file</i><tt>&gt;
</tt>
</pre>
</li>
<li>
<p>If <b>-A</b> is specified and the corresponding <i>file</i> operand names a library. In this case,
&lt;<i>object&nbsp;file</i>&gt; shall name the object file in the library containing the symbol being described:</p>
<pre>
<tt>"%s[%s]: ", &lt;</tt><i>file</i><tt>&gt;, &lt;</tt><i>object file</i><tt>&gt;
</tt>
</pre>
</li>
</ul>
<p>If <b>-A</b> is not specified, then if more than one <i>file</i> operand is specified or if only one <i>file</i> operand is
specified and it names a library, <i>nm</i> shall write a line identifying the object containing the following symbols before the
lines containing those symbols, in the form:</p>
<ul>
<li>
<p>If the corresponding <i>file</i> operand does not name a library:</p>
<pre>
<tt>"%s:\n", &lt;</tt><i>file</i><tt>&gt;
</tt>
</pre>
</li>
<li>
<p>If the corresponding <i>file</i> operand names a library; in this case, &lt;<i>object&nbsp;file</i>&gt; shall be the name of the
file in the library containing the following symbols:</p>
<pre>
<tt>"%s[%s]:\n", &lt;</tt><i>file</i><tt>&gt;, &lt;</tt><i>object file</i><tt>&gt;
</tt>
</pre>
</li>
</ul>
<p>If <b>-P</b> is specified, but <b>-t</b> is not, the format shall be as if <b>-t&nbsp;x</b> had been specified.</p>
</blockquote>
<h4><a name="tag_04_94_11"></a>STDERR</h4>
<blockquote>
<p>The standard error shall be used only for diagnostic messages.</p>
</blockquote>
<h4><a name="tag_04_94_12"></a>OUTPUT FILES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_94_13"></a>EXTENDED DESCRIPTION</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_94_14"></a>EXIT STATUS</h4>
<blockquote>
<p>The following exit values shall be returned:</p>
<dl compact>
<dt>&nbsp;0</dt>
<dd>Successful completion.</dd>
<dt>&gt;0</dt>
<dd>An error occurred.</dd>
</dl>
</blockquote>
<h4><a name="tag_04_94_15"></a>CONSEQUENCES OF ERRORS</h4>
<blockquote>
<p>Default.</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_04_94_16"></a>APPLICATION USAGE</h4>
<blockquote>
<p>Mechanisms for dynamic linking make this utility less meaningful when applied to an executable file because a dynamically linked
executable may omit numerous library routines that would be found in a statically linked executable.</p>
</blockquote>
<h4><a name="tag_04_94_17"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_94_18"></a>RATIONALE</h4>
<blockquote>
<p>Historical implementations of <i>nm</i> have used different bases for numeric output and supplied different default types of
symbols that were reported. The <b>-t</b> <i>format</i> option, similar to that used in <a href=
"../utilities/od.html"><i>od</i></a> and <a href="../utilities/strings.html"><i>strings</i></a>, can be used to specify the numeric
base; <b>-g</b> and <b>-u</b> can be used to restrict the amount of output or the types of symbols included in the output.</p>
<p>The compromise of using <b>-t</b> <i>format</i> <i>versus</i> using <b>-d</b>, <b>-o</b>, and other similar options was
necessary because of differences in the meaning of <b>-o</b> between implementations. The <b>-o</b> option from BSD has been
provided here as <b>-A</b> to avoid confusion with the <b>-o</b> from System V (which has been provided here as <b>-t</b> and as
<b>-o</b> on XSI-conformant systems).</p>
<p>The option list was significantly reduced from that provided by historical implementations.</p>
<p>The <i>nm</i> description is a subset of both the System V and BSD <i>nm</i> utilities with no specified default output.</p>
<p>It was recognized that mechanisms for dynamic linking make this utility less meaningful when applied to an executable file
(because a dynamically linked executable file may omit numerous library routines that would be found in a statically linked
executable file), but the value of <i>nm</i> during software development was judged to outweigh other limitations.</p>
<p>The default output format of <i>nm</i> is not specified because of differences in historical implementations. The <b>-P</b>
option was added to allow some type of portable output format. After a comparison of the different formats used in SunOS, BSD,
SVR3, and SVR4, it was decided to create one that did not match the current format of any of these four systems. The format devised
is easy to parse by humans, easy to parse in shell scripts, and does not need to vary depending on locale (because no English
descriptions are included). All of the systems currently have the information available to use this format.</p>
<p>The format given in <i>nm</i> STDOUT uses spaces between the fields, which may be any number of &lt;blank&gt;s required to align
the columns. The single-character types were selected to match historical practice, and the requirement that implementation
additions also be single characters made parsing the information easier for shell scripts.</p>
</blockquote>
<h4><a name="tag_04_94_19"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_94_20"></a>SEE ALSO</h4>
<blockquote>
<p><a href="ar.html"><i>ar</i></a> , <a href="c99.html"><i>c99</i></a></p>
</blockquote>
<h4><a name="tag_04_94_21"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 2.</p>
</blockquote>
<h4><a name="tag_04_94_22"></a>Issue 6</h4>
<blockquote>
<p>This utility is marked as supported when both the User Portability Utilities option and the Software Development Utilities
option are supported.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>