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