Oops... forgot 1.9 -> 1.90 last time around...
[binutils-gdb.git] / binutils / binutils.texinfo
1 \input texinfo
2 @setfilename binutils.info
3 @synindex ky cp
4 @c
5 @c This file documents the GNU binary utilities "ar", "ld", "objdump", "nm",
6 @c "size", "strip", and "ranlib".
7 @c
8 @c Copyright (C) 1991 Free Software Foundation, Inc.
9 @c
10 @c This text may be freely distributed under the terms of the GNU
11 @c General Public License.
12 @c
13 @c $Id$
14 @tex
15 @finalout
16 @c @smallbook
17 @end tex
18 @c @cropmarks
19 @setchapternewpage odd
20 @settitle GNU Binary Utilities
21 @titlepage
22 @title{The GNU Binary Utilities}
23 @subtitle{Version 1.90}
24 @sp 1
25 @subtitle October 1991
26 @author{Roland H. Pesch}
27 @author{Cygnus Support}
28 @page
29
30 @tex
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 }
35 @end tex
36
37 @vskip 0pt plus 1filll
38 Copyright @copyright{} 1991 Free Software Foundation, Inc.
39
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.
43
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.
48
49 Permission is granted to copy and distribute translations of this manual
50 into another language, under the above conditions for modified versions.
51 @end titlepage
52
53 @node Top, ar, (dir), (dir)
54 @chapter Introduction
55
56 This brief manual contains preliminary documentation for the GNU binary
57 utilities (collectively version 1.90): @samp{ar}, @samp{objdump},
58 @samp{nm}, @samp{size}, @samp{strip}, and @samp{ranlib}. @refill
59
60 @ifinfo
61 Copyright @copyright{} 1991 Free Software Foundation, Inc.
62
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.
66
67 @ignore
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).
72
73 @end ignore
74
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.
79
80 Permission is granted to copy and distribute translations of this manual
81 into another language, under the above conditions for modified versions.
82 @end ifinfo
83
84 @menu
85 * ar:: ar
86 * ld:: ld
87 * nm:: nm
88 * objdump:: objdump
89 * ranlib:: ranlib
90 * size:: size
91 * strip:: strip
92 @end menu
93
94 @node ar, ld, Top, Top
95 @chapter ar
96
97 @smallexample
98 ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{files}@dots{}
99 @end smallexample
100
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).
105
106 The original files' contents, mode (permissions), timestamp, owner, and
107 group are preserved in the archive, and may be reconstituted on
108 extraction.
109
110 GNU @code{ar} can maintain archives whose members have names of any
111 length; however, depending on how @code{ar} is configured on your
112 system, a limit on member-name length may be imposed (for compatibility
113 with archive formats maintained with other tools). If it exists, the
114 limit is often 15 characters (typical of formats related to a.out) or 16
115 characters (typical of formats related to coff).
116
117 @code{ar} is considered a binary utility because archives of this sort
118 are most often used as @dfn{libraries} holding commonly needed
119 subroutines.
120
121 @code{ar} will create an index to the symbols defined in relocatable
122 object modules in the archive when you specify the modifier @samp{s}.
123 Once created, this index is updated in the archive whenever @code{ar}
124 makes a change to its contents (save for the @samp{q} update operation).
125 An archive with such an index speeds up linking to the library, and
126 allows routines in the library to call each other without regard to
127 their placement in the archive.
128
129
130 You may use @samp{nm -s} or @samp{nm +print-armap} to list this index
131 table. If an archive lacks the table, another form of @code{ar} called
132 @code{ranlib} can be used to add just the table.
133
134 @code{ar} insists on at least two arguments to execute: one
135 keyletter specifying the @emph{operation} (optionally accompanied by other
136 keyletters specifying @emph{modifiers}), and the archive name to act on.
137
138 Most operations can also accept further @var{files} arguments,
139 specifying particular files to operate on.
140
141 GNU @code{ar} allows you to mix the operation code @var{p} and modifier
142 flags @var{mod} in any order, within the first command-line argument.
143
144 If you wish, you may prefix the first command-line argument with a
145 dash.
146
147 The @var{p} keyletter specifies what operation to execute; it may be
148 any of the following, but you must specify only one of them:
149
150 @table @code
151 @item d
152 @emph{Delete} modules from the archive. Specify the names of modules to
153 be deleted as @var{files}; the archive is untouched if you
154 specify no files to delete.
155
156 If you specify the @samp{v} modifier, @code{ar} will list each module
157 as it is deleted.
158
159 @item m
160 Use this operation to @emph{move} members in an archive.
161
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
164 than one member.
165
166 If no modifiers 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} modifiers to move them to a
169 specified place instead.
170
171 @item p
172 @emph{Print} the specified members of the archive, to the standard
173 output file. If the @samp{v} modifier is specified, show the member
174 name before copying its contents to standard output.
175
176 If you specify no @var{files}, all the files in the archive are printed.
177
178 @item q
179 @emph{Quick append}; add @var{files} to the end of @var{archive},
180 without checking for replacement.
181
182 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
183 operation; new members are always placed at the end of the archive.
184
185 The modifier @samp{v} makes @code{ar} list each file as it is appended.
186
187 Since the point of this operation is speed, the archive's symbol table
188 index is not updated, even if it already existed; you can use @samp{ar s} or
189 @code{ranlib} explicitly to update the symbol table index.
190
191 @item r
192 Insert @var{files} into @var{archive} (with @emph{replacement}). This
193 operation differs from @samp{q} in that any previously existing members
194 are deleted if their names match those being added.
195
196 If one of the files named in @var{files} doesn't exist, @code{ar}
197 displays an error message, and leaves undisturbed any existing members
198 of the archive matching that name.
199
200 By default, new members are added at the end of the file; but you may
201 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
202 placement relative to some existing member.
203
204 The modifier @samp{v} used with this operation elicits a line of
205 output for each file inserted, along with one of the letters @samp{a} or
206 @samp{r} to indicate whether the file was appended (no old member
207 deleted) or replaced.
208
209 @item t
210 Display a @emph{table} listing the contents of @var{archive}, or those
211 of the files listed in @var{files} that are present in the
212 archive. Normally only the member name is shown; if you also want to
213 see the modes (permissions), timestamp, owner, group, and size, you can
214 request that by also specifying the @samp{v} modifier.
215
216 If you do not specify any @var{files}, all files in the archive
217 are listed.
218
219 If there is more than one file with the same name (say, @samp{fie}) in
220 an archive (say @samp{b.a}), @samp{ar t b.a fie} will list only the
221 first instance; to see them all, you must ask for a complete
222 listing---in our example, @samp{ar t b.a}.
223 @c WRS only; per Gumby, this is implementation-dependent, and in a more
224 @c recent case in fact works the other way.
225
226 @item x
227 @emph{Extract} members (named @var{files}) from the archive. You can
228 use the @samp{v} modifier with this operation, to request that
229 @code{ar} list each name as it extracts it.
230
231 If you do not specify any @var{files}, all files in the archive
232 are extracted.
233
234 @end table
235
236 A number of modifiers (@var{mod}) may immediately follow the @var{p}
237 keyletter, to specify variations on an operation's behavior:
238
239 @table @code
240 @item a
241 Add new files @emph{after} an existing member of the
242 archive. If you use the modifier @code{a}, the name of an existing archive
243 member must be present as the @var{membername} argument, before the
244 @var{archive} specification.
245
246 @item b
247 Add new files @emph{before} an existing member of the
248 archive. If you use the modifier @code{b}, the name of an existing archive
249 member must be present as the @var{membername} argument, before the
250 @var{archive} specification. (same as @samp{i}).
251
252 @item c
253 @emph{Create} the archive. The specified @var{archive} is always
254 created if it didn't exist, when you request an update. But a warning is
255 issued unless you specify in advance that you expect to create it, by
256 using this modifier.
257
258 @item i
259 Insert new files @emph{before} an existing member of the
260 archive. If you use the modifier @code{i}, the name of an existing archive
261 member must be present as the @var{membername} argument, before the
262 @var{archive} specification. (same as @samp{b}).
263
264 @item l
265 This modifier is accepted but not used.
266 @c whaffor ar l modifier??? presumably compat; with
267 @c what???---pesch@@cygnus.com, 25jan91
268
269 @item o
270 Preserve the @emph{original} dates of members when extracting them. If
271 you do not specify this modifier, files extracted from the archive
272 will be stamped with the time of extraction.
273
274 @item s
275 Write an object-file index into the archive, or update an existing one,
276 even if no other change is made to the archive. You may use this modifier
277 flag either with any operation, or alone. Running @samp{ar s} on an
278 archive is equivalent to running @samp{ranlib} on it.
279
280 @item u
281 Normally, @code{ar r}@dots{} inserts all files
282 listed into the archive. If you would like to insert @emph{only} those
283 of the files you list that are newer than existing members of the same
284 names, use this modifier. The @samp{u} modifier is allowed only for the
285 operation @samp{r} (replace). In particular, the combination @samp{qu} is
286 not allowed, since checking the timestamps would lose any speed
287 advantage from the operation @samp{q}.
288
289 @item v
290 This modifier requests the @emph{verbose} version of an operation. Many
291 operations display additional information, such as filenames processed,
292 when the modifier @samp{v} is appended.
293
294 @end table
295
296 @node ld, nm, ar, Top
297 @chapter ld
298 The GNU linker @code{ld} is now described in a separate manual.
299 @xref{Top, , Overview, , GLD: the GNU linker}.
300
301 @node nm, objdump, ld, Top
302 @chapter nm
303
304 @smallexample
305 nm [ -a | +debug-syms ] [ -g | +extern-only ]
306 [ -s | +print-armap ] [ -o | +print-file-name ]
307 [ -n | +numeric-sort ] [ -p | +no-sort ]
308 [ -r | +reverse-sort ] [ -u | +undefined-only ]
309 [ +target @var{bfdname} ]
310 [ @var{objfiles}@dots{} ]
311 @end smallexample
312
313 GNU @code{nm} will list the symbols from object files @var{objfiles}.
314
315 The long and short forms of options, shown here as alternatives, are
316 equivalent.
317
318 @table @code
319 @item @var{objfiles}@dots{}
320 Object files whose symbols are to be listed. If no object files are
321 listed as arguments, @code{nm} assumes @samp{a.out}.
322
323 @item +debug-syms
324 @itemx -a
325 Display debugger-only symbols; normally these are not listed.
326
327 @item +extern-only
328 @itemx -g
329 Display only external symbols.
330
331 @item +no-sort
332 @itemx -p
333 Don't bother to sort the symbols in any order; just print them in the
334 order encountered.
335
336 @item +numeric-sort
337 @itemx -n
338 Sort symbols numerically by their addresses, not alphabetically by their
339 names.
340
341 @item +print-armap
342 @itemx -s
343 When listing symbols from archives, list the index: a mapping (stored in
344 the archive by @code{ar} or @code{ranlib}) of what modules contain
345 definitions for what names.
346
347 @item +print-file-name
348 @itemx -o
349 Precede each symbol by the name of the input file where it was found,
350 rather than identifying the input file once only before all of its
351 symbols.
352
353 @item +reverse-sort
354 @itemx -r
355 Reverse the sense of the sort (whether numeric or alphabetic); let the
356 last come first.
357
358 @item +target @var{bfdname}
359 @c @item +target
360 Specify an object code format other than your system's default format.
361 @xref{objdump}, for information on listing available formats.
362 @c FIXME what *does* +target/no arg do?
363
364
365 @item +undefined-only
366 @itemx -u
367 Display only undefined symbols (those external to each object file).
368
369 @end table
370
371 @node objdump, ranlib, nm, Top
372 @chapter objdump
373
374 @smallexample
375 objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ]
376 [ -h | +header ] [ -i ] [ -j @var{section} ] [ -l ]
377 [ -m @var{machine} ] [ -r | +reloc ] [ -s ]
378 [ -t | +syms ] [ -x ]
379 @var{objfiles}@dots{}
380 @end smallexample
381
382 @code{objdump} displays information about one or more object files.
383 The options control what particular information to display. This
384 information is mostly useful to programmers who are working on the
385 compilation tools, as opposed to programmers who just want their
386 program to compile and work.
387
388 The long and short forms of options, shown here as alternatives, are
389 equivalent.
390
391 @table @code
392 @item @var{objfiles}@dots{}
393 The object files to be examined.
394
395 @item -a
396 @c print_arelt_descr
397 If any files from @var{objfiles} are archives, display the archive
398 header information (in a format similar to @samp{ls -l}).
399
400 @c suggest longname +target or +format or +bfd
401 @item -b @var{bfdname}
402 You can specify a particular object-code format for your object files as
403 @var{bfdname}. This may not be necessary; @var{objdump} can
404 automatically recognize many formats. For example,
405 @example
406 objdump -b oasys -m vax -h fu.o
407 @end example
408 @noindent
409 Displays summary information from the section headers (@samp{-h}) of
410 @file{fu.o}, which is explicitly identified (@samp{-m}) as a Vax object
411 file in the format produced by Oasys compilers. You can list the
412 formats available with the @samp{-i} option.
413
414 @item -d
415 Disassemble. Display the assembler mnemonics for the machine
416 instructions from @var{objfiles}.
417
418 @item -f
419 File header. Display summary information from the overall header of
420 each file in @var{objfiles}.
421
422 @item +header
423 @itemx -h
424 Header. Display summary information from the section headers of the
425 object file.
426
427 @item -i
428 Display a list showing all architectures and object formats available
429 for specification with @code{-b} or @code{-m}.
430
431 @c suggest longname +section
432 @item -j @var{name}
433 Display information only for section @var{name}
434
435 @c suggest longname +label or +linespec
436 @item -l
437 Label the display (using debugging information) with the source filename
438 and line numbers corresponding to the object code shown.
439
440 @c suggest longname +architecture
441 @item -m @var{machine}
442 Specify the object files @var{objfiles} are for architecture
443 @var{machine}. You can list available architectures using the @samp{-i}
444 option.
445
446 @item +reloc
447 @itemx -r
448 Relocation. Print the relocation entries of the file.
449
450 @item -s
451 Display the full contents of any sections requested.
452
453 @item +syms
454 @itemx -t
455 Symbol Table. Print the symbol table entries of the file.
456 This is similar to the information provided by the @samp{nm} program.
457
458 @item -x
459 Display all available header information, including the symbol table and
460 relocation entries. Using @samp{-x} is equivalent to specifying all of
461 @samp{-f -a -h -r -t}.
462
463 @end table
464
465 @node ranlib, size, objdump, Top
466 @chapter ranlib
467
468 @smallexample
469 ranlib @var{archive}
470 @end smallexample
471
472 @code{ranlib} generates an index to the contents of an archive, and
473 stores it in the archive. The index lists each symbol defined by a
474 member of an archive that is a relocatable object file.
475
476 You may use @code{nm -s} or @code{nm +print-armap} to list this index.
477
478 An archive with such an index speeds up linking to the library, and
479 allows routines in the library to call each other without regard to
480 their placement in the archive.
481
482 The GNU @code{ranlib} program is another form of GNU @code{ar}; running
483 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
484 @xref{ar}.
485
486
487 @ignore
488 @c FIXME vintage ranlib had options [ -t | +touch ] [ -v | +verbose ]
489 @c which are gone here. Good or evil?
490
491 @code{ranlib}'s options make it report on what it's doing and fake an
492 update of a particular archive's index.
493
494 Any command-line options must precede the archive name.
495
496 The long and short forms of options, shown here as alternatives, are
497 equivalent.
498
499 @table @code
500
501 @item -t | +touch
502 You can use the ``touch'' option to fake an update of the index
503 table in archives; @code{ranlib} will first set the current date for the
504 index object module in the archive (to make it appear to have changed).
505
506 @item -v | +verbose
507 Use this option if you'd like informational messages about what
508 @code{ranlib} is up to, while it loops through the specified archives.
509
510 @end table
511 @end ignore
512
513 @node size, strip, ranlib, Top
514 @chapter size
515
516 @smallexample
517 size [ -A | -B | +format @var{compatibility} ]
518 [ +help ] [ -d | -o | -x | +radix @var{number} ]
519 [ +target @var{bfdname} [ -V | +version ]
520 @var{objfiles}@dots{}
521 @end smallexample
522
523 The GNU @code{size} utility lists the section sizes---and the total
524 size---for each of the object files @var{objfiles} in its argument list.
525 By default, one line of output is generated for each object file or each
526 module in an archive.
527
528 The command line options have the following meanings:
529 @table @code
530 @item @var{objfiles}@dots{}
531 The object files to be examined.
532
533 @item +format @var{compatibility}
534 @itemx -A
535 @itemx -B
536 Using one of these options, you can choose whether the output from GNU
537 @code{size} resembles output from System V @code{size} (using @samp{-A},
538 or @samp{+format sysv}, or Berkeley @code{size} (using @samp{-B}, or
539 @samp{+format berkeley}. The default is the one-line format similar to
540 Berkeley's.
541 @c Bonus for doc-source readers: you can also say +format=strange (or
542 @c anything else that starts with 's') for sysv, and +format=boring (or
543 @c anything else that starts with 'b') for Berkeley.
544
545 Here is an example of the Berkeley (default) format of output from
546 @code{size}:
547 @smallexample
548 eg$ size +format Berkeley ranlib size
549 text data bss dec hex filename
550 294880 81920 11592 388392 5ed28 ranlib
551 294880 81920 11888 388688 5ee50 size
552 @end smallexample
553
554 @noindent
555 This is the same data, but displayed closer to System V conventions:
556
557 @smallexample
558 eg$ size +format SysV ranlib size
559 ranlib :
560 section size addr
561 .text 294880 8192
562 .data 81920 303104
563 .bss 11592 385024
564 Total 388392
565
566
567 size :
568 section size addr
569 .text 294880 8192
570 .data 81920 303104
571 .bss 11888 385024
572 Total 388688
573 @end smallexample
574
575 @item +help
576 Show a summary of acceptable arguments and options.
577
578 @item +radix @var{number}
579 @itemx -d
580 @itemx -o
581 @itemx -x
582 Using one of these options, you can control whether the size of each
583 section is given in decimal (@samp{-d}, or @samp{+radix 10}); octal
584 (@samp{-o}, or @samp{+radix 8}); or hexadecimal (@samp{-x}, or
585 @samp{+radix 16}). In @samp{+radix @var{number}}, only the three
586 values (8, 10, 16) are supported. The total size is always given in two
587 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
588 octal and hexadecimal if you're using @samp{-o}.
589
590 @item +target @var{bfdname}
591 You can specify a particular object-code format for @var{objfiles} as
592 @var{bfdname}. This may not be necessary; @var{size} can
593 automatically recognize many formats. @xref{objdump}, for information
594 on listing available formats.
595
596 @item +version
597 @itemx -V
598 Display version number information on @code{size} itself.
599
600 @end table
601
602
603 @node strip, , size, Top
604 @chapter strip
605
606 @smallexample
607 strip [ -s | +strip-all ] [ -g | -S | +strip-debug ]
608 [ -x | +discard-all ] [ -X | +discard-locals ]
609 [ -T @var{bfdname} ]
610 @var{objfiles}@dots{}
611 @end smallexample
612
613 GNU @code{strip} will discard all symbols from object files
614 @var{objfiles}, if no options are specified; or only certain symbols,
615 depending on its command-line options.
616
617 @code{strip} will not execute unless at least one object file is listed.
618
619 @quotation
620 @emph{WARNING:} @code{strip} modifies the files named in its argument,
621 rather than writing modified copies under different names.
622 @end quotation
623
624 The long and short forms of options, shown here as alternatives, are
625 equivalent.
626
627 @table @code
628 @item +strip-all
629 @itemx -s
630 This is the default case: strip all symbol entries from @var{objfiles}.
631
632 @item +strip-debug
633 @itemx -g
634 @itemx -S
635 Discard only debugging symbol information from @var{objfiles}.
636
637 @item +discard-all
638 @itemx -x
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.
642
643 @item +discard-locals
644 @itemx -X
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}.)
648
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
653 available formats.
654 @end table
655
656 @contents
657 @bye
658
659