* binutils.texi (size): The object file argument is optional.
[binutils-gdb.git] / binutils / binutils.texi
1 \input texinfo @c -*- Texinfo -*-
2 @setfilename binutils.info
3 @include config.texi
4
5 @ifinfo
6 @format
7 START-INFO-DIR-ENTRY
8 * Binutils: (binutils). The GNU binary utilities "ar", "objcopy",
9 "objdump", "nm", "nlmconv", "size",
10 "strings", "strip", and "ranlib".
11 END-INFO-DIR-ENTRY
12 @end format
13 @end ifinfo
14
15 @ifinfo
16 Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
17
18 Permission is granted to make and distribute verbatim copies of
19 this manual provided the copyright notice and this permission notice
20 are preserved on all copies.
21
22 @ignore
23 Permission is granted to process this file through TeX and print the
24 results, provided the printed document carries a copying permission
25 notice identical to this one except for the removal of this paragraph
26 (this paragraph not being relevant to the printed manual).
27
28 @end ignore
29
30 Permission is granted to copy and distribute modified versions of this
31 manual under the conditions for verbatim copying, provided also that
32 the entire resulting derived work is distributed under the terms of a
33 permission notice identical to this one.
34
35 Permission is granted to copy and distribute translations of this manual
36 into another language, under the above conditions for modified versions.
37 @end ifinfo
38
39 @synindex ky cp
40 @c
41 @c This file documents the GNU binary utilities "ar", "ld", "objcopy",
42 @c "objdump", "nm", "size", "strings", "strip", and "ranlib".
43 @c
44 @c Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
45 @c
46 @c This text may be freely distributed under the terms of the GNU
47 @c General Public License.
48 @c
49
50 @setchapternewpage odd
51 @settitle @sc{gnu} Binary Utilities
52 @titlepage
53 @finalout
54 @title The @sc{gnu} Binary Utilities
55 @subtitle Version @value{VERSION}
56 @sp 1
57 @subtitle May 1993
58 @author Roland H. Pesch
59 @author Jeffrey M. Osier
60 @author Cygnus Support
61 @page
62
63 @tex
64 {\parskip=0pt \hfill Cygnus Support\par \hfill
65 \TeX{}info \texinfoversion\par }
66 @end tex
67
68 @vskip 0pt plus 1filll
69 Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
70
71 Permission is granted to make and distribute verbatim copies of
72 this manual provided the copyright notice and this permission notice
73 are preserved on all copies.
74
75 Permission is granted to copy and distribute modified versions of this
76 manual under the conditions for verbatim copying, provided also that
77 the entire resulting derived work is distributed under the terms of a
78 permission notice identical to this one.
79
80 Permission is granted to copy and distribute translations of this manual
81 into another language, under the above conditions for modified versions.
82 @end titlepage
83
84 @node Top
85 @top Introduction
86
87 @cindex version
88 This brief manual contains preliminary documentation for the @sc{gnu} binary
89 utilities (collectively version @value{VERSION}):
90
91 @iftex
92 @table @code
93 @item ar
94 Create, modify, and extract from archives
95
96 @item nm
97 List symbols from object files
98
99 @item objcopy
100 Copy and translate object files
101
102 @item objdump
103 Display information from object files
104
105 @item ranlib
106 Generate index to archive contents
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 c++filt
118 Demangle encoded C++ symbols
119
120 @item addr2line
121 Convert addresses into file names and line numbers
122
123 @item nlmconv
124 Convert object code into a Netware Loadable Module
125
126 @item windres
127 Manipulate Windows resources
128 @end table
129 @end iftex
130
131 @menu
132 * ar:: Create, modify, and extract from archives
133 * nm:: List symbols from object files
134 * objcopy:: Copy and translate object files
135 * objdump:: Display information from object files
136 * ranlib:: Generate index to archive contents
137 * size:: List section sizes and total size
138 * strings:: List printable strings from files
139 * strip:: Discard symbols
140 * c++filt:: Filter to demangle encoded C++ symbols
141 * addr2line:: Convert addresses to file and line
142 * nlmconv:: Converts object code into an NLM
143 * windres:: Manipulate Windows resources
144 * Selecting The Target System:: How these utilities determine the target.
145 * Reporting Bugs:: Reporting Bugs
146 * Index:: Index
147 @end menu
148
149 @node ar
150 @chapter ar
151
152 @kindex ar
153 @cindex archives
154 @cindex collections of files
155 @smallexample
156 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
157 ar -M [ <mri-script ]
158 @end smallexample
159
160 The @sc{gnu} @code{ar} program creates, modifies, and extracts from
161 archives. An @dfn{archive} is a single file holding a collection of
162 other files in a structure that makes it possible to retrieve
163 the original individual files (called @dfn{members} of the archive).
164
165 The original files' contents, mode (permissions), timestamp, owner, and
166 group are preserved in the archive, and can be restored on
167 extraction.
168
169 @cindex name length
170 @sc{gnu} @code{ar} can maintain archives whose members have names of any
171 length; however, depending on how @code{ar} is configured on your
172 system, a limit on member-name length may be imposed for compatibility
173 with archive formats maintained with other tools. If it exists, the
174 limit is often 15 characters (typical of formats related to a.out) or 16
175 characters (typical of formats related to coff).
176
177 @cindex libraries
178 @code{ar} is considered a binary utility because archives of this sort
179 are most often used as @dfn{libraries} holding commonly needed
180 subroutines.
181
182 @cindex symbol index
183 @code{ar} creates an index to the symbols defined in relocatable
184 object modules in the archive when you specify the modifier @samp{s}.
185 Once created, this index is updated in the archive whenever @code{ar}
186 makes a change to its contents (save for the @samp{q} update operation).
187 An archive with such an index speeds up linking to the library, and
188 allows routines in the library to call each other without regard to
189 their placement in the archive.
190
191 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
192 table. If an archive lacks the table, another form of @code{ar} called
193 @code{ranlib} can be used to add just the table.
194
195 @cindex compatibility, @code{ar}
196 @cindex @code{ar} compatibility
197 @sc{gnu} @code{ar} is designed to be compatible with two different
198 facilities. You can control its activity using command-line options,
199 like the different varieties of @code{ar} on Unix systems; or, if you
200 specify the single command-line option @samp{-M}, you can control it
201 with a script supplied via standard input, like the MRI ``librarian''
202 program.
203
204 @menu
205 * ar cmdline:: Controlling @code{ar} on the command line
206 * ar scripts:: Controlling @code{ar} with a script
207 @end menu
208
209 @page
210 @node ar cmdline
211 @section Controlling @code{ar} on the command line
212
213 @smallexample
214 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
215 @end smallexample
216
217 @cindex Unix compatibility, @code{ar}
218 When you use @code{ar} in the Unix style, @code{ar} insists on at least two
219 arguments to execute: one keyletter specifying the @emph{operation}
220 (optionally accompanied by other keyletters specifying
221 @emph{modifiers}), and the archive name to act on.
222
223 Most operations can also accept further @var{member} arguments,
224 specifying particular files to operate on.
225
226 @sc{gnu} @code{ar} allows you to mix the operation code @var{p} and modifier
227 flags @var{mod} in any order, within the first command-line argument.
228
229 If you wish, you may begin the first command-line argument with a
230 dash.
231
232 @cindex operations on archive
233 The @var{p} keyletter specifies what operation to execute; it may be
234 any of the following, but you must specify only one of them:
235
236 @table @code
237 @item d
238 @cindex deleting from archive
239 @emph{Delete} modules from the archive. Specify the names of modules to
240 be deleted as @var{member}@dots{}; the archive is untouched if you
241 specify no files to delete.
242
243 If you specify the @samp{v} modifier, @code{ar} lists each module
244 as it is deleted.
245
246 @item m
247 @cindex moving in archive
248 Use this operation to @emph{move} members in an archive.
249
250 The ordering of members in an archive can make a difference in how
251 programs are linked using the library, if a symbol is defined in more
252 than one member.
253
254 If no modifiers are used with @code{m}, any members you name in the
255 @var{member} arguments are moved to the @emph{end} of the archive;
256 you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
257 specified place instead.
258
259 @item p
260 @cindex printing from archive
261 @emph{Print} the specified members of the archive, to the standard
262 output file. If the @samp{v} modifier is specified, show the member
263 name before copying its contents to standard output.
264
265 If you specify no @var{member} arguments, all the files in the archive are
266 printed.
267
268 @item q
269 @cindex quick append to archive
270 @emph{Quick append}; add the files @var{member}@dots{} to the end of
271 @var{archive}, without checking for replacement.
272
273 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
274 operation; new members are always placed at the end of the archive.
275
276 The modifier @samp{v} makes @code{ar} list each file as it is appended.
277
278 Since the point of this operation is speed, the archive's symbol table
279 index is not updated, even if it already existed; you can use @samp{ar s} or
280 @code{ranlib} explicitly to update the symbol table index.
281
282 @item r
283 @cindex replacement in archive
284 Insert the files @var{member}@dots{} into @var{archive} (with
285 @emph{replacement}). This operation differs from @samp{q} in that any
286 previously existing members are deleted if their names match those being
287 added.
288
289 If one of the files named in @var{member}@dots{} does not exist, @code{ar}
290 displays an error message, and leaves undisturbed any existing members
291 of the archive matching that name.
292
293 By default, new members are added at the end of the file; but you may
294 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
295 placement relative to some existing member.
296
297 The modifier @samp{v} used with this operation elicits a line of
298 output for each file inserted, along with one of the letters @samp{a} or
299 @samp{r} to indicate whether the file was appended (no old member
300 deleted) or replaced.
301
302 @item t
303 @cindex contents of archive
304 Display a @emph{table} listing the contents of @var{archive}, or those
305 of the files listed in @var{member}@dots{} that are present in the
306 archive. Normally only the member name is shown; if you also want to
307 see the modes (permissions), timestamp, owner, group, and size, you can
308 request that by also specifying the @samp{v} modifier.
309
310 If you do not specify a @var{member}, all files in the archive
311 are listed.
312
313 @cindex repeated names in archive
314 @cindex name duplication in archive
315 If there is more than one file with the same name (say, @samp{fie}) in
316 an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
317 first instance; to see them all, you must ask for a complete
318 listing---in our example, @samp{ar t b.a}.
319 @c WRS only; per Gumby, this is implementation-dependent, and in a more
320 @c recent case in fact works the other way.
321
322 @item x
323 @cindex extract from archive
324 @emph{Extract} members (named @var{member}) from the archive. You can
325 use the @samp{v} modifier with this operation, to request that
326 @code{ar} list each name as it extracts it.
327
328 If you do not specify a @var{member}, all files in the archive
329 are extracted.
330
331 @end table
332
333 A number of modifiers (@var{mod}) may immediately follow the @var{p}
334 keyletter, to specify variations on an operation's behavior:
335
336 @table @code
337 @item a
338 @cindex relative placement in archive
339 Add new files @emph{after} an existing member of the
340 archive. If you use the modifier @samp{a}, the name of an existing archive
341 member must be present as the @var{relpos} argument, before the
342 @var{archive} specification.
343
344 @item b
345 Add new files @emph{before} an existing member of the
346 archive. If you use the modifier @samp{b}, the name of an existing archive
347 member must be present as the @var{relpos} argument, before the
348 @var{archive} specification. (same as @samp{i}).
349
350 @item c
351 @cindex creating archives
352 @emph{Create} the archive. The specified @var{archive} is always
353 created if it did not exist, when you request an update. But a warning is
354 issued unless you specify in advance that you expect to create it, by
355 using this modifier.
356
357 @item f
358 Truncate names in the archive. @sc{gnu} @code{ar} will normally permit file
359 names of any length. This will cause it to create archives which are
360 not compatible with the native @code{ar} program on some systems. If
361 this is a concern, the @samp{f} modifier may be used to truncate file
362 names when putting them in the archive.
363
364 @item i
365 Insert new files @emph{before} an existing member of the
366 archive. If you use the modifier @samp{i}, the name of an existing archive
367 member must be present as the @var{relpos} argument, before the
368 @var{archive} specification. (same as @samp{b}).
369
370 @item l
371 This modifier is accepted but not used.
372 @c whaffor ar l modifier??? presumably compat; with
373 @c what???---doc@@cygnus.com, 25jan91
374
375 @item o
376 @cindex dates in archive
377 Preserve the @emph{original} dates of members when extracting them. If
378 you do not specify this modifier, files extracted from the archive
379 are stamped with the time of extraction.
380
381 @item s
382 @cindex writing archive index
383 Write an object-file index into the archive, or update an existing one,
384 even if no other change is made to the archive. You may use this modifier
385 flag either with any operation, or alone. Running @samp{ar s} on an
386 archive is equivalent to running @samp{ranlib} on it.
387
388 @item u
389 @cindex updating an archive
390 Normally, @samp{ar r}@dots{} inserts all files
391 listed into the archive. If you would like to insert @emph{only} those
392 of the files you list that are newer than existing members of the same
393 names, use this modifier. The @samp{u} modifier is allowed only for the
394 operation @samp{r} (replace). In particular, the combination @samp{qu} is
395 not allowed, since checking the timestamps would lose any speed
396 advantage from the operation @samp{q}.
397
398 @item v
399 This modifier requests the @emph{verbose} version of an operation. Many
400 operations display additional information, such as filenames processed,
401 when the modifier @samp{v} is appended.
402
403 @item V
404 This modifier shows the version number of @code{ar}.
405 @end table
406
407 @node ar scripts
408 @section Controlling @code{ar} with a script
409
410 @smallexample
411 ar -M [ <@var{script} ]
412 @end smallexample
413
414 @cindex MRI compatibility, @code{ar}
415 @cindex scripts, @code{ar}
416 If you use the single command-line option @samp{-M} with @code{ar}, you
417 can control its operation with a rudimentary command language. This
418 form of @code{ar} operates interactively if standard input is coming
419 directly from a terminal. During interactive use, @code{ar} prompts for
420 input (the prompt is @samp{AR >}), and continues executing even after
421 errors. If you redirect standard input to a script file, no prompts are
422 issued, and @code{ar} abandons execution (with a nonzero exit code)
423 on any error.
424
425 The @code{ar} command language is @emph{not} designed to be equivalent
426 to the command-line options; in fact, it provides somewhat less control
427 over archives. The only purpose of the command language is to ease the
428 transition to @sc{gnu} @code{ar} for developers who already have scripts
429 written for the MRI ``librarian'' program.
430
431 The syntax for the @code{ar} command language is straightforward:
432 @itemize @bullet
433 @item
434 commands are recognized in upper or lower case; for example, @code{LIST}
435 is the same as @code{list}. In the following descriptions, commands are
436 shown in upper case for clarity.
437
438 @item
439 a single command may appear on each line; it is the first word on the
440 line.
441
442 @item
443 empty lines are allowed, and have no effect.
444
445 @item
446 comments are allowed; text after either of the characters @samp{*}
447 or @samp{;} is ignored.
448
449 @item
450 Whenever you use a list of names as part of the argument to an @code{ar}
451 command, you can separate the individual names with either commas or
452 blanks. Commas are shown in the explanations below, for clarity.
453
454 @item
455 @samp{+} is used as a line continuation character; if @samp{+} appears
456 at the end of a line, the text on the following line is considered part
457 of the current command.
458 @end itemize
459
460 Here are the commands you can use in @code{ar} scripts, or when using
461 @code{ar} interactively. Three of them have special significance:
462
463 @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
464 a temporary file required for most of the other commands.
465
466 @code{SAVE} commits the changes so far specified by the script. Prior
467 to @code{SAVE}, commands affect only the temporary copy of the current
468 archive.
469
470 @table @code
471 @item ADDLIB @var{archive}
472 @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
473 Add all the contents of @var{archive} (or, if specified, each named
474 @var{module} from @var{archive}) to the current archive.
475
476 Requires prior use of @code{OPEN} or @code{CREATE}.
477
478 @item ADDMOD @var{member}, @var{member}, @dots{} @var{member}
479 @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
480 @c else like "ar q..."
481 Add each named @var{member} as a module in the current archive.
482
483 Requires prior use of @code{OPEN} or @code{CREATE}.
484
485 @item CLEAR
486 Discard the contents of the current archive, cancelling the effect of
487 any operations since the last @code{SAVE}. May be executed (with no
488 effect) even if no current archive is specified.
489
490 @item CREATE @var{archive}
491 Creates an archive, and makes it the current archive (required for many
492 other commands). The new archive is created with a temporary name; it
493 is not actually saved as @var{archive} until you use @code{SAVE}.
494 You can overwrite existing archives; similarly, the contents of any
495 existing file named @var{archive} will not be destroyed until @code{SAVE}.
496
497 @item DELETE @var{module}, @var{module}, @dots{} @var{module}
498 Delete each listed @var{module} from the current archive; equivalent to
499 @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
500
501 Requires prior use of @code{OPEN} or @code{CREATE}.
502
503 @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
504 @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
505 List each named @var{module} present in @var{archive}. The separate
506 command @code{VERBOSE} specifies the form of the output: when verbose
507 output is off, output is like that of @samp{ar -t @var{archive}
508 @var{module}@dots{}}. When verbose output is on, the listing is like
509 @samp{ar -tv @var{archive} @var{module}@dots{}}.
510
511 Output normally goes to the standard output stream; however, if you
512 specify @var{outputfile} as a final argument, @code{ar} directs the
513 output to that file.
514
515 @item END
516 Exit from @code{ar}, with a @code{0} exit code to indicate successful
517 completion. This command does not save the output file; if you have
518 changed the current archive since the last @code{SAVE} command, those
519 changes are lost.
520
521 @item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
522 Extract each named @var{module} from the current archive, writing them
523 into the current directory as separate files. Equivalent to @samp{ar -x
524 @var{archive} @var{module}@dots{}}.
525
526 Requires prior use of @code{OPEN} or @code{CREATE}.
527
528 @ignore
529 @c FIXME Tokens but no commands???
530 @item FULLDIR
531
532 @item HELP
533 @end ignore
534
535 @item LIST
536 Display full contents of the current archive, in ``verbose'' style
537 regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
538 tv @var{archive}}). (This single command is a @sc{gnu} @code{ld}
539 enhancement, rather than present for MRI compatibility.)
540
541 Requires prior use of @code{OPEN} or @code{CREATE}.
542
543 @item OPEN @var{archive}
544 Opens an existing archive for use as the current archive (required for
545 many other commands). Any changes as the result of subsequent commands
546 will not actually affect @var{archive} until you next use @code{SAVE}.
547
548 @item REPLACE @var{module}, @var{module}, @dots{} @var{module}
549 In the current archive, replace each existing @var{module} (named in
550 the @code{REPLACE} arguments) from files in the current working directory.
551 To execute this command without errors, both the file, and the module in
552 the current archive, must exist.
553
554 Requires prior use of @code{OPEN} or @code{CREATE}.
555
556 @item VERBOSE
557 Toggle an internal flag governing the output from @code{DIRECTORY}.
558 When the flag is on, @code{DIRECTORY} output matches output from
559 @samp{ar -tv }@dots{}.
560
561 @item SAVE
562 Commit your changes to the current archive, and actually save it as a
563 file with the name specified in the last @code{CREATE} or @code{OPEN}
564 command.
565
566 Requires prior use of @code{OPEN} or @code{CREATE}.
567
568 @end table
569
570 @iftex
571 @node ld
572 @chapter ld
573 @cindex linker
574 @kindex ld
575 The @sc{gnu} linker @code{ld} is now described in a separate manual.
576 @xref{Top,, Overview,, Using LD: the @sc{gnu} linker}.
577 @end iftex
578
579 @node nm
580 @chapter nm
581 @cindex symbols
582 @kindex nm
583
584 @smallexample
585 nm [ -a | --debug-syms ] [ -g | --extern-only ]
586 [ -B ] [ -C | --demangle ] [ -D | --dynamic ]
587 [ -s | --print-armap ] [ -A | -o | --print-file-name ]
588 [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
589 [ -r | --reverse-sort ] [ --size-sort ] [ -u | --undefined-only ]
590 [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ]
591 [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ]
592 [ --defined-only ] [-l | --line-numbers ]
593 [ --no-demangle ] [ -V | --version ] [ --help ] [ @var{objfile}@dots{} ]
594 @end smallexample
595
596 @sc{gnu} @code{nm} lists the symbols from object files @var{objfile}@dots{}.
597 If no object files are listed as arguments, @code{nm} assumes
598 @file{a.out}.
599
600 For each symbol, @code{nm} shows:
601
602 @itemize @bullet
603 @item
604 The symbol value, in the radix selected by options (see below), or
605 hexadecimal by default.
606
607 @item
608 The symbol type. At least the following types are used; others are, as
609 well, depending on the object file format. If lowercase, the symbol is
610 local; if uppercase, the symbol is global (external).
611
612 @c Some more detail on exactly what these symbol types are used for
613 @c would be nice.
614 @table @code
615 @item A
616 The symbol's value is absolute, and will not be changed by further
617 linking.
618
619 @item B
620 The symbol is in the uninitialized data section (known as BSS).
621
622 @item C
623 The symbol is common. Common symbols are uninitialized data. When
624 linking, multiple common symbols may appear with the same name. If the
625 symbol is defined anywhere, the common symbols are treated as undefined
626 references. For more details on common symbols, see the discussion of
627 --warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}.
628
629 @item D
630 The symbol is in the initialized data section.
631
632 @item G
633 The symbol is in an initialized data section for small objects. Some
634 object file formats permit more efficient access to small data objects,
635 such as a global int variable as opposed to a large global array.
636
637 @item I
638 The symbol is an indirect reference to another symbol. This is a GNU
639 extension to the a.out object file format which is rarely used.
640
641 @item N
642 The symbol is a debugging symbol.
643
644 @item R
645 The symbol is in a read only data section.
646
647 @item S
648 The symbol is in an uninitialized data section for small objects.
649
650 @item T
651 The symbol is in the text (code) section.
652
653 @item U
654 The symbol is undefined.
655
656 @item W
657 The symbol is weak. When a weak defined symbol is linked with a normal
658 defined symbol, the normal defined symbol is used with no error. When a
659 weak undefined symbol is linked and the symbol is not defined, the value
660 of the weak symbol becomes zero with no error.
661
662 @item -
663 The symbol is a stabs symbol in an a.out object file. In this case, the
664 next values printed are the stabs other field, the stabs desc field, and
665 the stab type. Stabs symbols are used to hold debugging information;
666 for more information, see @ref{Top,Stabs,Stabs Overview,stabs.info, The
667 ``stabs'' debug format}.
668
669 @item ?
670 The symbol type is unknown, or object file format specific.
671 @end table
672
673 @item
674 The symbol name.
675 @end itemize
676
677 The long and short forms of options, shown here as alternatives, are
678 equivalent.
679
680 @table @code
681 @item -A
682 @itemx -o
683 @itemx --print-file-name
684 @cindex input file name
685 @cindex file name
686 @cindex source file name
687 Precede each symbol by the name of the input file (or archive element)
688 in which it was found, rather than identifying the input file once only,
689 before all of its symbols.
690
691 @item -a
692 @itemx --debug-syms
693 @cindex debugging symbols
694 Display all symbols, even debugger-only symbols; normally these are not
695 listed.
696
697 @item -B
698 @cindex @code{nm} format
699 @cindex @code{nm} compatibility
700 The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
701
702 @item -C
703 @itemx --demangle
704 @cindex demangling in nm
705 Decode (@dfn{demangle}) low-level symbol names into user-level names.
706 Besides removing any initial underscore prepended by the system, this
707 makes C++ function names readable. @xref{c++filt}, for more information
708 on demangling.
709
710 @item --no-demangle
711 Do not demangle low-level symbol names. This is the default.
712
713 @item -D
714 @itemx --dynamic
715 @cindex dynamic symbols
716 Display the dynamic symbols rather than the normal symbols. This is
717 only meaningful for dynamic objects, such as certain types of shared
718 libraries.
719
720 @item -f @var{format}
721 @itemx --format=@var{format}
722 @cindex @code{nm} format
723 @cindex @code{nm} compatibility
724 Use the output format @var{format}, which can be @code{bsd},
725 @code{sysv}, or @code{posix}. The default is @code{bsd}.
726 Only the first character of @var{format} is significant; it can be
727 either upper or lower case.
728
729 @item -g
730 @itemx --extern-only
731 @cindex external symbols
732 Display only external symbols.
733
734 @item -l
735 @itemx --line-numbers
736 @cindex symbol line numbers
737 For each symbol, use debugging information to try to find a filename and
738 line number. For a defined symbol, look for the line number of the
739 address of the symbol. For an undefined symbol, look for the line
740 number of a relocation entry which refers to the symbol. If line number
741 information can be found, print it after the other symbol information.
742
743 @item -n
744 @itemx -v
745 @itemx --numeric-sort
746 Sort symbols numerically by their addresses, rather than alphabetically
747 by their names.
748
749 @item -p
750 @itemx --no-sort
751 @cindex sorting symbols
752 Do not bother to sort the symbols in any order; print them in the order
753 encountered.
754
755 @item -P
756 @itemx --portability
757 Use the POSIX.2 standard output format instead of the default format.
758 Equivalent to @samp{-f posix}.
759
760 @item -s
761 @itemx --print-armap
762 @cindex symbol index, listing
763 When listing symbols from archive members, include the index: a mapping
764 (stored in the archive by @code{ar} or @code{ranlib}) of which modules
765 contain definitions for which names.
766
767 @item -r
768 @itemx --reverse-sort
769 Reverse the order of the sort (whether numeric or alphabetic); let the
770 last come first.
771
772 @item --size-sort
773 Sort symbols by size. The size is computed as the difference between
774 the value of the symbol and the value of the symbol with the next higher
775 value. The size of the symbol is printed, rather than the value.
776
777 @item -t @var{radix}
778 @itemx --radix=@var{radix}
779 Use @var{radix} as the radix for printing the symbol values. It must be
780 @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
781
782 @item --target=@var{bfdname}
783 @cindex object code format
784 Specify an object code format other than your system's default format.
785 @xref{Target Selection}, for more information.
786
787 @item -u
788 @itemx --undefined-only
789 @cindex external symbols
790 @cindex undefined symbols
791 Display only undefined symbols (those external to each object file).
792
793 @item --defined-only
794 @cindex external symbols
795 @cindex undefined symbols
796 Display only defined symbols for each object file.
797
798 @item -V
799 @itemx --version
800 Show the version number of @code{nm} and exit.
801
802 @item --help
803 Show a summary of the options to @code{nm} and exit.
804 @end table
805
806 @node objcopy
807 @chapter objcopy
808
809 @smallexample
810 objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
811 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
812 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
813 [ -S | --strip-all ] [ -g | --strip-debug ]
814 [ -K @var{symbolname} | --keep-symbol=@var{symbolname} ]
815 [ -N @var{symbolname} | --strip-symbol=@var{symbolname} ]
816 [ -x | --discard-all ] [ -X | --discard-locals ]
817 [ -b @var{byte} | --byte=@var{byte} ]
818 [ -i @var{interleave} | --interleave=@var{interleave} ]
819 [ -R @var{sectionname} | --remove-section=@var{sectionname} ]
820 [ -p | --preserve-dates ] [ --debugging ]
821 [ --gap-fill=@var{val} ] [ --pad-to=@var{address} ]
822 [ --set-start=@var{val} ] [ --adjust-start=@var{incr} ]
823 [ --adjust-vma=@var{incr} ]
824 [ --adjust-section-vma=@var{section}@{=,+,-@}@var{val} ]
825 [ --adjust-warnings ] [ --no-adjust-warnings ]
826 [ --set-section-flags=@var{section}=@var{flags} ]
827 [ --add-section=@var{sectionname}=@var{filename} ]
828 [ --change-leading-char ] [ --remove-leading-char ]
829 [ --weaken ]
830 [ -v | --verbose ] [ -V | --version ] [ --help ]
831 @var{infile} [@var{outfile}]
832 @end smallexample
833
834 The @sc{gnu} @code{objcopy} utility copies the contents of an object
835 file to another. @code{objcopy} uses the @sc{gnu} @sc{bfd} Library to
836 read and write the object files. It can write the destination object
837 file in a format different from that of the source object file. The
838 exact behavior of @code{objcopy} is controlled by command-line options.
839
840 @code{objcopy} creates temporary files to do its translations and
841 deletes them afterward. @code{objcopy} uses @sc{bfd} to do all its
842 translation work; it has access to all the formats described in @sc{bfd}
843 and thus is able to recognize most formats without being told
844 explicitly. @xref{BFD,,BFD,ld.info,Using LD}.
845
846 @code{objcopy} can be used to generate S-records by using an output
847 target of @samp{srec} (e.g., use @samp{-O srec}).
848
849 @code{objcopy} can be used to generate a raw binary file by using an
850 output target of @samp{binary} (e.g., use @samp{-O binary}). When
851 @code{objcopy} generates a raw binary file, it will essentially produce
852 a memory dump of the contents of the input object file. All symbols and
853 relocation information will be discarded. The memory dump will start at
854 the load address of the lowest section copied into the output file.
855
856 When generating an S-record or a raw binary file, it may be helpful to
857 use @samp{-S} to remove sections containing debugging information. In
858 some cases @samp{-R} will be useful to remove sections which contain
859 information which is not needed by the binary file.
860
861 @table @code
862 @item @var{infile}
863 @itemx @var{outfile}
864 The source and output files, respectively.
865 If you do not specify @var{outfile}, @code{objcopy} creates a
866 temporary file and destructively renames the result with
867 the name of @var{infile}.
868
869 @item -I @var{bfdname}
870 @itemx --input-target=@var{bfdname}
871 Consider the source file's object format to be @var{bfdname}, rather than
872 attempting to deduce it. @xref{Target Selection}, for more information.
873
874 @item -O @var{bfdname}
875 @itemx --output-target=@var{bfdname}
876 Write the output file using the object format @var{bfdname}.
877 @xref{Target Selection}, for more information.
878
879 @item -F @var{bfdname}
880 @itemx --target=@var{bfdname}
881 Use @var{bfdname} as the object format for both the input and the output
882 file; i.e., simply transfer data from source to destination with no
883 translation. @xref{Target Selection}, for more information.
884
885 @item -R @var{sectionname}
886 @itemx --remove-section=@var{sectionname}
887 Remove any section named @var{sectionname} from the output file. This
888 option may be given more than once. Note that using this option
889 inappropriately may make the output file unusable.
890
891 @item -S
892 @itemx --strip-all
893 Do not copy relocation and symbol information from the source file.
894
895 @item -g
896 @itemx --strip-debug
897 Do not copy debugging symbols from the source file.
898
899 @item --strip-unneeded
900 Strip all symbols that are not needed for relocation processing.
901
902 @item -K @var{symbolname}
903 @itemx --keep-symbol=@var{symbolname}
904 Copy only symbol @var{symbolname} from the source file. This option may
905 be given more than once.
906
907 @item -N @var{symbolname}
908 @itemx --strip-symbol=@var{symbolname}
909 Do not copy symbol @var{symbolname} from the source file. This option
910 may be given more than once, and may be combined with strip options
911 other than @code{-K}.
912
913 @item -x
914 @itemx --discard-all
915 Do not copy non-global symbols from the source file.
916 @c FIXME any reason to prefer "non-global" to "local" here?
917
918 @item -X
919 @itemx --discard-locals
920 Do not copy compiler-generated local symbols.
921 (These usually start with @samp{L} or @samp{.}.)
922
923 @item -b @var{byte}
924 @itemx --byte=@var{byte}
925 Keep only every @var{byte}th byte of the input file (header data is not
926 affected). @var{byte} can be in the range from 0 to @var{interleave}-1,
927 where @var{interleave} is given by the @samp{-i} or @samp{--interleave}
928 option, or the default of 4. This option is useful for creating files
929 to program @sc{rom}. It is typically used with an @code{srec} output
930 target.
931
932 @item -i @var{interleave}
933 @itemx --interleave=@var{interleave}
934 Only copy one out of every @var{interleave} bytes. Select which byte to
935 copy with the @var{-b} or @samp{--byte} option. The default is 4.
936 @code{objcopy} ignores this option if you do not specify either @samp{-b} or
937 @samp{--byte}.
938
939 @item -p
940 @itemx --preserve-dates
941 Set the access and modification dates of the output file to be the same
942 as those of the input file.
943
944 @item --debugging
945 Convert debugging information, if possible. This is not the default
946 because only certain debugging formats are supported, and the
947 conversion process can be time consuming.
948
949 @item --gap-fill @var{val}
950 Fill gaps between sections with @var{val}. This is done by increasing
951 the size of the section with the lower address, and filling in the extra
952 space created with @var{val}.
953
954 @item --pad-to @var{address}
955 Pad the output file up to the virtual address @var{address}. This is
956 done by increasing the size of the last section. The extra space is
957 filled in with the value specified by @samp{--gap-fill} (default zero).
958
959 @item --set-start @var{val}
960 Set the address of the new file to @var{val}. Not all object file
961 formats support setting the start address.
962
963 @item --adjust-start @var{incr}
964 Adjust the start address by adding @var{incr}. Not all object file
965 formats support setting the start address.
966
967 @item --adjust-vma @var{incr}
968 Adjust the address of all sections, as well as the start address, by
969 adding @var{incr}. Some object file formats do not permit section
970 addresses to be changed arbitrarily. Note that this does not relocate
971 the sections; if the program expects sections to be loaded at a certain
972 address, and this option is used to change the sections such that they
973 are loaded at a different address, the program may fail.
974
975 @item --adjust-section-vma @var{section}@{=,+,-@}@var{val}
976 Set or adjust the address of the named @var{section}. If @samp{=} is
977 used, the section address is set to @var{val}. Otherwise, @var{val} is
978 added to or subtracted from the section address. See the comments under
979 @samp{--adjust-vma}, above. If @var{section} does not exist in the
980 input file, a warning will be issued, unless @samp{--no-adjust-warnings}
981 is used.
982
983 @item --adjust-warnings
984 If @samp{--adjust-section-vma} is used, and the named section does not
985 exist, issue a warning. This is the default.
986
987 @item --no-adjust-warnings
988 Do not issue a warning if @samp{--adjust-section-vma} is used, even if
989 the named section does not exist.
990
991 @item --set-section-flags @var{section}=@var{flags}
992 Set the flags for the named section. The @var{flags} argument is a
993 comma separated string of flag names. The recognized names are
994 @samp{alloc}, @samp{load}, @samp{readonly}, @samp{code}, @samp{data},
995 and @samp{rom}. Not all flags are meaningful for all object file
996 formats.
997
998 @item --add-section @var{sectionname}=@var{filename}
999 Add a new section named @var{sectionname} while copying the file. The
1000 contents of the new section are taken from the file @var{filename}. The
1001 size of the section will be the size of the file. This option only
1002 works on file formats which can support sections with arbitrary names.
1003
1004 @item --change-leading-char
1005 Some object file formats use special characters at the start of
1006 symbols. The most common such character is underscore, which compilers
1007 often add before every symbol. This option tells @code{objcopy} to
1008 change the leading character of every symbol when it converts between
1009 object file formats. If the object file formats use the same leading
1010 character, this option has no effect. Otherwise, it will add a
1011 character, or remove a character, or change a character, as
1012 appropriate.
1013
1014 @item --remove-leading-char
1015 If the first character of a global symbol is a special symbol leading
1016 character used by the object file format, remove the character. The
1017 most common symbol leading character is underscore. This option will
1018 remove a leading underscore from all global symbols. This can be useful
1019 if you want to link together objects of different file formats with
1020 different conventions for symbol names. This is different from
1021 @code{--change-leading-char} because it always changes the symbol name
1022 when appropriate, regardless of the object file format of the output
1023 file.
1024
1025 @item --weaken
1026 Change all global symbols in the file to be weak. This can be useful
1027 when building an object which will be linked against other objects using
1028 the @code{-R} option to the linker. This option is only effective when
1029 using an object file format which supports weak symbols.
1030
1031 @item -V
1032 @itemx --version
1033 Show the version number of @code{objcopy}.
1034
1035 @item -v
1036 @itemx --verbose
1037 Verbose output: list all object files modified. In the case of
1038 archives, @samp{objcopy -V} lists all members of the archive.
1039
1040 @item --help
1041 Show a summary of the options to @code{objcopy}.
1042 @end table
1043
1044 @node objdump
1045 @chapter objdump
1046
1047 @cindex object file information
1048 @kindex objdump
1049
1050 @smallexample
1051 objdump [ -a | --archive-headers ]
1052 [ -b @var{bfdname} | --target=@var{bfdname} ] [ --debugging ]
1053 [ -C | --demangle ] [ -d | --disassemble ]
1054 [ -D | --disassemble-all ] [ --disassemble-zeroes ]
1055 [ -EB | -EL | --endian=@{big | little @} ]
1056 [ -f | --file-headers ]
1057 [ -h | --section-headers | --headers ] [ -i | --info ]
1058 [ -j @var{section} | --section=@var{section} ]
1059 [ -l | --line-numbers ] [ -S | --source ]
1060 [ -m @var{machine} | --architecture=@var{machine} ]
1061 [ -r | --reloc ] [ -R | --dynamic-reloc ]
1062 [ -s | --full-contents ] [ --stabs ]
1063 [ -t | --syms ] [ -T | --dynamic-syms ] [ -x | --all-headers ]
1064 [ -w | --wide ] [ --start-address=@var{address} ]
1065 [ --stop-address=@var{address} ]
1066 [ --prefix-addresses] [ --[no-]show-raw-insn ]
1067 [ --adjust-vma=@var{offset} ]
1068 [ --version ] [ --help ]
1069 @var{objfile}@dots{}
1070 @end smallexample
1071
1072 @code{objdump} displays information about one or more object files.
1073 The options control what particular information to display. This
1074 information is mostly useful to programmers who are working on the
1075 compilation tools, as opposed to programmers who just want their
1076 program to compile and work.
1077
1078 @var{objfile}@dots{} are the object files to be examined. When you
1079 specify archives, @code{objdump} shows information on each of the member
1080 object files.
1081
1082 The long and short forms of options, shown here as alternatives, are
1083 equivalent. At least one option besides @samp{-l} must be given.
1084
1085 @table @code
1086 @item -a
1087 @itemx --archive-header
1088 @cindex archive headers
1089 If any of the @var{objfile} files are archives, display the archive
1090 header information (in a format similar to @samp{ls -l}). Besides the
1091 information you could list with @samp{ar tv}, @samp{objdump -a} shows
1092 the object file format of each archive member.
1093
1094 @item --adjust-vma=@var{offset}
1095 @cindex section addresses in objdump
1096 @cindex VMA in objdump
1097 When dumping information, first add @var{offset} to all the section
1098 addresses. This is useful if the section addresses do not correspond to
1099 the symbol table, which can happen when putting sections at particular
1100 addresses when using a format which can not represent section addresses,
1101 such as a.out.
1102
1103 @item -b @var{bfdname}
1104 @itemx --target=@var{bfdname}
1105 @cindex object code format
1106 Specify that the object-code format for the object files is
1107 @var{bfdname}. This option may not be necessary; @var{objdump} can
1108 automatically recognize many formats.
1109
1110 For example,
1111 @example
1112 objdump -b oasys -m vax -h fu.o
1113 @end example
1114 @noindent
1115 displays summary information from the section headers (@samp{-h}) of
1116 @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
1117 file in the format produced by Oasys compilers. You can list the
1118 formats available with the @samp{-i} option.
1119 @xref{Target Selection}, for more information.
1120
1121 @item -C
1122 @itemx --demangle
1123 @cindex demangling in objdump
1124 Decode (@dfn{demangle}) low-level symbol names into user-level names.
1125 Besides removing any initial underscore prepended by the system, this
1126 makes C++ function names readable. @xref{c++filt}, for more information
1127 on demangling.
1128
1129 @item --debugging
1130 Display debugging information. This attempts to parse debugging
1131 information stored in the file and print it out using a C like syntax.
1132 Only certain types of debugging information have been implemented.
1133
1134 @item -d
1135 @itemx --disassemble
1136 @cindex disassembling object code
1137 @cindex machine instructions
1138 Display the assembler mnemonics for the machine instructions from
1139 @var{objfile}. This option only disassembles those sections which are
1140 expected to contain instructions.
1141
1142 @item -D
1143 @itemx --disassemble-all
1144 Like @samp{-d}, but disassemble the contents of all sections, not just
1145 those expected to contain instructions.
1146
1147 @item --prefix-addresses
1148 When disassembling, print the complete address on each line. This is
1149 the older disassembly format.
1150
1151 @item --disassemble-zeroes
1152 Normally the disassembly output will skip blocks of zeroes. This
1153 option directs the disassembler to disassemble those blocks, just like
1154 any other data.
1155
1156 @item -EB
1157 @itemx -EL
1158 @itemx --endian=@{big|little@}
1159 @cindex endianness
1160 @cindex disassembly endianness
1161 Specify the endianness of the object files. This only affects
1162 disassembly. This can be useful when disassembling a file format which
1163 does not describe endianness information, such as S-records.
1164
1165 @item -f
1166 @itemx --file-header
1167 @cindex object file header
1168 Display summary information from the overall header of
1169 each of the @var{objfile} files.
1170
1171 @item -h
1172 @itemx --section-header
1173 @itemx --header
1174 @cindex section headers
1175 Display summary information from the section headers of the
1176 object file.
1177
1178 File segments may be relocated to nonstandard addresses, for example by
1179 using the @samp{-Ttext}, @samp{-Tdata}, or @samp{-Tbss} options to
1180 @code{ld}. However, some object file formats, such as a.out, do not
1181 store the starting address of the file segments. In those situations,
1182 although @code{ld} relocates the sections correctly, using @samp{objdump
1183 -h} to list the file section headers cannot show the correct addresses.
1184 Instead, it shows the usual addresses, which are implicit for the
1185 target.
1186
1187 @item --help
1188 Print a summary of the options to @code{objdump} and exit.
1189
1190 @item -i
1191 @itemx --info
1192 @cindex architectures available
1193 @cindex object formats available
1194 Display a list showing all architectures and object formats available
1195 for specification with @samp{-b} or @samp{-m}.
1196
1197 @item -j @var{name}
1198 @itemx --section=@var{name}
1199 @cindex section information
1200 Display information only for section @var{name}.
1201
1202 @item -l
1203 @itemx --line-numbers
1204 @cindex source filenames for object files
1205 Label the display (using debugging information) with the filename and
1206 source line numbers corresponding to the object code or relocs shown.
1207 Only useful with @samp{-d}, @samp{-D}, or @samp{-r}.
1208
1209 @item -m @var{machine}
1210 @itemx --architecture=@var{machine}
1211 @cindex architecture
1212 @cindex disassembly architecture
1213 Specify the architecture to use when disassembling object files. This
1214 can be useful when disasembling object files which do not describe
1215 architecture information, such as S-records. You can list the available
1216 architectures with the @samp{-i} option.
1217
1218 @item -r
1219 @itemx --reloc
1220 @cindex relocation entries, in object file
1221 Print the relocation entries of the file. If used with @samp{-d} or
1222 @samp{-D}, the relocations are printed interspersed with the
1223 disassembly.
1224
1225 @item -R
1226 @itemx --dynamic-reloc
1227 @cindex dynamic relocation entries, in object file
1228 Print the dynamic relocation entries of the file. This is only
1229 meaningful for dynamic objects, such as certain types of shared
1230 libraries.
1231
1232 @item -s
1233 @itemx --full-contents
1234 @cindex sections, full contents
1235 @cindex object file sections
1236 Display the full contents of any sections requested.
1237
1238 @item -S
1239 @itemx --source
1240 @cindex source disassembly
1241 @cindex disassembly, with source
1242 Display source code intermixed with disassembly, if possible. Implies
1243 @samp{-d}.
1244
1245 @item --show-raw-insn
1246 When disassembling instructions, print the instruction in hex as well as
1247 in symbolic form. This is the default except when
1248 @code{--prefix-addresses} is used.
1249
1250 @item --no-show-raw-insn
1251 When disassembling instructions, do not print the instruction bytes.
1252 This is the default when @code{--prefix-addresses} is used.
1253
1254 @item --stabs
1255 @cindex stab
1256 @cindex .stab
1257 @cindex debug symbols
1258 @cindex ELF object file format
1259 Display the full contents of any sections requested. Display the
1260 contents of the .stab and .stab.index and .stab.excl sections from an
1261 ELF file. This is only useful on systems (such as Solaris 2.0) in which
1262 @code{.stab} debugging symbol-table entries are carried in an ELF
1263 section. In most other file formats, debugging symbol-table entries are
1264 interleaved with linkage symbols, and are visible in the @samp{--syms}
1265 output. For more information on stabs symbols, see @ref{Top,Stabs,Stabs
1266 Overview,stabs.info, The ``stabs'' debug format}.
1267
1268 @item --start-address=@var{address}
1269 @cindex start-address
1270 Start displaying data at the specified address. This affects the output
1271 of the @code{-d}, @code{-r} and @code{-s} options.
1272
1273 @item --stop-address=@var{address}
1274 @cindex stop-address
1275 Stop displaying data at the specified address. This affects the output
1276 of the @code{-d}, @code{-r} and @code{-s} options.
1277
1278 @item -t
1279 @itemx --syms
1280 @cindex symbol table entries, printing
1281 Print the symbol table entries of the file.
1282 This is similar to the information provided by the @samp{nm} program.
1283
1284 @item -T
1285 @itemx --dynamic-syms
1286 @cindex dynamic symbol table entries, printing
1287 Print the dynamic symbol table entries of the file. This is only
1288 meaningful for dynamic objects, such as certain types of shared
1289 libraries. This is similar to the information provided by the @samp{nm}
1290 program when given the @samp{-D} (@samp{--dynamic}) option.
1291
1292 @item --version
1293 Print the version number of @code{objdump} and exit.
1294
1295 @item -x
1296 @itemx --all-header
1297 @cindex all header information, object file
1298 @cindex header information, all
1299 Display all available header information, including the symbol table and
1300 relocation entries. Using @samp{-x} is equivalent to specifying all of
1301 @samp{-a -f -h -r -t}.
1302
1303 @item -w
1304 @item --wide
1305 @cindex wide output, printing
1306 Format some lines for output devices that have more than 80 columns.
1307 @end table
1308
1309 @node ranlib
1310 @chapter ranlib
1311
1312 @kindex ranlib
1313 @cindex archive contents
1314 @cindex symbol index
1315
1316 @smallexample
1317 ranlib [-vV] @var{archive}
1318 @end smallexample
1319
1320 @code{ranlib} generates an index to the contents of an archive and
1321 stores it in the archive. The index lists each symbol defined by a
1322 member of an archive that is a relocatable object file.
1323
1324 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
1325
1326 An archive with such an index speeds up linking to the library and
1327 allows routines in the library to call each other without regard to
1328 their placement in the archive.
1329
1330 The @sc{gnu} @code{ranlib} program is another form of @sc{gnu} @code{ar}; running
1331 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
1332 @xref{ar}.
1333
1334 @table @code
1335 @item -v
1336 @itemx -V
1337 Show the version number of @code{ranlib}.
1338 @end table
1339
1340 @node size
1341 @chapter size
1342
1343 @kindex size
1344 @cindex section sizes
1345
1346 @smallexample
1347 size [ -A | -B | --format=@var{compatibility} ]
1348 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
1349 [ --target=@var{bfdname} ] [ -V | --version ]
1350 [ @var{objfile}@dots{} ]
1351 @end smallexample
1352
1353 The @sc{gnu} @code{size} utility lists the section sizes---and the total
1354 size---for each of the object or archive files @var{objfile} in its
1355 argument list. By default, one line of output is generated for each
1356 object file or each module in an archive.
1357
1358 @var{objfile}@dots{} are the object files to be examined.
1359 If none are specified, the file @code{a.out} will be used.
1360
1361 The command line options have the following meanings:
1362
1363 @table @code
1364 @item -A
1365 @itemx -B
1366 @itemx --format=@var{compatibility}
1367 @cindex @code{size} display format
1368 Using one of these options, you can choose whether the output from @sc{gnu}
1369 @code{size} resembles output from System V @code{size} (using @samp{-A},
1370 or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
1371 @samp{--format=berkeley}). The default is the one-line format similar to
1372 Berkeley's.
1373 @c Bonus for doc-source readers: you can also say --format=strange (or
1374 @c anything else that starts with 's') for sysv, and --format=boring (or
1375 @c anything else that starts with 'b') for Berkeley.
1376
1377 Here is an example of the Berkeley (default) format of output from
1378 @code{size}:
1379 @smallexample
1380 size --format=Berkeley ranlib size
1381 text data bss dec hex filename
1382 294880 81920 11592 388392 5ed28 ranlib
1383 294880 81920 11888 388688 5ee50 size
1384 @end smallexample
1385
1386 @noindent
1387 This is the same data, but displayed closer to System V conventions:
1388
1389 @smallexample
1390 size --format=SysV ranlib size
1391 ranlib :
1392 section size addr
1393 .text 294880 8192
1394 .data 81920 303104
1395 .bss 11592 385024
1396 Total 388392
1397
1398
1399 size :
1400 section size addr
1401 .text 294880 8192
1402 .data 81920 303104
1403 .bss 11888 385024
1404 Total 388688
1405 @end smallexample
1406
1407 @item --help
1408 Show a summary of acceptable arguments and options.
1409
1410 @item -d
1411 @itemx -o
1412 @itemx -x
1413 @itemx --radix=@var{number}
1414 @cindex @code{size} number format
1415 @cindex radix for section sizes
1416 Using one of these options, you can control whether the size of each
1417 section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1418 (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1419 @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
1420 values (8, 10, 16) are supported. The total size is always given in two
1421 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1422 octal and hexadecimal if you're using @samp{-o}.
1423
1424 @item --target=@var{bfdname}
1425 @cindex object code format
1426 Specify that the object-code format for @var{objfile} is
1427 @var{bfdname}. This option may not be necessary; @code{size} can
1428 automatically recognize many formats.
1429 @xref{Target Selection}, for more information.
1430
1431 @item -V
1432 @itemx --version
1433 Display the version number of @code{size}.
1434 @end table
1435
1436 @node strings
1437 @chapter strings
1438 @kindex strings
1439 @cindex listings strings
1440 @cindex printing strings
1441 @cindex strings, printing
1442
1443 @smallexample
1444 strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-]
1445 [--all] [--print-file-name] [--bytes=@var{min-len}]
1446 [--radix=@var{radix}] [--target=@var{bfdname}]
1447 [--help] [--version] @var{file}@dots{}
1448 @end smallexample
1449
1450 For each @var{file} given, @sc{gnu} @code{strings} prints the printable
1451 character sequences that are at least 4 characters long (or the number
1452 given with the options below) and are followed by an unprintable
1453 character. By default, it only prints the strings from the initialized
1454 and loaded sections of object files; for other types of files, it prints
1455 the strings from the whole file.
1456
1457 @code{strings} is mainly useful for determining the contents of non-text
1458 files.
1459
1460 @table @code
1461 @item -a
1462 @itemx --all
1463 @itemx -
1464 Do not scan only the initialized and loaded sections of object files;
1465 scan the whole files.
1466
1467 @item -f
1468 @itemx --print-file-name
1469 Print the name of the file before each string.
1470
1471 @item --help
1472 Print a summary of the program usage on the standard output and exit.
1473
1474 @itemx -@var{min-len}
1475 @item -n @var{min-len}
1476 @itemx --bytes=@var{min-len}
1477 Print sequences of characters that are at least @var{min-len} characters
1478 long, instead of the default 4.
1479
1480 @item -o
1481 Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o}
1482 act like @samp{-t d} instead. Since we can not be compatible with both
1483 ways, we simply chose one.
1484
1485 @item -t @var{radix}
1486 @itemx --radix=@var{radix}
1487 Print the offset within the file before each string. The single
1488 character argument specifies the radix of the offset---@samp{o} for
1489 octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1490
1491 @item --target=@var{bfdname}
1492 @cindex object code format
1493 Specify an object code format other than your system's default format.
1494 @xref{Target Selection}, for more information.
1495
1496 @item -v
1497 @itemx --version
1498 Print the program version number on the standard output and exit.
1499 @end table
1500
1501 @node strip
1502 @chapter strip
1503
1504 @kindex strip
1505 @cindex removing symbols
1506 @cindex discarding symbols
1507 @cindex symbols, discarding
1508
1509 @smallexample
1510 strip [ -F @var{bfdname} | --target=@var{bfdname} | --target=@var{bfdname} ]
1511 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1512 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
1513 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
1514 [ -K @var{symbolname} | --keep-symbol=@var{symbolname} ]
1515 [ -N @var{symbolname} | --strip-symbol=@var{symbolname} ]
1516 [ -x | --discard-all ] [ -X | --discard-locals ]
1517 [ -R @var{sectionname} | --remove-section=@var{sectionname} ]
1518 [ -o @var{file} ] [ -p | --preserve-dates ]
1519 [ -v | --verbose ] [ -V | --version ] [ --help ]
1520 @var{objfile}@dots{}
1521 @end smallexample
1522
1523 @sc{gnu} @code{strip} discards all symbols from object files
1524 @var{objfile}. The list of object files may include archives.
1525 At least one object file must be given.
1526
1527 @code{strip} modifies the files named in its argument,
1528 rather than writing modified copies under different names.
1529
1530 @table @code
1531 @item -F @var{bfdname}
1532 @itemx --target=@var{bfdname}
1533 Treat the original @var{objfile} as a file with the object
1534 code format @var{bfdname}, and rewrite it in the same format.
1535 @xref{Target Selection}, for more information.
1536
1537 @item --help
1538 Show a summary of the options to @code{strip} and exit.
1539
1540 @item -I @var{bfdname}
1541 @itemx --input-target=@var{bfdname}
1542 Treat the original @var{objfile} as a file with the object
1543 code format @var{bfdname}.
1544 @xref{Target Selection}, for more information.
1545
1546 @item -O @var{bfdname}
1547 @itemx --output-target=@var{bfdname}
1548 Replace @var{objfile} with a file in the output format @var{bfdname}.
1549 @xref{Target Selection}, for more information.
1550
1551 @item -R @var{sectionname}
1552 @itemx --remove-section=@var{sectionname}
1553 Remove any section named @var{sectionname} from the output file. This
1554 option may be given more than once. Note that using this option
1555 inappropriately may make the output file unusable.
1556
1557 @item -s
1558 @itemx --strip-all
1559 Remove all symbols.
1560
1561 @item -g
1562 @itemx -S
1563 @itemx --strip-debug
1564 Remove debugging symbols only.
1565
1566 @item --strip-unneeded
1567 Remove all symbols that are not needed for relocation processing.
1568
1569 @item -K @var{symbolname}
1570 @itemx --keep-symbol=@var{symbolname}
1571 Keep only symbol @var{symbolname} from the source file. This option may
1572 be given more than once.
1573
1574 @item -N @var{symbolname}
1575 @itemx --strip-symbol=@var{symbolname}
1576 Remove symbol @var{symbolname} from the source file. This option may be
1577 given more than once, and may be combined with strip options other than
1578 @code{-K}.
1579
1580 @item -o @var{file}
1581 Put the stripped output in @var{file}, rather than replacing the
1582 existing file. When this argument is used, only one @var{objfile}
1583 argument may be specified.
1584
1585 @item -p
1586 @itemx --preserve-dates
1587 Preserve the access and modification dates of the file.
1588
1589 @item -x
1590 @itemx --discard-all
1591 Remove non-global symbols.
1592
1593 @item -X
1594 @itemx --discard-locals
1595 Remove compiler-generated local symbols.
1596 (These usually start with @samp{L} or @samp{.}.)
1597
1598 @item -V
1599 @itemx --version
1600 Show the version number for @code{strip}.
1601
1602 @item -v
1603 @itemx --verbose
1604 Verbose output: list all object files modified. In the case of
1605 archives, @samp{strip -v} lists all members of the archive.
1606 @end table
1607
1608 @node c++filt
1609 @chapter c++filt
1610
1611 @kindex c++filt
1612 @cindex demangling C++ symbols
1613
1614 @smallexample
1615 c++filt [ -_ | --strip-underscores ]
1616 [ -n | --no-strip-underscores ]
1617 [ -s @var{format} | --format=@var{format} ]
1618 [ --help ] [ --version ] [ @var{symbol}@dots{} ]
1619 @end smallexample
1620
1621 The C++ language provides function overloading, which means that you can
1622 write many functions with the same name (providing each takes parameters
1623 of different types). All C++ function names are encoded into a
1624 low-level assembly label (this process is known as
1625 @dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1626 decodes (@dfn{demangles}) low-level names into user-level names so that
1627 the linker can keep these overloaded functions from clashing.
1628
1629 Every alphanumeric word (consisting of letters, digits, underscores,
1630 dollars, or periods) seen in the input is a potential label. If the
1631 label decodes into a C++ name, the C++ name replaces the low-level
1632 name in the output.
1633
1634 You can use @code{c++filt} to decipher individual symbols:
1635
1636 @example
1637 c++filt @var{symbol}
1638 @end example
1639
1640 If no @var{symbol} arguments are given, @code{c++filt} reads symbol
1641 names from the standard input and writes the demangled names to the
1642 standard output. All results are printed on the standard output.
1643
1644 @table @code
1645 @item -_
1646 @itemx --strip-underscores
1647 On some systems, both the C and C++ compilers put an underscore in front
1648 of every name. For example, the C name @code{foo} gets the low-level
1649 name @code{_foo}. This option removes the initial underscore. Whether
1650 @code{c++filt} removes the underscore by default is target dependent.
1651
1652 @item -n
1653 @itemx --no-strip-underscores
1654 Do not remove the initial underscore.
1655
1656 @item -s @var{format}
1657 @itemx --format=@var{format}
1658 @sc{gnu} @code{nm} can decode three different methods of mangling, used by
1659 different C++ compilers. The argument to this option selects which
1660 method it uses:
1661
1662 @table @code
1663 @item gnu
1664 the one used by the @sc{gnu} compiler (the default method)
1665 @item lucid
1666 the one used by the Lucid compiler
1667 @item arm
1668 the one specified by the C++ Annotated Reference Manual
1669 @end table
1670
1671 @item --help
1672 Print a summary of the options to @code{c++filt} and exit.
1673
1674 @item --version
1675 Print the version number of @code{c++filt} and exit.
1676 @end table
1677
1678 @quotation
1679 @emph{Warning:} @code{c++filt} is a new utility, and the details of its
1680 user interface are subject to change in future releases. In particular,
1681 a command-line option may be required in the the future to decode a name
1682 passed as an argument on the command line; in other words,
1683
1684 @example
1685 c++filt @var{symbol}
1686 @end example
1687
1688 @noindent
1689 may in a future release become
1690
1691 @example
1692 c++filt @var{option} @var{symbol}
1693 @end example
1694 @end quotation
1695
1696 @node addr2line
1697 @chapter addr2line
1698
1699 @kindex addr2line
1700 @cindex address to file name and line number
1701
1702 @smallexample
1703 addr2line [ -b @var{bfdname} | --target=@var{bfdname} ]
1704 [ -C | --demangle ]
1705 [ -e @var{filename} | --exe=@var{filename} ]
1706 [ -f | --functions ] [ -s | --basename ]
1707 [ -H | --help ] [ -V | --version ]
1708 [ addr addr ... ]
1709 @end smallexample
1710
1711 @code{addr2line} translates program addresses into file names and line
1712 numbers. Given an address and an executable, it uses the debugging
1713 information in the executable to figure out which file name and line
1714 number are associated with a given address.
1715
1716 The executable to use is specified with the @code{-e} option. The
1717 default is @file{a.out}.
1718
1719 @code{addr2line} has two modes of operation.
1720
1721 In the first, hexadecimal addresses are specified on the command line,
1722 and @code{addr2line} displays the file name and line number for each
1723 address.
1724
1725 In the second, @code{addr2line} reads hexadecimal addresses from
1726 standard input, and prints the file name and line number for each
1727 address on standard output. In this mode, @code{addr2line} may be used
1728 in a pipe to convert dynamically chosen addresses.
1729
1730 The format of the output is @samp{FILENAME:LINENO}. The file name and
1731 line number for each address is printed on a separate line. If the
1732 @code{-f} option is used, then each @samp{FILENAME:LINENO} line is
1733 preceded by a @samp{FUNCTIONNAME} line which is the name of the function
1734 containing the address.
1735
1736 If the file name or function name can not be determined,
1737 @code{addr2line} will print two question marks in their place. If the
1738 line number can not be determined, @code{addr2line} will print 0.
1739
1740 The long and short forms of options, shown here as alternatives, are
1741 equivalent.
1742
1743 @table @code
1744 @item -b @var{bfdname}
1745 @itemx --target=@var{bfdname}
1746 @cindex object code format
1747 Specify that the object-code format for the object files is
1748 @var{bfdname}.
1749
1750 @item -C
1751 @itemx --demangle
1752 @cindex demangling in objdump
1753 Decode (@dfn{demangle}) low-level symbol names into user-level names.
1754 Besides removing any initial underscore prepended by the system, this
1755 makes C++ function names readable. @xref{c++filt}, for more information
1756 on demangling.
1757
1758 @item -e @var{filename}
1759 @itemx --exe=@var{filename}
1760 Specify the name of the executable for which addresses should be
1761 translated. The default file is @file{a.out}.
1762
1763 @item -f
1764 @itemx --functions
1765 Display function names as well as file and line number information.
1766
1767 @item -s
1768 @itemx --basenames
1769 Display only the base of each file name.
1770 @end table
1771
1772 @node nlmconv
1773 @chapter nlmconv
1774
1775 @code{nlmconv} converts a relocatable object file into a NetWare
1776 Loadable Module.
1777
1778 @ignore
1779 @code{nlmconv} currently works with @samp{i386} object
1780 files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC}
1781 object files in @sc{elf}, or @code{a.out} format@footnote{
1782 @code{nlmconv} should work with any @samp{i386} or @sc{sparc} object
1783 format in the Binary File Descriptor library. It has only been tested
1784 with the above formats.}.
1785 @end ignore
1786
1787 @quotation
1788 @emph{Warning:} @code{nlmconv} is not always built as part of the binary
1789 utilities, since it is only useful for NLM targets.
1790 @end quotation
1791
1792 @smallexample
1793 nlmconv [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1794 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
1795 [ -T @var{headerfile} | --header-file=@var{headerfile} ]
1796 [ -d | --debug] [ -l @var{linker} | --linker=@var{linker} ]
1797 [ -h | --help ] [ -V | --version ]
1798 @var{infile} @var{outfile}
1799 @end smallexample
1800
1801 @code{nlmconv} converts the relocatable @samp{i386} object file
1802 @var{infile} into the NetWare Loadable Module @var{outfile}, optionally
1803 reading @var{headerfile} for NLM header information. For instructions
1804 on writing the NLM command file language used in header files, see the
1805 @samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM
1806 Development and Tools Overview}, which is part of the NLM Software
1807 Developer's Kit (``NLM SDK''), available from Novell, Inc.
1808 @code{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read
1809 @var{infile}; see @ref{BFD,,BFD,ld.info,Using LD}, for
1810 more information.
1811
1812 @code{nlmconv} can perform a link step. In other words, you can list
1813 more than one object file for input if you list them in the definitions
1814 file (rather than simply specifying one input file on the command line).
1815 In this case, @code{nlmconv} calls the linker for you.
1816
1817 @table @code
1818 @item -I @var{bfdname}
1819 @itemx --input-target=@var{bfdname}
1820 Object format of the input file. @code{nlmconv} can usually determine
1821 the format of a given file (so no default is necessary).
1822 @xref{Target Selection}, for more information.
1823
1824 @item -O @var{bfdname}
1825 @itemx --output-target=@var{bfdname}
1826 Object format of the output file. @code{nlmconv} infers the output
1827 format based on the input format, e.g. for a @samp{i386} input file the
1828 output format is @samp{nlm32-i386}.
1829 @xref{Target Selection}, for more information.
1830
1831 @item -T @var{headerfile}
1832 @itemx --header-file=@var{headerfile}
1833 Reads @var{headerfile} for NLM header information. For instructions on
1834 writing the NLM command file language used in header files, see@ see the
1835 @samp{linkers} section, of the @cite{NLM Development and Tools
1836 Overview}, which is part of the NLM Software Developer's Kit, available
1837 from Novell, Inc.
1838
1839 @item -d
1840 @itemx --debug
1841 Displays (on standard error) the linker command line used by @code{nlmconv}.
1842
1843 @item -l @var{linker}
1844 @itemx --linker=@var{linker}
1845 Use @var{linker} for any linking. @var{linker} can be an abosolute or a
1846 relative pathname.
1847
1848 @item -h
1849 @itemx --help
1850 Prints a usage summary.
1851
1852 @item -V
1853 @itemx --version
1854 Prints the version number for @code{nlmconv}.
1855 @end table
1856
1857 @node windres
1858 @chapter windres
1859
1860 @code{windres} may be used to manipulate Windows resources.
1861
1862 @quotation
1863 @emph{Warning:} @code{windres} is not always built as part of the binary
1864 utilities, since it is only useful for Windows targets.
1865 @end quotation
1866
1867 @smallexample
1868 windres [options] [input-file] [output-file]
1869 @end smallexample
1870
1871 @code{windres} reads resources from an input file and copies them into
1872 an output file. Either file may be in one of three formats:
1873
1874 @table @code
1875 @item rc
1876 A text format read by the Resource Compiler.
1877
1878 @item res
1879 A binary format generated by the Resource Compiler.
1880
1881 @item coff
1882 A COFF object or executable.
1883 @end table
1884
1885 The exact description of these different formats is available in
1886 documentation from Microsoft.
1887
1888 When @code{windres} converts from the @code{rc} format to the @code{res}
1889 format, it is acting like the Windows Resource Compiler. When
1890 @code{windres} converts from the @code{res} format to the @code{coff}
1891 format, it is acting like the Windows @code{CVTRES} program.
1892
1893 When @code{windres} generates an @code{rc} file, the output is similar
1894 but not identical to the format expected for the input. When an input
1895 @code{rc} file refers to an external filename, an output @code{rc} file
1896 will instead include the file contents.
1897
1898 If the input or output format is not specified, @code{windres} will
1899 guess based on the file name, or, for the input file, the file contents.
1900 A file with an extension of @file{.rc} will be treated as an @code{rc}
1901 file, a file with an extension of @file{.res} will be treated as a
1902 @code{res} file, and a file with an extension of @file{.o} or
1903 @file{.exe} will be treated as a @code{coff} file.
1904
1905 If no output file is specified, @code{windres} will print the resources
1906 in @code{rc} format to standard output.
1907
1908 The normal use is for you to write an @code{rc} file, use @code{windres}
1909 to convert it to a COFF object file, and then link the COFF file into
1910 your application. This will make the resources described in the
1911 @code{rc} file available to Windows.
1912
1913 @table @code
1914 @item -i @var{filename}
1915 @itemx --input @var{filename}
1916 The name of the input file. If this option is not used, then
1917 @code{windres} will use the first non-option argument as the input file
1918 name. If there are no non-option arguments, then @code{windres} will
1919 read from standard input. @code{windres} can not read a COFF file from
1920 standard input.
1921
1922 @item -o @var{filename}
1923 @itemx --output @var{filename}
1924 The name of the output file. If this option is not used, then
1925 @code{windres} will use the first non-option argument, after any used
1926 for the input file name, as the output file name. If there is no
1927 non-option argument, then @code{windres} will write to standard output.
1928 @code{windres} can not write a COFF file to standard output.
1929
1930 @item -I @var{format}
1931 @itemx --input-format @var{format}
1932 The input format to read. @var{format} may be @samp{res}, @samp{rc}, or
1933 @samp{coff}. If no input format is specified, @code{windres} will
1934 guess, as described above.
1935
1936 @item -O @var{format}
1937 @itemx --output-format @var{format}
1938 The output format to generate. @var{format} may be @samp{res},
1939 @samp{rc}, or @samp{coff}. If no output format is specified,
1940 @code{windres} will guess, as described above.
1941
1942 @item -F @var{target}
1943 @itemx --target @var{target}
1944 Specify the BFD format to use for a COFF file as input or output. This
1945 is a BFD target name; you can use the @code{--help} option to see a list
1946 of supported targets. Normally @code{windres} will use the default
1947 format, which is the first one listed by the @code{--help} option.
1948 @ref{Target Selection}.
1949
1950 @item --preprocessor @var{program}
1951 When @code{windres} reads an @code{rc} file, it runs it through the C
1952 preprocessor first. This option may be used to specify the preprocessor
1953 to use, including any leading arguments. The default preprocessor
1954 argument is @code{gcc -E -xc-header -DRC_INVOKED}.
1955
1956 @item --include-dir @var{directory}
1957 Specify an include directory to use when reading an @code{rc} file.
1958 @code{windres} will pass this to the preprocessor as an @code{-I}
1959 option. @code{windres} will also search this directory when looking for
1960 files named in the @code{rc} file.
1961
1962 @item --define @var{sym[=val]}
1963 Specify a @code{-D} option to pass to the preprocessor when reading an
1964 @code{rc} file.
1965
1966 @item --language @var{val}
1967 Specify the default language to use when reading an @code{rc} file.
1968 @var{val} should be a hexadecimal language code. The low eight bits are
1969 the language, and the high eight bits are the sublanguage.
1970
1971 @item --help
1972 Prints a usage summary.
1973
1974 @item --version
1975 Prints the version number for @code{windres}.
1976
1977 @item --yydebug
1978 If @code{windres} is compiled with @code{YYDEBUG} defined as @code{1},
1979 this will turn on parser debugging.
1980 @end table
1981
1982 @node Selecting The Target System
1983 @chapter Selecting the target system
1984
1985 You can specify three aspects of the target system to the @sc{gnu}
1986 binary file utilities, each in several ways:
1987
1988 @itemize @bullet
1989 @item
1990 the target
1991
1992 @item
1993 the architecture
1994
1995 @item
1996 the linker emulation (which applies to the linker only)
1997 @end itemize
1998
1999 In the following summaries, the lists of ways to specify values are in
2000 order of decreasing precedence. The ways listed first override those
2001 listed later.
2002
2003 The commands to list valid values only list the values for which the
2004 programs you are running were configured. If they were configured with
2005 @samp{--enable-targets=all}, the commands list most of the available
2006 values, but a few are left out; not all targets can be configured in at
2007 once because some of them can only be configured @dfn{native} (on hosts
2008 with the same type as the target system).
2009
2010 @menu
2011 * Target Selection::
2012 * Architecture Selection::
2013 * Linker Emulation Selection::
2014 @end menu
2015
2016 @node Target Selection
2017 @section Target Selection
2018
2019 A @dfn{target} is an object file format. A given target may be
2020 supported for multiple architectures (@pxref{Architecture Selection}).
2021 A target selection may also have variations for different operating
2022 systems or architectures.
2023
2024 The command to list valid target values is @samp{objdump -i}
2025 (the first column of output contains the relevant information).
2026
2027 Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips},
2028 @samp{a.out-sunos-big}.
2029
2030 You can also specify a target using a configuration triplet. This is
2031 the same sort of name that is passed to configure to specify a target.
2032 When you use a configuration triplet as an argument, it must be fully
2033 canonicalized. You can see the canonical version of a triplet by
2034 running the shell script @file{config.sub} which is included with the
2035 sources.
2036
2037 Some sample configuration triplets are: @samp{m68k-hp-bsd},
2038 @samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}.
2039
2040 @subheading @code{objdump} Target
2041
2042 Ways to specify:
2043
2044 @enumerate
2045 @item
2046 command line option: @samp{-b} or @samp{--target}
2047
2048 @item
2049 environment variable @code{GNUTARGET}
2050
2051 @item
2052 deduced from the input file
2053 @end enumerate
2054
2055 @subheading @code{objcopy} and @code{strip} Input Target
2056
2057 Ways to specify:
2058
2059 @enumerate
2060 @item
2061 command line options: @samp{-I} or @samp{--input-target}, or @samp{-F} or @samp{--target}
2062
2063 @item
2064 environment variable @code{GNUTARGET}
2065
2066 @item
2067 deduced from the input file
2068 @end enumerate
2069
2070 @subheading @code{objcopy} and @code{strip} Output Target
2071
2072 Ways to specify:
2073
2074 @enumerate
2075 @item
2076 command line options: @samp{-O} or @samp{--output-target}, or @samp{-F} or @samp{--target}
2077
2078 @item
2079 the input target (see ``@code{objcopy} and @code{strip} Input Target'' above)
2080
2081 @item
2082 environment variable @code{GNUTARGET}
2083
2084 @item
2085 deduced from the input file
2086 @end enumerate
2087
2088 @subheading @code{nm}, @code{size}, and @code{strings} Target
2089
2090 Ways to specify:
2091
2092 @enumerate
2093 @item
2094 command line option: @samp{--target}
2095
2096 @item
2097 environment variable @code{GNUTARGET}
2098
2099 @item
2100 deduced from the input file
2101 @end enumerate
2102
2103 @subheading Linker Input Target
2104
2105 Ways to specify:
2106
2107 @enumerate
2108 @item
2109 command line option: @samp{-b} or @samp{--format}
2110 (@pxref{Options,,Options,ld.info,Using LD})
2111
2112 @item
2113 script command @code{TARGET}
2114 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
2115
2116 @item
2117 environment variable @code{GNUTARGET}
2118 (@pxref{Environment,,Environment,ld.info,Using LD})
2119
2120 @item
2121 the default target of the selected linker emulation
2122 (@pxref{Linker Emulation Selection})
2123 @end enumerate
2124
2125 @subheading Linker Output Target
2126
2127 Ways to specify:
2128
2129 @enumerate
2130 @item
2131 command line option: @samp{-oformat}
2132 (@pxref{Options,,Options,ld.info,Using LD})
2133
2134 @item
2135 script command @code{OUTPUT_FORMAT}
2136 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
2137
2138 @item
2139 the linker input target (see ``Linker Input Target'' above)
2140 @end enumerate
2141
2142 @node Architecture Selection
2143 @section Architecture selection
2144
2145 An @dfn{architecture} is a type of @sc{cpu} on which an object file is
2146 to run. Its name may contain a colon, separating the name of the
2147 processor family from the name of the particular @sc{cpu}.
2148
2149 The command to list valid architecture values is @samp{objdump -i} (the
2150 second column contains the relevant information).
2151
2152 Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}.
2153
2154 @subheading @code{objdump} Architecture
2155
2156 Ways to specify:
2157
2158 @enumerate
2159 @item
2160 command line option: @samp{-m} or @samp{--architecture}
2161
2162 @item
2163 deduced from the input file
2164 @end enumerate
2165
2166 @subheading @code{objcopy}, @code{nm}, @code{size}, @code{strings} Architecture
2167
2168 Ways to specify:
2169
2170 @enumerate
2171 @item
2172 deduced from the input file
2173 @end enumerate
2174
2175 @subheading Linker Input Architecture
2176
2177 Ways to specify:
2178
2179 @enumerate
2180 @item
2181 deduced from the input file
2182 @end enumerate
2183
2184 @subheading Linker Output Architecture
2185
2186 Ways to specify:
2187
2188 @enumerate
2189 @item
2190 script command @code{OUTPUT_ARCH}
2191 (@pxref{Option Commands,,Option Commands,ld.info,Using LD})
2192
2193 @item
2194 the default architecture from the linker output target
2195 (@pxref{Target Selection})
2196 @end enumerate
2197
2198 @node Linker Emulation Selection
2199 @section Linker emulation selection
2200
2201 A linker @dfn{emulation} is a ``personality'' of the linker, which gives
2202 the linker default values for the other aspects of the target system.
2203 In particular, it consists of
2204
2205 @itemize @bullet
2206 @item
2207 the linker script
2208
2209 @item
2210 the target
2211
2212 @item
2213 several ``hook'' functions that are run at certain stages of the linking
2214 process to do special things that some targets require
2215 @end itemize
2216
2217 The command to list valid linker emulation values is @samp{ld -V}.
2218
2219 Sample values: @samp{hp300bsd}, @samp{mipslit}, @samp{sun4}.
2220
2221 Ways to specify:
2222
2223 @enumerate
2224 @item
2225 command line option: @samp{-m}
2226 (@pxref{Options,,Options,ld.info,Using LD})
2227
2228 @item
2229 environment variable @code{LDEMULATION}
2230
2231 @item
2232 compiled-in @code{DEFAULT_EMULATION} from @file{Makefile},
2233 which comes from @code{EMUL} in @file{config/@var{target}.mt}
2234 @end enumerate
2235
2236 @node Reporting Bugs
2237 @chapter Reporting Bugs
2238 @cindex bugs
2239 @cindex reporting bugs
2240
2241 Your bug reports play an essential role in making the binary utilities
2242 reliable.
2243
2244 Reporting a bug may help you by bringing a solution to your problem, or
2245 it may not. But in any case the principal function of a bug report is
2246 to help the entire community by making the next version of the binary
2247 utilities work better. Bug reports are your contribution to their
2248 maintenance.
2249
2250 In order for a bug report to serve its purpose, you must include the
2251 information that enables us to fix the bug.
2252
2253 @menu
2254 * Bug Criteria:: Have you found a bug?
2255 * Bug Reporting:: How to report bugs
2256 @end menu
2257
2258 @node Bug Criteria
2259 @section Have you found a bug?
2260 @cindex bug criteria
2261
2262 If you are not sure whether you have found a bug, here are some guidelines:
2263
2264 @itemize @bullet
2265 @cindex fatal signal
2266 @cindex crash
2267 @item
2268 If a binary utility gets a fatal signal, for any input whatever, that is
2269 a bug. Reliable utilities never crash.
2270
2271 @cindex error on valid input
2272 @item
2273 If a binary utility produces an error message for valid input, that is a
2274 bug.
2275
2276 @item
2277 If you are an experienced user of binary utilities, your suggestions for
2278 improvement are welcome in any case.
2279 @end itemize
2280
2281 @node Bug Reporting
2282 @section How to report bugs
2283 @cindex bug reports
2284 @cindex bugs, reporting
2285
2286 A number of companies and individuals offer support for @sc{gnu}
2287 products. If you obtained the binary utilities from a support
2288 organization, we recommend you contact that organization first.
2289
2290 You can find contact information for many support companies and
2291 individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
2292 distribution.
2293
2294 In any event, we also recommend that you send bug reports for the binary
2295 utilities to @samp{bug-gnu-utils@@prep.ai.mit.edu}.
2296
2297 The fundamental principle of reporting bugs usefully is this:
2298 @strong{report all the facts}. If you are not sure whether to state a
2299 fact or leave it out, state it!
2300
2301 Often people omit facts because they think they know what causes the
2302 problem and assume that some details do not matter. Thus, you might
2303 assume that the name of a file you use in an example does not matter.
2304 Well, probably it does not, but one cannot be sure. Perhaps the bug is
2305 a stray memory reference which happens to fetch from the location where
2306 that pathname is stored in memory; perhaps, if the pathname were
2307 different, the contents of that location would fool the utility into
2308 doing the right thing despite the bug. Play it safe and give a
2309 specific, complete example. That is the easiest thing for you to do,
2310 and the most helpful.
2311
2312 Keep in mind that the purpose of a bug report is to enable us to fix the bug if
2313 it is new to us. Therefore, always write your bug reports on the assumption
2314 that the bug has not been reported previously.
2315
2316 Sometimes people give a few sketchy facts and ask, ``Does this ring a
2317 bell?'' Those bug reports are useless, and we urge everyone to
2318 @emph{refuse to respond to them} except to chide the sender to report
2319 bugs properly.
2320
2321 To enable us to fix the bug, you should include all these things:
2322
2323 @itemize @bullet
2324 @item
2325 The version of the utility. Each utility announces it if you start it
2326 with the @samp{--version} argument.
2327
2328 Without this, we will not know whether there is any point in looking for
2329 the bug in the current version of the binary utilities.
2330
2331 @item
2332 Any patches you may have applied to the source, including any patches
2333 made to the @code{BFD} library.
2334
2335 @item
2336 The type of machine you are using, and the operating system name and
2337 version number.
2338
2339 @item
2340 What compiler (and its version) was used to compile the utilities---e.g.
2341 ``@code{gcc-2.7}''.
2342
2343 @item
2344 The command arguments you gave the utility to observe the bug. To
2345 guarantee you will not omit something important, list them all. A copy
2346 of the Makefile (or the output from make) is sufficient.
2347
2348 If we were to try to guess the arguments, we would probably guess wrong
2349 and then we might not encounter the bug.
2350
2351 @item
2352 A complete input file, or set of input files, that will reproduce the
2353 bug. If the utility is reading an object file or files, then it is
2354 generally most helpful to send the actual object files, uuencoded if
2355 necessary to get them through the mail system. Making them available
2356 for anonymous FTP is not as good, but may be the only reasonable choice
2357 for large object files.
2358
2359 If the source files were produced exclusively using @sc{gnu} programs
2360 (e.g., @code{gcc}, @code{gas}, and/or the @sc{gnu} @code{ld}), then it
2361 may be OK to send the source files rather than the object files. In
2362 this case, be sure to say exactly what version of @code{gcc}, or
2363 whatever, was used to produce the object files. Also say how
2364 @code{gcc}, or whatever, was configured.
2365
2366 @item
2367 A description of what behavior you observe that you believe is
2368 incorrect. For example, ``It gets a fatal signal.''
2369
2370 Of course, if the bug is that the utility gets a fatal signal, then we
2371 will certainly notice it. But if the bug is incorrect output, we might
2372 not notice unless it is glaringly wrong. You might as well not give us
2373 a chance to make a mistake.
2374
2375 Even if the problem you experience is a fatal signal, you should still
2376 say so explicitly. Suppose something strange is going on, such as, your
2377 copy of the utility is out of synch, or you have encountered a bug in
2378 the C library on your system. (This has happened!) Your copy might
2379 crash and ours would not. If you told us to expect a crash, then when
2380 ours fails to crash, we would know that the bug was not happening for
2381 us. If you had not told us to expect a crash, then we would not be able
2382 to draw any conclusion from our observations.
2383
2384 @item
2385 If you wish to suggest changes to the source, send us context diffs, as
2386 generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p}
2387 option. Always send diffs from the old file to the new file. If you
2388 even discuss something in the @code{ld} source, refer to it by context,
2389 not by line number.
2390
2391 The line numbers in our development sources will not match those in your
2392 sources. Your line numbers would convey no useful information to us.
2393 @end itemize
2394
2395 Here are some things that are not necessary:
2396
2397 @itemize @bullet
2398 @item
2399 A description of the envelope of the bug.
2400
2401 Often people who encounter a bug spend a lot of time investigating
2402 which changes to the input file will make the bug go away and which
2403 changes will not affect it.
2404
2405 This is often time consuming and not very useful, because the way we
2406 will find the bug is by running a single example under the debugger
2407 with breakpoints, not by pure deduction from a series of examples.
2408 We recommend that you save your time for something else.
2409
2410 Of course, if you can find a simpler example to report @emph{instead}
2411 of the original one, that is a convenience for us. Errors in the
2412 output will be easier to spot, running under the debugger will take
2413 less time, and so on.
2414
2415 However, simplification is not vital; if you do not want to do this,
2416 report the bug anyway and send us the entire test case you used.
2417
2418 @item
2419 A patch for the bug.
2420
2421 A patch for the bug does help us if it is a good one. But do not omit
2422 the necessary information, such as the test case, on the assumption that
2423 a patch is all we need. We might see problems with your patch and decide
2424 to fix the problem another way, or we might not understand it at all.
2425
2426 Sometimes with programs as complicated as the binary utilities it is
2427 very hard to construct an example that will make the program follow a
2428 certain path through the code. If you do not send us the example, we
2429 will not be able to construct one, so we will not be able to verify that
2430 the bug is fixed.
2431
2432 And if we cannot understand what bug you are trying to fix, or why your
2433 patch should be an improvement, we will not install it. A test case will
2434 help us to understand.
2435
2436 @item
2437 A guess about what the bug is or what it depends on.
2438
2439 Such guesses are usually wrong. Even we cannot guess right about such
2440 things without first using the debugger to find the facts.
2441 @end itemize
2442
2443 @node Index
2444 @unnumbered Index
2445
2446 @printindex cp
2447
2448 @contents
2449 @bye