gdb/
[deliverable/binutils-gdb.git] / binutils / doc / binutils.texi
CommitLineData
252b5132
RH
1\input texinfo @c -*- Texinfo -*-
2@setfilename binutils.info
e016ec1f
NC
3@settitle @sc{gnu} Binary Utilities
4@finalout
5@synindex ky cp
8c2bc687 6
dff70155 7@c man begin INCLUDE
c428fa83 8@include bfdver.texi
dff70155 9@c man end
252b5132 10
0e9517a9 11@copying
0285c67d 12@c man begin COPYRIGHT
36e32b27
NC
13Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
141999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010, 2011, 2012
ed22650e 16Free Software Foundation, Inc.
252b5132 17
0285c67d 18Permission is granted to copy, distribute and/or modify this document
793c5807 19under the terms of the GNU Free Documentation License, Version 1.3
0285c67d
NC
20or any later version published by the Free Software Foundation;
21with no Invariant Sections, with no Front-Cover Texts, and with no
22Back-Cover Texts. A copy of the license is included in the
947ed062 23section entitled ``GNU Free Documentation License''.
252b5132 24
0285c67d 25@c man end
0e9517a9 26@end copying
252b5132 27
e016ec1f
NC
28@dircategory Software development
29@direntry
30* Binutils: (binutils). The GNU binary utilities.
31@end direntry
32
33@dircategory Individual utilities
34@direntry
35* addr2line: (binutils)addr2line. Convert addresses to file and line.
36* ar: (binutils)ar. Create, modify, and extract from archives.
37* c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols.
38* cxxfilt: (binutils)c++filt. MS-DOS name for c++filt.
39* dlltool: (binutils)dlltool. Create files needed to build and use DLLs.
40* nlmconv: (binutils)nlmconv. Converts object code into an NLM.
41* nm: (binutils)nm. List symbols from object files.
42* objcopy: (binutils)objcopy. Copy and translate object files.
43* objdump: (binutils)objdump. Display information from object files.
44* ranlib: (binutils)ranlib. Generate index to archive contents.
45* readelf: (binutils)readelf. Display the contents of ELF format files.
46* size: (binutils)size. List section sizes and total size.
47* strings: (binutils)strings. List printable strings from files.
48* strip: (binutils)strip. Discard symbols.
30fd33bb 49* elfedit: (binutils)elfedit. Update the ELF header of ELF files.
e016ec1f
NC
50* windmc: (binutils)windmc. Generator for Windows message resources.
51* windres: (binutils)windres. Manipulate Windows resources.
52@end direntry
53
252b5132 54@titlepage
252b5132 55@title The @sc{gnu} Binary Utilities
e49e529d
JM
56@ifset VERSION_PACKAGE
57@subtitle @value{VERSION_PACKAGE}
58@end ifset
252b5132
RH
59@subtitle Version @value{VERSION}
60@sp 1
36607f99 61@subtitle @value{UPDATED}
252b5132
RH
62@author Roland H. Pesch
63@author Jeffrey M. Osier
64@author Cygnus Support
65@page
66
67@tex
68{\parskip=0pt \hfill Cygnus Support\par \hfill
e016ec1f 69Texinfo \texinfoversion\par }
252b5132
RH
70@end tex
71
72@vskip 0pt plus 1filll
e016ec1f 73@insertcopying
252b5132 74@end titlepage
4ecceb71 75@contents
252b5132
RH
76
77@node Top
78@top Introduction
79
80@cindex version
947ed062 81This brief manual contains documentation for the @sc{gnu} binary
e49e529d
JM
82utilities
83@ifset VERSION_PACKAGE
84@value{VERSION_PACKAGE}
85@end ifset
86version @value{VERSION}:
252b5132
RH
87
88@iftex
89@table @code
90@item ar
91Create, modify, and extract from archives
92
93@item nm
94List symbols from object files
95
96@item objcopy
97Copy and translate object files
98
99@item objdump
100Display information from object files
101
102@item ranlib
103Generate index to archive contents
104
105@item readelf
106Display the contents of ELF format files.
107
108@item size
109List file section sizes and total size
110
111@item strings
112List printable strings from files
113
114@item strip
115Discard symbols
116
30fd33bb
L
117@item elfedit
118Update the ELF header of ELF files.
119
252b5132 120@item c++filt
9d51cc66
ILT
121Demangle encoded C++ symbols (on MS-DOS, this program is named
122@code{cxxfilt})
252b5132
RH
123
124@item addr2line
125Convert addresses into file names and line numbers
126
127@item nlmconv
128Convert object code into a Netware Loadable Module
129
130@item windres
131Manipulate Windows resources
132
692ed3e7
NC
133@item windmc
134Genertor for Windows message resources
135
252b5132
RH
136@item dlltool
137Create the files needed to build and use Dynamic Link Libraries
138@end table
139@end iftex
140
cf055d54 141This document is distributed under the terms of the GNU Free
793c5807
NC
142Documentation License version 1.3. A copy of the license is included
143in the section entitled ``GNU Free Documentation License''.
cf055d54 144
252b5132
RH
145@menu
146* ar:: Create, modify, and extract from archives
147* nm:: List symbols from object files
148* objcopy:: Copy and translate object files
149* objdump:: Display information from object files
150* ranlib:: Generate index to archive contents
fff279a7 151* readelf:: Display the contents of ELF format files
252b5132
RH
152* size:: List section sizes and total size
153* strings:: List printable strings from files
154* strip:: Discard symbols
30fd33bb 155* elfedit:: Update the ELF header of ELF files
252b5132 156* c++filt:: Filter to demangle encoded C++ symbols
9d51cc66 157* cxxfilt: c++filt. MS-DOS name for c++filt
252b5132
RH
158* addr2line:: Convert addresses to file and line
159* nlmconv:: Converts object code into an NLM
160* windres:: Manipulate Windows resources
692ed3e7 161* windmc:: Generator for Windows message resources
252b5132 162* dlltool:: Create files needed to build and use DLLs
07012eee 163* Common Options:: Command-line options for all utilities
fff279a7 164* Selecting the Target System:: How these utilities determine the target
252b5132 165* Reporting Bugs:: Reporting Bugs
cf055d54 166* GNU Free Documentation License:: GNU Free Documentation License
fa0d8a3e 167* Binutils Index:: Binutils Index
252b5132
RH
168@end menu
169
170@node ar
171@chapter ar
172
173@kindex ar
174@cindex archives
175@cindex collections of files
0285c67d
NC
176
177@c man title ar create, modify, and extract from archives
178
252b5132 179@smallexample
b3364cb9 180ar [@option{--plugin} @var{name}] [-]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] [@option{--target} @var{bfdname}] @var{archive} [@var{member}@dots{}]
252b5132
RH
181ar -M [ <mri-script ]
182@end smallexample
183
0285c67d
NC
184@c man begin DESCRIPTION ar
185
c7c55b78 186The @sc{gnu} @command{ar} program creates, modifies, and extracts from
252b5132
RH
187archives. An @dfn{archive} is a single file holding a collection of
188other files in a structure that makes it possible to retrieve
189the original individual files (called @dfn{members} of the archive).
190
191The original files' contents, mode (permissions), timestamp, owner, and
192group are preserved in the archive, and can be restored on
c1c0eb9e 193extraction.
252b5132
RH
194
195@cindex name length
c7c55b78
NC
196@sc{gnu} @command{ar} can maintain archives whose members have names of any
197length; however, depending on how @command{ar} is configured on your
252b5132
RH
198system, a limit on member-name length may be imposed for compatibility
199with archive formats maintained with other tools. If it exists, the
200limit is often 15 characters (typical of formats related to a.out) or 16
201characters (typical of formats related to coff).
202
203@cindex libraries
c7c55b78 204@command{ar} is considered a binary utility because archives of this sort
252b5132
RH
205are most often used as @dfn{libraries} holding commonly needed
206subroutines.
207
208@cindex symbol index
c7c55b78 209@command{ar} creates an index to the symbols defined in relocatable
252b5132 210object modules in the archive when you specify the modifier @samp{s}.
c7c55b78 211Once created, this index is updated in the archive whenever @command{ar}
252b5132
RH
212makes a change to its contents (save for the @samp{q} update operation).
213An archive with such an index speeds up linking to the library, and
214allows routines in the library to call each other without regard to
215their placement in the archive.
216
217You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
c7c55b78
NC
218table. If an archive lacks the table, another form of @command{ar} called
219@command{ranlib} can be used to add just the table.
252b5132 220
a8da6403
NC
221@cindex thin archives
222@sc{gnu} @command{ar} can optionally create a @emph{thin} archive,
223which contains a symbol index and references to the original copies
224of the member files of the archives. Such an archive is useful
225for building libraries for use within a local build, where the
226relocatable objects are expected to remain available, and copying the
227contents of each object would only waste time and space. Thin archives
228are also @emph{flattened}, so that adding one or more archives to a
229thin archive will add the elements of the nested archive individually.
230The paths to the elements of the archive are stored relative to the
231archive itself.
232
c7c55b78
NC
233@cindex compatibility, @command{ar}
234@cindex @command{ar} compatibility
235@sc{gnu} @command{ar} is designed to be compatible with two different
252b5132 236facilities. You can control its activity using command-line options,
c7c55b78
NC
237like the different varieties of @command{ar} on Unix systems; or, if you
238specify the single command-line option @option{-M}, you can control it
252b5132
RH
239with a script supplied via standard input, like the MRI ``librarian''
240program.
241
0285c67d
NC
242@c man end
243
252b5132 244@menu
c7c55b78
NC
245* ar cmdline:: Controlling @command{ar} on the command line
246* ar scripts:: Controlling @command{ar} with a script
252b5132
RH
247@end menu
248
249@page
250@node ar cmdline
947ed062 251@section Controlling @command{ar} on the Command Line
252b5132
RH
252
253@smallexample
0285c67d 254@c man begin SYNOPSIS ar
8adf5d70 255ar [@option{--plugin} @var{name}] [@option{-X32_64}] [@option{-}]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] [@option{--target} @var{bfdname}] @var{archive} [@var{member}@dots{}]
0285c67d 256@c man end
252b5132
RH
257@end smallexample
258
c7c55b78
NC
259@cindex Unix compatibility, @command{ar}
260When you use @command{ar} in the Unix style, @command{ar} insists on at least two
252b5132
RH
261arguments to execute: one keyletter specifying the @emph{operation}
262(optionally accompanied by other keyletters specifying
263@emph{modifiers}), and the archive name to act on.
264
265Most operations can also accept further @var{member} arguments,
266specifying particular files to operate on.
267
0285c67d
NC
268@c man begin OPTIONS ar
269
c7c55b78 270@sc{gnu} @command{ar} allows you to mix the operation code @var{p} and modifier
252b5132
RH
271flags @var{mod} in any order, within the first command-line argument.
272
273If you wish, you may begin the first command-line argument with a
274dash.
275
276@cindex operations on archive
277The @var{p} keyletter specifies what operation to execute; it may be
278any of the following, but you must specify only one of them:
279
c7c55b78 280@table @samp
252b5132
RH
281@item d
282@cindex deleting from archive
283@emph{Delete} modules from the archive. Specify the names of modules to
284be deleted as @var{member}@dots{}; the archive is untouched if you
285specify no files to delete.
286
c7c55b78 287If you specify the @samp{v} modifier, @command{ar} lists each module
252b5132
RH
288as it is deleted.
289
290@item m
291@cindex moving in archive
292Use this operation to @emph{move} members in an archive.
293
294The ordering of members in an archive can make a difference in how
295programs are linked using the library, if a symbol is defined in more
c1c0eb9e 296than one member.
252b5132
RH
297
298If no modifiers are used with @code{m}, any members you name in the
299@var{member} arguments are moved to the @emph{end} of the archive;
300you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
301specified place instead.
302
303@item p
304@cindex printing from archive
305@emph{Print} the specified members of the archive, to the standard
306output file. If the @samp{v} modifier is specified, show the member
307name before copying its contents to standard output.
308
309If you specify no @var{member} arguments, all the files in the archive are
310printed.
311
312@item q
313@cindex quick append to archive
314@emph{Quick append}; Historically, add the files @var{member}@dots{} to the end of
315@var{archive}, without checking for replacement.
316
317The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
318operation; new members are always placed at the end of the archive.
319
c7c55b78 320The modifier @samp{v} makes @command{ar} list each file as it is appended.
252b5132
RH
321
322Since the point of this operation is speed, the archive's symbol table
323index is not updated, even if it already existed; you can use @samp{ar s} or
c7c55b78 324@command{ranlib} explicitly to update the symbol table index.
252b5132
RH
325
326However, too many different systems assume quick append rebuilds the
947ed062 327index, so @sc{gnu} @command{ar} implements @samp{q} as a synonym for @samp{r}.
252b5132
RH
328
329@item r
330@cindex replacement in archive
331Insert the files @var{member}@dots{} into @var{archive} (with
332@emph{replacement}). This operation differs from @samp{q} in that any
333previously existing members are deleted if their names match those being
334added.
335
c7c55b78 336If one of the files named in @var{member}@dots{} does not exist, @command{ar}
252b5132
RH
337displays an error message, and leaves undisturbed any existing members
338of the archive matching that name.
339
340By default, new members are added at the end of the file; but you may
341use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
342placement relative to some existing member.
343
344The modifier @samp{v} used with this operation elicits a line of
345output for each file inserted, along with one of the letters @samp{a} or
346@samp{r} to indicate whether the file was appended (no old member
347deleted) or replaced.
348
e58bcb8f
NC
349@item s
350@cindex ranlib
351Add an index to the archive, or update it if it already exists. Note
352this command is an exception to the rule that there can only be one
353command letter, as it is possible to use it as either a command or a
354modifier. In either case it does the same thing.
355
252b5132
RH
356@item t
357@cindex contents of archive
358Display a @emph{table} listing the contents of @var{archive}, or those
359of the files listed in @var{member}@dots{} that are present in the
360archive. Normally only the member name is shown; if you also want to
361see the modes (permissions), timestamp, owner, group, and size, you can
362request that by also specifying the @samp{v} modifier.
363
364If you do not specify a @var{member}, all files in the archive
365are listed.
366
367@cindex repeated names in archive
368@cindex name duplication in archive
369If there is more than one file with the same name (say, @samp{fie}) in
370an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
371first instance; to see them all, you must ask for a complete
372listing---in our example, @samp{ar t b.a}.
373@c WRS only; per Gumby, this is implementation-dependent, and in a more
374@c recent case in fact works the other way.
375
376@item x
377@cindex extract from archive
378@emph{Extract} members (named @var{member}) from the archive. You can
379use the @samp{v} modifier with this operation, to request that
c7c55b78 380@command{ar} list each name as it extracts it.
252b5132
RH
381
382If you do not specify a @var{member}, all files in the archive
383are extracted.
384
a8da6403
NC
385Files cannot be extracted from a thin archive.
386
8adf5d70
NC
387@item --help
388Displays the list of command line options supported by @command{ar}
389and then exits.
390
391@item --version
392Displays the version information of @command{ar} and then exits.
393
252b5132
RH
394@end table
395
396A number of modifiers (@var{mod}) may immediately follow the @var{p}
397keyletter, to specify variations on an operation's behavior:
398
c7c55b78 399@table @samp
252b5132
RH
400@item a
401@cindex relative placement in archive
402Add new files @emph{after} an existing member of the
403archive. If you use the modifier @samp{a}, the name of an existing archive
404member must be present as the @var{relpos} argument, before the
405@var{archive} specification.
406
407@item b
408Add new files @emph{before} an existing member of the
409archive. If you use the modifier @samp{b}, the name of an existing archive
410member must be present as the @var{relpos} argument, before the
411@var{archive} specification. (same as @samp{i}).
412
413@item c
414@cindex creating archives
415@emph{Create} the archive. The specified @var{archive} is always
416created if it did not exist, when you request an update. But a warning is
417issued unless you specify in advance that you expect to create it, by
418using this modifier.
419
36e4dce6
CD
420@item D
421@cindex deterministic archives
9cb80f72 422@kindex --enable-deterministic-archives
36e4dce6
CD
423Operate in @emph{deterministic} mode. When adding files and the archive
424index use zero for UIDs, GIDs, timestamps, and use consistent file modes
425for all files. When this option is used, if @command{ar} is used with
426identical options and identical input files, multiple runs will create
427identical output files regardless of the input files' owners, groups,
428file modes, or modification times.
429
9cb80f72
RM
430If @file{binutils} was configured with
431@option{--enable-deterministic-archives}, then this mode is on by default.
432It can be disabled with the @samp{U} modifier, below.
433
252b5132 434@item f
c7c55b78 435Truncate names in the archive. @sc{gnu} @command{ar} will normally permit file
252b5132 436names of any length. This will cause it to create archives which are
c7c55b78 437not compatible with the native @command{ar} program on some systems. If
252b5132
RH
438this is a concern, the @samp{f} modifier may be used to truncate file
439names when putting them in the archive.
440
441@item i
442Insert new files @emph{before} an existing member of the
443archive. If you use the modifier @samp{i}, the name of an existing archive
444member must be present as the @var{relpos} argument, before the
445@var{archive} specification. (same as @samp{b}).
446
447@item l
448This modifier is accepted but not used.
449@c whaffor ar l modifier??? presumably compat; with
c1c0eb9e 450@c what???---doc@@cygnus.com, 25jan91
252b5132 451
3de39064
ILT
452@item N
453Uses the @var{count} parameter. This is used if there are multiple
454entries in the archive with the same name. Extract or delete instance
455@var{count} of the given name from the archive.
456
252b5132
RH
457@item o
458@cindex dates in archive
459Preserve the @emph{original} dates of members when extracting them. If
460you do not specify this modifier, files extracted from the archive
461are stamped with the time of extraction.
462
3de39064
ILT
463@item P
464Use the full path name when matching names in the archive. @sc{gnu}
c7c55b78 465@command{ar} can not create an archive with a full path name (such archives
3de39064 466are not POSIX complaint), but other archive creators can. This option
c7c55b78 467will cause @sc{gnu} @command{ar} to match file names using a complete path
3de39064
ILT
468name, which can be convenient when extracting a single file from an
469archive created by another tool.
470
252b5132
RH
471@item s
472@cindex writing archive index
473Write an object-file index into the archive, or update an existing one,
474even if no other change is made to the archive. You may use this modifier
475flag either with any operation, or alone. Running @samp{ar s} on an
476archive is equivalent to running @samp{ranlib} on it.
477
478@item S
479@cindex not writing archive index
480Do not generate an archive symbol table. This can speed up building a
481large library in several steps. The resulting archive can not be used
482with the linker. In order to build a symbol table, you must omit the
483@samp{S} modifier on the last execution of @samp{ar}, or you must run
484@samp{ranlib} on the archive.
485
a8da6403
NC
486@item T
487@cindex creating thin archive
488Make the specified @var{archive} a @emph{thin} archive. If it already
489exists and is a regular archive, the existing members must be present
490in the same directory as @var{archive}.
491
252b5132
RH
492@item u
493@cindex updating an archive
494Normally, @samp{ar r}@dots{} inserts all files
495listed into the archive. If you would like to insert @emph{only} those
496of the files you list that are newer than existing members of the same
497names, use this modifier. The @samp{u} modifier is allowed only for the
498operation @samp{r} (replace). In particular, the combination @samp{qu} is
499not allowed, since checking the timestamps would lose any speed
500advantage from the operation @samp{q}.
501
9cb80f72
RM
502@item U
503@cindex deterministic archives
504@kindex --enable-deterministic-archives
505Do @emph{not} operate in @emph{deterministic} mode. This is the inverse
506of the @samp{D} modifier, above: added files and the archive index will
507get their actual UID, GID, timestamp, and file mode values.
508
509This is the default unless @file{binutils} was configured with
510@option{--enable-deterministic-archives}.
511
252b5132
RH
512@item v
513This modifier requests the @emph{verbose} version of an operation. Many
514operations display additional information, such as filenames processed,
515when the modifier @samp{v} is appended.
516
517@item V
c7c55b78 518This modifier shows the version number of @command{ar}.
252b5132
RH
519@end table
520
c7c55b78 521@command{ar} ignores an initial option spelt @samp{-X32_64}, for
6e800839 522compatibility with AIX. The behaviour produced by this option is the
947ed062 523default for @sc{gnu} @command{ar}. @command{ar} does not support any of the other
c7c55b78
NC
524@samp{-X} options; in particular, it does not support @option{-X32}
525which is the default for AIX @command{ar}.
6e800839 526
ce3c775b
NC
527The optional command line switch @option{--plugin} @var{name} causes
528@command{ar} to load the plugin called @var{name} which adds support
529for more file formats. This option is only available if the toolchain
530has been built with plugin support enabled.
531
8adf5d70
NC
532The optional command line switch @option{--target} @var{bfdname}
533specifies that the archive members are in an object code format
534different from your system's default format. See
535@xref{Target Selection}, for more information.
536
0285c67d
NC
537@c man end
538
539@ignore
540@c man begin SEEALSO ar
541nm(1), ranlib(1), and the Info entries for @file{binutils}.
542@c man end
543@end ignore
544
252b5132 545@node ar scripts
947ed062 546@section Controlling @command{ar} with a Script
252b5132
RH
547
548@smallexample
549ar -M [ <@var{script} ]
550@end smallexample
551
c7c55b78
NC
552@cindex MRI compatibility, @command{ar}
553@cindex scripts, @command{ar}
554If you use the single command-line option @samp{-M} with @command{ar}, you
252b5132 555can control its operation with a rudimentary command language. This
c7c55b78
NC
556form of @command{ar} operates interactively if standard input is coming
557directly from a terminal. During interactive use, @command{ar} prompts for
252b5132
RH
558input (the prompt is @samp{AR >}), and continues executing even after
559errors. If you redirect standard input to a script file, no prompts are
c7c55b78 560issued, and @command{ar} abandons execution (with a nonzero exit code)
252b5132
RH
561on any error.
562
c7c55b78 563The @command{ar} command language is @emph{not} designed to be equivalent
252b5132
RH
564to the command-line options; in fact, it provides somewhat less control
565over archives. The only purpose of the command language is to ease the
c7c55b78 566transition to @sc{gnu} @command{ar} for developers who already have scripts
252b5132
RH
567written for the MRI ``librarian'' program.
568
c7c55b78 569The syntax for the @command{ar} command language is straightforward:
252b5132
RH
570@itemize @bullet
571@item
572commands are recognized in upper or lower case; for example, @code{LIST}
573is the same as @code{list}. In the following descriptions, commands are
574shown in upper case for clarity.
575
576@item
577a single command may appear on each line; it is the first word on the
578line.
579
580@item
581empty lines are allowed, and have no effect.
582
583@item
584comments are allowed; text after either of the characters @samp{*}
585or @samp{;} is ignored.
586
587@item
c7c55b78 588Whenever you use a list of names as part of the argument to an @command{ar}
252b5132
RH
589command, you can separate the individual names with either commas or
590blanks. Commas are shown in the explanations below, for clarity.
591
592@item
593@samp{+} is used as a line continuation character; if @samp{+} appears
594at the end of a line, the text on the following line is considered part
595of the current command.
596@end itemize
597
c7c55b78
NC
598Here are the commands you can use in @command{ar} scripts, or when using
599@command{ar} interactively. Three of them have special significance:
252b5132
RH
600
601@code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
602a temporary file required for most of the other commands.
603
604@code{SAVE} commits the changes so far specified by the script. Prior
605to @code{SAVE}, commands affect only the temporary copy of the current
606archive.
607
608@table @code
c1c0eb9e 609@item ADDLIB @var{archive}
252b5132
RH
610@itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
611Add all the contents of @var{archive} (or, if specified, each named
612@var{module} from @var{archive}) to the current archive.
613
614Requires prior use of @code{OPEN} or @code{CREATE}.
615
616@item ADDMOD @var{member}, @var{member}, @dots{} @var{member}
617@c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
618@c else like "ar q..."
619Add each named @var{member} as a module in the current archive.
620
621Requires prior use of @code{OPEN} or @code{CREATE}.
622
623@item CLEAR
624Discard the contents of the current archive, canceling the effect of
625any operations since the last @code{SAVE}. May be executed (with no
626effect) even if no current archive is specified.
627
628@item CREATE @var{archive}
629Creates an archive, and makes it the current archive (required for many
630other commands). The new archive is created with a temporary name; it
631is not actually saved as @var{archive} until you use @code{SAVE}.
632You can overwrite existing archives; similarly, the contents of any
633existing file named @var{archive} will not be destroyed until @code{SAVE}.
634
635@item DELETE @var{module}, @var{module}, @dots{} @var{module}
636Delete each listed @var{module} from the current archive; equivalent to
637@samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
638
639Requires prior use of @code{OPEN} or @code{CREATE}.
640
641@item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
642@itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
643List each named @var{module} present in @var{archive}. The separate
644command @code{VERBOSE} specifies the form of the output: when verbose
645output is off, output is like that of @samp{ar -t @var{archive}
646@var{module}@dots{}}. When verbose output is on, the listing is like
647@samp{ar -tv @var{archive} @var{module}@dots{}}.
648
649Output normally goes to the standard output stream; however, if you
c7c55b78 650specify @var{outputfile} as a final argument, @command{ar} directs the
252b5132
RH
651output to that file.
652
653@item END
c7c55b78 654Exit from @command{ar}, with a @code{0} exit code to indicate successful
252b5132
RH
655completion. This command does not save the output file; if you have
656changed the current archive since the last @code{SAVE} command, those
657changes are lost.
658
659@item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
660Extract each named @var{module} from the current archive, writing them
661into the current directory as separate files. Equivalent to @samp{ar -x
662@var{archive} @var{module}@dots{}}.
663
664Requires prior use of @code{OPEN} or @code{CREATE}.
665
666@ignore
667@c FIXME Tokens but no commands???
668@item FULLDIR
669
670@item HELP
671@end ignore
672
673@item LIST
674Display full contents of the current archive, in ``verbose'' style
675regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
c7c55b78 676tv @var{archive}}. (This single command is a @sc{gnu} @command{ar}
252b5132
RH
677enhancement, rather than present for MRI compatibility.)
678
679Requires prior use of @code{OPEN} or @code{CREATE}.
680
681@item OPEN @var{archive}
682Opens an existing archive for use as the current archive (required for
683many other commands). Any changes as the result of subsequent commands
684will not actually affect @var{archive} until you next use @code{SAVE}.
685
686@item REPLACE @var{module}, @var{module}, @dots{} @var{module}
687In the current archive, replace each existing @var{module} (named in
688the @code{REPLACE} arguments) from files in the current working directory.
689To execute this command without errors, both the file, and the module in
c1c0eb9e 690the current archive, must exist.
252b5132
RH
691
692Requires prior use of @code{OPEN} or @code{CREATE}.
693
694@item VERBOSE
695Toggle an internal flag governing the output from @code{DIRECTORY}.
696When the flag is on, @code{DIRECTORY} output matches output from
697@samp{ar -tv }@dots{}.
698
699@item SAVE
700Commit your changes to the current archive, and actually save it as a
701file with the name specified in the last @code{CREATE} or @code{OPEN}
c1c0eb9e 702command.
252b5132
RH
703
704Requires prior use of @code{OPEN} or @code{CREATE}.
705
706@end table
707
708@iftex
709@node ld
710@chapter ld
711@cindex linker
712@kindex ld
c7c55b78 713The @sc{gnu} linker @command{ld} is now described in a separate manual.
252b5132
RH
714@xref{Top,, Overview,, Using LD: the @sc{gnu} linker}.
715@end iftex
716
717@node nm
718@chapter nm
719@cindex symbols
720@kindex nm
721
0285c67d
NC
722@c man title nm list symbols from object files
723
252b5132 724@smallexample
0285c67d 725@c man begin SYNOPSIS nm
ce3c775b
NC
726nm [@option{-a}|@option{--debug-syms}]
727 [@option{-g}|@option{--extern-only}][@option{--plugin} @var{name}]
c7c55b78 728 [@option{-B}] [@option{-C}|@option{--demangle}[=@var{style}]] [@option{-D}|@option{--dynamic}]
72797995 729 [@option{-S}|@option{--print-size}] [@option{-s}|@option{--print-armap}]
3c9458e9 730 [@option{-A}|@option{-o}|@option{--print-file-name}][@option{--special-syms}]
c7c55b78
NC
731 [@option{-n}|@option{-v}|@option{--numeric-sort}] [@option{-p}|@option{--no-sort}]
732 [@option{-r}|@option{--reverse-sort}] [@option{--size-sort}] [@option{-u}|@option{--undefined-only}]
733 [@option{-t} @var{radix}|@option{--radix=}@var{radix}] [@option{-P}|@option{--portability}]
734 [@option{--target=}@var{bfdname}] [@option{-f}@var{format}|@option{--format=}@var{format}]
735 [@option{--defined-only}] [@option{-l}|@option{--line-numbers}] [@option{--no-demangle}]
736 [@option{-V}|@option{--version}] [@option{-X 32_64}] [@option{--help}] [@var{objfile}@dots{}]
0285c67d 737@c man end
252b5132
RH
738@end smallexample
739
0285c67d 740@c man begin DESCRIPTION nm
c7c55b78
NC
741@sc{gnu} @command{nm} lists the symbols from object files @var{objfile}@dots{}.
742If no object files are listed as arguments, @command{nm} assumes the file
252b5132
RH
743@file{a.out}.
744
c7c55b78 745For each symbol, @command{nm} shows:
252b5132
RH
746
747@itemize @bullet
748@item
749The symbol value, in the radix selected by options (see below), or
750hexadecimal by default.
751
752@item
753The symbol type. At least the following types are used; others are, as
754well, depending on the object file format. If lowercase, the symbol is
0ba0c2b3
NC
755usually local; if uppercase, the symbol is global (external). There
756are however a few lowercase symbols that are shown for special global
757symbols (@code{u}, @code{v} and @code{w}).
252b5132
RH
758
759@c Some more detail on exactly what these symbol types are used for
760@c would be nice.
761@table @code
762@item A
763The symbol's value is absolute, and will not be changed by further
764linking.
765
766@item B
a1039809 767@itemx b
252b5132
RH
768The symbol is in the uninitialized data section (known as BSS).
769
770@item C
771The symbol is common. Common symbols are uninitialized data. When
772linking, multiple common symbols may appear with the same name. If the
773symbol is defined anywhere, the common symbols are treated as undefined
0285c67d
NC
774references.
775@ifclear man
776For more details on common symbols, see the discussion of
252b5132 777--warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}.
0879a67a 778@end ifclear
252b5132
RH
779
780@item D
a1039809 781@itemx d
252b5132
RH
782The symbol is in the initialized data section.
783
784@item G
a1039809 785@itemx g
252b5132
RH
786The symbol is in an initialized data section for small objects. Some
787object file formats permit more efficient access to small data objects,
788such as a global int variable as opposed to a large global array.
789
a1039809 790@item i
3e7a7d11
NC
791For PE format files this indicates that the symbol is in a section
792specific to the implementation of DLLs. For ELF format files this
793indicates that the symbol is an indirect function. This is a GNU
794extension to the standard set of ELF symbol types. It indicates a
795symbol which if referenced by a relocation does not evaluate to its
796address, but instead must be invoked at runtime. The runtime
797execution will then return the value to be used in the relocation.
a1039809 798
252b5132
RH
799@item N
800The symbol is a debugging symbol.
801
a1039809
NC
802@item p
803The symbols is in a stack unwind section.
804
252b5132 805@item R
a1039809 806@itemx r
252b5132
RH
807The symbol is in a read only data section.
808
809@item S
a1039809 810@itemx s
252b5132
RH
811The symbol is in an uninitialized data section for small objects.
812
813@item T
a1039809 814@itemx t
252b5132
RH
815The symbol is in the text (code) section.
816
817@item U
818The symbol is undefined.
819
3e7a7d11
NC
820@item u
821The symbol is a unique global symbol. This is a GNU extension to the
822standard set of ELF symbol bindings. For such a symbol the dynamic linker
823will make sure that in the entire process there is just one symbol with
824this name and type in use.
825
fad6fcbb 826@item V
a1039809 827@itemx v
fad6fcbb
NC
828The symbol is a weak object. When a weak defined symbol is linked with
829a normal defined symbol, the normal defined symbol is used with no error.
830When a weak undefined symbol is linked and the symbol is not defined,
a1039809
NC
831the value of the weak symbol becomes zero with no error. On some
832systems, uppercase indicates that a default value has been specified.
fad6fcbb 833
252b5132 834@item W
a1039809 835@itemx w
fad6fcbb
NC
836The symbol is a weak symbol that has not been specifically tagged as a
837weak object symbol. When a weak defined symbol is linked with a normal
838defined symbol, the normal defined symbol is used with no error.
839When a weak undefined symbol is linked and the symbol is not defined,
c87db184 840the value of the symbol is determined in a system-specific manner without
c1c0eb9e 841error. On some systems, uppercase indicates that a default value has been
977cdf5a
NC
842specified.
843
252b5132
RH
844@item -
845The symbol is a stabs symbol in an a.out object file. In this case, the
846next values printed are the stabs other field, the stabs desc field, and
c7c55b78
NC
847the stab type. Stabs symbols are used to hold debugging information.
848@ifclear man
849For more information, see @ref{Top,Stabs,Stabs Overview,stabs.info, The
252b5132 850``stabs'' debug format}.
c7c55b78 851@end ifclear
252b5132
RH
852
853@item ?
854The symbol type is unknown, or object file format specific.
855@end table
856
857@item
858The symbol name.
859@end itemize
860
0285c67d
NC
861@c man end
862
863@c man begin OPTIONS nm
252b5132
RH
864The long and short forms of options, shown here as alternatives, are
865equivalent.
866
c7c55b78 867@table @env
252b5132
RH
868@item -A
869@itemx -o
c1c0eb9e 870@itemx --print-file-name
252b5132
RH
871@cindex input file name
872@cindex file name
873@cindex source file name
f20a759a 874Precede each symbol by the name of the input file (or archive member)
252b5132
RH
875in which it was found, rather than identifying the input file once only,
876before all of its symbols.
877
878@item -a
c1c0eb9e 879@itemx --debug-syms
252b5132
RH
880@cindex debugging symbols
881Display all symbols, even debugger-only symbols; normally these are not
882listed.
883
884@item -B
c7c55b78
NC
885@cindex @command{nm} format
886@cindex @command{nm} compatibility
887The same as @option{--format=bsd} (for compatibility with the MIPS @command{nm}).
252b5132
RH
888
889@item -C
28c309a2 890@itemx --demangle[=@var{style}]
252b5132
RH
891@cindex demangling in nm
892Decode (@dfn{demangle}) low-level symbol names into user-level names.
893Besides removing any initial underscore prepended by the system, this
28c309a2 894makes C++ function names readable. Different compilers have different
c1c0eb9e
RM
895mangling styles. The optional demangling style argument can be used to
896choose an appropriate demangling style for your compiler. @xref{c++filt},
28c309a2 897for more information on demangling.
252b5132
RH
898
899@item --no-demangle
900Do not demangle low-level symbol names. This is the default.
901
902@item -D
903@itemx --dynamic
904@cindex dynamic symbols
905Display the dynamic symbols rather than the normal symbols. This is
906only meaningful for dynamic objects, such as certain types of shared
907libraries.
908
909@item -f @var{format}
910@itemx --format=@var{format}
c7c55b78
NC
911@cindex @command{nm} format
912@cindex @command{nm} compatibility
252b5132
RH
913Use the output format @var{format}, which can be @code{bsd},
914@code{sysv}, or @code{posix}. The default is @code{bsd}.
915Only the first character of @var{format} is significant; it can be
916either upper or lower case.
917
918@item -g
c1c0eb9e 919@itemx --extern-only
252b5132
RH
920@cindex external symbols
921Display only external symbols.
922
ce3c775b
NC
923@item --plugin @var{name}
924@cindex load plugin
925Load the plugin called @var{name} to add support for extra target
926types. This option is only available if the toolchain has been built
927with plugin support enabled.
928
252b5132
RH
929@item -l
930@itemx --line-numbers
931@cindex symbol line numbers
932For each symbol, use debugging information to try to find a filename and
933line number. For a defined symbol, look for the line number of the
934address of the symbol. For an undefined symbol, look for the line
935number of a relocation entry which refers to the symbol. If line number
936information can be found, print it after the other symbol information.
937
938@item -n
939@itemx -v
c1c0eb9e 940@itemx --numeric-sort
252b5132 941Sort symbols numerically by their addresses, rather than alphabetically
c1c0eb9e 942by their names.
252b5132
RH
943
944@item -p
c1c0eb9e 945@itemx --no-sort
252b5132
RH
946@cindex sorting symbols
947Do not bother to sort the symbols in any order; print them in the order
948encountered.
949
950@item -P
951@itemx --portability
952Use the POSIX.2 standard output format instead of the default format.
953Equivalent to @samp{-f posix}.
954
72797995
L
955@item -S
956@itemx --print-size
1533edfb
AM
957Print both value and size of defined symbols for the @code{bsd} output style.
958This option has no effect for object formats that do not record symbol
959sizes, unless @samp{--size-sort} is also used in which case a
960calculated size is displayed.
72797995 961
252b5132
RH
962@item -s
963@itemx --print-armap
964@cindex symbol index, listing
965When listing symbols from archive members, include the index: a mapping
c7c55b78 966(stored in the archive by @command{ar} or @command{ranlib}) of which modules
252b5132
RH
967contain definitions for which names.
968
969@item -r
c1c0eb9e 970@itemx --reverse-sort
252b5132
RH
971Reverse the order of the sort (whether numeric or alphabetic); let the
972last come first.
973
974@item --size-sort
975Sort symbols by size. The size is computed as the difference between
976the value of the symbol and the value of the symbol with the next higher
c1c0eb9e
RM
977value. If the @code{bsd} output format is used the size of the symbol
978is printed, rather than the value, and @samp{-S} must be used in order
76ed1927 979both size and value to be printed.
252b5132 980
3c9458e9
NC
981@item --special-syms
982Display symbols which have a target-specific special meaning. These
983symbols are usually used by the target for some special processing and
984are not normally helpful when included included in the normal symbol
985lists. For example for ARM targets this option would skip the mapping
b45619c0 986symbols used to mark transitions between ARM code, THUMB code and
3c9458e9
NC
987data.
988
252b5132
RH
989@item -t @var{radix}
990@itemx --radix=@var{radix}
991Use @var{radix} as the radix for printing the symbol values. It must be
992@samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
993
994@item --target=@var{bfdname}
995@cindex object code format
996Specify an object code format other than your system's default format.
997@xref{Target Selection}, for more information.
998
999@item -u
c1c0eb9e 1000@itemx --undefined-only
252b5132
RH
1001@cindex external symbols
1002@cindex undefined symbols
1003Display only undefined symbols (those external to each object file).
1004
1005@item --defined-only
1006@cindex external symbols
1007@cindex undefined symbols
1008Display only defined symbols for each object file.
1009
1010@item -V
1011@itemx --version
c7c55b78 1012Show the version number of @command{nm} and exit.
252b5132 1013
6e800839
GK
1014@item -X
1015This option is ignored for compatibility with the AIX version of
c7c55b78
NC
1016@command{nm}. It takes one parameter which must be the string
1017@option{32_64}. The default mode of AIX @command{nm} corresponds
1018to @option{-X 32}, which is not supported by @sc{gnu} @command{nm}.
6e800839 1019
252b5132 1020@item --help
c7c55b78 1021Show a summary of the options to @command{nm} and exit.
252b5132
RH
1022@end table
1023
0285c67d
NC
1024@c man end
1025
1026@ignore
1027@c man begin SEEALSO nm
1028ar(1), objdump(1), ranlib(1), and the Info entries for @file{binutils}.
1029@c man end
1030@end ignore
1031
252b5132
RH
1032@node objcopy
1033@chapter objcopy
1034
0285c67d
NC
1035@c man title objcopy copy and translate object files
1036
252b5132 1037@smallexample
0285c67d 1038@c man begin SYNOPSIS objcopy
c7c55b78
NC
1039objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
1040 [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}]
1041 [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}]
1042 [@option{-B} @var{bfdarch}|@option{--binary-architecture=}@var{bfdarch}]
2593f09a
NC
1043 [@option{-S}|@option{--strip-all}]
1044 [@option{-g}|@option{--strip-debug}]
c7c55b78
NC
1045 [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}]
1046 [@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}]
bcf32829 1047 [@option{--strip-unneeded-symbol=}@var{symbolname}]
c7c55b78 1048 [@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}]
d58c2e3a 1049 [@option{--localize-hidden}]
c7c55b78 1050 [@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}]
7b4a0685 1051 [@option{--globalize-symbol=}@var{symbolname}]
c7c55b78 1052 [@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
5fe11841 1053 [@option{-w}|@option{--wildcard}]
2593f09a
NC
1054 [@option{-x}|@option{--discard-all}]
1055 [@option{-X}|@option{--discard-locals}]
c7c55b78 1056 [@option{-b} @var{byte}|@option{--byte=}@var{byte}]
b7dd81f7
NC
1057 [@option{-i} [@var{breadth}]|@option{--interleave}[=@var{breadth}]]
1058 [@option{--interleave-width=}@var{width}]
c7c55b78
NC
1059 [@option{-j} @var{sectionname}|@option{--only-section=}@var{sectionname}]
1060 [@option{-R} @var{sectionname}|@option{--remove-section=}@var{sectionname}]
1061 [@option{-p}|@option{--preserve-dates}]
2e30cb57 1062 [@option{-D}|@option{--enable-deterministic-archives}]
c7c55b78 1063 [@option{--debugging}]
2593f09a
NC
1064 [@option{--gap-fill=}@var{val}]
1065 [@option{--pad-to=}@var{address}]
1066 [@option{--set-start=}@var{val}]
1067 [@option{--adjust-start=}@var{incr}]
c7c55b78
NC
1068 [@option{--change-addresses=}@var{incr}]
1069 [@option{--change-section-address} @var{section}@{=,+,-@}@var{val}]
1070 [@option{--change-section-lma} @var{section}@{=,+,-@}@var{val}]
1071 [@option{--change-section-vma} @var{section}@{=,+,-@}@var{val}]
1072 [@option{--change-warnings}] [@option{--no-change-warnings}]
1073 [@option{--set-section-flags} @var{section}=@var{flags}]
1074 [@option{--add-section} @var{sectionname}=@var{filename}]
1075 [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]]
0408dee6 1076 [@option{--long-section-names} @{enable,disable,keep@}]
2593f09a 1077 [@option{--change-leading-char}] [@option{--remove-leading-char}]
9e48b4c6 1078 [@option{--reverse-bytes=}@var{num}]
2593f09a
NC
1079 [@option{--srec-len=}@var{ival}] [@option{--srec-forceS3}]
1080 [@option{--redefine-sym} @var{old}=@var{new}]
1081 [@option{--redefine-syms=}@var{filename}]
c7c55b78
NC
1082 [@option{--weaken}]
1083 [@option{--keep-symbols=}@var{filename}]
1084 [@option{--strip-symbols=}@var{filename}]
bcf32829 1085 [@option{--strip-unneeded-symbols=}@var{filename}]
c7c55b78
NC
1086 [@option{--keep-global-symbols=}@var{filename}]
1087 [@option{--localize-symbols=}@var{filename}]
7b4a0685 1088 [@option{--globalize-symbols=}@var{filename}]
c7c55b78 1089 [@option{--weaken-symbols=}@var{filename}]
c51238bc
DA
1090 [@option{--alt-machine-code=}@var{index}]
1091 [@option{--prefix-symbols=}@var{string}]
1092 [@option{--prefix-sections=}@var{string}]
1093 [@option{--prefix-alloc-sections=}@var{string}]
ed1653a7 1094 [@option{--add-gnu-debuglink=}@var{path-to-file}]
1637cd90 1095 [@option{--keep-file-symbols}]
ed1653a7 1096 [@option{--only-keep-debug}]
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
TT
2200Note: the output from the @option{=info} option can also be affected
2201by the options @option{--dwarf-depth} and @option{--dwarf-start}.
2202
2203@item --dwarf-depth=@var{n}
2204Limit the dump of the @code{.debug_info} section to @var{n} children.
2205This is only useful with @option{--dwarf=info}. The default is
2206to print all DIEs; the special value 0 for @var{n} will also have this
2207effect.
2208
2209With a non-zero value for @var{n}, DIEs at or deeper than @var{n}
2210levels will not be printed. The range for @var{n} is zero-based.
2211
2212@item --dwarf-start=@var{n}
2213Print only DIEs beginning with the DIE numbered @var{n}. This is only
2214useful with @option{--dwarf=info}.
2215
2216If specified, this option will suppress printing of any header
2217information and all DIEs before the DIE numbered @var{n}. Only
2218siblings and children of the specified DIE will be printed.
2219
2220This can be used in conjunction with @option{--dwarf-depth}.
2221
1dada9c5 2222@item -G
947ed062 2223@itemx --stabs
252b5132
RH
2224@cindex stab
2225@cindex .stab
2226@cindex debug symbols
2227@cindex ELF object file format
2228Display the full contents of any sections requested. Display the
2229contents of the .stab and .stab.index and .stab.excl sections from an
2230ELF file. This is only useful on systems (such as Solaris 2.0) in which
2231@code{.stab} debugging symbol-table entries are carried in an ELF
2232section. In most other file formats, debugging symbol-table entries are
c7c55b78 2233interleaved with linkage symbols, and are visible in the @option{--syms}
0285c67d
NC
2234output.
2235@ifclear man
2236For more information on stabs symbols, see @ref{Top,Stabs,Stabs
252b5132 2237Overview,stabs.info, The ``stabs'' debug format}.
0285c67d 2238@end ifclear
252b5132
RH
2239
2240@item --start-address=@var{address}
2241@cindex start-address
2242Start displaying data at the specified address. This affects the output
c7c55b78 2243of the @option{-d}, @option{-r} and @option{-s} options.
252b5132
RH
2244
2245@item --stop-address=@var{address}
2246@cindex stop-address
2247Stop displaying data at the specified address. This affects the output
c7c55b78 2248of the @option{-d}, @option{-r} and @option{-s} options.
252b5132
RH
2249
2250@item -t
2251@itemx --syms
2252@cindex symbol table entries, printing
2253Print the symbol table entries of the file.
a1039809
NC
2254This is similar to the information provided by the @samp{nm} program,
2255although the display format is different. The format of the output
2256depends upon the format of the file being dumped, but there are two main
2257types. One looks like this:
2258
2259@smallexample
2260[ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss
2261[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred
2262@end smallexample
2263
2264where the number inside the square brackets is the number of the entry
2265in the symbol table, the @var{sec} number is the section number, the
2266@var{fl} value are the symbol's flag bits, the @var{ty} number is the
2267symbol's type, the @var{scl} number is the symbol's storage class and
2268the @var{nx} value is the number of auxilary entries associated with
2269the symbol. The last two fields are the symbol's value and its name.
2270
2271The other common output format, usually seen with ELF based files,
2272looks like this:
2273
2274@smallexample
227500000000 l d .bss 00000000 .bss
227600000000 g .text 00000000 fred
2277@end smallexample
2278
2279Here the first number is the symbol's value (sometimes refered to as
2280its address). The next field is actually a set of characters and
2281spaces indicating the flag bits that are set on the symbol. These
af3e16d9
NC
2282characters are described below. Next is the section with which the
2283symbol is associated or @emph{*ABS*} if the section is absolute (ie
2284not connected with any section), or @emph{*UND*} if the section is
2285referenced in the file being dumped, but not defined there.
2286
2287After the section name comes another field, a number, which for common
2288symbols is the alignment and for other symbol is the size. Finally
2289the symbol's name is displayed.
a1039809
NC
2290
2291The flag characters are divided into 7 groups as follows:
2292@table @code
2293@item l
2294@itemx g
3e7a7d11 2295@itemx u
a1039809 2296@itemx !
3e7a7d11
NC
2297The symbol is a local (l), global (g), unique global (u), neither
2298global nor local (a space) or both global and local (!). A
928a4139 2299symbol can be neither local or global for a variety of reasons, e.g.,
a1039809 2300because it is used for debugging, but it is probably an indication of
3e7a7d11
NC
2301a bug if it is ever both local and global. Unique global symbols are
2302a GNU extension to the standard set of ELF symbol bindings. For such
2303a symbol the dynamic linker will make sure that in the entire process
2304there is just one symbol with this name and type in use.
a1039809
NC
2305
2306@item w
2307The symbol is weak (w) or strong (a space).
2308
2309@item C
2310The symbol denotes a constructor (C) or an ordinary symbol (a space).
2311
2312@item W
2313The symbol is a warning (W) or a normal symbol (a space). A warning
2314symbol's name is a message to be displayed if the symbol following the
2315warning symbol is ever referenced.
2316
2317@item I
171191ba
NC
2318@item i
2319The symbol is an indirect reference to another symbol (I), a function
2320to be evaluated during reloc processing (i) or a normal symbol (a
2321space).
a1039809
NC
2322
2323@item d
2324@itemx D
2325The symbol is a debugging symbol (d) or a dynamic symbol (D) or a
2326normal symbol (a space).
2327
2328@item F
2329@item f
2330@item O
af3e16d9 2331The symbol is the name of a function (F) or a file (f) or an object
a1039809
NC
2332(O) or just a normal symbol (a space).
2333@end table
252b5132
RH
2334
2335@item -T
2336@itemx --dynamic-syms
2337@cindex dynamic symbol table entries, printing
2338Print the dynamic symbol table entries of the file. This is only
2339meaningful for dynamic objects, such as certain types of shared
2340libraries. This is similar to the information provided by the @samp{nm}
c7c55b78 2341program when given the @option{-D} (@option{--dynamic}) option.
252b5132 2342
3c9458e9
NC
2343@item --special-syms
2344When displaying symbols include those which the target considers to be
2345special in some way and which would not normally be of interest to the
2346user.
2347
947ed062
NC
2348@item -V
2349@itemx --version
c7c55b78 2350Print the version number of @command{objdump} and exit.
252b5132
RH
2351
2352@item -x
947ed062 2353@itemx --all-headers
252b5132
RH
2354@cindex all header information, object file
2355@cindex header information, all
2356Display all available header information, including the symbol table and
c7c55b78 2357relocation entries. Using @option{-x} is equivalent to specifying all of
04c34128 2358@option{-a -f -h -p -r -t}.
252b5132
RH
2359
2360@item -w
2361@itemx --wide
2362@cindex wide output, printing
2363Format some lines for output devices that have more than 80 columns.
31104126 2364Also do not truncate symbol names when they are displayed.
aefbdd67
BE
2365
2366@item -z
2c0c15f9 2367@itemx --disassemble-zeroes
aefbdd67
BE
2368Normally the disassembly output will skip blocks of zeroes. This
2369option directs the disassembler to disassemble those blocks, just like
2370any other data.
252b5132
RH
2371@end table
2372
0285c67d
NC
2373@c man end
2374
2375@ignore
2376@c man begin SEEALSO objdump
2377nm(1), readelf(1), and the Info entries for @file{binutils}.
2378@c man end
2379@end ignore
2380
252b5132
RH
2381@node ranlib
2382@chapter ranlib
2383
2384@kindex ranlib
2385@cindex archive contents
2386@cindex symbol index
2387
0285c67d
NC
2388@c man title ranlib generate index to archive.
2389
252b5132 2390@smallexample
0285c67d 2391@c man begin SYNOPSIS ranlib
36e32b27 2392ranlib [@option{--plugin} @var{name}] [@option{-DhHvVt}] @var{archive}
0285c67d 2393@c man end
252b5132
RH
2394@end smallexample
2395
0285c67d
NC
2396@c man begin DESCRIPTION ranlib
2397
c7c55b78 2398@command{ranlib} generates an index to the contents of an archive and
252b5132 2399stores it in the archive. The index lists each symbol defined by a
c1c0eb9e 2400member of an archive that is a relocatable object file.
252b5132
RH
2401
2402You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
2403
2404An archive with such an index speeds up linking to the library and
2405allows routines in the library to call each other without regard to
2406their placement in the archive.
2407
c7c55b78
NC
2408The @sc{gnu} @command{ranlib} program is another form of @sc{gnu} @command{ar}; running
2409@command{ranlib} is completely equivalent to executing @samp{ar -s}.
252b5132
RH
2410@xref{ar}.
2411
0285c67d
NC
2412@c man end
2413
2414@c man begin OPTIONS ranlib
2415
c7c55b78 2416@table @env
b3364cb9
RM
2417@item -h
2418@itemx -H
2419@itemx --help
2420Show usage information for @command{ranlib}.
2421
252b5132
RH
2422@item -v
2423@itemx -V
f20a759a 2424@itemx --version
c7c55b78 2425Show the version number of @command{ranlib}.
b14f9da0 2426
b3364cb9
RM
2427@item -D
2428@cindex deterministic archives
9cb80f72 2429@kindex --enable-deterministic-archives
b3364cb9
RM
2430Operate in @emph{deterministic} mode. The symbol map archive member's
2431header will show zero for the UID, GID, and timestamp. When this
2432option is used, multiple runs will produce identical output files.
2433
9cb80f72
RM
2434This is the default unless @file{binutils} was configured with
2435@option{--enable-deterministic-archives}.
2436
b14f9da0
NC
2437@item -t
2438Update the timestamp of the symbol map of an archive.
9cb80f72
RM
2439
2440@item -U
2441@cindex deterministic archives
2442@kindex --enable-deterministic-archives
2443Do @emph{not} operate in @emph{deterministic} mode. This is the
2444inverse of the @samp{-D} option, above: the archive index will get
2445actual UID, GID, timestamp, and file mode values.
2446
2447This is the default unless @file{binutils} was configured with
2448@option{--enable-deterministic-archives}.
252b5132
RH
2449@end table
2450
0285c67d
NC
2451@c man end
2452
2453@ignore
2454@c man begin SEEALSO ranlib
2455ar(1), nm(1), and the Info entries for @file{binutils}.
2456@c man end
2457@end ignore
2458
252b5132
RH
2459@node size
2460@chapter size
2461
2462@kindex size
2463@cindex section sizes
2464
0285c67d
NC
2465@c man title size list section sizes and total size.
2466
252b5132 2467@smallexample
0285c67d 2468@c man begin SYNOPSIS size
c7c55b78 2469size [@option{-A}|@option{-B}|@option{--format=}@var{compatibility}]
15c82623
NC
2470 [@option{--help}]
2471 [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}]
29422971 2472 [@option{--common}]
15c82623 2473 [@option{-t}|@option{--totals}]
c1c0eb9e 2474 [@option{--target=}@var{bfdname}] [@option{-V}|@option{--version}]
c7c55b78 2475 [@var{objfile}@dots{}]
0285c67d 2476@c man end
252b5132
RH
2477@end smallexample
2478
0285c67d
NC
2479@c man begin DESCRIPTION size
2480
c7c55b78 2481The @sc{gnu} @command{size} utility lists the section sizes---and the total
252b5132
RH
2482size---for each of the object or archive files @var{objfile} in its
2483argument list. By default, one line of output is generated for each
2484object file or each module in an archive.
2485
2486@var{objfile}@dots{} are the object files to be examined.
2487If none are specified, the file @code{a.out} will be used.
2488
0285c67d
NC
2489@c man end
2490
2491@c man begin OPTIONS size
2492
252b5132
RH
2493The command line options have the following meanings:
2494
c7c55b78 2495@table @env
252b5132
RH
2496@item -A
2497@itemx -B
2498@itemx --format=@var{compatibility}
c7c55b78 2499@cindex @command{size} display format
252b5132 2500Using one of these options, you can choose whether the output from @sc{gnu}
c7c55b78
NC
2501@command{size} resembles output from System V @command{size} (using @option{-A},
2502or @option{--format=sysv}), or Berkeley @command{size} (using @option{-B}, or
2503@option{--format=berkeley}). The default is the one-line format similar to
c1c0eb9e 2504Berkeley's.
252b5132
RH
2505@c Bonus for doc-source readers: you can also say --format=strange (or
2506@c anything else that starts with 's') for sysv, and --format=boring (or
2507@c anything else that starts with 'b') for Berkeley.
2508
2509Here is an example of the Berkeley (default) format of output from
c1c0eb9e 2510@command{size}:
252b5132 2511@smallexample
f20a759a 2512$ size --format=Berkeley ranlib size
252b5132
RH
2513text data bss dec hex filename
2514294880 81920 11592 388392 5ed28 ranlib
2515294880 81920 11888 388688 5ee50 size
2516@end smallexample
2517
2518@noindent
2519This is the same data, but displayed closer to System V conventions:
2520
2521@smallexample
f20a759a 2522$ size --format=SysV ranlib size
252b5132
RH
2523ranlib :
2524section size addr
c1c0eb9e
RM
2525.text 294880 8192
2526.data 81920 303104
2527.bss 11592 385024
2528Total 388392
252b5132
RH
2529
2530
2531size :
2532section size addr
c1c0eb9e
RM
2533.text 294880 8192
2534.data 81920 303104
2535.bss 11888 385024
2536Total 388688
252b5132
RH
2537@end smallexample
2538
2539@item --help
2540Show a summary of acceptable arguments and options.
2541
2542@item -d
2543@itemx -o
2544@itemx -x
2545@itemx --radix=@var{number}
c7c55b78 2546@cindex @command{size} number format
252b5132
RH
2547@cindex radix for section sizes
2548Using one of these options, you can control whether the size of each
c7c55b78
NC
2549section is given in decimal (@option{-d}, or @option{--radix=10}); octal
2550(@option{-o}, or @option{--radix=8}); or hexadecimal (@option{-x}, or
2551@option{--radix=16}). In @option{--radix=@var{number}}, only the three
252b5132 2552values (8, 10, 16) are supported. The total size is always given in two
c7c55b78
NC
2553radices; decimal and hexadecimal for @option{-d} or @option{-x} output, or
2554octal and hexadecimal if you're using @option{-o}.
252b5132 2555
29422971
AM
2556@item --common
2557Print total size of common symbols in each file. When using Berkeley
2558format these are included in the bss size.
2559
15c82623
NC
2560@item -t
2561@itemx --totals
2562Show totals of all objects listed (Berkeley format listing mode only).
2563
252b5132
RH
2564@item --target=@var{bfdname}
2565@cindex object code format
2566Specify that the object-code format for @var{objfile} is
c7c55b78 2567@var{bfdname}. This option may not be necessary; @command{size} can
252b5132
RH
2568automatically recognize many formats.
2569@xref{Target Selection}, for more information.
2570
2571@item -V
2572@itemx --version
c7c55b78 2573Display the version number of @command{size}.
252b5132
RH
2574@end table
2575
0285c67d
NC
2576@c man end
2577
2578@ignore
2579@c man begin SEEALSO size
2580ar(1), objdump(1), readelf(1), and the Info entries for @file{binutils}.
2581@c man end
2582@end ignore
2583
252b5132
RH
2584@node strings
2585@chapter strings
2586@kindex strings
2587@cindex listings strings
2588@cindex printing strings
2589@cindex strings, printing
2590
0285c67d
NC
2591@c man title strings print the strings of printable characters in files.
2592
252b5132 2593@smallexample
0285c67d 2594@c man begin SYNOPSIS strings
ffbe5983 2595strings [@option{-afovV}] [@option{-}@var{min-len}]
d132876a
NC
2596 [@option{-n} @var{min-len}] [@option{--bytes=}@var{min-len}]
2597 [@option{-t} @var{radix}] [@option{--radix=}@var{radix}]
2598 [@option{-e} @var{encoding}] [@option{--encoding=}@var{encoding}]
2599 [@option{-}] [@option{--all}] [@option{--print-file-name}]
3bf31ec9 2600 [@option{-T} @var{bfdname}] [@option{--target=}@var{bfdname}]
c7c55b78 2601 [@option{--help}] [@option{--version}] @var{file}@dots{}
0285c67d 2602@c man end
252b5132
RH
2603@end smallexample
2604
0285c67d
NC
2605@c man begin DESCRIPTION strings
2606
c7c55b78 2607For each @var{file} given, @sc{gnu} @command{strings} prints the printable
252b5132
RH
2608character sequences that are at least 4 characters long (or the number
2609given with the options below) and are followed by an unprintable
2610character. By default, it only prints the strings from the initialized
2611and loaded sections of object files; for other types of files, it prints
2612the strings from the whole file.
2613
c7c55b78 2614@command{strings} is mainly useful for determining the contents of non-text
252b5132
RH
2615files.
2616
0285c67d
NC
2617@c man end
2618
2619@c man begin OPTIONS strings
2620
c7c55b78 2621@table @env
252b5132
RH
2622@item -a
2623@itemx --all
2624@itemx -
2625Do not scan only the initialized and loaded sections of object files;
2626scan the whole files.
2627
2628@item -f
2629@itemx --print-file-name
2630Print the name of the file before each string.
2631
2632@item --help
2633Print a summary of the program usage on the standard output and exit.
2634
2635@item -@var{min-len}
2636@itemx -n @var{min-len}
2637@itemx --bytes=@var{min-len}
2638Print sequences of characters that are at least @var{min-len} characters
2639long, instead of the default 4.
2640
2641@item -o
c7c55b78 2642Like @samp{-t o}. Some other versions of @command{strings} have @option{-o}
252b5132
RH
2643act like @samp{-t d} instead. Since we can not be compatible with both
2644ways, we simply chose one.
2645
2646@item -t @var{radix}
2647@itemx --radix=@var{radix}
2648Print the offset within the file before each string. The single
2649character argument specifies the radix of the offset---@samp{o} for
2650octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
2651
d132876a
NC
2652@item -e @var{encoding}
2653@itemx --encoding=@var{encoding}
2654Select the character encoding of the strings that are to be found.
8745eafa
NC
2655Possible values for @var{encoding} are: @samp{s} = single-7-bit-byte
2656characters (ASCII, ISO 8859, etc., default), @samp{S} =
2657single-8-bit-byte characters, @samp{b} = 16-bit bigendian, @samp{l} =
265816-bit littleendian, @samp{B} = 32-bit bigendian, @samp{L} = 32-bit
830bf75c
NC
2659littleendian. Useful for finding wide character strings. (@samp{l}
2660and @samp{b} apply to, for example, Unicode UTF-16/UCS-2 encodings).
d132876a 2661
3bf31ec9
NC
2662@item -T @var{bfdname}
2663@itemx --target=@var{bfdname}
252b5132
RH
2664@cindex object code format
2665Specify an object code format other than your system's default format.
2666@xref{Target Selection}, for more information.
2667
2668@item -v
ffbe5983 2669@itemx -V
252b5132
RH
2670@itemx --version
2671Print the program version number on the standard output and exit.
2672@end table
2673
0285c67d
NC
2674@c man end
2675
2676@ignore
2677@c man begin SEEALSO strings
2678ar(1), nm(1), objdump(1), ranlib(1), readelf(1)
2679and the Info entries for @file{binutils}.
2680@c man end
2681@end ignore
2682
252b5132
RH
2683@node strip
2684@chapter strip
2685
2686@kindex strip
2687@cindex removing symbols
2688@cindex discarding symbols
2689@cindex symbols, discarding
2690
0285c67d
NC
2691@c man title strip Discard symbols from object files.
2692
252b5132 2693@smallexample
0285c67d 2694@c man begin SYNOPSIS strip
2593f09a
NC
2695strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}]
2696 [@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname}]
2697 [@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}]
2698 [@option{-s}|@option{--strip-all}]
2699 [@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}]
96109726 2700 [@option{--strip-dwo}]
2593f09a
NC
2701 [@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname}]
2702 [@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}]
5fe11841 2703 [@option{-w}|@option{--wildcard}]
2593f09a
NC
2704 [@option{-x}|@option{--discard-all}] [@option{-X} |@option{--discard-locals}]
2705 [@option{-R} @var{sectionname} |@option{--remove-section=}@var{sectionname}]
2706 [@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}]
2e30cb57 2707 [@option{-D}|@option{--enable-deterministic-archives}]
1637cd90 2708 [@option{--keep-file-symbols}]
ed1653a7 2709 [@option{--only-keep-debug}]
7c29036b
NC
2710 [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}]
2711 [@option{--help}] [@option{--info}]
252b5132 2712 @var{objfile}@dots{}
0285c67d 2713@c man end
252b5132
RH
2714@end smallexample
2715
0285c67d
NC
2716@c man begin DESCRIPTION strip
2717
c7c55b78 2718@sc{gnu} @command{strip} discards all symbols from object files
252b5132
RH
2719@var{objfile}. The list of object files may include archives.
2720At least one object file must be given.
2721
c7c55b78 2722@command{strip} modifies the files named in its argument,
252b5132
RH
2723rather than writing modified copies under different names.
2724
0285c67d
NC
2725@c man end
2726
2727@c man begin OPTIONS strip
2728
c7c55b78 2729@table @env
252b5132
RH
2730@item -F @var{bfdname}
2731@itemx --target=@var{bfdname}
2732Treat the original @var{objfile} as a file with the object
2733code format @var{bfdname}, and rewrite it in the same format.
2734@xref{Target Selection}, for more information.
2735
2736@item --help
c7c55b78 2737Show a summary of the options to @command{strip} and exit.
252b5132 2738
7c29036b
NC
2739@item --info
2740Display a list showing all architectures and object formats available.
2741
947ed062 2742@item -I @var{bfdname}
252b5132
RH
2743@itemx --input-target=@var{bfdname}
2744Treat the original @var{objfile} as a file with the object
2745code format @var{bfdname}.
2746@xref{Target Selection}, for more information.
2747
2748@item -O @var{bfdname}
2749@itemx --output-target=@var{bfdname}
2750Replace @var{objfile} with a file in the output format @var{bfdname}.
2751@xref{Target Selection}, for more information.
2752
2753@item -R @var{sectionname}
2754@itemx --remove-section=@var{sectionname}
2755Remove any section named @var{sectionname} from the output file. This
2756option may be given more than once. Note that using this option
2757inappropriately may make the output file unusable.
2758
2759@item -s
2760@itemx --strip-all
2761Remove all symbols.
2762
2763@item -g
2764@itemx -S
15c82623 2765@itemx -d
252b5132
RH
2766@itemx --strip-debug
2767Remove debugging symbols only.
96109726
CC
2768
2769@item --strip-dwo
2770Remove the contents of all DWARF .dwo sections, leaving the
2771remaining debugging sections and all symbols intact.
2772See the description of this option in the @command{objcopy} section
2773for more information.
252b5132
RH
2774
2775@item --strip-unneeded
2776Remove all symbols that are not needed for relocation processing.
2777
2778@item -K @var{symbolname}
2779@itemx --keep-symbol=@var{symbolname}
e7f918ad
NC
2780When stripping symbols, keep symbol @var{symbolname} even if it would
2781normally be stripped. This option may be given more than once.
252b5132
RH
2782
2783@item -N @var{symbolname}
2784@itemx --strip-symbol=@var{symbolname}
2785Remove symbol @var{symbolname} from the source file. This option may be
2786given more than once, and may be combined with strip options other than
c7c55b78 2787@option{-K}.
252b5132
RH
2788
2789@item -o @var{file}
2790Put the stripped output in @var{file}, rather than replacing the
2791existing file. When this argument is used, only one @var{objfile}
2792argument may be specified.
2793
2794@item -p
2795@itemx --preserve-dates
2796Preserve the access and modification dates of the file.
2797
2e30cb57
CC
2798@item -D
2799@itemx --enable-deterministic-archives
2800Operate in @emph{deterministic} mode. When copying archive members
2801and writing the archive index, use zero for UIDs, GIDs, timestamps,
2802and use consistent file modes for all files.
2803
5fe11841
NC
2804@item -w
2805@itemx --wildcard
2806Permit regular expressions in @var{symbolname}s used in other command
2807line options. The question mark (?), asterisk (*), backslash (\) and
2808square brackets ([]) operators can be used anywhere in the symbol
2809name. If the first character of the symbol name is the exclamation
2810point (!) then the sense of the switch is reversed for that symbol.
2811For example:
2812
2813@smallexample
2814 -w -K !foo -K fo*
2815@end smallexample
2816
2817would cause strip to only keep symbols that start with the letters
2818``fo'', but to discard the symbol ``foo''.
2819
252b5132
RH
2820@item -x
2821@itemx --discard-all
2822Remove non-global symbols.
2823
2824@item -X
2825@itemx --discard-locals
2826Remove compiler-generated local symbols.
2827(These usually start with @samp{L} or @samp{.}.)
2828
1637cd90
JB
2829@item --keep-file-symbols
2830When stripping a file, perhaps with @option{--strip-debug} or
2831@option{--strip-unneeded}, retain any symbols specifying source file names,
2832which would otherwise get stripped.
2833
ed1653a7 2834@item --only-keep-debug
c1c0eb9e
RM
2835Strip a file, removing contents of any sections that would not be
2836stripped by @option{--strip-debug} and leaving the debugging sections
2837intact. In ELF files, this preserves all note sections in the output.
ed1653a7
NC
2838
2839The intention is that this option will be used in conjunction with
2840@option{--add-gnu-debuglink} to create a two part executable. One a
2841stripped binary which will occupy less space in RAM and in a
2842distribution and the second a debugging information file which is only
2843needed if debugging abilities are required. The suggested procedure
2844to create these files is as follows:
2845
2846@enumerate
2847@item Link the executable as normal. Assuming that is is called
2848@code{foo} then...
2849@item Run @code{objcopy --only-keep-debug foo foo.dbg} to
2850create a file containing the debugging info.
2851@item Run @code{objcopy --strip-debug foo} to create a
2852stripped executable.
2853@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo}
2854to add a link to the debugging info into the stripped executable.
2855@end enumerate
2856
928a4139 2857Note---the choice of @code{.dbg} as an extension for the debug info
ed1653a7
NC
2858file is arbitrary. Also the @code{--only-keep-debug} step is
2859optional. You could instead do this:
2860
2861@enumerate
2862@item Link the executable as normal.
928a4139 2863@item Copy @code{foo} to @code{foo.full}
ed1653a7
NC
2864@item Run @code{strip --strip-debug foo}
2865@item Run @code{objcopy --add-gnu-debuglink=foo.full foo}
2866@end enumerate
2867
928a4139 2868i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the
ed1653a7
NC
2869full executable. It does not have to be a file created by the
2870@option{--only-keep-debug} switch.
2871
928a4139 2872Note---this switch is only intended for use on fully linked files. It
91bb255c
NC
2873does not make sense to use it on object files where the debugging
2874information may be incomplete. Besides the gnu_debuglink feature
2875currently only supports the presence of one filename containing
2876debugging information, not multiple filenames on a one-per-object-file
2877basis.
2878
252b5132
RH
2879@item -V
2880@itemx --version
c7c55b78 2881Show the version number for @command{strip}.
252b5132
RH
2882
2883@item -v
2884@itemx --verbose
2885Verbose output: list all object files modified. In the case of
2886archives, @samp{strip -v} lists all members of the archive.
2887@end table
2888
0285c67d
NC
2889@c man end
2890
2891@ignore
2892@c man begin SEEALSO strip
2893the Info entries for @file{binutils}.
2894@c man end
2895@end ignore
2896
30fd33bb 2897@node c++filt, addr2line, elfedit, Top
252b5132
RH
2898@chapter c++filt
2899
2900@kindex c++filt
2901@cindex demangling C++ symbols
2902
0285c67d
NC
2903@c man title cxxfilt Demangle C++ and Java symbols.
2904
252b5132 2905@smallexample
0285c67d 2906@c man begin SYNOPSIS cxxfilt
ae9ab7c0
NC
2907c++filt [@option{-_}|@option{--strip-underscore}]
2908 [@option{-n}|@option{--no-strip-underscore}]
4e48c9dd 2909 [@option{-p}|@option{--no-params}]
ec948987 2910 [@option{-t}|@option{--types}]
cbf1f5df 2911 [@option{-i}|@option{--no-verbose}]
c7c55b78
NC
2912 [@option{-s} @var{format}|@option{--format=}@var{format}]
2913 [@option{--help}] [@option{--version}] [@var{symbol}@dots{}]
0285c67d 2914@c man end
252b5132
RH
2915@end smallexample
2916
0285c67d
NC
2917@c man begin DESCRIPTION cxxfilt
2918
9d51cc66 2919@kindex cxxfilt
ec948987
NC
2920The C++ and Java languages provide function overloading, which means
2921that you can write many functions with the same name, providing that
2922each function takes parameters of different types. In order to be
2923able to distinguish these similarly named functions C++ and Java
2924encode them into a low-level assembler name which uniquely identifies
2925each different version. This process is known as @dfn{mangling}. The
2926@command{c++filt}
c1c0eb9e 2927@footnote{MS-DOS does not allow @kbd{+} characters in file names, so on
195a97ce 2928MS-DOS this program is named @command{CXXFILT}.}
9d51cc66 2929program does the inverse mapping: it decodes (@dfn{demangles}) low-level
ec948987 2930names into user-level names so that they can be read.
252b5132
RH
2931
2932Every alphanumeric word (consisting of letters, digits, underscores,
cbf1f5df
NC
2933dollars, or periods) seen in the input is a potential mangled name.
2934If the name decodes into a C++ name, the C++ name replaces the
ec948987
NC
2935low-level name in the output, otherwise the original word is output.
2936In this way you can pass an entire assembler source file, containing
2937mangled names, through @command{c++filt} and see the same source file
2938containing demangled names.
252b5132 2939
ec948987
NC
2940You can also use @command{c++filt} to decipher individual symbols by
2941passing them on the command line:
252b5132
RH
2942
2943@example
2944c++filt @var{symbol}
2945@end example
2946
c7c55b78 2947If no @var{symbol} arguments are given, @command{c++filt} reads symbol
ec948987
NC
2948names from the standard input instead. All the results are printed on
2949the standard output. The difference between reading names from the
2950command line versus reading names from the standard input is that
2951command line arguments are expected to be just mangled names and no
b45619c0 2952checking is performed to separate them from surrounding text. Thus
ec948987
NC
2953for example:
2954
2955@smallexample
2956c++filt -n _Z1fv
2957@end smallexample
2958
2959will work and demangle the name to ``f()'' whereas:
2960
2961@smallexample
2962c++filt -n _Z1fv,
2963@end smallexample
2964
2965will not work. (Note the extra comma at the end of the mangled
2966name which makes it invalid). This command however will work:
2967
2968@smallexample
2969echo _Z1fv, | c++filt -n
2970@end smallexample
2971
928a4139 2972and will display ``f(),'', i.e., the demangled name followed by a
ec948987
NC
2973trailing comma. This behaviour is because when the names are read
2974from the standard input it is expected that they might be part of an
2975assembler source file where there might be extra, extraneous
928a4139 2976characters trailing after a mangled name. For example:
ec948987
NC
2977
2978@smallexample
2979 .type _Z1fv, @@function
2980@end smallexample
252b5132 2981
0285c67d
NC
2982@c man end
2983
2984@c man begin OPTIONS cxxfilt
2985
c7c55b78 2986@table @env
252b5132 2987@item -_
ae9ab7c0 2988@itemx --strip-underscore
252b5132
RH
2989On some systems, both the C and C++ compilers put an underscore in front
2990of every name. For example, the C name @code{foo} gets the low-level
2991name @code{_foo}. This option removes the initial underscore. Whether
c7c55b78 2992@command{c++filt} removes the underscore by default is target dependent.
252b5132 2993
252b5132 2994@item -n
ae9ab7c0 2995@itemx --no-strip-underscore
252b5132
RH
2996Do not remove the initial underscore.
2997
4e48c9dd
ILT
2998@item -p
2999@itemx --no-params
3000When demangling the name of a function, do not display the types of
3001the function's parameters.
3002
cbf1f5df 3003@item -t
ec948987
NC
3004@itemx --types
3005Attempt to demangle types as well as function names. This is disabled
3006by default since mangled types are normally only used internally in
928a4139 3007the compiler, and they can be confused with non-mangled names. For example,
ec948987
NC
3008a function called ``a'' treated as a mangled type name would be
3009demangled to ``signed char''.
cbf1f5df
NC
3010
3011@item -i
3012@itemx --no-verbose
3013Do not include implementation details (if any) in the demangled
3014output.
3015
252b5132
RH
3016@item -s @var{format}
3017@itemx --format=@var{format}
947ed062
NC
3018@command{c++filt} can decode various methods of mangling, used by
3019different compilers. The argument to this option selects which
252b5132
RH
3020method it uses:
3021
3022@table @code
947ed062
NC
3023@item auto
3024Automatic selection based on executable (the default method)
252b5132 3025@item gnu
947ed062 3026the one used by the @sc{gnu} C++ compiler (g++)
252b5132 3027@item lucid
947ed062 3028the one used by the Lucid compiler (lcc)
252b5132
RH
3029@item arm
3030the one specified by the C++ Annotated Reference Manual
3031@item hp
947ed062 3032the one used by the HP compiler (aCC)
252b5132
RH
3033@item edg
3034the one used by the EDG compiler
b5e2a4f3 3035@item gnu-v3
947ed062
NC
3036the one used by the @sc{gnu} C++ compiler (g++) with the V3 ABI.
3037@item java
3038the one used by the @sc{gnu} Java compiler (gcj)
3039@item gnat
3040the one used by the @sc{gnu} Ada compiler (GNAT).
252b5132
RH
3041@end table
3042
3043@item --help
c7c55b78 3044Print a summary of the options to @command{c++filt} and exit.
252b5132
RH
3045
3046@item --version
c7c55b78 3047Print the version number of @command{c++filt} and exit.
252b5132
RH
3048@end table
3049
0285c67d
NC
3050@c man end
3051
3052@ignore
3053@c man begin SEEALSO cxxfilt
3054the Info entries for @file{binutils}.
3055@c man end
3056@end ignore
3057
252b5132 3058@quotation
c7c55b78 3059@emph{Warning:} @command{c++filt} is a new utility, and the details of its
252b5132 3060user interface are subject to change in future releases. In particular,
b45619c0 3061a command-line option may be required in the future to decode a name
c1c0eb9e 3062passed as an argument on the command line; in other words,
252b5132
RH
3063
3064@example
3065c++filt @var{symbol}
3066@end example
3067
3068@noindent
3069may in a future release become
3070
3071@example
3072c++filt @var{option} @var{symbol}
3073@end example
3074@end quotation
3075
3076@node addr2line
3077@chapter addr2line
3078
3079@kindex addr2line
3080@cindex address to file name and line number
3081
0285c67d
NC
3082@c man title addr2line convert addresses into file names and line numbers.
3083
252b5132 3084@smallexample
0285c67d 3085@c man begin SYNOPSIS addr2line
be6f6493
TG
3086addr2line [@option{-a}|@option{--addresses}]
3087 [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}]
bf44dd74 3088 [@option{-C}|@option{--demangle}[=@var{style}]]
c7c55b78
NC
3089 [@option{-e} @var{filename}|@option{--exe=}@var{filename}]
3090 [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}]
0c552dc1 3091 [@option{-i}|@option{--inlines}]
68cdf72f 3092 [@option{-p}|@option{--pretty-print}]
c5f8c388 3093 [@option{-j}|@option{--section=}@var{name}]
c7c55b78
NC
3094 [@option{-H}|@option{--help}] [@option{-V}|@option{--version}]
3095 [addr addr @dots{}]
0285c67d 3096@c man end
252b5132
RH
3097@end smallexample
3098
0285c67d
NC
3099@c man begin DESCRIPTION addr2line
3100
c5f8c388
EB
3101@command{addr2line} translates addresses into file names and line numbers.
3102Given an address in an executable or an offset in a section of a relocatable
3103object, it uses the debugging information to figure out which file name and
3104line number are associated with it.
252b5132 3105
c5f8c388
EB
3106The executable or relocatable object to use is specified with the @option{-e}
3107option. The default is the file @file{a.out}. The section in the relocatable
3108object to use is specified with the @option{-j} option.
252b5132 3109
c7c55b78 3110@command{addr2line} has two modes of operation.
252b5132
RH
3111
3112In the first, hexadecimal addresses are specified on the command line,
c7c55b78 3113and @command{addr2line} displays the file name and line number for each
252b5132
RH
3114address.
3115
c7c55b78 3116In the second, @command{addr2line} reads hexadecimal addresses from
252b5132 3117standard input, and prints the file name and line number for each
c7c55b78 3118address on standard output. In this mode, @command{addr2line} may be used
252b5132
RH
3119in a pipe to convert dynamically chosen addresses.
3120
3121The format of the output is @samp{FILENAME:LINENO}. The file name and
9cf03b7e
NC
3122line number for each input address is printed on separate lines.
3123
3124If the @option{-f} option is used, then each @samp{FILENAME:LINENO}
3125line is preceded by @samp{FUNCTIONNAME} which is the name of the
3126function containing the address.
3127
3128If the @option{-i} option is used and the code at the given address is
3129present there because of inlining by the compiler then the
3130@samp{@{FUNCTIONNAME@} FILENAME:LINENO} information for the inlining
3131function will be displayed afterwards. This continues recursively
3132until there is no more inlining to report.
3133
3134If the @option{-a} option is used then the output is prefixed by the
3135input address.
3136
3137If the @option{-p} option is used then the output for each input
3138address is displayed on one, possibly quite long, line. If
3139@option{-p} is not used then the output is broken up into multiple
3140lines, based on the paragraphs above.
252b5132
RH
3141
3142If the file name or function name can not be determined,
c7c55b78
NC
3143@command{addr2line} will print two question marks in their place. If the
3144line number can not be determined, @command{addr2line} will print 0.
252b5132 3145
0285c67d
NC
3146@c man end
3147
3148@c man begin OPTIONS addr2line
3149
252b5132
RH
3150The long and short forms of options, shown here as alternatives, are
3151equivalent.
3152
c7c55b78 3153@table @env
be6f6493
TG
3154@item -a
3155@itemx --addresses
9cf03b7e 3156Display the address before the function name, file and line number
be6f6493
TG
3157information. The address is printed with a @samp{0x} prefix to easily
3158identify it.
3159
252b5132
RH
3160@item -b @var{bfdname}
3161@itemx --target=@var{bfdname}
3162@cindex object code format
3163Specify that the object-code format for the object files is
3164@var{bfdname}.
3165
3166@item -C
28c309a2 3167@itemx --demangle[=@var{style}]
252b5132
RH
3168@cindex demangling in objdump
3169Decode (@dfn{demangle}) low-level symbol names into user-level names.
3170Besides removing any initial underscore prepended by the system, this
28c309a2 3171makes C++ function names readable. Different compilers have different
c1c0eb9e
RM
3172mangling styles. The optional demangling style argument can be used to
3173choose an appropriate demangling style for your compiler. @xref{c++filt},
28c309a2 3174for more information on demangling.
252b5132
RH
3175
3176@item -e @var{filename}
3177@itemx --exe=@var{filename}
3178Specify the name of the executable for which addresses should be
3179translated. The default file is @file{a.out}.
3180
3181@item -f
3182@itemx --functions
3183Display function names as well as file and line number information.
3184
3185@item -s
3186@itemx --basenames
3187Display only the base of each file name.
0c552dc1
FF
3188
3189@item -i
3190@itemx --inlines
3191If the address belongs to a function that was inlined, the source
3192information for all enclosing scopes back to the first non-inlined
3193function will also be printed. For example, if @code{main} inlines
3194@code{callee1} which inlines @code{callee2}, and address is from
3195@code{callee2}, the source information for @code{callee1} and @code{main}
3196will also be printed.
c5f8c388
EB
3197
3198@item -j
3199@itemx --section
3200Read offsets relative to the specified section instead of absolute addresses.
68cdf72f
TG
3201
3202@item -p
3203@itemx --pretty-print
3204Make the output more human friendly: each location are printed on one line.
3205If option @option{-i} is specified, lines for all enclosing scopes are
3206prefixed with @samp{(inlined by)}.
e107c42f 3207@end table
252b5132 3208
0285c67d
NC
3209@c man end
3210
3211@ignore
3212@c man begin SEEALSO addr2line
3213Info entries for @file{binutils}.
3214@c man end
3215@end ignore
3216
252b5132
RH
3217@node nlmconv
3218@chapter nlmconv
3219
c7c55b78 3220@command{nlmconv} converts a relocatable object file into a NetWare
252b5132
RH
3221Loadable Module.
3222
3223@ignore
c7c55b78 3224@command{nlmconv} currently works with @samp{i386} object
252b5132
RH
3225files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC}
3226object files in @sc{elf}, or @code{a.out} format@footnote{
c7c55b78 3227@command{nlmconv} should work with any @samp{i386} or @sc{sparc} object
252b5132
RH
3228format in the Binary File Descriptor library. It has only been tested
3229with the above formats.}.
3230@end ignore
3231
3232@quotation
c7c55b78 3233@emph{Warning:} @command{nlmconv} is not always built as part of the binary
252b5132
RH
3234utilities, since it is only useful for NLM targets.
3235@end quotation
3236
0285c67d
NC
3237@c man title nlmconv converts object code into an NLM.
3238
252b5132 3239@smallexample
0285c67d 3240@c man begin SYNOPSIS nlmconv
c7c55b78
NC
3241nlmconv [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}]
3242 [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}]
3243 [@option{-T} @var{headerfile}|@option{--header-file=}@var{headerfile}]
3244 [@option{-d}|@option{--debug}] [@option{-l} @var{linker}|@option{--linker=}@var{linker}]
3245 [@option{-h}|@option{--help}] [@option{-V}|@option{--version}]
252b5132 3246 @var{infile} @var{outfile}
0285c67d 3247@c man end
252b5132
RH
3248@end smallexample
3249
0285c67d
NC
3250@c man begin DESCRIPTION nlmconv
3251
c7c55b78 3252@command{nlmconv} converts the relocatable @samp{i386} object file
252b5132
RH
3253@var{infile} into the NetWare Loadable Module @var{outfile}, optionally
3254reading @var{headerfile} for NLM header information. For instructions
3255on writing the NLM command file language used in header files, see the
3256@samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM
3257Development and Tools Overview}, which is part of the NLM Software
3258Developer's Kit (``NLM SDK''), available from Novell, Inc.
c7c55b78 3259@command{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read
0285c67d
NC
3260@var{infile};
3261@ifclear man
3262see @ref{BFD,,BFD,ld.info,Using LD}, for more information.
3263@end ifclear
252b5132 3264
c7c55b78 3265@command{nlmconv} can perform a link step. In other words, you can list
252b5132
RH
3266more than one object file for input if you list them in the definitions
3267file (rather than simply specifying one input file on the command line).
c7c55b78 3268In this case, @command{nlmconv} calls the linker for you.
252b5132 3269
0285c67d
NC
3270@c man end
3271
3272@c man begin OPTIONS nlmconv
3273
c7c55b78 3274@table @env
252b5132
RH
3275@item -I @var{bfdname}
3276@itemx --input-target=@var{bfdname}
c7c55b78 3277Object format of the input file. @command{nlmconv} can usually determine
252b5132
RH
3278the format of a given file (so no default is necessary).
3279@xref{Target Selection}, for more information.
3280
3281@item -O @var{bfdname}
3282@itemx --output-target=@var{bfdname}
c7c55b78 3283Object format of the output file. @command{nlmconv} infers the output
252b5132
RH
3284format based on the input format, e.g. for a @samp{i386} input file the
3285output format is @samp{nlm32-i386}.
3286@xref{Target Selection}, for more information.
3287
3288@item -T @var{headerfile}
3289@itemx --header-file=@var{headerfile}
3290Reads @var{headerfile} for NLM header information. For instructions on
3291writing the NLM command file language used in header files, see@ see the
3292@samp{linkers} section, of the @cite{NLM Development and Tools
3293Overview}, which is part of the NLM Software Developer's Kit, available
3294from Novell, Inc.
3295
3296@item -d
3297@itemx --debug
c7c55b78 3298Displays (on standard error) the linker command line used by @command{nlmconv}.
252b5132
RH
3299
3300@item -l @var{linker}
3301@itemx --linker=@var{linker}
3302Use @var{linker} for any linking. @var{linker} can be an absolute or a
3303relative pathname.
3304
3305@item -h
3306@itemx --help
3307Prints a usage summary.
3308
3309@item -V
3310@itemx --version
c7c55b78 3311Prints the version number for @command{nlmconv}.
252b5132
RH
3312@end table
3313
0285c67d
NC
3314@c man end
3315
3316@ignore
3317@c man begin SEEALSO nlmconv
3318the Info entries for @file{binutils}.
692ed3e7
NC
3319@c man end
3320@end ignore
3321
3322@node windmc
3323@chapter windmc
3324
3325@command{windmc} may be used to generator Windows message resources.
3326
3327@quotation
3328@emph{Warning:} @command{windmc} is not always built as part of the binary
3329utilities, since it is only useful for Windows targets.
3330@end quotation
3331
3332@c man title windmc generates Windows message resources.
3333
3334@smallexample
826fec2f 3335@c man begin SYNOPSIS windmc
692ed3e7
NC
3336windmc [options] input-file
3337@c man end
3338@end smallexample
3339
3340@c man begin DESCRIPTION windmc
3341
3342@command{windmc} reads message definitions from an input file (.mc) and
3343translate them into a set of output files. The output files may be of
3344four kinds:
3345
3346@table @code
3347@item h
3348A C header file containing the message definitions.
3349
3350@item rc
3351A resource file compilable by the @command{windres} tool.
3352
3353@item bin
3354One or more binary files containing the resource data for a specific
3355message language.
3356
3357@item dbg
3358A C include file that maps message id's to their symbolic name.
3359@end table
3360
3361The exact description of these different formats is available in
3362documentation from Microsoft.
3363
3364When @command{windmc} converts from the @code{mc} format to the @code{bin}
3365format, @code{rc}, @code{h}, and optional @code{dbg} it is acting like the
3366Windows Message Compiler.
3367
3368@c man end
3369
3370@c man begin OPTIONS windmc
3371
3372@table @env
3373@item -a
3374@itemx --ascii_in
826fec2f 3375Specifies that the input file specified is ASCII. This is the default
692ed3e7
NC
3376behaviour.
3377
3378@item -A
3379@itemx --ascii_out
826fec2f 3380Specifies that messages in the output @code{bin} files should be in ASCII
692ed3e7
NC
3381format.
3382
3383@item -b
3384@itemx --binprefix
3385Specifies that @code{bin} filenames should have to be prefixed by the
3386basename of the source file.
3387
3388@item -c
3389@itemx --customflag
3390Sets the customer bit in all message id's.
3391
3392@item -C @var{codepage}
3393@itemx --codepage_in @var{codepage}
3394Sets the default codepage to be used to convert input file to UTF16. The
3395default is ocdepage 1252.
3396
3397@item -d
3398@itemx --decimal_values
3399Outputs the constants in the header file in decimal. Default is using
3400hexadecimal output.
3401
3402@item -e @var{ext}
3403@itemx --extension @var{ext}
3404The extension for the header file. The default is .h extension.
3405
3406@item -F @var{target}
3407@itemx --target @var{target}
3408Specify the BFD format to use for a bin file as output. This
3409is a BFD target name; you can use the @option{--help} option to see a list
3410of supported targets. Normally @command{windmc} will use the default
3411format, which is the first one listed by the @option{--help} option.
3412@ifclear man
3413@ref{Target Selection}.
3414@end ifclear
3415
3416@item -h @var{path}
3417@itemx --headerdir @var{path}
3418The target directory of the generated header file. The default is the
3419current directory.
3420
3421@item -H
3422@itemx --help
3423Displays a list of command line options and then exits.
3424
3425@item -m @var{characters}
3426@itemx --maxlength @var{characters}
3427Instructs @command{windmc} to generate a warning if the length
3428of any message exceeds the number specified.
3429
3430@item -n
3431@itemx --nullterminate
3432Terminate message text in @code{bin} files by zero. By default they are
3433terminated by CR/LF.
3434
3435@item -o
3436@itemx --hresult_use
3437Not yet implemented. Instructs @code{windmc} to generate an OLE2 header
3438file, using HRESULT definitions. Status codes are used if the flag is not
3439specified.
3440
3441@item -O @var{codepage}
3442@itemx --codepage_out @var{codepage}
3443Sets the default codepage to be used to output text files. The default
3444is ocdepage 1252.
3445
3446@item -r @var{path}
3447@itemx --rcdir @var{path}
3448The target directory for the generated @code{rc} script and the generated
3449@code{bin} files that the resource compiler script includes. The default
3450is the current directory.
3451
3452@item -u
3453@itemx --unicode_in
3454Specifies that the input file is UTF16.
3455
3456@item -U
3457@itemx --unicode_out
3458Specifies that messages in the output @code{bin} file should be in UTF16
3459format. This is the default behaviour.
3460
3461@item -v
3462@item --verbose
bd37ed49 3463Enable verbose mode.
692ed3e7
NC
3464
3465@item -V
3466@item --version
bd37ed49 3467Prints the version number for @command{windmc}.
692ed3e7
NC
3468
3469@item -x @var{path}
3470@itemx --xdgb @var{path}
3471The path of the @code{dbg} C include file that maps message id's to the
3472symbolic name. No such file is generated without specifying the switch.
3473@end table
3474
3475@c man end
3476
3477@ignore
3478@c man begin SEEALSO windmc
3479the Info entries for @file{binutils}.
0285c67d
NC
3480@c man end
3481@end ignore
3482
252b5132
RH
3483@node windres
3484@chapter windres
3485
c7c55b78 3486@command{windres} may be used to manipulate Windows resources.
252b5132
RH
3487
3488@quotation
c7c55b78 3489@emph{Warning:} @command{windres} is not always built as part of the binary
252b5132
RH
3490utilities, since it is only useful for Windows targets.
3491@end quotation
3492
0285c67d
NC
3493@c man title windres manipulate Windows resources.
3494
252b5132 3495@smallexample
0285c67d 3496@c man begin SYNOPSIS windres
252b5132 3497windres [options] [input-file] [output-file]
0285c67d 3498@c man end
252b5132
RH
3499@end smallexample
3500
0285c67d
NC
3501@c man begin DESCRIPTION windres
3502
c7c55b78 3503@command{windres} reads resources from an input file and copies them into
252b5132
RH
3504an output file. Either file may be in one of three formats:
3505
3506@table @code
3507@item rc
3508A text format read by the Resource Compiler.
3509
3510@item res
3511A binary format generated by the Resource Compiler.
3512
3513@item coff
3514A COFF object or executable.
3515@end table
3516
3517The exact description of these different formats is available in
3518documentation from Microsoft.
3519
c7c55b78 3520When @command{windres} converts from the @code{rc} format to the @code{res}
252b5132 3521format, it is acting like the Windows Resource Compiler. When
c7c55b78 3522@command{windres} converts from the @code{res} format to the @code{coff}
252b5132
RH
3523format, it is acting like the Windows @code{CVTRES} program.
3524
c7c55b78 3525When @command{windres} generates an @code{rc} file, the output is similar
252b5132
RH
3526but not identical to the format expected for the input. When an input
3527@code{rc} file refers to an external filename, an output @code{rc} file
3528will instead include the file contents.
3529
c7c55b78 3530If the input or output format is not specified, @command{windres} will
252b5132
RH
3531guess based on the file name, or, for the input file, the file contents.
3532A file with an extension of @file{.rc} will be treated as an @code{rc}
3533file, a file with an extension of @file{.res} will be treated as a
3534@code{res} file, and a file with an extension of @file{.o} or
3535@file{.exe} will be treated as a @code{coff} file.
3536
c7c55b78 3537If no output file is specified, @command{windres} will print the resources
252b5132
RH
3538in @code{rc} format to standard output.
3539
c7c55b78 3540The normal use is for you to write an @code{rc} file, use @command{windres}
252b5132
RH
3541to convert it to a COFF object file, and then link the COFF file into
3542your application. This will make the resources described in the
3543@code{rc} file available to Windows.
3544
0285c67d
NC
3545@c man end
3546
3547@c man begin OPTIONS windres
3548
c7c55b78 3549@table @env
252b5132
RH
3550@item -i @var{filename}
3551@itemx --input @var{filename}
3552The name of the input file. If this option is not used, then
c7c55b78
NC
3553@command{windres} will use the first non-option argument as the input file
3554name. If there are no non-option arguments, then @command{windres} will
3555read from standard input. @command{windres} can not read a COFF file from
edbedb71 3556standard input.
252b5132
RH
3557
3558@item -o @var{filename}
3559@itemx --output @var{filename}
3560The name of the output file. If this option is not used, then
c7c55b78 3561@command{windres} will use the first non-option argument, after any used
252b5132 3562for the input file name, as the output file name. If there is no
c7c55b78 3563non-option argument, then @command{windres} will write to standard output.
edbedb71 3564@command{windres} can not write a COFF file to standard output. Note,
b45619c0 3565for compatibility with @command{rc} the option @option{-fo} is also
edbedb71 3566accepted, but its use is not recommended.
252b5132 3567
85eb5110 3568@item -J @var{format}
252b5132
RH
3569@itemx --input-format @var{format}
3570The input format to read. @var{format} may be @samp{res}, @samp{rc}, or
c7c55b78 3571@samp{coff}. If no input format is specified, @command{windres} will
252b5132
RH
3572guess, as described above.
3573
3574@item -O @var{format}
3575@itemx --output-format @var{format}
3576The output format to generate. @var{format} may be @samp{res},
3577@samp{rc}, or @samp{coff}. If no output format is specified,
c7c55b78 3578@command{windres} will guess, as described above.
252b5132
RH
3579
3580@item -F @var{target}
3581@itemx --target @var{target}
3582Specify the BFD format to use for a COFF file as input or output. This
c7c55b78
NC
3583is a BFD target name; you can use the @option{--help} option to see a list
3584of supported targets. Normally @command{windres} will use the default
3585format, which is the first one listed by the @option{--help} option.
3586@ifclear man
252b5132 3587@ref{Target Selection}.
c7c55b78 3588@end ifclear
252b5132
RH
3589
3590@item --preprocessor @var{program}
c7c55b78 3591When @command{windres} reads an @code{rc} file, it runs it through the C
252b5132
RH
3592preprocessor first. This option may be used to specify the preprocessor
3593to use, including any leading arguments. The default preprocessor
3594argument is @code{gcc -E -xc-header -DRC_INVOKED}.
3595
ec25acb3
NC
3596@item --preprocessor-arg @var{option}
3597When @command{windres} reads an @code{rc} file, it runs it through
3598the C preprocessor first. This option may be used to specify additional
3599text to be passed to preprocessor on its command line.
3600This option can be used multiple times to add multiple options to the
3601preprocessor command line.
3602
85eb5110
NC
3603@item -I @var{directory}
3604@itemx --include-dir @var{directory}
252b5132 3605Specify an include directory to use when reading an @code{rc} file.
c7c55b78
NC
3606@command{windres} will pass this to the preprocessor as an @option{-I}
3607option. @command{windres} will also search this directory when looking for
85eb5110 3608files named in the @code{rc} file. If the argument passed to this command
c1c0eb9e 3609matches any of the supported @var{formats} (as described in the @option{-J}
85eb5110
NC
3610option), it will issue a deprecation warning, and behave just like the
3611@option{-J} option. New programs should not use this behaviour. If a
3612directory happens to match a @var{format}, simple prefix it with @samp{./}
3613to disable the backward compatibility.
252b5132 3614
751d21b5 3615@item -D @var{target}
ad0481cd 3616@itemx --define @var{sym}[=@var{val}]
c7c55b78 3617Specify a @option{-D} option to pass to the preprocessor when reading an
252b5132
RH
3618@code{rc} file.
3619
29b058f1
NC
3620@item -U @var{target}
3621@itemx --undefine @var{sym}
3622Specify a @option{-U} option to pass to the preprocessor when reading an
3623@code{rc} file.
3624
3126d709
CF
3625@item -r
3626Ignored for compatibility with rc.
3627
751d21b5
DD
3628@item -v
3629Enable verbose mode. This tells you what the preprocessor is if you
3630didn't specify one.
3631
30ff741f
NC
3632@item -c @var{val}
3633@item --codepage @var{val}
3634Specify the default codepage to use when reading an @code{rc} file.
3635@var{val} should be a hexadecimal prefixed by @samp{0x} or decimal
3636codepage code. The valid range is from zero up to 0xffff, but the
3637validity of the codepage is host and configuration dependent.
3638
3077f5d8 3639@item -l @var{val}
252b5132
RH
3640@item --language @var{val}
3641Specify the default language to use when reading an @code{rc} file.
3642@var{val} should be a hexadecimal language code. The low eight bits are
3643the language, and the high eight bits are the sublanguage.
3644
5a298d2d
NC
3645@item --use-temp-file
3646Use a temporary file to instead of using popen to read the output of
c1c0eb9e
RM
3647the preprocessor. Use this option if the popen implementation is buggy
3648on the host (eg., certain non-English language versions of Windows 95 and
5a298d2d
NC
3649Windows 98 are known to have buggy popen where the output will instead
3650go the console).
3651
3652@item --no-use-temp-file
3653Use popen, not a temporary file, to read the output of the preprocessor.
3654This is the default behaviour.
3655
3077f5d8 3656@item -h
252b5132
RH
3657@item --help
3658Prints a usage summary.
3659
3077f5d8 3660@item -V
252b5132 3661@item --version
c7c55b78 3662Prints the version number for @command{windres}.
252b5132
RH
3663
3664@item --yydebug
c7c55b78 3665If @command{windres} is compiled with @code{YYDEBUG} defined as @code{1},
252b5132
RH
3666this will turn on parser debugging.
3667@end table
3668
0285c67d
NC
3669@c man end
3670
3671@ignore
3672@c man begin SEEALSO windres
3673the Info entries for @file{binutils}.
3674@c man end
3675@end ignore
252b5132
RH
3676
3677@node dlltool
2aa9814e 3678@chapter dlltool
252b5132
RH
3679@cindex DLL
3680@kindex dlltool
3681
2aa9814e
BE
3682@command{dlltool} is used to create the files needed to create dynamic
3683link libraries (DLLs) on systems which understand PE format image
3684files such as Windows. A DLL contains an export table which contains
3685information that the runtime loader needs to resolve references from a
3686referencing program.
3687
3688The export table is generated by this program by reading in a
3689@file{.def} file or scanning the @file{.a} and @file{.o} files which
3690will be in the DLL. A @file{.o} file can contain information in
3691special @samp{.drectve} sections with export information.
252b5132
RH
3692
3693@quotation
2aa9814e
BE
3694@emph{Note:} @command{dlltool} is not always built as part of the
3695binary utilities, since it is only useful for those targets which
3696support DLLs.
252b5132
RH
3697@end quotation
3698
0285c67d
NC
3699@c man title dlltool Create files needed to build and use DLLs.
3700
252b5132 3701@smallexample
0285c67d 3702@c man begin SYNOPSIS dlltool
c7c55b78
NC
3703dlltool [@option{-d}|@option{--input-def} @var{def-file-name}]
3704 [@option{-b}|@option{--base-file} @var{base-file-name}]
3705 [@option{-e}|@option{--output-exp} @var{exports-file-name}]
3706 [@option{-z}|@option{--output-def} @var{def-file-name}]
c1c0eb9e 3707 [@option{-l}|@option{--output-lib} @var{library-file-name}]
10e636d2 3708 [@option{-y}|@option{--output-delaylib} @var{library-file-name}]
c7c55b78
NC
3709 [@option{--export-all-symbols}] [@option{--no-export-all-symbols}]
3710 [@option{--exclude-symbols} @var{list}]
3711 [@option{--no-default-excludes}]
3712 [@option{-S}|@option{--as} @var{path-to-assembler}] [@option{-f}|@option{--as-flags} @var{options}]
3713 [@option{-D}|@option{--dllname} @var{name}] [@option{-m}|@option{--machine} @var{machine}]
14288fdc
DS
3714 [@option{-a}|@option{--add-indirect}]
3715 [@option{-U}|@option{--add-underscore}] [@option{--add-stdcall-underscore}]
3716 [@option{-k}|@option{--kill-at}] [@option{-A}|@option{--add-stdcall-alias}]
607dea97 3717 [@option{-p}|@option{--ext-prefix-alias} @var{prefix}]
d4732f7c 3718 [@option{-x}|@option{--no-idata4}] [@option{-c}|@option{--no-idata5}]
e77b97d4 3719 [@option{--use-nul-prefixed-import-tables}]
71c57c16
NC
3720 [@option{-I}|@option{--identify} @var{library-file-name}] [@option{--identify-strict}]
3721 [@option{-i}|@option{--interwork}]
f9346411 3722 [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}]
c1c0eb9e 3723 [@option{-v}|@option{--verbose}]
c7c55b78 3724 [@option{-h}|@option{--help}] [@option{-V}|@option{--version}]
36d21de5 3725 [@option{--no-leading-underscore}] [@option{--leading-underscore}]
252b5132 3726 [object-file @dots{}]
0285c67d 3727@c man end
252b5132
RH
3728@end smallexample
3729
0285c67d
NC
3730@c man begin DESCRIPTION dlltool
3731
c7c55b78
NC
3732@command{dlltool} reads its inputs, which can come from the @option{-d} and
3733@option{-b} options as well as object files specified on the command
3734line. It then processes these inputs and if the @option{-e} option has
3735been specified it creates a exports file. If the @option{-l} option
3736has been specified it creates a library file and if the @option{-z} option
c1c0eb9e
RM
3737has been specified it creates a def file. Any or all of the @option{-e},
3738@option{-l} and @option{-z} options can be present in one invocation of
c7c55b78 3739dlltool.
252b5132
RH
3740
3741When creating a DLL, along with the source for the DLL, it is necessary
c7c55b78 3742to have three other files. @command{dlltool} can help with the creation of
252b5132
RH
3743these files.
3744
2aa9814e 3745The first file is a @file{.def} file which specifies which functions are
252b5132 3746exported from the DLL, which functions the DLL imports, and so on. This
c7c55b78
NC
3747is a text file and can be created by hand, or @command{dlltool} can be used
3748to create it using the @option{-z} option. In this case @command{dlltool}
252b5132
RH
3749will scan the object files specified on its command line looking for
3750those functions which have been specially marked as being exported and
2aa9814e 3751put entries for them in the @file{.def} file it creates.
252b5132
RH
3752
3753In order to mark a function as being exported from a DLL, it needs to
c7c55b78 3754have an @option{-export:<name_of_function>} entry in the @samp{.drectve}
252b5132
RH
3755section of the object file. This can be done in C by using the
3756asm() operator:
3757
3758@smallexample
c1c0eb9e 3759 asm (".section .drectve");
252b5132
RH
3760 asm (".ascii \"-export:my_func\"");
3761
3762 int my_func (void) @{ @dots{} @}
3763@end smallexample
3764
3765The second file needed for DLL creation is an exports file. This file
3766is linked with the object files that make up the body of the DLL and it
3767handles the interface between the DLL and the outside world. This is a
c7c55b78 3768binary file and it can be created by giving the @option{-e} option to
c1c0eb9e 3769@command{dlltool} when it is creating or reading in a @file{.def} file.
252b5132
RH
3770
3771The third file needed for DLL creation is the library file that programs
d4732f7c
CW
3772will link with in order to access the functions in the DLL (an `import
3773library'). This file can be created by giving the @option{-l} option to
3774dlltool when it is creating or reading in a @file{.def} file.
252b5132 3775
10e636d2
DK
3776If the @option{-y} option is specified, dlltool generates a delay-import
3777library that can be used instead of the normal import library to allow
3778a program to link to the dll only as soon as an imported function is
3779called for the first time. The resulting executable will need to be
3780linked to the static delayimp library containing __delayLoadHelper2(),
3781which in turn will import LoadLibraryA and GetProcAddress from kernel32.
3782
c7c55b78 3783@command{dlltool} builds the library file by hand, but it builds the
252b5132 3784exports file by creating temporary files containing assembler statements
c7c55b78 3785and then assembling these. The @option{-S} command line option can be
252b5132 3786used to specify the path to the assembler that dlltool will use,
c7c55b78
NC
3787and the @option{-f} option can be used to pass specific flags to that
3788assembler. The @option{-n} can be used to prevent dlltool from deleting
3789these temporary assembler files when it is done, and if @option{-n} is
252b5132
RH
3790specified twice then this will prevent dlltool from deleting the
3791temporary object files it used to build the library.
3792
3793Here is an example of creating a DLL from a source file @samp{dll.c} and
3794also creating a program (from an object file called @samp{program.o})
3795that uses that DLL:
3796
3797@smallexample
3798 gcc -c dll.c
3799 dlltool -e exports.o -l dll.lib dll.o
3800 gcc dll.o exports.o -o dll.dll
3801 gcc program.o dll.lib -o program
3802@end smallexample
3803
d4732f7c
CW
3804
3805@command{dlltool} may also be used to query an existing import library
b3364cb9 3806to determine the name of the DLL to which it is associated. See the
d4732f7c 3807description of the @option{-I} or @option{--identify} option.
b3364cb9 3808
0285c67d
NC
3809@c man end
3810
3811@c man begin OPTIONS dlltool
3812
252b5132
RH
3813The command line options have the following meanings:
3814
c7c55b78 3815@table @env
252b5132
RH
3816
3817@item -d @var{filename}
3818@itemx --input-def @var{filename}
3819@cindex input .def file
2aa9814e 3820Specifies the name of a @file{.def} file to be read in and processed.
252b5132
RH
3821
3822@item -b @var{filename}
3823@itemx --base-file @var{filename}
3824@cindex base files
3825Specifies the name of a base file to be read in and processed. The
3826contents of this file will be added to the relocation section in the
3827exports file generated by dlltool.
3828
3829@item -e @var{filename}
3830@itemx --output-exp @var{filename}
3831Specifies the name of the export file to be created by dlltool.
3832
3833@item -z @var{filename}
3834@itemx --output-def @var{filename}
2aa9814e 3835Specifies the name of the @file{.def} file to be created by dlltool.
252b5132
RH
3836
3837@item -l @var{filename}
3838@itemx --output-lib @var{filename}
3839Specifies the name of the library file to be created by dlltool.
3840
10e636d2
DK
3841@item -y @var{filename}
3842@itemx --output-delaylib @var{filename}
3843Specifies the name of the delay-import library file to be created by dlltool.
3844
252b5132
RH
3845@item --export-all-symbols
3846Treat all global and weak defined symbols found in the input object
3847files as symbols to be exported. There is a small list of symbols which
c7c55b78 3848are not exported by default; see the @option{--no-default-excludes}
252b5132 3849option. You may add to the list of symbols to not export by using the
c7c55b78 3850@option{--exclude-symbols} option.
252b5132
RH
3851
3852@item --no-export-all-symbols
2aa9814e 3853Only export symbols explicitly listed in an input @file{.def} file or in
252b5132
RH
3854@samp{.drectve} sections in the input object files. This is the default
3855behaviour. The @samp{.drectve} sections are created by @samp{dllexport}
3856attributes in the source code.
3857
3858@item --exclude-symbols @var{list}
3859Do not export the symbols in @var{list}. This is a list of symbol names
3860separated by comma or colon characters. The symbol names should not
3861contain a leading underscore. This is only meaningful when
c7c55b78 3862@option{--export-all-symbols} is used.
252b5132
RH
3863
3864@item --no-default-excludes
c7c55b78 3865When @option{--export-all-symbols} is used, it will by default avoid
252b5132
RH
3866exporting certain special symbols. The current list of symbols to avoid
3867exporting is @samp{DllMain@@12}, @samp{DllEntryPoint@@0},
c7c55b78 3868@samp{impure_ptr}. You may use the @option{--no-default-excludes} option
252b5132 3869to go ahead and export these special symbols. This is only meaningful
c7c55b78 3870when @option{--export-all-symbols} is used.
252b5132
RH
3871
3872@item -S @var{path}
3873@itemx --as @var{path}
3874Specifies the path, including the filename, of the assembler to be used
3875to create the exports file.
3876
6364e0b4
NC
3877@item -f @var{options}
3878@itemx --as-flags @var{options}
3879Specifies any specific command line options to be passed to the
252b5132 3880assembler when building the exports file. This option will work even if
c7c55b78 3881the @option{-S} option is not used. This option only takes one argument,
252b5132
RH
3882and if it occurs more than once on the command line, then later
3883occurrences will override earlier occurrences. So if it is necessary to
6364e0b4 3884pass multiple options to the assembler they should be enclosed in
252b5132
RH
3885double quotes.
3886
3887@item -D @var{name}
3888@itemx --dll-name @var{name}
2aa9814e
BE
3889Specifies the name to be stored in the @file{.def} file as the name of
3890the DLL when the @option{-e} option is used. If this option is not
3891present, then the filename given to the @option{-e} option will be
3892used as the name of the DLL.
252b5132
RH
3893
3894@item -m @var{machine}
3895@itemx -machine @var{machine}
3896Specifies the type of machine for which the library file should be
c7c55b78 3897built. @command{dlltool} has a built in default type, depending upon how
252b5132
RH
3898it was created, but this option can be used to override that. This is
3899normally only useful when creating DLLs for an ARM processor, when the
c36774d6 3900contents of the DLL are actually encode using Thumb instructions.
252b5132
RH
3901
3902@item -a
3903@itemx --add-indirect
c7c55b78 3904Specifies that when @command{dlltool} is creating the exports file it
252b5132
RH
3905should add a section which allows the exported functions to be
3906referenced without using the import library. Whatever the hell that
c1c0eb9e 3907means!
252b5132
RH
3908
3909@item -U
3910@itemx --add-underscore
c7c55b78 3911Specifies that when @command{dlltool} is creating the exports file it
c1c0eb9e 3912should prepend an underscore to the names of @emph{all} exported symbols.
14288fdc 3913
36d21de5
KT
3914@item --no-leading-underscore
3915@item --leading-underscore
3916Specifies whether standard symbol should be forced to be prefixed, or
3917not.
3918
14288fdc
DS
3919@item --add-stdcall-underscore
3920Specifies that when @command{dlltool} is creating the exports file it
3921should prepend an underscore to the names of exported @emph{stdcall}
3922functions. Variable names and non-stdcall function names are not modified.
3923This option is useful when creating GNU-compatible import libs for third
3924party DLLs that were built with MS-Windows tools.
252b5132
RH
3925
3926@item -k
3927@itemx --kill-at
c7c55b78 3928Specifies that when @command{dlltool} is creating the exports file it
d67a454c
NC
3929should not append the string @samp{@@ <number>}. These numbers are
3930called ordinal numbers and they represent another way of accessing the
3931function in a DLL, other than by name.
252b5132
RH
3932
3933@item -A
3934@itemx --add-stdcall-alias
c7c55b78 3935Specifies that when @command{dlltool} is creating the exports file it
252b5132
RH
3936should add aliases for stdcall symbols without @samp{@@ <number>}
3937in addition to the symbols with @samp{@@ <number>}.
3938
607dea97
NC
3939@item -p
3940@itemx --ext-prefix-alias @var{prefix}
3941Causes @command{dlltool} to create external aliases for all DLL
3942imports with the specified prefix. The aliases are created for both
3943external and import symbols with no leading underscore.
3944
252b5132
RH
3945@item -x
3946@itemx --no-idata4
c7c55b78
NC
3947Specifies that when @command{dlltool} is creating the exports and library
3948files it should omit the @code{.idata4} section. This is for compatibility
252b5132
RH
3949with certain operating systems.
3950
e77b97d4
KT
3951@item --use-nul-prefixed-import-tables
3952Specifies that when @command{dlltool} is creating the exports and library
3953files it should prefix the @code{.idata4} and @code{.idata5} by zero an
3954element. This emulates old gnu import library generation of
3955@code{dlltool}. By default this option is turned off.
3956
252b5132
RH
3957@item -c
3958@itemx --no-idata5
c7c55b78
NC
3959Specifies that when @command{dlltool} is creating the exports and library
3960files it should omit the @code{.idata5} section. This is for compatibility
252b5132
RH
3961with certain operating systems.
3962
d4732f7c
CW
3963@item -I @var{filename}
3964@itemx --identify @var{filename}
3965Specifies that @command{dlltool} should inspect the import library
71c57c16
NC
3966indicated by @var{filename} and report, on @code{stdout}, the name(s)
3967of the associated DLL(s). This can be performed in addition to any
3968other operations indicated by the other options and arguments.
3969@command{dlltool} fails if the import library does not exist or is not
3970actually an import library. See also @option{--identify-strict}.
3971
3972@item --identify-strict
3973Modifies the behavior of the @option{--identify} option, such
3974that an error is reported if @var{filename} is associated with
3975more than one DLL.
d4732f7c 3976
252b5132
RH
3977@item -i
3978@itemx --interwork
c7c55b78 3979Specifies that @command{dlltool} should mark the objects in the library
252b5132 3980file and exports file that it produces as supporting interworking
c36774d6 3981between ARM and Thumb code.
252b5132
RH
3982
3983@item -n
3984@itemx --nodelete
c7c55b78 3985Makes @command{dlltool} preserve the temporary assembler files it used to
252b5132
RH
3986create the exports file. If this option is repeated then dlltool will
3987also preserve the temporary object files it uses to create the library
f9346411
DS
3988file.
3989
3990@item -t @var{prefix}
3991@itemx --temp-prefix @var{prefix}
3992Makes @command{dlltool} use @var{prefix} when constructing the names of
3993temporary assembler and object files. By default, the temp file prefix
c1c0eb9e 3994is generated from the pid.
252b5132
RH
3995
3996@item -v
3997@itemx --verbose
3998Make dlltool describe what it is doing.
3999
4000@item -h
4001@itemx --help
4002Displays a list of command line options and then exits.
4003
4004@item -V
4005@itemx --version
4006Displays dlltool's version number and then exits.
4007
4008@end table
4009
0285c67d
NC
4010@c man end
4011
2aa9814e
BE
4012@menu
4013* def file format:: The format of the dlltool @file{.def} file
4014@end menu
4015
4016@node def file format
4017@section The format of the @command{dlltool} @file{.def} file
4018
4019A @file{.def} file contains any number of the following commands:
4020
4021@table @asis
4022
4023@item @code{NAME} @var{name} @code{[ ,} @var{base} @code{]}
4024The result is going to be named @var{name}@code{.exe}.
4025
4026@item @code{LIBRARY} @var{name} @code{[ ,} @var{base} @code{]}
4027The result is going to be named @var{name}@code{.dll}.
5b3d386e
KT
4028Note: If you want to use LIBRARY as name then you need to quote. Otherwise
4029this will fail due a necessary hack for libtool (see PR binutils/13710 for more
4030details).
2aa9814e 4031
bf201fdd 4032@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
4033@item @code{[} @var{integer} @code{] [ NONAME ] [ CONSTANT ] [ DATA ] [ PRIVATE ] ) *}
4034Declares @var{name1} as an exported symbol from the DLL, with optional
4035ordinal number @var{integer}, or declares @var{name1} as an alias
bf201fdd
KT
4036(forward) of the function @var{external-name} in the DLL.
4037If @var{its_name} is specified, this name is used as string in export table.
2aa9814e 4038@var{module-name}.
5b3d386e
KT
4039Note: The @code{EXPORTS} has to be the last command in .def file, as keywords
4040are treated - beside @code{LIBRARY} - as simple name-identifiers.
4041If you want to use LIBRARY as name then you need to quote it.
2aa9814e 4042
bf201fdd 4043@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
4044Declares that @var{external-name} or the exported function whose
4045ordinal number is @var{integer} is to be imported from the file
4046@var{module-name}. If @var{internal-name} is specified then this is
4047the name that the imported function will be referred to in the body of
4048the DLL.
bf201fdd 4049If @var{its_name} is specified, this name is used as string in import table.
5b3d386e
KT
4050Note: The @code{IMPORTS} has to be the last command in .def file, as keywords
4051are treated - beside @code{LIBRARY} - as simple name-identifiers.
4052If you want to use LIBRARY as name then you need to quote it.
2aa9814e
BE
4053
4054@item @code{DESCRIPTION} @var{string}
4055Puts @var{string} into the output @file{.exp} file in the
4056@code{.rdata} section.
4057
4058@item @code{STACKSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]}
4059@item @code{HEAPSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]}
4060Generates @code{--stack} or @code{--heap}
4061@var{number-reserve},@var{number-commit} in the output @code{.drectve}
4062section. The linker will see this and act upon it.
4063
4064@item @code{CODE} @var{attr} @code{+}
4065@item @code{DATA} @var{attr} @code{+}
4066@item @code{SECTIONS (} @var{section-name} @var{attr}@code{ + ) *}
4067Generates @code{--attr} @var{section-name} @var{attr} in the output
4068@code{.drectve} section, where @var{attr} is one of @code{READ},
4069@code{WRITE}, @code{EXECUTE} or @code{SHARED}. The linker will see
4070this and act upon it.
4071
4072@end table
4073
0285c67d
NC
4074@ignore
4075@c man begin SEEALSO dlltool
2aa9814e 4076The Info pages for @file{binutils}.
0285c67d
NC
4077@c man end
4078@end ignore
4079
252b5132
RH
4080@node readelf
4081@chapter readelf
4082
4083@cindex ELF file information
4084@kindex readelf
4085
0285c67d
NC
4086@c man title readelf Displays information about ELF files.
4087
252b5132 4088@smallexample
0285c67d 4089@c man begin SYNOPSIS readelf
c1c0eb9e 4090readelf [@option{-a}|@option{--all}]
c7c55b78
NC
4091 [@option{-h}|@option{--file-header}]
4092 [@option{-l}|@option{--program-headers}|@option{--segments}]
4093 [@option{-S}|@option{--section-headers}|@option{--sections}]
81fc812e 4094 [@option{-g}|@option{--section-groups}]
5477e8a0 4095 [@option{-t}|@option{--section-details}]
c7c55b78
NC
4096 [@option{-e}|@option{--headers}]
4097 [@option{-s}|@option{--syms}|@option{--symbols}]
2c610e4b 4098 [@option{--dyn-syms}]
c7c55b78
NC
4099 [@option{-n}|@option{--notes}]
4100 [@option{-r}|@option{--relocs}]
4101 [@option{-u}|@option{--unwind}]
4102 [@option{-d}|@option{--dynamic}]
4103 [@option{-V}|@option{--version-info}]
947ed062 4104 [@option{-A}|@option{--arch-specific}]
c7c55b78 4105 [@option{-D}|@option{--use-dynamic}]
aef1f6d0 4106 [@option{-x} <number or name>|@option{--hex-dump=}<number or name>]
09c11c86 4107 [@option{-p} <number or name>|@option{--string-dump=}<number or name>]
cf13d699 4108 [@option{-R} <number or name>|@option{--relocated-dump=}<number or name>]
4145f1d5 4109 [@option{-c}|@option{--archive-index}]
f9f0e732 4110 [@option{-w[lLiaprmfFsoRt]}|
5bbdf3d5 4111 @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
4112 [@option{--dwarf-depth=@var{n}}]
4113 [@option{--dwarf-start=@var{n}}]
ed22650e 4114 [@option{-I}|@option{--histogram}]
c7c55b78 4115 [@option{-v}|@option{--version}]
d974e256 4116 [@option{-W}|@option{--wide}]
c7c55b78 4117 [@option{-H}|@option{--help}]
252b5132 4118 @var{elffile}@dots{}
0285c67d 4119@c man end
252b5132
RH
4120@end smallexample
4121
0285c67d
NC
4122@c man begin DESCRIPTION readelf
4123
c7c55b78 4124@command{readelf} displays information about one or more ELF format object
252b5132
RH
4125files. The options control what particular information to display.
4126
fb52b2f4
NC
4127@var{elffile}@dots{} are the object files to be examined. 32-bit and
412864-bit ELF files are supported, as are archives containing ELF files.
252b5132 4129
9eb20dd8
NC
4130This program performs a similar function to @command{objdump} but it
4131goes into more detail and it exists independently of the @sc{bfd}
4132library, so if there is a bug in @sc{bfd} then readelf will not be
4133affected.
4134
0285c67d
NC
4135@c man end
4136
4137@c man begin OPTIONS readelf
4138
252b5132
RH
4139The long and short forms of options, shown here as alternatives, are
4140equivalent. At least one option besides @samp{-v} or @samp{-H} must be
c1c0eb9e 4141given.
252b5132 4142
c7c55b78 4143@table @env
252b5132
RH
4144@item -a
4145@itemx --all
d95ef3ab 4146Equivalent to specifying @option{--file-header},
c7c55b78
NC
4147@option{--program-headers}, @option{--sections}, @option{--symbols},
4148@option{--relocs}, @option{--dynamic}, @option{--notes} and
c1c0eb9e 4149@option{--version-info}.
252b5132
RH
4150
4151@item -h
4152@itemx --file-header
4153@cindex ELF file header information
4154Displays the information contained in the ELF header at the start of the
4155file.
4156
4157@item -l
4158@itemx --program-headers
4159@itemx --segments
4160@cindex ELF program header information
4161@cindex ELF segment information
4162Displays the information contained in the file's segment headers, if it
4163has any.
4164
4165@item -S
4166@itemx --sections
4167@itemx --section-headers
4168@cindex ELF section information
4169Displays the information contained in the file's section headers, if it
4170has any.
4171
81fc812e
L
4172@item -g
4173@itemx --section-groups
4174@cindex ELF section group information
4175Displays the information contained in the file's section groups, if it
4176has any.
4177
5477e8a0
L
4178@item -t
4179@itemx --section-details
4180@cindex ELF section information
4181Displays the detailed section information. Implies @option{-S}.
81fc812e 4182
252b5132
RH
4183@item -s
4184@itemx --symbols
4185@itemx --syms
4186@cindex ELF symbol table information
4187Displays the entries in symbol table section of the file, if it has one.
4188
2c610e4b
L
4189@item --dyn-syms
4190@cindex ELF dynamic symbol table information
4191Displays the entries in dynamic symbol table section of the file, if it
4192has one.
4193
252b5132
RH
4194@item -e
4195@itemx --headers
c7c55b78 4196Display all the headers in the file. Equivalent to @option{-h -l -S}.
252b5132 4197
779fe533
NC
4198@item -n
4199@itemx --notes
1ec5cd37
NC
4200@cindex ELF notes
4201Displays the contents of the NOTE segments and/or sections, if any.
779fe533 4202
252b5132
RH
4203@item -r
4204@itemx --relocs
4205@cindex ELF reloc information
f5e21966
NC
4206Displays the contents of the file's relocation section, if it has one.
4207
4208@item -u
4209@itemx --unwind
4210@cindex unwind information
4211Displays the contents of the file's unwind section, if it has one. Only
ba7f2642
TS
4212the unwind sections for IA64 ELF files, as well as ARM unwind tables
4213(@code{.ARM.exidx} / @code{.ARM.extab}) are currently supported.
252b5132
RH
4214
4215@item -d
4216@itemx --dynamic
4217@cindex ELF dynamic section information
4218Displays the contents of the file's dynamic section, if it has one.
4219
4220@item -V
4221@itemx --version-info
4222@cindex ELF version sections informations
4223Displays the contents of the version sections in the file, it they
4224exist.
4225
947ed062
NC
4226@item -A
4227@itemx --arch-specific
4228Displays architecture-specific information in the file, if there
4229is any.
4230
252b5132
RH
4231@item -D
4232@itemx --use-dynamic
c7c55b78 4233When displaying symbols, this option makes @command{readelf} use the
2c610e4b
L
4234symbol hash tables in the file's dynamic section, rather than the
4235symbol table sections.
252b5132 4236
aef1f6d0
DJ
4237@item -x <number or name>
4238@itemx --hex-dump=<number or name>
cf13d699 4239Displays the contents of the indicated section as a hexadecimal bytes.
aef1f6d0
DJ
4240A number identifies a particular section by index in the section table;
4241any other string identifies all sections with that name in the object file.
252b5132 4242
cf13d699
NC
4243@item -R <number or name>
4244@itemx --relocated-dump=<number or name>
4245Displays the contents of the indicated section as a hexadecimal
4246bytes. A number identifies a particular section by index in the
4247section table; any other string identifies all sections with that name
4248in the object file. The contents of the section will be relocated
4249before they are displayed.
4250
09c11c86
NC
4251@item -p <number or name>
4252@itemx --string-dump=<number or name>
4253Displays the contents of the indicated section as printable strings.
4254A number identifies a particular section by index in the section table;
4255any other string identifies all sections with that name in the object file.
4256
4145f1d5
NC
4257@item -c
4258@itemx --archive-index
4259@cindex Archive file symbol index information
4260Displays the file symbol index infomation contained in the header part
4261of binary archives. Performs the same function as the @option{t}
4262command to @command{ar}, but without using the BFD library. @xref{ar}.
4263
f9f0e732 4264@item -w[lLiaprmfFsoRt]
5bbdf3d5 4265@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
4266Displays the contents of the debug sections in the file, if any are
4267present. If one of the optional letters or words follows the switch
4268then only data found in those specific sections will be dumped.
4269
6f875884 4270Note that there is no single letter option to display the content of
5bbdf3d5 4271trace sections or .gdb_index.
6f875884 4272
a262ae96
NC
4273Note: the @option{=decodedline} option will display the interpreted
4274contents of a .debug_line section whereas the @option{=rawline} option
4275dumps the contents in a raw format.
4276
1ed06042
NC
4277Note: the @option{=frames-interp} option will display the interpreted
4278contents of a .debug_frame section whereas the @option{=frames} option
4279dumps the contents in a raw format.
4280
fd2f0033
TT
4281Note: the output from the @option{=info} option can also be affected
4282by the options @option{--dwarf-depth} and @option{--dwarf-start}.
4283
4284@item --dwarf-depth=@var{n}
4285Limit the dump of the @code{.debug_info} section to @var{n} children.
4286This is only useful with @option{--debug-dump=info}. The default is
4287to print all DIEs; the special value 0 for @var{n} will also have this
4288effect.
4289
4290With a non-zero value for @var{n}, DIEs at or deeper than @var{n}
4291levels will not be printed. The range for @var{n} is zero-based.
4292
4293@item --dwarf-start=@var{n}
4294Print only DIEs beginning with the DIE numbered @var{n}. This is only
4295useful with @option{--debug-dump=info}.
4296
4297If specified, this option will suppress printing of any header
4298information and all DIEs before the DIE numbered @var{n}. Only
4299siblings and children of the specified DIE will be printed.
4300
4301This can be used in conjunction with @option{--dwarf-depth}.
4302
947ed062
NC
4303@item -I
4304@itemx --histogram
252b5132
RH
4305Display a histogram of bucket list lengths when displaying the contents
4306of the symbol tables.
4307
4308@item -v
4309@itemx --version
4310Display the version number of readelf.
4311
d974e256
JJ
4312@item -W
4313@itemx --wide
4314Don't break output lines to fit into 80 columns. By default
4315@command{readelf} breaks section header and segment listing lines for
431664-bit ELF files, so that they fit into 80 columns. This option causes
4317@command{readelf} to print each section header resp. each segment one a
4318single line, which is far more readable on terminals wider than 80 columns.
4319
252b5132
RH
4320@item -H
4321@itemx --help
c7c55b78 4322Display the command line options understood by @command{readelf}.
252b5132
RH
4323
4324@end table
4325
0285c67d
NC
4326@c man end
4327
4328@ignore
4329@c man begin SEEALSO readelf
4330objdump(1), and the Info entries for @file{binutils}.
4331@c man end
4332@end ignore
252b5132 4333
30fd33bb
L
4334@node elfedit
4335@chapter elfedit
4336
4337@cindex Update ELF header
4338@kindex elfedit
4339
4340@c man title elfedit Update the ELF header of ELF files.
4341
4342@smallexample
4343@c man begin SYNOPSIS elfedit
4344elfedit [@option{--input-mach=}@var{machine}]
dd35de74 4345 [@option{--input-type=}@var{type}]
08ebfb8c 4346 [@option{--input-osabi=}@var{osabi}]
c7a795f8 4347 @option{--output-mach=}@var{machine}
dd35de74 4348 @option{--output-type=}@var{type}
08ebfb8c 4349 @option{--output-osabi=}@var{osabi}
30fd33bb
L
4350 [@option{-v}|@option{--version}]
4351 [@option{-h}|@option{--help}]
4352 @var{elffile}@dots{}
4353@c man end
4354@end smallexample
4355
4356@c man begin DESCRIPTION elfedit
4357
dd35de74
L
4358@command{elfedit} updates the ELF header of ELF files which have
4359the matching ELF machine and file types. The options control how and
4360which fields in the ELF header should be updated.
30fd33bb
L
4361
4362@var{elffile}@dots{} are the ELF files to be updated. 32-bit and
436364-bit ELF files are supported, as are archives containing ELF files.
4364@c man end
4365
4366@c man begin OPTIONS elfedit
4367
4368The long and short forms of options, shown here as alternatives, are
d0514c49
L
4369equivalent. At least one of the @option{--output-mach},
4370@option{--output-type} and @option{--output-osabi} options must be given.
30fd33bb
L
4371
4372@table @env
4373
4374@itemx --input-mach=@var{machine}
dd35de74
L
4375Set the matching input ELF machine type to @var{machine}. If
4376@option{--input-mach} isn't specified, it will match any ELF
4377machine types.
30fd33bb 4378
7a9068fe
L
4379The supported ELF machine types are, @var{L1OM}, @var{K1OM} and
4380@var{x86-64}.
30fd33bb
L
4381
4382@itemx --output-mach=@var{machine}
4383Change the ELF machine type in the ELF header to @var{machine}. The
4384supported ELF machine types are the same as @option{--input-mach}.
4385
dd35de74
L
4386@itemx --input-type=@var{type}
4387Set the matching input ELF file type to @var{type}. If
4388@option{--input-type} isn't specified, it will match any ELF file types.
4389
4390The supported ELF file types are, @var{rel}, @var{exec} and @var{dyn}.
4391
4392@itemx --output-type=@var{type}
4393Change the ELF file type in the ELF header to @var{type}. The
4394supported ELF types are the same as @option{--input-type}.
4395
d0514c49 4396@itemx --input-osabi=@var{osabi}
08ebfb8c 4397Set the matching input ELF file OSABI to @var{osabi}. If
d0514c49
L
4398@option{--input-osabi} isn't specified, it will match any ELF OSABIs.
4399
4400The supported ELF OSABIs are, @var{none}, @var{HPUX}, @var{NetBSD},
9c55345c
TS
4401@var{GNU}, @var{Linux} (alias for @var{GNU}),
4402@var{Solaris}, @var{AIX}, @var{Irix},
d0514c49
L
4403@var{FreeBSD}, @var{TRU64}, @var{Modesto}, @var{OpenBSD}, @var{OpenVMS},
4404@var{NSK}, @var{AROS} and @var{FenixOS}.
4405
4406@itemx --output-osabi=@var{osabi}
08ebfb8c 4407Change the ELF OSABI in the ELF header to @var{osabi}. The
d0514c49
L
4408supported ELF OSABI are the same as @option{--input-osabi}.
4409
30fd33bb
L
4410@item -v
4411@itemx --version
4412Display the version number of @command{elfedit}.
4413
4414@item -h
4415@itemx --help
4416Display the command line options understood by @command{elfedit}.
4417
4418@end table
4419
4420@c man end
4421
4422@ignore
4423@c man begin SEEALSO elfedit
4424readelf(1), and the Info entries for @file{binutils}.
4425@c man end
4426@end ignore
4427
07012eee
MM
4428@node Common Options
4429@chapter Common Options
4430
4431The following command-line options are supported by all of the
4432programs described in this manual.
4433
dff70155 4434@c man begin OPTIONS
07012eee 4435@table @env
38fc1cb1 4436@include at-file.texi
dff70155 4437@c man end
07012eee
MM
4438
4439@item --help
4440Display the command-line options supported by the program.
4441
4442@item --version
4443Display the version number of the program.
4444
dff70155 4445@c man begin OPTIONS
07012eee 4446@end table
dff70155 4447@c man end
07012eee 4448
fff279a7 4449@node Selecting the Target System
947ed062 4450@chapter Selecting the Target System
252b5132 4451
947ed062 4452You can specify two aspects of the target system to the @sc{gnu}
252b5132
RH
4453binary file utilities, each in several ways:
4454
4455@itemize @bullet
4456@item
4457the target
4458
4459@item
4460the architecture
252b5132
RH
4461@end itemize
4462
4463In the following summaries, the lists of ways to specify values are in
4464order of decreasing precedence. The ways listed first override those
4465listed later.
4466
4467The commands to list valid values only list the values for which the
4468programs you are running were configured. If they were configured with
c7c55b78 4469@option{--enable-targets=all}, the commands list most of the available
252b5132
RH
4470values, but a few are left out; not all targets can be configured in at
4471once because some of them can only be configured @dfn{native} (on hosts
4472with the same type as the target system).
4473
4474@menu
c1c0eb9e
RM
4475* Target Selection::
4476* Architecture Selection::
252b5132
RH
4477@end menu
4478
4479@node Target Selection
4480@section Target Selection
4481
4482A @dfn{target} is an object file format. A given target may be
4483supported for multiple architectures (@pxref{Architecture Selection}).
4484A target selection may also have variations for different operating
4485systems or architectures.
4486
4487The command to list valid target values is @samp{objdump -i}
4488(the first column of output contains the relevant information).
4489
4490Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips},
4491@samp{a.out-sunos-big}.
4492
4493You can also specify a target using a configuration triplet. This is
f20a759a
ILT
4494the same sort of name that is passed to @file{configure} to specify a
4495target. When you use a configuration triplet as an argument, it must be
4496fully canonicalized. You can see the canonical version of a triplet by
252b5132
RH
4497running the shell script @file{config.sub} which is included with the
4498sources.
4499
4500Some sample configuration triplets are: @samp{m68k-hp-bsd},
4501@samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}.
4502
c7c55b78 4503@subheading @command{objdump} Target
252b5132
RH
4504
4505Ways to specify:
4506
4507@enumerate
4508@item
c7c55b78 4509command line option: @option{-b} or @option{--target}
252b5132
RH
4510
4511@item
4512environment variable @code{GNUTARGET}
4513
4514@item
4515deduced from the input file
4516@end enumerate
4517
c7c55b78 4518@subheading @command{objcopy} and @command{strip} Input Target
252b5132
RH
4519
4520Ways to specify:
4521
4522@enumerate
4523@item
c7c55b78 4524command line options: @option{-I} or @option{--input-target}, or @option{-F} or @option{--target}
252b5132
RH
4525
4526@item
4527environment variable @code{GNUTARGET}
4528
4529@item
4530deduced from the input file
4531@end enumerate
4532
c7c55b78 4533@subheading @command{objcopy} and @command{strip} Output Target
252b5132
RH
4534
4535Ways to specify:
4536
4537@enumerate
4538@item
c7c55b78 4539command line options: @option{-O} or @option{--output-target}, or @option{-F} or @option{--target}
252b5132
RH
4540
4541@item
c7c55b78 4542the input target (see ``@command{objcopy} and @command{strip} Input Target'' above)
252b5132
RH
4543
4544@item
4545environment variable @code{GNUTARGET}
4546
4547@item
4548deduced from the input file
4549@end enumerate
4550
c7c55b78 4551@subheading @command{nm}, @command{size}, and @command{strings} Target
252b5132
RH
4552
4553Ways to specify:
4554
4555@enumerate
4556@item
c7c55b78 4557command line option: @option{--target}
252b5132
RH
4558
4559@item
4560environment variable @code{GNUTARGET}
4561
4562@item
4563deduced from the input file
4564@end enumerate
4565
252b5132 4566@node Architecture Selection
947ed062 4567@section Architecture Selection
252b5132
RH
4568
4569An @dfn{architecture} is a type of @sc{cpu} on which an object file is
4570to run. Its name may contain a colon, separating the name of the
4571processor family from the name of the particular @sc{cpu}.
4572
4573The command to list valid architecture values is @samp{objdump -i} (the
4574second column contains the relevant information).
4575
4576Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}.
4577
c7c55b78 4578@subheading @command{objdump} Architecture
252b5132
RH
4579
4580Ways to specify:
4581
4582@enumerate
4583@item
c7c55b78 4584command line option: @option{-m} or @option{--architecture}
252b5132
RH
4585
4586@item
4587deduced from the input file
4588@end enumerate
4589
c7c55b78 4590@subheading @command{objcopy}, @command{nm}, @command{size}, @command{strings} Architecture
252b5132
RH
4591
4592Ways to specify:
4593
4594@enumerate
4595@item
4596deduced from the input file
4597@end enumerate
4598
252b5132
RH
4599@node Reporting Bugs
4600@chapter Reporting Bugs
4601@cindex bugs
4602@cindex reporting bugs
4603
4604Your bug reports play an essential role in making the binary utilities
4605reliable.
4606
4607Reporting a bug may help you by bringing a solution to your problem, or
4608it may not. But in any case the principal function of a bug report is
4609to help the entire community by making the next version of the binary
4610utilities work better. Bug reports are your contribution to their
4611maintenance.
4612
4613In order for a bug report to serve its purpose, you must include the
4614information that enables us to fix the bug.
4615
4616@menu
4617* Bug Criteria:: Have you found a bug?
4618* Bug Reporting:: How to report bugs
4619@end menu
4620
4621@node Bug Criteria
947ed062 4622@section Have You Found a Bug?
252b5132
RH
4623@cindex bug criteria
4624
4625If you are not sure whether you have found a bug, here are some guidelines:
4626
4627@itemize @bullet
4628@cindex fatal signal
4629@cindex crash
4630@item
4631If a binary utility gets a fatal signal, for any input whatever, that is
4632a bug. Reliable utilities never crash.
4633
4634@cindex error on valid input
4635@item
4636If a binary utility produces an error message for valid input, that is a
4637bug.
4638
4639@item
4640If you are an experienced user of binary utilities, your suggestions for
4641improvement are welcome in any case.
4642@end itemize
4643
4644@node Bug Reporting
947ed062 4645@section How to Report Bugs
252b5132
RH
4646@cindex bug reports
4647@cindex bugs, reporting
4648
4649A number of companies and individuals offer support for @sc{gnu}
4650products. If you obtained the binary utilities from a support
4651organization, we recommend you contact that organization first.
4652
4653You can find contact information for many support companies and
4654individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
4655distribution.
4656
ad22bfe8 4657@ifset BUGURL
252b5132 4658In any event, we also recommend that you send bug reports for the binary
ad22bfe8
JM
4659utilities to @value{BUGURL}.
4660@end ifset
252b5132
RH
4661
4662The fundamental principle of reporting bugs usefully is this:
4663@strong{report all the facts}. If you are not sure whether to state a
4664fact or leave it out, state it!
4665
4666Often people omit facts because they think they know what causes the
4667problem and assume that some details do not matter. Thus, you might
4668assume that the name of a file you use in an example does not matter.
4669Well, probably it does not, but one cannot be sure. Perhaps the bug is
4670a stray memory reference which happens to fetch from the location where
4671that pathname is stored in memory; perhaps, if the pathname were
4672different, the contents of that location would fool the utility into
4673doing the right thing despite the bug. Play it safe and give a
4674specific, complete example. That is the easiest thing for you to do,
4675and the most helpful.
4676
4677Keep in mind that the purpose of a bug report is to enable us to fix the bug if
4678it is new to us. Therefore, always write your bug reports on the assumption
4679that the bug has not been reported previously.
4680
4681Sometimes people give a few sketchy facts and ask, ``Does this ring a
947ed062
NC
4682bell?'' This cannot help us fix a bug, so it is basically useless. We
4683respond by asking for enough details to enable us to investigate.
4684You might as well expedite matters by sending them to begin with.
252b5132
RH
4685
4686To enable us to fix the bug, you should include all these things:
4687
4688@itemize @bullet
4689@item
4690The version of the utility. Each utility announces it if you start it
c7c55b78 4691with the @option{--version} argument.
252b5132
RH
4692
4693Without this, we will not know whether there is any point in looking for
4694the bug in the current version of the binary utilities.
4695
4696@item
4697Any patches you may have applied to the source, including any patches
4698made to the @code{BFD} library.
4699
4700@item
4701The type of machine you are using, and the operating system name and
4702version number.
4703
4704@item
4705What compiler (and its version) was used to compile the utilities---e.g.
4706``@code{gcc-2.7}''.
4707
4708@item
4709The command arguments you gave the utility to observe the bug. To
4710guarantee you will not omit something important, list them all. A copy
4711of the Makefile (or the output from make) is sufficient.
4712
4713If we were to try to guess the arguments, we would probably guess wrong
4714and then we might not encounter the bug.
4715
4716@item
4717A complete input file, or set of input files, that will reproduce the
4718bug. If the utility is reading an object file or files, then it is
ad22bfe8 4719generally most helpful to send the actual object files.
252b5132
RH
4720
4721If the source files were produced exclusively using @sc{gnu} programs
c7c55b78 4722(e.g., @command{gcc}, @command{gas}, and/or the @sc{gnu} @command{ld}), then it
252b5132 4723may be OK to send the source files rather than the object files. In
c7c55b78 4724this case, be sure to say exactly what version of @command{gcc}, or
252b5132 4725whatever, was used to produce the object files. Also say how
c7c55b78 4726@command{gcc}, or whatever, was configured.
252b5132
RH
4727
4728@item
4729A description of what behavior you observe that you believe is
4730incorrect. For example, ``It gets a fatal signal.''
4731
4732Of course, if the bug is that the utility gets a fatal signal, then we
4733will certainly notice it. But if the bug is incorrect output, we might
4734not notice unless it is glaringly wrong. You might as well not give us
4735a chance to make a mistake.
4736
4737Even if the problem you experience is a fatal signal, you should still
f20a759a 4738say so explicitly. Suppose something strange is going on, such as your
b45619c0 4739copy of the utility is out of sync, or you have encountered a bug in
252b5132
RH
4740the C library on your system. (This has happened!) Your copy might
4741crash and ours would not. If you told us to expect a crash, then when
4742ours fails to crash, we would know that the bug was not happening for
4743us. If you had not told us to expect a crash, then we would not be able
4744to draw any conclusion from our observations.
4745
4746@item
4747If you wish to suggest changes to the source, send us context diffs, as
c7c55b78 4748generated by @command{diff} with the @option{-u}, @option{-c}, or @option{-p}
252b5132 4749option. Always send diffs from the old file to the new file. If you
c7c55b78 4750wish to discuss something in the @command{ld} source, refer to it by
f20a759a 4751context, not by line number.
252b5132
RH
4752
4753The line numbers in our development sources will not match those in your
4754sources. Your line numbers would convey no useful information to us.
4755@end itemize
4756
4757Here are some things that are not necessary:
4758
4759@itemize @bullet
4760@item
4761A description of the envelope of the bug.
4762
4763Often people who encounter a bug spend a lot of time investigating
4764which changes to the input file will make the bug go away and which
4765changes will not affect it.
4766
4767This is often time consuming and not very useful, because the way we
4768will find the bug is by running a single example under the debugger
4769with breakpoints, not by pure deduction from a series of examples.
4770We recommend that you save your time for something else.
4771
4772Of course, if you can find a simpler example to report @emph{instead}
4773of the original one, that is a convenience for us. Errors in the
4774output will be easier to spot, running under the debugger will take
4775less time, and so on.
4776
4777However, simplification is not vital; if you do not want to do this,
4778report the bug anyway and send us the entire test case you used.
4779
4780@item
4781A patch for the bug.
4782
4783A patch for the bug does help us if it is a good one. But do not omit
4784the necessary information, such as the test case, on the assumption that
4785a patch is all we need. We might see problems with your patch and decide
4786to fix the problem another way, or we might not understand it at all.
4787
4788Sometimes with programs as complicated as the binary utilities it is
4789very hard to construct an example that will make the program follow a
4790certain path through the code. If you do not send us the example, we
4791will not be able to construct one, so we will not be able to verify that
4792the bug is fixed.
4793
4794And if we cannot understand what bug you are trying to fix, or why your
4795patch should be an improvement, we will not install it. A test case will
4796help us to understand.
4797
4798@item
4799A guess about what the bug is or what it depends on.
4800
4801Such guesses are usually wrong. Even we cannot guess right about such
4802things without first using the debugger to find the facts.
4803@end itemize
4804
fff279a7
NC
4805@node GNU Free Documentation License
4806@appendix GNU Free Documentation License
b3364cb9 4807
947ed062 4808@include fdl.texi
cf055d54 4809
fa0d8a3e
NC
4810@node Binutils Index
4811@unnumbered Binutils Index
252b5132
RH
4812
4813@printindex cp
4814
252b5132 4815@bye
This page took 0.807962 seconds and 4 git commands to generate.