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