1 \input texinfo @c -*- Texinfo -*-
2 @setfilename binutils.info
7 * Binutils:: The GNU binary utilities "ar", "ld", "objcopy",
8 "objdump", "nm", "size", "strings", "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", "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
54 @title The GNU Binary Utilities
58 @author Roland H. Pesch
59 @author Jeffrey M. Osier
60 @author Cygnus Support
64 {\parskip=0pt \hfill Cygnus Support\par \hfill
65 \TeX{}info \texinfoversion\par }
68 @vskip 0pt plus 1filll
69 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
71 Permission is granted to make and distribute verbatim copies of
72 this manual provided the copyright notice and this permission notice
73 are preserved on all copies.
75 Permission is granted to copy and distribute modified versions of this
76 manual under the conditions for verbatim copying, provided also that
77 the entire resulting derived work is distributed under the terms of a
78 permission notice identical to this one.
80 Permission is granted to copy and distribute translations of this manual
81 into another language, under the above conditions for modified versions.
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 List symbols from object files
101 Copy and translate object files
104 Display information from object files
107 Generate index to archive contents
110 List file section sizes and total size
113 List printable strings from files
119 Demangle encoded C++ symbols
122 Convert object code into a Netware Loadable Module
127 * ar:: Create, modify, and extract from archives
128 * nm:: List symbols from object files
129 * objcopy:: Copy and translate object files
130 * objdump:: Display information from object files
131 * ranlib:: Generate index to archive contents
132 * size:: List section sizes and total size
133 * strings:: List printable strings from files
134 * strip:: Discard symbols
135 * c++filt:: Filter to demangle encoded C++ symbols
136 * nlmconv:: Converts object code into an NLM
137 * Selecting The Target System:: How these utilities determine the target.
146 @cindex collections of files
148 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
149 ar -M [ <mri-script ]
152 The GNU @code{ar} program creates, modifies, and extracts from
153 archives. An @dfn{archive} is a single file holding a collection of
154 other files in a structure that makes it possible to retrieve
155 the original individual files (called @dfn{members} of the archive).
157 The original files' contents, mode (permissions), timestamp, owner, and
158 group are preserved in the archive, and can be restored on
162 GNU @code{ar} can maintain archives whose members have names of any
163 length; however, depending on how @code{ar} is configured on your
164 system, a limit on member-name length may be imposed for compatibility
165 with archive formats maintained with other tools. If it exists, the
166 limit is often 15 characters (typical of formats related to a.out) or 16
167 characters (typical of formats related to coff).
170 @code{ar} is considered a binary utility because archives of this sort
171 are most often used as @dfn{libraries} holding commonly needed
175 @code{ar} creates an index to the symbols defined in relocatable
176 object modules in the archive when you specify the modifier @samp{s}.
177 Once created, this index is updated in the archive whenever @code{ar}
178 makes a change to its contents (save for the @samp{q} update operation).
179 An archive with such an index speeds up linking to the library, and
180 allows routines in the library to call each other without regard to
181 their placement in the archive.
183 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
184 table. If an archive lacks the table, another form of @code{ar} called
185 @code{ranlib} can be used to add just the table.
187 @cindex compatibility, @code{ar}
188 @cindex @code{ar} compatibility
189 GNU @code{ar} is designed to be compatible with two different
190 facilities. You can control its activity using command-line options,
191 like the different varieties of @code{ar} on Unix systems; or, if you
192 specify the single command-line option @samp{-M}, you can control it
193 with a script supplied via standard input, like the MRI ``librarian''
197 * ar cmdline:: Controlling @code{ar} on the command line
198 * ar scripts:: Controlling @code{ar} with a script
203 @section Controlling @code{ar} on the command line
206 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
209 @cindex Unix compatibility, @code{ar}
210 When you use @code{ar} in the Unix style, @code{ar} insists on at least two
211 arguments to execute: one keyletter specifying the @emph{operation}
212 (optionally accompanied by other keyletters specifying
213 @emph{modifiers}), and the archive name to act on.
215 Most operations can also accept further @var{member} arguments,
216 specifying particular files to operate on.
218 GNU @code{ar} allows you to mix the operation code @var{p} and modifier
219 flags @var{mod} in any order, within the first command-line argument.
221 If you wish, you may begin the first command-line argument with a
224 @cindex operations on archive
225 The @var{p} keyletter specifies what operation to execute; it may be
226 any of the following, but you must specify only one of them:
230 @cindex deleting from archive
231 @emph{Delete} modules from the archive. Specify the names of modules to
232 be deleted as @var{member}@dots{}; the archive is untouched if you
233 specify no files to delete.
235 If you specify the @samp{v} modifier, @code{ar} lists each module
239 @cindex moving in archive
240 Use this operation to @emph{move} members in an archive.
242 The ordering of members in an archive can make a difference in how
243 programs are linked using the library, if a symbol is defined in more
246 If no modifiers are used with @code{m}, any members you name in the
247 @var{member} arguments are moved to the @emph{end} of the archive;
248 you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
249 specified place instead.
252 @cindex printing from archive
253 @emph{Print} the specified members of the archive, to the standard
254 output file. If the @samp{v} modifier is specified, show the member
255 name before copying its contents to standard output.
257 If you specify no @var{member} arguments, all the files in the archive are
261 @cindex quick append to archive
262 @emph{Quick append}; add the files @var{member}@dots{} to the end of
263 @var{archive}, without checking for replacement.
265 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
266 operation; new members are always placed at the end of the archive.
268 The modifier @samp{v} makes @code{ar} list each file as it is appended.
270 Since the point of this operation is speed, the archive's symbol table
271 index is not updated, even if it already existed; you can use @samp{ar s} or
272 @code{ranlib} explicitly to update the symbol table index.
275 @cindex replacement in archive
276 Insert the files @var{member}@dots{} into @var{archive} (with
277 @emph{replacement}). This operation differs from @samp{q} in that any
278 previously existing members are deleted if their names match those being
281 If one of the files named in @var{member}@dots{} does not exist, @code{ar}
282 displays an error message, and leaves undisturbed any existing members
283 of the archive matching that name.
285 By default, new members are added at the end of the file; but you may
286 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
287 placement relative to some existing member.
289 The modifier @samp{v} used with this operation elicits a line of
290 output for each file inserted, along with one of the letters @samp{a} or
291 @samp{r} to indicate whether the file was appended (no old member
292 deleted) or replaced.
295 @cindex contents of archive
296 Display a @emph{table} listing the contents of @var{archive}, or those
297 of the files listed in @var{member}@dots{} that are present in the
298 archive. Normally only the member name is shown; if you also want to
299 see the modes (permissions), timestamp, owner, group, and size, you can
300 request that by also specifying the @samp{v} modifier.
302 If you do not specify a @var{member}, all files in the archive
305 @cindex repeated names in archive
306 @cindex name duplication in archive
307 If there is more than one file with the same name (say, @samp{fie}) in
308 an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
309 first instance; to see them all, you must ask for a complete
310 listing---in our example, @samp{ar t b.a}.
311 @c WRS only; per Gumby, this is implementation-dependent, and in a more
312 @c recent case in fact works the other way.
315 @cindex extract from archive
316 @emph{Extract} members (named @var{member}) from the archive. You can
317 use the @samp{v} modifier with this operation, to request that
318 @code{ar} list each name as it extracts it.
320 If you do not specify a @var{member}, all files in the archive
325 A number of modifiers (@var{mod}) may immediately follow the @var{p}
326 keyletter, to specify variations on an operation's behavior:
330 @cindex relative placement in archive
331 Add new files @emph{after} an existing member of the
332 archive. If you use the modifier @samp{a}, the name of an existing archive
333 member must be present as the @var{relpos} argument, before the
334 @var{archive} specification.
337 Add new files @emph{before} an existing member of the
338 archive. If you use the modifier @samp{b}, the name of an existing archive
339 member must be present as the @var{relpos} argument, before the
340 @var{archive} specification. (same as @samp{i}).
343 @cindex creating archives
344 @emph{Create} the archive. The specified @var{archive} is always
345 created if it did not exist, when you request an update. But a warning is
346 issued unless you specify in advance that you expect to create it, by
350 Insert new files @emph{before} an existing member of the
351 archive. If you use the modifier @samp{i}, the name of an existing archive
352 member must be present as the @var{relpos} argument, before the
353 @var{archive} specification. (same as @samp{b}).
356 This modifier is accepted but not used.
357 @c whaffor ar l modifier??? presumably compat; with
358 @c what???---pesch@@cygnus.com, 25jan91
361 @cindex dates in archive
362 Preserve the @emph{original} dates of members when extracting them. If
363 you do not specify this modifier, files extracted from the archive
364 are stamped with the time of extraction.
367 @cindex writing archive index
368 Write an object-file index into the archive, or update an existing one,
369 even if no other change is made to the archive. You may use this modifier
370 flag either with any operation, or alone. Running @samp{ar s} on an
371 archive is equivalent to running @samp{ranlib} on it.
374 @cindex updating an archive
375 Normally, @samp{ar r}@dots{} inserts all files
376 listed into the archive. If you would like to insert @emph{only} those
377 of the files you list that are newer than existing members of the same
378 names, use this modifier. The @samp{u} modifier is allowed only for the
379 operation @samp{r} (replace). In particular, the combination @samp{qu} is
380 not allowed, since checking the timestamps would lose any speed
381 advantage from the operation @samp{q}.
384 This modifier requests the @emph{verbose} version of an operation. Many
385 operations display additional information, such as filenames processed,
386 when the modifier @samp{v} is appended.
389 This modifier shows the version number of @code{ar}.
393 @section Controlling @code{ar} with a script
396 ar -M [ <@var{script} ]
399 @cindex MRI compatibility, @code{ar}
400 @cindex scripts, @code{ar}
401 If you use the single command-line option @samp{-M} with @code{ar}, you
402 can control its operation with a rudimentary command language. This
403 form of @code{ar} operates interactively if standard input is coming
404 directly from a terminal. During interactive use, @code{ar} prompts for
405 input (the prompt is @samp{AR >}), and continues executing even after
406 errors. If you redirect standard input to a script file, no prompts are
407 issued, and @code{ar} abandons execution (with a nonzero exit code)
410 The @code{ar} command language is @emph{not} designed to be equivalent
411 to the command-line options; in fact, it provides somewhat less control
412 over archives. The only purpose of the command language is to ease the
413 transition to GNU @code{ar} for developers who already have scripts
414 written for the MRI ``librarian'' program.
416 The syntax for the @code{ar} command language is straightforward:
419 commands are recognized in upper or lower case; for example, @code{LIST}
420 is the same as @code{list}. In the following descriptions, commands are
421 shown in upper case for clarity.
424 a single command may appear on each line; it is the first word on the
428 empty lines are allowed, and have no effect.
431 comments are allowed; text after either of the characters @samp{*}
432 or @samp{;} is ignored.
435 Whenever you use a list of names as part of the argument to an @code{ar}
436 command, you can separate the individual names with either commas or
437 blanks. Commas are shown in the explanations below, for clarity.
440 @samp{+} is used as a line continuation character; if @samp{+} appears
441 at the end of a line, the text on the following line is considered part
442 of the current command.
445 Here are the commands you can use in @code{ar} scripts, or when using
446 @code{ar} interactively. Three of them have special significance:
448 @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
449 a temporary file required for most of the other commands.
451 @code{SAVE} commits the changes so far specified by the script. Prior
452 to @code{SAVE}, commands affect only the temporary copy of the current
456 @item ADDLIB @var{archive}
457 @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
458 Add all the contents of @var{archive} (or, if specified, each named
459 @var{module} from @var{archive}) to the current archive.
461 Requires prior use of @code{OPEN} or @code{CREATE}.
463 @item ADDMOD @var{member}, @var{member}, @dots{} @var{member}
464 @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
465 @c else like "ar q..."
466 Add each named @var{member} as a module in the current archive.
468 Requires prior use of @code{OPEN} or @code{CREATE}.
471 Discard the contents of the current archive, cancelling the effect of
472 any operations since the last @code{SAVE}. May be executed (with no
473 effect) even if no current archive is specified.
475 @item CREATE @var{archive}
476 Creates an archive, and makes it the current archive (required for many
477 other commands). The new archive is created with a temporary name; it
478 is not actually saved as @var{archive} until you use @code{SAVE}.
479 You can overwrite existing archives; similarly, the contents of any
480 existing file named @var{archive} will not be destroyed until @code{SAVE}.
482 @item DELETE @var{module}, @var{module}, @dots{} @var{module}
483 Delete each listed @var{module} from the current archive; equivalent to
484 @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
486 Requires prior use of @code{OPEN} or @code{CREATE}.
488 @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
489 @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
490 List each named @var{module} present in @var{archive}. The separate
491 command @code{VERBOSE} specifies the form of the output: when verbose
492 output is off, output is like that of @samp{ar -t @var{archive}
493 @var{module}@dots{}}. When verbose output is on, the listing is like
494 @samp{ar -tv @var{archive} @var{module}@dots{}}.
496 Output normally goes to the standard output stream; however, if you
497 specify @var{outputfile} as a final argument, @code{ar} directs the
501 Exit from @code{ar}, with a @code{0} exit code to indicate successful
502 completion. This command does not save the output file; if you have
503 changed the current archive since the last @code{SAVE} command, those
506 @item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
507 Extract each named @var{module} from the current archive, writing them
508 into the current directory as separate files. Equivalent to @samp{ar -x
509 @var{archive} @var{module}@dots{}}.
511 Requires prior use of @code{OPEN} or @code{CREATE}.
514 @c FIXME Tokens but no commands???
521 Display full contents of the current archive, in ``verbose'' style
522 regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
523 tv @var{archive}}). (This single command is a GNU @code{ld}
524 enhancement, rather than present for MRI compatibility.)
526 Requires prior use of @code{OPEN} or @code{CREATE}.
528 @item OPEN @var{archive}
529 Opens an existing archive for use as the current archive (required for
530 many other commands). Any changes as the result of subsequent commands
531 will not actually affect @var{archive} until you next use @code{SAVE}.
533 @item REPLACE @var{module}, @var{module}, @dots{} @var{module}
534 In the current archive, replace each existing @var{module} (named in
535 the @code{REPLACE} arguments) from files in the current working directory.
536 To execute this command without errors, both the file, and the module in
537 the current archive, must exist.
539 Requires prior use of @code{OPEN} or @code{CREATE}.
542 Toggle an internal flag governing the output from @code{DIRECTORY}.
543 When the flag is on, @code{DIRECTORY} output matches output from
544 @samp{ar -tv }@dots{}.
547 Commit your changes to the current archive, and actually save it as a
548 file with the name specified in the last @code{CREATE} or @code{OPEN}
551 Requires prior use of @code{OPEN} or @code{CREATE}.
560 The GNU linker @code{ld} is now described in a separate manual.
561 @xref{Top,, Overview,, Using LD: the GNU linker}.
570 nm [ -a | --debug-syms ] [ -g | --extern-only ]
571 [ -B ] [ -C | --demangle ]
572 [ -s | --print-armap ] [ -A | -o | --print-file-name ]
573 [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
574 [ -r | --reverse-sort ] [ -u | --undefined-only ]
575 [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ]
576 [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ]
577 [ -V | --version ] [ --help ] [ @var{objfile}@dots{} ]
580 GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}.
581 If no object files are listed as arguments, @code{nm} assumes
584 For each symbol, @code{nm} shows:
588 The symbol value, in the radix selected by options (see below), or
589 hexadecimal by default.
592 The symbol type. At least the following types are used; others are, as
593 well, depending on the object file format. If lowercase, the symbol is
594 local; if uppercase, the symbol is global (external).
596 @c Some more detail on exactly what these symbol types are used for
603 BSS (uninitialized data).
625 The long and short forms of options, shown here as alternatives, are
631 @itemx --print-file-name
632 @cindex input file name
634 @cindex source file name
635 Precede each symbol by the name of the input file (or archive element)
636 in which it was found, rather than identifying the input file once only,
637 before all of its symbols.
641 @cindex debugging symbols
642 Display all symbols, even debugger-only symbols; normally these are not
646 @cindex @code{nm} format
647 @cindex @code{nm} compatibility
648 The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
652 @cindex demangling C++ symbols
653 Decode (@dfn{demangle}) low-level symbol names into user-level names.
654 Besides removing any initial underscore prepended by the system, this
655 makes C++ function names readable. @xref{c++filt}, for more information
658 @item -f @var{format}
659 @itemx --format=@var{format}
660 @cindex @code{nm} format
661 @cindex @code{nm} compatibility
662 Use the output format @var{format}, which can be @code{bsd},
663 @code{sysv}, or @code{posix}. The default is @code{bsd}.
664 Only the first character of @var{format} is significant; it can be
665 either upper or lower case.
669 @cindex external symbols
670 Display only external symbols.
674 @itemx --numeric-sort
675 Sort symbols numerically by their addresses, rather than alphabetically
680 @cindex sorting symbols
681 Do not bother to sort the symbols in any order; print them in the order
686 Use the POSIX.2 standard output format instead of the default format.
687 Equivalent to @samp{-f posix}.
691 @cindex symbol index, listing
692 When listing symbols from archive members, include the index: a mapping
693 (stored in the archive by @code{ar} or @code{ranlib}) of which modules
694 contain definitions for which names.
697 @itemx --reverse-sort
698 Reverse the order of the sort (whether numeric or alphabetic); let the
702 @itemx --radix=@var{radix}
703 Use @var{radix} as the radix for printing the symbol values. It must be
704 @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
706 @item --target=@var{bfdname}
707 @cindex object code format
708 Specify an object code format other than your system's default format.
709 @xref{Target Selection}, for more information.
712 @itemx --undefined-only
713 @cindex external symbols
714 @cindex undefined symbols
715 Display only undefined symbols (those external to each object file).
719 Show the version number of @code{nm} and exit.
722 Show a summary of the options to @code{nm} and exit.
729 objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
730 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
731 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
732 [ -S | --strip-all ] [ -g | --strip-debug ]
733 [ -x | --discard-all ] [ -X | --discard-locals ]
734 [ -v | --verbose ] [ -V | --version ] [ --help ]
735 @var{infile} [@var{outfile}]
738 The GNU @code{objcopy} utility copies the contents of an object file to
739 another. @code{objcopy} uses the GNU BFD Library to read and write the
740 object files. It can write the destination object file in a format
741 different from that of the source object file. The exact behavior of
742 @code{objcopy} is controlled by command-line options.
744 @code{objcopy} creates temporary files to do its translations and
745 deletes them afterward. @code{objcopy} uses BFD to do all its
746 translation work; it knows about all the formats BFD knows about, and
747 thus is able to recognize most formats without being told explicitly.
748 @xref{BFD,,BFD,ld.info,Using LD}.
753 The source and output files respectively.
754 If you do not specify @var{outfile}, @code{objcopy} creates a
755 temporary file and destructively renames the result with
756 the name of the input file.
758 @item -I @var{bfdname}
759 @itemx --input-target=@var{bfdname}
760 Consider the source file's object format to be @var{bfdname}, rather than
761 attempting to deduce it. @xref{Target Selection}, for more information.
763 @item -O @var{bfdname}
764 @itemx --output-target=@var{bfdname}
765 Write the output file using the object format @var{bfdname}.
766 @xref{Target Selection}, for more information.
768 @item -F @var{bfdname}
769 @itemx --target=@var{bfdname}
770 Use @var{bfdname} as the object format for both the input and the output
771 file; i.e., simply transfer data from source to destination with no
772 translation. @xref{Target Selection}, for more information.
776 Do not copy relocation and symbol information from the source file.
780 Do not copy debugging symbols from the source file.
784 Do not copy non-global symbols from the source file.
785 @c FIXME any reason to prefer "non-global" to "local" here?
788 @itemx --discard-locals
789 Do not copy compiler-generated local symbols.
790 (These usually start with @samp{L} or @samp{.}.)
794 Show the version number of @code{objcopy}.
798 Verbose output: list all object files modified. In the case of
799 archives, @samp{objcopy -V} lists all members of the archive.
802 Show a summary of the options to @code{objcopy}.
808 @cindex object file information
812 objdump [ -a | --archive-headers ] [ -b @var{bfdname} | --target=@var{bfdname} ]
813 [ -d | --disassemble ] [ -f | --file-headers ]
814 [ -h | --section-headers | --headers ] [ -i | --info ]
815 [ -j @var{section} | --section=@var{section} ] [ -l | --line-numbers ]
816 [ -m @var{machine} | --architecture=@var{machine} ] [ -r | --reloc ]
817 [ -s | --full-contents ] [ --stabs ] [ -t | --syms ]
818 [ -x | --all-headers ] [ --version ] [ --help ]
822 @code{objdump} displays information about one or more object files.
823 The options control what particular information to display. This
824 information is mostly useful to programmers who are working on the
825 compilation tools, as opposed to programmers who just want their
826 program to compile and work.
828 @var{objfile}@dots{} are the object files to be examined. When you
829 specify archives, @code{objdump} shows information on each of the member
832 The long and short forms of options, shown here as alternatives, are
833 equivalent. At least one option besides @samp{-l} must be given.
837 @itemx --archive-header
838 @cindex archive headers
839 If any of the @var{objfile} files are archives, display the archive
840 header information (in a format similar to @samp{ls -l}). Besides the
841 information you could list with @samp{ar tv}, @samp{objdump -a} shows
842 the object file format of each archive member.
844 @item -b @var{bfdname}
845 @itemx --target=@var{bfdname}
846 @cindex object code format
847 Specify that the object-code format for the object files is
848 @var{bfdname}. This option may not be necessary; @var{objdump} can
849 automatically recognize many formats.
853 objdump -b oasys -m vax -h fu.o
856 displays summary information from the section headers (@samp{-h}) of
857 @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
858 file in the format produced by Oasys compilers. You can list the
859 formats available with the @samp{-i} option.
860 @xref{Target Selection}, for more information.
864 @cindex disassembling object code
865 @cindex machine instructions
866 Display the assembler mnemonics for the machine
867 instructions from @var{objfile}.
871 @cindex object file header
872 Display summary information from the overall header of
873 each of the @var{objfile} files.
876 @itemx --section-header
878 @cindex section headers
879 Display summary information from the section headers of the
883 Print a summary of the options to @code{objdump} and exit.
887 @cindex architectures available
888 @cindex object formats available
889 Display a list showing all architectures and object formats available
890 for specification with @samp{-b} or @samp{-m}.
893 @itemx --section=@var{name}
894 @cindex section information
895 Display information only for section @var{name}.
898 @itemx --line-numbers
899 @cindex source filenames for object files
900 Label the display (using debugging information) with the filename
901 and source line numbers corresponding to the object code shown.
902 Only useful with @samp{-d}.
904 @item -m @var{machine}
905 @itemx --architecture=@var{machine}
907 Specify that the object files @var{objfile} are for architecture
908 @var{machine}. You can list available architectures using the @samp{-i}
913 @cindex relocation entries, in object file
914 Print the relocation entries of the file.
917 @itemx --full-contents
918 @cindex sections, full contents
919 @cindex object file sections
920 Display the full contents of any sections requested.
925 @cindex debug symbols
926 @cindex ELF object file format
927 Display the full contents of any sections requested. Display the
928 contents of the .stab and .stab.index and .stab.excl sections from an
929 ELF file. This is only useful on systems (such as Solaris 2.0) in which
930 @code{.stab} debugging symbol-table entries are carried in an ELF
931 section. In most other file formats, debugging symbol-table entries are
932 interleaved with linkage symbols, and are visible in the @samp{--syms}
937 @cindex symbol table entries, printing
938 Print the symbol table entries of the file.
939 This is similar to the information provided by the @samp{nm} program.
942 Print the version number of @code{objdump} and exit.
946 @cindex all header information, object file
947 @cindex header information, all
948 Display all available header information, including the symbol table and
949 relocation entries. Using @samp{-x} is equivalent to specifying all of
950 @samp{-a -f -h -r -t}.
957 @cindex archive contents
961 ranlib [-vV] @var{archive}
964 @code{ranlib} generates an index to the contents of an archive and
965 stores it in the archive. The index lists each symbol defined by a
966 member of an archive that is a relocatable object file.
968 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
970 An archive with such an index speeds up linking to the library and
971 allows routines in the library to call each other without regard to
972 their placement in the archive.
974 The GNU @code{ranlib} program is another form of GNU @code{ar}; running
975 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
981 Show the version number of @code{ranlib}.
988 @cindex section sizes
991 size [ -A | -B | --format=@var{compatibility} ]
992 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
993 [ --target=@var{bfdname} ] [ -V | --version ]
997 The GNU @code{size} utility lists the section sizes---and the total
998 size---for each of the object or archive files @var{objfile} in its
999 argument list. By default, one line of output is generated for each
1000 object file or each module in an archive.
1002 @var{objfile}@dots{} are the object files to be examined.
1004 The command line options have the following meanings:
1009 @itemx --format=@var{compatibility}
1010 @cindex @code{size} display format
1011 Using one of these options, you can choose whether the output from GNU
1012 @code{size} resembles output from System V @code{size} (using @samp{-A},
1013 or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
1014 @samp{--format=berkeley}). The default is the one-line format similar to
1016 @c Bonus for doc-source readers: you can also say --format=strange (or
1017 @c anything else that starts with 's') for sysv, and --format=boring (or
1018 @c anything else that starts with 'b') for Berkeley.
1020 Here is an example of the Berkeley (default) format of output from
1023 size --format=Berkeley ranlib size
1024 text data bss dec hex filename
1025 294880 81920 11592 388392 5ed28 ranlib
1026 294880 81920 11888 388688 5ee50 size
1030 This is the same data, but displayed closer to System V conventions:
1033 size --format=SysV ranlib size
1051 Show a summary of acceptable arguments and options.
1056 @itemx --radix=@var{number}
1057 @cindex @code{size} number format
1058 @cindex radix for section sizes
1059 Using one of these options, you can control whether the size of each
1060 section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1061 (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1062 @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
1063 values (8, 10, 16) are supported. The total size is always given in two
1064 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1065 octal and hexadecimal if you're using @samp{-o}.
1067 @item --target=@var{bfdname}
1068 @cindex object code format
1069 Specify that the object-code format for @var{objfile} is
1070 @var{bfdname}. This option may not be necessary; @code{size} can
1071 automatically recognize many formats.
1072 @xref{Target Selection}, for more information.
1076 Display the version number of @code{size}.
1082 @cindex listings strings
1083 @cindex printing strings
1084 @cindex strings, printing
1087 strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-]
1088 [--all] [--print-file-name] [--bytes=@var{min-len}]
1089 [--radix=@var{radix}] [--target=@var{bfdname}]
1090 [--help] [--version] @var{file}@dots{}
1093 For each @var{file} given, GNU @code{strings} prints the printable
1094 character sequences that are at least 4 characters long (or the number
1095 given with the options below) and are followed by a NUL or newline
1096 character. By default, it only prints the strings from the initialized
1097 data sections of object files; for other types of files, it prints the
1098 strings from the whole file.
1100 @code{strings} is mainly useful for determining the contents of non-text
1107 Do not scan only the initialized data section of object files; scan
1111 @itemx --print-file-name
1112 Print the name of the file before each string.
1115 Print a summary of the program usage on the standard output and exit.
1117 @itemx -@var{min-len}
1118 @item -n @var{min-len}
1119 @itemx --bytes=@var{min-len}
1120 Print sequences of characters that are at least @var{min-len} characters
1121 long, instead of the default 4.
1124 Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o}
1125 act like @samp{-t d} instead. Since we can not be compatible with both
1126 ways, we simply chose one.
1128 @item -t @var{radix}
1129 @itemx --radix=@var{radix}
1130 Print the offset within the file before each string. The single
1131 character argument specifies the radix of the offset---@samp{o} for
1132 octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1134 @item --target=@var{bfdname}
1135 @cindex object code format
1136 Specify an object code format other than your system's default format.
1137 @xref{Target Selection}, for more information.
1141 Print the program version number on the standard output and exit.
1148 @cindex removing symbols
1149 @cindex discarding symbols
1150 @cindex symbols, discarding
1153 strip [ -F @var{bfdname} | --target=@var{bfdname} | --target=@var{bfdname} ]
1154 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1155 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
1156 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
1157 [ -x | --discard-all ] [ -X | --discard-locals ]
1158 [ -v | --verbose ] [ -V | --version ] [ --help ]
1159 @var{objfile}@dots{}
1162 GNU @code{strip} discards all symbols from object files
1163 @var{objfile}. The list of object files may include archives.
1164 At least one object file must be given.
1166 @code{strip} modifies the files named in its argument,
1167 rather than writing modified copies under different names.
1170 @item -F @var{bfdname}
1171 @itemx --target=@var{bfdname}
1172 Treat the original @var{objfile} as a file with the object
1173 code format @var{bfdname}, and rewrite it in the same format.
1174 @xref{Target Selection}, for more information.
1177 Show a summary of the options to @code{strip} and exit.
1179 @item -I @var{bfdname}
1180 @itemx --input-target=@var{bfdname}
1181 Treat the original @var{objfile} as a file with the object
1182 code format @var{bfdname}.
1183 @xref{Target Selection}, for more information.
1185 @item -O @var{bfdname}
1186 @itemx --output-target=@var{bfdname}
1187 Replace @var{objfile} with a file in the output format @var{bfdname}.
1188 @xref{Target Selection}, for more information.
1196 @itemx --strip-debug
1197 Remove debugging symbols only.
1200 @itemx --discard-all
1201 Remove non-global symbols.
1204 @itemx --discard-locals
1205 Remove compiler-generated local symbols.
1206 (These usually start with @samp{L} or @samp{.}.)
1210 Show the version number for @code{strip}.
1214 Verbose output: list all object files modified. In the case of
1215 archives, @samp{strip -v} lists all members of the archive.
1222 @cindex demangling C++ symbols
1225 c++filt [ -_ | --strip-underscores ]
1226 [ -s @var{format} | --format=@var{format} ]
1227 [ --help ] [ --version ] [ @var{symbol}@dots{} ]
1230 The C++ language provides function overloading, which means that you can
1231 write many functions with the same name (providing each takes parameters
1232 of different types). All C++ function names are encoded into a
1233 low-level assembly label (this process is known as
1234 @dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1235 decodes (@dfn{demangles}) low-level names into user-level names so that
1236 the linker can keep these overloaded functions from clashing.
1238 Every alphanumeric word (consisting of letters, digits, underscores,
1239 dollars, or periods) seen in the input is a potential label. If the
1240 label decodes into a C++ name, the C++ name replaces the low-level
1243 You can use @code{c++filt} to decipher individual symbols:
1246 c++filt @var{symbol}
1249 If no @var{symbol} arguments are given, @code{c++filt} reads symbol
1250 names from the standard input and writes the demangled names to the
1251 standard output. All results are printed on the standard output.
1255 @itemx --strip-underscores
1256 On some systems, both the C and C++ compilers put an underscore in front
1257 of every name. For example, the C name @code{foo} gets the low-level
1258 name @code{_foo}. This option removes the initial underscore.
1260 @item -s @var{format}
1261 @itemx --format=@var{format}
1262 GNU @code{nm} can decode three different methods of mangling, used by
1263 different C++ compilers. The argument to this option selects which
1268 the one used by the GNU compiler (the default method)
1270 the one used by the Lucid compiler
1272 the one specified by the C++ Annotated Reference Manual
1276 Print a summary of the options to @code{c++filt} and exit.
1279 Print the version number of @code{c++filt} and exit.
1283 @emph{Warning:} @code{c++filt} is a new utility, and the details of its
1284 user interface are subject to change in future releases. In particular,
1285 a command-line option may be required in the the future to decode a name
1286 passed as an argument on the command line; in other words,
1289 c++filt @var{symbol}
1293 may in a future release become
1296 c++filt @var{option} @var{symbol}
1303 @code{nlmconv} converts a relocatable object file into a NetWare
1304 Loadable Module. @code{nlmconv} currently works with @samp{i386} object
1305 files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC}
1306 object files in @sc{elf}, or @code{a.out} format@footnote{
1307 @code{nlmconv} should work with any @samp{i386} or @sc{sparc} object
1308 format in the Binary File Descriptor library. It has only been tested
1309 with the above formats.}.
1312 @emph{Warning:} @code{nlmconv} is not always built as part of the binary
1313 utilities, since it is only useful for NLM targets.
1317 nlmconv [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1318 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
1319 [ -T @var{headerfile} | --header-file=@var{headerfile} ]
1320 [ -h | --help ] [ -V | --version ]
1321 @var{infile} @var{outfile}
1324 @code{nlmconv} converts the relocatable @samp{i386} object file
1325 @var{infile} into the NetWare Loadable Module @var{outfile}, optionally
1326 reading @var{headerfile} for NLM header information. For instructions
1327 on writing the NLM command file language used in header files, see the
1328 @samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM
1329 Development and Tools Overview}, which is part of the NLM Software
1330 Developer's Kit (``NLM SDK''), available from Novell, Inc.
1331 @code{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read
1332 @var{infile}; see @ref{BFD,,BFD,ld.info,Using LD}, for
1336 @item -I @var{bfdname}
1337 @itemx --input-target=@var{bfdname}
1338 Object format of the input file. @code{nlmconv} can usually determine
1339 the format of a given file (so no default is necessary).
1340 @xref{Target Selection}, for more information.
1342 @item -O @var{bfdname}
1343 @itemx --output-target=@var{bfdname}
1344 Object format of the output file. @code{nlmconv} infers the output
1345 format based on the input format, e.g. for a @samp{i386} input file the
1346 output format is @samp{nlm32-i386}.
1347 @xref{Target Selection}, for more information.
1349 @item -T @var{headerfile}
1350 @itemx --header-file=@var{headerfile}
1351 Reads @var{headerfile} for NLM header information. For instructions on
1352 writing the NLM command file language used in header files, see@ see the
1353 @samp{linkers} section, of the @cite{NLM Development and Tools
1354 Overview}, which is part of the NLM Software Developer's Kit, available
1359 Prints a usage summary.
1363 Prints the version number for @code{nlmconv}.
1366 @node Selecting The Target System
1367 @chapter Selecting the target system
1369 You can specify three aspects of the target system to the GNU binary
1370 file utilities, each in several ways. The three aspects of the target
1371 system that you can specify are
1378 the architecture, and
1381 the linker emulation (which applies to the linker only).
1384 In the following summaries, the lists of ways to specify values are in
1385 order of decreasing precedence. In other words, the ways listed earlier
1386 override the ways listed later.
1388 The commands to list valid values only list the values that the programs
1389 you are running were configured for. If they were configured with
1390 @samp{--with-targets=all}, the commands list most of the available
1391 values, but a few are left out; not all targets can be configured in at
1392 once because some of them can only be compiled ``native'' (on hosts with
1393 the same type as the target system).
1396 * Target Selection::
1397 * Architecture Selection::
1398 * Linker Emulation Selection::
1401 @node Target Selection
1402 @section Target selection
1404 A @dfn{target} is an object file format. A given target may be
1405 supported for multiple architectures (@pxref{Architecture Selection}).
1406 It may also have variations for different operating systems or architectures.
1408 Command to list valid values: @samp{objdump -i} (first column).
1410 Sample values: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips}, @samp{a.out-sunos-big}.
1414 * objcopy strip Input Target::
1415 * objcopy strip Output Target::
1416 * nm size strings Target::
1417 * Linker Input Target::
1418 * Linker Output Target::
1421 @node objdump Target
1422 @subsection @code{objdump} target
1428 command line option @samp{-b}, @samp{--target}
1431 environment variable @code{GNUTARGET}
1434 deduced from the input file
1437 @node objcopy strip Input Target
1438 @subsection @code{objcopy} and @code{strip} input target
1444 command line option @samp{-I}, @samp{--input-target}, @samp{-F}, @samp{--target}
1447 environment variable @code{GNUTARGET}
1450 deduced from the input file
1453 @node objcopy strip Output Target
1454 @subsection @code{objcopy} and @code{strip} output target
1460 command line option @samp{-O}, @samp{-F}, @samp{--output-target}, @samp{--target}
1463 the input target (@pxref{objcopy strip Input Target})
1466 environment variable @code{GNUTARGET}
1469 deduced from the input file
1472 @node nm size strings Target
1473 @subsection @code{nm}, @code{size}, and @code{strings} target
1479 command line option @samp{--target}
1482 environment variable @code{GNUTARGET}
1485 deduced from the input file
1488 @node Linker Input Target
1489 @subsection Linker input target
1495 command line option @samp{-b}, @samp{-format}
1496 (@pxref{Options,,Options,ld.info,Using LD})
1499 script command @code{TARGET}
1500 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
1503 environment variable @code{GNUTARGET}
1504 (@pxref{Environment,,Environment,ld.info,Using LD})
1507 the default target of the selected linker emulation
1508 (@pxref{Linker Emulation Selection})
1511 @node Linker Output Target
1512 @subsection Linker output target
1518 command line option @samp{-oformat}
1519 (@pxref{Options,,Options,ld.info,Using LD})
1522 script command @code{OUTPUT_FORMAT}
1523 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
1526 the linker input target (@pxref{Linker Input Target})
1529 @node Architecture Selection
1530 @section Architecture selection
1532 An @dfn{architecture} is a type of CPU on which an object file is to
1533 run. Its name may contain a colon, separating the name of the
1534 processor family from the name of the particular CPU.
1536 Command to list valid values: @samp{objdump -i} (second column).
1538 Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}.
1541 * objdump Architecture::
1542 * objcopy nm size strings Architecture::
1543 * Linker Input Architecture::
1544 * Linker Output Architecture::
1547 @node objdump Architecture
1548 @subsection @code{objdump} architecture
1554 command line option @samp{-m}, @samp{--architecture}
1557 deduced from the input file
1560 @node objcopy nm size strings Architecture
1561 @subsection @code{objcopy}, @code{nm}, @code{size}, @code{strings} architecture
1567 deduced from the input file
1570 @node Linker Input Architecture
1571 @subsection Linker input architecture
1577 deduced from the input file
1580 @node Linker Output Architecture
1581 @subsection Linker output architecture
1587 script command @code{OUTPUT_ARCH}
1588 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
1591 the default architecture from the linker output target
1592 (@pxref{Linker Output Target})
1595 @node Linker Emulation Selection
1596 @section Linker emulation selection
1598 A linker @dfn{emulation} is a ``personality'' of the linker, which gives
1599 the linker default values for the other aspects of the target system.
1600 In particular, it consists of
1610 several ``hook'' functions that are run at certain stages of the linking
1611 process to do special things that some targets require.
1614 Command to list valid values: @samp{ld -V}.
1616 Sample values: @samp{hp300bsd}, @samp{mipslit}, @samp{sun4}.
1622 command line option @samp{-m}
1623 (@pxref{Options,,Options,ld.info,Using LD})
1626 environment variable @code{LDEMULATION}
1629 compiled-in @code{DEFAULT_EMULATION} from @file{Makefile},
1630 which comes from @code{EMUL} in @file{config/@var{target}.mt}