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