2 @setfilename binutils.info
5 @c This file documents the GNU binary utilities "ar", "ld", "objdump", "nm",
6 @c "size", "strip", and "ranlib".
8 @c Copyright (C) 1991 Free Software Foundation, Inc.
10 @c This text may be freely distributed under the terms of the GNU
11 @c General Public License.
19 @setchapternewpage odd
20 @settitle GNU Binary Utilities
22 @title{The GNU Binary Utilities}
23 @subtitle{Version 1.9}
25 @subtitle October 1991
26 @author{Roland H. Pesch}
27 @author{Cygnus Support}
31 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
32 \xdef\manvers{\$Revision$} % For use in headers, footers too
33 {\parskip=0pt \hfill Cygnus Support\par \hfill \manvers\par \hfill
34 \TeX{}info \texinfoversion\par }
37 @vskip 0pt plus 1filll
38 Copyright @copyright{} 1991 Free Software Foundation, Inc.
40 Permission is granted to make and distribute verbatim copies of
41 this manual provided the copyright notice and this permission notice
42 are preserved on all copies.
44 Permission is granted to copy and distribute modified versions of this
45 manual under the conditions for verbatim copying, provided also that
46 the entire resulting derived work is distributed under the terms of a
47 permission notice identical to this one.
49 Permission is granted to copy and distribute translations of this manual
50 into another language, under the above conditions for modified versions.
53 @node Top, ar, (dir), (dir)
56 This brief manual contains preliminary documentation for the GNU binary
57 utilities (collectively version 1.9): @samp{ar}, @samp{objdump},
58 @samp{nm}, @samp{size}, @samp{strip}, and @samp{ranlib}. @refill
61 Copyright @copyright{} 1991 Free Software Foundation, Inc.
63 Permission is granted to make and distribute verbatim copies of
64 this manual provided the copyright notice and this permission notice
65 are preserved on all copies.
68 Permission is granted to process this file through TeX and print the
69 results, provided the printed document carries a copying permission
70 notice identical to this one except for the removal of this paragraph
71 (this paragraph not being relevant to the printed manual).
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.
94 @node ar, ld, Top, Top
98 ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{files}@dots{}
101 The GNU @code{ar} program creates, modifies, and extracts
102 archives. An @dfn{archive} is a single file holding a collection of
103 other files in a structure that makes it possible to retrieve
104 the original individual files (called @dfn{members} of the archive).
106 The original files' contents, mode (permissions), timestamp, owner, and
107 group are preserved in the archive, and may be reconstituted on
110 Only the first fifteen characters of a file name are kept in archives.
111 @c FIXME: with BFD version, this depends on obj format.
113 @code{ar} is considered a binary utility because archives of this sort
114 are most often used as @dfn{libraries} holding commonly needed
117 @code{ar} will create an index to the symbols defined in relocatable
118 object modules in the archive when you specify the option @samp{s}.
119 Once created, this index is updated in the archive whenever @code{ar}
120 makes a change to its contents. An archive with such an index speeds up
121 linking to the library, and allows routines in the library to call each
122 other without regard to their placement in the archive.
123 @c FIXME This auto-update may happen-always only for WRS version; Gumby
124 @c says, for instance, that it doesn't happen with 'q' updates elsewhere.
126 You may use @samp{nm -s} or @samp{nm +print-armap} to list this index
127 table. If an archive lacks the table, another form of @code{ar} called
128 @code{ranlib} can be used to add just the table.
130 @code{ar} insists on at least two arguments to execute: one
131 keyletter specifying the @emph{operation} (optionally accompanied by other
132 keyletters specifying @emph{modifiers}), and the archive name to act on.
134 Most operations can also accept further @var{files} arguments,
135 specifying particular files to operate on.
137 GNU @code{ar} allows you to mix the operation code and modifier flags in
138 any order, within the first command-line argument.
140 If you wish, you may prefix the first command-line argument with a
143 The @var{p} keyletter specifies what operation to execute; it may be
144 any of the following, but you must specify only one of them:
148 @emph{Delete} modules from the archive. Specify the names of modules to
149 be deleted as @var{files}; the archive is untouched if you
150 specify no files to delete.
152 If you wish to delete an archive's index, you can use this option to do
153 it; the internal name of the index (which you will need to specify in
154 @var{files} to delete it) is @samp{__.SYMDEF}.
156 If you specify the @samp{v} option flag, @code{ar} will list each module
160 Use this operation to @emph{move} members in an archive.
162 The ordering of members in an archive can make a difference in how
163 programs are linked using the library, if a symbol is defined in more
166 If no option flags are used with @code{m}, any members you name in the
167 @var{files} arguments are moved to the @emph{end} of the archive;
168 you can use the @samp{a}, @samp{b}, or @samp{i} options to move them to a
169 specified place instead.
172 @emph{Print} the specified members of the archive, to the standard
173 output file. If the @samp{v} option flag is specified, show the member
174 name before copying its contents to standard output.
176 If you specify no @var{files}, all the files in the archive are printed,
177 save for the index (if any), which is listed only if you ask for it by
178 name: @samp{__.SYMDEF}.
181 @emph{Quick append}; add @var{files} to the end of @var{archive},
182 without checking for replacement.
184 The options @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
185 operation; new members are always placed at the end of the archive.
187 The option @samp{v} makes @code{ar} list each file as it is appended.
189 @c FIXME: per Gumby, versions other than WRS of this will *not* auto-update
190 @c SYMDEF index on 'q' updates.
193 Insert @var{files} into @var{archive} (with @emph{replacement}). This
194 operation differs from @samp{q} in that any previously existing members
195 are deleted if their names match those being added.
197 If one of the files named in @var{files} doesn't exist, @code{ar}
198 displays an error message, and leaves undisturbed any existing members
199 of the archive matching that name.
201 By default, new members are added at the end of the file; but you may
202 use one of the options @samp{a}, @samp{b}, or @samp{i} to request
203 placement relative to some existing member.
205 The option flag @samp{v} used with this operation elicits a line of
206 output for each file inserted, along with one of the letters @samp{a} or
207 @samp{r} to indicate whether the file was appended (no old member
208 deleted) or replaced.
211 Display a @emph{table} listing the contents of @var{archive}, or those
212 of the files listed in @var{files} that are present in the
213 archive. Normally only the member name is shown; if you also want to
214 see the modes (permissions), timestamp, owner, group, and size, you can
215 request that by also specifying the @samp{v} option flag.
217 If you do not specify any @var{files}, all files in the archive
218 are listed; but the index to symbols from relocatable modules, called
219 @samp{__.SYMDEF}, is not listed unless you explicitly request it by
222 If there is more than one file with the same name (say, @samp{fie}) in
223 an archive (say @samp{b.a}), @samp{ar t b.a fie} will list only the
224 first instance; to see them all, you must ask for a complete
225 listing---in our example, @samp{ar t b.a}.
226 @c WRS only; per Gumby, this is implementation-dependent, and in a more
227 @c recent case in fact works the other way.
230 @emph{Extract} members (named @var{files}) from the archive. You can
231 use the @samp{v} option flag with this operation, to request that
232 @code{ar} list each name as it extracts it.
234 If you do not specify any @var{files}, all files in the archive
235 are extracted; but the index to symbols from relocatable modules, called
236 @samp{__.SYMDEF}, is not extracted unless you explicitly request it by
238 @c FIXME: does __.SYMDEF appear in all BFD arch formats? If not, which?
242 A number of modifiers (@var{mod}) may immediately follow the @var{p}
243 keyletter, to specify variations on an operation's behavior:
247 Add new files @emph{after} an existing member of the
248 archive. If you use the modifier @code{a}, the name of an existing archive
249 member must be present as the @var{membername} argument, before the
250 @var{archive} specification.
253 Add new files @emph{before} an existing member of the
254 archive. If you use the modifier @code{b}, the name of an existing archive
255 member must be present as the @var{membername} argument, before the
256 @var{archive} specification. (same as @samp{i}).
259 @emph{Create} the archive. The specified @var{archive} is always
260 created if it didn't exist, when you request an update. But a warning is
261 issued unless you specify in advance that you expect to create it, by
262 using this option flag.
265 Insert new files @emph{before} an existing member of the
266 archive. If you use the modifier @code{i}, the name of an existing archive
267 member must be present as the @var{membername} argument, before the
268 @var{archive} specification. (same as @samp{b}).
271 This option flag is recognized but not used; it is permitted for
272 compatibility with other forms of @code{ar}.
273 @c FIXME ar l modifier???---pesch@@cygnus.com, 25jan91
276 Preserve the @emph{original} dates of members when extracting them. If
277 you do not specify this option flag, files extracted from the archive
278 will be stamped with the time of extraction.
281 Write an object-file index into the archive, or update an existing one,
282 even if no other change is made to the archive. You may use this option
283 flag either with any operation, or alone. Running @samp{ar s} on an
284 archive is equivalent to running @samp{ranlib} on it.
287 Normally, @code{ar r}@dots{} or @code{ar q}@dots{} insert all files
288 listed into the archive. If you would like to insert @emph{only} those
289 of the files you list that are newer than existing members of the same
290 names, use this option. The option-flag combination @samp{qu} is
291 equivalent to @samp{ru}; checking the timestamps loses any speed
292 advantage, so @code{ar} treats both commands as replace operations with
293 the @samp{u} option appended.
296 This option requests the @emph{verbose} version of an operations. Many
297 operations display additional information, such as filenames processed,
298 when the option @samp{v} is appended.
302 @node ld, nm, ar, Top
304 The GNU linker @code{ld} is now described in a separate manual.
305 @xref{Top, , Overview, , GLD: the GNU linker}.
307 @node nm, objdump, ld, Top
311 nm [ -a | +debug-syms ] [ -g | +extern-only ]
312 [ -s | +print-armap ] [ -o | +print-file-name ]
313 [ -n | +numeric-sort ] [ -p | +no-sort ]
314 [ -r | +reverse-sort ] [ -u | +undefined-only ]
315 [ +target [@var{bfdname}] ]
316 [ @var{objfiles}@dots{} ]
319 GNU @code{nm} will list the symbols from object files @var{objfiles}.
320 Any command-line options must precede all object files; only the
321 @samp{+target} option can be further specified with an argument.
323 The long and short forms of options, shown here as alternatives, are
327 @item @var{objfiles}@dots{}
328 Object files whose symbols are to be listed. If no object files are
329 listed as arguments, @code{nm} assumes @samp{a.out}.
333 Display debugger-only symbols; normally these are not listed.
337 Display only external symbols.
341 Don't bother to sort the symbols in any order; just print them in the
346 Sort symbols numerically by their addresses, not alphabetically by their
351 When listing symbols from archives, list the index: a mapping (stored in
352 the archive by @code{ar} or @code{ranlib} of what modules contain
353 definitions for what names.
355 @item +print-file-name
357 Precede each symbol by the name of the input file where it was found,
358 rather than identifying the input file once only before all of its
363 Reverse the sense of the sort (whether numeric or alphabetic); let the
366 @item +target @var{bfdname}
368 Specify an object code format other than your system's default format.
369 @xref{objdump}, for information on listing available formats.
370 @c FIXME what *does* +target/no arg do?
373 @item +undefined-only
375 Display only undefined symbols (those external to each object file).
379 @node objdump, ranlib, nm, Top
383 objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ] [ -i ]
384 [ -j @var{section} ] [ -l ]
385 [ -m @var{machine} ] [ -s ] [ -x ]
387 [ -h | +header ] [ -r | +reloc ]
388 [ -t | +syms ] @var{objfiles}@dots{}
391 @code{objdump} displays information about one or more object files.
392 The options control what particular information to display. This
393 information is mostly useful to programmers who are working on the
394 compilation tools, as opposed to programmers who just want their
395 program to compile and work.
397 The long and short forms of options, shown here as alternatives, are
401 @item @var{objfiles}@dots{}
402 The object files to be examined.
406 If any files from @var{objfiles} are archives, display the archive
407 header information (in a format similar to @samp{ls -l}).
409 @c suggest longname +target or +format or +bfd
410 @item -b @var{bfdname}
411 You can specify a particular object-code format for your object files as
412 @var{bfdname}. This may not be necessary; @var{objdump} can
413 automatically recognize many formats. For example,
415 objdump -b oasys -m vax -h fu.o
418 Displays summary information from the section headers (@samp{-h}) of
419 @file{fu.o}, which is explicitly identified as a Vax (@samp{-m}) object
420 file in the format produced by Oasys compilers. You can list the
421 formats available with the @var{-i} option.
424 Disassemble. Display the assembler mnemonics for the machine
425 instructions from @var{objfiles}.
428 File header. Display summary information from the overall header of
429 each file in @var{objfiles}.
433 Header. Display summary information from the section headers of the
437 Display a list showing all architectures and object formats available
438 for specification with @code{-b} or @code{-m}.
440 @c suggest longname +section
442 Display information only for section @var{name}
444 @c suggest longname +label or +linespec
446 Label the display (using debugging information) with the source filename
447 and line numbers corresponding to the object code shown.
449 @c suggest longname +architecture
450 @item -m @var{machine}
451 Specify the object files @var{objfiles} are for architecture
452 @var{machine}. You can list available architectures using the @samp{-i}
457 Relocation. Print the relocation entries of the file.
460 Display the full contents of any sections requested.
464 Symbol Table. Print the symbol table entries of the file.
465 This is similar to the information provided by the @samp{nm} program.
468 Display all available header information, including the symbol table and
469 relocation entries. @samp{-x} is equivalent to @samp{-f -a -h -r -t}.
473 @node ranlib, size, objdump, Top
480 @code{ranlib} generates the an index to the contents of an archive, and
481 stores it in the archive. The index lists each symbol defined by a
482 member of an archive that is a relocatable object file.
484 You may use @code{nm -s} or @code{nm +print-armap} to list this table.
485 The index is internally stored in the archive under the name
487 @c FIXME does __.SYMDEF exist in archives in all flavors? (ranlib)
489 An archive with such an index speeds up linking to the library, and
490 allows routines in the library to call each other without regard to
491 their placement in the archive.
493 The GNU @code{ranlib} program is another form of GNU @code{ar}.
496 @c FIXME vintage ranlib had options [ -t | +touch ] [ -v | +verbose ]
497 @c which are gone here. Good or evil?
499 @code{ranlib}'s options make it report on what it's doing and fake an
500 update of a particular archive's index.
502 Any command-line options must precede the archive name.
504 The long and short forms of options, shown here as alternatives, are
510 You can use the ``touch'' option to fake an update of the index
511 table in archives; @code{ranlib} will first set the current date for the
512 index object module in the archive (to make it appear to have changed).
515 Use this option if you'd like informational messages about what
516 @code{ranlib} is up to, while it loops through the specified archives.
521 @node size, strip, ranlib, Top
525 size [ -d | -o | -x | +radix @var{number} ]
526 [ -A | -B | +format @var{compatibility} ] [ +help ]
527 [ +target [@var{bfdname}] [ -V | +version ]
528 @var{objfiles}@dots{}
531 The GNU @code{size} utility lists the section sizes---and the total
532 size---for each of the object files @var{objfiles} in its argument list.
533 By default, one line of output is generated for each object file or each
534 module in an archive.
536 The command line options have the following meanings:
538 @item +radix @var{number}
542 Using one of these options, you can control whether the size of each
543 section is given in decimal (@samp{-d}, or @samp{+radix 10}); octal
544 (@samp{-o}, or @samp{+radix 8}); or hexadecimal (@samp{-x}, or
545 @samp{+radix 16}). In @samp{+radix @var{number}}, only the three
546 values (8, 10, 16) are supported. The total size is always given in two
547 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
548 octal and hexadecimal if you're using @samp{-o}.
550 @item +format @var{compatibility}
553 Using one of these options, you can choose whether the output from GNU
554 @code{size} resembles output from System V @code{size} (using @samp{-A},
555 or @samp{+format sysv}, or Berkeley @code{size} (using @samp{-B}, or
556 @samp{+format berkeley}. The default is the one-line format similar to
558 @c Bonus for doc-source readers: you can also say +format=strange (or
559 @c anything else that starts with 's') for sysv, and +format=boring (or
560 @c anything else that starts with 'b') for Berkeley.
562 Here is an example of the Berkeley (default) format of output from
565 eg$ size +format Berkeley ranlib size
566 text data bss dec hex filename
567 294880 81920 11592 388392 5ed28 ranlib
568 294880 81920 11888 388688 5ee50 size
572 This is the same data, but displayed closer to System V conventions:
576 eg$ size +format SysV ranlib size
592 @item +target @var{bfdname}
593 You can specify a particular object-code format for @var{objfiles} as
594 @var{bfdname}. This may not be necessary; @var{size} can
595 automatically recognize many formats. @xref{objdump}, for information
596 on listing available formats.
600 Display version number information on @code{size} itself.
605 @node strip, , size, Top
609 strip [ -s | +strip-all ] [ -g | -S | +strip-debug ]
610 [ -x | +discard-all ] [ -X | +discard-locals ]
612 @var{objfiles}@dots{}
615 GNU @code{strip} will discard all symbols from object files
616 @var{objfiles}, if no options are specified; or only certain symbols,
617 depending on its command-line options.
619 @code{strip} will not execute unless at least one object file is listed.
621 @emph{WARNING:} @code{strip} modifies the files named in its argument,
622 rather than writing modified copies under different names.
624 The long and short forms of options, shown here as alternatives, are
630 This is the default case: strip all symbol entries from @var{objfiles}.
635 Discard only debugging symbol information from @var{objfiles}.
639 Discard all symbols local to each file in @var{objfiles}.
640 @emph{WARNING:} Note that @code{+discard-all} discards only @emph{local}
641 symbols, in spite of its name.
643 @item +discard-locals
645 Discard local symbols starting with @samp{L} from each file in
646 @var{objfiles}. (Some compilers produce internally-used symbols that
647 begin with @samp{L}.)
649 @item -T @var{bfdname}
650 You can specify a particular object-code format @var{bfdname} for
651 @var{objfiles}. This may not be necessary; @var{strip} can automatically
652 recognize many formats. @xref{objdump}, for information on listing