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