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