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