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