1nm(1) User Commands nm(1)
2
3
4
6 nm - print name list of an object file
7
9 /usr/bin/nm [-ACDhlnPprRsTuVv] [-efox] [-g | -u]
10 [-t format] file...
11
12
13 /usr/xpg4/bin/nm [-ACDhlnPprRsTuVv] [-efox] [-g | -u]
14 [-t format] file...
15
16
18 The nm utility displays the symbol table of each ELF object file that
19 is specified by file.
20
21
22 If no symbolic information is available for a valid input file, the nm
23 utility reports that fact, but not consider it an error condition.
24
26 The output of nm can be controlled using the following options:
27
28 -A Writes the full path name or library name of an object on
29 each line.
30
31
32 -C Demangles C++ symbol names before printing them out.
33
34
35 -D Displays the SHT_DYNSYM symbol information. This is the
36 symbol table used by ld.so.1 and is present even in
37 stripped dynamic executables. If -D is not specified, the
38 default behavior is to display the SHT_SYMTAB symbol
39 information.
40
41
42 -e See NOTES below.
43
44
45 -f See NOTES below.
46
47
48 -g Writes only external (global) symbol information.
49
50
51 -h Does not display the output heading data.
52
53
54 -L Displays the SHT_SUNW_LDYNSYM symbol information. This
55 symbol table contains local function symbols.
56 SHT_SUNW_LDYNSM symbol tables are present even in stripped
57 dynamic executables. These symbols augment the global sym‐
58 bols that are found in SHT_DYNSYM symbol table. If -L is
59 not specified, the default behavior is to display the
60 SHT_SYMTAB symbol information.
61
62
63 -l Distinguishes between WEAK and GLOBAL symbols by appending
64 a * to the key letter for WEAK symbols.
65
66
67 -n Sorts external symbols by name before they are printed.
68
69
70 -o Prints the value and size of a symbol in octal instead of
71 decimal (equivalent to -t o).
72
73
74 -p Produces easy to parse, terse output. Each symbol name is
75 preceded by its value (blanks if undefined) and one of the
76 letters:
77
78 A Absolute symbol.
79
80
81 B bss (uninitialized data space) symbol.
82
83
84 C COMMON symbol.
85
86
87 D Data object symbol.
88
89
90 F File symbol.
91
92
93 N Symbol has no type.
94
95
96 L Thread-Local storage symbol.
97
98
99 S Section symbol.
100
101
102 T Text symbol.
103
104
105 U Undefined.
106
107 If the symbol's binding attribute is:
108
109 LOCAL The key letter is lower case.
110
111
112 WEAK The key letter is upper case. If the -l modifier
113 is specified, the upper case key letter is fol‐
114 lowed by a *
115
116
117 GLOBAL The key letter is upper case.
118
119
120
121 -P Writes information in a portable output format, as speci‐
122 fied in Standard Output.
123
124
125 -r Prepends the name of the object file or archive to each
126 output line.
127
128
129 -R Prints the archive name (if present), followed by the
130 object file and symbol name. If the -r option is also
131 specified, this option is ignored.
132
133
134 -s Prints section name instead of section index.
135
136
137 -t format Writes each numeric value in the specified format. The
138 format is dependent on the single character used as the
139 format option-argument:
140
141 d The offset is written in decimal (default).
142
143
144 o The offset is written in octal.
145
146
147 x The offset is written in hexadecimal.
148
149
150
151 -T See NOTES.
152
153
154 /usr/bin/nm
155 -u Prints undefined symbols only.
156
157
158 /usr/xpg4/bin/nm
159 -u Prints long listing for each undefined symbol. See OUTPUT below.
160
161
162 -v Sorts external symbols by value before they are printed.
163
164
165 -V Prints the version of the nm command executing on the standard
166 error output.
167
168
169 -x Prints the value and size of a symbol in hexadecimal instead of
170 decimal (equivalent to -t x).
171
172
173
174 Options can be used in any order, either singly or in combination, and
175 can appear anywhere in the command line. When conflicting options are
176 specified (such as -v and -n, or -o and -x) the first is taken and the
177 second ignored with a warning message to the user. (See -R for excep‐
178 tion.)
179
181 The following operand is supported:
182
183 file A path name of an object file, executable file or object-file
184 library.
185
186
188 This section describes the nm utility's output options.
189
190 Standard Output
191 For each symbol, the following information is printed:
192
193 Index The index of the symbol. (The index appears in brack‐
194 ets.)
195
196
197 Value The value of the symbol is one of the following:
198
199 o A section offset for defined symbols in a
200 relocatable file.
201
202 o Alignment constraints for symbols whose sec‐
203 tion index is SHN_COMMON.
204
205 o A virtual address in executable and dynamic
206 library files.
207
208
209 Size The size in bytes of the associated object.
210
211
212 Type A symbol is of one of the following types:
213
214 NOTYPE No type was specified.
215
216
217 OBJECT A data object such as an array or variable.
218
219
220 FUNC A function or other executable code.
221
222
223 REGI A register symbol (SPARC only).
224
225
226 SECTION A section symbol.
227
228
229 FILE Name of the source file.
230
231
232 COMMON An uninitialized common block.
233
234
235 TLS A variable associated with Thread-Local stor‐
236 age.
237
238
239
240 Bind The symbol's binding attributes.
241
242 LOCAL symbols Have a scope limited to the object
243 file containing their definition.
244
245
246 GLOBAL symbols Are visible to all object files being
247 combined.
248
249
250 WEAK symbols Are essentially global symbols with a
251 lower precedence than GLOBAL.
252
253
254
255 Other A symbol's visibility.
256
257 The lower bits of the st_other member of the Elf32_Sym
258 structure, and the Elf64_Sym structure, defined in
259 <sys/elf.h>, are currently used and can be one of:
260
261 #define STV_DEFAULT 0
262 #define STV_INTERNAL 1
263 #define STV_HIDDEN 2
264 #define STV_PROTECTED 3
265 #define STV_EXPORTED 4
266 #define STV_SINGLETON 5
267 #define STV_ELIMINATE 6
268
269
270
271
272 Shndx Except for three special values, this is the section
273 header table index in relation to which the symbol is
274 defined. The following special values exist:
275
276 ABS Indicates the symbol's value does not change
277 through relocation.
278
279
280 COMMON Indicates an unallocated block and the value
281 provides alignment constraints.
282
283
284 UNDEF Indicates an undefined symbol.
285
286
287
288 Name The name of the symbol.
289
290
291 Object Name The name of the object or library if -A is specified.
292
293
294
295 If the -P option is specified, the previous information is displayed
296 using the following portable format. The three versions differ depend‐
297 ing on whether -t d, -t o, or -t x was specified, respectively:
298
299 "%s%s %s %d %d0, library/object name, name, type, value, \
300 size "%s%s %s %o %o0, library/object name, name, \
301 type, value , size "%s%s %s %x %x0, library/object name, name, \
302 type, value, size
303
304
305
306
307 where library/object name is formatted as follows:
308
309 o If -A is not specified, library/object name is an empty
310 string.
311
312 o If -A is specified and the corresponding file operand does
313 not name a library:
314
315 "%s: ", file
316
317
318
319 o If -A is specified and the corresponding file operand names
320 a library. In this case, object file names the object file
321 in the library containing the symbol being described:
322
323 "%s[%s]: ", file, object file
324
325
326
327
328 If -A is not specified, then if more than one file operand is specified
329 or if only one file operand is specified and it names a library, nm
330 writes a line identifying the object containing the following symbols
331 before the lines containing those symbols, in the form:
332
333 o If the corresponding file operand does not name a library:
334
335 "%s:0, file
336
337
338
339 o If the corresponding file operand names a library; in this
340 case, object file is the name of the file in the library
341 containing the following symbols:
342
343 "%s[%s]:0, file, object file
344
345
346
347
348 If -P is specified, but -t is not, the format is as if -t x had been
349 specified.
350
352 See environ(5) for descriptions of the following environment variables
353 that affect the execution of nm: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
354 LC_MESSAGES, and NLSPATH.
355
357 The following exit values are returned:
358
359 0 Successful completion.
360
361
362 >0 An error occurred.
363
364
366 See attributes(5) for descriptions of the following attributes:
367
369 ┌─────────────────────────────┬─────────────────────────────┐
370 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
371 ├─────────────────────────────┼─────────────────────────────┤
372 │Availability │SUNWbtool │
373 └─────────────────────────────┴─────────────────────────────┘
374
376 ┌─────────────────────────────┬─────────────────────────────┐
377 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
378 ├─────────────────────────────┼─────────────────────────────┤
379 │Availability │SUNWxcu4 │
380 ├─────────────────────────────┼─────────────────────────────┤
381 │Interface Stability │Committed │
382 └─────────────────────────────┴─────────────────────────────┘
383
385 ar(1), as(1), dump(1), ld(1), ld.so.1(1), ar.h(3HEAD), a.out(4),
386 attributes(5), environ(5), standards(5)
387
389 The following options are obsolete because of changes to the object
390 file format and might be deleted in a future release.
391
392 -e Prints only external and static symbols. The symbol table now
393 contains only static and external symbols. Automatic symbols no
394 longer appear in the symbol table. They do appear in the debug‐
395 ging information produced by cc -g, which can be examined using
396 dump(1).
397
398
399 -f Produces full output. Redundant symbols (such as .text, .data,
400 and so forth), which existed previously, do not exist and produc‐
401 ing full output is identical to the default output.
402
403
404 -T By default, nm prints the entire name of the symbols listed.
405 Since symbol names have been moved to the last column, the prob‐
406 lem of overflow is removed and it is no longer necessary to trun‐
407 cate the symbol name.
408
409
410
411
412SunOS 5.11 10 Oct 2007 nm(1)