1NM(P) POSIX Programmer's Manual NM(P)
2
3
4
6 nm - write the name list of an object file (DEVELOPMENT)
7
9 nm [-APv][-efox][ -g| -u][-t format] file...
10
12 This utility shall be provided on systems that support both the User
13 Portability Utilities option and the Software Development Utilities
14 option. On other systems it is optional. Certain options are only
15 available on XSI-conformant systems.
16
17 The nm utility shall display symbolic information appearing in the
18 object file, executable file, or object-file library named by file. If
19 no symbolic information is available for a valid input file, the nm
20 utility shall report that fact, but not consider it an error condition.
21
22 The default base used when numeric values are written is unspecified.
23 On XSI-conformant systems, it shall be decimal.
24
26 The nm utility shall conform to the Base Definitions volume of
27 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
28
29 The following options shall be supported:
30
31 -A Write the full pathname or library name of an object on each
32 line.
33
34 -e Write only external (global) and static symbol information.
35
36 -f Produce full output. Write redundant symbols ( .text, .data, and
37 .bss), normally suppressed.
38
39 -g Write only external (global) symbol information.
40
41 -o Write numeric values in octal (equivalent to -t o).
42
43 -P Write information in a portable output format, as specified in
44 the STDOUT section.
45
46 -t format
47 Write each numeric value in the specified format. The format
48 shall be dependent on the single character used as the format
49 option-argument:
50
51 d
52 The offset is written in decimal (default).
53
54 o
55 The offset is written in octal.
56
57 x
58 The offset is written in hexadecimal.
59
60
61 -u Write only undefined symbols.
62
63 -v Sort output by value instead of alphabetically.
64
65 -x Write numeric values in hexadecimal (equivalent to -t x).
66
67
69 The following operand shall be supported:
70
71 file A pathname of an object file, executable file, or object-file
72 library.
73
74
76 See the INPUT FILES section.
77
79 The input file shall be an object file, an object-file library whose
80 format is the same as those produced by the ar utility for link edit‐
81 ing, or an executable file. The nm utility may accept additional imple‐
82 mentation-defined object library formats for the input file.
83
85 The following environment variables shall affect the execution of nm:
86
87 LANG Provide a default value for the internationalization variables
88 that are unset or null. (See the Base Definitions volume of
89 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
90 ables for the precedence of internationalization variables used
91 to determine the values of locale categories.)
92
93 LC_ALL If set to a non-empty string value, override the values of all
94 the other internationalization variables.
95
96 LC_COLLATE
97
98 Determine the locale for character collation information for the
99 symbol-name and symbol-value collation sequences.
100
101 LC_CTYPE
102 Determine the locale for the interpretation of sequences of
103 bytes of text data as characters (for example, single-byte as
104 opposed to multi-byte characters in arguments).
105
106 LC_MESSAGES
107 Determine the locale that should be used to affect the format
108 and contents of diagnostic messages written to standard error.
109
110 NLSPATH
111 Determine the location of message catalogs for the processing of
112 LC_MESSAGES .
113
114
116 Default.
117
119 If symbolic information is present in the input files, then for each
120 file or for each member of an archive, the nm utility shall write the
121 following information to standard output. By default, the format is
122 unspecified, but the output shall be sorted alphabetically by symbol
123 name:
124
125 * Library or object name, if -A is specified
126
127 * Symbol name
128
129 * Symbol type, which shall either be one of the following single char‐
130 acters or an implementation-defined type represented by a single
131 character:
132
133 A
134 Global absolute symbol.
135
136 a
137 Local absolute symbol.
138
139 B
140 Global "bss" (that is, uninitialized data space) symbol.
141
142 b
143 Local bss symbol.
144
145 D
146 Global data symbol.
147
148 d
149 Local data symbol.
150
151 T
152 Global text symbol.
153
154 t
155 Local text symbol.
156
157 U
158 Undefined symbol.
159
160
161 * Value of the symbol
162
163 * The size associated with the symbol, if applicable
164
165 This information may be supplemented by additional information specific
166 to the implementation.
167
168 If the -P option is specified, the previous information shall be dis‐
169 played using the following portable format. The three versions differ
170 depending on whether -t d, -t o, or -t x was specified, respectively:
171
172
173 "%s%s %s %d %d\n", <library/object name>, <name>, <type>,
174 <value>, <size>
175
176
177 "%s%s %s %o %o\n", <library/object name>, <name>, <type>,
178 <value>, <size>
179
180
181 "%s%s %s %x %x\n", <library/object name>, <name>, <type>,
182 <value>, <size>
183 where <library/object name> shall be formatted as follows:
184
185 * If -A is not specified, <library/object name> shall be an empty
186 string.
187
188 * If -A is specified and the corresponding file operand does not name
189 a library:
190
191
192 "%s: ", <file>
193
194 * If -A is specified and the corresponding file operand names a
195 library. In this case, <object file> shall name the object file in
196 the library containing the symbol being described:
197
198
199 "%s[%s]: ", <file>, <object file>
200
201 If -A is not specified, then if more than one file operand is specified
202 or if only one file operand is specified and it names a library, nm
203 shall write a line identifying the object containing the following sym‐
204 bols before the lines containing those symbols, in the form:
205
206 * If the corresponding file operand does not name a library:
207
208
209 "%s:\n", <file>
210
211 * If the corresponding file operand names a library; in this case,
212 <object file> shall be the name of the file in the library contain‐
213 ing the following symbols:
214
215
216 "%s[%s]:\n", <file>, <object file>
217
218 If -P is specified, but -t is not, the format shall be as if -t x had
219 been specified.
220
222 The standard error shall be used only for diagnostic messages.
223
225 None.
226
228 None.
229
231 The following exit values shall be returned:
232
233 0 Successful completion.
234
235 >0 An error occurred.
236
237
239 Default.
240
241 The following sections are informative.
242
244 Mechanisms for dynamic linking make this utility less meaningful when
245 applied to an executable file because a dynamically linked executable
246 may omit numerous library routines that would be found in a statically
247 linked executable.
248
250 None.
251
253 Historical implementations of nm have used different bases for numeric
254 output and supplied different default types of symbols that were
255 reported. The -t format option, similar to that used in od and strings,
256 can be used to specify the numeric base; -g and -u can be used to
257 restrict the amount of output or the types of symbols included in the
258 output.
259
260 The compromise of using -t format versus using -d, -o, and other simi‐
261 lar options was necessary because of differences in the meaning of -o
262 between implementations. The -o option from BSD has been provided here
263 as -A to avoid confusion with the -o from System V (which has been pro‐
264 vided here as -t and as -o on XSI-conformant systems).
265
266 The option list was significantly reduced from that provided by histor‐
267 ical implementations.
268
269 The nm description is a subset of both the System V and BSD nm utili‐
270 ties with no specified default output.
271
272 It was recognized that mechanisms for dynamic linking make this utility
273 less meaningful when applied to an executable file (because a dynami‐
274 cally linked executable file may omit numerous library routines that
275 would be found in a statically linked executable file), but the value
276 of nm during software development was judged to outweigh other limita‐
277 tions.
278
279 The default output format of nm is not specified because of differences
280 in historical implementations. The -P option was added to allow some
281 type of portable output format. After a comparison of the different
282 formats used in SunOS, BSD, SVR3, and SVR4, it was decided to create
283 one that did not match the current format of any of these four systems.
284 The format devised is easy to parse by humans, easy to parse in shell
285 scripts, and does not need to vary depending on locale (because no Eng‐
286 lish descriptions are included). All of the systems currently have the
287 information available to use this format.
288
289 The format given in nm STDOUT uses spaces between the fields, which may
290 be any number of <blank>s required to align the columns. The single-
291 character types were selected to match historical practice, and the
292 requirement that implementation additions also be single characters
293 made parsing the information easier for shell scripts.
294
296 None.
297
299 ar , c99
300
302 Portions of this text are reprinted and reproduced in electronic form
303 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
304 -- Portable Operating System Interface (POSIX), The Open Group Base
305 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
306 Electrical and Electronics Engineers, Inc and The Open Group. In the
307 event of any discrepancy between this version and the original IEEE and
308 The Open Group Standard, the original IEEE and The Open Group Standard
309 is the referee document. The original Standard can be obtained online
310 at http://www.opengroup.org/unix/online.html .
311
312
313
314IEEE/The Open Group 2003 NM(P)