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