add nm -B
[binutils-gdb.git] / binutils / binutils.texi
1 \input texinfo @c -*- Texinfo -*-
2 @setfilename binutils.info
3
4 @ifinfo
5 @format
6 START-INFO-DIR-ENTRY
7 * Binutils:: The GNU binary utilities "ar", "ld", "objcopy",
8 "objdump", "nm", "size", "strings", "strip", and "ranlib".
9 END-INFO-DIR-ENTRY
10 @end format
11 @end ifinfo
12
13 @ifinfo
14 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
15
16 Permission is granted to make and distribute verbatim copies of
17 this manual provided the copyright notice and this permission notice
18 are preserved on all copies.
19
20 @ignore
21 Permission is granted to process this file through TeX and print the
22 results, provided the printed document carries a copying permission
23 notice identical to this one except for the removal of this paragraph
24 (this paragraph not being relevant to the printed manual).
25
26 @end ignore
27
28 Permission is granted to copy and distribute modified versions of this
29 manual under the conditions for verbatim copying, provided also that
30 the entire resulting derived work is distributed under the terms of a
31 permission notice identical to this one.
32
33 Permission is granted to copy and distribute translations of this manual
34 into another language, under the above conditions for modified versions.
35 @end ifinfo
36
37 @synindex ky cp
38 @c
39 @c This file documents the GNU binary utilities "ar", "ld", "objcopy",
40 @c "objdump", "nm", "size", "strings", "strip", and "ranlib".
41 @c
42 @c Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
43 @c
44 @c This text may be freely distributed under the terms of the GNU
45 @c General Public License.
46 @c
47
48 @setchapternewpage odd
49 @settitle GNU Binary Utilities
50 @c @smallbook
51 @c @cropmarks
52 @titlepage
53 @finalout
54 @title The GNU Binary Utilities
55 @subtitle Version 2.2
56 @sp 1
57 @subtitle May 1993
58 @author Roland H. Pesch
59 @author Cygnus Support
60 @page
61
62 @tex
63 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
64 \xdef\manvers{\$Revision$} % For use in headers, footers too
65 {\parskip=0pt \hfill Cygnus Support\par \hfill \manvers\par \hfill
66 \TeX{}info \texinfoversion\par }
67 @end tex
68
69 @vskip 0pt plus 1filll
70 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
71
72 Permission is granted to make and distribute verbatim copies of
73 this manual provided the copyright notice and this permission notice
74 are preserved on all copies.
75
76 Permission is granted to copy and distribute modified versions of this
77 manual under the conditions for verbatim copying, provided also that
78 the entire resulting derived work is distributed under the terms of a
79 permission notice identical to this one.
80
81 Permission is granted to copy and distribute translations of this manual
82 into another language, under the above conditions for modified versions.
83 @end titlepage
84
85 @node Top, ar, (dir), (dir)
86 @chapter Introduction
87
88 @cindex version
89 This brief manual contains preliminary documentation for the GNU binary
90 utilities (collectively version 2.2):
91
92 @iftex
93 @table @code
94 @item ar
95 Create, modify, and extract from archives
96
97 @item objcopy
98 Copy and translate object files
99
100 @item nm
101 List symbols from object files
102
103 @item objdump
104 Display information from object files
105
106 @item ranlib
107 Generate index to archive contents
108
109 @item size
110 List section sizes and total size
111
112 @item strings
113 List printable strings from files
114
115 @item strip
116 Discard symbols
117 @end table
118 @end iftex
119
120 @menu
121 * ar:: Create, modify, and extract from archives
122 * objcopy:: Copy and translate object files
123 * ld:(ld)Overview. Combine object and archive files
124 * nm:: List symbols from object files
125 * objdump:: Display information from object files
126 * ranlib:: Generate index to archive contents
127 * size:: List section sizes and total size
128 * strings:: List printable strings from files
129 * strip:: Discard symbols
130 * c++filt:: Filter to demangle encoded C++ symbols
131 * Index::
132 @end menu
133
134 @node ar, objcopy, Top, Top
135 @chapter ar
136
137 @kindex ar
138 @cindex archives
139 @cindex collections of files
140 @smallexample
141 ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{}
142 ar -M [ <mri-script ]
143 @end smallexample
144
145 The GNU @code{ar} program creates, modifies, and extracts from
146 archives. An @dfn{archive} is a single file holding a collection of
147 other files in a structure that makes it possible to retrieve
148 the original individual files (called @dfn{members} of the archive).
149
150 The original files' contents, mode (permissions), timestamp, owner, and
151 group are preserved in the archive, and can be restored on
152 extraction.
153
154 @cindex name length
155 GNU @code{ar} can maintain archives whose members have names of any
156 length; however, depending on how @code{ar} is configured on your
157 system, a limit on member-name length may be imposed for compatibility
158 with archive formats maintained with other tools. If it exists, the
159 limit is often 15 characters (typical of formats related to a.out) or 16
160 characters (typical of formats related to coff).
161
162 @cindex libraries
163 @code{ar} is considered a binary utility because archives of this sort
164 are most often used as @dfn{libraries} holding commonly needed
165 subroutines.
166
167 @cindex symbol index
168 @code{ar} creates an index to the symbols defined in relocatable
169 object modules in the archive when you specify the modifier @samp{s}.
170 Once created, this index is updated in the archive whenever @code{ar}
171 makes a change to its contents (save for the @samp{q} update operation).
172 An archive with such an index speeds up linking to the library, and
173 allows routines in the library to call each other without regard to
174 their placement in the archive.
175
176 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
177 table. If an archive lacks the table, another form of @code{ar} called
178 @code{ranlib} can be used to add just the table.
179
180 @cindex compatibility, @code{ar}
181 @cindex @code{ar} compatibility
182 GNU @code{ar} is designed to be compatible with two different
183 facilities. You can control its activity using command-line options,
184 like the different varieties of @code{ar} on Unix systems; or, if you
185 specify the single command-line option @samp{-M}, you can control it
186 with a script supplied via standard input, like the MRI ``librarian''
187 program.
188
189 @menu
190 * ar-cmdline:: Controlling @code{ar} on the command line
191 * ar-scripts:: Controlling @code{ar} with a script
192 @end menu
193
194 @page
195 @node ar-cmdline, ar-scripts, ar, ar
196 @section Controlling @code{ar} on the command line
197
198 @smallexample
199 ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{}
200 @end smallexample
201
202 @cindex Unix compatibility, @code{ar}
203 When you use @code{ar} in the Unix style, @code{ar} insists on at least two
204 arguments to execute: one keyletter specifying the @emph{operation}
205 (optionally accompanied by other keyletters specifying
206 @emph{modifiers}), and the archive name to act on.
207
208 Most operations can also accept further @var{file} arguments,
209 specifying particular files to operate on.
210
211 GNU @code{ar} allows you to mix the operation code @var{p} and modifier
212 flags @var{mod} in any order, within the first command-line argument.
213
214 If you wish, you may begin the first command-line argument with a
215 dash.
216
217 @cindex operations on archive
218 The @var{p} keyletter specifies what operation to execute; it may be
219 any of the following, but you must specify only one of them:
220
221 @table @code
222 @item d
223 @cindex deleting from archive
224 @emph{Delete} modules from the archive. Specify the names of modules to
225 be deleted as @var{file}@dots{}; the archive is untouched if you
226 specify no files to delete.
227
228 If you specify the @samp{v} modifier, @code{ar} lists each module
229 as it is deleted.
230
231 @item m
232 @cindex moving in archive
233 Use this operation to @emph{move} members in an archive.
234
235 The ordering of members in an archive can make a difference in how
236 programs are linked using the library, if a symbol is defined in more
237 than one member.
238
239 If no modifiers are used with @code{m}, any members you name in the
240 @var{file} arguments are moved to the @emph{end} of the archive;
241 you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
242 specified place instead.
243
244 @item p
245 @cindex printing from archive
246 @emph{Print} the specified members of the archive, to the standard
247 output file. If the @samp{v} modifier is specified, show the member
248 name before copying its contents to standard output.
249
250 If you specify no @var{file} arguments, all the files in the archive are
251 printed.
252
253 @item q
254 @cindex quick append to archive
255 @emph{Quick append}; add the files @var{file}@dots{} to the end of
256 @var{archive}, without checking for replacement.
257
258 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
259 operation; new members are always placed at the end of the archive.
260
261 The modifier @samp{v} makes @code{ar} list each file as it is appended.
262
263 Since the point of this operation is speed, the archive's symbol table
264 index is not updated, even if it already existed; you can use @samp{ar s} or
265 @code{ranlib} explicitly to update the symbol table index.
266
267 @item r
268 @cindex replacement in archive
269 Insert the files @var{file}@dots{} into @var{archive} (with
270 @emph{replacement}). This operation differs from @samp{q} in that any
271 previously existing members are deleted if their names match those being
272 added.
273
274 If one of the files named in @var{file}@dots{} doesn't exist, @code{ar}
275 displays an error message, and leaves undisturbed any existing members
276 of the archive matching that name.
277
278 By default, new members are added at the end of the file; but you may
279 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
280 placement relative to some existing member.
281
282 The modifier @samp{v} used with this operation elicits a line of
283 output for each file inserted, along with one of the letters @samp{a} or
284 @samp{r} to indicate whether the file was appended (no old member
285 deleted) or replaced.
286
287 @item t
288 @cindex contents of archive
289 Display a @emph{table} listing the contents of @var{archive}, or those
290 of the files listed in @var{file}@dots{} that are present in the
291 archive. Normally only the member name is shown; if you also want to
292 see the modes (permissions), timestamp, owner, group, and size, you can
293 request that by also specifying the @samp{v} modifier.
294
295 If you do not specify a @var{file}, all files in the archive
296 are listed.
297
298 @cindex repeated names in archive
299 @cindex name duplication in archive
300 If there is more than one file with the same name (say, @samp{fie}) in
301 an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
302 first instance; to see them all, you must ask for a complete
303 listing---in our example, @samp{ar t b.a}.
304 @c WRS only; per Gumby, this is implementation-dependent, and in a more
305 @c recent case in fact works the other way.
306
307 @item x
308 @cindex extract from archive
309 @emph{Extract} members (named @var{file}) from the archive. You can
310 use the @samp{v} modifier with this operation, to request that
311 @code{ar} list each name as it extracts it.
312
313 If you do not specify a @var{file}, all files in the archive
314 are extracted.
315
316 @end table
317
318 A number of modifiers (@var{mod}) may immediately follow the @var{p}
319 keyletter, to specify variations on an operation's behavior:
320
321 @table @code
322 @item a
323 @cindex relative placement in archive
324 Add new files @emph{after} an existing member of the
325 archive. If you use the modifier @samp{a}, the name of an existing archive
326 member must be present as the @var{membername} argument, before the
327 @var{archive} specification.
328
329 @item b
330 Add new files @emph{before} an existing member of the
331 archive. If you use the modifier @samp{b}, the name of an existing archive
332 member must be present as the @var{membername} argument, before the
333 @var{archive} specification. (same as @samp{i}).
334
335 @item c
336 @cindex creating archives
337 @emph{Create} the archive. The specified @var{archive} is always
338 created if it didn't exist, when you request an update. But a warning is
339 issued unless you specify in advance that you expect to create it, by
340 using this modifier.
341
342 @item i
343 Insert new files @emph{before} an existing member of the
344 archive. If you use the modifier @samp{i}, the name of an existing archive
345 member must be present as the @var{membername} argument, before the
346 @var{archive} specification. (same as @samp{b}).
347
348 @item l
349 This modifier is accepted but not used.
350 @c whaffor ar l modifier??? presumably compat; with
351 @c what???---pesch@@cygnus.com, 25jan91
352
353 @item o
354 @cindex dates in archive
355 Preserve the @emph{original} dates of members when extracting them. If
356 you do not specify this modifier, files extracted from the archive
357 are stamped with the time of extraction.
358
359 @item s
360 @cindex writing archive index
361 Write an object-file index into the archive, or update an existing one,
362 even if no other change is made to the archive. You may use this modifier
363 flag either with any operation, or alone. Running @samp{ar s} on an
364 archive is equivalent to running @samp{ranlib} on it.
365
366 @item u
367 @cindex updating an archive
368 Normally, @samp{ar r}@dots{} inserts all files
369 listed into the archive. If you would like to insert @emph{only} those
370 of the files you list that are newer than existing members of the same
371 names, use this modifier. The @samp{u} modifier is allowed only for the
372 operation @samp{r} (replace). In particular, the combination @samp{qu} is
373 not allowed, since checking the timestamps would lose any speed
374 advantage from the operation @samp{q}.
375
376 @item v
377 This modifier requests the @emph{verbose} version of an operation. Many
378 operations display additional information, such as filenames processed,
379 when the modifier @samp{v} is appended.
380
381 @item V
382 This modifier shows the version number of @code{ar}.
383 @end table
384
385 @node ar-scripts, , ar-cmdline, ar
386 @section Controlling @code{ar} with a script
387
388 @smallexample
389 ar -M [ <@var{script} ]
390 @end smallexample
391
392 @cindex MRI compatibility, @code{ar}
393 @cindex scripts, @code{ar}
394 If you use the single command-line option @samp{-M} with @code{ar}, you
395 can control its operation with a rudimentary command language. This
396 form of @code{ar} operates interactively if standard input is coming
397 directly from a terminal. During interactive use, @code{ar} prompts for
398 input (the prompt is @samp{AR >}), and continues executing even after
399 errors. If you redirect standard input to a script file, no prompts are
400 issued, and @code{ar} abandons execution (with a nonzero exit code)
401 on any error.
402
403 The @code{ar} command language is @emph{not} designed to be equivalent
404 to the command-line options; in fact, it provides somewhat less control
405 over archives. The only purpose of the command language is to ease the
406 transition to GNU @code{ar} for developers who already have scripts
407 written for the MRI ``librarian'' program.
408
409 The syntax for the @code{ar} command language is straightforward:
410 @itemize @bullet
411 @item
412 commands are recognized in upper or lower case; for example, @code{LIST}
413 is the same as @code{list}. In the following descriptions, commands are
414 shown in upper case for clarity.
415
416 @item
417 a single command may appear on each line; it is the first word on the
418 line.
419
420 @item
421 empty lines are allowed, and have no effect.
422
423 @item
424 comments are allowed; text after either of the characters @samp{*}
425 or @samp{;} is ignored.
426
427 @item
428 Whenever you use a list of names as part of the argument to an @code{ar}
429 command, you can separate the individual names with either commas or
430 blanks. Commas are shown in the explanations below, for clarity.
431
432 @item
433 @samp{+} is used as a line continuation character; if @samp{+} appears
434 at the end of a line, the text on the following line is considered part
435 of the current command.
436 @end itemize
437
438 Here are the commands you can use in @code{ar} scripts, or when using
439 @code{ar} interactively. Three of them have special significance:
440
441 @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
442 a temporary file required for most of the other commands.
443
444 @code{SAVE} commits the changes so far specified by the script. Prior
445 to @code{SAVE}, commands affect only the temporary copy of the current
446 archive.
447
448 @table @code
449 @item ADDLIB @var{archive}
450 @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
451 Add all the contents of @var{archive} (or, if specified, each named
452 @var{module} from @var{archive}) to the current archive.
453
454 Requires prior use of @code{OPEN} or @code{CREATE}.
455
456 @item ADDMOD @var{file}, @var{file}, @dots{} @var{file}
457 @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
458 @c else like "ar q..."
459 Add each named @var{file} as a module in the current archive.
460
461 Requires prior use of @code{OPEN} or @code{CREATE}.
462
463 @item CLEAR
464 Discard the contents of the current archive, cancelling the effect of
465 any operations since the last @code{SAVE}. May be executed (with no
466 effect) even if no current archive is specified.
467
468 @item CREATE @var{archive}
469 Creates an archive, and makes it the current archive (required for many
470 other commands). The new archive is created with a temporary name; it
471 is not actually saved as @var{archive} until you use @code{SAVE}.
472 You can overwrite existing archives; similarly, the contents of any
473 existing file named @var{archive} will not be destroyed until @code{SAVE}.
474
475 @item DELETE @var{module}, @var{module}, @dots{} @var{module}
476 Delete each listed @var{module} from the current archive; equivalent to
477 @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
478
479 Requires prior use of @code{OPEN} or @code{CREATE}.
480
481 @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
482 @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
483 List each named @var{module} present in @var{archive}. The separate
484 command @code{VERBOSE} specifies the form of the output: when verbose
485 output is off, output is like that of @samp{ar -t @var{archive}
486 @var{module}@dots{}}. When verbose output is on, the listing is like
487 @samp{ar -tv @var{archive} @var{module}@dots{}}.
488
489 Output normally goes to the standard output stream; however, if you
490 specify @var{outputfile} as a final argument, @code{ar} directs the
491 output to that file.
492
493 @item END
494 Exit from @code{ar}, with a @code{0} exit code to indicate successful
495 completion. This command does not save the output file; if you have
496 changed the current archive since the last @code{SAVE} command, those
497 changes are lost.
498
499 @item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
500 Extract each named @var{module} from the current archive, writing them
501 into the current directory as separate files. Equivalent to @samp{ar -x
502 @var{archive} @var{module}@dots{}}.
503
504 Requires prior use of @code{OPEN} or @code{CREATE}.
505
506 @ignore
507 @c FIXME Tokens but no commands???
508 @item FULLDIR
509
510 @item HELP
511 @end ignore
512
513 @item LIST
514 Display full contents of the current archive, in ``verbose'' style
515 regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
516 tv @var{archive}}). (This single command is a GNU @code{ld}
517 enhancement, rather than present for MRI compatibility.)
518
519 Requires prior use of @code{OPEN} or @code{CREATE}.
520
521 @item OPEN @var{archive}
522 Opens an existing archive for use as the current archive (required for
523 many other commands). Any changes as the result of subsequent commands
524 will not actually affect @var{archive} until you next use @code{SAVE}.
525
526 @item REPLACE @var{module}, @var{module}, @dots{} @var{module}
527 In the current archive, replace each existing @var{module} (named in
528 the @code{REPLACE} arguments) from files in the current working directory.
529 To execute this command without errors, both the file, and the module in
530 the current archive, must exist.
531
532 Requires prior use of @code{OPEN} or @code{CREATE}.
533
534 @item VERBOSE
535 Toggle an internal flag governing the output from @code{DIRECTORY}.
536 When the flag is on, @code{DIRECTORY} output matches output from
537 @samp{ar -tv }@dots{}.
538
539 @item SAVE
540 Commit your changes to the current archive, and actually save it as a
541 file with the name specified in the last @code{CREATE} or @code{OPEN}
542 command.
543
544 Requires prior use of @code{OPEN} or @code{CREATE}.
545
546 @end table
547
548 @node objcopy, nm, ar, Top
549 @chapter objcopy
550
551 @smallexample
552 objcopy [ -F @var{format} | --format=@var{format} ]
553 [ -I @var{format} | --input-format=@var{format} ]
554 [ -O @var{format} | --output-format=@var{format} ]
555 [ -S | --strip-all ] [ -g | --strip-debug ]
556 [ -x | --discard-all ] [ -X | --discard-locals ]
557 [ -v | --verbose ] [ -V | --version ] [ --help ]
558 @var{infile} [@var{outfile}]
559 @end smallexample
560
561 The GNU @code{objcopy} utility copies the contents of an object file to
562 another. @code{objcopy} uses the GNU BFD Library to read and write the
563 object files. It can write the destination object file in a format
564 different from that of the source object file. The exact behavior of
565 @code{objcopy} is controlled by command-line options.
566
567 @code{objcopy} creates temporary files to do its translations and
568 deletes them afterward. @code{objcopy} uses BFD to do all its
569 translation work; it knows about all the formats BFD knows about, and
570 thus is able to recognize most formats without being told explicitly.
571 @xref{BFD,,BFD,ld.info,Using LD, the GNU linker}.
572
573 @table @code
574 @item @var{infile}
575 @itemx @var{outfile}
576 The source and output files respectively.
577 If you do not specify @var{outfile}, @code{objcopy} creates a
578 temporary file and destructively renames the result with
579 the name of the input file.
580
581 @item -I @var{format}
582 @itemx --input-format=@var{format}
583 Consider the source file's object format to be @var{format}, rather than
584 attempting to deduce it.
585
586 @item -O @var{format}
587 @itemx --output-format=@var{format}
588 Write the output file using the object format @var{format}.
589
590 @item -F @var{format}
591 @itemx --format=@var{format}
592 Use @var{format} as the object format for both the input and the output
593 file; i.e. simply transfer data from source to destination with no
594 translation.
595
596 @item -S
597 @itemx --strip-all
598 Do not copy relocation and symbol information from the source file.
599
600 @item -g
601 @itemx --strip-debug
602 Do not copy debugging symbols from the source file.
603
604 @item -x
605 @itemx --discard-all
606 Do not copy non-global symbols from the source file.
607 @c FIXME any reason to prefer "non-global" to "local" here?
608
609 @item -X
610 @itemx --discard-locals
611 Do not copy compiler-generated local symbols.
612 (These usually start with @samp{L} or @samp{.}.)
613
614 @item -V
615 @itemx --version
616 Show the version number of @code{objcopy}.
617
618 @item -v
619 @itemx --verbose
620 Verbose output: list all object files modified. In the case of
621 archives, @samp{objcopy -V} lists all members of the archive.
622
623 @item --help
624 Show a summary of the options to @code{objcopy}.
625 @end table
626
627 @iftex
628 @node ld
629 @chapter ld
630 @cindex linker
631 @kindex ld
632 The GNU linker @code{ld} is now described in a separate manual.
633 @xref{Top,, Overview,, Using LD: the GNU linker}.
634 @end iftex
635
636 @node nm, objdump, objcopy, Top
637 @chapter nm
638 @cindex symbols
639 @kindex nm
640
641 @smallexample
642 nm [ -a | --debug-syms ] [ -g | --extern-only ] [ -B ]
643 [ -s | --print-armap ] [ -A | -o | --print-file-name ]
644 [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
645 [ -r | --reverse-sort ] [ -u | --undefined-only ]
646 [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ]
647 [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ]
648 [ -V | --version ] [ --help ] [ @var{objfile}@dots{} ]
649 @end smallexample
650
651 GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}.
652 If no object files are listed as arguments, @code{nm} assumes
653 @file{a.out}.
654
655 For each symbol, @code{nm} shows:
656
657 @itemize @bullet
658 @item
659 The symbol value, in the radix selected by options (see below), or
660 hexadecimal by default.
661
662 @item
663 The symbol type. At least the following types are used; others are, as
664 well, depending on the object file format. If lowercase, the symbol is
665 local; if uppercase, the symbol is global (external).
666
667 @c Some more detail on exactly what these symbol types are used for
668 @c would be nice.
669 @table @code
670 @item A
671 Absolute.
672
673 @item B
674 BSS (uninitialized data).
675
676 @item C
677 Common.
678
679 @item D
680 Initialized data.
681
682 @item I
683 Indirect reference.
684
685 @item T
686 Text (program code).
687
688 @item U
689 Undefined.
690 @end table
691
692 @item
693 The symbol name.
694 @end itemize
695
696 The long and short forms of options, shown here as alternatives, are
697 equivalent.
698
699 @table @code
700 @item -A
701 @itemx -o
702 @itemx --print-file-name
703 @cindex input file name
704 @cindex file name
705 @cindex source file name
706 Precede each symbol by the name of the input file (or archive element)
707 in which it was found, rather than identifying the input file once only,
708 before all of its symbols.
709
710 @item -a
711 @itemx --debug-syms
712 @cindex debugging symbols
713 Display all symbols, even debugger-only symbols; normally these are not
714 listed.
715
716 @item -B
717 @cindex @code{nm} format
718 @cindex @code{nm} compatibility
719 The same as @samp{--format=bsd}.
720
721 @item -f @var{format}
722 @itemx --format=@var{format}
723 @cindex @code{nm} format
724 @cindex @code{nm} compatibility
725 Use the output format @var{format}, which can be @code{bsd},
726 @code{sysv}, or @code{posix}. The default is @code{bsd}.
727 Only the first character of @var{format} is significant; it can be
728 either upper or lower case.
729
730 @item -g
731 @itemx --extern-only
732 @cindex external symbols
733 Display only external symbols.
734
735 @item -n
736 @itemx -v
737 @itemx --numeric-sort
738 Sort symbols numerically by their addresses, rather than alphabetically
739 by their names.
740
741 @item -p
742 @itemx --no-sort
743 @cindex sorting symbols
744 Don't bother to sort the symbols in any order; print them in the order
745 encountered.
746
747 @item -P
748 @itemx --portability
749 Use the POSIX.2 standard output format instead of the default format.
750 Equivalent to @samp{-f posix}.
751
752 @item -s
753 @itemx --print-armap
754 @cindex symbol index, listing
755 When listing symbols from archive members, include the index: a mapping
756 (stored in the archive by @code{ar} or @code{ranlib}) of which modules
757 contain definitions for which names.
758
759 @item -r
760 @itemx --reverse-sort
761 Reverse the order of the sort (whether numeric or alphabetic); let the
762 last come first.
763
764 @item -t @var{radix}
765 @itemx --radix=@var{radix}
766 Use @var{radix} as the radix for printing the symbol values. It must be
767 @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
768
769 @item --target=@var{bfdname}
770 @cindex object code format
771 Specify an object code format other than your system's default format.
772 @xref{objdump}, for information on listing available formats.
773
774 @item -u
775 @itemx --undefined-only
776 @cindex external symbols
777 @cindex undefined symbols
778 Display only undefined symbols (those external to each object file).
779
780 @item -V
781 @itemx --version
782 Show the version number of @code{nm} and exit.
783
784 @item --help
785 Show a summary of the options to @code{nm} and exit.
786 @end table
787
788 @node objdump, ranlib, nm, Top
789 @chapter objdump
790
791 @cindex object file information
792 @kindex objdump
793
794 @smallexample
795 objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ]
796 [ -h | --header ] [ -i ] [ -j @var{section} ] [ -l ]
797 [ -m @var{machine} ] [ -r | --reloc ] [ -s ] [ --stabs ]
798 [ -t | --syms ] [ -x ] [ --version ] [ --help ]
799 @var{objfile}@dots{}
800 @end smallexample
801
802 @code{objdump} displays information about one or more object files.
803 The options control what particular information to display. This
804 information is mostly useful to programmers who are working on the
805 compilation tools, as opposed to programmers who just want their
806 program to compile and work.
807
808 @var{objfile}@dots{} are the object files to be examined. When you
809 specify archives, @code{objdump} shows information on each of the member
810 object files.
811
812 The long and short forms of options, shown here as alternatives, are
813 equivalent.
814
815 @table @code
816 @item -a
817 @c print_arelt_descr
818 @cindex archive headers
819 If any of the @var{objfile} files are archives, display the archive
820 header information (in a format similar to @samp{ls -l}). Besides the
821 information you could list with @samp{ar tv}, @samp{objdump -a} shows
822 the object file format of each archive member.
823
824 @c suggest longname --target or --format or --bfd
825 @item -b @var{bfdname}
826 @cindex object code format
827 Specify that the object-code format for the object files is
828 @var{bfdname}. This option may not be necessary; @var{objdump} can
829 automatically recognize many formats.
830
831 For example,
832 @example
833 objdump -b oasys -m vax -h fu.o
834 @end example
835 @noindent
836 displays summary information from the section headers (@samp{-h}) of
837 @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
838 file in the format produced by Oasys compilers. You can list the
839 formats available with the @samp{-i} option.
840
841 @item -d
842 @cindex disassembling object code
843 @cindex machine instructions
844 Disassemble. Display the assembler mnemonics for the machine
845 instructions from @var{objfile}.
846
847 @item -f
848 @cindex object file header
849 File header. Display summary information from the overall header of
850 each of the @var{objfile} files.
851
852 @item -h
853 @itemx --header
854 @cindex section headers
855 Header. Display summary information from the section headers of the
856 object file.
857
858 @item --help
859 Print a summary of the options to @code{objdump} and exit.
860
861 @item -i
862 @cindex architectures available
863 @cindex object formats available
864 Display a list showing all architectures and object formats available
865 for specification with @samp{-b} or @samp{-m}.
866
867 @c suggest longname --section
868 @item -j @var{name}
869 @cindex section information
870 Display information only for section @var{name}.
871
872 @c suggest longname --label or --linespec
873 @item -l
874 @cindex source filenames for object files
875 Label the display (using debugging information) with the source filename
876 and line numbers corresponding to the object code shown.
877
878 @c suggest longname --architecture
879 @item -m @var{machine}
880 @cindex architecture
881 Specify that the object files @var{objfile} are for architecture
882 @var{machine}. You can list available architectures using the @samp{-i}
883 option.
884
885 @item -r
886 @itemx --reloc
887 @cindex relocation entries, in object file
888 Relocation. Print the relocation entries of the file.
889
890 @item -s
891 @cindex sections, full contents
892 @cindex object file sections
893 Display the full contents of any sections requested.
894
895 @item --stabs
896 @cindex stab
897 @cindex .stab
898 @cindex debug symbols
899 @cindex ELF object file format
900 Display the full contents of any sections requested. Display the
901 contents of the .stab and .stab.index and .stab.excl sections from an
902 ELF file. This is only useful on systems (such as Solaris 2.0) in which
903 @code{.stab} debugging symbol-table entries are carried in an ELF
904 section. In most other file formats, debugging symbol-table entries are
905 interleaved with linkage symbols, and are visible in the @samp{--syms}
906 output.
907
908 @item -t
909 @itemx --syms
910 @cindex symbol table entries, printing
911 Symbol Table. Print the symbol table entries of the file.
912 This is similar to the information provided by the @samp{nm} program.
913
914 @item --version
915 Print the version number of @code{objdump} and exit.
916
917 @item -x
918 @cindex all header information, object file
919 @cindex header information, all
920 Display all available header information, including the symbol table and
921 relocation entries. Using @samp{-x} is equivalent to specifying all of
922 @samp{-a -f -h -r -t}.
923 @end table
924
925 @node ranlib, size, objdump, Top
926 @chapter ranlib
927
928 @kindex ranlib
929 @cindex archive contents
930 @cindex symbol index
931
932 @smallexample
933 ranlib [-vV] @var{archive}
934 @end smallexample
935
936 @code{ranlib} generates an index to the contents of an archive and
937 stores it in the archive. The index lists each symbol defined by a
938 member of an archive that is a relocatable object file.
939
940 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
941
942 An archive with such an index speeds up linking to the library and
943 allows routines in the library to call each other without regard to
944 their placement in the archive.
945
946 The GNU @code{ranlib} program is another form of GNU @code{ar}; running
947 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
948 @xref{ar}.
949
950 @table @code
951 @item -v
952 @itemx -V
953 Show the version number of @code{ranlib}.
954 @end table
955
956 @node size, strings, ranlib, Top
957 @chapter size
958
959 @kindex size
960 @cindex section sizes
961
962 @smallexample
963 size [ -A | -B | --format=@var{compatibility} ]
964 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
965 [ --target=@var{bfdname} ] [ -V | --version ]
966 @var{objfile}@dots{}
967 @end smallexample
968
969 The GNU @code{size} utility lists the section sizes---and the total
970 size---for each of the object or archive files @var{objfile} in its
971 argument list. By default, one line of output is generated for each
972 object file or each module in an archive.
973
974 @var{objfile}@dots{} are the object files to be examined.
975
976 The command line options have the following meanings:
977
978 @table @code
979 @item -A
980 @itemx -B
981 @itemx --format=@var{compatibility}
982 @cindex @code{size} display format
983 Using one of these options, you can choose whether the output from GNU
984 @code{size} resembles output from System V @code{size} (using @samp{-A},
985 or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
986 @samp{--format=berkeley}). The default is the one-line format similar to
987 Berkeley's.
988 @c Bonus for doc-source readers: you can also say --format=strange (or
989 @c anything else that starts with 's') for sysv, and --format=boring (or
990 @c anything else that starts with 'b') for Berkeley.
991
992 Here is an example of the Berkeley (default) format of output from
993 @code{size}:
994 @smallexample
995 size --format Berkeley ranlib size
996 text data bss dec hex filename
997 294880 81920 11592 388392 5ed28 ranlib
998 294880 81920 11888 388688 5ee50 size
999 @end smallexample
1000
1001 @noindent
1002 This is the same data, but displayed closer to System V conventions:
1003
1004 @smallexample
1005 size --format SysV ranlib size
1006 ranlib :
1007 section size addr
1008 .text 294880 8192
1009 .data 81920 303104
1010 .bss 11592 385024
1011 Total 388392
1012
1013
1014 size :
1015 section size addr
1016 .text 294880 8192
1017 .data 81920 303104
1018 .bss 11888 385024
1019 Total 388688
1020 @end smallexample
1021
1022 @item --help
1023 Show a summary of acceptable arguments and options.
1024
1025 @item -d
1026 @itemx -o
1027 @itemx -x
1028 @itemx --radix=@var{number}
1029 @cindex @code{size} number format
1030 @cindex radix for section sizes
1031 Using one of these options, you can control whether the size of each
1032 section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1033 (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1034 @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
1035 values (8, 10, 16) are supported. The total size is always given in two
1036 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1037 octal and hexadecimal if you're using @samp{-o}.
1038
1039 @item --target=@var{bfdname}
1040 @cindex object code format
1041 Specify that the object-code format for @var{objfile} is
1042 @var{bfdname}. This option may not be necessary; @code{size} can
1043 automatically recognize many formats. @xref{objdump}, for information
1044 on listing available formats.
1045
1046 @item -V
1047 @itemx --version
1048 Display the version number of @code{size}.
1049 @end table
1050
1051 @node strings, strip, size, Top
1052 @chapter strings
1053 @kindex strings
1054 @cindex listings strings
1055 @cindex printing strings
1056 @cindex strings, printing
1057
1058 @smallexample
1059 strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-]
1060 [--all] [--print-file-name] [--bytes=@var{min-len}] [--radix=@var{radix}]
1061 [--help] [--version] @var{file}@dots{}
1062 @end smallexample
1063
1064 For each @var{file} given, GNU @code{strings} prints the printable
1065 character sequences that are at least 4 characters long (or the number
1066 given with the options below) and are followed by a NUL or newline
1067 character. By default, it only prints the strings from the initialized
1068 data sections of object files; for other types of files, it prints the
1069 strings from the whole file.
1070
1071 @code{strings} is mainly useful for determining the contents of non-text
1072 files.
1073
1074 @table @code
1075 @item -a
1076 @itemx --all
1077 @itemx -
1078 Do not scan only the initialized data section of object files; scan
1079 the whole files.
1080
1081 @item -f
1082 @itemx --print-file-name
1083 Print the name of the file before each string.
1084
1085 @item --help
1086 Print a summary of the program usage on the standard output and exit.
1087
1088 @itemx -@var{min-len}
1089 @item -n @var{min-len}
1090 @itemx --bytes=@var{min-len}
1091 Print sequences of characters that are at least @var{min-len} characters
1092 long, instead of the default 4.
1093
1094 @item -o
1095 Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o}
1096 act like @samp{-t d} instead. Since we can not be compatible with both
1097 ways, we simply chose one.
1098
1099 @item -t @var{radix}
1100 @itemx --radix=@var{radix}
1101 Print the offset within the file before each string. The single
1102 character argument specifies the radix of the offset---@samp{o} for
1103 octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1104
1105 @item -v
1106 @itemx --version
1107 Print the program version number on the standard output and exit.
1108 @end table
1109
1110 @node strip, c++filt, strings, Top
1111 @chapter strip
1112
1113 @kindex strip
1114 @cindex removing symbols
1115 @cindex discarding symbols
1116 @cindex symbols, discarding
1117
1118 @smallexample
1119 strip [ -F @var{format} | --format=@var{format} | --target=@var{format} ]
1120 [ -I @var{format} | --input-format=@var{format} ]
1121 [ -O @var{format} | --output-format=@var{format} ]
1122 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
1123 [ -x | --discard-all ] [ -X | --discard-locals ]
1124 [ -v | --verbose ] [ -V | --version ] [ --help ]
1125 @var{objfile}@dots{}
1126 @end smallexample
1127
1128 GNU @code{strip} discards all symbols from object files
1129 @var{objfile}. The list of object files may include archives.
1130 At least one object file must be given.
1131
1132 @code{strip} modifies the files named in its argument,
1133 rather than writing modified copies under different names.
1134
1135 @table @code
1136 @item -F @var{format}
1137 @itemx --format=@var{format}
1138 @itemx --target=@var{format}
1139 Treat the original @var{objfile} as a file with the object
1140 code format @var{format}, and rewrite it in the same format.
1141
1142 @item --help
1143 Show a summary of the options to @code{strip} and exit.
1144
1145 @item -I @var{format}
1146 @itemx --input-format=@var{format}
1147 Treat the original @var{objfile} as a file with the object
1148 code format @var{format}.
1149
1150 @item -O @var{format}
1151 @itemx --output-format=@var{format}
1152 Replace @var{objfile} with a file in the output format @var{format}.
1153
1154 @item -s
1155 @itemx --strip-all
1156 Remove all symbols.
1157
1158 @item -g
1159 @itemx -S
1160 @itemx --strip-debug
1161 Remove debugging symbols only.
1162
1163 @item -x
1164 @itemx --discard-all
1165 Remove non-global symbols.
1166
1167 @item -X
1168 @itemx --discard-locals
1169 Remove compiler-generated local symbols.
1170 (These usually start with @samp{L} or @samp{.}.)
1171
1172 @item -V
1173 @itemx --version
1174 Show the version number for @code{strip}.
1175
1176 @item -v
1177 @itemx --verbose
1178 Verbose output: list all object files modified. In the case of
1179 archives, @samp{strip -v} lists all members of the archive.
1180 @end table
1181
1182 @node c++filt, Index, strip, Top
1183 @chapter c++filt
1184
1185 @kindex c++filt
1186 @cindex demangling C++ symbols
1187
1188 @smallexample
1189 c++filt [ -_ | --strip-underscores ]
1190 [ -s @var{format} | --format=@var{format} ]
1191 [ --help ] [ --version ] [ @var{arg}@dots{} ]
1192 @end smallexample
1193
1194 The C++ language provides function overloading, which means that you can
1195 write many functions with the same name (providing each takes parameters
1196 of different types). All C++ function names are encoded into a
1197 low-level assembly label (this process is known as
1198 @dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1199 decodes (@dfn{demangles}) low-level names into user-level names so that
1200 the linker can keep these overloaded functions from clashing.
1201
1202 Every alphanumeric word (consisting of letters, digits, underscores,
1203 dollars, or periods) seen in the input is a potential label. If the
1204 label decodes into a C++ name, the C++ name replaces the low-level
1205 name in the output.
1206
1207 A typical use of @code{c++filt} is to pipe the output of @code{nm}
1208 though it, using @code{c++filt} as a filter:
1209
1210 @example
1211 nm @var{objfile} | c++filt
1212 @end example
1213
1214 You can also use @code{c++filt} to decipher individual symbols:
1215
1216 @example
1217 c++filt @var{symbol}
1218 @end example
1219
1220 All results are printed on the standard output.
1221
1222 @table @code
1223 @item -_
1224 @item --strip-underscores
1225 On some systems, both the C and C++ compilers put an underscore in front
1226 of every name. For example, the C name @code{foo} gets the low-level
1227 name @code{_foo}. This option removes the initial underscore.
1228
1229 @item -s @var{format}
1230 @itemx --format=@var{format}
1231 GNU @code{nm} can decode three different methods of mangling, used by
1232 different C++ compilers. The argument to this option selects which
1233 method it uses:
1234
1235 @table @code
1236 @item gnu
1237 the one used by the GNU compiler (the default method)
1238 @item lucid
1239 the one used by the Lucid compiler
1240 @item arm
1241 the one specified by the C++ Annotated Reference Manual
1242 @end table
1243
1244 @item --help
1245 Print a summary of the options to @code{c++filt} and exit.
1246
1247 @item --version
1248 Print the version number of @code{c++filt} and exit.
1249 @end table
1250
1251 @quotation
1252 @emph{Warning:} @code{c++filt} is a new utility, and the details of its
1253 user interface are subject to change in future releases. In particular,
1254 a command-line option may be required in the the future to decode a name
1255 passed as an argument on the command line; in other words,
1256
1257 @example
1258 c++filt @var{symbol}
1259 @end example
1260
1261 @noindent
1262 may in a future release become
1263
1264 @example
1265 c++filt @var{option} @var{symbol}
1266 @end example
1267 @end quotation
1268
1269 @node Index, , c++filt, Top
1270 @unnumbered Index
1271
1272 @printindex cp
1273
1274 @contents
1275 @bye