summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/nm.1
blob: e304bd7c027e1008829bedb028a1a1188d30d002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
'\" te
.\" Copyright 1989 AT&T
.\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved
.\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
.\"  This notice shall appear on any product containing this material.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH NM 1 "Sep 10, 2013"
.SH NAME
nm \- print name list of an object file
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/nm\fR [\fB-ACDhlnPprRsTuVv\fR] [\fB-efox\fR] [\fB-g\fR | \fB-u\fR]
     [\fB-t\fR \fIformat\fR] \fIfile\fR...
.fi

.LP
.nf
\fB/usr/xpg4/bin/nm\fR [\fB-ACDhlnPprRsTuVv\fR] [\fB-efox\fR] [\fB-g\fR | \fB-u\fR]
     [\fB-t\fR \fIformat\fR] \fIfile\fR...
.fi

.SH DESCRIPTION
.sp
.LP
The \fBnm\fR utility displays the symbol table of each \fBELF\fR object file
that is specified by \fIfile\fR.
.sp
.LP
If no symbolic information is available for a valid input file, the \fBnm\fR
utility reports that fact, but not consider it an error condition.
.SH OPTIONS
.sp
.LP
The output of \fBnm\fR can be controlled using the following options:
.sp
.ne 2
.na
\fB\fB-A\fR\fR
.ad
.RS 13n
Writes the full path name or library name of an object on each line.
.RE

.sp
.ne 2
.na
\fB\fB-C\fR\fR
.ad
.RS 13n
Demangles C++ symbol names before printing them out.
.RE

.sp
.ne 2
.na
\fB\fB-D\fR\fR
.ad
.RS 13n
Displays the \fBSHT_DYNSYM\fR symbol information. This is the symbol table used
by \fBld.so.1\fR and is present even in stripped dynamic executables. If
\fB-D\fR is not specified, the default behavior is to display the
\fBSHT_SYMTAB\fR symbol information.
.RE

.sp
.ne 2
.na
\fB\fB-e\fR\fR
.ad
.RS 13n
See NOTES below.
.RE

.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.RS 13n
See NOTES below.
.RE

.sp
.ne 2
.na
\fB\fB-g\fR\fR
.ad
.RS 13n
Writes only external (global) symbol information.
.RE

.sp
.ne 2
.na
\fB\fB-h\fR\fR
.ad
.RS 13n
Does not display the output heading data.
.RE

.sp
.ne 2
.na
\fB\fB-L\fR\fR
.ad
.RS 13n
Displays the \fBSHT_SUNW_LDYNSYM\fR symbol information. This symbol table
contains local function symbols. \fBSHT_SUNW_LDYNSM\fR symbol tables are
present even in stripped dynamic executables. These symbols augment the global
symbols that are found in \fBSHT_DYNSYM\fR symbol table. If \fB-L\fR is not
specified, the default behavior is to display the \fBSHT_SYMTAB\fR symbol
information.
.RE

.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 13n
Distinguishes between \fBWEAK\fR and \fBGLOBAL\fR symbols by appending a * to
the key letter for \fBWEAK\fR symbols.
.RE

.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 13n
Sorts external symbols by name before they are printed.
.RE

.sp
.ne 2
.na
\fB\fB-o\fR\fR
.ad
.RS 13n
Prints the value and size of a symbol in octal instead of decimal (equivalent
to \fB-t\fR \fBo\fR).
.RE

.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 13n
Produces easy to parse, terse output. Each symbol name is preceded by its value
(blanks if undefined) and one of the letters:
.sp
.ne 2
.na
\fB\fBA\fR\fR
.ad
.RS 5n
Absolute symbol.
.RE

.sp
.ne 2
.na
\fB\fBB\fR\fR
.ad
.RS 5n
bss (uninitialized data space) symbol.
.RE

.sp
.ne 2
.na
\fB\fBC\fR\fR
.ad
.RS 5n
COMMON symbol.
.RE

.sp
.ne 2
.na
\fB\fBD\fR\fR
.ad
.RS 5n
Data object symbol.
.RE

.sp
.ne 2
.na
\fB\fBF\fR\fR
.ad
.RS 5n
File symbol.
.RE

.sp
.ne 2
.na
\fB\fBN\fR\fR
.ad
.RS 5n
Symbol has no type.
.RE

.sp
.ne 2
.na
\fB\fBL\fR\fR
.ad
.RS 5n
Thread-Local storage symbol.
.RE

.sp
.ne 2
.na
\fB\fBS\fR\fR
.ad
.RS 5n
Section symbol.
.RE

.sp
.ne 2
.na
\fB\fBT\fR\fR
.ad
.RS 5n
Text symbol.
.RE

.sp
.ne 2
.na
\fB\fBU\fR\fR
.ad
.RS 5n
Undefined.
.RE

If the symbol's binding attribute is:
.sp
.ne 2
.na
\fB\fBLOCAL\fR\fR
.ad
.RS 10n
The key letter is lower case.
.RE

.sp
.ne 2
.na
\fB\fBWEAK\fR\fR
.ad
.RS 10n
The key letter is upper case. If the \fB-l\fR modifier is specified, the upper
case key letter is followed by a \fB*\fR
.RE

.sp
.ne 2
.na
\fB\fBGLOBAL\fR\fR
.ad
.RS 10n
The key letter is upper case.
.RE

.RE

.sp
.ne 2
.na
\fB\fB-P\fR\fR
.ad
.RS 13n
Writes information in a portable output format, as specified in \fBStandard
Output\fR.
.RE

.sp
.ne 2
.na
\fB\fB-r\fR\fR
.ad
.RS 13n
Prepends the name of the object file or archive to each output line.
.RE

.sp
.ne 2
.na
\fB\fB-R\fR\fR
.ad
.RS 13n
Prints the archive name (if present), followed by the object file and symbol
name. If the \fB-r\fR option is also specified, this option is ignored.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 13n
Prints section name instead of section index.
.RE

.sp
.ne 2
.na
\fB\fB-t\fR \fIformat\fR\fR
.ad
.RS 13n
Writes each numeric value in the specified format. The format is dependent on
the single character used as the \fIformat\fR option-argument:
.sp
.ne 2
.na
\fB\fBd\fR\fR
.ad
.RS 5n
The offset is written in decimal (default).
.RE

.sp
.ne 2
.na
\fB\fBo\fR\fR
.ad
.RS 5n
The offset is written in octal.
.RE

.sp
.ne 2
.na
\fB\fBx\fR\fR
.ad
.RS 5n
The offset is written in hexadecimal.
.RE

.RE

.sp
.ne 2
.na
\fB\fB-T\fR\fR
.ad
.RS 13n
See \fBNOTES\fR.
.RE

.SS "/usr/bin/nm"
.sp
.ne 2
.na
\fB\fB-u\fR\fR
.ad
.RS 6n
Prints undefined symbols only.
.RE

.SS "/usr/xpg4/bin/nm"
.sp
.ne 2
.na
\fB\fB-u\fR\fR
.ad
.RS 6n
Prints long listing for each undefined symbol. See \fBOUTPUT\fR below.
.RE

.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 6n
Sorts external symbols by value before they are printed.
.RE

.sp
.ne 2
.na
\fB\fB-V\fR\fR
.ad
.RS 6n
Prints the version of the \fBnm\fR command executing on the standard error
output.
.RE

.sp
.ne 2
.na
\fB\fB-x\fR\fR
.ad
.RS 6n
Prints the value and size of a symbol in hexadecimal instead of decimal
(equivalent to \fB-t\fR \fBx\fR).
.RE

.sp
.LP
Options can be used in any order, either singly or in combination, and can
appear anywhere in the command line. When conflicting options are specified
(such as \fB-v\fR and \fB-n\fR, or \fB-o\fR and \fB-x\fR) the first is taken
and the second ignored with a warning message to the user. (See \fB-R\fR for
exception.)
.SH OPERANDS
.sp
.LP
The following operand is supported:
.sp
.ne 2
.na
\fB\fIfile\fR\fR
.ad
.RS 8n
A path name of an object file, executable file or object-file library.
.RE

.SH OUTPUT
.sp
.LP
This section describes the \fBnm\fR utility's output options.
.SS "Standard Output"
.sp
.LP
For each symbol, the following information is printed:
.sp
.ne 2
.na
\fB\fBIndex\fR\fR
.ad
.RS 15n
The index of the symbol. (The index appears in brackets.)
.RE

.sp
.ne 2
.na
\fB\fBValue\fR\fR
.ad
.RS 15n
The value of the symbol is one of the following:
.RS +4
.TP
.ie t \(bu
.el o
A section offset for defined symbols in a relocatable file.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Alignment constraints for symbols whose section index is \fBSHN_COMMON\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
A virtual address in executable and dynamic library files.
.RE
.RE

.sp
.ne 2
.na
\fB\fBSize\fR\fR
.ad
.RS 15n
The size in bytes of the associated object.
.RE

.sp
.ne 2
.na
\fB\fBType\fR\fR
.ad
.RS 15n
A symbol is of one of the following types:
.sp
.ne 2
.na
\fB\fBNOTYPE\fR\fR
.ad
.RS 11n
No type was specified.
.RE

.sp
.ne 2
.na
\fB\fBOBJECT\fR\fR
.ad
.RS 11n
A data object such as an array or variable.
.RE

.sp
.ne 2
.na
\fB\fBFUNC\fR\fR
.ad
.RS 11n
A function or other executable code.
.RE

.sp
.ne 2
.na
\fB\fBREGI\fR\fR
.ad
.RS 11n
A register symbol (\fBSPARC\fR only).
.RE

.sp
.ne 2
.na
\fB\fBSECTION\fR\fR
.ad
.RS 11n
A section symbol.
.RE

.sp
.ne 2
.na
\fB\fBFILE\fR\fR
.ad
.RS 11n
Name of the source file.
.RE

.sp
.ne 2
.na
\fB\fBCOMMON\fR\fR
.ad
.RS 11n
An uninitialized common block.
.RE

.sp
.ne 2
.na
\fB\fBTLS\fR\fR
.ad
.RS 11n
A variable associated with Thread-Local storage.
.RE

.RE

.sp
.ne 2
.na
\fB\fBBind\fR\fR
.ad
.RS 15n
The symbol's binding attributes.
.sp
.ne 2
.na
\fB\fBLOCAL symbols\fR\fR
.ad
.RS 18n
Have a scope limited to the object file containing their definition.
.RE

.sp
.ne 2
.na
\fB\fBGLOBAL symbols\fR\fR
.ad
.RS 18n
Are visible to all object files being combined.
.RE

.sp
.ne 2
.na
\fB\fBWEAK symbols\fR\fR
.ad
.RS 18n
Are essentially global symbols with a lower precedence than \fBGLOBAL\fR.
.RE

.RE

.sp
.ne 2
.na
\fB\fBOther\fR\fR
.ad
.RS 15n
A symbol's visibility.
.sp
The lower bits of the \fBst_other\fR member of the \fBElf32_Sym\fR structure,
and the \fBElf64_Sym\fR structure, defined in \fB<sys/elf.h>\fR, are currently
used and can be one of:
.sp
.in +2
.nf
#define STV_DEFAULT     0
#define STV_INTERNAL    1
#define STV_HIDDEN      2
#define STV_PROTECTED   3
#define STV_EXPORTED    4
#define STV_SINGLETON   5
#define STV_ELIMINATE   6
.fi
.in -2
.sp

.RE

.sp
.ne 2
.na
\fB\fBShndx\fR\fR
.ad
.RS 15n
Except for three special values, this is the section header table index in
relation to which the symbol is defined. The following special values exist:
.sp
.ne 2
.na
\fB\fBABS\fR\fR
.ad
.RS 10n
Indicates the symbol's value does not change through relocation.
.RE

.sp
.ne 2
.na
\fB\fBCOMMON\fR\fR
.ad
.RS 10n
Indicates an unallocated block and the value provides alignment constraints.
.RE

.sp
.ne 2
.na
\fB\fBUNDEF\fR\fR
.ad
.RS 10n
Indicates an undefined symbol.
.RE

.RE

.sp
.ne 2
.na
\fB\fBName\fR\fR
.ad
.RS 15n
The name of the symbol.
.RE

.sp
.ne 2
.na
\fB\fBObject Name\fR\fR
.ad
.RS 15n
The name of the object or library if \fB-A\fR is specified.
.RE

.sp
.LP
If the \fB-P\fR option is specified, the previous information is displayed
using the following portable format. The three versions differ depending on
whether \fB-t\fR \fBd\fR, \fB-t\fR \fBo\fR, or \fB-t\fR \fBx\fR was specified,
respectively:
.sp
.in +2
.nf
\fB"%s%s %s %d %d\n",\fR \fIlibrary/object name\fR, \fIname\fR\fB, type,\fR \fIvalue\fR, \e
     \fBsize "%s%s %s %o %o\en",\fR \fIlibrary/object name\fR, \fIname\fR, \e
     \fBtype,\fR \fIvalue\fR \fB, size "%s%s %s %x %x\en",\fR \fIlibrary/object name\fR, \fIname\fR, \e
     \fBtype,\fR \fIvalue\fR\fB, size\fR
.fi
.in -2
.sp

.sp
.LP
where \fIlibrary/object name\fR is formatted as follows:
.RS +4
.TP
.ie t \(bu
.el o
If \fB-A\fR is not specified, \fIlibrary/object name\fR is an empty string.
.RE
.RS +4
.TP
.ie t \(bu
.el o
If \fB-A\fR is specified and the corresponding \fIfile\fR operand does not name
a library:
.sp
.in +2
.nf
\fB"%s: ", \fIfile\fR\fR
.fi
.in -2
.sp

.RE
.RS +4
.TP
.ie t \(bu
.el o
If \fB-A\fR is specified and the corresponding \fIfile\fR operand names a
library. In this case, \fIobject file\fR names the object file in the library
containing the symbol being described:
.sp
.in +2
.nf
\fB"%s[%s]: ", \fIfile\fR, \fIobject file\fR\fR
.fi
.in -2
.sp

.RE
.sp
.LP
If \fB-A\fR is not specified, then if more than one \fIfile\fR operand is
specified or if only one \fIfile\fR operand is specified and it names a
library, \fBnm\fR writes a line identifying the object containing the following
symbols before the lines containing those symbols, in the form:
.RS +4
.TP
.ie t \(bu
.el o
If the corresponding \fIfile\fR operand does not name a library:
.sp
.in +2
.nf
\fB"%s:\en", \fIfile\fR\fR
.fi
.in -2
.sp

.RE
.RS +4
.TP
.ie t \(bu
.el o
If the corresponding \fIfile\fR operand names a library; in this case,
\fIobject file\fR is the name of the file in the library containing the
following symbols:
.sp
.in +2
.nf
\fB"%s[%s]:\en", \fIfile\fR, \fIobject file\fR\fR
.fi
.in -2
.sp

.RE
.sp
.LP
If \fB-P\fR is specified, but \fB-t\fR is not, the format is as if \fB-t\fR
\fBx\fR had been specified.
.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(5) for descriptions of the following environment variables
that affect the execution of \fBnm\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.SH /USR/XPG4/BIN/NM
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
.TE

.SH SEE ALSO
.sp
.LP
\fBar\fR(1), \fBas\fR(1), \fBdump\fR(1), \fBld\fR(1), \fBld.so.1\fR(1),
\fBar.h\fR(3HEAD), \fBa.out\fR(4), \fBattributes\fR(5), \fBenviron\fR(5),
\fBstandards\fR(5)
.SH NOTES
.sp
.LP
The following options are obsolete because of changes to the object file format
and might be deleted in a future release.
.sp
.ne 2
.na
\fB\fB-e\fR\fR
.ad
.RS 6n
Prints only external and static symbols. The symbol table now contains only
static and external symbols. Automatic symbols no longer appear in the symbol
table. They do appear in the debugging information produced by \fBcc\fR
\fB-g\fR, which can be examined using \fBdump\fR(1).
.RE

.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.RS 6n
Produces full output. Redundant symbols (such as \fB\&.text\fR, \fB\&.data\fR,
and so forth), which existed previously, do not exist and producing full output
is identical to the default output.
.RE

.sp
.ne 2
.na
\fB\fB-T\fR\fR
.ad
.RS 6n
By default, \fBnm\fR prints the entire name of the symbols listed. Since symbol
names have been moved to the last column, the problem of overflow is removed
and it is no longer necessary to truncate the symbol name.
.RE