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