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