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