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