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