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