1 \input texinfo @c -*- Texinfo -*-
2 @setfilename binutils.info
7 * Binutils: (binutils). The GNU binary utilities "ar", "ld", "objcopy",
8 "objdump", "nm", "size", "strings", "strip", and "ranlib".
14 Copyright @copyright{} 1991, 1992, 1993, 1994 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", "strings", "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
52 @title The GNU Binary Utilities
56 @author Roland H. Pesch
57 @author Jeffrey M. Osier
58 @author Cygnus Support
62 {\parskip=0pt \hfill Cygnus Support\par \hfill
63 \TeX{}info \texinfoversion\par }
66 @vskip 0pt plus 1filll
67 Copyright @copyright{} 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
69 Permission is granted to make and distribute verbatim copies of
70 this manual provided the copyright notice and this permission notice
71 are preserved on all copies.
73 Permission is granted to copy and distribute modified versions of this
74 manual under the conditions for verbatim copying, provided also that
75 the entire resulting derived work is distributed under the terms of a
76 permission notice identical to this one.
78 Permission is granted to copy and distribute translations of this manual
79 into another language, under the above conditions for modified versions.
86 This brief manual contains preliminary documentation for the GNU binary
87 utilities (collectively version 2.2):
92 Create, modify, and extract from archives
95 List symbols from object files
98 Copy and translate object files
101 Display information from object files
104 Generate index to archive contents
107 List file section sizes and total size
110 List printable strings from files
116 Demangle encoded C++ symbols
119 Convert object code into a Netware Loadable Module
124 * ar:: Create, modify, and extract from archives
125 * nm:: List symbols from object files
126 * objcopy:: Copy and translate object files
127 * objdump:: Display information from object files
128 * ranlib:: Generate index to archive contents
129 * size:: List section sizes and total size
130 * strings:: List printable strings from files
131 * strip:: Discard symbols
132 * c++filt:: Filter to demangle encoded C++ symbols
133 * nlmconv:: Converts object code into an NLM
134 * Selecting The Target System:: How these utilities determine the target.
143 @cindex collections of files
145 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
146 ar -M [ <mri-script ]
149 The GNU @code{ar} program creates, modifies, and extracts from
150 archives. An @dfn{archive} is a single file holding a collection of
151 other files in a structure that makes it possible to retrieve
152 the original individual files (called @dfn{members} of the archive).
154 The original files' contents, mode (permissions), timestamp, owner, and
155 group are preserved in the archive, and can be restored on
159 GNU @code{ar} can maintain archives whose members have names of any
160 length; however, depending on how @code{ar} is configured on your
161 system, a limit on member-name length may be imposed for compatibility
162 with archive formats maintained with other tools. If it exists, the
163 limit is often 15 characters (typical of formats related to a.out) or 16
164 characters (typical of formats related to coff).
167 @code{ar} is considered a binary utility because archives of this sort
168 are most often used as @dfn{libraries} holding commonly needed
172 @code{ar} creates an index to the symbols defined in relocatable
173 object modules in the archive when you specify the modifier @samp{s}.
174 Once created, this index is updated in the archive whenever @code{ar}
175 makes a change to its contents (save for the @samp{q} update operation).
176 An archive with such an index speeds up linking to the library, and
177 allows routines in the library to call each other without regard to
178 their placement in the archive.
180 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
181 table. If an archive lacks the table, another form of @code{ar} called
182 @code{ranlib} can be used to add just the table.
184 @cindex compatibility, @code{ar}
185 @cindex @code{ar} compatibility
186 GNU @code{ar} is designed to be compatible with two different
187 facilities. You can control its activity using command-line options,
188 like the different varieties of @code{ar} on Unix systems; or, if you
189 specify the single command-line option @samp{-M}, you can control it
190 with a script supplied via standard input, like the MRI ``librarian''
194 * ar cmdline:: Controlling @code{ar} on the command line
195 * ar scripts:: Controlling @code{ar} with a script
200 @section Controlling @code{ar} on the command line
203 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
206 @cindex Unix compatibility, @code{ar}
207 When you use @code{ar} in the Unix style, @code{ar} insists on at least two
208 arguments to execute: one keyletter specifying the @emph{operation}
209 (optionally accompanied by other keyletters specifying
210 @emph{modifiers}), and the archive name to act on.
212 Most operations can also accept further @var{member} arguments,
213 specifying particular files to operate on.
215 GNU @code{ar} allows you to mix the operation code @var{p} and modifier
216 flags @var{mod} in any order, within the first command-line argument.
218 If you wish, you may begin the first command-line argument with a
221 @cindex operations on archive
222 The @var{p} keyletter specifies what operation to execute; it may be
223 any of the following, but you must specify only one of them:
227 @cindex deleting from archive
228 @emph{Delete} modules from the archive. Specify the names of modules to
229 be deleted as @var{member}@dots{}; the archive is untouched if you
230 specify no files to delete.
232 If you specify the @samp{v} modifier, @code{ar} lists each module
236 @cindex moving in archive
237 Use this operation to @emph{move} members in an archive.
239 The ordering of members in an archive can make a difference in how
240 programs are linked using the library, if a symbol is defined in more
243 If no modifiers are used with @code{m}, any members you name in the
244 @var{member} arguments are moved to the @emph{end} of the archive;
245 you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
246 specified place instead.
249 @cindex printing from archive
250 @emph{Print} the specified members of the archive, to the standard
251 output file. If the @samp{v} modifier is specified, show the member
252 name before copying its contents to standard output.
254 If you specify no @var{member} arguments, all the files in the archive are
258 @cindex quick append to archive
259 @emph{Quick append}; add the files @var{member}@dots{} to the end of
260 @var{archive}, without checking for replacement.
262 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
263 operation; new members are always placed at the end of the archive.
265 The modifier @samp{v} makes @code{ar} list each file as it is appended.
267 Since the point of this operation is speed, the archive's symbol table
268 index is not updated, even if it already existed; you can use @samp{ar s} or
269 @code{ranlib} explicitly to update the symbol table index.
272 @cindex replacement in archive
273 Insert the files @var{member}@dots{} into @var{archive} (with
274 @emph{replacement}). This operation differs from @samp{q} in that any
275 previously existing members are deleted if their names match those being
278 If one of the files named in @var{member}@dots{} does not exist, @code{ar}
279 displays an error message, and leaves undisturbed any existing members
280 of the archive matching that name.
282 By default, new members are added at the end of the file; but you may
283 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
284 placement relative to some existing member.
286 The modifier @samp{v} used with this operation elicits a line of
287 output for each file inserted, along with one of the letters @samp{a} or
288 @samp{r} to indicate whether the file was appended (no old member
289 deleted) or replaced.
292 @cindex contents of archive
293 Display a @emph{table} listing the contents of @var{archive}, or those
294 of the files listed in @var{member}@dots{} that are present in the
295 archive. Normally only the member name is shown; if you also want to
296 see the modes (permissions), timestamp, owner, group, and size, you can
297 request that by also specifying the @samp{v} modifier.
299 If you do not specify a @var{member}, all files in the archive
302 @cindex repeated names in archive
303 @cindex name duplication in archive
304 If there is more than one file with the same name (say, @samp{fie}) in
305 an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
306 first instance; to see them all, you must ask for a complete
307 listing---in our example, @samp{ar t b.a}.
308 @c WRS only; per Gumby, this is implementation-dependent, and in a more
309 @c recent case in fact works the other way.
312 @cindex extract from archive
313 @emph{Extract} members (named @var{member}) from the archive. You can
314 use the @samp{v} modifier with this operation, to request that
315 @code{ar} list each name as it extracts it.
317 If you do not specify a @var{member}, all files in the archive
322 A number of modifiers (@var{mod}) may immediately follow the @var{p}
323 keyletter, to specify variations on an operation's behavior:
327 @cindex relative placement in archive
328 Add new files @emph{after} an existing member of the
329 archive. If you use the modifier @samp{a}, the name of an existing archive
330 member must be present as the @var{relpos} argument, before the
331 @var{archive} specification.
334 Add new files @emph{before} an existing member of the
335 archive. If you use the modifier @samp{b}, the name of an existing archive
336 member must be present as the @var{relpos} argument, before the
337 @var{archive} specification. (same as @samp{i}).
340 @cindex creating archives
341 @emph{Create} the archive. The specified @var{archive} is always
342 created if it did not exist, when you request an update. But a warning is
343 issued unless you specify in advance that you expect to create it, by
347 Insert new files @emph{before} an existing member of the
348 archive. If you use the modifier @samp{i}, the name of an existing archive
349 member must be present as the @var{relpos} argument, before the
350 @var{archive} specification. (same as @samp{b}).
353 This modifier is accepted but not used.
354 @c whaffor ar l modifier??? presumably compat; with
355 @c what???---pesch@@cygnus.com, 25jan91
358 @cindex dates in archive
359 Preserve the @emph{original} dates of members when extracting them. If
360 you do not specify this modifier, files extracted from the archive
361 are stamped with the time of extraction.
364 @cindex writing archive index
365 Write an object-file index into the archive, or update an existing one,
366 even if no other change is made to the archive. You may use this modifier
367 flag either with any operation, or alone. Running @samp{ar s} on an
368 archive is equivalent to running @samp{ranlib} on it.
371 @cindex updating an archive
372 Normally, @samp{ar r}@dots{} inserts all files
373 listed into the archive. If you would like to insert @emph{only} those
374 of the files you list that are newer than existing members of the same
375 names, use this modifier. The @samp{u} modifier is allowed only for the
376 operation @samp{r} (replace). In particular, the combination @samp{qu} is
377 not allowed, since checking the timestamps would lose any speed
378 advantage from the operation @samp{q}.
381 This modifier requests the @emph{verbose} version of an operation. Many
382 operations display additional information, such as filenames processed,
383 when the modifier @samp{v} is appended.
386 This modifier shows the version number of @code{ar}.
390 @section Controlling @code{ar} with a script
393 ar -M [ <@var{script} ]
396 @cindex MRI compatibility, @code{ar}
397 @cindex scripts, @code{ar}
398 If you use the single command-line option @samp{-M} with @code{ar}, you
399 can control its operation with a rudimentary command language. This
400 form of @code{ar} operates interactively if standard input is coming
401 directly from a terminal. During interactive use, @code{ar} prompts for
402 input (the prompt is @samp{AR >}), and continues executing even after
403 errors. If you redirect standard input to a script file, no prompts are
404 issued, and @code{ar} abandons execution (with a nonzero exit code)
407 The @code{ar} command language is @emph{not} designed to be equivalent
408 to the command-line options; in fact, it provides somewhat less control
409 over archives. The only purpose of the command language is to ease the
410 transition to GNU @code{ar} for developers who already have scripts
411 written for the MRI ``librarian'' program.
413 The syntax for the @code{ar} command language is straightforward:
416 commands are recognized in upper or lower case; for example, @code{LIST}
417 is the same as @code{list}. In the following descriptions, commands are
418 shown in upper case for clarity.
421 a single command may appear on each line; it is the first word on the
425 empty lines are allowed, and have no effect.
428 comments are allowed; text after either of the characters @samp{*}
429 or @samp{;} is ignored.
432 Whenever you use a list of names as part of the argument to an @code{ar}
433 command, you can separate the individual names with either commas or
434 blanks. Commas are shown in the explanations below, for clarity.
437 @samp{+} is used as a line continuation character; if @samp{+} appears
438 at the end of a line, the text on the following line is considered part
439 of the current command.
442 Here are the commands you can use in @code{ar} scripts, or when using
443 @code{ar} interactively. Three of them have special significance:
445 @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
446 a temporary file required for most of the other commands.
448 @code{SAVE} commits the changes so far specified by the script. Prior
449 to @code{SAVE}, commands affect only the temporary copy of the current
453 @item ADDLIB @var{archive}
454 @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
455 Add all the contents of @var{archive} (or, if specified, each named
456 @var{module} from @var{archive}) to the current archive.
458 Requires prior use of @code{OPEN} or @code{CREATE}.
460 @item ADDMOD @var{member}, @var{member}, @dots{} @var{member}
461 @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
462 @c else like "ar q..."
463 Add each named @var{member} as a module in the current archive.
465 Requires prior use of @code{OPEN} or @code{CREATE}.
468 Discard the contents of the current archive, cancelling the effect of
469 any operations since the last @code{SAVE}. May be executed (with no
470 effect) even if no current archive is specified.
472 @item CREATE @var{archive}
473 Creates an archive, and makes it the current archive (required for many
474 other commands). The new archive is created with a temporary name; it
475 is not actually saved as @var{archive} until you use @code{SAVE}.
476 You can overwrite existing archives; similarly, the contents of any
477 existing file named @var{archive} will not be destroyed until @code{SAVE}.
479 @item DELETE @var{module}, @var{module}, @dots{} @var{module}
480 Delete each listed @var{module} from the current archive; equivalent to
481 @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
483 Requires prior use of @code{OPEN} or @code{CREATE}.
485 @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
486 @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
487 List each named @var{module} present in @var{archive}. The separate
488 command @code{VERBOSE} specifies the form of the output: when verbose
489 output is off, output is like that of @samp{ar -t @var{archive}
490 @var{module}@dots{}}. When verbose output is on, the listing is like
491 @samp{ar -tv @var{archive} @var{module}@dots{}}.
493 Output normally goes to the standard output stream; however, if you
494 specify @var{outputfile} as a final argument, @code{ar} directs the
498 Exit from @code{ar}, with a @code{0} exit code to indicate successful
499 completion. This command does not save the output file; if you have
500 changed the current archive since the last @code{SAVE} command, those
503 @item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
504 Extract each named @var{module} from the current archive, writing them
505 into the current directory as separate files. Equivalent to @samp{ar -x
506 @var{archive} @var{module}@dots{}}.
508 Requires prior use of @code{OPEN} or @code{CREATE}.
511 @c FIXME Tokens but no commands???
518 Display full contents of the current archive, in ``verbose'' style
519 regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
520 tv @var{archive}}). (This single command is a GNU @code{ld}
521 enhancement, rather than present for MRI compatibility.)
523 Requires prior use of @code{OPEN} or @code{CREATE}.
525 @item OPEN @var{archive}
526 Opens an existing archive for use as the current archive (required for
527 many other commands). Any changes as the result of subsequent commands
528 will not actually affect @var{archive} until you next use @code{SAVE}.
530 @item REPLACE @var{module}, @var{module}, @dots{} @var{module}
531 In the current archive, replace each existing @var{module} (named in
532 the @code{REPLACE} arguments) from files in the current working directory.
533 To execute this command without errors, both the file, and the module in
534 the current archive, must exist.
536 Requires prior use of @code{OPEN} or @code{CREATE}.
539 Toggle an internal flag governing the output from @code{DIRECTORY}.
540 When the flag is on, @code{DIRECTORY} output matches output from
541 @samp{ar -tv }@dots{}.
544 Commit your changes to the current archive, and actually save it as a
545 file with the name specified in the last @code{CREATE} or @code{OPEN}
548 Requires prior use of @code{OPEN} or @code{CREATE}.
557 The GNU linker @code{ld} is now described in a separate manual.
558 @xref{Top,, Overview,, Using LD: the GNU linker}.
567 nm [ -a | --debug-syms ] [ -g | --extern-only ]
568 [ -B ] [ -C | --demangle ]
569 [ -s | --print-armap ] [ -A | -o | --print-file-name ]
570 [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
571 [ -r | --reverse-sort ] [ -u | --undefined-only ]
572 [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ]
573 [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ]
574 [ -V | --version ] [ --help ] [ @var{objfile}@dots{} ]
577 GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}.
578 If no object files are listed as arguments, @code{nm} assumes
581 For each symbol, @code{nm} shows:
585 The symbol value, in the radix selected by options (see below), or
586 hexadecimal by default.
589 The symbol type. At least the following types are used; others are, as
590 well, depending on the object file format. If lowercase, the symbol is
591 local; if uppercase, the symbol is global (external).
593 @c Some more detail on exactly what these symbol types are used for
600 BSS (uninitialized data).
622 The long and short forms of options, shown here as alternatives, are
628 @itemx --print-file-name
629 @cindex input file name
631 @cindex source file name
632 Precede each symbol by the name of the input file (or archive element)
633 in which it was found, rather than identifying the input file once only,
634 before all of its symbols.
638 @cindex debugging symbols
639 Display all symbols, even debugger-only symbols; normally these are not
643 @cindex @code{nm} format
644 @cindex @code{nm} compatibility
645 The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
649 @cindex demangling C++ symbols
650 Decode (@dfn{demangle}) low-level symbol names into user-level names.
651 Besides removing any initial underscore prepended by the system, this
652 makes C++ function names readable. @xref{c++filt}, for more information
655 @item -f @var{format}
656 @itemx --format=@var{format}
657 @cindex @code{nm} format
658 @cindex @code{nm} compatibility
659 Use the output format @var{format}, which can be @code{bsd},
660 @code{sysv}, or @code{posix}. The default is @code{bsd}.
661 Only the first character of @var{format} is significant; it can be
662 either upper or lower case.
666 @cindex external symbols
667 Display only external symbols.
671 @itemx --numeric-sort
672 Sort symbols numerically by their addresses, rather than alphabetically
677 @cindex sorting symbols
678 Do not bother to sort the symbols in any order; print them in the order
683 Use the POSIX.2 standard output format instead of the default format.
684 Equivalent to @samp{-f posix}.
688 @cindex symbol index, listing
689 When listing symbols from archive members, include the index: a mapping
690 (stored in the archive by @code{ar} or @code{ranlib}) of which modules
691 contain definitions for which names.
694 @itemx --reverse-sort
695 Reverse the order of the sort (whether numeric or alphabetic); let the
699 @itemx --radix=@var{radix}
700 Use @var{radix} as the radix for printing the symbol values. It must be
701 @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
703 @item --target=@var{bfdname}
704 @cindex object code format
705 Specify an object code format other than your system's default format.
706 @xref{Target Selection}, for more information.
709 @itemx --undefined-only
710 @cindex external symbols
711 @cindex undefined symbols
712 Display only undefined symbols (those external to each object file).
716 Show the version number of @code{nm} and exit.
719 Show a summary of the options to @code{nm} and exit.
726 objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
727 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
728 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
729 [ -S | --strip-all ] [ -g | --strip-debug ]
730 [ -x | --discard-all ] [ -X | --discard-locals ]
731 [ -b @var{byte} | --byte=@var{byte} ]
732 [ -i @var{interleave} | --interleave=@var{interleave} ]
733 [ -v | --verbose ] [ -V | --version ] [ --help ]
734 @var{infile} [@var{outfile}]
737 The @sc{gnu} @code{objcopy} utility copies the contents of an object
738 file to another. @code{objcopy} uses the @sc{gnu} @sc{bfd} Library to
739 read and write the object files. It can write the destination object
740 file in a format different from that of the source object file. The
741 exact behavior of @code{objcopy} is controlled by command-line options.
743 @code{objcopy} creates temporary files to do its translations and
744 deletes them afterward. @code{objcopy} uses @sc{bfd} to do all its
745 translation work; it has access to all the formats described in @sc{bfd}
746 and thus is able to recognize most formats without being told
747 explicitly. @xref{BFD,,BFD,ld.info,Using LD}.
752 The source and output files, respectively.
753 If you do not specify @var{outfile}, @code{objcopy} creates a
754 temporary file and destructively renames the result with
755 the name of @var{infile}.
757 @item -I @var{bfdname}
758 @itemx --input-target=@var{bfdname}
759 Consider the source file's object format to be @var{bfdname}, rather than
760 attempting to deduce it. @xref{Target Selection}, for more information.
762 @item -O @var{bfdname}
763 @itemx --output-target=@var{bfdname}
764 Write the output file using the object format @var{bfdname}.
765 @xref{Target Selection}, for more information.
767 @item -F @var{bfdname}
768 @itemx --target=@var{bfdname}
769 Use @var{bfdname} as the object format for both the input and the output
770 file; i.e., simply transfer data from source to destination with no
771 translation. @xref{Target Selection}, for more information.
775 Do not copy relocation and symbol information from the source file.
779 Do not copy debugging symbols from the source file.
783 Do not copy non-global symbols from the source file.
784 @c FIXME any reason to prefer "non-global" to "local" here?
787 @itemx --discard-locals
788 Do not copy compiler-generated local symbols.
789 (These usually start with @samp{L} or @samp{.}.)
792 @itemx --byte=@var{byte}
793 Keep only every @var{byte}th byte of the input file (header data is not
794 affected). @var{byte} can be in the range from 0 to @var{interleave}-1,
795 where @var{interleave} is given by the @samp{-i} or @samp{--interleave}
796 option, or the default of 4. This option is useful for creating files
797 to program @sc{rom}. It is typically used with an @code{srec} output
800 @item -i @var{interleave}
801 @itemx --interleave=@var{interleave}
802 Only copy one out of every @var{interleave} bytes. Select which byte to
803 copy with the @var{-b} or @samp{--byte} option. The default is 4.
804 @code{objcopy} ignores this option if you do not specify either @samp{-b} or
809 Show the version number of @code{objcopy}.
813 Verbose output: list all object files modified. In the case of
814 archives, @samp{objcopy -V} lists all members of the archive.
817 Show a summary of the options to @code{objcopy}.
823 @cindex object file information
827 objdump [ -a | --archive-headers ]
828 [ -b @var{bfdname} | --target=@var{bfdname} ]
829 [ -d | --disassemble ] [ -f | --file-headers ]
830 [ -h | --section-headers | --headers ] [ -i | --info ]
831 [ -j @var{section} | --section=@var{section} ]
832 [ -l | --line-numbers ]
833 [ -m @var{machine} | --architecture=@var{machine} ] [ -r | --reloc ]
834 [ -s | --full-contents ] [ --stabs ] [ -t | --syms ]
835 [ -x | --all-headers ] [ --version ] [ --help ]
839 @code{objdump} displays information about one or more object files.
840 The options control what particular information to display. This
841 information is mostly useful to programmers who are working on the
842 compilation tools, as opposed to programmers who just want their
843 program to compile and work.
845 @var{objfile}@dots{} are the object files to be examined. When you
846 specify archives, @code{objdump} shows information on each of the member
849 The long and short forms of options, shown here as alternatives, are
850 equivalent. At least one option besides @samp{-l} must be given.
854 @itemx --archive-header
855 @cindex archive headers
856 If any of the @var{objfile} files are archives, display the archive
857 header information (in a format similar to @samp{ls -l}). Besides the
858 information you could list with @samp{ar tv}, @samp{objdump -a} shows
859 the object file format of each archive member.
861 @item -b @var{bfdname}
862 @itemx --target=@var{bfdname}
863 @cindex object code format
864 Specify that the object-code format for the object files is
865 @var{bfdname}. This option may not be necessary; @var{objdump} can
866 automatically recognize many formats.
870 objdump -b oasys -m vax -h fu.o
873 displays summary information from the section headers (@samp{-h}) of
874 @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
875 file in the format produced by Oasys compilers. You can list the
876 formats available with the @samp{-i} option.
877 @xref{Target Selection}, for more information.
881 @cindex disassembling object code
882 @cindex machine instructions
883 Display the assembler mnemonics for the machine
884 instructions from @var{objfile}.
888 @cindex object file header
889 Display summary information from the overall header of
890 each of the @var{objfile} files.
893 @itemx --section-header
895 @cindex section headers
896 Display summary information from the section headers of the
899 File segments may be relocated to nonstandard addresses, for example by
900 using the @samp{-Ttext}, @samp{-Tdata}, or @samp{-Tbss} options to
901 @code{ld}. However, some object file formats, such as a.out, do not
902 store the starting address of the file segments. In those situations,
903 although @code{ld} relocates the sections correctly, using @samp{objdump
904 -h} to list the file section headers cannot show the correct addresses.
905 Instead, it shows the usual addresses, which are implicit for the
909 Print a summary of the options to @code{objdump} and exit.
913 @cindex architectures available
914 @cindex object formats available
915 Display a list showing all architectures and object formats available
916 for specification with @samp{-b} or @samp{-m}.
919 @itemx --section=@var{name}
920 @cindex section information
921 Display information only for section @var{name}.
924 @itemx --line-numbers
925 @cindex source filenames for object files
926 Label the display (using debugging information) with the filename
927 and source line numbers corresponding to the object code shown.
928 Only useful with @samp{-d}.
930 @item -m @var{machine}
931 @itemx --architecture=@var{machine}
933 Specify that the object files @var{objfile} are for architecture
934 @var{machine}. You can list available architectures using the @samp{-i}
939 @cindex relocation entries, in object file
940 Print the relocation entries of the file.
943 @itemx --full-contents
944 @cindex sections, full contents
945 @cindex object file sections
946 Display the full contents of any sections requested.
951 @cindex debug symbols
952 @cindex ELF object file format
953 Display the full contents of any sections requested. Display the
954 contents of the .stab and .stab.index and .stab.excl sections from an
955 ELF file. This is only useful on systems (such as Solaris 2.0) in which
956 @code{.stab} debugging symbol-table entries are carried in an ELF
957 section. In most other file formats, debugging symbol-table entries are
958 interleaved with linkage symbols, and are visible in the @samp{--syms}
963 @cindex symbol table entries, printing
964 Print the symbol table entries of the file.
965 This is similar to the information provided by the @samp{nm} program.
968 Print the version number of @code{objdump} and exit.
972 @cindex all header information, object file
973 @cindex header information, all
974 Display all available header information, including the symbol table and
975 relocation entries. Using @samp{-x} is equivalent to specifying all of
976 @samp{-a -f -h -r -t}.
983 @cindex archive contents
987 ranlib [-vV] @var{archive}
990 @code{ranlib} generates an index to the contents of an archive and
991 stores it in the archive. The index lists each symbol defined by a
992 member of an archive that is a relocatable object file.
994 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
996 An archive with such an index speeds up linking to the library and
997 allows routines in the library to call each other without regard to
998 their placement in the archive.
1000 The GNU @code{ranlib} program is another form of GNU @code{ar}; running
1001 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
1007 Show the version number of @code{ranlib}.
1014 @cindex section sizes
1017 size [ -A | -B | --format=@var{compatibility} ]
1018 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
1019 [ --target=@var{bfdname} ] [ -V | --version ]
1020 @var{objfile}@dots{}
1023 The GNU @code{size} utility lists the section sizes---and the total
1024 size---for each of the object or archive files @var{objfile} in its
1025 argument list. By default, one line of output is generated for each
1026 object file or each module in an archive.
1028 @var{objfile}@dots{} are the object files to be examined.
1030 The command line options have the following meanings:
1035 @itemx --format=@var{compatibility}
1036 @cindex @code{size} display format
1037 Using one of these options, you can choose whether the output from GNU
1038 @code{size} resembles output from System V @code{size} (using @samp{-A},
1039 or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
1040 @samp{--format=berkeley}). The default is the one-line format similar to
1042 @c Bonus for doc-source readers: you can also say --format=strange (or
1043 @c anything else that starts with 's') for sysv, and --format=boring (or
1044 @c anything else that starts with 'b') for Berkeley.
1046 Here is an example of the Berkeley (default) format of output from
1049 size --format=Berkeley ranlib size
1050 text data bss dec hex filename
1051 294880 81920 11592 388392 5ed28 ranlib
1052 294880 81920 11888 388688 5ee50 size
1056 This is the same data, but displayed closer to System V conventions:
1059 size --format=SysV ranlib size
1077 Show a summary of acceptable arguments and options.
1082 @itemx --radix=@var{number}
1083 @cindex @code{size} number format
1084 @cindex radix for section sizes
1085 Using one of these options, you can control whether the size of each
1086 section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1087 (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1088 @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
1089 values (8, 10, 16) are supported. The total size is always given in two
1090 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1091 octal and hexadecimal if you're using @samp{-o}.
1093 @item --target=@var{bfdname}
1094 @cindex object code format
1095 Specify that the object-code format for @var{objfile} is
1096 @var{bfdname}. This option may not be necessary; @code{size} can
1097 automatically recognize many formats.
1098 @xref{Target Selection}, for more information.
1102 Display the version number of @code{size}.
1108 @cindex listings strings
1109 @cindex printing strings
1110 @cindex strings, printing
1113 strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-]
1114 [--all] [--print-file-name] [--bytes=@var{min-len}]
1115 [--radix=@var{radix}] [--target=@var{bfdname}]
1116 [--help] [--version] @var{file}@dots{}
1119 For each @var{file} given, GNU @code{strings} prints the printable
1120 character sequences that are at least 4 characters long (or the number
1121 given with the options below) and are followed by a NUL or newline
1122 character. By default, it only prints the strings from the initialized
1123 data sections of object files; for other types of files, it prints the
1124 strings from the whole file.
1126 @code{strings} is mainly useful for determining the contents of non-text
1133 Do not scan only the initialized data section of object files; scan
1137 @itemx --print-file-name
1138 Print the name of the file before each string.
1141 Print a summary of the program usage on the standard output and exit.
1143 @itemx -@var{min-len}
1144 @item -n @var{min-len}
1145 @itemx --bytes=@var{min-len}
1146 Print sequences of characters that are at least @var{min-len} characters
1147 long, instead of the default 4.
1150 Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o}
1151 act like @samp{-t d} instead. Since we can not be compatible with both
1152 ways, we simply chose one.
1154 @item -t @var{radix}
1155 @itemx --radix=@var{radix}
1156 Print the offset within the file before each string. The single
1157 character argument specifies the radix of the offset---@samp{o} for
1158 octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1160 @item --target=@var{bfdname}
1161 @cindex object code format
1162 Specify an object code format other than your system's default format.
1163 @xref{Target Selection}, for more information.
1167 Print the program version number on the standard output and exit.
1174 @cindex removing symbols
1175 @cindex discarding symbols
1176 @cindex symbols, discarding
1179 strip [ -F @var{bfdname} | --target=@var{bfdname} | --target=@var{bfdname} ]
1180 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1181 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
1182 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
1183 [ -x | --discard-all ] [ -X | --discard-locals ]
1184 [ -v | --verbose ] [ -V | --version ] [ --help ]
1185 @var{objfile}@dots{}
1188 GNU @code{strip} discards all symbols from object files
1189 @var{objfile}. The list of object files may include archives.
1190 At least one object file must be given.
1192 @code{strip} modifies the files named in its argument,
1193 rather than writing modified copies under different names.
1196 @item -F @var{bfdname}
1197 @itemx --target=@var{bfdname}
1198 Treat the original @var{objfile} as a file with the object
1199 code format @var{bfdname}, and rewrite it in the same format.
1200 @xref{Target Selection}, for more information.
1203 Show a summary of the options to @code{strip} and exit.
1205 @item -I @var{bfdname}
1206 @itemx --input-target=@var{bfdname}
1207 Treat the original @var{objfile} as a file with the object
1208 code format @var{bfdname}.
1209 @xref{Target Selection}, for more information.
1211 @item -O @var{bfdname}
1212 @itemx --output-target=@var{bfdname}
1213 Replace @var{objfile} with a file in the output format @var{bfdname}.
1214 @xref{Target Selection}, for more information.
1222 @itemx --strip-debug
1223 Remove debugging symbols only.
1226 @itemx --discard-all
1227 Remove non-global symbols.
1230 @itemx --discard-locals
1231 Remove compiler-generated local symbols.
1232 (These usually start with @samp{L} or @samp{.}.)
1236 Show the version number for @code{strip}.
1240 Verbose output: list all object files modified. In the case of
1241 archives, @samp{strip -v} lists all members of the archive.
1248 @cindex demangling C++ symbols
1251 c++filt [ -_ | --strip-underscores ]
1252 [ -s @var{format} | --format=@var{format} ]
1253 [ --help ] [ --version ] [ @var{symbol}@dots{} ]
1256 The C++ language provides function overloading, which means that you can
1257 write many functions with the same name (providing each takes parameters
1258 of different types). All C++ function names are encoded into a
1259 low-level assembly label (this process is known as
1260 @dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1261 decodes (@dfn{demangles}) low-level names into user-level names so that
1262 the linker can keep these overloaded functions from clashing.
1264 Every alphanumeric word (consisting of letters, digits, underscores,
1265 dollars, or periods) seen in the input is a potential label. If the
1266 label decodes into a C++ name, the C++ name replaces the low-level
1269 You can use @code{c++filt} to decipher individual symbols:
1272 c++filt @var{symbol}
1275 If no @var{symbol} arguments are given, @code{c++filt} reads symbol
1276 names from the standard input and writes the demangled names to the
1277 standard output. All results are printed on the standard output.
1281 @itemx --strip-underscores
1282 On some systems, both the C and C++ compilers put an underscore in front
1283 of every name. For example, the C name @code{foo} gets the low-level
1284 name @code{_foo}. This option removes the initial underscore.
1286 @item -s @var{format}
1287 @itemx --format=@var{format}
1288 GNU @code{nm} can decode three different methods of mangling, used by
1289 different C++ compilers. The argument to this option selects which
1294 the one used by the GNU compiler (the default method)
1296 the one used by the Lucid compiler
1298 the one specified by the C++ Annotated Reference Manual
1302 Print a summary of the options to @code{c++filt} and exit.
1305 Print the version number of @code{c++filt} and exit.
1309 @emph{Warning:} @code{c++filt} is a new utility, and the details of its
1310 user interface are subject to change in future releases. In particular,
1311 a command-line option may be required in the the future to decode a name
1312 passed as an argument on the command line; in other words,
1315 c++filt @var{symbol}
1319 may in a future release become
1322 c++filt @var{option} @var{symbol}
1329 @code{nlmconv} converts a relocatable object file into a NetWare
1333 @code{nlmconv} currently works with @samp{i386} object
1334 files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC}
1335 object files in @sc{elf}, or @code{a.out} format@footnote{
1336 @code{nlmconv} should work with any @samp{i386} or @sc{sparc} object
1337 format in the Binary File Descriptor library. It has only been tested
1338 with the above formats.}.
1342 @emph{Warning:} @code{nlmconv} is not always built as part of the binary
1343 utilities, since it is only useful for NLM targets.
1347 nlmconv [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1348 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
1349 [ -T @var{headerfile} | --header-file=@var{headerfile} ]
1350 [ -h | --help ] [ -V | --version ]
1351 @var{infile} @var{outfile}
1354 @code{nlmconv} converts the relocatable @samp{i386} object file
1355 @var{infile} into the NetWare Loadable Module @var{outfile}, optionally
1356 reading @var{headerfile} for NLM header information. For instructions
1357 on writing the NLM command file language used in header files, see the
1358 @samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM
1359 Development and Tools Overview}, which is part of the NLM Software
1360 Developer's Kit (``NLM SDK''), available from Novell, Inc.
1361 @code{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read
1362 @var{infile}; see @ref{BFD,,BFD,ld.info,Using LD}, for
1366 @item -I @var{bfdname}
1367 @itemx --input-target=@var{bfdname}
1368 Object format of the input file. @code{nlmconv} can usually determine
1369 the format of a given file (so no default is necessary).
1370 @xref{Target Selection}, for more information.
1372 @item -O @var{bfdname}
1373 @itemx --output-target=@var{bfdname}
1374 Object format of the output file. @code{nlmconv} infers the output
1375 format based on the input format, e.g. for a @samp{i386} input file the
1376 output format is @samp{nlm32-i386}.
1377 @xref{Target Selection}, for more information.
1379 @item -T @var{headerfile}
1380 @itemx --header-file=@var{headerfile}
1381 Reads @var{headerfile} for NLM header information. For instructions on
1382 writing the NLM command file language used in header files, see@ see the
1383 @samp{linkers} section, of the @cite{NLM Development and Tools
1384 Overview}, which is part of the NLM Software Developer's Kit, available
1389 Prints a usage summary.
1393 Prints the version number for @code{nlmconv}.
1396 @node Selecting The Target System
1397 @chapter Selecting the target system
1399 You can specify three aspects of the target system to the @sc{gnu}
1400 binary file utilities, each in several ways:
1410 the linker emulation (which applies to the linker only)
1413 In the following summaries, the lists of ways to specify values are in
1414 order of decreasing precedence. The ways listed first override those
1417 The commands to list valid values only list the values for which the
1418 programs you are running were configured. If they were configured with
1419 @samp{--with-targets=all}, the commands list most of the available
1420 values, but a few are left out; not all targets can be configured in at
1421 once because some of them can only be configured @dfn{native} (on hosts
1422 with the same type as the target system).
1425 * Target Selection::
1426 * Architecture Selection::
1427 * Linker Emulation Selection::
1430 @node Target Selection
1431 @section Target Selection
1433 A @dfn{target} is an object file format. A given target may be
1434 supported for multiple architectures (@pxref{Architecture Selection}).
1435 A target selection may also have variations for different operating
1436 systems or architectures.
1438 The command to list valid target values is @samp{objdump -i}
1439 (the first column of output contains the relevant information).
1441 Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips},
1442 @samp{a.out-sunos-big}.
1444 @subheading @code{objdump} Target
1450 command line option: @samp{-b} or @samp{--target}
1453 environment variable @code{GNUTARGET}
1456 deduced from the input file
1459 @subheading @code{objcopy} and @code{strip} Input Target
1465 command line options: @samp{-I} or @samp{--input-target}, or @samp{-F} or @samp{--target}
1468 environment variable @code{GNUTARGET}
1471 deduced from the input file
1474 @subheading @code{objcopy} and @code{strip} Output Target
1480 command line options: @samp{-O} or @samp{--output-target}, or @samp{-F} or @samp{--target}
1483 the input target (see ``@code{objcopy} and @code{strip} Input Target'' above)
1486 environment variable @code{GNUTARGET}
1489 deduced from the input file
1492 @subheading @code{nm}, @code{size}, and @code{strings} Target
1498 command line option: @samp{--target}
1501 environment variable @code{GNUTARGET}
1504 deduced from the input file
1507 @subheading Linker Input Target
1513 command line option: @samp{-b} or @samp{--format}
1514 (@pxref{Options,,Options,ld.info,Using LD})
1517 script command @code{TARGET}
1518 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
1521 environment variable @code{GNUTARGET}
1522 (@pxref{Environment,,Environment,ld.info,Using LD})
1525 the default target of the selected linker emulation
1526 (@pxref{Linker Emulation Selection})
1529 @subheading Linker Output Target
1535 command line option: @samp{-oformat}
1536 (@pxref{Options,,Options,ld.info,Using LD})
1539 script command @code{OUTPUT_FORMAT}
1540 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
1543 the linker input target (see ``Linker Input Target'' above)
1546 @node Architecture Selection
1547 @section Architecture selection
1549 An @dfn{architecture} is a type of @sc{cpu} on which an object file is
1550 to run. Its name may contain a colon, separating the name of the
1551 processor family from the name of the particular @sc{cpu}.
1553 The command to list valid architecture values is @samp{objdump -i} (the
1554 second column contains the relevant information).
1556 Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}.
1558 @subheading @code{objdump} Architecture
1564 command line option: @samp{-m} or @samp{--architecture}
1567 deduced from the input file
1570 @subheading @code{objcopy}, @code{nm}, @code{size}, @code{strings} Architecture
1576 deduced from the input file
1579 @subheading Linker Input Architecture
1585 deduced from the input file
1588 @subheading Linker Output Architecture
1594 script command @code{OUTPUT_ARCH}
1595 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
1598 the default architecture from the linker output target
1599 (@pxref{Target Selection})
1602 @node Linker Emulation Selection
1603 @section Linker emulation selection
1605 A linker @dfn{emulation} is a ``personality'' of the linker, which gives
1606 the linker default values for the other aspects of the target system.
1607 In particular, it consists of
1617 several ``hook'' functions that are run at certain stages of the linking
1618 process to do special things that some targets require
1621 The command to list valid linker emulation values is @samp{ld -V}.
1623 Sample values: @samp{hp300bsd}, @samp{mipslit}, @samp{sun4}.
1629 command line option: @samp{-m}
1630 (@pxref{Options,,Options,ld.info,Using LD})
1633 environment variable @code{LDEMULATION}
1636 compiled-in @code{DEFAULT_EMULATION} from @file{Makefile},
1637 which comes from @code{EMUL} in @file{config/@var{target}.mt}