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