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