1 \input texinfo @c -*- Texinfo -*-
2 @setfilename binutils.info
7 * Binutils: (binutils). The GNU binary utilities "ar", "ld", "objcopy",
8 "objdump", "nm", "size", "strip", and "ranlib".
14 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
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.
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).
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.
33 Permission is granted to copy and distribute translations of this manual
34 into another language, under the above conditions for modified versions.
39 @c This file documents the GNU binary utilities "ar", "ld", "objcopy",
40 @c "objdump", "nm", "size", "strip", and "ranlib".
42 @c Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
44 @c This text may be freely distributed under the terms of the GNU
45 @c General Public License.
48 @setchapternewpage odd
49 @settitle GNU Binary Utilities
54 @title The GNU Binary Utilities
58 @author Roland H. Pesch
59 @author Cygnus Support
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 }
69 @vskip 0pt plus 1filll
70 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
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.
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.
81 Permission is granted to copy and distribute translations of this manual
82 into another language, under the above conditions for modified versions.
85 @node Top, ar, (dir), (dir)
89 This brief manual contains preliminary documentation for the GNU binary
90 utilities (collectively version 2.2):
95 Create, modify, and extract from archives
98 Copy and translate object files
101 List symbols from object files
104 Display information from object files
107 Generate index to archive contents
110 List section sizes and total size
118 * ar:: Create, modify, and extract from archives
119 * objcopy:: Copy and translate object files
120 * ld:(ld)Overview. Combine object and archive files
121 * nm:: List symbols from object files
122 * objdump:: Display information from object files
123 * ranlib:: Generate index to archive contents
124 * size:: List section sizes and total size
125 * strip:: Discard symbols
126 * c++filt:: Filter to demangle encoded C++ symbols
130 @node ar, objcopy, Top, Top
135 @cindex collections of files
137 ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{}
138 ar -M [ <mri-script ]
141 The GNU @code{ar} program creates, modifies, and extracts from
142 archives. An @dfn{archive} is a single file holding a collection of
143 other files in a structure that makes it possible to retrieve
144 the original individual files (called @dfn{members} of the archive).
146 The original files' contents, mode (permissions), timestamp, owner, and
147 group are preserved in the archive, and can be restored on
151 GNU @code{ar} can maintain archives whose members have names of any
152 length; however, depending on how @code{ar} is configured on your
153 system, a limit on member-name length may be imposed for compatibility
154 with archive formats maintained with other tools. If it exists, the
155 limit is often 15 characters (typical of formats related to a.out) or 16
156 characters (typical of formats related to coff).
159 @code{ar} is considered a binary utility because archives of this sort
160 are most often used as @dfn{libraries} holding commonly needed
164 @code{ar} creates an index to the symbols defined in relocatable
165 object modules in the archive when you specify the modifier @samp{s}.
166 Once created, this index is updated in the archive whenever @code{ar}
167 makes a change to its contents (save for the @samp{q} update operation).
168 An archive with such an index speeds up linking to the library, and
169 allows routines in the library to call each other without regard to
170 their placement in the archive.
172 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
173 table. If an archive lacks the table, another form of @code{ar} called
174 @code{ranlib} can be used to add just the table.
176 @cindex compatibility, @code{ar}
177 @cindex @code{ar} compatibility
178 GNU @code{ar} is designed to be compatible with two different
179 facilities. You can control its activity using command-line options,
180 like the different varieties of @code{ar} on Unix systems; or, if you
181 specify the single command-line option @samp{-M}, you can control it
182 with a script supplied via standard input, like the MRI ``librarian''
186 * ar-cmdline:: Controlling @code{ar} on the command line
187 * ar-scripts:: Controlling @code{ar} with a script
191 @node ar-cmdline, ar-scripts, ar, ar
192 @section Controlling @code{ar} on the command line
195 ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{}
198 @cindex Unix compatibility, @code{ar}
199 When you use @code{ar} in the Unix style, @code{ar} insists on at least two
200 arguments to execute: one keyletter specifying the @emph{operation}
201 (optionally accompanied by other keyletters specifying
202 @emph{modifiers}), and the archive name to act on.
204 Most operations can also accept further @var{file} arguments,
205 specifying particular files to operate on.
207 GNU @code{ar} allows you to mix the operation code @var{p} and modifier
208 flags @var{mod} in any order, within the first command-line argument.
210 If you wish, you may begin the first command-line argument with a
213 @cindex operations on archive
214 The @var{p} keyletter specifies what operation to execute; it may be
215 any of the following, but you must specify only one of them:
219 @cindex deleting from archive
220 @emph{Delete} modules from the archive. Specify the names of modules to
221 be deleted as @var{file}@dots{}; the archive is untouched if you
222 specify no files to delete.
224 If you specify the @samp{v} modifier, @code{ar} lists each module
228 @cindex moving in archive
229 Use this operation to @emph{move} members in an archive.
231 The ordering of members in an archive can make a difference in how
232 programs are linked using the library, if a symbol is defined in more
235 If no modifiers are used with @code{m}, any members you name in the
236 @var{file} arguments are moved to the @emph{end} of the archive;
237 you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
238 specified place instead.
241 @cindex printing from archive
242 @emph{Print} the specified members of the archive, to the standard
243 output file. If the @samp{v} modifier is specified, show the member
244 name before copying its contents to standard output.
246 If you specify no @var{file} arguments, all the files in the archive are
250 @cindex quick append to archive
251 @emph{Quick append}; add the files @var{file}@dots{} to the end of
252 @var{archive}, without checking for replacement.
254 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
255 operation; new members are always placed at the end of the archive.
257 The modifier @samp{v} makes @code{ar} list each file as it is appended.
259 Since the point of this operation is speed, the archive's symbol table
260 index is not updated, even if it already existed; you can use @samp{ar s} or
261 @code{ranlib} explicitly to update the symbol table index.
264 @cindex replacement in archive
265 Insert the files @var{file}@dots{} into @var{archive} (with
266 @emph{replacement}). This operation differs from @samp{q} in that any
267 previously existing members are deleted if their names match those being
270 If one of the files named in @var{file}@dots{} doesn't exist, @code{ar}
271 displays an error message, and leaves undisturbed any existing members
272 of the archive matching that name.
274 By default, new members are added at the end of the file; but you may
275 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
276 placement relative to some existing member.
278 The modifier @samp{v} used with this operation elicits a line of
279 output for each file inserted, along with one of the letters @samp{a} or
280 @samp{r} to indicate whether the file was appended (no old member
281 deleted) or replaced.
284 @cindex contents of archive
285 Display a @emph{table} listing the contents of @var{archive}, or those
286 of the files listed in @var{file}@dots{} that are present in the
287 archive. Normally only the member name is shown; if you also want to
288 see the modes (permissions), timestamp, owner, group, and size, you can
289 request that by also specifying the @samp{v} modifier.
291 If you do not specify a @var{file}, all files in the archive
294 @cindex repeated names in archive
295 @cindex name duplication in archive
296 If there is more than one file with the same name (say, @samp{fie}) in
297 an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
298 first instance; to see them all, you must ask for a complete
299 listing---in our example, @samp{ar t b.a}.
300 @c WRS only; per Gumby, this is implementation-dependent, and in a more
301 @c recent case in fact works the other way.
304 @cindex extract from archive
305 @emph{Extract} members (named @var{file}) from the archive. You can
306 use the @samp{v} modifier with this operation, to request that
307 @code{ar} list each name as it extracts it.
309 If you do not specify a @var{file}, all files in the archive
314 A number of modifiers (@var{mod}) may immediately follow the @var{p}
315 keyletter, to specify variations on an operation's behavior:
319 @cindex relative placement in archive
320 Add new files @emph{after} an existing member of the
321 archive. If you use the modifier @samp{a}, the name of an existing archive
322 member must be present as the @var{membername} argument, before the
323 @var{archive} specification.
326 Add new files @emph{before} an existing member of the
327 archive. If you use the modifier @samp{b}, the name of an existing archive
328 member must be present as the @var{membername} argument, before the
329 @var{archive} specification. (same as @samp{i}).
332 @cindex creating archives
333 @emph{Create} the archive. The specified @var{archive} is always
334 created if it didn't exist, when you request an update. But a warning is
335 issued unless you specify in advance that you expect to create it, by
339 Insert new files @emph{before} an existing member of the
340 archive. If you use the modifier @samp{i}, the name of an existing archive
341 member must be present as the @var{membername} argument, before the
342 @var{archive} specification. (same as @samp{b}).
345 This modifier is accepted but not used.
346 @c whaffor ar l modifier??? presumably compat; with
347 @c what???---pesch@@cygnus.com, 25jan91
350 @cindex dates in archive
351 Preserve the @emph{original} dates of members when extracting them. If
352 you do not specify this modifier, files extracted from the archive
353 are stamped with the time of extraction.
356 @cindex writing archive index
357 Write an object-file index into the archive, or update an existing one,
358 even if no other change is made to the archive. You may use this modifier
359 flag either with any operation, or alone. Running @samp{ar s} on an
360 archive is equivalent to running @samp{ranlib} on it.
363 @cindex updating an archive
364 Normally, @samp{ar r}@dots{} inserts all files
365 listed into the archive. If you would like to insert @emph{only} those
366 of the files you list that are newer than existing members of the same
367 names, use this modifier. The @samp{u} modifier is allowed only for the
368 operation @samp{r} (replace). In particular, the combination @samp{qu} is
369 not allowed, since checking the timestamps would lose any speed
370 advantage from the operation @samp{q}.
373 This modifier requests the @emph{verbose} version of an operation. Many
374 operations display additional information, such as filenames processed,
375 when the modifier @samp{v} is appended.
378 This modifier shows the version number of @code{ar}.
381 @node ar-scripts, , ar-cmdline, ar
382 @section Controlling @code{ar} with a script
385 ar -M [ <@var{script} ]
388 @cindex MRI compatibility, @code{ar}
389 @cindex scripts, @code{ar}
390 If you use the single command-line option @samp{-M} with @code{ar}, you
391 can control its operation with a rudimentary command language. This
392 form of @code{ar} operates interactively if standard input is coming
393 directly from a terminal. During interactive use, @code{ar} prompts for
394 input (the prompt is @samp{AR >}), and continues executing even after
395 errors. If you redirect standard input to a script file, no prompts are
396 issued, and @code{ar} abandons execution (with a nonzero exit code)
399 The @code{ar} command language is @emph{not} designed to be equivalent
400 to the command-line options; in fact, it provides somewhat less control
401 over archives. The only purpose of the command language is to ease the
402 transition to GNU @code{ar} for developers who already have scripts
403 written for the MRI ``librarian'' program.
405 The syntax for the @code{ar} command language is straightforward:
408 commands are recognized in upper or lower case; for example, @code{LIST}
409 is the same as @code{list}. In the following descriptions, commands are
410 shown in upper case for clarity.
413 a single command may appear on each line; it is the first word on the
417 empty lines are allowed, and have no effect.
420 comments are allowed; text after either of the characters @samp{*}
421 or @samp{;} is ignored.
424 Whenever you use a list of names as part of the argument to an @code{ar}
425 command, you can separate the individual names with either commas or
426 blanks. Commas are shown in the explanations below, for clarity.
429 @samp{+} is used as a line continuation character; if @samp{+} appears
430 at the end of a line, the text on the following line is considered part
431 of the current command.
434 Here are the commands you can use in @code{ar} scripts, or when using
435 @code{ar} interactively. Three of them have special significance:
437 @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
438 a temporary file required for most of the other commands.
440 @code{SAVE} commits the changes so far specified by the script. Prior
441 to @code{SAVE}, commands affect only the temporary copy of the current
445 @item ADDLIB @var{archive}
446 @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
447 Add all the contents of @var{archive} (or, if specified, each named
448 @var{module} from @var{archive}) to the current archive.
450 Requires prior use of @code{OPEN} or @code{CREATE}.
452 @item ADDMOD @var{file}, @var{file}, @dots{} @var{file}
453 @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
454 @c else like "ar q..."
455 Add each named @var{file} as a module in the current archive.
457 Requires prior use of @code{OPEN} or @code{CREATE}.
460 Discard the contents of the current archive, cancelling the effect of
461 any operations since the last @code{SAVE}. May be executed (with no
462 effect) even if no current archive is specified.
464 @item CREATE @var{archive}
465 Creates an archive, and makes it the current archive (required for many
466 other commands). The new archive is created with a temporary name; it
467 is not actually saved as @var{archive} until you use @code{SAVE}.
468 You can overwrite existing archives; similarly, the contents of any
469 existing file named @var{archive} will not be destroyed until @code{SAVE}.
471 @item DELETE @var{module}, @var{module}, @dots{} @var{module}
472 Delete each listed @var{module} from the current archive; equivalent to
473 @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
475 Requires prior use of @code{OPEN} or @code{CREATE}.
477 @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
478 @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
479 List each named @var{module} present in @var{archive}. The separate
480 command @code{VERBOSE} specifies the form of the output: when verbose
481 output is off, output is like that of @samp{ar -t @var{archive}
482 @var{module}@dots{}}. When verbose output is on, the listing is like
483 @samp{ar -tv @var{archive} @var{module}@dots{}}.
485 Output normally goes to the standard output stream; however, if you
486 specify @var{outputfile} as a final argument, @code{ar} directs the
490 Exit from @code{ar}, with a @code{0} exit code to indicate successful
491 completion. This command does not save the output file; if you have
492 changed the current archive since the last @code{SAVE} command, those
495 @item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
496 Extract each named @var{module} from the current archive, writing them
497 into the current directory as separate files. Equivalent to @samp{ar -x
498 @var{archive} @var{module}@dots{}}.
500 Requires prior use of @code{OPEN} or @code{CREATE}.
503 @c FIXME Tokens but no commands???
510 Display full contents of the current archive, in ``verbose'' style
511 regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
512 tv @var{archive}}). (This single command is a GNU @code{ld}
513 enhancement, rather than present for MRI compatibility.)
515 Requires prior use of @code{OPEN} or @code{CREATE}.
517 @item OPEN @var{archive}
518 Opens an existing archive for use as the current archive (required for
519 many other commands). Any changes as the result of subsequent commands
520 will not actually affect @var{archive} until you next use @code{SAVE}.
522 @item REPLACE @var{module}, @var{module}, @dots{} @var{module}
523 In the current archive, replace each existing @var{module} (named in
524 the @code{REPLACE} arguments) from files in the current working directory.
525 To execute this command without errors, both the file, and the module in
526 the current archive, must exist.
528 Requires prior use of @code{OPEN} or @code{CREATE}.
531 Toggle an internal flag governing the output from @code{DIRECTORY}.
532 When the flag is on, @code{DIRECTORY} output matches output from
533 @samp{ar -tv }@dots{}.
536 Commit your changes to the current archive, and actually save it as a
537 file with the name specified in the last @code{CREATE} or @code{OPEN}
540 Requires prior use of @code{OPEN} or @code{CREATE}.
544 @node objcopy, nm, ar, Top
548 objcopy [ -F @var{format} | --format=@var{format} ]
549 [ -I @var{format} | --input-format=@var{format} ]
550 [ -O @var{format} | --output-format=@var{format} ]
551 [ -S | --strip-all ] [ -g | --strip-debug ]
552 [ -x | --discard-all ] [ -X | --discard-locals ]
553 [ -v | --verbose ] [ -V | --version ]
554 @var{infile} [@var{outfile}]
557 The GNU @code{objcopy} utility copies the contents of an object file to
558 another. @code{objcopy} uses the GNU BFD Library to read and write the
559 object files. It can write the destination object file in a format
560 different from that of the source object file. The exact behavior of
561 @code{objcopy} is controlled by command-line options.
563 @code{objcopy} creates temporary files to do its translations and
564 deletes them afterward. @code{objcopy} uses BFD to do all its
565 translation work; it knows about all the formats BFD knows about, and
566 thus is able to recognize most formats without being told explicitly.
567 @xref{BFD,,BFD,ld.info,Using LD, the GNU linker}.
572 The source and output files respectively.
573 If you do not specify @var{outfile}, @code{objcopy} creates a
574 temporary file and destructively renames the result with
575 the name of the input file.
577 @item -I @var{format}
578 @itemx --input-format=@var{format}
579 Consider the source file's object format to be @var{format}, rather than
580 attempting to deduce it.
582 @item -O @var{format}
583 @itemx --output-format=@var{format}
584 Write the output file using the object format @var{format}.
586 @item -F @var{format}
587 @itemx --format=@var{format}
588 Use @var{format} as the object format for both the input and the output
589 file; i.e. simply transfer data from source to destination with no
594 Do not copy relocation and symbol information from the source file.
598 Do not copy debugging symbols from the source file.
602 Do not copy non-global symbols from the source file.
603 @c FIXME any reason to prefer "non-global" to "local" here?
606 @itemx --discard-locals
607 Do not copy compiler-generated local symbols.
608 (These usually start with @samp{L} or @samp{.}.)
612 Show the version number of @code{objcopy}.
616 Verbose output: list all object files modified. In the case of
617 archives, @samp{objcopy -V} lists all members of the archive.
625 The GNU linker @code{ld} is now described in a separate manual.
626 @xref{Top,, Overview,, Using LD: the GNU linker}.
629 @node nm, objdump, objcopy, Top
635 nm [ -a | --debug-syms ] [ -g | --extern-only ]
636 [ -s | --print-armap ] [ -o | --print-file-name ]
637 [ -n | --numeric-sort ] [ -p | --no-sort ]
638 [ -r | --reverse-sort ] [ -u | --undefined-only ]
639 [ --target=@var{bfdname} ]
640 [ @var{objfile}@dots{} ]
643 GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}.
645 The long and short forms of options, shown here as alternatives, are
649 @item @var{objfile}@dots{}
651 Object files whose symbols are to be listed. If no object files are
652 listed as arguments, @code{nm} assumes @samp{a.out}.
656 @cindex debugging symbols
657 Display debugger-only symbols; normally these are not listed.
661 @cindex external symbols
662 Display only external symbols.
666 @cindex sorting symbols
667 Don't bother to sort the symbols in any order; just print them in the
671 @itemx --numeric-sort
672 Sort symbols numerically by their addresses, rather than alphabetically
677 @cindex symbol index, listing
678 When listing symbols from archive members, include the index: a mapping
679 (stored in the archive by @code{ar} or @code{ranlib}) of which modules
680 contain definitions for which names.
683 @itemx --print-file-name
684 @cindex input file name
686 @cindex source file name
687 Precede each symbol by the name of the input file where it was found,
688 rather than identifying the input file once only before all of its
692 @itemx --reverse-sort
693 Reverse the order of the sort (whether numeric or alphabetic); let the
696 @item --target=@var{bfdname}
698 @cindex object code format
699 Specify an object code format other than your system's default format.
700 @xref{objdump}, for information on listing available formats.
701 @c FIXME what *does* --target/no arg do?
704 @itemx --undefined-only
705 @cindex external symbols
706 @cindex undefined symbols
707 Display only undefined symbols (those external to each object file).
711 @node objdump, ranlib, nm, Top
714 @cindex object file information
718 objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ]
719 [ -h | --header ] [ -i ] [ -j @var{section} ] [ -l ]
720 [ -m @var{machine} ] [ -r | --reloc ] [ -s ]
721 [ --stabs ] [ -t | --syms ] [ -x ]
725 @code{objdump} displays information about one or more object files.
726 The options control what particular information to display. This
727 information is mostly useful to programmers who are working on the
728 compilation tools, as opposed to programmers who just want their
729 program to compile and work.
731 The long and short forms of options, shown here as alternatives, are
735 @item @var{objfile}@dots{}
736 The object files to be examined. When you specify archives,
737 @code{objdump} shows information on each of the member object files.
741 @cindex archive headers
742 If any of the @var{objfile} files are archives, display the archive
743 header information (in a format similar to @samp{ls -l}). Besides the
744 information you could list with @samp{ar tv}, @samp{objdump -a} shows
745 the object file format of each archive member.
747 @c suggest longname --target or --format or --bfd
748 @item -b @var{bfdname}
749 @cindex object code format
750 Specify that the object-code format for the object files is
751 @var{bfdname}. This option may not be necessary; @var{objdump} can
752 automatically recognize many formats.
756 objdump -b oasys -m vax -h fu.o
759 displays summary information from the section headers (@samp{-h}) of
760 @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
761 file in the format produced by Oasys compilers. You can list the
762 formats available with the @samp{-i} option.
765 @cindex disassembling object code
766 @cindex machine instructions
767 Disassemble. Display the assembler mnemonics for the machine
768 instructions from @var{objfile}.
771 @cindex object file header
772 File header. Display summary information from the overall header of
773 each of the @var{objfile} files.
777 @cindex section headers
778 Header. Display summary information from the section headers of the
782 @cindex architectures available
783 @cindex object formats available
784 Display a list showing all architectures and object formats available
785 for specification with @samp{-b} or @samp{-m}.
787 @c suggest longname --section
789 @cindex section information
790 Display information only for section @var{name}.
792 @c suggest longname --label or --linespec
794 @cindex source filenames for object files
795 Label the display (using debugging information) with the source filename
796 and line numbers corresponding to the object code shown.
798 @c suggest longname --architecture
799 @item -m @var{machine}
801 Specify that the object files @var{objfile} are for architecture
802 @var{machine}. You can list available architectures using the @samp{-i}
807 @cindex relocation entries, in object file
808 Relocation. Print the relocation entries of the file.
811 @cindex sections, full contents
812 @cindex object file sections
813 Display the full contents of any sections requested.
818 @cindex debug symbols
819 @cindex ELF object file format
820 Display the full contents of any sections requested. Display the
821 contents of the .stab and .stab.index and .stab.excl sections from an
822 ELF file. This is only useful on systems (such as Solaris 2.0) in which
823 @code{.stab} debugging symbol-table entries are carried in an ELF
824 section. In most other file formats, debugging symbol-table entries are
825 interleaved with linkage symbols, and are visible in the @samp{--syms}
830 @cindex symbol table entries, printing
831 Symbol Table. Print the symbol table entries of the file.
832 This is similar to the information provided by the @samp{nm} program.
835 @cindex all header information, object file
836 @cindex header information, all
837 Display all available header information, including the symbol table and
838 relocation entries. Using @samp{-x} is equivalent to specifying all of
839 @samp{-a -f -h -r -t}.
843 @node ranlib, size, objdump, Top
847 @cindex archive contents
851 ranlib [-vV] @var{archive}
854 @code{ranlib} generates an index to the contents of an archive and
855 stores it in the archive. The index lists each symbol defined by a
856 member of an archive that is a relocatable object file.
858 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
860 An archive with such an index speeds up linking to the library and
861 allows routines in the library to call each other without regard to
862 their placement in the archive.
864 The GNU @code{ranlib} program is another form of GNU @code{ar}; running
865 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
871 Show the version number of @code{ranlib}.
874 @node size, strip, ranlib, Top
878 @cindex section sizes
881 size [ -A | -B | --format=@var{compatibility} ]
882 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
883 [ --target=@var{bfdname} ] [ -V | --version ]
887 The GNU @code{size} utility lists the section sizes---and the total
888 size---for each of the object or archive files @var{objfile} in its
889 argument list. By default, one line of output is generated for each
890 object file or each module in an archive.
892 The command line options have the following meanings:
894 @item @var{objfile}@dots{}
895 The object files to be examined.
899 @itemx --format=@var{compatibility}
900 @cindex size display format
901 Using one of these options, you can choose whether the output from GNU
902 @code{size} resembles output from System V @code{size} (using @samp{-A},
903 or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
904 @samp{--format=berkeley}). The default is the one-line format similar to
906 @c Bonus for doc-source readers: you can also say --format=strange (or
907 @c anything else that starts with 's') for sysv, and --format=boring (or
908 @c anything else that starts with 'b') for Berkeley.
910 Here is an example of the Berkeley (default) format of output from
913 size --format Berkeley ranlib size
914 text data bss dec hex filename
915 294880 81920 11592 388392 5ed28 ranlib
916 294880 81920 11888 388688 5ee50 size
920 This is the same data, but displayed closer to System V conventions:
923 size --format SysV ranlib size
941 Show a summary of acceptable arguments and options.
946 @itemx --radix=@var{number}
947 @cindex size number format
948 @cindex radix for section sizes
949 Using one of these options, you can control whether the size of each
950 section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
951 (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
952 @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
953 values (8, 10, 16) are supported. The total size is always given in two
954 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
955 octal and hexadecimal if you're using @samp{-o}.
957 @item --target=@var{bfdname}
958 @cindex object code format
959 Specify that the object-code format for @var{objfile} is
960 @var{bfdname}. This option may not be necessary; @code{size} can
961 automatically recognize many formats. @xref{objdump}, for information
962 on listing available formats.
966 Display the version number of @code{size}.
969 @node strip, c++filt, size, Top
973 @cindex removing symbols
974 @cindex discarding symbols
975 @cindex symbols, discarding
978 strip [ -F @var{format} | --format=@var{format} | --target=@var{format} ]
979 [ -I @var{format} | --input-format=@var{format} ]
980 [ -O @var{format} | --output-format=@var{format} ]
981 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
982 [ -x | --discard-all ] [ -X | --discard-locals ]
983 [ -v | --verbose ] [ -V | --version ]
987 GNU @code{strip} discards all symbols from object files
988 @var{objfile}. The list of object files may include archives.
990 @code{strip} will not execute unless at least one object file is listed.
992 @code{strip} modifies the files named in its argument,
993 rather than writing modified copies under different names.
996 @item -I @var{format}
997 @itemx --input-format=@var{format}
998 Treat the original @var{objfile} as a file with the object
999 code format @var{format}.
1001 @item -O @var{format}
1002 @itemx --output-format=@var{format}
1003 Replace @var{objfile} with a file in the output format @var{format}.
1005 @item -F @var{format}
1006 @itemx --format=@var{format}
1007 @itemx --target=@var{format}
1008 Treat the original @var{objfile} as a file with the object
1009 code format @var{format}, and rewrite it in the same format.
1017 @itemx --strip-debug
1018 Remove debugging symbols only.
1021 @itemx --discard-all
1022 Remove non-global symbols.
1025 @itemx --discard-locals
1026 Remove compiler-generated local symbols.
1027 (These usually start with @samp{L} or @samp{.}.)
1031 Show the version number for @code{strip}.
1035 Verbose output: list all object files modified. In the case of
1036 archives, @samp{strip -v} lists all members of the archive.
1039 @node c++filt, Index, strip, Top
1043 @cindex demangling C++ symbols
1045 The C++ language provides function overloading, which means that
1046 you can write many function with the same name (but taking
1047 different kinds of parameters). So that the linker can keep these
1048 overloaded functions from clashing, all C++ function names are
1049 encoded (``mangled'') into a funny-looking low-level assembly label.
1050 The @code{c++filt} program does the inverse mapping: It decodes
1051 (``demangles'') low-level names into user-level names.
1053 When you use @code{c++filt} as a filter (which is usually the case),
1054 it reads from standard input. Every alphanumeric word (consisting
1055 of letters, digits, underscores, dollars, or periods) seen in the
1056 input is a potential label. If the label decodes into a C++ name.
1057 the C++ name will replace the low-level name in the output.
1059 A typical use of @code{c++filt} is to pipe the output of @code{nm}
1062 Note that on some systems, both the C and C++ compilers put an
1063 underscore in front of every name. (I.e. the C name @code{foo} gets the
1064 low-level name @code{_foo}.) On such systems, @code{c++filt} removes
1065 any initial underscore of a potential label.
1067 @node Index, , c++filt, Top