binutils.texi: added nlmconv chapter
[binutils-gdb.git] / binutils / binutils.texi
1 \input texinfo @c -*- Texinfo -*-
2 @setfilename binutils.info
3
4 @ifinfo
5 @format
6 START-INFO-DIR-ENTRY
7 * Binutils:: The GNU binary utilities "ar", "ld", "objcopy",
8 "objdump", "nm", "size", "strings", "strip", and "ranlib".
9 END-INFO-DIR-ENTRY
10 @end format
11 @end ifinfo
12
13 @ifinfo
14 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
15
16 Permission is granted to make and distribute verbatim copies of
17 this manual provided the copyright notice and this permission notice
18 are preserved on all copies.
19
20 @ignore
21 Permission is granted to process this file through TeX and print the
22 results, provided the printed document carries a copying permission
23 notice identical to this one except for the removal of this paragraph
24 (this paragraph not being relevant to the printed manual).
25
26 @end ignore
27
28 Permission is granted to copy and distribute modified versions of this
29 manual under the conditions for verbatim copying, provided also that
30 the entire resulting derived work is distributed under the terms of a
31 permission notice identical to this one.
32
33 Permission is granted to copy and distribute translations of this manual
34 into another language, under the above conditions for modified versions.
35 @end ifinfo
36
37 @synindex ky cp
38 @c
39 @c This file documents the GNU binary utilities "ar", "ld", "objcopy",
40 @c "objdump", "nm", "size", "strings", "strip", and "ranlib".
41 @c
42 @c Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
43 @c
44 @c This text may be freely distributed under the terms of the GNU
45 @c General Public License.
46 @c
47
48 @setchapternewpage odd
49 @settitle GNU Binary Utilities
50 @c @smallbook
51 @c @cropmarks
52 @titlepage
53 @finalout
54 @title The GNU Binary Utilities
55 @subtitle Version 2.2
56 @sp 1
57 @subtitle May 1993
58 @author Roland H. Pesch
59 @author Cygnus Support
60 @page
61
62 @tex
63 {\parskip=0pt \hfill Cygnus Support\par \hfill
64 \TeX{}info \texinfoversion\par }
65 @end tex
66
67 @vskip 0pt plus 1filll
68 Copyright @copyright{} 1991, 1992, 1993 Free Software Foundation, Inc.
69
70 Permission is granted to make and distribute verbatim copies of
71 this manual provided the copyright notice and this permission notice
72 are preserved on all copies.
73
74 Permission is granted to copy and distribute modified versions of this
75 manual under the conditions for verbatim copying, provided also that
76 the entire resulting derived work is distributed under the terms of a
77 permission notice identical to this one.
78
79 Permission is granted to copy and distribute translations of this manual
80 into another language, under the above conditions for modified versions.
81 @end titlepage
82
83 @node Top, ar, (dir), (dir)
84 @chapter Introduction
85
86 @cindex version
87 This brief manual contains preliminary documentation for the GNU binary
88 utilities (collectively version 2.2):
89
90 @iftex
91 @table @code
92 @item ar
93 Create, modify, and extract from archives
94
95 @item nm
96 List symbols from object files
97
98 @item objcopy
99 Copy and translate object files
100
101 @item objdump
102 Display information from object files
103
104 @item ranlib
105 Generate index to archive contents
106
107 @item size
108 List section sizes and total size
109
110 @item strings
111 List printable strings from files
112
113 @item strip
114 Discard symbols
115 @end table
116 @end iftex
117
118 @menu
119 * ar:: Create, modify, and extract from archives
120 * ld:(ld)Overview. Combine object and archive files
121 * nm:: List symbols from object files
122 * objcopy:: Copy and translate object files
123 * objdump:: Display information from object files
124 * ranlib:: Generate index to archive contents
125 * size:: List section sizes and total size
126 * strings:: List printable strings from files
127 * strip:: Discard symbols
128 * c++filt:: Filter to demangle encoded C++ symbols
129 * nlmconv:: Converts object code into an NLM
130 * Index::
131 @end menu
132
133 @node ar, nm, Top, Top
134 @chapter ar
135
136 @kindex ar
137 @cindex archives
138 @cindex collections of files
139 @smallexample
140 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
141 ar -M [ <mri-script ]
142 @end smallexample
143
144 The GNU @code{ar} program creates, modifies, and extracts from
145 archives. An @dfn{archive} is a single file holding a collection of
146 other files in a structure that makes it possible to retrieve
147 the original individual files (called @dfn{members} of the archive).
148
149 The original files' contents, mode (permissions), timestamp, owner, and
150 group are preserved in the archive, and can be restored on
151 extraction.
152
153 @cindex name length
154 GNU @code{ar} can maintain archives whose members have names of any
155 length; however, depending on how @code{ar} is configured on your
156 system, a limit on member-name length may be imposed for compatibility
157 with archive formats maintained with other tools. If it exists, the
158 limit is often 15 characters (typical of formats related to a.out) or 16
159 characters (typical of formats related to coff).
160
161 @cindex libraries
162 @code{ar} is considered a binary utility because archives of this sort
163 are most often used as @dfn{libraries} holding commonly needed
164 subroutines.
165
166 @cindex symbol index
167 @code{ar} creates an index to the symbols defined in relocatable
168 object modules in the archive when you specify the modifier @samp{s}.
169 Once created, this index is updated in the archive whenever @code{ar}
170 makes a change to its contents (save for the @samp{q} update operation).
171 An archive with such an index speeds up linking to the library, and
172 allows routines in the library to call each other without regard to
173 their placement in the archive.
174
175 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index
176 table. If an archive lacks the table, another form of @code{ar} called
177 @code{ranlib} can be used to add just the table.
178
179 @cindex compatibility, @code{ar}
180 @cindex @code{ar} compatibility
181 GNU @code{ar} is designed to be compatible with two different
182 facilities. You can control its activity using command-line options,
183 like the different varieties of @code{ar} on Unix systems; or, if you
184 specify the single command-line option @samp{-M}, you can control it
185 with a script supplied via standard input, like the MRI ``librarian''
186 program.
187
188 @menu
189 * ar-cmdline:: Controlling @code{ar} on the command line
190 * ar-scripts:: Controlling @code{ar} with a script
191 @end menu
192
193 @page
194 @node ar-cmdline, ar-scripts, ar, ar
195 @section Controlling @code{ar} on the command line
196
197 @smallexample
198 ar [-]@var{p}[@var{mod} [@var{relpos}]] @var{archive} [@var{member}@dots{}]
199 @end smallexample
200
201 @cindex Unix compatibility, @code{ar}
202 When you use @code{ar} in the Unix style, @code{ar} insists on at least two
203 arguments to execute: one keyletter specifying the @emph{operation}
204 (optionally accompanied by other keyletters specifying
205 @emph{modifiers}), and the archive name to act on.
206
207 Most operations can also accept further @var{member} arguments,
208 specifying particular files to operate on.
209
210 GNU @code{ar} allows you to mix the operation code @var{p} and modifier
211 flags @var{mod} in any order, within the first command-line argument.
212
213 If you wish, you may begin the first command-line argument with a
214 dash.
215
216 @cindex operations on archive
217 The @var{p} keyletter specifies what operation to execute; it may be
218 any of the following, but you must specify only one of them:
219
220 @table @code
221 @item d
222 @cindex deleting from archive
223 @emph{Delete} modules from the archive. Specify the names of modules to
224 be deleted as @var{member}@dots{}; the archive is untouched if you
225 specify no files to delete.
226
227 If you specify the @samp{v} modifier, @code{ar} lists each module
228 as it is deleted.
229
230 @item m
231 @cindex moving in archive
232 Use this operation to @emph{move} members in an archive.
233
234 The ordering of members in an archive can make a difference in how
235 programs are linked using the library, if a symbol is defined in more
236 than one member.
237
238 If no modifiers are used with @code{m}, any members you name in the
239 @var{member} arguments are moved to the @emph{end} of the archive;
240 you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a
241 specified place instead.
242
243 @item p
244 @cindex printing from archive
245 @emph{Print} the specified members of the archive, to the standard
246 output file. If the @samp{v} modifier is specified, show the member
247 name before copying its contents to standard output.
248
249 If you specify no @var{member} arguments, all the files in the archive are
250 printed.
251
252 @item q
253 @cindex quick append to archive
254 @emph{Quick append}; add the files @var{member}@dots{} to the end of
255 @var{archive}, without checking for replacement.
256
257 The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this
258 operation; new members are always placed at the end of the archive.
259
260 The modifier @samp{v} makes @code{ar} list each file as it is appended.
261
262 Since the point of this operation is speed, the archive's symbol table
263 index is not updated, even if it already existed; you can use @samp{ar s} or
264 @code{ranlib} explicitly to update the symbol table index.
265
266 @item r
267 @cindex replacement in archive
268 Insert the files @var{member}@dots{} into @var{archive} (with
269 @emph{replacement}). This operation differs from @samp{q} in that any
270 previously existing members are deleted if their names match those being
271 added.
272
273 If one of the files named in @var{member}@dots{} does not exist, @code{ar}
274 displays an error message, and leaves undisturbed any existing members
275 of the archive matching that name.
276
277 By default, new members are added at the end of the file; but you may
278 use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request
279 placement relative to some existing member.
280
281 The modifier @samp{v} used with this operation elicits a line of
282 output for each file inserted, along with one of the letters @samp{a} or
283 @samp{r} to indicate whether the file was appended (no old member
284 deleted) or replaced.
285
286 @item t
287 @cindex contents of archive
288 Display a @emph{table} listing the contents of @var{archive}, or those
289 of the files listed in @var{member}@dots{} that are present in the
290 archive. Normally only the member name is shown; if you also want to
291 see the modes (permissions), timestamp, owner, group, and size, you can
292 request that by also specifying the @samp{v} modifier.
293
294 If you do not specify a @var{member}, all files in the archive
295 are listed.
296
297 @cindex repeated names in archive
298 @cindex name duplication in archive
299 If there is more than one file with the same name (say, @samp{fie}) in
300 an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the
301 first instance; to see them all, you must ask for a complete
302 listing---in our example, @samp{ar t b.a}.
303 @c WRS only; per Gumby, this is implementation-dependent, and in a more
304 @c recent case in fact works the other way.
305
306 @item x
307 @cindex extract from archive
308 @emph{Extract} members (named @var{member}) from the archive. You can
309 use the @samp{v} modifier with this operation, to request that
310 @code{ar} list each name as it extracts it.
311
312 If you do not specify a @var{member}, all files in the archive
313 are extracted.
314
315 @end table
316
317 A number of modifiers (@var{mod}) may immediately follow the @var{p}
318 keyletter, to specify variations on an operation's behavior:
319
320 @table @code
321 @item a
322 @cindex relative placement in archive
323 Add new files @emph{after} an existing member of the
324 archive. If you use the modifier @samp{a}, the name of an existing archive
325 member must be present as the @var{relpos} argument, before the
326 @var{archive} specification.
327
328 @item b
329 Add new files @emph{before} an existing member of the
330 archive. If you use the modifier @samp{b}, the name of an existing archive
331 member must be present as the @var{relpos} argument, before the
332 @var{archive} specification. (same as @samp{i}).
333
334 @item c
335 @cindex creating archives
336 @emph{Create} the archive. The specified @var{archive} is always
337 created if it did not exist, when you request an update. But a warning is
338 issued unless you specify in advance that you expect to create it, by
339 using this modifier.
340
341 @item i
342 Insert new files @emph{before} an existing member of the
343 archive. If you use the modifier @samp{i}, the name of an existing archive
344 member must be present as the @var{relpos} argument, before the
345 @var{archive} specification. (same as @samp{b}).
346
347 @item l
348 This modifier is accepted but not used.
349 @c whaffor ar l modifier??? presumably compat; with
350 @c what???---pesch@@cygnus.com, 25jan91
351
352 @item o
353 @cindex dates in archive
354 Preserve the @emph{original} dates of members when extracting them. If
355 you do not specify this modifier, files extracted from the archive
356 are stamped with the time of extraction.
357
358 @item s
359 @cindex writing archive index
360 Write an object-file index into the archive, or update an existing one,
361 even if no other change is made to the archive. You may use this modifier
362 flag either with any operation, or alone. Running @samp{ar s} on an
363 archive is equivalent to running @samp{ranlib} on it.
364
365 @item u
366 @cindex updating an archive
367 Normally, @samp{ar r}@dots{} inserts all files
368 listed into the archive. If you would like to insert @emph{only} those
369 of the files you list that are newer than existing members of the same
370 names, use this modifier. The @samp{u} modifier is allowed only for the
371 operation @samp{r} (replace). In particular, the combination @samp{qu} is
372 not allowed, since checking the timestamps would lose any speed
373 advantage from the operation @samp{q}.
374
375 @item v
376 This modifier requests the @emph{verbose} version of an operation. Many
377 operations display additional information, such as filenames processed,
378 when the modifier @samp{v} is appended.
379
380 @item V
381 This modifier shows the version number of @code{ar}.
382 @end table
383
384 @node ar-scripts, , ar-cmdline, ar
385 @section Controlling @code{ar} with a script
386
387 @smallexample
388 ar -M [ <@var{script} ]
389 @end smallexample
390
391 @cindex MRI compatibility, @code{ar}
392 @cindex scripts, @code{ar}
393 If you use the single command-line option @samp{-M} with @code{ar}, you
394 can control its operation with a rudimentary command language. This
395 form of @code{ar} operates interactively if standard input is coming
396 directly from a terminal. During interactive use, @code{ar} prompts for
397 input (the prompt is @samp{AR >}), and continues executing even after
398 errors. If you redirect standard input to a script file, no prompts are
399 issued, and @code{ar} abandons execution (with a nonzero exit code)
400 on any error.
401
402 The @code{ar} command language is @emph{not} designed to be equivalent
403 to the command-line options; in fact, it provides somewhat less control
404 over archives. The only purpose of the command language is to ease the
405 transition to GNU @code{ar} for developers who already have scripts
406 written for the MRI ``librarian'' program.
407
408 The syntax for the @code{ar} command language is straightforward:
409 @itemize @bullet
410 @item
411 commands are recognized in upper or lower case; for example, @code{LIST}
412 is the same as @code{list}. In the following descriptions, commands are
413 shown in upper case for clarity.
414
415 @item
416 a single command may appear on each line; it is the first word on the
417 line.
418
419 @item
420 empty lines are allowed, and have no effect.
421
422 @item
423 comments are allowed; text after either of the characters @samp{*}
424 or @samp{;} is ignored.
425
426 @item
427 Whenever you use a list of names as part of the argument to an @code{ar}
428 command, you can separate the individual names with either commas or
429 blanks. Commas are shown in the explanations below, for clarity.
430
431 @item
432 @samp{+} is used as a line continuation character; if @samp{+} appears
433 at the end of a line, the text on the following line is considered part
434 of the current command.
435 @end itemize
436
437 Here are the commands you can use in @code{ar} scripts, or when using
438 @code{ar} interactively. Three of them have special significance:
439
440 @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is
441 a temporary file required for most of the other commands.
442
443 @code{SAVE} commits the changes so far specified by the script. Prior
444 to @code{SAVE}, commands affect only the temporary copy of the current
445 archive.
446
447 @table @code
448 @item ADDLIB @var{archive}
449 @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module})
450 Add all the contents of @var{archive} (or, if specified, each named
451 @var{module} from @var{archive}) to the current archive.
452
453 Requires prior use of @code{OPEN} or @code{CREATE}.
454
455 @item ADDMOD @var{member}, @var{member}, @dots{} @var{member}
456 @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}"
457 @c else like "ar q..."
458 Add each named @var{member} as a module in the current archive.
459
460 Requires prior use of @code{OPEN} or @code{CREATE}.
461
462 @item CLEAR
463 Discard the contents of the current archive, cancelling the effect of
464 any operations since the last @code{SAVE}. May be executed (with no
465 effect) even if no current archive is specified.
466
467 @item CREATE @var{archive}
468 Creates an archive, and makes it the current archive (required for many
469 other commands). The new archive is created with a temporary name; it
470 is not actually saved as @var{archive} until you use @code{SAVE}.
471 You can overwrite existing archives; similarly, the contents of any
472 existing file named @var{archive} will not be destroyed until @code{SAVE}.
473
474 @item DELETE @var{module}, @var{module}, @dots{} @var{module}
475 Delete each listed @var{module} from the current archive; equivalent to
476 @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}.
477
478 Requires prior use of @code{OPEN} or @code{CREATE}.
479
480 @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module})
481 @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile}
482 List each named @var{module} present in @var{archive}. The separate
483 command @code{VERBOSE} specifies the form of the output: when verbose
484 output is off, output is like that of @samp{ar -t @var{archive}
485 @var{module}@dots{}}. When verbose output is on, the listing is like
486 @samp{ar -tv @var{archive} @var{module}@dots{}}.
487
488 Output normally goes to the standard output stream; however, if you
489 specify @var{outputfile} as a final argument, @code{ar} directs the
490 output to that file.
491
492 @item END
493 Exit from @code{ar}, with a @code{0} exit code to indicate successful
494 completion. This command does not save the output file; if you have
495 changed the current archive since the last @code{SAVE} command, those
496 changes are lost.
497
498 @item EXTRACT @var{module}, @var{module}, @dots{} @var{module}
499 Extract each named @var{module} from the current archive, writing them
500 into the current directory as separate files. Equivalent to @samp{ar -x
501 @var{archive} @var{module}@dots{}}.
502
503 Requires prior use of @code{OPEN} or @code{CREATE}.
504
505 @ignore
506 @c FIXME Tokens but no commands???
507 @item FULLDIR
508
509 @item HELP
510 @end ignore
511
512 @item LIST
513 Display full contents of the current archive, in ``verbose'' style
514 regardless of the state of @code{VERBOSE}. The effect is like @samp{ar
515 tv @var{archive}}). (This single command is a GNU @code{ld}
516 enhancement, rather than present for MRI compatibility.)
517
518 Requires prior use of @code{OPEN} or @code{CREATE}.
519
520 @item OPEN @var{archive}
521 Opens an existing archive for use as the current archive (required for
522 many other commands). Any changes as the result of subsequent commands
523 will not actually affect @var{archive} until you next use @code{SAVE}.
524
525 @item REPLACE @var{module}, @var{module}, @dots{} @var{module}
526 In the current archive, replace each existing @var{module} (named in
527 the @code{REPLACE} arguments) from files in the current working directory.
528 To execute this command without errors, both the file, and the module in
529 the current archive, must exist.
530
531 Requires prior use of @code{OPEN} or @code{CREATE}.
532
533 @item VERBOSE
534 Toggle an internal flag governing the output from @code{DIRECTORY}.
535 When the flag is on, @code{DIRECTORY} output matches output from
536 @samp{ar -tv }@dots{}.
537
538 @item SAVE
539 Commit your changes to the current archive, and actually save it as a
540 file with the name specified in the last @code{CREATE} or @code{OPEN}
541 command.
542
543 Requires prior use of @code{OPEN} or @code{CREATE}.
544
545 @end table
546
547 @iftex
548 @node ld
549 @chapter ld
550 @cindex linker
551 @kindex ld
552 The GNU linker @code{ld} is now described in a separate manual.
553 @xref{Top,, Overview,, Using LD: the GNU linker}.
554 @end iftex
555
556 @node nm, objcopy, ar, Top
557 @chapter nm
558 @cindex symbols
559 @kindex nm
560
561 @smallexample
562 nm [ -a | --debug-syms ] [ -g | --extern-only ]
563 [ -B ] [ -C | --demangle ]
564 [ -s | --print-armap ] [ -A | -o | --print-file-name ]
565 [ -n | -v | --numeric-sort ] [ -p | --no-sort ]
566 [ -r | --reverse-sort ] [ -u | --undefined-only ]
567 [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ]
568 [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ]
569 [ -V | --version ] [ --help ] [ @var{objfile}@dots{} ]
570 @end smallexample
571
572 GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}.
573 If no object files are listed as arguments, @code{nm} assumes
574 @file{a.out}.
575
576 For each symbol, @code{nm} shows:
577
578 @itemize @bullet
579 @item
580 The symbol value, in the radix selected by options (see below), or
581 hexadecimal by default.
582
583 @item
584 The symbol type. At least the following types are used; others are, as
585 well, depending on the object file format. If lowercase, the symbol is
586 local; if uppercase, the symbol is global (external).
587
588 @c Some more detail on exactly what these symbol types are used for
589 @c would be nice.
590 @table @code
591 @item A
592 Absolute.
593
594 @item B
595 BSS (uninitialized data).
596
597 @item C
598 Common.
599
600 @item D
601 Initialized data.
602
603 @item I
604 Indirect reference.
605
606 @item T
607 Text (program code).
608
609 @item U
610 Undefined.
611 @end table
612
613 @item
614 The symbol name.
615 @end itemize
616
617 The long and short forms of options, shown here as alternatives, are
618 equivalent.
619
620 @table @code
621 @item -A
622 @itemx -o
623 @itemx --print-file-name
624 @cindex input file name
625 @cindex file name
626 @cindex source file name
627 Precede each symbol by the name of the input file (or archive element)
628 in which it was found, rather than identifying the input file once only,
629 before all of its symbols.
630
631 @item -a
632 @itemx --debug-syms
633 @cindex debugging symbols
634 Display all symbols, even debugger-only symbols; normally these are not
635 listed.
636
637 @item -B
638 @cindex @code{nm} format
639 @cindex @code{nm} compatibility
640 The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
641
642 @item -C
643 @itemx --demangle
644 @cindex demangling C++ symbols
645 Decode (@dfn{demangle}) low-level symbol names into user-level names.
646 Besides removing any initial underscore prepended by the system, this
647 makes C++ function names readable. @xref{c++filt}, for more information
648 on demangling.
649
650 @item -f @var{format}
651 @itemx --format=@var{format}
652 @cindex @code{nm} format
653 @cindex @code{nm} compatibility
654 Use the output format @var{format}, which can be @code{bsd},
655 @code{sysv}, or @code{posix}. The default is @code{bsd}.
656 Only the first character of @var{format} is significant; it can be
657 either upper or lower case.
658
659 @item -g
660 @itemx --extern-only
661 @cindex external symbols
662 Display only external symbols.
663
664 @item -n
665 @itemx -v
666 @itemx --numeric-sort
667 Sort symbols numerically by their addresses, rather than alphabetically
668 by their names.
669
670 @item -p
671 @itemx --no-sort
672 @cindex sorting symbols
673 Do not bother to sort the symbols in any order; print them in the order
674 encountered.
675
676 @item -P
677 @itemx --portability
678 Use the POSIX.2 standard output format instead of the default format.
679 Equivalent to @samp{-f posix}.
680
681 @item -s
682 @itemx --print-armap
683 @cindex symbol index, listing
684 When listing symbols from archive members, include the index: a mapping
685 (stored in the archive by @code{ar} or @code{ranlib}) of which modules
686 contain definitions for which names.
687
688 @item -r
689 @itemx --reverse-sort
690 Reverse the order of the sort (whether numeric or alphabetic); let the
691 last come first.
692
693 @item -t @var{radix}
694 @itemx --radix=@var{radix}
695 Use @var{radix} as the radix for printing the symbol values. It must be
696 @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal.
697
698 @item --target=@var{bfdname}
699 @cindex object code format
700 Specify an object code format other than your system's default format.
701 @xref{objdump}, for information on listing available formats.
702
703 @item -u
704 @itemx --undefined-only
705 @cindex external symbols
706 @cindex undefined symbols
707 Display only undefined symbols (those external to each object file).
708
709 @item -V
710 @itemx --version
711 Show the version number of @code{nm} and exit.
712
713 @item --help
714 Show a summary of the options to @code{nm} and exit.
715 @end table
716
717 @node objcopy, objdump, nm, Top
718 @chapter objcopy
719
720 @smallexample
721 objcopy [ -F @var{format} | --format=@var{format} ]
722 [ -I @var{format} | --input-format=@var{format} ]
723 [ -O @var{format} | --output-format=@var{format} ]
724 [ -S | --strip-all ] [ -g | --strip-debug ]
725 [ -x | --discard-all ] [ -X | --discard-locals ]
726 [ -v | --verbose ] [ -V | --version ] [ --help ]
727 @var{infile} [@var{outfile}]
728 @end smallexample
729
730 The GNU @code{objcopy} utility copies the contents of an object file to
731 another. @code{objcopy} uses the GNU BFD Library to read and write the
732 object files. It can write the destination object file in a format
733 different from that of the source object file. The exact behavior of
734 @code{objcopy} is controlled by command-line options.
735
736 @code{objcopy} creates temporary files to do its translations and
737 deletes them afterward. @code{objcopy} uses BFD to do all its
738 translation work; it knows about all the formats BFD knows about, and
739 thus is able to recognize most formats without being told explicitly.
740 @xref{BFD,,BFD,ld.info,Using LD, the GNU linker}.
741
742 @table @code
743 @item @var{infile}
744 @itemx @var{outfile}
745 The source and output files respectively.
746 If you do not specify @var{outfile}, @code{objcopy} creates a
747 temporary file and destructively renames the result with
748 the name of the input file.
749
750 @item -I @var{format}
751 @itemx --input-format=@var{format}
752 Consider the source file's object format to be @var{format}, rather than
753 attempting to deduce it.
754
755 @item -O @var{format}
756 @itemx --output-format=@var{format}
757 Write the output file using the object format @var{format}.
758
759 @item -F @var{format}
760 @itemx --format=@var{format}
761 Use @var{format} as the object format for both the input and the output
762 file; i.e. simply transfer data from source to destination with no
763 translation.
764
765 @item -S
766 @itemx --strip-all
767 Do not copy relocation and symbol information from the source file.
768
769 @item -g
770 @itemx --strip-debug
771 Do not copy debugging symbols from the source file.
772
773 @item -x
774 @itemx --discard-all
775 Do not copy non-global symbols from the source file.
776 @c FIXME any reason to prefer "non-global" to "local" here?
777
778 @item -X
779 @itemx --discard-locals
780 Do not copy compiler-generated local symbols.
781 (These usually start with @samp{L} or @samp{.}.)
782
783 @item -V
784 @itemx --version
785 Show the version number of @code{objcopy}.
786
787 @item -v
788 @itemx --verbose
789 Verbose output: list all object files modified. In the case of
790 archives, @samp{objcopy -V} lists all members of the archive.
791
792 @item --help
793 Show a summary of the options to @code{objcopy}.
794 @end table
795
796 @node objdump, ranlib, objcopy, Top
797 @chapter objdump
798
799 @cindex object file information
800 @kindex objdump
801
802 @smallexample
803 objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ]
804 [ -h | --header ] [ -i ] [ -j @var{section} ] [ -l ]
805 [ -m @var{machine} ] [ -r | --reloc ] [ -s ] [ --stabs ]
806 [ -t | --syms ] [ -x ] [ --version ] [ --help ]
807 @var{objfile}@dots{}
808 @end smallexample
809
810 @code{objdump} displays information about one or more object files.
811 The options control what particular information to display. This
812 information is mostly useful to programmers who are working on the
813 compilation tools, as opposed to programmers who just want their
814 program to compile and work.
815
816 @var{objfile}@dots{} are the object files to be examined. When you
817 specify archives, @code{objdump} shows information on each of the member
818 object files.
819
820 The long and short forms of options, shown here as alternatives, are
821 equivalent. At least one option besides @samp{-l} must be given.
822
823 @table @code
824 @item -a
825 @c print_arelt_descr
826 @cindex archive headers
827 If any of the @var{objfile} files are archives, display the archive
828 header information (in a format similar to @samp{ls -l}). Besides the
829 information you could list with @samp{ar tv}, @samp{objdump -a} shows
830 the object file format of each archive member.
831
832 @c suggest longname --target or --format or --bfd
833 @item -b @var{bfdname}
834 @cindex object code format
835 Specify that the object-code format for the object files is
836 @var{bfdname}. This option may not be necessary; @var{objdump} can
837 automatically recognize many formats.
838
839 For example,
840 @example
841 objdump -b oasys -m vax -h fu.o
842 @end example
843 @noindent
844 displays summary information from the section headers (@samp{-h}) of
845 @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
846 file in the format produced by Oasys compilers. You can list the
847 formats available with the @samp{-i} option.
848
849 @item -d
850 @cindex disassembling object code
851 @cindex machine instructions
852 Disassemble. Display the assembler mnemonics for the machine
853 instructions from @var{objfile}.
854
855 @item -f
856 @cindex object file header
857 File header. Display summary information from the overall header of
858 each of the @var{objfile} files.
859
860 @item -h
861 @itemx --header
862 @cindex section headers
863 Header. Display summary information from the section headers of the
864 object file.
865
866 @item --help
867 Print a summary of the options to @code{objdump} and exit.
868
869 @item -i
870 @cindex architectures available
871 @cindex object formats available
872 Display a list showing all architectures and object formats available
873 for specification with @samp{-b} or @samp{-m}.
874
875 @c suggest longname --section
876 @item -j @var{name}
877 @cindex section information
878 Display information only for section @var{name}.
879
880 @c suggest longname --label or --linespec
881 @item -l
882 @cindex source filenames for object files
883 Label the display (using debugging information) with the source filename
884 and line numbers corresponding to the object code shown.
885
886 @c suggest longname --architecture
887 @item -m @var{machine}
888 @cindex architecture
889 Specify that the object files @var{objfile} are for architecture
890 @var{machine}. You can list available architectures using the @samp{-i}
891 option.
892
893 @item -r
894 @itemx --reloc
895 @cindex relocation entries, in object file
896 Relocation. Print the relocation entries of the file.
897
898 @item -s
899 @cindex sections, full contents
900 @cindex object file sections
901 Display the full contents of any sections requested.
902
903 @item --stabs
904 @cindex stab
905 @cindex .stab
906 @cindex debug symbols
907 @cindex ELF object file format
908 Display the full contents of any sections requested. Display the
909 contents of the .stab and .stab.index and .stab.excl sections from an
910 ELF file. This is only useful on systems (such as Solaris 2.0) in which
911 @code{.stab} debugging symbol-table entries are carried in an ELF
912 section. In most other file formats, debugging symbol-table entries are
913 interleaved with linkage symbols, and are visible in the @samp{--syms}
914 output.
915
916 @item -t
917 @itemx --syms
918 @cindex symbol table entries, printing
919 Symbol Table. Print the symbol table entries of the file.
920 This is similar to the information provided by the @samp{nm} program.
921
922 @item --version
923 Print the version number of @code{objdump} and exit.
924
925 @item -x
926 @cindex all header information, object file
927 @cindex header information, all
928 Display all available header information, including the symbol table and
929 relocation entries. Using @samp{-x} is equivalent to specifying all of
930 @samp{-a -f -h -r -t}.
931 @end table
932
933 @node ranlib, size, objdump, Top
934 @chapter ranlib
935
936 @kindex ranlib
937 @cindex archive contents
938 @cindex symbol index
939
940 @smallexample
941 ranlib [-vV] @var{archive}
942 @end smallexample
943
944 @code{ranlib} generates an index to the contents of an archive and
945 stores it in the archive. The index lists each symbol defined by a
946 member of an archive that is a relocatable object file.
947
948 You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
949
950 An archive with such an index speeds up linking to the library and
951 allows routines in the library to call each other without regard to
952 their placement in the archive.
953
954 The GNU @code{ranlib} program is another form of GNU @code{ar}; running
955 @code{ranlib} is completely equivalent to executing @samp{ar -s}.
956 @xref{ar}.
957
958 @table @code
959 @item -v
960 @itemx -V
961 Show the version number of @code{ranlib}.
962 @end table
963
964 @node size, strings, ranlib, Top
965 @chapter size
966
967 @kindex size
968 @cindex section sizes
969
970 @smallexample
971 size [ -A | -B | --format=@var{compatibility} ]
972 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
973 [ --target=@var{bfdname} ] [ -V | --version ]
974 @var{objfile}@dots{}
975 @end smallexample
976
977 The GNU @code{size} utility lists the section sizes---and the total
978 size---for each of the object or archive files @var{objfile} in its
979 argument list. By default, one line of output is generated for each
980 object file or each module in an archive.
981
982 @var{objfile}@dots{} are the object files to be examined.
983
984 The command line options have the following meanings:
985
986 @table @code
987 @item -A
988 @itemx -B
989 @itemx --format=@var{compatibility}
990 @cindex @code{size} display format
991 Using one of these options, you can choose whether the output from GNU
992 @code{size} resembles output from System V @code{size} (using @samp{-A},
993 or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
994 @samp{--format=berkeley}). The default is the one-line format similar to
995 Berkeley's.
996 @c Bonus for doc-source readers: you can also say --format=strange (or
997 @c anything else that starts with 's') for sysv, and --format=boring (or
998 @c anything else that starts with 'b') for Berkeley.
999
1000 Here is an example of the Berkeley (default) format of output from
1001 @code{size}:
1002 @smallexample
1003 size --format Berkeley ranlib size
1004 text data bss dec hex filename
1005 294880 81920 11592 388392 5ed28 ranlib
1006 294880 81920 11888 388688 5ee50 size
1007 @end smallexample
1008
1009 @noindent
1010 This is the same data, but displayed closer to System V conventions:
1011
1012 @smallexample
1013 size --format SysV ranlib size
1014 ranlib :
1015 section size addr
1016 .text 294880 8192
1017 .data 81920 303104
1018 .bss 11592 385024
1019 Total 388392
1020
1021
1022 size :
1023 section size addr
1024 .text 294880 8192
1025 .data 81920 303104
1026 .bss 11888 385024
1027 Total 388688
1028 @end smallexample
1029
1030 @item --help
1031 Show a summary of acceptable arguments and options.
1032
1033 @item -d
1034 @itemx -o
1035 @itemx -x
1036 @itemx --radix=@var{number}
1037 @cindex @code{size} number format
1038 @cindex radix for section sizes
1039 Using one of these options, you can control whether the size of each
1040 section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1041 (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1042 @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
1043 values (8, 10, 16) are supported. The total size is always given in two
1044 radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1045 octal and hexadecimal if you're using @samp{-o}.
1046
1047 @item --target=@var{bfdname}
1048 @cindex object code format
1049 Specify that the object-code format for @var{objfile} is
1050 @var{bfdname}. This option may not be necessary; @code{size} can
1051 automatically recognize many formats. @xref{objdump}, for information
1052 on listing available formats.
1053
1054 @item -V
1055 @itemx --version
1056 Display the version number of @code{size}.
1057 @end table
1058
1059 @node strings, strip, size, Top
1060 @chapter strings
1061 @kindex strings
1062 @cindex listings strings
1063 @cindex printing strings
1064 @cindex strings, printing
1065
1066 @smallexample
1067 strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-]
1068 [--all] [--print-file-name] [--bytes=@var{min-len}]
1069 [--radix=@var{radix}] [--help] [--version] @var{file}@dots{}
1070 @end smallexample
1071
1072 For each @var{file} given, GNU @code{strings} prints the printable
1073 character sequences that are at least 4 characters long (or the number
1074 given with the options below) and are followed by a NUL or newline
1075 character. By default, it only prints the strings from the initialized
1076 data sections of object files; for other types of files, it prints the
1077 strings from the whole file.
1078
1079 @code{strings} is mainly useful for determining the contents of non-text
1080 files.
1081
1082 @table @code
1083 @item -a
1084 @itemx --all
1085 @itemx -
1086 Do not scan only the initialized data section of object files; scan
1087 the whole files.
1088
1089 @item -f
1090 @itemx --print-file-name
1091 Print the name of the file before each string.
1092
1093 @item --help
1094 Print a summary of the program usage on the standard output and exit.
1095
1096 @itemx -@var{min-len}
1097 @item -n @var{min-len}
1098 @itemx --bytes=@var{min-len}
1099 Print sequences of characters that are at least @var{min-len} characters
1100 long, instead of the default 4.
1101
1102 @item -o
1103 Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o}
1104 act like @samp{-t d} instead. Since we can not be compatible with both
1105 ways, we simply chose one.
1106
1107 @item -t @var{radix}
1108 @itemx --radix=@var{radix}
1109 Print the offset within the file before each string. The single
1110 character argument specifies the radix of the offset---@samp{o} for
1111 octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1112
1113 @item -v
1114 @itemx --version
1115 Print the program version number on the standard output and exit.
1116 @end table
1117
1118 @node strip, c++filt, strings, Top
1119 @chapter strip
1120
1121 @kindex strip
1122 @cindex removing symbols
1123 @cindex discarding symbols
1124 @cindex symbols, discarding
1125
1126 @smallexample
1127 strip [ -F @var{format} | --format=@var{format} | --target=@var{format} ]
1128 [ -I @var{format} | --input-format=@var{format} ]
1129 [ -O @var{format} | --output-format=@var{format} ]
1130 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
1131 [ -x | --discard-all ] [ -X | --discard-locals ]
1132 [ -v | --verbose ] [ -V | --version ] [ --help ]
1133 @var{objfile}@dots{}
1134 @end smallexample
1135
1136 GNU @code{strip} discards all symbols from object files
1137 @var{objfile}. The list of object files may include archives.
1138 At least one object file must be given.
1139
1140 @code{strip} modifies the files named in its argument,
1141 rather than writing modified copies under different names.
1142
1143 @table @code
1144 @item -F @var{format}
1145 @itemx --format=@var{format}
1146 @itemx --target=@var{format}
1147 Treat the original @var{objfile} as a file with the object
1148 code format @var{format}, and rewrite it in the same format.
1149
1150 @item --help
1151 Show a summary of the options to @code{strip} and exit.
1152
1153 @item -I @var{format}
1154 @itemx --input-format=@var{format}
1155 Treat the original @var{objfile} as a file with the object
1156 code format @var{format}.
1157
1158 @item -O @var{format}
1159 @itemx --output-format=@var{format}
1160 Replace @var{objfile} with a file in the output format @var{format}.
1161
1162 @item -s
1163 @itemx --strip-all
1164 Remove all symbols.
1165
1166 @item -g
1167 @itemx -S
1168 @itemx --strip-debug
1169 Remove debugging symbols only.
1170
1171 @item -x
1172 @itemx --discard-all
1173 Remove non-global symbols.
1174
1175 @item -X
1176 @itemx --discard-locals
1177 Remove compiler-generated local symbols.
1178 (These usually start with @samp{L} or @samp{.}.)
1179
1180 @item -V
1181 @itemx --version
1182 Show the version number for @code{strip}.
1183
1184 @item -v
1185 @itemx --verbose
1186 Verbose output: list all object files modified. In the case of
1187 archives, @samp{strip -v} lists all members of the archive.
1188 @end table
1189
1190 @node c++filt, nlmconv, strip, Top
1191 @chapter c++filt
1192
1193 @kindex c++filt
1194 @cindex demangling C++ symbols
1195
1196 @smallexample
1197 c++filt [ -_ | --strip-underscores ]
1198 [ -s @var{format} | --format=@var{format} ]
1199 [ --help ] [ --version ] [ @var{symbol}@dots{} ]
1200 @end smallexample
1201
1202 The C++ language provides function overloading, which means that you can
1203 write many functions with the same name (providing each takes parameters
1204 of different types). All C++ function names are encoded into a
1205 low-level assembly label (this process is known as
1206 @dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1207 decodes (@dfn{demangles}) low-level names into user-level names so that
1208 the linker can keep these overloaded functions from clashing.
1209
1210 Every alphanumeric word (consisting of letters, digits, underscores,
1211 dollars, or periods) seen in the input is a potential label. If the
1212 label decodes into a C++ name, the C++ name replaces the low-level
1213 name in the output.
1214
1215 You can use @code{c++filt} to decipher individual symbols:
1216
1217 @example
1218 c++filt @var{symbol}
1219 @end example
1220
1221 If no @var{symbol} arguments are given, @code{c++filt} reads symbol
1222 names from the standard input and writes the demangled names to the
1223 standard output. All results are printed on the standard output.
1224
1225 @table @code
1226 @item -_
1227 @itemx --strip-underscores
1228 On some systems, both the C and C++ compilers put an underscore in front
1229 of every name. For example, the C name @code{foo} gets the low-level
1230 name @code{_foo}. This option removes the initial underscore.
1231
1232 @item -s @var{format}
1233 @itemx --format=@var{format}
1234 GNU @code{nm} can decode three different methods of mangling, used by
1235 different C++ compilers. The argument to this option selects which
1236 method it uses:
1237
1238 @table @code
1239 @item gnu
1240 the one used by the GNU compiler (the default method)
1241 @item lucid
1242 the one used by the Lucid compiler
1243 @item arm
1244 the one specified by the C++ Annotated Reference Manual
1245 @end table
1246
1247 @item --help
1248 Print a summary of the options to @code{c++filt} and exit.
1249
1250 @item --version
1251 Print the version number of @code{c++filt} and exit.
1252 @end table
1253
1254 @quotation
1255 @emph{Warning:} @code{c++filt} is a new utility, and the details of its
1256 user interface are subject to change in future releases. In particular,
1257 a command-line option may be required in the the future to decode a name
1258 passed as an argument on the command line; in other words,
1259
1260 @example
1261 c++filt @var{symbol}
1262 @end example
1263
1264 @noindent
1265 may in a future release become
1266
1267 @example
1268 c++filt @var{option} @var{symbol}
1269 @end example
1270 @end quotation
1271
1272 @node nlmconv, Index, c++filt, Top
1273 @chapter nlmconv
1274
1275 @code{nlmconv} converts a relocatable object file into a NetWare
1276 Loadable Module. @code{nlmconv} currently only works with @samp{i386}
1277 object files in @code{coff}, @sc{elf}, or @code{a.out} format.
1278
1279 @smallexample
1280 nlmconv [ -I @var{format} | --input-format=@var{format} ]
1281 [ -O @var{format} | --output-format=@var{format} ]
1282 [ -T @var{headerfile} | --header-file=@var{headerfile} ]
1283 [ -h | --help ] [ -V | --version ]
1284 @var{infile} @var{outfile}
1285 @end smallexample
1286
1287 @code{nlmconv} converts the relocatable @samp{i386} object file
1288 @var{infile} into the NetWare Loadable Module @var{outfile}, optionally
1289 reading @var{headerfile} for NLM header information. For instructions
1290 on writing the NLM command file language used in header files, see
1291 @cite{The NetWare Tool Maker Specification Manual}, available from
1292 Novell, Inc. @code{nlmconv} uses the @sc{gnu} Binary File Descriptor
1293 library to read @var{infile}; see @ref{BFD,,BFD,ld.info,Using LD, the
1294 GNU linker}, for more information.
1295
1296 @table @code
1297 @item -I @var{format}
1298 @itemx --input-format=@var{format}
1299 Object format of the input file. @code{nlmconv} can usually determine
1300 the format of a given file (so no default is necessary). @var{format}
1301 arguments are normal BFD names; for a list of these, run
1302 @w{@samp{objdump -i}}.
1303
1304 @item -O @var{format}
1305 @itemx --output-format=@var{format}
1306 Object format of the output file. @code{nlmconv} infers the output
1307 format based on the input format, e.g. for a @samp{i386} input file the
1308 output format is @samp{nlm32-i386}. @var{format} arguments are normal
1309 BFD names; for a list of these, run @w{@samp{objdump -i}}.
1310
1311 @item -T @var{headerfile}
1312 @itemx --header-file=@var{headerfile}
1313 Reads @var{headerfile} for NLM header information. For instructions on
1314 writing the NLM command file language used in header files, see
1315 @cite{The NetWare Tool Maker Specification Manual}, available from
1316 Novell, Inc.
1317
1318 @item -h
1319 @itemx --help
1320 Prints a usage summary.
1321
1322 @item -V
1323 @itemx --version
1324 Prints the version number for @code{nlmconv}.
1325 @end table
1326
1327 @node Index, , nlmconv, Top
1328 @unnumbered Index
1329
1330 @printindex cp
1331
1332 @contents
1333 @bye