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