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