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