PR 10980
[deliverable/binutils-gdb.git] / binutils / doc / binutils.texi
CommitLineData
252b5132
RH
1\input texinfo @c -*- Texinfo -*-
2@setfilename binutils.info
e016ec1f
NC
3@settitle @sc{gnu} Binary Utilities
4@finalout
5@synindex ky cp
8c2bc687 6
dff70155 7@c man begin INCLUDE
c428fa83 8@include bfdver.texi
dff70155 9@c man end
252b5132 10
0e9517a9 11@copying
0285c67d 12@c man begin COPYRIGHT
2423fbe6 13Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
71c57c16 142000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
252b5132 15
0285c67d 16Permission is granted to copy, distribute and/or modify this document
793c5807 17under the terms of the GNU Free Documentation License, Version 1.3
0285c67d
NC
18or any later version published by the Free Software Foundation;
19with no Invariant Sections, with no Front-Cover Texts, and with no
20Back-Cover Texts. A copy of the license is included in the
947ed062 21section entitled ``GNU Free Documentation License''.
252b5132 22
0285c67d 23@c man end
0e9517a9 24@end copying
252b5132 25
e016ec1f
NC
26@dircategory Software development
27@direntry
28* Binutils: (binutils). The GNU binary utilities.
29@end direntry
30
31@dircategory Individual utilities
32@direntry
33* addr2line: (binutils)addr2line. Convert addresses to file and line.
34* ar: (binutils)ar. Create, modify, and extract from archives.
35* c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols.
36* cxxfilt: (binutils)c++filt. MS-DOS name for c++filt.
37* dlltool: (binutils)dlltool. Create files needed to build and use DLLs.
38* nlmconv: (binutils)nlmconv. Converts object code into an NLM.
39* nm: (binutils)nm. List symbols from object files.
40* objcopy: (binutils)objcopy. Copy and translate object files.
41* objdump: (binutils)objdump. Display information from object files.
42* ranlib: (binutils)ranlib. Generate index to archive contents.
43* readelf: (binutils)readelf. Display the contents of ELF format files.
44* size: (binutils)size. List section sizes and total size.
45* strings: (binutils)strings. List printable strings from files.
46* strip: (binutils)strip. Discard symbols.
30fd33bb 47* elfedit: (binutils)elfedit. Update the ELF header of ELF files.
e016ec1f
NC
48* windmc: (binutils)windmc. Generator for Windows message resources.
49* windres: (binutils)windres. Manipulate Windows resources.
50@end direntry
51
252b5132 52@titlepage
252b5132 53@title The @sc{gnu} Binary Utilities
e49e529d
JM
54@ifset VERSION_PACKAGE
55@subtitle @value{VERSION_PACKAGE}
56@end ifset
252b5132
RH
57@subtitle Version @value{VERSION}
58@sp 1
36607f99 59@subtitle @value{UPDATED}
252b5132
RH
60@author Roland H. Pesch
61@author Jeffrey M. Osier
62@author Cygnus Support
63@page
64
65@tex
66{\parskip=0pt \hfill Cygnus Support\par \hfill
e016ec1f 67Texinfo \texinfoversion\par }
252b5132
RH
68@end tex
69
70@vskip 0pt plus 1filll
e016ec1f 71@insertcopying
252b5132 72@end titlepage
4ecceb71 73@contents
252b5132
RH
74
75@node Top
76@top Introduction
77
78@cindex version
947ed062 79This brief manual contains documentation for the @sc{gnu} binary
e49e529d
JM
80utilities
81@ifset VERSION_PACKAGE
82@value{VERSION_PACKAGE}
83@end ifset
84version @value{VERSION}:
252b5132
RH
85
86@iftex
87@table @code
88@item ar
89Create, modify, and extract from archives
90
91@item nm
92List symbols from object files
93
94@item objcopy
95Copy and translate object files
96
97@item objdump
98Display information from object files
99
100@item ranlib
101Generate index to archive contents
102
103@item readelf
104Display the contents of ELF format files.
105
106@item size
107List file section sizes and total size
108
109@item strings
110List printable strings from files
111
112@item strip
113Discard symbols
114
30fd33bb
L
115@item elfedit
116Update the ELF header of ELF files.
117
252b5132 118@item c++filt
9d51cc66
ILT
119Demangle encoded C++ symbols (on MS-DOS, this program is named
120@code{cxxfilt})
252b5132
RH
121
122@item addr2line
123Convert addresses into file names and line numbers
124
125@item nlmconv
126Convert object code into a Netware Loadable Module
127
128@item windres
129Manipulate Windows resources
130
692ed3e7
NC
131@item windmc
132Genertor for Windows message resources
133
252b5132
RH
134@item dlltool
135Create the files needed to build and use Dynamic Link Libraries
136@end table
137@end iftex
138
cf055d54 139This document is distributed under the terms of the GNU Free
793c5807
NC
140Documentation License version 1.3. A copy of the license is included
141in the section entitled ``GNU Free Documentation License''.
cf055d54 142
252b5132
RH
143@menu
144* ar:: Create, modify, and extract from archives
145* nm:: List symbols from object files
146* objcopy:: Copy and translate object files
147* objdump:: Display information from object files
148* ranlib:: Generate index to archive contents
fff279a7 149* readelf:: Display the contents of ELF format files
252b5132
RH
150* size:: List section sizes and total size
151* strings:: List printable strings from files
152* strip:: Discard symbols
30fd33bb 153* elfedit:: Update the ELF header of ELF files
252b5132 154* c++filt:: Filter to demangle encoded C++ symbols
9d51cc66 155* cxxfilt: c++filt. MS-DOS name for c++filt
252b5132
RH
156* addr2line:: Convert addresses to file and line
157* nlmconv:: Converts object code into an NLM
158* windres:: Manipulate Windows resources
692ed3e7 159* windmc:: Generator for Windows message resources
252b5132 160* dlltool:: Create files needed to build and use DLLs
07012eee 161* Common Options:: Command-line options for all utilities
fff279a7 162* Selecting the Target System:: How these utilities determine the target
252b5132 163* Reporting Bugs:: Reporting Bugs
cf055d54 164* GNU Free Documentation License:: GNU Free Documentation License
fa0d8a3e 165* Binutils Index:: Binutils Index
252b5132
RH
166@end menu
167
168@node ar
169@chapter ar
170
171@kindex ar
172@cindex archives
173@cindex collections of files
0285c67d
NC
174
175@c man title ar create, modify, and extract from archives
176
252b5132 177@smallexample
ce3c775b 178ar [@option{--plugin} @var{name}] [-]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] @var{archive} [@var{member}@dots{}]
252b5132
RH
179ar -M [ <mri-script ]
180@end smallexample
181
0285c67d
NC
182@c man begin DESCRIPTION ar
183
c7c55b78 184The @sc{gnu} @command{ar} program creates, modifies, and extracts from
252b5132
RH
185archives. An @dfn{archive} is a single file holding a collection of
186other files in a structure that makes it possible to retrieve
187the original individual files (called @dfn{members} of the archive).
188
189The original files' contents, mode (permissions), timestamp, owner, and
190group are preserved in the archive, and can be restored on
c1c0eb9e 191extraction.
252b5132
RH
192
193@cindex name length
c7c55b78
NC
194@sc{gnu} @command{ar} can maintain archives whose members have names of any
195length; however, depending on how @command{ar} is configured on your
252b5132
RH
196system, a limit on member-name length may be imposed for compatibility
197with archive formats maintained with other tools. If it exists, the
198limit is often 15 characters (typical of formats related to a.out) or 16
199characters (typical of formats related to coff).
200
201@cindex libraries
c7c55b78 202@command{ar} is considered a binary utility because archives of this sort
252b5132
RH
203are most often used as @dfn{libraries} holding commonly needed
204subroutines.
205
206@cindex symbol index
c7c55b78 207@command{ar} creates an index to the symbols defined in relocatable
252b5132 208object modules in the archive when you specify the modifier @samp{s}.
c7c55b78 209Once created, this index is updated in the archive whenever @command{ar}
252b5132
RH
210makes a change to its contents (save for the @samp{q} update operation).
211An archive with such an index speeds up linking to the library, and
212allows routines in the library to call each other without regard to
213their placement in the archive.
214
215You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
c7c55b78
NC
216table. If an archive lacks the table, another form of @command{ar} called
217@command{ranlib} can be used to add just the table.
252b5132 218
a8da6403
NC
219@cindex thin archives
220@sc{gnu} @command{ar} can optionally create a @emph{thin} archive,
221which contains a symbol index and references to the original copies
222of the member files of the archives. Such an archive is useful
223for building libraries for use within a local build, where the
224relocatable objects are expected to remain available, and copying the
225contents of each object would only waste time and space. Thin archives
226are also @emph{flattened}, so that adding one or more archives to a
227thin archive will add the elements of the nested archive individually.
228The paths to the elements of the archive are stored relative to the
229archive itself.
230
c7c55b78
NC
231@cindex compatibility, @command{ar}
232@cindex @command{ar} compatibility
233@sc{gnu} @command{ar} is designed to be compatible with two different
252b5132 234facilities. You can control its activity using command-line options,
c7c55b78
NC
235like the different varieties of @command{ar} on Unix systems; or, if you
236specify the single command-line option @option{-M}, you can control it
252b5132
RH
237with a script supplied via standard input, like the MRI ``librarian''
238program.
239
0285c67d
NC
240@c man end
241
252b5132 242@menu
c7c55b78
NC
243* ar cmdline:: Controlling @command{ar} on the command line
244* ar scripts:: Controlling @command{ar} with a script
252b5132
RH
245@end menu
246
247@page
248@node ar cmdline
947ed062 249@section Controlling @command{ar} on the Command Line
252b5132
RH
250
251@smallexample
0285c67d 252@c man begin SYNOPSIS ar
ce3c775b 253ar [@option{--plugin} @var{name}] [@option{-X32_64}] [@option{-}]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] @var{archive} [@var{member}@dots{}]
0285c67d 254@c man end
252b5132
RH
255@end smallexample
256
c7c55b78
NC
257@cindex Unix compatibility, @command{ar}
258When you use @command{ar} in the Unix style, @command{ar} insists on at least two
252b5132
RH
259arguments to execute: one keyletter specifying the @emph{operation}
260(optionally accompanied by other keyletters specifying
261@emph{modifiers}), and the archive name to act on.
262
263Most operations can also accept further @var{member} arguments,
264specifying particular files to operate on.
265
0285c67d
NC
266@c man begin OPTIONS ar
267
c7c55b78 268@sc{gnu} @command{ar} allows you to mix the operation code @var{p} and modifier
252b5132
RH
269flags @var{mod} in any order, within the first command-line argument.
270
271If you wish, you may begin the first command-line argument with a
272dash.
273
274@cindex operations on archive
275The @var{p} keyletter specifies what operation to execute; it may be
276any of the following, but you must specify only one of them:
277
c7c55b78 278@table @samp
252b5132
RH
279@item d
280@cindex deleting from archive
281@emph{Delete} modules from the archive. Specify the names of modules to
282be deleted as @var{member}@dots{}; the archive is untouched if you
283specify no files to delete.
284
c7c55b78 285If you specify the @samp{v} modifier, @command{ar} lists each module
252b5132
RH
286as it is deleted.
287
288@item m
289@cindex moving in archive
290Use this operation to @emph{move} members in an archive.
291
292The ordering of members in an archive can make a difference in how
293programs are linked using the library, if a symbol is defined in more
c1c0eb9e 294than one member.
252b5132
RH
295
296If no modifiers are used with @code{m}, any members you name in the
297@var{member} arguments are moved to the @emph{end} of the archive;
298you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
299specified place instead.
300
301@item p
302@cindex printing from archive
303@emph{Print} the specified members of the archive, to the standard
304output file. If the @samp{v} modifier is specified, show the member
305name before copying its contents to standard output.
306
307If you specify no @var{member} arguments, all the files in the archive are
308printed.
309
310@item q
311@cindex quick append to archive
312@emph{Quick append}; Historically, add the files @var{member}@dots{} to the end of
313@var{archive}, without checking for replacement.
314
315The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
316operation; new members are always placed at the end of the archive.
317
c7c55b78 318The modifier @samp{v} makes @command{ar} list each file as it is appended.
252b5132
RH
319
320Since the point of this operation is speed, the archive's symbol table
321index is not updated, even if it already existed; you can use @samp{ar s} or
c7c55b78 322@command{ranlib} explicitly to update the symbol table index.
252b5132
RH
323
324However, too many different systems assume quick append rebuilds the
947ed062 325index, so @sc{gnu} @command{ar} implements @samp{q} as a synonym for @samp{r}.
252b5132
RH
326
327@item r
328@cindex replacement in archive
329Insert the files @var{member}@dots{} into @var{archive} (with
330@emph{replacement}). This operation differs from @samp{q} in that any
331previously existing members are deleted if their names match those being
332added.
333
c7c55b78 334If one of the files named in @var{member}@dots{} does not exist, @command{ar}
252b5132
RH
335displays an error message, and leaves undisturbed any existing members
336of the archive matching that name.
337
338By default, new members are added at the end of the file; but you may
339use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
340placement relative to some existing member.
341
342The modifier @samp{v} used with this operation elicits a line of
343output for each file inserted, along with one of the letters @samp{a} or
344@samp{r} to indicate whether the file was appended (no old member
345deleted) or replaced.
346
347@item t
348@cindex contents of archive
349Display a @emph{table} listing the contents of @var{archive}, or those
350of the files listed in @var{member}@dots{} that are present in the
351archive. Normally only the member name is shown; if you also want to
352see the modes (permissions), timestamp, owner, group, and size, you can
353request that by also specifying the @samp{v} modifier.
354
355If you do not specify a @var{member}, all files in the archive
356are listed.
357
358@cindex repeated names in archive
359@cindex name duplication in archive
360If there is more than one file with the same name (say, @samp{fie}) in
361an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
362first instance; to see them all, you must ask for a complete
363listing---in our example, @samp{ar t b.a}.
364@c WRS only; per Gumby, this is implementation-dependent, and in a more
365@c recent case in fact works the other way.
366
367@item x
368@cindex extract from archive
369@emph{Extract} members (named @var{member}) from the archive. You can
370use the @samp{v} modifier with this operation, to request that
c7c55b78 371@command{ar} list each name as it extracts it.
252b5132
RH
372
373If you do not specify a @var{member}, all files in the archive
374are extracted.
375
a8da6403
NC
376Files cannot be extracted from a thin archive.
377
252b5132
RH
378@end table
379
380A number of modifiers (@var{mod}) may immediately follow the @var{p}
381keyletter, to specify variations on an operation's behavior:
382
c7c55b78 383@table @samp
252b5132
RH
384@item a
385@cindex relative placement in archive
386Add new files @emph{after} an existing member of the
387archive. If you use the modifier @samp{a}, the name of an existing archive
388member must be present as the @var{relpos} argument, before the
389@var{archive} specification.
390
391@item b
392Add new files @emph{before} an existing member of the
393archive. If you use the modifier @samp{b}, the name of an existing archive
394member must be present as the @var{relpos} argument, before the
395@var{archive} specification. (same as @samp{i}).
396
397@item c
398@cindex creating archives
399@emph{Create} the archive. The specified @var{archive} is always
400created if it did not exist, when you request an update. But a warning is
401issued unless you specify in advance that you expect to create it, by
402using this modifier.
403
36e4dce6
CD
404@item D
405@cindex deterministic archives
406Operate in @emph{deterministic} mode. When adding files and the archive
407index use zero for UIDs, GIDs, timestamps, and use consistent file modes
408for all files. When this option is used, if @command{ar} is used with
409identical options and identical input files, multiple runs will create
410identical output files regardless of the input files' owners, groups,
411file modes, or modification times.
412
252b5132 413@item f
c7c55b78 414Truncate names in the archive. @sc{gnu} @command{ar} will normally permit file
252b5132 415names of any length. This will cause it to create archives which are
c7c55b78 416not compatible with the native @command{ar} program on some systems. If
252b5132
RH
417this is a concern, the @samp{f} modifier may be used to truncate file
418names when putting them in the archive.
419
420@item i
421Insert new files @emph{before} an existing member of the
422archive. If you use the modifier @samp{i}, the name of an existing archive
423member must be present as the @var{relpos} argument, before the
424@var{archive} specification. (same as @samp{b}).
425
426@item l
427This modifier is accepted but not used.
428@c whaffor ar l modifier??? presumably compat; with
c1c0eb9e 429@c what???---doc@@cygnus.com, 25jan91
252b5132 430
3de39064
ILT
431@item N
432Uses the @var{count} parameter. This is used if there are multiple
433entries in the archive with the same name. Extract or delete instance
434@var{count} of the given name from the archive.
435
252b5132
RH
436@item o
437@cindex dates in archive
438Preserve the @emph{original} dates of members when extracting them. If
439you do not specify this modifier, files extracted from the archive
440are stamped with the time of extraction.
441
3de39064
ILT
442@item P
443Use the full path name when matching names in the archive. @sc{gnu}
c7c55b78 444@command{ar} can not create an archive with a full path name (such archives
3de39064 445are not POSIX complaint), but other archive creators can. This option
c7c55b78 446will cause @sc{gnu} @command{ar} to match file names using a complete path
3de39064
ILT
447name, which can be convenient when extracting a single file from an
448archive created by another tool.
449
252b5132
RH
450@item s
451@cindex writing archive index
452Write an object-file index into the archive, or update an existing one,
453even if no other change is made to the archive. You may use this modifier
454flag either with any operation, or alone. Running @samp{ar s} on an
455archive is equivalent to running @samp{ranlib} on it.
456
457@item S
458@cindex not writing archive index
459Do not generate an archive symbol table. This can speed up building a
460large library in several steps. The resulting archive can not be used
461with the linker. In order to build a symbol table, you must omit the
462@samp{S} modifier on the last execution of @samp{ar}, or you must run
463@samp{ranlib} on the archive.
464
a8da6403
NC
465@item T
466@cindex creating thin archive
467Make the specified @var{archive} a @emph{thin} archive. If it already
468exists and is a regular archive, the existing members must be present
469in the same directory as @var{archive}.
470
252b5132
RH
471@item u
472@cindex updating an archive
473Normally, @samp{ar r}@dots{} inserts all files
474listed into the archive. If you would like to insert @emph{only} those
475of the files you list that are newer than existing members of the same
476names, use this modifier. The @samp{u} modifier is allowed only for the
477operation @samp{r} (replace). In particular, the combination @samp{qu} is
478not allowed, since checking the timestamps would lose any speed
479advantage from the operation @samp{q}.
480
481@item v
482This modifier requests the @emph{verbose} version of an operation. Many
483operations display additional information, such as filenames processed,
484when the modifier @samp{v} is appended.
485
486@item V
c7c55b78 487This modifier shows the version number of @command{ar}.
252b5132
RH
488@end table
489
c7c55b78 490@command{ar} ignores an initial option spelt @samp{-X32_64}, for
6e800839 491compatibility with AIX. The behaviour produced by this option is the
947ed062 492default for @sc{gnu} @command{ar}. @command{ar} does not support any of the other
c7c55b78
NC
493@samp{-X} options; in particular, it does not support @option{-X32}
494which is the default for AIX @command{ar}.
6e800839 495
ce3c775b
NC
496The optional command line switch @option{--plugin} @var{name} causes
497@command{ar} to load the plugin called @var{name} which adds support
498for more file formats. This option is only available if the toolchain
499has been built with plugin support enabled.
500
0285c67d
NC
501@c man end
502
503@ignore
504@c man begin SEEALSO ar
505nm(1), ranlib(1), and the Info entries for @file{binutils}.
506@c man end
507@end ignore
508
252b5132 509@node ar scripts
947ed062 510@section Controlling @command{ar} with a Script
252b5132
RH
511
512@smallexample
513ar -M [ <@var{script} ]
514@end smallexample
515
c7c55b78
NC
516@cindex MRI compatibility, @command{ar}
517@cindex scripts, @command{ar}
518If you use the single command-line option @samp{-M} with @command{ar}, you
252b5132 519can control its operation with a rudimentary command language. This
c7c55b78
NC
520form of @command{ar} operates interactively if standard input is coming
521directly from a terminal. During interactive use, @command{ar} prompts for
252b5132
RH
522input (the prompt is @samp{AR >}), and continues executing even after
523errors. If you redirect standard input to a script file, no prompts are
c7c55b78 524issued, and @command{ar} abandons execution (with a nonzero exit code)
252b5132
RH
525on any error.
526
c7c55b78 527The @command{ar} command language is @emph{not} designed to be equivalent
252b5132
RH
528to the command-line options; in fact, it provides somewhat less control
529over archives. The only purpose of the command language is to ease the
c7c55b78 530transition to @sc{gnu} @command{ar} for developers who already have scripts
252b5132
RH
531written for the MRI ``librarian'' program.
532
c7c55b78 533The syntax for the @command{ar} command language is straightforward:
252b5132
RH
534@itemize @bullet
535@item
536commands are recognized in upper or lower case; for example, @code{LIST}
537is the same as @code{list}. In the following descriptions, commands are
538shown in upper case for clarity.
539
540@item
541a single command may appear on each line; it is the first word on the
542line.
543
544@item
545empty lines are allowed, and have no effect.
546
547@item
548comments are allowed; text after either of the characters @samp{*}
549or @samp{;} is ignored.
550
551@item
c7c55b78 552Whenever you use a list of names as part of the argument to an @command{ar}
252b5132
RH
553command, you can separate the individual names with either commas or
554blanks. Commas are shown in the explanations below, for clarity.
555
556@item
557@samp{+} is used as a line continuation character; if @samp{+} appears
558at the end of a line, the text on the following line is considered part
559of the current command.
560@end itemize
561
c7c55b78
NC
562Here are the commands you can use in @command{ar} scripts, or when using
563@command{ar} interactively. Three of them have special significance:
252b5132
RH
564
565@code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
566a temporary file required for most of the other commands.
567
568@code{SAVE} commits the changes so far specified by the script. Prior
569to @code{SAVE}, commands affect only the temporary copy of the current
570archive.
571
572@table @code
c1c0eb9e 573@item ADDLIB @var{archive}
252b5132
RH
574@itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
575Add all the contents of @var{archive} (or, if specified, each named
576@var{module} from @var{archive}) to the current archive.
577
578Requires prior use of @code{OPEN} or @code{CREATE}.
579
580@item ADDMOD @var{member}, @var{member}, @dots{} @var{member}
581@c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
582@c else like "ar q..."
583Add each named @var{member} as a module in the current archive.
584
585Requires prior use of @code{OPEN} or @code{CREATE}.
586
587@item CLEAR
588Discard the contents of the current archive, canceling the effect of
589any operations since the last @code{SAVE}. May be executed (with no
590effect) even if no current archive is specified.
591
592@item CREATE @var{archive}
593Creates an archive, and makes it the current archive (required for many
594other commands). The new archive is created with a temporary name; it
595is not actually saved as @var{archive} until you use @code{SAVE}.
596You can overwrite existing archives; similarly, the contents of any
597existing file named @var{archive} will not be destroyed until @code{SAVE}.
598
599@item DELETE @var{module}, @var{module}, @dots{} @var{module}
600Delete each listed @var{module} from the current archive; equivalent to
601@samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
602
603Requires prior use of @code{OPEN} or @code{CREATE}.
604
605@item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
606@itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
607List each named @var{module} present in @var{archive}. The separate
608command @code{VERBOSE} specifies the form of the output: when verbose
609output is off, output is like that of @samp{ar -t @var{archive}
610@var{module}@dots{}}. When verbose output is on, the listing is like
611@samp{ar -tv @var{archive} @var{module}@dots{}}.
612
613Output normally goes to the standard output stream; however, if you
c7c55b78 614specify @var{outputfile} as a final argument, @command{ar} directs the
252b5132
RH
615output to that file.
616
617@item END
c7c55b78 618Exit from @command{ar}, with a @code{0} exit code to indicate successful
252b5132
RH
619completion. This command does not save the output file; if you have
620changed the current archive since the last @code{SAVE} command, those
621changes are lost.
622
623@item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
624Extract each named @var{module} from the current archive, writing them
625into the current directory as separate files. Equivalent to @samp{ar -x
626@var{archive} @var{module}@dots{}}.
627
628Requires prior use of @code{OPEN} or @code{CREATE}.
629
630@ignore
631@c FIXME Tokens but no commands???
632@item FULLDIR
633
634@item HELP
635@end ignore
636
637@item LIST
638Display full contents of the current archive, in ``verbose'' style
639regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
c7c55b78 640tv @var{archive}}. (This single command is a @sc{gnu} @command{ar}
252b5132
RH
641enhancement, rather than present for MRI compatibility.)
642
643Requires prior use of @code{OPEN} or @code{CREATE}.
644
645@item OPEN @var{archive}
646Opens an existing archive for use as the current archive (required for
647many other commands). Any changes as the result of subsequent commands
648will not actually affect @var{archive} until you next use @code{SAVE}.
649
650@item REPLACE @var{module}, @var{module}, @dots{} @var{module}
651In the current archive, replace each existing @var{module} (named in
652the @code{REPLACE} arguments) from files in the current working directory.
653To execute this command without errors, both the file, and the module in
c1c0eb9e 654the current archive, must exist.
252b5132
RH
655
656Requires prior use of @code{OPEN} or @code{CREATE}.
657
658@item VERBOSE
659Toggle an internal flag governing the output from @code{DIRECTORY}.
660When the flag is on, @code{DIRECTORY} output matches output from
661@samp{ar -tv }@dots{}.
662
663@item SAVE
664Commit your changes to the current archive, and actually save it as a
665file with the name specified in the last @code{CREATE} or @code{OPEN}
c1c0eb9e 666command.
252b5132
RH
667
668Requires prior use of @code{OPEN} or @code{CREATE}.
669
670@end table
671
672@iftex
673@node ld
674@chapter ld
675@cindex linker
676@kindex ld
c7c55b78 677The @sc{gnu} linker @command{ld} is now described in a separate manual.
252b5132
RH
678@xref{Top,, Overview,, Using LD: the @sc{gnu} linker}.
679@end iftex
680
681@node nm
682@chapter nm
683@cindex symbols
684@kindex nm
685
0285c67d
NC
686@c man title nm list symbols from object files
687
252b5132 688@smallexample
0285c67d 689@c man begin SYNOPSIS nm
ce3c775b
NC
690nm [@option{-a}|@option{--debug-syms}]
691 [@option{-g}|@option{--extern-only}][@option{--plugin} @var{name}]
c7c55b78 692 [@option{-B}] [@option{-C}|@option{--demangle}[=@var{style}]] [@option{-D}|@option{--dynamic}]
72797995 693 [@option{-S}|@option{--print-size}] [@option{-s}|@option{--print-armap}]
3c9458e9 694 [@option{-A}|@option{-o}|@option{--print-file-name}][@option{--special-syms}]
c7c55b78
NC
695 [@option{-n}|@option{-v}|@option{--numeric-sort}] [@option{-p}|@option{--no-sort}]
696 [@option{-r}|@option{--reverse-sort}] [@option{--size-sort}] [@option{-u}|@option{--undefined-only}]
697 [@option{-t} @var{radix}|@option{--radix=}@var{radix}] [@option{-P}|@option{--portability}]
698 [@option{--target=}@var{bfdname}] [@option{-f}@var{format}|@option{--format=}@var{format}]
699 [@option{--defined-only}] [@option{-l}|@option{--line-numbers}] [@option{--no-demangle}]
700 [@option{-V}|@option{--version}] [@option{-X 32_64}] [@option{--help}] [@var{objfile}@dots{}]
0285c67d 701@c man end
252b5132
RH
702@end smallexample
703
0285c67d 704@c man begin DESCRIPTION nm
c7c55b78
NC
705@sc{gnu} @command{nm} lists the symbols from object files @var{objfile}@dots{}.
706If no object files are listed as arguments, @command{nm} assumes the file
252b5132
RH
707@file{a.out}.
708
c7c55b78 709For each symbol, @command{nm} shows:
252b5132
RH
710
711@itemize @bullet
712@item
713The symbol value, in the radix selected by options (see below), or
714hexadecimal by default.
715
716@item
717The symbol type. At least the following types are used; others are, as
718well, depending on the object file format. If lowercase, the symbol is
719local; if uppercase, the symbol is global (external).
720
721@c Some more detail on exactly what these symbol types are used for
722@c would be nice.
723@table @code
724@item A
725The symbol's value is absolute, and will not be changed by further
726linking.
727
728@item B
a1039809 729@itemx b
252b5132
RH
730The symbol is in the uninitialized data section (known as BSS).
731
732@item C
733The symbol is common. Common symbols are uninitialized data. When
734linking, multiple common symbols may appear with the same name. If the
735symbol is defined anywhere, the common symbols are treated as undefined
0285c67d
NC
736references.
737@ifclear man
738For more details on common symbols, see the discussion of
252b5132 739--warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}.
0879a67a 740@end ifclear
252b5132
RH
741
742@item D
a1039809 743@itemx d
252b5132
RH
744The symbol is in the initialized data section.
745
746@item G
a1039809 747@itemx g
252b5132
RH
748The symbol is in an initialized data section for small objects. Some
749object file formats permit more efficient access to small data objects,
750such as a global int variable as opposed to a large global array.
751
a1039809 752@item i
3e7a7d11
NC
753For PE format files this indicates that the symbol is in a section
754specific to the implementation of DLLs. For ELF format files this
755indicates that the symbol is an indirect function. This is a GNU
756extension to the standard set of ELF symbol types. It indicates a
757symbol which if referenced by a relocation does not evaluate to its
758address, but instead must be invoked at runtime. The runtime
759execution will then return the value to be used in the relocation.
a1039809 760
252b5132
RH
761@item N
762The symbol is a debugging symbol.
763
a1039809
NC
764@item p
765The symbols is in a stack unwind section.
766
252b5132 767@item R
a1039809 768@itemx r
252b5132
RH
769The symbol is in a read only data section.
770
771@item S
a1039809 772@itemx s
252b5132
RH
773The symbol is in an uninitialized data section for small objects.
774
775@item T
a1039809 776@itemx t
252b5132
RH
777The symbol is in the text (code) section.
778
779@item U
780The symbol is undefined.
781
3e7a7d11
NC
782@item u
783The symbol is a unique global symbol. This is a GNU extension to the
784standard set of ELF symbol bindings. For such a symbol the dynamic linker
785will make sure that in the entire process there is just one symbol with
786this name and type in use.
787
fad6fcbb 788@item V
a1039809 789@itemx v
fad6fcbb
NC
790The symbol is a weak object. When a weak defined symbol is linked with
791a normal defined symbol, the normal defined symbol is used with no error.
792When a weak undefined symbol is linked and the symbol is not defined,
a1039809
NC
793the value of the weak symbol becomes zero with no error. On some
794systems, uppercase indicates that a default value has been specified.
fad6fcbb 795
252b5132 796@item W
a1039809 797@itemx w
fad6fcbb
NC
798The symbol is a weak symbol that has not been specifically tagged as a
799weak object symbol. When a weak defined symbol is linked with a normal
800defined symbol, the normal defined symbol is used with no error.
801When a weak undefined symbol is linked and the symbol is not defined,
c87db184 802the value of the symbol is determined in a system-specific manner without
c1c0eb9e 803error. On some systems, uppercase indicates that a default value has been
977cdf5a
NC
804specified.
805
252b5132
RH
806@item -
807The symbol is a stabs symbol in an a.out object file. In this case, the
808next values printed are the stabs other field, the stabs desc field, and
c7c55b78
NC
809the stab type. Stabs symbols are used to hold debugging information.
810@ifclear man
811For more information, see @ref{Top,Stabs,Stabs Overview,stabs.info, The
252b5132 812``stabs'' debug format}.
c7c55b78 813@end ifclear
252b5132
RH
814
815@item ?
816The symbol type is unknown, or object file format specific.
817@end table
818
819@item
820The symbol name.
821@end itemize
822
0285c67d
NC
823@c man end
824
825@c man begin OPTIONS nm
252b5132
RH
826The long and short forms of options, shown here as alternatives, are
827equivalent.
828
c7c55b78 829@table @env
252b5132
RH
830@item -A
831@itemx -o
c1c0eb9e 832@itemx --print-file-name
252b5132
RH
833@cindex input file name
834@cindex file name
835@cindex source file name
f20a759a 836Precede each symbol by the name of the input file (or archive member)
252b5132
RH
837in which it was found, rather than identifying the input file once only,
838before all of its symbols.
839
840@item -a
c1c0eb9e 841@itemx --debug-syms
252b5132
RH
842@cindex debugging symbols
843Display all symbols, even debugger-only symbols; normally these are not
844listed.
845
846@item -B
c7c55b78
NC
847@cindex @command{nm} format
848@cindex @command{nm} compatibility
849The same as @option{--format=bsd} (for compatibility with the MIPS @command{nm}).
252b5132
RH
850
851@item -C
28c309a2 852@itemx --demangle[=@var{style}]
252b5132
RH
853@cindex demangling in nm
854Decode (@dfn{demangle}) low-level symbol names into user-level names.
855Besides removing any initial underscore prepended by the system, this
28c309a2 856makes C++ function names readable. Different compilers have different
c1c0eb9e
RM
857mangling styles. The optional demangling style argument can be used to
858choose an appropriate demangling style for your compiler. @xref{c++filt},
28c309a2 859for more information on demangling.
252b5132
RH
860
861@item --no-demangle
862Do not demangle low-level symbol names. This is the default.
863
864@item -D
865@itemx --dynamic
866@cindex dynamic symbols
867Display the dynamic symbols rather than the normal symbols. This is
868only meaningful for dynamic objects, such as certain types of shared
869libraries.
870
871@item -f @var{format}
872@itemx --format=@var{format}
c7c55b78
NC
873@cindex @command{nm} format
874@cindex @command{nm} compatibility
252b5132
RH
875Use the output format @var{format}, which can be @code{bsd},
876@code{sysv}, or @code{posix}. The default is @code{bsd}.
877Only the first character of @var{format} is significant; it can be
878either upper or lower case.
879
880@item -g
c1c0eb9e 881@itemx --extern-only
252b5132
RH
882@cindex external symbols
883Display only external symbols.
884
ce3c775b
NC
885@item --plugin @var{name}
886@cindex load plugin
887Load the plugin called @var{name} to add support for extra target
888types. This option is only available if the toolchain has been built
889with plugin support enabled.
890
252b5132
RH
891@item -l
892@itemx --line-numbers
893@cindex symbol line numbers
894For each symbol, use debugging information to try to find a filename and
895line number. For a defined symbol, look for the line number of the
896address of the symbol. For an undefined symbol, look for the line
897number of a relocation entry which refers to the symbol. If line number
898information can be found, print it after the other symbol information.
899
900@item -n
901@itemx -v
c1c0eb9e 902@itemx --numeric-sort
252b5132 903Sort symbols numerically by their addresses, rather than alphabetically
c1c0eb9e 904by their names.
252b5132
RH
905
906@item -p
c1c0eb9e 907@itemx --no-sort
252b5132
RH
908@cindex sorting symbols
909Do not bother to sort the symbols in any order; print them in the order
910encountered.
911
912@item -P
913@itemx --portability
914Use the POSIX.2 standard output format instead of the default format.
915Equivalent to @samp{-f posix}.
916
72797995
L
917@item -S
918@itemx --print-size
1533edfb
AM
919Print both value and size of defined symbols for the @code{bsd} output style.
920This option has no effect for object formats that do not record symbol
921sizes, unless @samp{--size-sort} is also used in which case a
922calculated size is displayed.
72797995 923
252b5132
RH
924@item -s
925@itemx --print-armap
926@cindex symbol index, listing
927When listing symbols from archive members, include the index: a mapping
c7c55b78 928(stored in the archive by @command{ar} or @command{ranlib}) of which modules
252b5132
RH
929contain definitions for which names.
930
931@item -r
c1c0eb9e 932@itemx --reverse-sort
252b5132
RH
933Reverse the order of the sort (whether numeric or alphabetic); let the
934last come first.
935
936@item --size-sort
937Sort symbols by size. The size is computed as the difference between
938the value of the symbol and the value of the symbol with the next higher
c1c0eb9e
RM
939value. If the @code{bsd} output format is used the size of the symbol
940is printed, rather than the value, and @samp{-S} must be used in order
76ed1927 941both size and value to be printed.
252b5132 942
3c9458e9
NC
943@item --special-syms
944Display symbols which have a target-specific special meaning. These
945symbols are usually used by the target for some special processing and
946are not normally helpful when included included in the normal symbol
947lists. For example for ARM targets this option would skip the mapping
b45619c0 948symbols used to mark transitions between ARM code, THUMB code and
3c9458e9
NC
949data.
950
252b5132
RH
951@item -t @var{radix}
952@itemx --radix=@var{radix}
953Use @var{radix} as the radix for printing the symbol values. It must be
954@samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
955
956@item --target=@var{bfdname}
957@cindex object code format
958Specify an object code format other than your system's default format.
959@xref{Target Selection}, for more information.
960
961@item -u
c1c0eb9e 962@itemx --undefined-only
252b5132
RH
963@cindex external symbols
964@cindex undefined symbols
965Display only undefined symbols (those external to each object file).
966
967@item --defined-only
968@cindex external symbols
969@cindex undefined symbols
970Display only defined symbols for each object file.
971
972@item -V
973@itemx --version
c7c55b78 974Show the version number of @command{nm} and exit.
252b5132 975
6e800839
GK
976@item -X
977This option is ignored for compatibility with the AIX version of
c7c55b78
NC
978@command{nm}. It takes one parameter which must be the string
979@option{32_64}. The default mode of AIX @command{nm} corresponds
980to @option{-X 32}, which is not supported by @sc{gnu} @command{nm}.
6e800839 981
252b5132 982@item --help
c7c55b78 983Show a summary of the options to @command{nm} and exit.
252b5132
RH
984@end table
985
0285c67d
NC
986@c man end
987
988@ignore
989@c man begin SEEALSO nm
990ar(1), objdump(1), ranlib(1), and the Info entries for @file{binutils}.
991@c man end
992@end ignore
993
252b5132
RH
994@node objcopy
995@chapter objcopy
996
0285c67d
NC
997@c man title objcopy copy and translate object files
998
252b5132 999@smallexample
0285c67d 1000@c man begin SYNOPSIS objcopy
c7c55b78
NC
1001objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
1002 [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}]
1003 [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}]
1004 [@option{-B} @var{bfdarch}|@option{--binary-architecture=}@var{bfdarch}]
2593f09a
NC
1005 [@option{-S}|@option{--strip-all}]
1006 [@option{-g}|@option{--strip-debug}]
c7c55b78
NC
1007 [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}]
1008 [@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}]
bcf32829 1009 [@option{--strip-unneeded-symbol=}@var{symbolname}]
c7c55b78 1010 [@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}]
d58c2e3a 1011 [@option{--localize-hidden}]
c7c55b78 1012 [@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}]
7b4a0685 1013 [@option{--globalize-symbol=}@var{symbolname}]
c7c55b78 1014 [@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
5fe11841 1015 [@option{-w}|@option{--wildcard}]
2593f09a
NC
1016 [@option{-x}|@option{--discard-all}]
1017 [@option{-X}|@option{--discard-locals}]
c7c55b78
NC
1018 [@option{-b} @var{byte}|@option{--byte=}@var{byte}]
1019 [@option{-i} @var{interleave}|@option{--interleave=}@var{interleave}]
1020 [@option{-j} @var{sectionname}|@option{--only-section=}@var{sectionname}]
1021 [@option{-R} @var{sectionname}|@option{--remove-section=}@var{sectionname}]
1022 [@option{-p}|@option{--preserve-dates}]
1023 [@option{--debugging}]
2593f09a
NC
1024 [@option{--gap-fill=}@var{val}]
1025 [@option{--pad-to=}@var{address}]
1026 [@option{--set-start=}@var{val}]
1027 [@option{--adjust-start=}@var{incr}]
c7c55b78
NC
1028 [@option{--change-addresses=}@var{incr}]
1029 [@option{--change-section-address} @var{section}@{=,+,-@}@var{val}]
1030 [@option{--change-section-lma} @var{section}@{=,+,-@}@var{val}]
1031 [@option{--change-section-vma} @var{section}@{=,+,-@}@var{val}]
1032 [@option{--change-warnings}] [@option{--no-change-warnings}]
1033 [@option{--set-section-flags} @var{section}=@var{flags}]
1034 [@option{--add-section} @var{sectionname}=@var{filename}]
1035 [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]]
0408dee6 1036 [@option{--long-section-names} @{enable,disable,keep@}]
2593f09a 1037 [@option{--change-leading-char}] [@option{--remove-leading-char}]
9e48b4c6 1038 [@option{--reverse-bytes=}@var{num}]
2593f09a
NC
1039 [@option{--srec-len=}@var{ival}] [@option{--srec-forceS3}]
1040 [@option{--redefine-sym} @var{old}=@var{new}]
1041 [@option{--redefine-syms=}@var{filename}]
c7c55b78
NC
1042 [@option{--weaken}]
1043 [@option{--keep-symbols=}@var{filename}]
1044 [@option{--strip-symbols=}@var{filename}]
bcf32829 1045 [@option{--strip-unneeded-symbols=}@var{filename}]
c7c55b78
NC
1046 [@option{--keep-global-symbols=}@var{filename}]
1047 [@option{--localize-symbols=}@var{filename}]
7b4a0685 1048 [@option{--globalize-symbols=}@var{filename}]
c7c55b78 1049 [@option{--weaken-symbols=}@var{filename}]
c51238bc
DA
1050 [@option{--alt-machine-code=}@var{index}]
1051 [@option{--prefix-symbols=}@var{string}]
1052 [@option{--prefix-sections=}@var{string}]
1053 [@option{--prefix-alloc-sections=}@var{string}]
ed1653a7 1054 [@option{--add-gnu-debuglink=}@var{path-to-file}]
1637cd90 1055 [@option{--keep-file-symbols}]
ed1653a7 1056 [@option{--only-keep-debug}]
d3e52d40 1057 [@option{--extract-symbol}]
4087920c
MR
1058 [@option{--writable-text}]
1059 [@option{--readonly-text}]
1060 [@option{--pure}]
1061 [@option{--impure}]
92dd4511
L
1062 [@option{--file-alignment=}@var{num}]
1063 [@option{--heap=}@var{size}]
1064 [@option{--image-base=}@var{address}]
1065 [@option{--section-alignment=}@var{num}]
1066 [@option{--stack=}@var{size}]
1067 [@option{--subsystem=}@var{which}:@var{major}.@var{minor}]
c7c55b78 1068 [@option{-v}|@option{--verbose}]
c1c0eb9e 1069 [@option{-V}|@option{--version}]
7c29036b 1070 [@option{--help}] [@option{--info}]
252b5132 1071 @var{infile} [@var{outfile}]
0285c67d 1072@c man end
252b5132
RH
1073@end smallexample
1074
0285c67d 1075@c man begin DESCRIPTION objcopy
c7c55b78
NC
1076The @sc{gnu} @command{objcopy} utility copies the contents of an object
1077file to another. @command{objcopy} uses the @sc{gnu} @sc{bfd} Library to
252b5132
RH
1078read and write the object files. It can write the destination object
1079file in a format different from that of the source object file. The
c7c55b78
NC
1080exact behavior of @command{objcopy} is controlled by command-line options.
1081Note that @command{objcopy} should be able to copy a fully linked file
ccd13d18
L
1082between any two formats. However, copying a relocatable object file
1083between any two formats may not work as expected.
252b5132 1084
c7c55b78
NC
1085@command{objcopy} creates temporary files to do its translations and
1086deletes them afterward. @command{objcopy} uses @sc{bfd} to do all its
252b5132
RH
1087translation work; it has access to all the formats described in @sc{bfd}
1088and thus is able to recognize most formats without being told
1089explicitly. @xref{BFD,,BFD,ld.info,Using LD}.
1090
c7c55b78 1091@command{objcopy} can be used to generate S-records by using an output
252b5132
RH
1092target of @samp{srec} (e.g., use @samp{-O srec}).
1093
c7c55b78
NC
1094@command{objcopy} can be used to generate a raw binary file by using an
1095output target of @samp{binary} (e.g., use @option{-O binary}). When
1096@command{objcopy} generates a raw binary file, it will essentially produce
252b5132
RH
1097a memory dump of the contents of the input object file. All symbols and
1098relocation information will be discarded. The memory dump will start at
1099the load address of the lowest section copied into the output file.
1100
1101When generating an S-record or a raw binary file, it may be helpful to
c7c55b78
NC
1102use @option{-S} to remove sections containing debugging information. In
1103some cases @option{-R} will be useful to remove sections which contain
f20a759a 1104information that is not needed by the binary file.
252b5132 1105
947ed062
NC
1106Note---@command{objcopy} is not able to change the endianness of its input
1107files. If the input format has an endianness (some formats do not),
c7c55b78 1108@command{objcopy} can only copy the inputs into file formats that have the
947ed062 1109same endianness or which have no endianness (e.g., @samp{srec}).
9e48b4c6 1110(However, see the @option{--reverse-bytes} option.)
18356cf2 1111
0285c67d
NC
1112@c man end
1113
1114@c man begin OPTIONS objcopy
1115
c7c55b78 1116@table @env
252b5132
RH
1117@item @var{infile}
1118@itemx @var{outfile}
f20a759a 1119The input and output files, respectively.
c7c55b78 1120If you do not specify @var{outfile}, @command{objcopy} creates a
252b5132
RH
1121temporary file and destructively renames the result with
1122the name of @var{infile}.
1123
c7c55b78 1124@item -I @var{bfdname}
252b5132
RH
1125@itemx --input-target=@var{bfdname}
1126Consider the source file's object format to be @var{bfdname}, rather than
1127attempting to deduce it. @xref{Target Selection}, for more information.
1128
1129@item -O @var{bfdname}
1130@itemx --output-target=@var{bfdname}
1131Write the output file using the object format @var{bfdname}.
1132@xref{Target Selection}, for more information.
1133
1134@item -F @var{bfdname}
1135@itemx --target=@var{bfdname}
1136Use @var{bfdname} as the object format for both the input and the output
1137file; i.e., simply transfer data from source to destination with no
1138translation. @xref{Target Selection}, for more information.
1139
43a0748c
NC
1140@item -B @var{bfdarch}
1141@itemx --binary-architecture=@var{bfdarch}
8b31b6c4
NC
1142Useful when transforming a architecture-less input file into an object file.
1143In this case the output architecture can be set to @var{bfdarch}. This
1144option will be ignored if the input file has a known @var{bfdarch}. You
43a0748c
NC
1145can access this binary data inside a program by referencing the special
1146symbols that are created by the conversion process. These symbols are
1147called _binary_@var{objfile}_start, _binary_@var{objfile}_end and
1148_binary_@var{objfile}_size. e.g. you can transform a picture file into
c1c0eb9e 1149an object file and then access it in your code using these symbols.
43a0748c 1150
f91ea849
ILT
1151@item -j @var{sectionname}
1152@itemx --only-section=@var{sectionname}
1153Copy only the named section from the input file to the output file.
1154This option may be given more than once. Note that using this option
1155inappropriately may make the output file unusable.
1156
252b5132
RH
1157@item -R @var{sectionname}
1158@itemx --remove-section=@var{sectionname}
1159Remove any section named @var{sectionname} from the output file. This
1160option may be given more than once. Note that using this option
1161inappropriately may make the output file unusable.
1162
1163@item -S
1164@itemx --strip-all
1165Do not copy relocation and symbol information from the source file.
1166
1167@item -g
1168@itemx --strip-debug
2593f09a 1169Do not copy debugging symbols or sections from the source file.
252b5132
RH
1170
1171@item --strip-unneeded
1172Strip all symbols that are not needed for relocation processing.
1173
1174@item -K @var{symbolname}
1175@itemx --keep-symbol=@var{symbolname}
e7f918ad
NC
1176When stripping symbols, keep symbol @var{symbolname} even if it would
1177normally be stripped. This option may be given more than once.
252b5132
RH
1178
1179@item -N @var{symbolname}
1180@itemx --strip-symbol=@var{symbolname}
1181Do not copy symbol @var{symbolname} from the source file. This option
1182may be given more than once.
1183
bcf32829
JB
1184@item --strip-unneeded-symbol=@var{symbolname}
1185Do not copy symbol @var{symbolname} from the source file unless it is needed
1186by a relocation. This option may be given more than once.
1187
16b2b71c
NC
1188@item -G @var{symbolname}
1189@itemx --keep-global-symbol=@var{symbolname}
1190Keep only symbol @var{symbolname} global. Make all other symbols local
1191to the file, so that they are not visible externally. This option may
1192be given more than once.
1193
d58c2e3a
RS
1194@item --localize-hidden
1195In an ELF object, mark all symbols that have hidden or internal visibility
1196as local. This option applies on top of symbol-specific localization options
1197such as @option{-L}.
1198
252b5132
RH
1199@item -L @var{symbolname}
1200@itemx --localize-symbol=@var{symbolname}
1201Make symbol @var{symbolname} local to the file, so that it is not
1202visible externally. This option may be given more than once.
1203
1204@item -W @var{symbolname}
1205@itemx --weaken-symbol=@var{symbolname}
1206Make symbol @var{symbolname} weak. This option may be given more than once.
1207
7b4a0685
NC
1208@item --globalize-symbol=@var{symbolname}
1209Give symbol @var{symbolname} global scoping so that it is visible
1210outside of the file in which it is defined. This option may be given
1211more than once.
1212
5fe11841
NC
1213@item -w
1214@itemx --wildcard
1215Permit regular expressions in @var{symbolname}s used in other command
1216line options. The question mark (?), asterisk (*), backslash (\) and
1217square brackets ([]) operators can be used anywhere in the symbol
1218name. If the first character of the symbol name is the exclamation
1219point (!) then the sense of the switch is reversed for that symbol.
1220For example:
1221
1222@smallexample
1223 -w -W !foo -W fo*
1224@end smallexample
1225
1226would cause objcopy to weaken all symbols that start with ``fo''
1227except for the symbol ``foo''.
1228
252b5132
RH
1229@item -x
1230@itemx --discard-all
1231Do not copy non-global symbols from the source file.
1232@c FIXME any reason to prefer "non-global" to "local" here?
1233
1234@item -X
1235@itemx --discard-locals
1236Do not copy compiler-generated local symbols.
1237(These usually start with @samp{L} or @samp{.}.)
1238
1239@item -b @var{byte}
1240@itemx --byte=@var{byte}
1241Keep only every @var{byte}th byte of the input file (header data is not
1242affected). @var{byte} can be in the range from 0 to @var{interleave}-1,
c7c55b78 1243where @var{interleave} is given by the @option{-i} or @option{--interleave}
252b5132
RH
1244option, or the default of 4. This option is useful for creating files
1245to program @sc{rom}. It is typically used with an @code{srec} output
1246target.
1247
1248@item -i @var{interleave}
1249@itemx --interleave=@var{interleave}
1250Only copy one out of every @var{interleave} bytes. Select which byte to
c7c55b78
NC
1251copy with the @option{-b} or @option{--byte} option. The default is 4.
1252@command{objcopy} ignores this option if you do not specify either @option{-b} or
1253@option{--byte}.
252b5132
RH
1254
1255@item -p
1256@itemx --preserve-dates
1257Set the access and modification dates of the output file to be the same
1258as those of the input file.
1259
1260@item --debugging
1261Convert debugging information, if possible. This is not the default
1262because only certain debugging formats are supported, and the
1263conversion process can be time consuming.
1264
1265@item --gap-fill @var{val}
1266Fill gaps between sections with @var{val}. This operation applies to
1267the @emph{load address} (LMA) of the sections. It is done by increasing
1268the size of the section with the lower address, and filling in the extra
1269space created with @var{val}.
1270
1271@item --pad-to @var{address}
1272Pad the output file up to the load address @var{address}. This is
1273done by increasing the size of the last section. The extra space is
c7c55b78 1274filled in with the value specified by @option{--gap-fill} (default zero).
252b5132
RH
1275
1276@item --set-start @var{val}
f20a759a 1277Set the start address of the new file to @var{val}. Not all object file
252b5132
RH
1278formats support setting the start address.
1279
1280@item --change-start @var{incr}
1281@itemx --adjust-start @var{incr}
1282@cindex changing start address
1283Change the start address by adding @var{incr}. Not all object file
1284formats support setting the start address.
1285
1286@item --change-addresses @var{incr}
1287@itemx --adjust-vma @var{incr}
1288@cindex changing object addresses
1289Change the VMA and LMA addresses of all sections, as well as the start
1290address, by adding @var{incr}. Some object file formats do not permit
1291section addresses to be changed arbitrarily. Note that this does not
1292relocate the sections; if the program expects sections to be loaded at a
1293certain address, and this option is used to change the sections such
c1c0eb9e 1294that they are loaded at a different address, the program may fail.
252b5132
RH
1295
1296@item --change-section-address @var{section}@{=,+,-@}@var{val}
1297@itemx --adjust-section-vma @var{section}@{=,+,-@}@var{val}
1298@cindex changing section address
1299Set or change both the VMA address and the LMA address of the named
1300@var{section}. If @samp{=} is used, the section address is set to
1301@var{val}. Otherwise, @var{val} is added to or subtracted from the
c7c55b78 1302section address. See the comments under @option{--change-addresses},
252b5132 1303above. If @var{section} does not exist in the input file, a warning will
c7c55b78 1304be issued, unless @option{--no-change-warnings} is used.
252b5132
RH
1305
1306@item --change-section-lma @var{section}@{=,+,-@}@var{val}
1307@cindex changing section LMA
1308Set or change the LMA address of the named @var{section}. The LMA
1309address is the address where the section will be loaded into memory at
1310program load time. Normally this is the same as the VMA address, which
1311is the address of the section at program run time, but on some systems,
1312especially those where a program is held in ROM, the two can be
1313different. If @samp{=} is used, the section address is set to
1314@var{val}. Otherwise, @var{val} is added to or subtracted from the
c7c55b78 1315section address. See the comments under @option{--change-addresses},
252b5132 1316above. If @var{section} does not exist in the input file, a warning
c1c0eb9e 1317will be issued, unless @option{--no-change-warnings} is used.
252b5132
RH
1318
1319@item --change-section-vma @var{section}@{=,+,-@}@var{val}
1320@cindex changing section VMA
1321Set or change the VMA address of the named @var{section}. The VMA
1322address is the address where the section will be located once the
1323program has started executing. Normally this is the same as the LMA
1324address, which is the address where the section will be loaded into
1325memory, but on some systems, especially those where a program is held in
1326ROM, the two can be different. If @samp{=} is used, the section address
1327is set to @var{val}. Otherwise, @var{val} is added to or subtracted
1328from the section address. See the comments under
c7c55b78 1329@option{--change-addresses}, above. If @var{section} does not exist in
252b5132 1330the input file, a warning will be issued, unless
c1c0eb9e 1331@option{--no-change-warnings} is used.
252b5132
RH
1332
1333@item --change-warnings
1334@itemx --adjust-warnings
c7c55b78
NC
1335If @option{--change-section-address} or @option{--change-section-lma} or
1336@option{--change-section-vma} is used, and the named section does not
c1c0eb9e 1337exist, issue a warning. This is the default.
252b5132
RH
1338
1339@item --no-change-warnings
1340@itemx --no-adjust-warnings
c7c55b78
NC
1341Do not issue a warning if @option{--change-section-address} or
1342@option{--adjust-section-lma} or @option{--adjust-section-vma} is used, even
c1c0eb9e 1343if the named section does not exist.
252b5132
RH
1344
1345@item --set-section-flags @var{section}=@var{flags}
1346Set the flags for the named section. The @var{flags} argument is a
1347comma separated string of flag names. The recognized names are
3994e2c6
ILT
1348@samp{alloc}, @samp{contents}, @samp{load}, @samp{noload},
1349@samp{readonly}, @samp{code}, @samp{data}, @samp{rom}, @samp{share}, and
1350@samp{debug}. You can set the @samp{contents} flag for a section which
1351does not have contents, but it is not meaningful to clear the
1352@samp{contents} flag of a section which does have contents--just remove
1353the section instead. Not all flags are meaningful for all object file
1354formats.
252b5132
RH
1355
1356@item --add-section @var{sectionname}=@var{filename}
1357Add a new section named @var{sectionname} while copying the file. The
1358contents of the new section are taken from the file @var{filename}. The
1359size of the section will be the size of the file. This option only
1360works on file formats which can support sections with arbitrary names.
1361
594ef5db
NC
1362@item --rename-section @var{oldname}=@var{newname}[,@var{flags}]
1363Rename a section from @var{oldname} to @var{newname}, optionally
1364changing the section's flags to @var{flags} in the process. This has
1365the advantage over usng a linker script to perform the rename in that
1366the output stays as an object file and does not become a linked
1367executable.
1368
1369This option is particularly helpful when the input format is binary,
1370since this will always create a section called .data. If for example,
1371you wanted instead to create a section called .rodata containing binary
1372data you could use the following command line to achieve it:
1373
1374@smallexample
1375 objcopy -I binary -O <output_format> -B <architecture> \
1376 --rename-section .data=.rodata,alloc,load,readonly,data,contents \
1377 <input_binary_file> <output_object_file>
1378@end smallexample
1379
0408dee6
DK
1380@item --long-section-names @{enable,disable,keep@}
1381Controls the handling of long section names when processing @code{COFF}
1382and @code{PE-COFF} object formats. The default behaviour, @samp{keep},
1383is to preserve long section names if any are present in the input file.
1384The @samp{enable} and @samp{disable} options forcibly enable or disable
1385the use of long section names in the output object; when @samp{disable}
1386is in effect, any long section names in the input object will be truncated.
1387The @samp{enable} option will only emit long section names if any are
1388present in the inputs; this is mostly the same as @samp{keep}, but it
1389is left undefined whether the @samp{enable} option might force the
1390creation of an empty string table in the output file.
1391
252b5132
RH
1392@item --change-leading-char
1393Some object file formats use special characters at the start of
1394symbols. The most common such character is underscore, which compilers
c7c55b78 1395often add before every symbol. This option tells @command{objcopy} to
252b5132
RH
1396change the leading character of every symbol when it converts between
1397object file formats. If the object file formats use the same leading
1398character, this option has no effect. Otherwise, it will add a
1399character, or remove a character, or change a character, as
1400appropriate.
1401
1402@item --remove-leading-char
1403If the first character of a global symbol is a special symbol leading
1404character used by the object file format, remove the character. The
1405most common symbol leading character is underscore. This option will
1406remove a leading underscore from all global symbols. This can be useful
1407if you want to link together objects of different file formats with
1408different conventions for symbol names. This is different from
c7c55b78 1409@option{--change-leading-char} because it always changes the symbol name
252b5132
RH
1410when appropriate, regardless of the object file format of the output
1411file.
1412
9e48b4c6
NC
1413@item --reverse-bytes=@var{num}
1414Reverse the bytes in a section with output contents. A section length must
1415be evenly divisible by the value given in order for the swap to be able to
1416take place. Reversing takes place before the interleaving is performed.
1417
1418This option is used typically in generating ROM images for problematic
1419target systems. For example, on some target boards, the 32-bit words
1420fetched from 8-bit ROMs are re-assembled in little-endian byte order
1421regardless of the CPU byte order. Depending on the programming model, the
1422endianness of the ROM may need to be modified.
1423
1424Consider a simple file with a section containing the following eight
1425bytes: @code{12345678}.
1426
1427Using @samp{--reverse-bytes=2} for the above example, the bytes in the
1428output file would be ordered @code{21436587}.
1429
1430Using @samp{--reverse-bytes=4} for the above example, the bytes in the
1431output file would be ordered @code{43218765}.
1432
1433By using @samp{--reverse-bytes=2} for the above example, followed by
1434@samp{--reverse-bytes=4} on the output file, the bytes in the second
1435output file would be ordered @code{34127856}.
1436
420496c1
NC
1437@item --srec-len=@var{ival}
1438Meaningful only for srec output. Set the maximum length of the Srecords
1439being produced to @var{ival}. This length covers both address, data and
1440crc fields.
1441
1442@item --srec-forceS3
c1c0eb9e 1443Meaningful only for srec output. Avoid generation of S1/S2 records,
420496c1
NC
1444creating S3-only record format.
1445
57938635
AM
1446@item --redefine-sym @var{old}=@var{new}
1447Change the name of a symbol @var{old}, to @var{new}. This can be useful
1448when one is trying link two things together for which you have no
1449source, and there are name collisions.
1450
92991082
JT
1451@item --redefine-syms=@var{filename}
1452Apply @option{--redefine-sym} to each symbol pair "@var{old} @var{new}"
1453listed in the file @var{filename}. @var{filename} is simply a flat file,
1454with one symbol pair per line. Line comments may be introduced by the hash
1455character. This option may be given more than once.
1456
252b5132
RH
1457@item --weaken
1458Change all global symbols in the file to be weak. This can be useful
1459when building an object which will be linked against other objects using
c7c55b78 1460the @option{-R} option to the linker. This option is only effective when
252b5132
RH
1461using an object file format which supports weak symbols.
1462
16b2b71c 1463@item --keep-symbols=@var{filename}
c7c55b78 1464Apply @option{--keep-symbol} option to each symbol listed in the file
16b2b71c
NC
1465@var{filename}. @var{filename} is simply a flat file, with one symbol
1466name per line. Line comments may be introduced by the hash character.
1467This option may be given more than once.
1468
1469@item --strip-symbols=@var{filename}
c7c55b78 1470Apply @option{--strip-symbol} option to each symbol listed in the file
16b2b71c
NC
1471@var{filename}. @var{filename} is simply a flat file, with one symbol
1472name per line. Line comments may be introduced by the hash character.
1473This option may be given more than once.
1474
bcf32829
JB
1475@item --strip-unneeded-symbols=@var{filename}
1476Apply @option{--strip-unneeded-symbol} option to each symbol listed in
1477the file @var{filename}. @var{filename} is simply a flat file, with one
1478symbol name per line. Line comments may be introduced by the hash
1479character. This option may be given more than once.
1480
16b2b71c 1481@item --keep-global-symbols=@var{filename}
c7c55b78 1482Apply @option{--keep-global-symbol} option to each symbol listed in the
16b2b71c
NC
1483file @var{filename}. @var{filename} is simply a flat file, with one
1484symbol name per line. Line comments may be introduced by the hash
1485character. This option may be given more than once.
1486
1487@item --localize-symbols=@var{filename}
c7c55b78 1488Apply @option{--localize-symbol} option to each symbol listed in the file
16b2b71c
NC
1489@var{filename}. @var{filename} is simply a flat file, with one symbol
1490name per line. Line comments may be introduced by the hash character.
1491This option may be given more than once.
1492
7b4a0685
NC
1493@item --globalize-symbols=@var{filename}
1494Apply @option{--globalize-symbol} option to each symbol listed in the file
1495@var{filename}. @var{filename} is simply a flat file, with one symbol
1496name per line. Line comments may be introduced by the hash character.
1497This option may be given more than once.
1498
16b2b71c 1499@item --weaken-symbols=@var{filename}
c7c55b78 1500Apply @option{--weaken-symbol} option to each symbol listed in the file
16b2b71c
NC
1501@var{filename}. @var{filename} is simply a flat file, with one symbol
1502name per line. Line comments may be introduced by the hash character.
1503This option may be given more than once.
1504
1ae8b3d2
AO
1505@item --alt-machine-code=@var{index}
1506If the output architecture has alternate machine codes, use the
1507@var{index}th code instead of the default one. This is useful in case
c1c0eb9e 1508a machine is assigned an official code and the tool-chain adopts the
1ae8b3d2 1509new code, but other applications still depend on the original code
f9d4ad2a
NC
1510being used. For ELF based architectures if the @var{index}
1511alternative does not exist then the value is treated as an absolute
1512number to be stored in the e_machine field of the ELF header.
1ae8b3d2 1513
4087920c
MR
1514@item --writable-text
1515Mark the output text as writable. This option isn't meaningful for all
1516object file formats.
1517
1518@item --readonly-text
1519Make the output text write protected. This option isn't meaningful for all
1520object file formats.
1521
1522@item --pure
1523Mark the output file as demand paged. This option isn't meaningful for all
1524object file formats.
1525
1526@item --impure
1527Mark the output file as impure. This option isn't meaningful for all
1528object file formats.
1529
d7fb0dd2
NC
1530@item --prefix-symbols=@var{string}
1531Prefix all symbols in the output file with @var{string}.
1532
1533@item --prefix-sections=@var{string}
1534Prefix all section names in the output file with @var{string}.
1535
1536@item --prefix-alloc-sections=@var{string}
1537Prefix all the names of all allocated sections in the output file with
1538@var{string}.
1539
ed1653a7
NC
1540@item --add-gnu-debuglink=@var{path-to-file}
1541Creates a .gnu_debuglink section which contains a reference to @var{path-to-file}
1542and adds it to the output file.
1543
1637cd90
JB
1544@item --keep-file-symbols
1545When stripping a file, perhaps with @option{--strip-debug} or
1546@option{--strip-unneeded}, retain any symbols specifying source file names,
1547which would otherwise get stripped.
1548
ed1653a7 1549@item --only-keep-debug
36d3b955
MR
1550Strip a file, removing contents of any sections that would not be
1551stripped by @option{--strip-debug} and leaving the debugging sections
c1c0eb9e 1552intact. In ELF files, this preserves all note sections in the output.
ed1653a7
NC
1553
1554The intention is that this option will be used in conjunction with
1555@option{--add-gnu-debuglink} to create a two part executable. One a
1556stripped binary which will occupy less space in RAM and in a
1557distribution and the second a debugging information file which is only
1558needed if debugging abilities are required. The suggested procedure
1559to create these files is as follows:
1560
b96fec5e
DK
1561@enumerate
1562@item Link the executable as normal. Assuming that is is called
1563@code{foo} then...
1564@item Run @code{objcopy --only-keep-debug foo foo.dbg} to
1565create a file containing the debugging info.
1566@item Run @code{objcopy --strip-debug foo} to create a
1567stripped executable.
1568@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo}
1569to add a link to the debugging info into the stripped executable.
1570@end enumerate
1571
1572Note---the choice of @code{.dbg} as an extension for the debug info
1573file is arbitrary. Also the @code{--only-keep-debug} step is
1574optional. You could instead do this:
1575
1576@enumerate
1577@item Link the executable as normal.
1578@item Copy @code{foo} to @code{foo.full}
1579@item Run @code{objcopy --strip-debug foo}
1580@item Run @code{objcopy --add-gnu-debuglink=foo.full foo}
1581@end enumerate
1582
1583i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the
1584full executable. It does not have to be a file created by the
1585@option{--only-keep-debug} switch.
1586
1587Note---this switch is only intended for use on fully linked files. It
1588does not make sense to use it on object files where the debugging
1589information may be incomplete. Besides the gnu_debuglink feature
1590currently only supports the presence of one filename containing
1591debugging information, not multiple filenames on a one-per-object-file
1592basis.
1593
92dd4511
L
1594@item --file-alignment @var{num}
1595Specify the file alignment. Sections in the file will always begin at
1596file offsets which are multiples of this number. This defaults to
1597512.
1598[This option is specific to PE targets.]
1599
1600@item --heap @var{reserve}
1601@itemx --heap @var{reserve},@var{commit}
1602Specify the number of bytes of memory to reserve (and optionally commit)
1603to be used as heap for this program.
1604[This option is specific to PE targets.]
1605
1606@item --image-base @var{value}
1607Use @var{value} as the base address of your program or dll. This is
1608the lowest memory location that will be used when your program or dll
1609is loaded. To reduce the need to relocate and improve performance of
1610your dlls, each should have a unique base address and not overlap any
1611other dlls. The default is 0x400000 for executables, and 0x10000000
1612for dlls.
1613[This option is specific to PE targets.]
1614
1615@item --section-alignment @var{num}
1616Sets the section alignment. Sections in memory will always begin at
1617addresses which are a multiple of this number. Defaults to 0x1000.
1618[This option is specific to PE targets.]
1619
1620@item --stack @var{reserve}
1621@itemx --stack @var{reserve},@var{commit}
1622Specify the number of bytes of memory to reserve (and optionally commit)
1623to be used as stack for this program.
1624[This option is specific to PE targets.]
1625
1626@item --subsystem @var{which}
1627@itemx --subsystem @var{which}:@var{major}
1628@itemx --subsystem @var{which}:@var{major}.@var{minor}
1629Specifies the subsystem under which your program will execute. The
1630legal values for @var{which} are @code{native}, @code{windows},
1631@code{console}, @code{posix}, @code{efi-app}, @code{efi-bsd},
d9118602 1632@code{efi-rtd}, @code{sal-rtd}, and @code{xbox}. You may optionally set
92dd4511
L
1633the subsystem version also. Numeric values are also accepted for
1634@var{which}.
1635[This option is specific to PE targets.]
1636
d3e52d40
RS
1637@item --extract-symbol
1638Keep the file's section flags and symbols but remove all section data.
1639Specifically, the option:
1640
1641@itemize
d3e52d40
RS
1642@item removes the contents of all sections;
1643@item sets the size of every section to zero; and
1644@item sets the file's start address to zero.
1645@end itemize
c1c0eb9e 1646
d3e52d40
RS
1647This option is used to build a @file{.sym} file for a VxWorks kernel.
1648It can also be a useful way of reducing the size of a @option{--just-symbols}
1649linker input file.
1650
252b5132
RH
1651@item -V
1652@itemx --version
c7c55b78 1653Show the version number of @command{objcopy}.
252b5132
RH
1654
1655@item -v
1656@itemx --verbose
1657Verbose output: list all object files modified. In the case of
1658archives, @samp{objcopy -V} lists all members of the archive.
1659
1660@item --help
c7c55b78 1661Show a summary of the options to @command{objcopy}.
7c29036b
NC
1662
1663@item --info
1664Display a list showing all architectures and object formats available.
252b5132
RH
1665@end table
1666
0285c67d
NC
1667@c man end
1668
1669@ignore
1670@c man begin SEEALSO objcopy
1671ld(1), objdump(1), and the Info entries for @file{binutils}.
1672@c man end
1673@end ignore
1674
252b5132
RH
1675@node objdump
1676@chapter objdump
1677
1678@cindex object file information
1679@kindex objdump
1680
0285c67d
NC
1681@c man title objdump display information from object files.
1682
252b5132 1683@smallexample
0285c67d 1684@c man begin SYNOPSIS objdump
c7c55b78
NC
1685objdump [@option{-a}|@option{--archive-headers}]
1686 [@option{-b} @var{bfdname}|@option{--target=@var{bfdname}}]
1687 [@option{-C}|@option{--demangle}[=@var{style}] ]
1688 [@option{-d}|@option{--disassemble}]
1689 [@option{-D}|@option{--disassemble-all}]
1690 [@option{-z}|@option{--disassemble-zeroes}]
1691 [@option{-EB}|@option{-EL}|@option{--endian=}@{big | little @}]
1692 [@option{-f}|@option{--file-headers}]
98ec6e72 1693 [@option{-F}|@option{--file-offsets}]
c7c55b78
NC
1694 [@option{--file-start-context}]
1695 [@option{-g}|@option{--debugging}]
51cdc6e0 1696 [@option{-e}|@option{--debugging-tags}]
c7c55b78
NC
1697 [@option{-h}|@option{--section-headers}|@option{--headers}]
1698 [@option{-i}|@option{--info}]
1699 [@option{-j} @var{section}|@option{--section=}@var{section}]
1700 [@option{-l}|@option{--line-numbers}]
1701 [@option{-S}|@option{--source}]
1702 [@option{-m} @var{machine}|@option{--architecture=}@var{machine}]
1703 [@option{-M} @var{options}|@option{--disassembler-options=}@var{options}]
1704 [@option{-p}|@option{--private-headers}]
1705 [@option{-r}|@option{--reloc}]
1706 [@option{-R}|@option{--dynamic-reloc}]
1707 [@option{-s}|@option{--full-contents}]
f9f0e732
NC
1708 [@option{-W[lLiaprmfFsoRt]}|
1709 @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]]
c7c55b78
NC
1710 [@option{-G}|@option{--stabs}]
1711 [@option{-t}|@option{--syms}]
1712 [@option{-T}|@option{--dynamic-syms}]
1713 [@option{-x}|@option{--all-headers}]
1714 [@option{-w}|@option{--wide}]
1715 [@option{--start-address=}@var{address}]
1716 [@option{--stop-address=}@var{address}]
1717 [@option{--prefix-addresses}]
1718 [@option{--[no-]show-raw-insn}]
1719 [@option{--adjust-vma=}@var{offset}]
3c9458e9 1720 [@option{--special-syms}]
0dafdf3f
L
1721 [@option{--prefix=}@var{prefix}]
1722 [@option{--prefix-strip=}@var{level}]
3dcb3fcb 1723 [@option{--insn-width=}@var{width}]
c7c55b78
NC
1724 [@option{-V}|@option{--version}]
1725 [@option{-H}|@option{--help}]
252b5132 1726 @var{objfile}@dots{}
0285c67d 1727@c man end
252b5132
RH
1728@end smallexample
1729
0285c67d
NC
1730@c man begin DESCRIPTION objdump
1731
c7c55b78 1732@command{objdump} displays information about one or more object files.
252b5132
RH
1733The options control what particular information to display. This
1734information is mostly useful to programmers who are working on the
1735compilation tools, as opposed to programmers who just want their
1736program to compile and work.
1737
1738@var{objfile}@dots{} are the object files to be examined. When you
c7c55b78 1739specify archives, @command{objdump} shows information on each of the member
252b5132
RH
1740object files.
1741
0285c67d
NC
1742@c man end
1743
1744@c man begin OPTIONS objdump
1745
252b5132 1746The long and short forms of options, shown here as alternatives, are
1dada9c5 1747equivalent. At least one option from the list
155e0d23 1748@option{-a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-r,-R,-s,-S,-t,-T,-V,-x} must be given.
252b5132 1749
c7c55b78 1750@table @env
252b5132
RH
1751@item -a
1752@itemx --archive-header
1753@cindex archive headers
1754If any of the @var{objfile} files are archives, display the archive
1755header information (in a format similar to @samp{ls -l}). Besides the
1756information you could list with @samp{ar tv}, @samp{objdump -a} shows
1757the object file format of each archive member.
1758
1759@item --adjust-vma=@var{offset}
1760@cindex section addresses in objdump
1761@cindex VMA in objdump
1762When dumping information, first add @var{offset} to all the section
1763addresses. This is useful if the section addresses do not correspond to
1764the symbol table, which can happen when putting sections at particular
1765addresses when using a format which can not represent section addresses,
1766such as a.out.
1767
1768@item -b @var{bfdname}
1769@itemx --target=@var{bfdname}
1770@cindex object code format
1771Specify that the object-code format for the object files is
1772@var{bfdname}. This option may not be necessary; @var{objdump} can
1773automatically recognize many formats.
1774
1775For example,
1776@example
1777objdump -b oasys -m vax -h fu.o
1778@end example
1779@noindent
c7c55b78
NC
1780displays summary information from the section headers (@option{-h}) of
1781@file{fu.o}, which is explicitly identified (@option{-m}) as a VAX object
252b5132 1782file in the format produced by Oasys compilers. You can list the
c7c55b78 1783formats available with the @option{-i} option.
252b5132
RH
1784@xref{Target Selection}, for more information.
1785
1786@item -C
28c309a2 1787@itemx --demangle[=@var{style}]
252b5132
RH
1788@cindex demangling in objdump
1789Decode (@dfn{demangle}) low-level symbol names into user-level names.
1790Besides removing any initial underscore prepended by the system, this
28c309a2 1791makes C++ function names readable. Different compilers have different
c1c0eb9e
RM
1792mangling styles. The optional demangling style argument can be used to
1793choose an appropriate demangling style for your compiler. @xref{c++filt},
28c309a2 1794for more information on demangling.
252b5132 1795
947ed062
NC
1796@item -g
1797@itemx --debugging
b922d590
NC
1798Display debugging information. This attempts to parse STABS and IEEE
1799debugging format information stored in the file and print it out using
1800a C like syntax. If neither of these formats are found this option
1801falls back on the @option{-W} option to print any DWARF information in
1802the file.
252b5132 1803
51cdc6e0
NC
1804@item -e
1805@itemx --debugging-tags
1806Like @option{-g}, but the information is generated in a format compatible
1807with ctags tool.
1808
252b5132
RH
1809@item -d
1810@itemx --disassemble
1811@cindex disassembling object code
1812@cindex machine instructions
1813Display the assembler mnemonics for the machine instructions from
1814@var{objfile}. This option only disassembles those sections which are
1815expected to contain instructions.
1816
1817@item -D
1818@itemx --disassemble-all
c7c55b78 1819Like @option{-d}, but disassemble the contents of all sections, not just
252b5132
RH
1820those expected to contain instructions.
1821
0313a2b8
NC
1822If the target is an ARM architecture this switch also has the effect
1823of forcing the disassembler to decode pieces of data found in code
1824sections as if they were instructions.
1825
252b5132
RH
1826@item --prefix-addresses
1827When disassembling, print the complete address on each line. This is
1828the older disassembly format.
1829
252b5132
RH
1830@item -EB
1831@itemx -EL
1832@itemx --endian=@{big|little@}
1833@cindex endianness
1834@cindex disassembly endianness
1835Specify the endianness of the object files. This only affects
1836disassembly. This can be useful when disassembling a file format which
1837does not describe endianness information, such as S-records.
1838
1839@item -f
947ed062 1840@itemx --file-headers
252b5132
RH
1841@cindex object file header
1842Display summary information from the overall header of
1843each of the @var{objfile} files.
1844
98ec6e72
NC
1845@item -F
1846@itemx --file-offsets
1847@cindex object file offsets
1848When disassembling sections, whenever a symbol is displayed, also
1849display the file offset of the region of data that is about to be
1850dumped. If zeroes are being skipped, then when disassembly resumes,
1851tell the user how many zeroes were skipped and the file offset of the
32760852
NC
1852location from where the disassembly resumes. When dumping sections,
1853display the file offset of the location from where the dump starts.
98ec6e72 1854
f1563258
TW
1855@item --file-start-context
1856@cindex source code context
1857Specify that when displaying interlisted source code/disassembly
c7c55b78 1858(assumes @option{-S}) from a file that has not yet been displayed, extend the
f1563258
TW
1859context to the start of the file.
1860
252b5132 1861@item -h
947ed062
NC
1862@itemx --section-headers
1863@itemx --headers
252b5132
RH
1864@cindex section headers
1865Display summary information from the section headers of the
1866object file.
1867
1868File segments may be relocated to nonstandard addresses, for example by
c7c55b78
NC
1869using the @option{-Ttext}, @option{-Tdata}, or @option{-Tbss} options to
1870@command{ld}. However, some object file formats, such as a.out, do not
252b5132 1871store the starting address of the file segments. In those situations,
c7c55b78 1872although @command{ld} relocates the sections correctly, using @samp{objdump
252b5132
RH
1873-h} to list the file section headers cannot show the correct addresses.
1874Instead, it shows the usual addresses, which are implicit for the
1875target.
1876
947ed062
NC
1877@item -H
1878@itemx --help
c7c55b78 1879Print a summary of the options to @command{objdump} and exit.
252b5132
RH
1880
1881@item -i
1882@itemx --info
1883@cindex architectures available
1884@cindex object formats available
1885Display a list showing all architectures and object formats available
c7c55b78 1886for specification with @option{-b} or @option{-m}.
252b5132
RH
1887
1888@item -j @var{name}
1889@itemx --section=@var{name}
1890@cindex section information
1891Display information only for section @var{name}.
1892
1893@item -l
1894@itemx --line-numbers
1895@cindex source filenames for object files
1896Label the display (using debugging information) with the filename and
1897source line numbers corresponding to the object code or relocs shown.
c7c55b78 1898Only useful with @option{-d}, @option{-D}, or @option{-r}.
252b5132
RH
1899
1900@item -m @var{machine}
1901@itemx --architecture=@var{machine}
1902@cindex architecture
1903@cindex disassembly architecture
1904Specify the architecture to use when disassembling object files. This
1905can be useful when disassembling object files which do not describe
1906architecture information, such as S-records. You can list the available
c7c55b78 1907architectures with the @option{-i} option.
252b5132 1908
0313a2b8
NC
1909If the target is an ARM architecture then this switch has an
1910additional effect. It restricts the disassembly to only those
1911instructions supported by the architecture specified by @var{machine}.
1912If it is necessary to use this switch because the input file does not
1913contain any architecture information, but it is also desired to
1914disassemble all the instructions use @option{-marm}.
1915
dd92f639
NC
1916@item -M @var{options}
1917@itemx --disassembler-options=@var{options}
1918Pass target specific information to the disassembler. Only supported on
31e0f3cd
NC
1919some targets. If it is necessary to specify more than one
1920disassembler option then multiple @option{-M} options can be used or
1921can be placed together into a comma separated list.
dd92f639
NC
1922
1923If the target is an ARM architecture then this switch can be used to
1924select which register name set is used during disassembler. Specifying
9c092ace 1925@option{-M reg-names-std} (the default) will select the register names as
58efb6c0
NC
1926used in ARM's instruction set documentation, but with register 13 called
1927'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying
c7c55b78
NC
1928@option{-M reg-names-apcs} will select the name set used by the ARM
1929Procedure Call Standard, whilst specifying @option{-M reg-names-raw} will
58efb6c0
NC
1930just use @samp{r} followed by the register number.
1931
1932There are also two variants on the APCS register naming scheme enabled
c7c55b78
NC
1933by @option{-M reg-names-atpcs} and @option{-M reg-names-special-atpcs} which
1934use the ARM/Thumb Procedure Call Standard naming conventions. (Either
947ed062 1935with the normal register names or the special register names).
dd92f639 1936
8f915f68 1937This option can also be used for ARM architectures to force the
c36774d6 1938disassembler to interpret all instructions as Thumb instructions by
c7c55b78 1939using the switch @option{--disassembler-options=force-thumb}. This can be
8f915f68
NC
1940useful when attempting to disassemble thumb code produced by other
1941compilers.
1942
e396998b
AM
1943For the x86, some of the options duplicate functions of the @option{-m}
1944switch, but allow finer grained control. Multiple selections from the
1945following may be specified as a comma separated string.
b89e9eae 1946@option{x86-64}, @option{i386} and @option{i8086} select disassembly for
e396998b 1947the given architecture. @option{intel} and @option{att} select between
9d141669
L
1948intel syntax mode and AT&T syntax mode.
1949@option{intel-mnemonic} and @option{att-mnemonic} select between
1950intel mnemonic mode and AT&T mnemonic mode. @option{intel-mnemonic}
1951implies @option{intel} and @option{att-mnemonic} implies @option{att}.
1952@option{addr64}, @option{addr32},
e396998b
AM
1953@option{addr16}, @option{data32} and @option{data16} specify the default
1954address size and operand size. These four options will be overridden if
b89e9eae 1955@option{x86-64}, @option{i386} or @option{i8086} appear later in the
e396998b 1956option string. Lastly, @option{suffix}, when in AT&T mode,
b9e5d8e5 1957instructs the disassembler to print a mnemonic suffix even when the
e396998b
AM
1958suffix could be inferred by the operands.
1959
2f3bb96a
BE
1960For PowerPC, @option{booke} controls the disassembly of BookE
1961instructions. @option{32} and @option{64} select PowerPC and
1962PowerPC64 disassembly, respectively. @option{e300} selects
1963disassembly for the e300 family. @option{440} selects disassembly for
1964the PowerPC 440. @option{ppcps} selects disassembly for the paired
1965single instructions of the PPC750CL.
802a735e 1966
b45619c0 1967For MIPS, this option controls the printing of instruction mnemonic
e39893d7
FF
1968names and register names in disassembled instructions. Multiple
1969selections from the following may be specified as a comma separated
1970string, and invalid options are ignored:
640c0ccd
CD
1971
1972@table @code
e39893d7 1973@item no-aliases
b45619c0
NC
1974Print the 'raw' instruction mnemonic instead of some pseudo
1975instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move',
e39893d7
FF
1976'sll' instead of 'nop', etc.
1977
640c0ccd
CD
1978@item gpr-names=@var{ABI}
1979Print GPR (general-purpose register) names as appropriate
1980for the specified ABI. By default, GPR names are selected according to
1981the ABI of the binary being disassembled.
1982
1983@item fpr-names=@var{ABI}
1984Print FPR (floating-point register) names as
1985appropriate for the specified ABI. By default, FPR numbers are printed
1986rather than names.
1987
1988@item cp0-names=@var{ARCH}
1989Print CP0 (system control coprocessor; coprocessor 0) register names
1990as appropriate for the CPU or architecture specified by
1991@var{ARCH}. By default, CP0 register names are selected according to
1992the architecture and CPU of the binary being disassembled.
1993
af7ee8bf
CD
1994@item hwr-names=@var{ARCH}
1995Print HWR (hardware register, used by the @code{rdhwr} instruction) names
1996as appropriate for the CPU or architecture specified by
1997@var{ARCH}. By default, HWR names are selected according to
1998the architecture and CPU of the binary being disassembled.
1999
640c0ccd
CD
2000@item reg-names=@var{ABI}
2001Print GPR and FPR names as appropriate for the selected ABI.
2002
2003@item reg-names=@var{ARCH}
af7ee8bf
CD
2004Print CPU-specific register names (CP0 register and HWR names)
2005as appropriate for the selected CPU or architecture.
640c0ccd
CD
2006@end table
2007
2008For any of the options listed above, @var{ABI} or
2009@var{ARCH} may be specified as @samp{numeric} to have numbers printed
2010rather than names, for the selected types of registers.
2011You can list the available values of @var{ABI} and @var{ARCH} using
2012the @option{--help} option.
2013
ec72cfe5
NC
2014For VAX, you can specify function entry addresses with @option{-M
2015entry:0xf00ba}. You can use this multiple times to properly
2016disassemble VAX binary files that don't contain symbol tables (like
2017ROM dumps). In these cases, the function entry mask would otherwise
b45619c0 2018be decoded as VAX instructions, which would probably lead the rest
ec72cfe5
NC
2019of the function being wrongly disassembled.
2020
252b5132
RH
2021@item -p
2022@itemx --private-headers
2023Print information that is specific to the object file format. The exact
2024information printed depends upon the object file format. For some
2025object file formats, no additional information is printed.
2026
2027@item -r
2028@itemx --reloc
2029@cindex relocation entries, in object file
c7c55b78
NC
2030Print the relocation entries of the file. If used with @option{-d} or
2031@option{-D}, the relocations are printed interspersed with the
252b5132
RH
2032disassembly.
2033
2034@item -R
2035@itemx --dynamic-reloc
2036@cindex dynamic relocation entries, in object file
2037Print the dynamic relocation entries of the file. This is only
2038meaningful for dynamic objects, such as certain types of shared
840b96a7
AM
2039libraries. As for @option{-r}, if used with @option{-d} or
2040@option{-D}, the relocations are printed interspersed with the
2041disassembly.
252b5132
RH
2042
2043@item -s
2044@itemx --full-contents
2045@cindex sections, full contents
2046@cindex object file sections
155e0d23
NC
2047Display the full contents of any sections requested. By default all
2048non-empty sections are displayed.
252b5132
RH
2049
2050@item -S
2051@itemx --source
2052@cindex source disassembly
2053@cindex disassembly, with source
2054Display source code intermixed with disassembly, if possible. Implies
c7c55b78 2055@option{-d}.
252b5132 2056
0dafdf3f
L
2057@item --prefix=@var{prefix}
2058@cindex Add prefix to absolute paths
2059Specify @var{prefix} to add to the absolute paths when used with
2060@option{-S}.
2061
2062@item --prefix-strip=@var{level}
2063@cindex Strip absolute paths
2064Indicate how many initial directory names to strip off the hardwired
2065absolute paths. It has no effect without @option{--prefix=}@var{prefix}.
2066
252b5132
RH
2067@item --show-raw-insn
2068When disassembling instructions, print the instruction in hex as well as
2069in symbolic form. This is the default except when
c7c55b78 2070@option{--prefix-addresses} is used.
252b5132
RH
2071
2072@item --no-show-raw-insn
2073When disassembling instructions, do not print the instruction bytes.
c7c55b78 2074This is the default when @option{--prefix-addresses} is used.
252b5132 2075
3dcb3fcb
L
2076@item --insn-width=@var{width}
2077@cindex Instruction width
2078Display @var{width} bytes on a single line when disassembling
2079instructions.
2080
f9f0e732
NC
2081@item -W[lLiaprmfFsoRt]
2082@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]
4de2ad99
L
2083@cindex DWARF
2084@cindex debug symbols
4cb93e3b
TG
2085Displays the contents of the debug sections in the file, if any are
2086present. If one of the optional letters or words follows the switch
2087then only data found in those specific sections will be dumped.
4de2ad99 2088
1dada9c5 2089@item -G
947ed062 2090@itemx --stabs
252b5132
RH
2091@cindex stab
2092@cindex .stab
2093@cindex debug symbols
2094@cindex ELF object file format
2095Display the full contents of any sections requested. Display the
2096contents of the .stab and .stab.index and .stab.excl sections from an
2097ELF file. This is only useful on systems (such as Solaris 2.0) in which
2098@code{.stab} debugging symbol-table entries are carried in an ELF
2099section. In most other file formats, debugging symbol-table entries are
c7c55b78 2100interleaved with linkage symbols, and are visible in the @option{--syms}
0285c67d
NC
2101output.
2102@ifclear man
2103For more information on stabs symbols, see @ref{Top,Stabs,Stabs
252b5132 2104Overview,stabs.info, The ``stabs'' debug format}.
0285c67d 2105@end ifclear
252b5132
RH
2106
2107@item --start-address=@var{address}
2108@cindex start-address
2109Start displaying data at the specified address. This affects the output
c7c55b78 2110of the @option{-d}, @option{-r} and @option{-s} options.
252b5132
RH
2111
2112@item --stop-address=@var{address}
2113@cindex stop-address
2114Stop displaying data at the specified address. This affects the output
c7c55b78 2115of the @option{-d}, @option{-r} and @option{-s} options.
252b5132
RH
2116
2117@item -t
2118@itemx --syms
2119@cindex symbol table entries, printing
2120Print the symbol table entries of the file.
a1039809
NC
2121This is similar to the information provided by the @samp{nm} program,
2122although the display format is different. The format of the output
2123depends upon the format of the file being dumped, but there are two main
2124types. One looks like this:
2125
2126@smallexample
2127[ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss
2128[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred
2129@end smallexample
2130
2131where the number inside the square brackets is the number of the entry
2132in the symbol table, the @var{sec} number is the section number, the
2133@var{fl} value are the symbol's flag bits, the @var{ty} number is the
2134symbol's type, the @var{scl} number is the symbol's storage class and
2135the @var{nx} value is the number of auxilary entries associated with
2136the symbol. The last two fields are the symbol's value and its name.
2137
2138The other common output format, usually seen with ELF based files,
2139looks like this:
2140
2141@smallexample
214200000000 l d .bss 00000000 .bss
214300000000 g .text 00000000 fred
2144@end smallexample
2145
2146Here the first number is the symbol's value (sometimes refered to as
2147its address). The next field is actually a set of characters and
2148spaces indicating the flag bits that are set on the symbol. These
af3e16d9
NC
2149characters are described below. Next is the section with which the
2150symbol is associated or @emph{*ABS*} if the section is absolute (ie
2151not connected with any section), or @emph{*UND*} if the section is
2152referenced in the file being dumped, but not defined there.
2153
2154After the section name comes another field, a number, which for common
2155symbols is the alignment and for other symbol is the size. Finally
2156the symbol's name is displayed.
a1039809
NC
2157
2158The flag characters are divided into 7 groups as follows:
2159@table @code
2160@item l
2161@itemx g
3e7a7d11 2162@itemx u
a1039809 2163@itemx !
3e7a7d11
NC
2164The symbol is a local (l), global (g), unique global (u), neither
2165global nor local (a space) or both global and local (!). A
928a4139 2166symbol can be neither local or global for a variety of reasons, e.g.,
a1039809 2167because it is used for debugging, but it is probably an indication of
3e7a7d11
NC
2168a bug if it is ever both local and global. Unique global symbols are
2169a GNU extension to the standard set of ELF symbol bindings. For such
2170a symbol the dynamic linker will make sure that in the entire process
2171there is just one symbol with this name and type in use.
a1039809
NC
2172
2173@item w
2174The symbol is weak (w) or strong (a space).
2175
2176@item C
2177The symbol denotes a constructor (C) or an ordinary symbol (a space).
2178
2179@item W
2180The symbol is a warning (W) or a normal symbol (a space). A warning
2181symbol's name is a message to be displayed if the symbol following the
2182warning symbol is ever referenced.
2183
2184@item I
171191ba
NC
2185@item i
2186The symbol is an indirect reference to another symbol (I), a function
2187to be evaluated during reloc processing (i) or a normal symbol (a
2188space).
a1039809
NC
2189
2190@item d
2191@itemx D
2192The symbol is a debugging symbol (d) or a dynamic symbol (D) or a
2193normal symbol (a space).
2194
2195@item F
2196@item f
2197@item O
af3e16d9 2198The symbol is the name of a function (F) or a file (f) or an object
a1039809
NC
2199(O) or just a normal symbol (a space).
2200@end table
252b5132
RH
2201
2202@item -T
2203@itemx --dynamic-syms
2204@cindex dynamic symbol table entries, printing
2205Print the dynamic symbol table entries of the file. This is only
2206meaningful for dynamic objects, such as certain types of shared
2207libraries. This is similar to the information provided by the @samp{nm}
c7c55b78 2208program when given the @option{-D} (@option{--dynamic}) option.
252b5132 2209
3c9458e9
NC
2210@item --special-syms
2211When displaying symbols include those which the target considers to be
2212special in some way and which would not normally be of interest to the
2213user.
2214
947ed062
NC
2215@item -V
2216@itemx --version
c7c55b78 2217Print the version number of @command{objdump} and exit.
252b5132
RH
2218
2219@item -x
947ed062 2220@itemx --all-headers
252b5132
RH
2221@cindex all header information, object file
2222@cindex header information, all
2223Display all available header information, including the symbol table and
c7c55b78 2224relocation entries. Using @option{-x} is equivalent to specifying all of
04c34128 2225@option{-a -f -h -p -r -t}.
252b5132
RH
2226
2227@item -w
2228@itemx --wide
2229@cindex wide output, printing
2230Format some lines for output devices that have more than 80 columns.
31104126 2231Also do not truncate symbol names when they are displayed.
aefbdd67
BE
2232
2233@item -z
2c0c15f9 2234@itemx --disassemble-zeroes
aefbdd67
BE
2235Normally the disassembly output will skip blocks of zeroes. This
2236option directs the disassembler to disassemble those blocks, just like
2237any other data.
252b5132
RH
2238@end table
2239
0285c67d
NC
2240@c man end
2241
2242@ignore
2243@c man begin SEEALSO objdump
2244nm(1), readelf(1), and the Info entries for @file{binutils}.
2245@c man end
2246@end ignore
2247
252b5132
RH
2248@node ranlib
2249@chapter ranlib
2250
2251@kindex ranlib
2252@cindex archive contents
2253@cindex symbol index
2254
0285c67d
NC
2255@c man title ranlib generate index to archive.
2256
252b5132 2257@smallexample
0285c67d 2258@c man begin SYNOPSIS ranlib
b14f9da0 2259ranlib [@option{-vVt}] @var{archive}
0285c67d 2260@c man end
252b5132
RH
2261@end smallexample
2262
0285c67d
NC
2263@c man begin DESCRIPTION ranlib
2264
c7c55b78 2265@command{ranlib} generates an index to the contents of an archive and
252b5132 2266stores it in the archive. The index lists each symbol defined by a
c1c0eb9e 2267member of an archive that is a relocatable object file.
252b5132
RH
2268
2269You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
2270
2271An archive with such an index speeds up linking to the library and
2272allows routines in the library to call each other without regard to
2273their placement in the archive.
2274
c7c55b78
NC
2275The @sc{gnu} @command{ranlib} program is another form of @sc{gnu} @command{ar}; running
2276@command{ranlib} is completely equivalent to executing @samp{ar -s}.
252b5132
RH
2277@xref{ar}.
2278
0285c67d
NC
2279@c man end
2280
2281@c man begin OPTIONS ranlib
2282
c7c55b78 2283@table @env
252b5132
RH
2284@item -v
2285@itemx -V
f20a759a 2286@itemx --version
c7c55b78 2287Show the version number of @command{ranlib}.
b14f9da0
NC
2288
2289@item -t
2290Update the timestamp of the symbol map of an archive.
252b5132
RH
2291@end table
2292
0285c67d
NC
2293@c man end
2294
2295@ignore
2296@c man begin SEEALSO ranlib
2297ar(1), nm(1), and the Info entries for @file{binutils}.
2298@c man end
2299@end ignore
2300
252b5132
RH
2301@node size
2302@chapter size
2303
2304@kindex size
2305@cindex section sizes
2306
0285c67d
NC
2307@c man title size list section sizes and total size.
2308
252b5132 2309@smallexample
0285c67d 2310@c man begin SYNOPSIS size
c7c55b78 2311size [@option{-A}|@option{-B}|@option{--format=}@var{compatibility}]
15c82623
NC
2312 [@option{--help}]
2313 [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}]
29422971 2314 [@option{--common}]
15c82623 2315 [@option{-t}|@option{--totals}]
c1c0eb9e 2316 [@option{--target=}@var{bfdname}] [@option{-V}|@option{--version}]
c7c55b78 2317 [@var{objfile}@dots{}]
0285c67d 2318@c man end
252b5132
RH
2319@end smallexample
2320
0285c67d
NC
2321@c man begin DESCRIPTION size
2322
c7c55b78 2323The @sc{gnu} @command{size} utility lists the section sizes---and the total
252b5132
RH
2324size---for each of the object or archive files @var{objfile} in its
2325argument list. By default, one line of output is generated for each
2326object file or each module in an archive.
2327
2328@var{objfile}@dots{} are the object files to be examined.
2329If none are specified, the file @code{a.out} will be used.
2330
0285c67d
NC
2331@c man end
2332
2333@c man begin OPTIONS size
2334
252b5132
RH
2335The command line options have the following meanings:
2336
c7c55b78 2337@table @env
252b5132
RH
2338@item -A
2339@itemx -B
2340@itemx --format=@var{compatibility}
c7c55b78 2341@cindex @command{size} display format
252b5132 2342Using one of these options, you can choose whether the output from @sc{gnu}
c7c55b78
NC
2343@command{size} resembles output from System V @command{size} (using @option{-A},
2344or @option{--format=sysv}), or Berkeley @command{size} (using @option{-B}, or
2345@option{--format=berkeley}). The default is the one-line format similar to
c1c0eb9e 2346Berkeley's.
252b5132
RH
2347@c Bonus for doc-source readers: you can also say --format=strange (or
2348@c anything else that starts with 's') for sysv, and --format=boring (or
2349@c anything else that starts with 'b') for Berkeley.
2350
2351Here is an example of the Berkeley (default) format of output from
c1c0eb9e 2352@command{size}:
252b5132 2353@smallexample
f20a759a 2354$ size --format=Berkeley ranlib size
252b5132
RH
2355text data bss dec hex filename
2356294880 81920 11592 388392 5ed28 ranlib
2357294880 81920 11888 388688 5ee50 size
2358@end smallexample
2359
2360@noindent
2361This is the same data, but displayed closer to System V conventions:
2362
2363@smallexample
f20a759a 2364$ size --format=SysV ranlib size
252b5132
RH
2365ranlib :
2366section size addr
c1c0eb9e
RM
2367.text 294880 8192
2368.data 81920 303104
2369.bss 11592 385024
2370Total 388392
252b5132
RH
2371
2372
2373size :
2374section size addr
c1c0eb9e
RM
2375.text 294880 8192
2376.data 81920 303104
2377.bss 11888 385024
2378Total 388688
252b5132
RH
2379@end smallexample
2380
2381@item --help
2382Show a summary of acceptable arguments and options.
2383
2384@item -d
2385@itemx -o
2386@itemx -x
2387@itemx --radix=@var{number}
c7c55b78 2388@cindex @command{size} number format
252b5132
RH
2389@cindex radix for section sizes
2390Using one of these options, you can control whether the size of each
c7c55b78
NC
2391section is given in decimal (@option{-d}, or @option{--radix=10}); octal
2392(@option{-o}, or @option{--radix=8}); or hexadecimal (@option{-x}, or
2393@option{--radix=16}). In @option{--radix=@var{number}}, only the three
252b5132 2394values (8, 10, 16) are supported. The total size is always given in two
c7c55b78
NC
2395radices; decimal and hexadecimal for @option{-d} or @option{-x} output, or
2396octal and hexadecimal if you're using @option{-o}.
252b5132 2397
29422971
AM
2398@item --common
2399Print total size of common symbols in each file. When using Berkeley
2400format these are included in the bss size.
2401
15c82623
NC
2402@item -t
2403@itemx --totals
2404Show totals of all objects listed (Berkeley format listing mode only).
2405
252b5132
RH
2406@item --target=@var{bfdname}
2407@cindex object code format
2408Specify that the object-code format for @var{objfile} is
c7c55b78 2409@var{bfdname}. This option may not be necessary; @command{size} can
252b5132
RH
2410automatically recognize many formats.
2411@xref{Target Selection}, for more information.
2412
2413@item -V
2414@itemx --version
c7c55b78 2415Display the version number of @command{size}.
252b5132
RH
2416@end table
2417
0285c67d
NC
2418@c man end
2419
2420@ignore
2421@c man begin SEEALSO size
2422ar(1), objdump(1), readelf(1), and the Info entries for @file{binutils}.
2423@c man end
2424@end ignore
2425
252b5132
RH
2426@node strings
2427@chapter strings
2428@kindex strings
2429@cindex listings strings
2430@cindex printing strings
2431@cindex strings, printing
2432
0285c67d
NC
2433@c man title strings print the strings of printable characters in files.
2434
252b5132 2435@smallexample
0285c67d 2436@c man begin SYNOPSIS strings
ffbe5983 2437strings [@option{-afovV}] [@option{-}@var{min-len}]
d132876a
NC
2438 [@option{-n} @var{min-len}] [@option{--bytes=}@var{min-len}]
2439 [@option{-t} @var{radix}] [@option{--radix=}@var{radix}]
2440 [@option{-e} @var{encoding}] [@option{--encoding=}@var{encoding}]
2441 [@option{-}] [@option{--all}] [@option{--print-file-name}]
3bf31ec9 2442 [@option{-T} @var{bfdname}] [@option{--target=}@var{bfdname}]
c7c55b78 2443 [@option{--help}] [@option{--version}] @var{file}@dots{}
0285c67d 2444@c man end
252b5132
RH
2445@end smallexample
2446
0285c67d
NC
2447@c man begin DESCRIPTION strings
2448
c7c55b78 2449For each @var{file} given, @sc{gnu} @command{strings} prints the printable
252b5132
RH
2450character sequences that are at least 4 characters long (or the number
2451given with the options below) and are followed by an unprintable
2452character. By default, it only prints the strings from the initialized
2453and loaded sections of object files; for other types of files, it prints
2454the strings from the whole file.
2455
c7c55b78 2456@command{strings} is mainly useful for determining the contents of non-text
252b5132
RH
2457files.
2458
0285c67d
NC
2459@c man end
2460
2461@c man begin OPTIONS strings
2462
c7c55b78 2463@table @env
252b5132
RH
2464@item -a
2465@itemx --all
2466@itemx -
2467Do not scan only the initialized and loaded sections of object files;
2468scan the whole files.
2469
2470@item -f
2471@itemx --print-file-name
2472Print the name of the file before each string.
2473
2474@item --help
2475Print a summary of the program usage on the standard output and exit.
2476
2477@item -@var{min-len}
2478@itemx -n @var{min-len}
2479@itemx --bytes=@var{min-len}
2480Print sequences of characters that are at least @var{min-len} characters
2481long, instead of the default 4.
2482
2483@item -o
c7c55b78 2484Like @samp{-t o}. Some other versions of @command{strings} have @option{-o}
252b5132
RH
2485act like @samp{-t d} instead. Since we can not be compatible with both
2486ways, we simply chose one.
2487
2488@item -t @var{radix}
2489@itemx --radix=@var{radix}
2490Print the offset within the file before each string. The single
2491character argument specifies the radix of the offset---@samp{o} for
2492octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
2493
d132876a
NC
2494@item -e @var{encoding}
2495@itemx --encoding=@var{encoding}
2496Select the character encoding of the strings that are to be found.
8745eafa
NC
2497Possible values for @var{encoding} are: @samp{s} = single-7-bit-byte
2498characters (ASCII, ISO 8859, etc., default), @samp{S} =
2499single-8-bit-byte characters, @samp{b} = 16-bit bigendian, @samp{l} =
250016-bit littleendian, @samp{B} = 32-bit bigendian, @samp{L} = 32-bit
830bf75c
NC
2501littleendian. Useful for finding wide character strings. (@samp{l}
2502and @samp{b} apply to, for example, Unicode UTF-16/UCS-2 encodings).
d132876a 2503
3bf31ec9
NC
2504@item -T @var{bfdname}
2505@itemx --target=@var{bfdname}
252b5132
RH
2506@cindex object code format
2507Specify an object code format other than your system's default format.
2508@xref{Target Selection}, for more information.
2509
2510@item -v
ffbe5983 2511@itemx -V
252b5132
RH
2512@itemx --version
2513Print the program version number on the standard output and exit.
2514@end table
2515
0285c67d
NC
2516@c man end
2517
2518@ignore
2519@c man begin SEEALSO strings
2520ar(1), nm(1), objdump(1), ranlib(1), readelf(1)
2521and the Info entries for @file{binutils}.
2522@c man end
2523@end ignore
2524
252b5132
RH
2525@node strip
2526@chapter strip
2527
2528@kindex strip
2529@cindex removing symbols
2530@cindex discarding symbols
2531@cindex symbols, discarding
2532
0285c67d
NC
2533@c man title strip Discard symbols from object files.
2534
252b5132 2535@smallexample
0285c67d 2536@c man begin SYNOPSIS strip
2593f09a
NC
2537strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}]
2538 [@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname}]
2539 [@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}]
2540 [@option{-s}|@option{--strip-all}]
2541 [@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}]
2542 [@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname}]
2543 [@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}]
5fe11841 2544 [@option{-w}|@option{--wildcard}]
2593f09a
NC
2545 [@option{-x}|@option{--discard-all}] [@option{-X} |@option{--discard-locals}]
2546 [@option{-R} @var{sectionname} |@option{--remove-section=}@var{sectionname}]
2547 [@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}]
1637cd90 2548 [@option{--keep-file-symbols}]
ed1653a7 2549 [@option{--only-keep-debug}]
7c29036b
NC
2550 [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}]
2551 [@option{--help}] [@option{--info}]
252b5132 2552 @var{objfile}@dots{}
0285c67d 2553@c man end
252b5132
RH
2554@end smallexample
2555
0285c67d
NC
2556@c man begin DESCRIPTION strip
2557
c7c55b78 2558@sc{gnu} @command{strip} discards all symbols from object files
252b5132
RH
2559@var{objfile}. The list of object files may include archives.
2560At least one object file must be given.
2561
c7c55b78 2562@command{strip} modifies the files named in its argument,
252b5132
RH
2563rather than writing modified copies under different names.
2564
0285c67d
NC
2565@c man end
2566
2567@c man begin OPTIONS strip
2568
c7c55b78 2569@table @env
252b5132
RH
2570@item -F @var{bfdname}
2571@itemx --target=@var{bfdname}
2572Treat the original @var{objfile} as a file with the object
2573code format @var{bfdname}, and rewrite it in the same format.
2574@xref{Target Selection}, for more information.
2575
2576@item --help
c7c55b78 2577Show a summary of the options to @command{strip} and exit.
252b5132 2578
7c29036b
NC
2579@item --info
2580Display a list showing all architectures and object formats available.
2581
947ed062 2582@item -I @var{bfdname}
252b5132
RH
2583@itemx --input-target=@var{bfdname}
2584Treat the original @var{objfile} as a file with the object
2585code format @var{bfdname}.
2586@xref{Target Selection}, for more information.
2587
2588@item -O @var{bfdname}
2589@itemx --output-target=@var{bfdname}
2590Replace @var{objfile} with a file in the output format @var{bfdname}.
2591@xref{Target Selection}, for more information.
2592
2593@item -R @var{sectionname}
2594@itemx --remove-section=@var{sectionname}
2595Remove any section named @var{sectionname} from the output file. This
2596option may be given more than once. Note that using this option
2597inappropriately may make the output file unusable.
2598
2599@item -s
2600@itemx --strip-all
2601Remove all symbols.
2602
2603@item -g
2604@itemx -S
15c82623 2605@itemx -d
252b5132
RH
2606@itemx --strip-debug
2607Remove debugging symbols only.
2608
2609@item --strip-unneeded
2610Remove all symbols that are not needed for relocation processing.
2611
2612@item -K @var{symbolname}
2613@itemx --keep-symbol=@var{symbolname}
e7f918ad
NC
2614When stripping symbols, keep symbol @var{symbolname} even if it would
2615normally be stripped. This option may be given more than once.
252b5132
RH
2616
2617@item -N @var{symbolname}
2618@itemx --strip-symbol=@var{symbolname}
2619Remove symbol @var{symbolname} from the source file. This option may be
2620given more than once, and may be combined with strip options other than
c7c55b78 2621@option{-K}.
252b5132
RH
2622
2623@item -o @var{file}
2624Put the stripped output in @var{file}, rather than replacing the
2625existing file. When this argument is used, only one @var{objfile}
2626argument may be specified.
2627
2628@item -p
2629@itemx --preserve-dates
2630Preserve the access and modification dates of the file.
2631
5fe11841
NC
2632@item -w
2633@itemx --wildcard
2634Permit regular expressions in @var{symbolname}s used in other command
2635line options. The question mark (?), asterisk (*), backslash (\) and
2636square brackets ([]) operators can be used anywhere in the symbol
2637name. If the first character of the symbol name is the exclamation
2638point (!) then the sense of the switch is reversed for that symbol.
2639For example:
2640
2641@smallexample
2642 -w -K !foo -K fo*
2643@end smallexample
2644
2645would cause strip to only keep symbols that start with the letters
2646``fo'', but to discard the symbol ``foo''.
2647
252b5132
RH
2648@item -x
2649@itemx --discard-all
2650Remove non-global symbols.
2651
2652@item -X
2653@itemx --discard-locals
2654Remove compiler-generated local symbols.
2655(These usually start with @samp{L} or @samp{.}.)
2656
1637cd90
JB
2657@item --keep-file-symbols
2658When stripping a file, perhaps with @option{--strip-debug} or
2659@option{--strip-unneeded}, retain any symbols specifying source file names,
2660which would otherwise get stripped.
2661
ed1653a7 2662@item --only-keep-debug
c1c0eb9e
RM
2663Strip a file, removing contents of any sections that would not be
2664stripped by @option{--strip-debug} and leaving the debugging sections
2665intact. In ELF files, this preserves all note sections in the output.
ed1653a7
NC
2666
2667The intention is that this option will be used in conjunction with
2668@option{--add-gnu-debuglink} to create a two part executable. One a
2669stripped binary which will occupy less space in RAM and in a
2670distribution and the second a debugging information file which is only
2671needed if debugging abilities are required. The suggested procedure
2672to create these files is as follows:
2673
2674@enumerate
2675@item Link the executable as normal. Assuming that is is called
2676@code{foo} then...
2677@item Run @code{objcopy --only-keep-debug foo foo.dbg} to
2678create a file containing the debugging info.
2679@item Run @code{objcopy --strip-debug foo} to create a
2680stripped executable.
2681@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo}
2682to add a link to the debugging info into the stripped executable.
2683@end enumerate
2684
928a4139 2685Note---the choice of @code{.dbg} as an extension for the debug info
ed1653a7
NC
2686file is arbitrary. Also the @code{--only-keep-debug} step is
2687optional. You could instead do this:
2688
2689@enumerate
2690@item Link the executable as normal.
928a4139 2691@item Copy @code{foo} to @code{foo.full}
ed1653a7
NC
2692@item Run @code{strip --strip-debug foo}
2693@item Run @code{objcopy --add-gnu-debuglink=foo.full foo}
2694@end enumerate
2695
928a4139 2696i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the
ed1653a7
NC
2697full executable. It does not have to be a file created by the
2698@option{--only-keep-debug} switch.
2699
928a4139 2700Note---this switch is only intended for use on fully linked files. It
91bb255c
NC
2701does not make sense to use it on object files where the debugging
2702information may be incomplete. Besides the gnu_debuglink feature
2703currently only supports the presence of one filename containing
2704debugging information, not multiple filenames on a one-per-object-file
2705basis.
2706
252b5132
RH
2707@item -V
2708@itemx --version
c7c55b78 2709Show the version number for @command{strip}.
252b5132
RH
2710
2711@item -v
2712@itemx --verbose
2713Verbose output: list all object files modified. In the case of
2714archives, @samp{strip -v} lists all members of the archive.
2715@end table
2716
0285c67d
NC
2717@c man end
2718
2719@ignore
2720@c man begin SEEALSO strip
2721the Info entries for @file{binutils}.
2722@c man end
2723@end ignore
2724
30fd33bb 2725@node c++filt, addr2line, elfedit, Top
252b5132
RH
2726@chapter c++filt
2727
2728@kindex c++filt
2729@cindex demangling C++ symbols
2730
0285c67d
NC
2731@c man title cxxfilt Demangle C++ and Java symbols.
2732
252b5132 2733@smallexample
0285c67d 2734@c man begin SYNOPSIS cxxfilt
c7c55b78 2735c++filt [@option{-_}|@option{--strip-underscores}]
c7c55b78 2736 [@option{-n}|@option{--no-strip-underscores}]
4e48c9dd 2737 [@option{-p}|@option{--no-params}]
ec948987 2738 [@option{-t}|@option{--types}]
cbf1f5df 2739 [@option{-i}|@option{--no-verbose}]
c7c55b78
NC
2740 [@option{-s} @var{format}|@option{--format=}@var{format}]
2741 [@option{--help}] [@option{--version}] [@var{symbol}@dots{}]
0285c67d 2742@c man end
252b5132
RH
2743@end smallexample
2744
0285c67d
NC
2745@c man begin DESCRIPTION cxxfilt
2746
9d51cc66 2747@kindex cxxfilt
ec948987
NC
2748The C++ and Java languages provide function overloading, which means
2749that you can write many functions with the same name, providing that
2750each function takes parameters of different types. In order to be
2751able to distinguish these similarly named functions C++ and Java
2752encode them into a low-level assembler name which uniquely identifies
2753each different version. This process is known as @dfn{mangling}. The
2754@command{c++filt}
c1c0eb9e 2755@footnote{MS-DOS does not allow @kbd{+} characters in file names, so on
195a97ce 2756MS-DOS this program is named @command{CXXFILT}.}
9d51cc66 2757program does the inverse mapping: it decodes (@dfn{demangles}) low-level
ec948987 2758names into user-level names so that they can be read.
252b5132
RH
2759
2760Every alphanumeric word (consisting of letters, digits, underscores,
cbf1f5df
NC
2761dollars, or periods) seen in the input is a potential mangled name.
2762If the name decodes into a C++ name, the C++ name replaces the
ec948987
NC
2763low-level name in the output, otherwise the original word is output.
2764In this way you can pass an entire assembler source file, containing
2765mangled names, through @command{c++filt} and see the same source file
2766containing demangled names.
252b5132 2767
ec948987
NC
2768You can also use @command{c++filt} to decipher individual symbols by
2769passing them on the command line:
252b5132
RH
2770
2771@example
2772c++filt @var{symbol}
2773@end example
2774
c7c55b78 2775If no @var{symbol} arguments are given, @command{c++filt} reads symbol
ec948987
NC
2776names from the standard input instead. All the results are printed on
2777the standard output. The difference between reading names from the
2778command line versus reading names from the standard input is that
2779command line arguments are expected to be just mangled names and no
b45619c0 2780checking is performed to separate them from surrounding text. Thus
ec948987
NC
2781for example:
2782
2783@smallexample
2784c++filt -n _Z1fv
2785@end smallexample
2786
2787will work and demangle the name to ``f()'' whereas:
2788
2789@smallexample
2790c++filt -n _Z1fv,
2791@end smallexample
2792
2793will not work. (Note the extra comma at the end of the mangled
2794name which makes it invalid). This command however will work:
2795
2796@smallexample
2797echo _Z1fv, | c++filt -n
2798@end smallexample
2799
928a4139 2800and will display ``f(),'', i.e., the demangled name followed by a
ec948987
NC
2801trailing comma. This behaviour is because when the names are read
2802from the standard input it is expected that they might be part of an
2803assembler source file where there might be extra, extraneous
928a4139 2804characters trailing after a mangled name. For example:
ec948987
NC
2805
2806@smallexample
2807 .type _Z1fv, @@function
2808@end smallexample
252b5132 2809
0285c67d
NC
2810@c man end
2811
2812@c man begin OPTIONS cxxfilt
2813
c7c55b78 2814@table @env
252b5132
RH
2815@item -_
2816@itemx --strip-underscores
2817On some systems, both the C and C++ compilers put an underscore in front
2818of every name. For example, the C name @code{foo} gets the low-level
2819name @code{_foo}. This option removes the initial underscore. Whether
c7c55b78 2820@command{c++filt} removes the underscore by default is target dependent.
252b5132 2821
252b5132
RH
2822@item -n
2823@itemx --no-strip-underscores
2824Do not remove the initial underscore.
2825
4e48c9dd
ILT
2826@item -p
2827@itemx --no-params
2828When demangling the name of a function, do not display the types of
2829the function's parameters.
2830
cbf1f5df 2831@item -t
ec948987
NC
2832@itemx --types
2833Attempt to demangle types as well as function names. This is disabled
2834by default since mangled types are normally only used internally in
928a4139 2835the compiler, and they can be confused with non-mangled names. For example,
ec948987
NC
2836a function called ``a'' treated as a mangled type name would be
2837demangled to ``signed char''.
cbf1f5df
NC
2838
2839@item -i
2840@itemx --no-verbose
2841Do not include implementation details (if any) in the demangled
2842output.
2843
252b5132
RH
2844@item -s @var{format}
2845@itemx --format=@var{format}
947ed062
NC
2846@command{c++filt} can decode various methods of mangling, used by
2847different compilers. The argument to this option selects which
252b5132
RH
2848method it uses:
2849
2850@table @code
947ed062
NC
2851@item auto
2852Automatic selection based on executable (the default method)
252b5132 2853@item gnu
947ed062 2854the one used by the @sc{gnu} C++ compiler (g++)
252b5132 2855@item lucid
947ed062 2856the one used by the Lucid compiler (lcc)
252b5132
RH
2857@item arm
2858the one specified by the C++ Annotated Reference Manual
2859@item hp
947ed062 2860the one used by the HP compiler (aCC)
252b5132
RH
2861@item edg
2862the one used by the EDG compiler
b5e2a4f3 2863@item gnu-v3
947ed062
NC
2864the one used by the @sc{gnu} C++ compiler (g++) with the V3 ABI.
2865@item java
2866the one used by the @sc{gnu} Java compiler (gcj)
2867@item gnat
2868the one used by the @sc{gnu} Ada compiler (GNAT).
252b5132
RH
2869@end table
2870
2871@item --help
c7c55b78 2872Print a summary of the options to @command{c++filt} and exit.
252b5132
RH
2873
2874@item --version
c7c55b78 2875Print the version number of @command{c++filt} and exit.
252b5132
RH
2876@end table
2877
0285c67d
NC
2878@c man end
2879
2880@ignore
2881@c man begin SEEALSO cxxfilt
2882the Info entries for @file{binutils}.
2883@c man end
2884@end ignore
2885
252b5132 2886@quotation
c7c55b78 2887@emph{Warning:} @command{c++filt} is a new utility, and the details of its
252b5132 2888user interface are subject to change in future releases. In particular,
b45619c0 2889a command-line option may be required in the future to decode a name
c1c0eb9e 2890passed as an argument on the command line; in other words,
252b5132
RH
2891
2892@example
2893c++filt @var{symbol}
2894@end example
2895
2896@noindent
2897may in a future release become
2898
2899@example
2900c++filt @var{option} @var{symbol}
2901@end example
2902@end quotation
2903
2904@node addr2line
2905@chapter addr2line
2906
2907@kindex addr2line
2908@cindex address to file name and line number
2909
0285c67d
NC
2910@c man title addr2line convert addresses into file names and line numbers.
2911
252b5132 2912@smallexample
0285c67d 2913@c man begin SYNOPSIS addr2line
be6f6493
TG
2914addr2line [@option{-a}|@option{--addresses}]
2915 [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}]
bf44dd74 2916 [@option{-C}|@option{--demangle}[=@var{style}]]
c7c55b78
NC
2917 [@option{-e} @var{filename}|@option{--exe=}@var{filename}]
2918 [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
0c552dc1 2919 [@option{-i}|@option{--inlines}]
68cdf72f 2920 [@option{-p}|@option{--pretty-print}]
c5f8c388 2921 [@option{-j}|@option{--section=}@var{name}]
c7c55b78
NC
2922 [@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
2923 [addr addr @dots{}]
0285c67d 2924@c man end
252b5132
RH
2925@end smallexample
2926
0285c67d
NC
2927@c man begin DESCRIPTION addr2line
2928
c5f8c388
EB
2929@command{addr2line} translates addresses into file names and line numbers.
2930Given an address in an executable or an offset in a section of a relocatable
2931object, it uses the debugging information to figure out which file name and
2932line number are associated with it.
252b5132 2933
c5f8c388
EB
2934The executable or relocatable object to use is specified with the @option{-e}
2935option. The default is the file @file{a.out}. The section in the relocatable
2936object to use is specified with the @option{-j} option.
252b5132 2937
c7c55b78 2938@command{addr2line} has two modes of operation.
252b5132
RH
2939
2940In the first, hexadecimal addresses are specified on the command line,
c7c55b78 2941and @command{addr2line} displays the file name and line number for each
252b5132
RH
2942address.
2943
c7c55b78 2944In the second, @command{addr2line} reads hexadecimal addresses from
252b5132 2945standard input, and prints the file name and line number for each
c7c55b78 2946address on standard output. In this mode, @command{addr2line} may be used
252b5132
RH
2947in a pipe to convert dynamically chosen addresses.
2948
2949The format of the output is @samp{FILENAME:LINENO}. The file name and
2950line number for each address is printed on a separate line. If the
c7c55b78 2951@command{-f} option is used, then each @samp{FILENAME:LINENO} line is
252b5132 2952preceded by a @samp{FUNCTIONNAME} line which is the name of the function
be6f6493
TG
2953containing the address. If the @command{-a} option is used, then the
2954address read is first printed.
252b5132
RH
2955
2956If the file name or function name can not be determined,
c7c55b78
NC
2957@command{addr2line} will print two question marks in their place. If the
2958line number can not be determined, @command{addr2line} will print 0.
252b5132 2959
0285c67d
NC
2960@c man end
2961
2962@c man begin OPTIONS addr2line
2963
252b5132
RH
2964The long and short forms of options, shown here as alternatives, are
2965equivalent.
2966
c7c55b78 2967@table @env
be6f6493
TG
2968@item -a
2969@itemx --addresses
2970Display address before function names or file and line number
2971information. The address is printed with a @samp{0x} prefix to easily
2972identify it.
2973
252b5132
RH
2974@item -b @var{bfdname}
2975@itemx --target=@var{bfdname}
2976@cindex object code format
2977Specify that the object-code format for the object files is
2978@var{bfdname}.
2979
2980@item -C
28c309a2 2981@itemx --demangle[=@var{style}]
252b5132
RH
2982@cindex demangling in objdump
2983Decode (@dfn{demangle}) low-level symbol names into user-level names.
2984Besides removing any initial underscore prepended by the system, this
28c309a2 2985makes C++ function names readable. Different compilers have different
c1c0eb9e
RM
2986mangling styles. The optional demangling style argument can be used to
2987choose an appropriate demangling style for your compiler. @xref{c++filt},
28c309a2 2988for more information on demangling.
252b5132
RH
2989
2990@item -e @var{filename}
2991@itemx --exe=@var{filename}
2992Specify the name of the executable for which addresses should be
2993translated. The default file is @file{a.out}.
2994
2995@item -f
2996@itemx --functions
2997Display function names as well as file and line number information.
2998
2999@item -s
3000@itemx --basenames
3001Display only the base of each file name.
0c552dc1
FF
3002
3003@item -i
3004@itemx --inlines
3005If the address belongs to a function that was inlined, the source
3006information for all enclosing scopes back to the first non-inlined
3007function will also be printed. For example, if @code{main} inlines
3008@code{callee1} which inlines @code{callee2}, and address is from
3009@code{callee2}, the source information for @code{callee1} and @code{main}
3010will also be printed.
c5f8c388
EB
3011
3012@item -j
3013@itemx --section
3014Read offsets relative to the specified section instead of absolute addresses.
68cdf72f
TG
3015
3016@item -p
3017@itemx --pretty-print
3018Make the output more human friendly: each location are printed on one line.
3019If option @option{-i} is specified, lines for all enclosing scopes are
3020prefixed with @samp{(inlined by)}.
e107c42f 3021@end table
252b5132 3022
0285c67d
NC
3023@c man end
3024
3025@ignore
3026@c man begin SEEALSO addr2line
3027Info entries for @file{binutils}.
3028@c man end
3029@end ignore
3030
252b5132
RH
3031@node nlmconv
3032@chapter nlmconv
3033
c7c55b78 3034@command{nlmconv} converts a relocatable object file into a NetWare
252b5132
RH
3035Loadable Module.
3036
3037@ignore
c7c55b78 3038@command{nlmconv} currently works with @samp{i386} object
252b5132
RH
3039files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC}
3040object files in @sc{elf}, or @code{a.out} format@footnote{
c7c55b78 3041@command{nlmconv} should work with any @samp{i386} or @sc{sparc} object
252b5132
RH
3042format in the Binary File Descriptor library. It has only been tested
3043with the above formats.}.
3044@end ignore
3045
3046@quotation
c7c55b78 3047@emph{Warning:} @command{nlmconv} is not always built as part of the binary
252b5132
RH
3048utilities, since it is only useful for NLM targets.
3049@end quotation
3050
0285c67d
NC
3051@c man title nlmconv converts object code into an NLM.
3052
252b5132 3053@smallexample
0285c67d 3054@c man begin SYNOPSIS nlmconv
c7c55b78
NC
3055nlmconv [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}]
3056 [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}]
3057 [@option{-T} @var{headerfile}|@option{--header-file=}@var{headerfile}]
3058 [@option{-d}|@option{--debug}] [@option{-l} @var{linker}|@option{--linker=}@var{linker}]
3059 [@option{-h}|@option{--help}] [@option{-V}|@option{--version}]
252b5132 3060 @var{infile} @var{outfile}
0285c67d 3061@c man end
252b5132
RH
3062@end smallexample
3063
0285c67d
NC
3064@c man begin DESCRIPTION nlmconv
3065
c7c55b78 3066@command{nlmconv} converts the relocatable @samp{i386} object file
252b5132
RH
3067@var{infile} into the NetWare Loadable Module @var{outfile}, optionally
3068reading @var{headerfile} for NLM header information. For instructions
3069on writing the NLM command file language used in header files, see the
3070@samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM
3071Development and Tools Overview}, which is part of the NLM Software
3072Developer's Kit (``NLM SDK''), available from Novell, Inc.
c7c55b78 3073@command{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read
0285c67d
NC
3074@var{infile};
3075@ifclear man
3076see @ref{BFD,,BFD,ld.info,Using LD}, for more information.
3077@end ifclear
252b5132 3078
c7c55b78 3079@command{nlmconv} can perform a link step. In other words, you can list
252b5132
RH
3080more than one object file for input if you list them in the definitions
3081file (rather than simply specifying one input file on the command line).
c7c55b78 3082In this case, @command{nlmconv} calls the linker for you.
252b5132 3083
0285c67d
NC
3084@c man end
3085
3086@c man begin OPTIONS nlmconv
3087
c7c55b78 3088@table @env
252b5132
RH
3089@item -I @var{bfdname}
3090@itemx --input-target=@var{bfdname}
c7c55b78 3091Object format of the input file. @command{nlmconv} can usually determine
252b5132
RH
3092the format of a given file (so no default is necessary).
3093@xref{Target Selection}, for more information.
3094
3095@item -O @var{bfdname}
3096@itemx --output-target=@var{bfdname}
c7c55b78 3097Object format of the output file. @command{nlmconv} infers the output
252b5132
RH
3098format based on the input format, e.g. for a @samp{i386} input file the
3099output format is @samp{nlm32-i386}.
3100@xref{Target Selection}, for more information.
3101
3102@item -T @var{headerfile}
3103@itemx --header-file=@var{headerfile}
3104Reads @var{headerfile} for NLM header information. For instructions on
3105writing the NLM command file language used in header files, see@ see the
3106@samp{linkers} section, of the @cite{NLM Development and Tools
3107Overview}, which is part of the NLM Software Developer's Kit, available
3108from Novell, Inc.
3109
3110@item -d
3111@itemx --debug
c7c55b78 3112Displays (on standard error) the linker command line used by @command{nlmconv}.
252b5132
RH
3113
3114@item -l @var{linker}
3115@itemx --linker=@var{linker}
3116Use @var{linker} for any linking. @var{linker} can be an absolute or a
3117relative pathname.
3118
3119@item -h
3120@itemx --help
3121Prints a usage summary.
3122
3123@item -V
3124@itemx --version
c7c55b78 3125Prints the version number for @command{nlmconv}.
252b5132
RH
3126@end table
3127
0285c67d
NC
3128@c man end
3129
3130@ignore
3131@c man begin SEEALSO nlmconv
3132the Info entries for @file{binutils}.
692ed3e7
NC
3133@c man end
3134@end ignore
3135
3136@node windmc
3137@chapter windmc
3138
3139@command{windmc} may be used to generator Windows message resources.
3140
3141@quotation
3142@emph{Warning:} @command{windmc} is not always built as part of the binary
3143utilities, since it is only useful for Windows targets.
3144@end quotation
3145
3146@c man title windmc generates Windows message resources.
3147
3148@smallexample
3149@c man begin SYNOPSIS windres
3150windmc [options] input-file
3151@c man end
3152@end smallexample
3153
3154@c man begin DESCRIPTION windmc
3155
3156@command{windmc} reads message definitions from an input file (.mc) and
3157translate them into a set of output files. The output files may be of
3158four kinds:
3159
3160@table @code
3161@item h
3162A C header file containing the message definitions.
3163
3164@item rc
3165A resource file compilable by the @command{windres} tool.
3166
3167@item bin
3168One or more binary files containing the resource data for a specific
3169message language.
3170
3171@item dbg
3172A C include file that maps message id's to their symbolic name.
3173@end table
3174
3175The exact description of these different formats is available in
3176documentation from Microsoft.
3177
3178When @command{windmc} converts from the @code{mc} format to the @code{bin}
3179format, @code{rc}, @code{h}, and optional @code{dbg} it is acting like the
3180Windows Message Compiler.
3181
3182@c man end
3183
3184@c man begin OPTIONS windmc
3185
3186@table @env
3187@item -a
3188@itemx --ascii_in
3189Specifies that the input file specified is ANSI. This is the default
3190behaviour.
3191
3192@item -A
3193@itemx --ascii_out
3194Specifies that messages in the output @code{bin} files should be in ANSI
3195format.
3196
3197@item -b
3198@itemx --binprefix
3199Specifies that @code{bin} filenames should have to be prefixed by the
3200basename of the source file.
3201
3202@item -c
3203@itemx --customflag
3204Sets the customer bit in all message id's.
3205
3206@item -C @var{codepage}
3207@itemx --codepage_in @var{codepage}
3208Sets the default codepage to be used to convert input file to UTF16. The
3209default is ocdepage 1252.
3210
3211@item -d
3212@itemx --decimal_values
3213Outputs the constants in the header file in decimal. Default is using
3214hexadecimal output.
3215
3216@item -e @var{ext}
3217@itemx --extension @var{ext}
3218The extension for the header file. The default is .h extension.
3219
3220@item -F @var{target}
3221@itemx --target @var{target}
3222Specify the BFD format to use for a bin file as output. This
3223is a BFD target name; you can use the @option{--help} option to see a list
3224of supported targets. Normally @command{windmc} will use the default
3225format, which is the first one listed by the @option{--help} option.
3226@ifclear man
3227@ref{Target Selection}.
3228@end ifclear
3229
3230@item -h @var{path}
3231@itemx --headerdir @var{path}
3232The target directory of the generated header file. The default is the
3233current directory.
3234
3235@item -H
3236@itemx --help
3237Displays a list of command line options and then exits.
3238
3239@item -m @var{characters}
3240@itemx --maxlength @var{characters}
3241Instructs @command{windmc} to generate a warning if the length
3242of any message exceeds the number specified.
3243
3244@item -n
3245@itemx --nullterminate
3246Terminate message text in @code{bin} files by zero. By default they are
3247terminated by CR/LF.
3248
3249@item -o
3250@itemx --hresult_use
3251Not yet implemented. Instructs @code{windmc} to generate an OLE2 header
3252file, using HRESULT definitions. Status codes are used if the flag is not
3253specified.
3254
3255@item -O @var{codepage}
3256@itemx --codepage_out @var{codepage}
3257Sets the default codepage to be used to output text files. The default
3258is ocdepage 1252.
3259
3260@item -r @var{path}
3261@itemx --rcdir @var{path}
3262The target directory for the generated @code{rc} script and the generated
3263@code{bin} files that the resource compiler script includes. The default
3264is the current directory.
3265
3266@item -u
3267@itemx --unicode_in
3268Specifies that the input file is UTF16.
3269
3270@item -U
3271@itemx --unicode_out
3272Specifies that messages in the output @code{bin} file should be in UTF16
3273format. This is the default behaviour.
3274
3275@item -v
3276@item --verbose
bd37ed49 3277Enable verbose mode.
692ed3e7
NC
3278
3279@item -V
3280@item --version
bd37ed49 3281Prints the version number for @command{windmc}.
692ed3e7
NC
3282
3283@item -x @var{path}
3284@itemx --xdgb @var{path}
3285The path of the @code{dbg} C include file that maps message id's to the
3286symbolic name. No such file is generated without specifying the switch.
3287@end table
3288
3289@c man end
3290
3291@ignore
3292@c man begin SEEALSO windmc
3293the Info entries for @file{binutils}.
0285c67d
NC
3294@c man end
3295@end ignore
3296
252b5132
RH
3297@node windres
3298@chapter windres
3299
c7c55b78 3300@command{windres} may be used to manipulate Windows resources.
252b5132
RH
3301
3302@quotation
c7c55b78 3303@emph{Warning:} @command{windres} is not always built as part of the binary
252b5132
RH
3304utilities, since it is only useful for Windows targets.
3305@end quotation
3306
0285c67d
NC
3307@c man title windres manipulate Windows resources.
3308
252b5132 3309@smallexample
0285c67d 3310@c man begin SYNOPSIS windres
252b5132 3311windres [options] [input-file] [output-file]
0285c67d 3312@c man end
252b5132
RH
3313@end smallexample
3314
0285c67d
NC
3315@c man begin DESCRIPTION windres
3316
c7c55b78 3317@command{windres} reads resources from an input file and copies them into
252b5132
RH
3318an output file. Either file may be in one of three formats:
3319
3320@table @code
3321@item rc
3322A text format read by the Resource Compiler.
3323
3324@item res
3325A binary format generated by the Resource Compiler.
3326
3327@item coff
3328A COFF object or executable.
3329@end table
3330
3331The exact description of these different formats is available in
3332documentation from Microsoft.
3333
c7c55b78 3334When @command{windres} converts from the @code{rc} format to the @code{res}
252b5132 3335format, it is acting like the Windows Resource Compiler. When
c7c55b78 3336@command{windres} converts from the @code{res} format to the @code{coff}
252b5132
RH
3337format, it is acting like the Windows @code{CVTRES} program.
3338
c7c55b78 3339When @command{windres} generates an @code{rc} file, the output is similar
252b5132
RH
3340but not identical to the format expected for the input. When an input
3341@code{rc} file refers to an external filename, an output @code{rc} file
3342will instead include the file contents.
3343
c7c55b78 3344If the input or output format is not specified, @command{windres} will
252b5132
RH
3345guess based on the file name, or, for the input file, the file contents.
3346A file with an extension of @file{.rc} will be treated as an @code{rc}
3347file, a file with an extension of @file{.res} will be treated as a
3348@code{res} file, and a file with an extension of @file{.o} or
3349@file{.exe} will be treated as a @code{coff} file.
3350
c7c55b78 3351If no output file is specified, @command{windres} will print the resources
252b5132
RH
3352in @code{rc} format to standard output.
3353
c7c55b78 3354The normal use is for you to write an @code{rc} file, use @command{windres}
252b5132
RH
3355to convert it to a COFF object file, and then link the COFF file into
3356your application. This will make the resources described in the
3357@code{rc} file available to Windows.
3358
0285c67d
NC
3359@c man end
3360
3361@c man begin OPTIONS windres
3362
c7c55b78 3363@table @env
252b5132
RH
3364@item -i @var{filename}
3365@itemx --input @var{filename}
3366The name of the input file. If this option is not used, then
c7c55b78
NC
3367@command{windres} will use the first non-option argument as the input file
3368name. If there are no non-option arguments, then @command{windres} will
3369read from standard input. @command{windres} can not read a COFF file from
edbedb71 3370standard input.
252b5132
RH
3371
3372@item -o @var{filename}
3373@itemx --output @var{filename}
3374The name of the output file. If this option is not used, then
c7c55b78 3375@command{windres} will use the first non-option argument, after any used
252b5132 3376for the input file name, as the output file name. If there is no
c7c55b78 3377non-option argument, then @command{windres} will write to standard output.
edbedb71 3378@command{windres} can not write a COFF file to standard output. Note,
b45619c0 3379for compatibility with @command{rc} the option @option{-fo} is also
edbedb71 3380accepted, but its use is not recommended.
252b5132 3381
85eb5110 3382@item -J @var{format}
252b5132
RH
3383@itemx --input-format @var{format}
3384The input format to read. @var{format} may be @samp{res}, @samp{rc}, or
c7c55b78 3385@samp{coff}. If no input format is specified, @command{windres} will
252b5132
RH
3386guess, as described above.
3387
3388@item -O @var{format}
3389@itemx --output-format @var{format}
3390The output format to generate. @var{format} may be @samp{res},
3391@samp{rc}, or @samp{coff}. If no output format is specified,
c7c55b78 3392@command{windres} will guess, as described above.
252b5132
RH
3393
3394@item -F @var{target}
3395@itemx --target @var{target}
3396Specify the BFD format to use for a COFF file as input or output. This
c7c55b78
NC
3397is a BFD target name; you can use the @option{--help} option to see a list
3398of supported targets. Normally @command{windres} will use the default
3399format, which is the first one listed by the @option{--help} option.
3400@ifclear man
252b5132 3401@ref{Target Selection}.
c7c55b78 3402@end ifclear
252b5132
RH
3403
3404@item --preprocessor @var{program}
c7c55b78 3405When @command{windres} reads an @code{rc} file, it runs it through the C
252b5132
RH
3406preprocessor first. This option may be used to specify the preprocessor
3407to use, including any leading arguments. The default preprocessor
3408argument is @code{gcc -E -xc-header -DRC_INVOKED}.
3409
85eb5110
NC
3410@item -I @var{directory}
3411@itemx --include-dir @var{directory}
252b5132 3412Specify an include directory to use when reading an @code{rc} file.
c7c55b78
NC
3413@command{windres} will pass this to the preprocessor as an @option{-I}
3414option. @command{windres} will also search this directory when looking for
85eb5110 3415files named in the @code{rc} file. If the argument passed to this command
c1c0eb9e 3416matches any of the supported @var{formats} (as described in the @option{-J}
85eb5110
NC
3417option), it will issue a deprecation warning, and behave just like the
3418@option{-J} option. New programs should not use this behaviour. If a
3419directory happens to match a @var{format}, simple prefix it with @samp{./}
3420to disable the backward compatibility.
252b5132 3421
751d21b5 3422@item -D @var{target}
ad0481cd 3423@itemx --define @var{sym}[=@var{val}]
c7c55b78 3424Specify a @option{-D} option to pass to the preprocessor when reading an
252b5132
RH
3425@code{rc} file.
3426
29b058f1
NC
3427@item -U @var{target}
3428@itemx --undefine @var{sym}
3429Specify a @option{-U} option to pass to the preprocessor when reading an
3430@code{rc} file.
3431
3126d709
CF
3432@item -r
3433Ignored for compatibility with rc.
3434
751d21b5
DD
3435@item -v
3436Enable verbose mode. This tells you what the preprocessor is if you
3437didn't specify one.
3438
30ff741f
NC
3439@item -c @var{val}
3440@item --codepage @var{val}
3441Specify the default codepage to use when reading an @code{rc} file.
3442@var{val} should be a hexadecimal prefixed by @samp{0x} or decimal
3443codepage code. The valid range is from zero up to 0xffff, but the
3444validity of the codepage is host and configuration dependent.
3445
3077f5d8 3446@item -l @var{val}
252b5132
RH
3447@item --language @var{val}
3448Specify the default language to use when reading an @code{rc} file.
3449@var{val} should be a hexadecimal language code. The low eight bits are
3450the language, and the high eight bits are the sublanguage.
3451
5a298d2d
NC
3452@item --use-temp-file
3453Use a temporary file to instead of using popen to read the output of
c1c0eb9e
RM
3454the preprocessor. Use this option if the popen implementation is buggy
3455on the host (eg., certain non-English language versions of Windows 95 and
5a298d2d
NC
3456Windows 98 are known to have buggy popen where the output will instead
3457go the console).
3458
3459@item --no-use-temp-file
3460Use popen, not a temporary file, to read the output of the preprocessor.
3461This is the default behaviour.
3462
3077f5d8 3463@item -h
252b5132
RH
3464@item --help
3465Prints a usage summary.
3466
3077f5d8 3467@item -V
252b5132 3468@item --version
c7c55b78 3469Prints the version number for @command{windres}.
252b5132
RH
3470
3471@item --yydebug
c7c55b78 3472If @command{windres} is compiled with @code{YYDEBUG} defined as @code{1},
252b5132
RH
3473this will turn on parser debugging.
3474@end table
3475
0285c67d
NC
3476@c man end
3477
3478@ignore
3479@c man begin SEEALSO windres
3480the Info entries for @file{binutils}.
3481@c man end
3482@end ignore
252b5132
RH
3483
3484@node dlltool
2aa9814e 3485@chapter dlltool
252b5132
RH
3486@cindex DLL
3487@kindex dlltool
3488
2aa9814e
BE
3489@command{dlltool} is used to create the files needed to create dynamic
3490link libraries (DLLs) on systems which understand PE format image
3491files such as Windows. A DLL contains an export table which contains
3492information that the runtime loader needs to resolve references from a
3493referencing program.
3494
3495The export table is generated by this program by reading in a
3496@file{.def} file or scanning the @file{.a} and @file{.o} files which
3497will be in the DLL. A @file{.o} file can contain information in
3498special @samp{.drectve} sections with export information.
252b5132
RH
3499
3500@quotation
2aa9814e
BE
3501@emph{Note:} @command{dlltool} is not always built as part of the
3502binary utilities, since it is only useful for those targets which
3503support DLLs.
252b5132
RH
3504@end quotation
3505
0285c67d
NC
3506@c man title dlltool Create files needed to build and use DLLs.
3507
252b5132 3508@smallexample
0285c67d 3509@c man begin SYNOPSIS dlltool
c7c55b78
NC
3510dlltool [@option{-d}|@option{--input-def} @var{def-file-name}]
3511 [@option{-b}|@option{--base-file} @var{base-file-name}]
3512 [@option{-e}|@option{--output-exp} @var{exports-file-name}]
3513 [@option{-z}|@option{--output-def} @var{def-file-name}]
c1c0eb9e 3514 [@option{-l}|@option{--output-lib} @var{library-file-name}]
10e636d2 3515 [@option{-y}|@option{--output-delaylib} @var{library-file-name}]
c7c55b78
NC
3516 [@option{--export-all-symbols}] [@option{--no-export-all-symbols}]
3517 [@option{--exclude-symbols} @var{list}]
3518 [@option{--no-default-excludes}]
3519 [@option{-S}|@option{--as} @var{path-to-assembler}] [@option{-f}|@option{--as-flags} @var{options}]
3520 [@option{-D}|@option{--dllname} @var{name}] [@option{-m}|@option{--machine} @var{machine}]
14288fdc
DS
3521 [@option{-a}|@option{--add-indirect}]
3522 [@option{-U}|@option{--add-underscore}] [@option{--add-stdcall-underscore}]
3523 [@option{-k}|@option{--kill-at}] [@option{-A}|@option{--add-stdcall-alias}]
607dea97 3524 [@option{-p}|@option{--ext-prefix-alias} @var{prefix}]
d4732f7c 3525 [@option{-x}|@option{--no-idata4}] [@option{-c}|@option{--no-idata5}]
e77b97d4 3526 [@option{--use-nul-prefixed-import-tables}]
71c57c16
NC
3527 [@option{-I}|@option{--identify} @var{library-file-name}] [@option{--identify-strict}]
3528 [@option{-i}|@option{--interwork}]
f9346411 3529 [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}]
c1c0eb9e 3530 [@option{-v}|@option{--verbose}]
c7c55b78 3531 [@option{-h}|@option{--help}] [@option{-V}|@option{--version}]
36d21de5 3532 [@option{--no-leading-underscore}] [@option{--leading-underscore}]
252b5132 3533 [object-file @dots{}]
0285c67d 3534@c man end
252b5132
RH
3535@end smallexample
3536
0285c67d
NC
3537@c man begin DESCRIPTION dlltool
3538
c7c55b78
NC
3539@command{dlltool} reads its inputs, which can come from the @option{-d} and
3540@option{-b} options as well as object files specified on the command
3541line. It then processes these inputs and if the @option{-e} option has
3542been specified it creates a exports file. If the @option{-l} option
3543has been specified it creates a library file and if the @option{-z} option
c1c0eb9e
RM
3544has been specified it creates a def file. Any or all of the @option{-e},
3545@option{-l} and @option{-z} options can be present in one invocation of
c7c55b78 3546dlltool.
252b5132
RH
3547
3548When creating a DLL, along with the source for the DLL, it is necessary
c7c55b78 3549to have three other files. @command{dlltool} can help with the creation of
252b5132
RH
3550these files.
3551
2aa9814e 3552The first file is a @file{.def} file which specifies which functions are
252b5132 3553exported from the DLL, which functions the DLL imports, and so on. This
c7c55b78
NC
3554is a text file and can be created by hand, or @command{dlltool} can be used
3555to create it using the @option{-z} option. In this case @command{dlltool}
252b5132
RH
3556will scan the object files specified on its command line looking for
3557those functions which have been specially marked as being exported and
2aa9814e 3558put entries for them in the @file{.def} file it creates.
252b5132
RH
3559
3560In order to mark a function as being exported from a DLL, it needs to
c7c55b78 3561have an @option{-export:<name_of_function>} entry in the @samp{.drectve}
252b5132
RH
3562section of the object file. This can be done in C by using the
3563asm() operator:
3564
3565@smallexample
c1c0eb9e 3566 asm (".section .drectve");
252b5132
RH
3567 asm (".ascii \"-export:my_func\"");
3568
3569 int my_func (void) @{ @dots{} @}
3570@end smallexample
3571
3572The second file needed for DLL creation is an exports file. This file
3573is linked with the object files that make up the body of the DLL and it
3574handles the interface between the DLL and the outside world. This is a
c7c55b78 3575binary file and it can be created by giving the @option{-e} option to
c1c0eb9e 3576@command{dlltool} when it is creating or reading in a @file{.def} file.
252b5132
RH
3577
3578The third file needed for DLL creation is the library file that programs
d4732f7c
CW
3579will link with in order to access the functions in the DLL (an `import
3580library'). This file can be created by giving the @option{-l} option to
3581dlltool when it is creating or reading in a @file{.def} file.
252b5132 3582
10e636d2
DK
3583If the @option{-y} option is specified, dlltool generates a delay-import
3584library that can be used instead of the normal import library to allow
3585a program to link to the dll only as soon as an imported function is
3586called for the first time. The resulting executable will need to be
3587linked to the static delayimp library containing __delayLoadHelper2(),
3588which in turn will import LoadLibraryA and GetProcAddress from kernel32.
3589
c7c55b78 3590@command{dlltool} builds the library file by hand, but it builds the
252b5132 3591exports file by creating temporary files containing assembler statements
c7c55b78 3592and then assembling these. The @option{-S} command line option can be
252b5132 3593used to specify the path to the assembler that dlltool will use,
c7c55b78
NC
3594and the @option{-f} option can be used to pass specific flags to that
3595assembler. The @option{-n} can be used to prevent dlltool from deleting
3596these temporary assembler files when it is done, and if @option{-n} is
252b5132
RH
3597specified twice then this will prevent dlltool from deleting the
3598temporary object files it used to build the library.
3599
3600Here is an example of creating a DLL from a source file @samp{dll.c} and
3601also creating a program (from an object file called @samp{program.o})
3602that uses that DLL:
3603
3604@smallexample
3605 gcc -c dll.c
3606 dlltool -e exports.o -l dll.lib dll.o
3607 gcc dll.o exports.o -o dll.dll
3608 gcc program.o dll.lib -o program
3609@end smallexample
3610
d4732f7c
CW
3611
3612@command{dlltool} may also be used to query an existing import library
3613to determine the name of the DLL to which it is associated. See the
3614description of the @option{-I} or @option{--identify} option.
3615
0285c67d
NC
3616@c man end
3617
3618@c man begin OPTIONS dlltool
3619
252b5132
RH
3620The command line options have the following meanings:
3621
c7c55b78 3622@table @env
252b5132
RH
3623
3624@item -d @var{filename}
3625@itemx --input-def @var{filename}
3626@cindex input .def file
2aa9814e 3627Specifies the name of a @file{.def} file to be read in and processed.
252b5132
RH
3628
3629@item -b @var{filename}
3630@itemx --base-file @var{filename}
3631@cindex base files
3632Specifies the name of a base file to be read in and processed. The
3633contents of this file will be added to the relocation section in the
3634exports file generated by dlltool.
3635
3636@item -e @var{filename}
3637@itemx --output-exp @var{filename}
3638Specifies the name of the export file to be created by dlltool.
3639
3640@item -z @var{filename}
3641@itemx --output-def @var{filename}
2aa9814e 3642Specifies the name of the @file{.def} file to be created by dlltool.
252b5132
RH
3643
3644@item -l @var{filename}
3645@itemx --output-lib @var{filename}
3646Specifies the name of the library file to be created by dlltool.
3647
10e636d2
DK
3648@item -y @var{filename}
3649@itemx --output-delaylib @var{filename}
3650Specifies the name of the delay-import library file to be created by dlltool.
3651
252b5132
RH
3652@item --export-all-symbols
3653Treat all global and weak defined symbols found in the input object
3654files as symbols to be exported. There is a small list of symbols which
c7c55b78 3655are not exported by default; see the @option{--no-default-excludes}
252b5132 3656option. You may add to the list of symbols to not export by using the
c7c55b78 3657@option{--exclude-symbols} option.
252b5132
RH
3658
3659@item --no-export-all-symbols
2aa9814e 3660Only export symbols explicitly listed in an input @file{.def} file or in
252b5132
RH
3661@samp{.drectve} sections in the input object files. This is the default
3662behaviour. The @samp{.drectve} sections are created by @samp{dllexport}
3663attributes in the source code.
3664
3665@item --exclude-symbols @var{list}
3666Do not export the symbols in @var{list}. This is a list of symbol names
3667separated by comma or colon characters. The symbol names should not
3668contain a leading underscore. This is only meaningful when
c7c55b78 3669@option{--export-all-symbols} is used.
252b5132
RH
3670
3671@item --no-default-excludes
c7c55b78 3672When @option{--export-all-symbols} is used, it will by default avoid
252b5132
RH
3673exporting certain special symbols. The current list of symbols to avoid
3674exporting is @samp{DllMain@@12}, @samp{DllEntryPoint@@0},
c7c55b78 3675@samp{impure_ptr}. You may use the @option{--no-default-excludes} option
252b5132 3676to go ahead and export these special symbols. This is only meaningful
c7c55b78 3677when @option{--export-all-symbols} is used.
252b5132
RH
3678
3679@item -S @var{path}
3680@itemx --as @var{path}
3681Specifies the path, including the filename, of the assembler to be used
3682to create the exports file.
3683
6364e0b4
NC
3684@item -f @var{options}
3685@itemx --as-flags @var{options}
3686Specifies any specific command line options to be passed to the
252b5132 3687assembler when building the exports file. This option will work even if
c7c55b78 3688the @option{-S} option is not used. This option only takes one argument,
252b5132
RH
3689and if it occurs more than once on the command line, then later
3690occurrences will override earlier occurrences. So if it is necessary to
6364e0b4 3691pass multiple options to the assembler they should be enclosed in
252b5132
RH
3692double quotes.
3693
3694@item -D @var{name}
3695@itemx --dll-name @var{name}
2aa9814e
BE
3696Specifies the name to be stored in the @file{.def} file as the name of
3697the DLL when the @option{-e} option is used. If this option is not
3698present, then the filename given to the @option{-e} option will be
3699used as the name of the DLL.
252b5132
RH
3700
3701@item -m @var{machine}
3702@itemx -machine @var{machine}
3703Specifies the type of machine for which the library file should be
c7c55b78 3704built. @command{dlltool} has a built in default type, depending upon how
252b5132
RH
3705it was created, but this option can be used to override that. This is
3706normally only useful when creating DLLs for an ARM processor, when the
c36774d6 3707contents of the DLL are actually encode using Thumb instructions.
252b5132
RH
3708
3709@item -a
3710@itemx --add-indirect
c7c55b78 3711Specifies that when @command{dlltool} is creating the exports file it
252b5132
RH
3712should add a section which allows the exported functions to be
3713referenced without using the import library. Whatever the hell that
c1c0eb9e 3714means!
252b5132
RH
3715
3716@item -U
3717@itemx --add-underscore
c7c55b78 3718Specifies that when @command{dlltool} is creating the exports file it
c1c0eb9e 3719should prepend an underscore to the names of @emph{all} exported symbols.
14288fdc 3720
36d21de5
KT
3721@item --no-leading-underscore
3722@item --leading-underscore
3723Specifies whether standard symbol should be forced to be prefixed, or
3724not.
3725
14288fdc
DS
3726@item --add-stdcall-underscore
3727Specifies that when @command{dlltool} is creating the exports file it
3728should prepend an underscore to the names of exported @emph{stdcall}
3729functions. Variable names and non-stdcall function names are not modified.
3730This option is useful when creating GNU-compatible import libs for third
3731party DLLs that were built with MS-Windows tools.
252b5132
RH
3732
3733@item -k
3734@itemx --kill-at
c7c55b78 3735Specifies that when @command{dlltool} is creating the exports file it
d67a454c
NC
3736should not append the string @samp{@@ <number>}. These numbers are
3737called ordinal numbers and they represent another way of accessing the
3738function in a DLL, other than by name.
252b5132
RH
3739
3740@item -A
3741@itemx --add-stdcall-alias
c7c55b78 3742Specifies that when @command{dlltool} is creating the exports file it
252b5132
RH
3743should add aliases for stdcall symbols without @samp{@@ <number>}
3744in addition to the symbols with @samp{@@ <number>}.
3745
607dea97
NC
3746@item -p
3747@itemx --ext-prefix-alias @var{prefix}
3748Causes @command{dlltool} to create external aliases for all DLL
3749imports with the specified prefix. The aliases are created for both
3750external and import symbols with no leading underscore.
3751
252b5132
RH
3752@item -x
3753@itemx --no-idata4
c7c55b78
NC
3754Specifies that when @command{dlltool} is creating the exports and library
3755files it should omit the @code{.idata4} section. This is for compatibility
252b5132
RH
3756with certain operating systems.
3757
e77b97d4
KT
3758@item --use-nul-prefixed-import-tables
3759Specifies that when @command{dlltool} is creating the exports and library
3760files it should prefix the @code{.idata4} and @code{.idata5} by zero an
3761element. This emulates old gnu import library generation of
3762@code{dlltool}. By default this option is turned off.
3763
252b5132
RH
3764@item -c
3765@itemx --no-idata5
c7c55b78
NC
3766Specifies that when @command{dlltool} is creating the exports and library
3767files it should omit the @code{.idata5} section. This is for compatibility
252b5132
RH
3768with certain operating systems.
3769
d4732f7c
CW
3770@item -I @var{filename}
3771@itemx --identify @var{filename}
3772Specifies that @command{dlltool} should inspect the import library
71c57c16
NC
3773indicated by @var{filename} and report, on @code{stdout}, the name(s)
3774of the associated DLL(s). This can be performed in addition to any
3775other operations indicated by the other options and arguments.
3776@command{dlltool} fails if the import library does not exist or is not
3777actually an import library. See also @option{--identify-strict}.
3778
3779@item --identify-strict
3780Modifies the behavior of the @option{--identify} option, such
3781that an error is reported if @var{filename} is associated with
3782more than one DLL.
d4732f7c 3783
252b5132
RH
3784@item -i
3785@itemx --interwork
c7c55b78 3786Specifies that @command{dlltool} should mark the objects in the library
252b5132 3787file and exports file that it produces as supporting interworking
c36774d6 3788between ARM and Thumb code.
252b5132
RH
3789
3790@item -n
3791@itemx --nodelete
c7c55b78 3792Makes @command{dlltool} preserve the temporary assembler files it used to
252b5132
RH
3793create the exports file. If this option is repeated then dlltool will
3794also preserve the temporary object files it uses to create the library
f9346411
DS
3795file.
3796
3797@item -t @var{prefix}
3798@itemx --temp-prefix @var{prefix}
3799Makes @command{dlltool} use @var{prefix} when constructing the names of
3800temporary assembler and object files. By default, the temp file prefix
c1c0eb9e 3801is generated from the pid.
252b5132
RH
3802
3803@item -v
3804@itemx --verbose
3805Make dlltool describe what it is doing.
3806
3807@item -h
3808@itemx --help
3809Displays a list of command line options and then exits.
3810
3811@item -V
3812@itemx --version
3813Displays dlltool's version number and then exits.
3814
3815@end table
3816
0285c67d
NC
3817@c man end
3818
2aa9814e
BE
3819@menu
3820* def file format:: The format of the dlltool @file{.def} file
3821@end menu
3822
3823@node def file format
3824@section The format of the @command{dlltool} @file{.def} file
3825
3826A @file{.def} file contains any number of the following commands:
3827
3828@table @asis
3829
3830@item @code{NAME} @var{name} @code{[ ,} @var{base} @code{]}
3831The result is going to be named @var{name}@code{.exe}.
3832
3833@item @code{LIBRARY} @var{name} @code{[ ,} @var{base} @code{]}
3834The result is going to be named @var{name}@code{.dll}.
3835
bf201fdd 3836@item @code{EXPORTS ( ( (} @var{name1} @code{[ = } @var{name2} @code{] ) | ( } @var{name1} @code{=} @var{module-name} @code{.} @var{external-name} @code{) ) [ == } @var{its_name} @code{]}
2aa9814e
BE
3837@item @code{[} @var{integer} @code{] [ NONAME ] [ CONSTANT ] [ DATA ] [ PRIVATE ] ) *}
3838Declares @var{name1} as an exported symbol from the DLL, with optional
3839ordinal number @var{integer}, or declares @var{name1} as an alias
bf201fdd
KT
3840(forward) of the function @var{external-name} in the DLL.
3841If @var{its_name} is specified, this name is used as string in export table.
2aa9814e
BE
3842@var{module-name}.
3843
bf201fdd 3844@item @code{IMPORTS ( (} @var{internal-name} @code{=} @var{module-name} @code{.} @var{integer} @code{) | [} @var{internal-name} @code{= ]} @var{module-name} @code{.} @var{external-name} @code{) [ == ) @var{its_name} @code{]} *}
2aa9814e
BE
3845Declares that @var{external-name} or the exported function whose
3846ordinal number is @var{integer} is to be imported from the file
3847@var{module-name}. If @var{internal-name} is specified then this is
3848the name that the imported function will be referred to in the body of
3849the DLL.
bf201fdd 3850If @var{its_name} is specified, this name is used as string in import table.
2aa9814e
BE
3851
3852@item @code{DESCRIPTION} @var{string}
3853Puts @var{string} into the output @file{.exp} file in the
3854@code{.rdata} section.
3855
3856@item @code{STACKSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]}
3857@item @code{HEAPSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]}
3858Generates @code{--stack} or @code{--heap}
3859@var{number-reserve},@var{number-commit} in the output @code{.drectve}
3860section. The linker will see this and act upon it.
3861
3862@item @code{CODE} @var{attr} @code{+}
3863@item @code{DATA} @var{attr} @code{+}
3864@item @code{SECTIONS (} @var{section-name} @var{attr}@code{ + ) *}
3865Generates @code{--attr} @var{section-name} @var{attr} in the output
3866@code{.drectve} section, where @var{attr} is one of @code{READ},
3867@code{WRITE}, @code{EXECUTE} or @code{SHARED}. The linker will see
3868this and act upon it.
3869
3870@end table
3871
0285c67d
NC
3872@ignore
3873@c man begin SEEALSO dlltool
2aa9814e 3874The Info pages for @file{binutils}.
0285c67d
NC
3875@c man end
3876@end ignore
3877
252b5132
RH
3878@node readelf
3879@chapter readelf
3880
3881@cindex ELF file information
3882@kindex readelf
3883
0285c67d
NC
3884@c man title readelf Displays information about ELF files.
3885
252b5132 3886@smallexample
0285c67d 3887@c man begin SYNOPSIS readelf
c1c0eb9e 3888readelf [@option{-a}|@option{--all}]
c7c55b78
NC
3889 [@option{-h}|@option{--file-header}]
3890 [@option{-l}|@option{--program-headers}|@option{--segments}]
3891 [@option{-S}|@option{--section-headers}|@option{--sections}]
81fc812e 3892 [@option{-g}|@option{--section-groups}]
5477e8a0 3893 [@option{-t}|@option{--section-details}]
c7c55b78
NC
3894 [@option{-e}|@option{--headers}]
3895 [@option{-s}|@option{--syms}|@option{--symbols}]
3896 [@option{-n}|@option{--notes}]
3897 [@option{-r}|@option{--relocs}]
3898 [@option{-u}|@option{--unwind}]
3899 [@option{-d}|@option{--dynamic}]
3900 [@option{-V}|@option{--version-info}]
947ed062 3901 [@option{-A}|@option{--arch-specific}]
c7c55b78 3902 [@option{-D}|@option{--use-dynamic}]
aef1f6d0 3903 [@option{-x} <number or name>|@option{--hex-dump=}<number or name>]
09c11c86 3904 [@option{-p} <number or name>|@option{--string-dump=}<number or name>]
cf13d699 3905 [@option{-R} <number or name>|@option{--relocated-dump=}<number or name>]
4145f1d5 3906 [@option{-c}|@option{--archive-index}]
f9f0e732
NC
3907 [@option{-w[lLiaprmfFsoRt]}|
3908 @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]]
947ed062 3909 [@option{-I}|@option{-histogram}]
c7c55b78 3910 [@option{-v}|@option{--version}]
d974e256 3911 [@option{-W}|@option{--wide}]
c7c55b78 3912 [@option{-H}|@option{--help}]
252b5132 3913 @var{elffile}@dots{}
0285c67d 3914@c man end
252b5132
RH
3915@end smallexample
3916
0285c67d
NC
3917@c man begin DESCRIPTION readelf
3918
c7c55b78 3919@command{readelf} displays information about one or more ELF format object
252b5132
RH
3920files. The options control what particular information to display.
3921
fb52b2f4
NC
3922@var{elffile}@dots{} are the object files to be examined. 32-bit and
392364-bit ELF files are supported, as are archives containing ELF files.
252b5132 3924
9eb20dd8
NC
3925This program performs a similar function to @command{objdump} but it
3926goes into more detail and it exists independently of the @sc{bfd}
3927library, so if there is a bug in @sc{bfd} then readelf will not be
3928affected.
3929
0285c67d
NC
3930@c man end
3931
3932@c man begin OPTIONS readelf
3933
252b5132
RH
3934The long and short forms of options, shown here as alternatives, are
3935equivalent. At least one option besides @samp{-v} or @samp{-H} must be
c1c0eb9e 3936given.
252b5132 3937
c7c55b78 3938@table @env
252b5132
RH
3939@item -a
3940@itemx --all
d95ef3ab 3941Equivalent to specifying @option{--file-header},
c7c55b78
NC
3942@option{--program-headers}, @option{--sections}, @option{--symbols},
3943@option{--relocs}, @option{--dynamic}, @option{--notes} and
c1c0eb9e 3944@option{--version-info}.
252b5132
RH
3945
3946@item -h
3947@itemx --file-header
3948@cindex ELF file header information
3949Displays the information contained in the ELF header at the start of the
3950file.
3951
3952@item -l
3953@itemx --program-headers
3954@itemx --segments
3955@cindex ELF program header information
3956@cindex ELF segment information
3957Displays the information contained in the file's segment headers, if it
3958has any.
3959
3960@item -S
3961@itemx --sections
3962@itemx --section-headers
3963@cindex ELF section information
3964Displays the information contained in the file's section headers, if it
3965has any.
3966
81fc812e
L
3967@item -g
3968@itemx --section-groups
3969@cindex ELF section group information
3970Displays the information contained in the file's section groups, if it
3971has any.
3972
5477e8a0
L
3973@item -t
3974@itemx --section-details
3975@cindex ELF section information
3976Displays the detailed section information. Implies @option{-S}.
81fc812e 3977
252b5132
RH
3978@item -s
3979@itemx --symbols
3980@itemx --syms
3981@cindex ELF symbol table information
3982Displays the entries in symbol table section of the file, if it has one.
3983
3984@item -e
3985@itemx --headers
c7c55b78 3986Display all the headers in the file. Equivalent to @option{-h -l -S}.
252b5132 3987
779fe533
NC
3988@item -n
3989@itemx --notes
1ec5cd37
NC
3990@cindex ELF notes
3991Displays the contents of the NOTE segments and/or sections, if any.
779fe533 3992
252b5132
RH
3993@item -r
3994@itemx --relocs
3995@cindex ELF reloc information
f5e21966
NC
3996Displays the contents of the file's relocation section, if it has one.
3997
3998@item -u
3999@itemx --unwind
4000@cindex unwind information
4001Displays the contents of the file's unwind section, if it has one. Only
4002the unwind sections for IA64 ELF files are currently supported.
252b5132
RH
4003
4004@item -d
4005@itemx --dynamic
4006@cindex ELF dynamic section information
4007Displays the contents of the file's dynamic section, if it has one.
4008
4009@item -V
4010@itemx --version-info
4011@cindex ELF version sections informations
4012Displays the contents of the version sections in the file, it they
4013exist.
4014
947ed062
NC
4015@item -A
4016@itemx --arch-specific
4017Displays architecture-specific information in the file, if there
4018is any.
4019
252b5132
RH
4020@item -D
4021@itemx --use-dynamic
c7c55b78 4022When displaying symbols, this option makes @command{readelf} use the
6dbb55b6 4023symbol table in the file's dynamic section, rather than the one in the
252b5132
RH
4024symbols section.
4025
aef1f6d0
DJ
4026@item -x <number or name>
4027@itemx --hex-dump=<number or name>
cf13d699 4028Displays the contents of the indicated section as a hexadecimal bytes.
aef1f6d0
DJ
4029A number identifies a particular section by index in the section table;
4030any other string identifies all sections with that name in the object file.
252b5132 4031
cf13d699
NC
4032@item -R <number or name>
4033@itemx --relocated-dump=<number or name>
4034Displays the contents of the indicated section as a hexadecimal
4035bytes. A number identifies a particular section by index in the
4036section table; any other string identifies all sections with that name
4037in the object file. The contents of the section will be relocated
4038before they are displayed.
4039
09c11c86
NC
4040@item -p <number or name>
4041@itemx --string-dump=<number or name>
4042Displays the contents of the indicated section as printable strings.
4043A number identifies a particular section by index in the section table;
4044any other string identifies all sections with that name in the object file.
4045
4145f1d5
NC
4046@item -c
4047@itemx --archive-index
4048@cindex Archive file symbol index information
4049Displays the file symbol index infomation contained in the header part
4050of binary archives. Performs the same function as the @option{t}
4051command to @command{ar}, but without using the BFD library. @xref{ar}.
4052
f9f0e732
NC
4053@item -w[lLiaprmfFsoRt]
4054@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes]
252b5132
RH
4055Displays the contents of the debug sections in the file, if any are
4056present. If one of the optional letters or words follows the switch
4057then only data found in those specific sections will be dumped.
4058
a262ae96
NC
4059Note: the @option{=decodedline} option will display the interpreted
4060contents of a .debug_line section whereas the @option{=rawline} option
4061dumps the contents in a raw format.
4062
1ed06042
NC
4063Note: the @option{=frames-interp} option will display the interpreted
4064contents of a .debug_frame section whereas the @option{=frames} option
4065dumps the contents in a raw format.
4066
947ed062
NC
4067@item -I
4068@itemx --histogram
252b5132
RH
4069Display a histogram of bucket list lengths when displaying the contents
4070of the symbol tables.
4071
4072@item -v
4073@itemx --version
4074Display the version number of readelf.
4075
d974e256
JJ
4076@item -W
4077@itemx --wide
4078Don't break output lines to fit into 80 columns. By default
4079@command{readelf} breaks section header and segment listing lines for
408064-bit ELF files, so that they fit into 80 columns. This option causes
4081@command{readelf} to print each section header resp. each segment one a
4082single line, which is far more readable on terminals wider than 80 columns.
4083
252b5132
RH
4084@item -H
4085@itemx --help
c7c55b78 4086Display the command line options understood by @command{readelf}.
252b5132
RH
4087
4088@end table
4089
0285c67d
NC
4090@c man end
4091
4092@ignore
4093@c man begin SEEALSO readelf
4094objdump(1), and the Info entries for @file{binutils}.
4095@c man end
4096@end ignore
252b5132 4097
30fd33bb
L
4098@node elfedit
4099@chapter elfedit
4100
4101@cindex Update ELF header
4102@kindex elfedit
4103
4104@c man title elfedit Update the ELF header of ELF files.
4105
4106@smallexample
4107@c man begin SYNOPSIS elfedit
4108elfedit [@option{--input-mach=}@var{machine}]
4109 @option{--output-machine=}@var{machine}
4110 [@option{-v}|@option{--version}]
4111 [@option{-h}|@option{--help}]
4112 @var{elffile}@dots{}
4113@c man end
4114@end smallexample
4115
4116@c man begin DESCRIPTION elfedit
4117
4118@command{elfedit} updates the ELF header of ELF files. The
4119options control how and which fields in the ELF header should be
4120updated.
4121
4122@var{elffile}@dots{} are the ELF files to be updated. 32-bit and
412364-bit ELF files are supported, as are archives containing ELF files.
4124@c man end
4125
4126@c man begin OPTIONS elfedit
4127
4128The long and short forms of options, shown here as alternatives, are
4129equivalent. The @option{--output-mach} option must be given.
4130
4131@table @env
4132
4133@itemx --input-mach=@var{machine}
4134Only the input files with ELF machine type, @var{machine}, will be
4135updated. If @option{--input-mach} isn't specified, any ELF file
4136will be updated.
4137
4138The supported ELF machine types are, @var{L1OM} and @var{x86-64}.
4139
4140@itemx --output-mach=@var{machine}
4141Change the ELF machine type in the ELF header to @var{machine}. The
4142supported ELF machine types are the same as @option{--input-mach}.
4143
4144@item -v
4145@itemx --version
4146Display the version number of @command{elfedit}.
4147
4148@item -h
4149@itemx --help
4150Display the command line options understood by @command{elfedit}.
4151
4152@end table
4153
4154@c man end
4155
4156@ignore
4157@c man begin SEEALSO elfedit
4158readelf(1), and the Info entries for @file{binutils}.
4159@c man end
4160@end ignore
4161
07012eee
MM
4162@node Common Options
4163@chapter Common Options
4164
4165The following command-line options are supported by all of the
4166programs described in this manual.
4167
dff70155 4168@c man begin OPTIONS
07012eee 4169@table @env
38fc1cb1 4170@include at-file.texi
dff70155 4171@c man end
07012eee
MM
4172
4173@item --help
4174Display the command-line options supported by the program.
4175
4176@item --version
4177Display the version number of the program.
4178
dff70155 4179@c man begin OPTIONS
07012eee 4180@end table
dff70155 4181@c man end
07012eee 4182
fff279a7 4183@node Selecting the Target System
947ed062 4184@chapter Selecting the Target System
252b5132 4185
947ed062 4186You can specify two aspects of the target system to the @sc{gnu}
252b5132
RH
4187binary file utilities, each in several ways:
4188
4189@itemize @bullet
4190@item
4191the target
4192
4193@item
4194the architecture
252b5132
RH
4195@end itemize
4196
4197In the following summaries, the lists of ways to specify values are in
4198order of decreasing precedence. The ways listed first override those
4199listed later.
4200
4201The commands to list valid values only list the values for which the
4202programs you are running were configured. If they were configured with
c7c55b78 4203@option{--enable-targets=all}, the commands list most of the available
252b5132
RH
4204values, but a few are left out; not all targets can be configured in at
4205once because some of them can only be configured @dfn{native} (on hosts
4206with the same type as the target system).
4207
4208@menu
c1c0eb9e
RM
4209* Target Selection::
4210* Architecture Selection::
252b5132
RH
4211@end menu
4212
4213@node Target Selection
4214@section Target Selection
4215
4216A @dfn{target} is an object file format. A given target may be
4217supported for multiple architectures (@pxref{Architecture Selection}).
4218A target selection may also have variations for different operating
4219systems or architectures.
4220
4221The command to list valid target values is @samp{objdump -i}
4222(the first column of output contains the relevant information).
4223
4224Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips},
4225@samp{a.out-sunos-big}.
4226
4227You can also specify a target using a configuration triplet. This is
f20a759a
ILT
4228the same sort of name that is passed to @file{configure} to specify a
4229target. When you use a configuration triplet as an argument, it must be
4230fully canonicalized. You can see the canonical version of a triplet by
252b5132
RH
4231running the shell script @file{config.sub} which is included with the
4232sources.
4233
4234Some sample configuration triplets are: @samp{m68k-hp-bsd},
4235@samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}.
4236
c7c55b78 4237@subheading @command{objdump} Target
252b5132
RH
4238
4239Ways to specify:
4240
4241@enumerate
4242@item
c7c55b78 4243command line option: @option{-b} or @option{--target}
252b5132
RH
4244
4245@item
4246environment variable @code{GNUTARGET}
4247
4248@item
4249deduced from the input file
4250@end enumerate
4251
c7c55b78 4252@subheading @command{objcopy} and @command{strip} Input Target
252b5132
RH
4253
4254Ways to specify:
4255
4256@enumerate
4257@item
c7c55b78 4258command line options: @option{-I} or @option{--input-target}, or @option{-F} or @option{--target}
252b5132
RH
4259
4260@item
4261environment variable @code{GNUTARGET}
4262
4263@item
4264deduced from the input file
4265@end enumerate
4266
c7c55b78 4267@subheading @command{objcopy} and @command{strip} Output Target
252b5132
RH
4268
4269Ways to specify:
4270
4271@enumerate
4272@item
c7c55b78 4273command line options: @option{-O} or @option{--output-target}, or @option{-F} or @option{--target}
252b5132
RH
4274
4275@item
c7c55b78 4276the input target (see ``@command{objcopy} and @command{strip} Input Target'' above)
252b5132
RH
4277
4278@item
4279environment variable @code{GNUTARGET}
4280
4281@item
4282deduced from the input file
4283@end enumerate
4284
c7c55b78 4285@subheading @command{nm}, @command{size}, and @command{strings} Target
252b5132
RH
4286
4287Ways to specify:
4288
4289@enumerate
4290@item
c7c55b78 4291command line option: @option{--target}
252b5132
RH
4292
4293@item
4294environment variable @code{GNUTARGET}
4295
4296@item
4297deduced from the input file
4298@end enumerate
4299
252b5132 4300@node Architecture Selection
947ed062 4301@section Architecture Selection
252b5132
RH
4302
4303An @dfn{architecture} is a type of @sc{cpu} on which an object file is
4304to run. Its name may contain a colon, separating the name of the
4305processor family from the name of the particular @sc{cpu}.
4306
4307The command to list valid architecture values is @samp{objdump -i} (the
4308second column contains the relevant information).
4309
4310Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}.
4311
c7c55b78 4312@subheading @command{objdump} Architecture
252b5132
RH
4313
4314Ways to specify:
4315
4316@enumerate
4317@item
c7c55b78 4318command line option: @option{-m} or @option{--architecture}
252b5132
RH
4319
4320@item
4321deduced from the input file
4322@end enumerate
4323
c7c55b78 4324@subheading @command{objcopy}, @command{nm}, @command{size}, @command{strings} Architecture
252b5132
RH
4325
4326Ways to specify:
4327
4328@enumerate
4329@item
4330deduced from the input file
4331@end enumerate
4332
252b5132
RH
4333@node Reporting Bugs
4334@chapter Reporting Bugs
4335@cindex bugs
4336@cindex reporting bugs
4337
4338Your bug reports play an essential role in making the binary utilities
4339reliable.
4340
4341Reporting a bug may help you by bringing a solution to your problem, or
4342it may not. But in any case the principal function of a bug report is
4343to help the entire community by making the next version of the binary
4344utilities work better. Bug reports are your contribution to their
4345maintenance.
4346
4347In order for a bug report to serve its purpose, you must include the
4348information that enables us to fix the bug.
4349
4350@menu
4351* Bug Criteria:: Have you found a bug?
4352* Bug Reporting:: How to report bugs
4353@end menu
4354
4355@node Bug Criteria
947ed062 4356@section Have You Found a Bug?
252b5132
RH
4357@cindex bug criteria
4358
4359If you are not sure whether you have found a bug, here are some guidelines:
4360
4361@itemize @bullet
4362@cindex fatal signal
4363@cindex crash
4364@item
4365If a binary utility gets a fatal signal, for any input whatever, that is
4366a bug. Reliable utilities never crash.
4367
4368@cindex error on valid input
4369@item
4370If a binary utility produces an error message for valid input, that is a
4371bug.
4372
4373@item
4374If you are an experienced user of binary utilities, your suggestions for
4375improvement are welcome in any case.
4376@end itemize
4377
4378@node Bug Reporting
947ed062 4379@section How to Report Bugs
252b5132
RH
4380@cindex bug reports
4381@cindex bugs, reporting
4382
4383A number of companies and individuals offer support for @sc{gnu}
4384products. If you obtained the binary utilities from a support
4385organization, we recommend you contact that organization first.
4386
4387You can find contact information for many support companies and
4388individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
4389distribution.
4390
ad22bfe8 4391@ifset BUGURL
252b5132 4392In any event, we also recommend that you send bug reports for the binary
ad22bfe8
JM
4393utilities to @value{BUGURL}.
4394@end ifset
252b5132
RH
4395
4396The fundamental principle of reporting bugs usefully is this:
4397@strong{report all the facts}. If you are not sure whether to state a
4398fact or leave it out, state it!
4399
4400Often people omit facts because they think they know what causes the
4401problem and assume that some details do not matter. Thus, you might
4402assume that the name of a file you use in an example does not matter.
4403Well, probably it does not, but one cannot be sure. Perhaps the bug is
4404a stray memory reference which happens to fetch from the location where
4405that pathname is stored in memory; perhaps, if the pathname were
4406different, the contents of that location would fool the utility into
4407doing the right thing despite the bug. Play it safe and give a
4408specific, complete example. That is the easiest thing for you to do,
4409and the most helpful.
4410
4411Keep in mind that the purpose of a bug report is to enable us to fix the bug if
4412it is new to us. Therefore, always write your bug reports on the assumption
4413that the bug has not been reported previously.
4414
4415Sometimes people give a few sketchy facts and ask, ``Does this ring a
947ed062
NC
4416bell?'' This cannot help us fix a bug, so it is basically useless. We
4417respond by asking for enough details to enable us to investigate.
4418You might as well expedite matters by sending them to begin with.
252b5132
RH
4419
4420To enable us to fix the bug, you should include all these things:
4421
4422@itemize @bullet
4423@item
4424The version of the utility. Each utility announces it if you start it
c7c55b78 4425with the @option{--version} argument.
252b5132
RH
4426
4427Without this, we will not know whether there is any point in looking for
4428the bug in the current version of the binary utilities.
4429
4430@item
4431Any patches you may have applied to the source, including any patches
4432made to the @code{BFD} library.
4433
4434@item
4435The type of machine you are using, and the operating system name and
4436version number.
4437
4438@item
4439What compiler (and its version) was used to compile the utilities---e.g.
4440``@code{gcc-2.7}''.
4441
4442@item
4443The command arguments you gave the utility to observe the bug. To
4444guarantee you will not omit something important, list them all. A copy
4445of the Makefile (or the output from make) is sufficient.
4446
4447If we were to try to guess the arguments, we would probably guess wrong
4448and then we might not encounter the bug.
4449
4450@item
4451A complete input file, or set of input files, that will reproduce the
4452bug. If the utility is reading an object file or files, then it is
ad22bfe8 4453generally most helpful to send the actual object files.
252b5132
RH
4454
4455If the source files were produced exclusively using @sc{gnu} programs
c7c55b78 4456(e.g., @command{gcc}, @command{gas}, and/or the @sc{gnu} @command{ld}), then it
252b5132 4457may be OK to send the source files rather than the object files. In
c7c55b78 4458this case, be sure to say exactly what version of @command{gcc}, or
252b5132 4459whatever, was used to produce the object files. Also say how
c7c55b78 4460@command{gcc}, or whatever, was configured.
252b5132
RH
4461
4462@item
4463A description of what behavior you observe that you believe is
4464incorrect. For example, ``It gets a fatal signal.''
4465
4466Of course, if the bug is that the utility gets a fatal signal, then we
4467will certainly notice it. But if the bug is incorrect output, we might
4468not notice unless it is glaringly wrong. You might as well not give us
4469a chance to make a mistake.
4470
4471Even if the problem you experience is a fatal signal, you should still
f20a759a 4472say so explicitly. Suppose something strange is going on, such as your
b45619c0 4473copy of the utility is out of sync, or you have encountered a bug in
252b5132
RH
4474the C library on your system. (This has happened!) Your copy might
4475crash and ours would not. If you told us to expect a crash, then when
4476ours fails to crash, we would know that the bug was not happening for
4477us. If you had not told us to expect a crash, then we would not be able
4478to draw any conclusion from our observations.
4479
4480@item
4481If you wish to suggest changes to the source, send us context diffs, as
c7c55b78 4482generated by @command{diff} with the @option{-u}, @option{-c}, or @option{-p}
252b5132 4483option. Always send diffs from the old file to the new file. If you
c7c55b78 4484wish to discuss something in the @command{ld} source, refer to it by
f20a759a 4485context, not by line number.
252b5132
RH
4486
4487The line numbers in our development sources will not match those in your
4488sources. Your line numbers would convey no useful information to us.
4489@end itemize
4490
4491Here are some things that are not necessary:
4492
4493@itemize @bullet
4494@item
4495A description of the envelope of the bug.
4496
4497Often people who encounter a bug spend a lot of time investigating
4498which changes to the input file will make the bug go away and which
4499changes will not affect it.
4500
4501This is often time consuming and not very useful, because the way we
4502will find the bug is by running a single example under the debugger
4503with breakpoints, not by pure deduction from a series of examples.
4504We recommend that you save your time for something else.
4505
4506Of course, if you can find a simpler example to report @emph{instead}
4507of the original one, that is a convenience for us. Errors in the
4508output will be easier to spot, running under the debugger will take
4509less time, and so on.
4510
4511However, simplification is not vital; if you do not want to do this,
4512report the bug anyway and send us the entire test case you used.
4513
4514@item
4515A patch for the bug.
4516
4517A patch for the bug does help us if it is a good one. But do not omit
4518the necessary information, such as the test case, on the assumption that
4519a patch is all we need. We might see problems with your patch and decide
4520to fix the problem another way, or we might not understand it at all.
4521
4522Sometimes with programs as complicated as the binary utilities it is
4523very hard to construct an example that will make the program follow a
4524certain path through the code. If you do not send us the example, we
4525will not be able to construct one, so we will not be able to verify that
4526the bug is fixed.
4527
4528And if we cannot understand what bug you are trying to fix, or why your
4529patch should be an improvement, we will not install it. A test case will
4530help us to understand.
4531
4532@item
4533A guess about what the bug is or what it depends on.
4534
4535Such guesses are usually wrong. Even we cannot guess right about such
4536things without first using the debugger to find the facts.
4537@end itemize
4538
fff279a7
NC
4539@node GNU Free Documentation License
4540@appendix GNU Free Documentation License
4541
947ed062 4542@include fdl.texi
cf055d54 4543
fa0d8a3e
NC
4544@node Binutils Index
4545@unnumbered Binutils Index
252b5132
RH
4546
4547@printindex cp
4548
252b5132 4549@bye
This page took 0.697225 seconds and 4 git commands to generate.