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