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