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