Works again.
[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
d6391983 7* Binutils:: The GNU binary utilities "ar", "ld", "objcopy",
ba7c8e29 8 "objdump", "nm", "size", "strings", "strip", and "ranlib".
9abcc3b8
RP
9END-INFO-DIR-ENTRY
10@end format
11@end ifinfo
c72af735 12
8b2c2275 13@ifinfo
e32341a7 14Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
8b2c2275
RP
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
df14d957 39@c This file documents the GNU binary utilities "ar", "ld", "objcopy",
ba7c8e29 40@c "objdump", "nm", "size", "strings", "strip", and "ranlib".
c72af735 41@c
e32341a7 42@c Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
c72af735
RP
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
b6216af2 55@subtitle Version 2.2
c72af735 56@sp 1
e32341a7 57@subtitle May 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
e32341a7 70Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
c72af735
RP
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
b6216af2 90utilities (collectively version 2.2):
8b2c2275
RP
91
92@iftex
c72af735
RP
93@table @code
94@item ar
95Create, modify, and extract from archives
96
df14d957 97@item objcopy
e31e9a8d
JO
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
ba7c8e29
DM
112@item strings
113List printable strings from files
114
c72af735
RP
115@item strip
116Discard symbols
117@end table
8b2c2275 118@end iftex
c72af735
RP
119
120@menu
8b2c2275 121* ar:: Create, modify, and extract from archives
df14d957 122* objcopy:: Copy and translate object files
8b2c2275
RP
123* ld:(ld)Overview. Combine object and archive files
124* nm:: List symbols from object files
125* objdump:: Display information from object files
126* ranlib:: Generate index to archive contents
127* size:: List section sizes and total size
ba7c8e29 128* strings:: List printable strings from files
8b2c2275 129* strip:: Discard symbols
b6216af2 130* c++filt:: Filter to demangle encoded C++ symbols
8b2c2275 131* Index::
c72af735
RP
132@end menu
133
df14d957 134@node ar, objcopy, Top, Top
c72af735
RP
135@chapter ar
136
137@kindex ar
138@cindex archives
139@cindex collections of files
140@smallexample
4d9b5d5a
DM
141ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{}
142ar -M [ <mri-script ]
c72af735
RP
143@end smallexample
144
145The GNU @code{ar} program creates, modifies, and extracts from
146archives. An @dfn{archive} is a single file holding a collection of
147other files in a structure that makes it possible to retrieve
148the original individual files (called @dfn{members} of the archive).
149
150The original files' contents, mode (permissions), timestamp, owner, and
ec40bbb8 151group are preserved in the archive, and can be restored on
c72af735
RP
152extraction.
153
154@cindex name length
155GNU @code{ar} can maintain archives whose members have names of any
156length; however, depending on how @code{ar} is configured on your
ec40bbb8
DM
157system, a limit on member-name length may be imposed for compatibility
158with archive formats maintained with other tools. If it exists, the
c72af735
RP
159limit is often 15 characters (typical of formats related to a.out) or 16
160characters (typical of formats related to coff).
161
162@cindex libraries
163@code{ar} is considered a binary utility because archives of this sort
164are most often used as @dfn{libraries} holding commonly needed
165subroutines.
166
167@cindex symbol index
e31e9a8d 168@code{ar} creates an index to the symbols defined in relocatable
c72af735
RP
169object modules in the archive when you specify the modifier @samp{s}.
170Once created, this index is updated in the archive whenever @code{ar}
171makes a change to its contents (save for the @samp{q} update operation).
172An archive with such an index speeds up linking to the library, and
173allows routines in the library to call each other without regard to
174their placement in the archive.
175
918c2f61 176You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
c72af735
RP
177table. If an archive lacks the table, another form of @code{ar} called
178@code{ranlib} can be used to add just the table.
179
765a273f
RP
180@cindex compatibility, @code{ar}
181@cindex @code{ar} compatibility
182GNU @code{ar} is designed to be compatible with two different
183facilities. You can control its activity using command-line options,
184like the different varieties of @code{ar} on Unix systems; or, if you
185specify the single command-line option @samp{-M}, you can control it
186with a script supplied via standard input, like the MRI ``librarian''
187program.
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
4d9b5d5a 199ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{}
765a273f
RP
200@end smallexample
201
202@cindex Unix compatibility, @code{ar}
203When you use @code{ar} in the Unix style, @code{ar} insists on at least two
204arguments 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.
c72af735 207
ec40bbb8 208Most operations can also accept further @var{file} arguments,
c72af735
RP
209specifying particular files to operate on.
210
211GNU @code{ar} allows you to mix the operation code @var{p} and modifier
212flags @var{mod} in any order, within the first command-line argument.
213
214If you wish, you may begin the first command-line argument with a
215dash.
216
217@cindex operations on archive
218The @var{p} keyletter specifies what operation to execute; it may be
219any 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
b703c078 225be deleted as @var{file}@dots{}; the archive is untouched if you
c72af735
RP
226specify no files to delete.
227
e31e9a8d 228If you specify the @samp{v} modifier, @code{ar} lists each module
c72af735
RP
229as it is deleted.
230
231@item m
232@cindex moving in archive
233Use this operation to @emph{move} members in an archive.
234
235The ordering of members in an archive can make a difference in how
236programs are linked using the library, if a symbol is defined in more
237than one member.
238
239If no modifiers are used with @code{m}, any members you name in the
ec40bbb8 240@var{file} arguments are moved to the @emph{end} of the archive;
c72af735
RP
241you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
242specified place instead.
243
244@item p
245@cindex printing from archive
246@emph{Print} the specified members of the archive, to the standard
247output file. If the @samp{v} modifier is specified, show the member
248name before copying its contents to standard output.
249
ec40bbb8
DM
250If you specify no @var{file} arguments, all the files in the archive are
251printed.
c72af735
RP
252
253@item q
254@cindex quick append to archive
b703c078 255@emph{Quick append}; add the files @var{file}@dots{} to the end of
ec40bbb8 256@var{archive}, without checking for replacement.
c72af735
RP
257
258The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
259operation; new members are always placed at the end of the archive.
260
261The modifier @samp{v} makes @code{ar} list each file as it is appended.
262
263Since the point of this operation is speed, the archive's symbol table
264index is not updated, even if it already existed; you can use @samp{ar s} or
265@code{ranlib} explicitly to update the symbol table index.
266
267@item r
268@cindex replacement in archive
b703c078 269Insert the files @var{file}@dots{} into @var{archive} (with
ec40bbb8
DM
270@emph{replacement}). This operation differs from @samp{q} in that any
271previously existing members are deleted if their names match those being
272added.
c72af735 273
b703c078 274If one of the files named in @var{file}@dots{} doesn't exist, @code{ar}
c72af735
RP
275displays an error message, and leaves undisturbed any existing members
276of the archive matching that name.
277
278By default, new members are added at the end of the file; but you may
279use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
280placement relative to some existing member.
281
282The modifier @samp{v} used with this operation elicits a line of
283output for each file inserted, along with one of the letters @samp{a} or
284@samp{r} to indicate whether the file was appended (no old member
285deleted) or replaced.
286
287@item t
288@cindex contents of archive
289Display a @emph{table} listing the contents of @var{archive}, or those
b703c078 290of the files listed in @var{file}@dots{} that are present in the
c72af735
RP
291archive. Normally only the member name is shown; if you also want to
292see the modes (permissions), timestamp, owner, group, and size, you can
293request that by also specifying the @samp{v} modifier.
294
ec40bbb8 295If you do not specify a @var{file}, all files in the archive
c72af735
RP
296are listed.
297
298@cindex repeated names in archive
299@cindex name duplication in archive
300If there is more than one file with the same name (say, @samp{fie}) in
e31e9a8d 301an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
c72af735
RP
302first instance; to see them all, you must ask for a complete
303listing---in our example, @samp{ar t b.a}.
304@c WRS only; per Gumby, this is implementation-dependent, and in a more
305@c recent case in fact works the other way.
306
307@item x
308@cindex extract from archive
ec40bbb8 309@emph{Extract} members (named @var{file}) from the archive. You can
c72af735
RP
310use the @samp{v} modifier with this operation, to request that
311@code{ar} list each name as it extracts it.
312
ec40bbb8 313If you do not specify a @var{file}, all files in the archive
c72af735
RP
314are extracted.
315
316@end table
317
318A number of modifiers (@var{mod}) may immediately follow the @var{p}
319keyletter, to specify variations on an operation's behavior:
320
321@table @code
322@item a
323@cindex relative placement in archive
324Add new files @emph{after} an existing member of the
ec40bbb8 325archive. If you use the modifier @samp{a}, the name of an existing archive
c72af735
RP
326member must be present as the @var{membername} argument, before the
327@var{archive} specification.
328
329@item b
330Add new files @emph{before} an existing member of the
ec40bbb8 331archive. If you use the modifier @samp{b}, the name of an existing archive
c72af735
RP
332member must be present as the @var{membername} argument, before the
333@var{archive} specification. (same as @samp{i}).
334
335@item c
336@cindex creating archives
337@emph{Create} the archive. The specified @var{archive} is always
338created if it didn't exist, when you request an update. But a warning is
339issued unless you specify in advance that you expect to create it, by
340using this modifier.
341
342@item i
343Insert new files @emph{before} an existing member of the
ec40bbb8 344archive. If you use the modifier @samp{i}, the name of an existing archive
c72af735
RP
345member must be present as the @var{membername} argument, before the
346@var{archive} specification. (same as @samp{b}).
347
348@item l
349This modifier is accepted but not used.
350@c whaffor ar l modifier??? presumably compat; with
351@c what???---pesch@@cygnus.com, 25jan91
352
353@item o
354@cindex dates in archive
355Preserve the @emph{original} dates of members when extracting them. If
356you do not specify this modifier, files extracted from the archive
e31e9a8d 357are stamped with the time of extraction.
c72af735
RP
358
359@item s
360@cindex writing archive index
361Write an object-file index into the archive, or update an existing one,
362even if no other change is made to the archive. You may use this modifier
363flag either with any operation, or alone. Running @samp{ar s} on an
364archive is equivalent to running @samp{ranlib} on it.
365
366@item u
367@cindex updating an archive
b703c078 368Normally, @samp{ar r}@dots{} inserts all files
c72af735
RP
369listed into the archive. If you would like to insert @emph{only} those
370of the files you list that are newer than existing members of the same
371names, use this modifier. The @samp{u} modifier is allowed only for the
372operation @samp{r} (replace). In particular, the combination @samp{qu} is
373not allowed, since checking the timestamps would lose any speed
374advantage from the operation @samp{q}.
375
376@item v
377This modifier requests the @emph{verbose} version of an operation. Many
378operations display additional information, such as filenames processed,
379when the modifier @samp{v} is appended.
4d9b5d5a
DM
380
381@item V
382This modifier shows the version number of @code{ar}.
765a273f
RP
383@end table
384
385@node ar-scripts, , ar-cmdline, ar
386@section Controlling @code{ar} with a script
387
388@smallexample
389ar -M [ <@var{script} ]
390@end smallexample
391
392@cindex MRI compatibility, @code{ar}
393@cindex scripts, @code{ar}
394If you use the single command-line option @samp{-M} with @code{ar}, you
395can control its operation with a rudimentary command language. This
e31e9a8d 396form of @code{ar} operates interactively if standard input is coming
765a273f
RP
397directly from a terminal. During interactive use, @code{ar} prompts for
398input (the prompt is @samp{AR >}), and continues executing even after
399errors. If you redirect standard input to a script file, no prompts are
e31e9a8d 400issued, and @code{ar} abandons execution (with a nonzero exit code)
765a273f
RP
401on any error.
402
403The @code{ar} command language is @emph{not} designed to be equivalent
404to the command-line options; in fact, it provides somewhat less control
405over archives. The only purpose of the command language is to ease the
406transition to GNU @code{ar} for developers who already have scripts
407written for the MRI ``librarian'' program.
408
409The syntax for the @code{ar} command language is straightforward:
410@itemize @bullet
411@item
412commands are recognized in upper or lower case; for example, @code{LIST}
413is the same as @code{list}. In the following descriptions, commands are
414shown in upper case for clarity.
415
416@item
417a single command may appear on each line; it is the first word on the
418line.
419
420@item
421empty lines are allowed, and have no effect.
422
423@item
424comments are allowed; text after either of the characters @samp{*}
425or @samp{;} is ignored.
426
427@item
428Whenever you use a list of names as part of the argument to an @code{ar}
429command, you can separate the individual names with either commas or
430blanks. Commas are shown in the explanations below, for clarity.
431
432@item
433@samp{+} is used as a line continuation character; if @samp{+} appears
434at the end of a line, the text on the following line is considered part
435of the current command.
436@end itemize
437
438Here are the commands you can use in @code{ar} scripts, or when using
439@code{ar} interactively. Three of them have special significance:
440
441@code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
442a temporary file required for most of the other commands.
443
444@code{SAVE} commits the changes so far specified by the script. Prior
445to @code{SAVE}, commands affect only the temporary copy of the current
446archive.
447
448@table @code
449@item ADDLIB @var{archive}
450@itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
451Add all the contents of @var{archive} (or, if specified, each named
452@var{module} from @var{archive}) to the current archive.
453
454Requires prior use of @code{OPEN} or @code{CREATE}.
455
456@item ADDMOD @var{file}, @var{file}, @dots{} @var{file}
457@c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
458@c else like "ar q..."
459Add each named @var{file} as a module in the current archive.
460
461Requires prior use of @code{OPEN} or @code{CREATE}.
462
463@item CLEAR
464Discard the contents of the current archive, cancelling the effect of
465any operations since the last @code{SAVE}. May be executed (with no
466effect) even if no current archive is specified.
467
468@item CREATE @var{archive}
469Creates an archive, and makes it the current archive (required for many
470other commands). The new archive is created with a temporary name; it
471is not actually saved as @var{archive} until you use @code{SAVE}.
472You can overwrite existing archives; similarly, the contents of any
473existing file named @var{archive} will not be destroyed until @code{SAVE}.
474
475@item DELETE @var{module}, @var{module}, @dots{} @var{module}
476Delete each listed @var{module} from the current archive; equivalent to
477@samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
478
479Requires prior use of @code{OPEN} or @code{CREATE}.
480
481@item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
482@itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
483List each named @var{module} present in @var{archive}. The separate
484command @code{VERBOSE} specifies the form of the output: when verbose
485output is off, output is like that of @samp{ar -t @var{archive}
b703c078
DM
486@var{module}@dots{}}. When verbose output is on, the listing is like
487@samp{ar -tv @var{archive} @var{module}@dots{}}.
765a273f
RP
488
489Output normally goes to the standard output stream; however, if you
490specify @var{outputfile} as a final argument, @code{ar} directs the
491output to that file.
492
493@item END
494Exit from @code{ar}, with a @code{0} exit code to indicate successful
495completion. This command does not save the output file; if you have
496changed the current archive since the last @code{SAVE} command, those
497changes are lost.
498
499@item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
500Extract each named @var{module} from the current archive, writing them
501into the current directory as separate files. Equivalent to @samp{ar -x
b703c078 502@var{archive} @var{module}@dots{}}.
765a273f
RP
503
504Requires prior use of @code{OPEN} or @code{CREATE}.
505
506@ignore
507@c FIXME Tokens but no commands???
508@item FULLDIR
509
510@item HELP
511@end ignore
512
513@item LIST
514Display full contents of the current archive, in ``verbose'' style
515regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
516tv @var{archive}}). (This single command is a GNU @code{ld}
517enhancement, rather than present for MRI compatibility.)
518
519Requires prior use of @code{OPEN} or @code{CREATE}.
520
521@item OPEN @var{archive}
522Opens an existing archive for use as the current archive (required for
523many other commands). Any changes as the result of subsequent commands
524will not actually affect @var{archive} until you next use @code{SAVE}.
525
526@item REPLACE @var{module}, @var{module}, @dots{} @var{module}
527In the current archive, replace each existing @var{module} (named in
528the @code{REPLACE} arguments) from files in the current working directory.
529To execute this command without errors, both the file, and the module in
530the current archive, must exist.
531
532Requires prior use of @code{OPEN} or @code{CREATE}.
533
534@item VERBOSE
535Toggle an internal flag governing the output from @code{DIRECTORY}.
536When the flag is on, @code{DIRECTORY} output matches output from
b703c078 537@samp{ar -tv }@dots{}.
765a273f
RP
538
539@item SAVE
540Commit your changes to the current archive, and actually save it as a
541file with the name specified in the last @code{CREATE} or @code{OPEN}
542command.
543
544Requires prior use of @code{OPEN} or @code{CREATE}.
c72af735
RP
545
546@end table
547
df14d957
ILT
548@node objcopy, nm, ar, Top
549@chapter objcopy
e31e9a8d
JO
550
551@smallexample
df14d957
ILT
552objcopy [ -F @var{format} | --format=@var{format} ]
553 [ -I @var{format} | --input-format=@var{format} ]
554 [ -O @var{format} | --output-format=@var{format} ]
555 [ -S | --strip-all ] [ -g | --strip-debug ]
556 [ -x | --discard-all ] [ -X | --discard-locals ]
557 [ -v | --verbose ] [ -V | --version ]
558 @var{infile} [@var{outfile}]
e31e9a8d
JO
559@end smallexample
560
df14d957
ILT
561The GNU @code{objcopy} utility copies the contents of an object file to
562another. @code{objcopy} uses the GNU BFD Library to read and write the
918c2f61
PB
563object files. It can write the destination object file in a format
564different from that of the source object file. The exact behavior of
df14d957 565@code{objcopy} is controlled by command-line options.
e31e9a8d 566
df14d957
ILT
567@code{objcopy} creates temporary files to do its translations and
568deletes them afterward. @code{objcopy} uses BFD to do all its
e31e9a8d
JO
569translation work; it knows about all the formats BFD knows about, and
570thus is able to recognize most formats without being told explicitly.
571@xref{BFD,,BFD,ld.info,Using LD, the GNU linker}.
572
573@table @code
918c2f61
PB
574@item @var{infile}
575@itemx @var{outfile}
576The source and output files respectively.
df14d957 577If you do not specify @var{outfile}, @code{objcopy} creates a
918c2f61
PB
578temporary file and destructively renames the result with
579the name of the input file.
580
581@item -I @var{format}
582@itemx --input-format=@var{format}
ec40bbb8 583Consider the source file's object format to be @var{format}, rather than
918c2f61
PB
584attempting to deduce it.
585
586@item -O @var{format}
587@itemx --output-format=@var{format}
ec40bbb8 588Write the output file using the object format @var{format}.
918c2f61
PB
589
590@item -F @var{format}
591@itemx --format=@var{format}
592Use @var{format} as the object format for both the input and the output
593file; i.e. simply transfer data from source to destination with no
594translation.
e31e9a8d 595
918c2f61
PB
596@item -S
597@itemx --strip-all
598Do not copy relocation and symbol information from the source file.
e31e9a8d 599
918c2f61
PB
600@item -g
601@itemx --strip-debug
602Do not copy debugging symbols from the source file.
e31e9a8d 603
918c2f61
PB
604@item -x
605@itemx --discard-all
606Do not copy non-global symbols from the source file.
607@c FIXME any reason to prefer "non-global" to "local" here?
e31e9a8d 608
918c2f61
PB
609@item -X
610@itemx --discard-locals
611Do not copy compiler-generated local symbols.
612(These usually start with @samp{L} or @samp{.}.)
e31e9a8d
JO
613
614@item -V
918c2f61 615@itemx --version
df14d957 616Show the version number of @code{objcopy}.
e31e9a8d 617
918c2f61
PB
618@item -v
619@itemx --verbose
620Verbose output: list all object files modified. In the case of
df14d957 621archives, @samp{objcopy -V} lists all members of the archive.
e31e9a8d
JO
622@end table
623
8b2c2275
RP
624@iftex
625@node ld
c72af735
RP
626@chapter ld
627@cindex linker
628@kindex ld
629The GNU linker @code{ld} is now described in a separate manual.
27e94bd5 630@xref{Top,, Overview,, Using LD: the GNU linker}.
8b2c2275 631@end iftex
c72af735 632
df14d957 633@node nm, objdump, objcopy, Top
c72af735
RP
634@chapter nm
635@cindex symbols
636@kindex nm
637
638@smallexample
4d9b5d5a 639nm [ -a | --debug-syms ] [ -g | --extern-only ]
6cfbdb50
DM
640 [ -s | --print-armap ] [ -A | -o | --print-file-name ]
641 [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
4d9b5d5a 642 [ -r | --reverse-sort ] [ -u | --undefined-only ]
6cfbdb50
DM
643 [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ]
644 [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ]
645 [ -V | --version ] [ @var{objfile}@dots{} ]
c72af735
RP
646@end smallexample
647
b703c078 648GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}.
6cfbdb50
DM
649If no object files are listed as arguments, @code{nm} assumes
650@file{a.out}.
651
652For each symbol, @code{nm} shows:
653
654@itemize @bullet
655@item
656The symbol value, in the radix selected by options (see below), or
657hexadecimal by default.
658
659@item
660The symbol type. At least the following types are used; others are, as
661well, depending on the object file format. If lowercase, the symbol is
662local; if uppercase, the symbol is global (external).
663
664@c Some more detail on exactly what these symbol types are used for
665@c would be nice.
666@table @code
667@item A
668Absolute.
669
670@item B
671BSS (uninitialized data).
672
673@item C
674Common.
675
676@item D
677Initialized data.
678
679@item I
680Indirect reference.
681
682@item T
683Text (program code).
684
685@item U
686Undefined.
687@end table
688
689@item
690The symbol name.
691@end itemize
c72af735
RP
692
693The long and short forms of options, shown here as alternatives, are
694equivalent.
695
696@table @code
6cfbdb50
DM
697@item -A
698@itemx -o
699@itemx --print-file-name
700@cindex input file name
701@cindex file name
702@cindex source file name
703Precede each symbol by the name of the input file (or archive element)
704in which it was found, rather than identifying the input file once only,
705before all of its symbols.
c72af735
RP
706
707@item -a
918c2f61 708@itemx --debug-syms
c72af735 709@cindex debugging symbols
6cfbdb50
DM
710Display all symbols, even debugger-only symbols; normally these are not
711listed.
712
713@item -f @var{format}
714@itemx --format=@var{format}
715Use the output format @var{format}, which can be @code{bsd},
716@code{sysv}, or @code{posix}. The default is @code{bsd}.
717Only the first character of @var{format} is significant, it can be
718either upper or lower case.
c72af735
RP
719
720@item -g
918c2f61 721@itemx --extern-only
c72af735
RP
722@cindex external symbols
723Display only external symbols.
724
725@item -p
918c2f61 726@itemx --no-sort
c72af735 727@cindex sorting symbols
6cfbdb50
DM
728Don't bother to sort the symbols in any order; print them in the order
729encountered.
730
731@item -P
732@itemx --portability
733Use the POSIX.2 standard output format instead of the default format.
734Equivalent to @samp{-f posix}.
c72af735
RP
735
736@item -n
6cfbdb50 737@itemx -v
918c2f61 738@itemx --numeric-sort
ec40bbb8
DM
739Sort symbols numerically by their addresses, rather than alphabetically
740by their names.
c72af735
RP
741
742@item -s
918c2f61 743@itemx --print-armap
c72af735
RP
744@cindex symbol index, listing
745When listing symbols from archive members, include the index: a mapping
ec40bbb8
DM
746(stored in the archive by @code{ar} or @code{ranlib}) of which modules
747contain definitions for which names.
c72af735 748
c72af735 749@item -r
918c2f61 750@itemx --reverse-sort
ec40bbb8 751Reverse the order of the sort (whether numeric or alphabetic); let the
c72af735
RP
752last come first.
753
6cfbdb50
DM
754@item -t @var{radix}
755@itemx --radix=@var{radix}
756Use @var{radix} as the radix for printing the symbol values. It must be
757@samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
758
ec40bbb8 759@item --target=@var{bfdname}
c72af735
RP
760@cindex object code format
761Specify an object code format other than your system's default format.
762@xref{objdump}, for information on listing available formats.
c72af735
RP
763
764@item -u
918c2f61 765@itemx --undefined-only
c72af735
RP
766@cindex external symbols
767@cindex undefined symbols
768Display only undefined symbols (those external to each object file).
769
6cfbdb50
DM
770@item -V
771@itemx --version
772Show the version number of @code{nm}.
c72af735
RP
773@end table
774
775@node objdump, ranlib, nm, Top
776@chapter objdump
777
778@cindex object file information
779@kindex objdump
780
781@smallexample
4d9b5d5a
DM
782objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ]
783 [ -h | --header ] [ -i ] [ -j @var{section} ] [ -l ]
784 [ -m @var{machine} ] [ -r | --reloc ] [ -s ]
785 [ --stabs ] [ -t | --syms ] [ -x ]
786 @var{objfile}@dots{}
c72af735
RP
787@end smallexample
788
789@code{objdump} displays information about one or more object files.
790The options control what particular information to display. This
791information is mostly useful to programmers who are working on the
792compilation tools, as opposed to programmers who just want their
793program to compile and work.
794
795The long and short forms of options, shown here as alternatives, are
796equivalent.
797
798@table @code
b703c078 799@item @var{objfile}@dots{}
c72af735
RP
800The object files to be examined. When you specify archives,
801@code{objdump} shows information on each of the member object files.
802
803@item -a
804@c print_arelt_descr
805@cindex archive headers
ec40bbb8 806If any of the @var{objfile} files are archives, display the archive
c72af735
RP
807header information (in a format similar to @samp{ls -l}). Besides the
808information you could list with @samp{ar tv}, @samp{objdump -a} shows
809the object file format of each archive member.
810
c5f0c938 811@c suggest longname --target or --format or --bfd
c72af735
RP
812@item -b @var{bfdname}
813@cindex object code format
ec40bbb8
DM
814Specify that the object-code format for the object files is
815@var{bfdname}. This option may not be necessary; @var{objdump} can
816automatically recognize many formats.
817
818For example,
c72af735
RP
819@example
820objdump -b oasys -m vax -h fu.o
821@end example
822@noindent
ec40bbb8
DM
823displays summary information from the section headers (@samp{-h}) of
824@file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
c72af735
RP
825file in the format produced by Oasys compilers. You can list the
826formats available with the @samp{-i} option.
827
828@item -d
829@cindex disassembling object code
830@cindex machine instructions
831Disassemble. Display the assembler mnemonics for the machine
ec40bbb8 832instructions from @var{objfile}.
c72af735
RP
833
834@item -f
835@cindex object file header
836File header. Display summary information from the overall header of
ec40bbb8 837each of the @var{objfile} files.
c72af735
RP
838
839@item -h
c5f0c938 840@itemx --header
c72af735
RP
841@cindex section headers
842Header. Display summary information from the section headers of the
843object file.
844
845@item -i
846@cindex architectures available
847@cindex object formats available
848Display a list showing all architectures and object formats available
ec40bbb8 849for specification with @samp{-b} or @samp{-m}.
c72af735 850
c5f0c938 851@c suggest longname --section
c72af735
RP
852@item -j @var{name}
853@cindex section information
ec40bbb8 854Display information only for section @var{name}.
c72af735 855
c5f0c938 856@c suggest longname --label or --linespec
c72af735
RP
857@item -l
858@cindex source filenames for object files
859Label the display (using debugging information) with the source filename
860and line numbers corresponding to the object code shown.
861
c5f0c938 862@c suggest longname --architecture
c72af735
RP
863@item -m @var{machine}
864@cindex architecture
ec40bbb8 865Specify that the object files @var{objfile} are for architecture
c72af735
RP
866@var{machine}. You can list available architectures using the @samp{-i}
867option.
868
869@item -r
c5f0c938 870@itemx --reloc
c72af735
RP
871@cindex relocation entries, in object file
872Relocation. Print the relocation entries of the file.
873
874@item -s
875@cindex sections, full contents
876@cindex object file sections
877Display the full contents of any sections requested.
878
c5f0c938
JG
879@item --stabs
880@cindex stab
881@cindex .stab
882@cindex debug symbols
883@cindex ELF object file format
c3c93fda
JG
884Display the full contents of any sections requested. Display the
885contents of the .stab and .stab.index and .stab.excl sections from an
886ELF file. This is only useful on systems (such as Solaris 2.0) in which
887@code{.stab} debugging symbol-table entries are carried in an ELF
888section. In most other file formats, debugging symbol-table entries are
c5f0c938
JG
889interleaved with linkage symbols, and are visible in the @samp{--syms}
890output.
891
c72af735 892@item -t
c5f0c938 893@itemx --syms
c72af735
RP
894@cindex symbol table entries, printing
895Symbol Table. Print the symbol table entries of the file.
896This is similar to the information provided by the @samp{nm} program.
897
898@item -x
899@cindex all header information, object file
900@cindex header information, all
901Display all available header information, including the symbol table and
902relocation entries. Using @samp{-x} is equivalent to specifying all of
903@samp{-a -f -h -r -t}.
904
905@end table
906
907@node ranlib, size, objdump, Top
908@chapter ranlib
909
910@kindex ranlib
911@cindex archive contents
912@cindex symbol index
913
914@smallexample
4d9b5d5a 915ranlib [-vV] @var{archive}
c72af735
RP
916@end smallexample
917
ec40bbb8 918@code{ranlib} generates an index to the contents of an archive and
c72af735
RP
919stores it in the archive. The index lists each symbol defined by a
920member of an archive that is a relocatable object file.
921
918c2f61 922You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
c72af735 923
ec40bbb8 924An archive with such an index speeds up linking to the library and
c72af735
RP
925allows routines in the library to call each other without regard to
926their placement in the archive.
927
928The GNU @code{ranlib} program is another form of GNU @code{ar}; running
929@code{ranlib} is completely equivalent to executing @samp{ar -s}.
930@xref{ar}.
931
4d9b5d5a
DM
932@table @code
933@item -v
934@itemx -V
935Show the version number of @code{ranlib}.
c3f471a4 936@end table
4d9b5d5a 937
ba7c8e29 938@node size, strings, ranlib, Top
c72af735
RP
939@chapter size
940
941@kindex size
942@cindex section sizes
943
944@smallexample
4d9b5d5a
DM
945size [ -A | -B | --format=@var{compatibility} ]
946 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
947 [ --target=@var{bfdname} ] [ -V | --version ]
948 @var{objfile}@dots{}
c72af735
RP
949@end smallexample
950
951The GNU @code{size} utility lists the section sizes---and the total
ec40bbb8
DM
952size---for each of the object or archive files @var{objfile} in its
953argument list. By default, one line of output is generated for each
954object file or each module in an archive.
c72af735
RP
955
956The command line options have the following meanings:
957@table @code
b703c078 958@item @var{objfile}@dots{}
c72af735
RP
959The object files to be examined.
960
961@item -A
962@itemx -B
ec40bbb8 963@itemx --format=@var{compatibility}
c72af735
RP
964@cindex size display format
965Using one of these options, you can choose whether the output from GNU
966@code{size} resembles output from System V @code{size} (using @samp{-A},
ec40bbb8
DM
967or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
968@samp{--format=berkeley}). The default is the one-line format similar to
c72af735 969Berkeley's.
918c2f61
PB
970@c Bonus for doc-source readers: you can also say --format=strange (or
971@c anything else that starts with 's') for sysv, and --format=boring (or
c72af735
RP
972@c anything else that starts with 'b') for Berkeley.
973
974Here is an example of the Berkeley (default) format of output from
975@code{size}:
976@smallexample
4d9b5d5a 977size --format Berkeley ranlib size
c72af735
RP
978text data bss dec hex filename
979294880 81920 11592 388392 5ed28 ranlib
980294880 81920 11888 388688 5ee50 size
981@end smallexample
982
983@noindent
984This is the same data, but displayed closer to System V conventions:
985
986@smallexample
4d9b5d5a 987size --format SysV ranlib size
c72af735
RP
988ranlib :
989section size addr
990.text 294880 8192
991.data 81920 303104
992.bss 11592 385024
993Total 388392
994
995
996size :
997section size addr
998.text 294880 8192
999.data 81920 303104
1000.bss 11888 385024
1001Total 388688
1002@end smallexample
1003
918c2f61 1004@item --help
c72af735
RP
1005Show a summary of acceptable arguments and options.
1006
1007@item -d
1008@itemx -o
1009@itemx -x
ec40bbb8 1010@itemx --radix=@var{number}
c72af735
RP
1011@cindex size number format
1012@cindex radix for section sizes
1013Using one of these options, you can control whether the size of each
ec40bbb8
DM
1014section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1015(@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1016@samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
c72af735
RP
1017values (8, 10, 16) are supported. The total size is always given in two
1018radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1019octal and hexadecimal if you're using @samp{-o}.
1020
ec40bbb8 1021@item --target=@var{bfdname}
c72af735 1022@cindex object code format
ec40bbb8
DM
1023Specify that the object-code format for @var{objfile} is
1024@var{bfdname}. This option may not be necessary; @code{size} can
c72af735
RP
1025automatically recognize many formats. @xref{objdump}, for information
1026on listing available formats.
1027
1028@item -V
918c2f61 1029@itemx --version
4d9b5d5a 1030Display the version number of @code{size}.
c72af735
RP
1031@end table
1032
ba7c8e29
DM
1033@node strings, strip, size, Top
1034@chapter strings
1035@kindex strings
1036@cindex listings strings
1037@cindex printing strings
1038@cindex strings, printing
1039
1040@smallexample
1041strings [-afhov] [-n @var{min-len}] [-@var{min-len}] [-t @var{radix}] [-]
1042 [--all] [--print-file-name] [--bytes=@var{min-len}] [--radix=@var{radix}]
1043 [--help] [--version] @var{file}@dots{}
1044@end smallexample
1045
1046For each @var{file} given, GNU @code{strings} prints the printable
1047character sequences that are at least 4 characters long (or the number
1048given with the options below) and are followed by a NUL or newline
1049character. By default, it only prints the strings from the initialized
1050data sections of object files; for other types of files, it prints the
1051strings from the whole file.
1052
1053@code{strings} is mainly useful for determining the contents of non-text
1054files.
1055
1056@table @code
1057@item -a
1058@itemx --all
1059@itemx -
1060Do not scan only the initialized data section of object files; scan
1061the whole files.
1062
1063@item -f
1064@itemx --print-file-name
1065Print the name of the file before each string.
1066
1067@item -h
1068@itemx --help
1069Print a summary of the program usage on the standard output and exit.
1070
1071@item -n @var{min-len}
1072@itemx -@var{min-len}
1073@itemx --bytes=@var{min-len}
1074Print sequences of characters that are at least @var{min-len} characters
1075long, instead of the default 4.
1076
1077@item -o
1078Like @samp{-t o}.
1079Some other versions of @code{strings} have @samp{-o} act like @samp{-t d} instead.
1080Since we can not be compatible with both ways, we simply chose one.
1081
1082@item -t @var{radix}
1083@itemx --radix=@var{radix}
1084Print the offset within the file before each string. The single
1085character argument specifies the radix of the offset---@samp{o} for
1086octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1087
1088@item -v
1089@itemx --version
1090Print the program version number on the standard output and exit.
1091@end table
1092
1093@node strip, c++filt, strings, Top
c72af735
RP
1094@chapter strip
1095
1096@kindex strip
1097@cindex removing symbols
1098@cindex discarding symbols
1815e42c 1099@cindex symbols, discarding
c72af735
RP
1100
1101@smallexample
b703c078
DM
1102strip [ -F @var{format} | --format=@var{format} | --target=@var{format} ]
1103 [ -I @var{format} | --input-format=@var{format} ]
1104 [ -O @var{format} | --output-format=@var{format} ]
1105 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
1106 [ -x | --discard-all ] [ -X | --discard-locals ]
918c2f61 1107 [ -v | --verbose ] [ -V | --version ]
b703c078 1108 @var{objfile}@dots{}
c72af735
RP
1109@end smallexample
1110
e31e9a8d 1111GNU @code{strip} discards all symbols from object files
ec40bbb8 1112@var{objfile}. The list of object files may include archives.
c72af735
RP
1113
1114@code{strip} will not execute unless at least one object file is listed.
1115
ec40bbb8 1116@code{strip} modifies the files named in its argument,
c72af735 1117rather than writing modified copies under different names.
c72af735 1118
c72af735 1119@table @code
918c2f61
PB
1120@item -I @var{format}
1121@itemx --input-format=@var{format}
ec40bbb8
DM
1122Treat the original @var{objfile} as a file with the object
1123code format @var{format}.
918c2f61
PB
1124
1125@item -O @var{format}
1126@itemx --output-format=@var{format}
ec40bbb8 1127Replace @var{objfile} with a file in the output format @var{format}.
918c2f61
PB
1128
1129@item -F @var{format}
1130@itemx --format=@var{format}
b703c078 1131@itemx --target=@var{format}
ec40bbb8
DM
1132Treat the original @var{objfile} as a file with the object
1133code format @var{format}, and rewrite it in the same format.
918c2f61 1134
b703c078
DM
1135@item -s
1136@itemx --strip-all
1137Remove all symbols.
1138
918c2f61
PB
1139@item -g
1140@itemx -S
1141@itemx --strip-debug
1142Remove debugging symbols only.
1143
1144@item -x
1145@itemx --discard-all
1146Remove non-global symbols.
1147
1148@item -X
1149@itemx --discard-locals
1150Remove compiler-generated local symbols.
ec40bbb8 1151(These usually start with @samp{L} or @samp{.}.)
918c2f61
PB
1152
1153@item -V
1154@itemx --version
ec40bbb8 1155Show the version number for @code{strip}.
918c2f61 1156
1815e42c 1157@item -v
918c2f61
PB
1158@itemx --verbose
1159Verbose output: list all object files modified. In the case of
1269d441 1160archives, @samp{strip -v} lists all members of the archive.
c72af735
RP
1161@end table
1162
b6216af2
PB
1163@node c++filt, Index, strip, Top
1164@chapter c++filt
1165
1166@kindex c++filt
1167@cindex demangling C++ symbols
1168
6c69b6bd
JO
1169The C++ language provides function overloading, which means that you can
1170write many functions with the same name (providing each takes parameters
1171of different types). All C++ function names are encoded into a
1172low-level assembly label (in some circles this is described as
1173@dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1174decodes (@dfn{demangles}) low-level names into user-level names so that
1175the linker can keep these overloaded functions from clashing.
1176
1177Every alphanumeric word (consisting of letters, digits, underscores,
1178dollars, or periods) seen in the input is a potential label. If the
1179label decodes into a C++ name, the C++ name replaces the low-level
1180name in the output.
b6216af2
PB
1181
1182A typical use of @code{c++filt} is to pipe the output of @code{nm}
6c69b6bd
JO
1183though it, using @code{c++filt} as a filter:
1184
1185@example
1186nm @var{objfile} | c++filt
1187@end example
1188
1189You can also use @code{c++filt} to decipher individual symbols:
1190
1191@example
1192c++filt @var{symbol}
1193@end example
1194
1195All results are printed on the standard output.
b6216af2 1196
e32341a7
RP
1197Note that on some systems, both the C and C++ compilers put an
1198underscore in front of every name. (I.e. the C name @code{foo} gets the
1199low-level name @code{_foo}.) On such systems, @code{c++filt} removes
1200any initial underscore of a potential label.
b6216af2 1201
5eac46ae
JO
1202@quotation
1203@emph{Warning:} @code{c++filt} is a new utility, and the details of its
1204user interface are subject to change in future releases. In particular,
1205a command-line option may be required in the the future to decode a name
1206passed as an argument on the command line; in other words,
1207
1208@example
1209c++filt @var{SYMBOL}
1210@end example
1211
1212@noindent
1213may in a future release become
1214
1215@example
1216c++filt @var{flag} @var{SYMBOL}
1217@end example
1218@end quotation
1219
b6216af2 1220@node Index, , c++filt, Top
c72af735
RP
1221@unnumbered Index
1222
1223@printindex cp
1224
1225@contents
1226@bye
This page took 0.143012 seconds and 4 git commands to generate.