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