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