x
[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
JO
1128 [ -m @var{machine} | --architecture=@var{machine} ]
1129 [ -r | --reloc ] [ -R | --dynamic-reloc ]
1130 [ -s | --full-contents ] [ --stabs ]
de3b08ac 1131 [ -t | --syms ] [ -T | --dynamic-syms ] [ -x | --all-headers ]
aa21a2a9 1132 [ -w | --wide ] [ --start-address=@var{address} ]
4cb99ff2 1133 [ --stop-address=@var{address} ]
5c59269f 1134 [ --prefix-addresses] [ --[no-]show-raw-insn ]
ab3a59cf 1135 [ --adjust-vma=@var{offset} ]
458bbd1f 1136 [ --version ] [ --help ]
aa21a2a9 1137 @var{objfile}@dots{}
c72af735
RP
1138@end smallexample
1139
1140@code{objdump} displays information about one or more object files.
1141The options control what particular information to display. This
1142information is mostly useful to programmers who are working on the
1143compilation tools, as opposed to programmers who just want their
1144program to compile and work.
1145
b26ac613
DM
1146@var{objfile}@dots{} are the object files to be examined. When you
1147specify archives, @code{objdump} shows information on each of the member
1148object files.
1149
c72af735 1150The long and short forms of options, shown here as alternatives, are
ed78872a 1151equivalent. At least one option besides @samp{-l} must be given.
c72af735
RP
1152
1153@table @code
c72af735 1154@item -a
eae04238 1155@itemx --archive-header
c72af735 1156@cindex archive headers
ec40bbb8 1157If any of the @var{objfile} files are archives, display the archive
c72af735
RP
1158header information (in a format similar to @samp{ls -l}). Besides the
1159information you could list with @samp{ar tv}, @samp{objdump -a} shows
1160the object file format of each archive member.
1161
ab3a59cf
ILT
1162@item --adjust-vma=@var{offset}
1163@cindex section addresses in objdump
1164@cindex VMA in objdump
1165When dumping information, first add @var{offset} to all the section
1166addresses. This is useful if the section addresses do not correspond to
1167the symbol table, which can happen when putting sections at particular
1168addresses when using a format which can not represent section addresses,
1169such as a.out.
1170
c72af735 1171@item -b @var{bfdname}
eae04238 1172@itemx --target=@var{bfdname}
c72af735 1173@cindex object code format
ec40bbb8
DM
1174Specify that the object-code format for the object files is
1175@var{bfdname}. This option may not be necessary; @var{objdump} can
1176automatically recognize many formats.
1177
1178For example,
c72af735
RP
1179@example
1180objdump -b oasys -m vax -h fu.o
1181@end example
1182@noindent
ec40bbb8
DM
1183displays summary information from the section headers (@samp{-h}) of
1184@file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object
c72af735
RP
1185file in the format produced by Oasys compilers. You can list the
1186formats available with the @samp{-i} option.
eae04238 1187@xref{Target Selection}, for more information.
c72af735 1188
9793039f
ILT
1189@item -C
1190@itemx --demangle
1191@cindex demangling in objdump
1192Decode (@dfn{demangle}) low-level symbol names into user-level names.
1193Besides removing any initial underscore prepended by the system, this
1194makes C++ function names readable. @xref{c++filt}, for more information
1195on demangling.
1196
e1c14599
ILT
1197@item --debugging
1198Display debugging information. This attempts to parse debugging
1199information stored in the file and print it out using a C like syntax.
1200Only certain types of debugging information have been implemented.
1201
c72af735 1202@item -d
eae04238 1203@itemx --disassemble
c72af735
RP
1204@cindex disassembling object code
1205@cindex machine instructions
d5464baa
ILT
1206Display the assembler mnemonics for the machine instructions from
1207@var{objfile}. This option only disassembles those sections which are
1208expected to contain instructions.
1209
1210@item -D
1211@itemx --disassemble-all
1212Like @samp{-d}, but disassemble the contents of all sections, not just
1213those expected to contain instructions.
c72af735 1214
51b8c416
ILT
1215@item --prefix-addresses
1216When disassembling, print the complete address on each line. This is
1217the older disassembly format.
1218
1219@item --disassemble-zeroes
1220Normally the disassembly output will skip blocks of zeroes. This
1221option directs the disassembler to disassemble those blocks, just like
1222any other data.
1223
67c8c901
ILT
1224@item -EB
1225@itemx -EL
1226@itemx --endian=@{big|little@}
1227@cindex endianness
1228@cindex disassembly endianness
1229Specify the endianness of the object files. This only affects
1230disassembly. This can be useful when disassembling a file format which
1231does not describe endianness information, such as S-records.
1232
c72af735 1233@item -f
eae04238 1234@itemx --file-header
c72af735 1235@cindex object file header
eae04238 1236Display summary information from the overall header of
ec40bbb8 1237each of the @var{objfile} files.
c72af735
RP
1238
1239@item -h
eae04238 1240@itemx --section-header
c5f0c938 1241@itemx --header
c72af735 1242@cindex section headers
eae04238 1243Display summary information from the section headers of the
c72af735
RP
1244object file.
1245
db2e6adb
DM
1246File segments may be relocated to nonstandard addresses, for example by
1247using the @samp{-Ttext}, @samp{-Tdata}, or @samp{-Tbss} options to
1248@code{ld}. However, some object file formats, such as a.out, do not
1249store the starting address of the file segments. In those situations,
1250although @code{ld} relocates the sections correctly, using @samp{objdump
1251-h} to list the file section headers cannot show the correct addresses.
1252Instead, it shows the usual addresses, which are implicit for the
1253target.
1254
b26ac613
DM
1255@item --help
1256Print a summary of the options to @code{objdump} and exit.
1257
c72af735 1258@item -i
eae04238 1259@itemx --info
c72af735
RP
1260@cindex architectures available
1261@cindex object formats available
1262Display a list showing all architectures and object formats available
ec40bbb8 1263for specification with @samp{-b} or @samp{-m}.
c72af735 1264
c72af735 1265@item -j @var{name}
eae04238 1266@itemx --section=@var{name}
c72af735 1267@cindex section information
ec40bbb8 1268Display information only for section @var{name}.
c72af735 1269
c72af735 1270@item -l
eae04238 1271@itemx --line-numbers
c72af735 1272@cindex source filenames for object files
11548211
ILT
1273Label the display (using debugging information) with the filename and
1274source line numbers corresponding to the object code or relocs shown.
1275Only useful with @samp{-d}, @samp{-D}, or @samp{-r}.
c72af735 1276
c72af735 1277@item -m @var{machine}
eae04238 1278@itemx --architecture=@var{machine}
c72af735 1279@cindex architecture
67c8c901
ILT
1280@cindex disassembly architecture
1281Specify the architecture to use when disassembling object files. This
061ed861 1282can be useful when disassembling object files which do not describe
67c8c901
ILT
1283architecture information, such as S-records. You can list the available
1284architectures with the @samp{-i} option.
c72af735
RP
1285
1286@item -r
c5f0c938 1287@itemx --reloc
c72af735 1288@cindex relocation entries, in object file
d5464baa
ILT
1289Print the relocation entries of the file. If used with @samp{-d} or
1290@samp{-D}, the relocations are printed interspersed with the
1291disassembly.
c72af735 1292
de3b08ac
ILT
1293@item -R
1294@itemx --dynamic-reloc
1295@cindex dynamic relocation entries, in object file
1296Print the dynamic relocation entries of the file. This is only
1297meaningful for dynamic objects, such as certain types of shared
1298libraries.
1299
c72af735 1300@item -s
eae04238 1301@itemx --full-contents
c72af735
RP
1302@cindex sections, full contents
1303@cindex object file sections
1304Display the full contents of any sections requested.
1305
a8e27cc6
ILT
1306@item -S
1307@itemx --source
1308@cindex source disassembly
1309@cindex disassembly, with source
1310Display source code intermixed with disassembly, if possible. Implies
1311@samp{-d}.
1312
458bbd1f
DE
1313@item --show-raw-insn
1314When disassembling instructions, print the instruction in hex as well as
4cb99ff2
ILT
1315in symbolic form. This is the default except when
1316@code{--prefix-addresses} is used.
458bbd1f 1317
5c59269f
ILT
1318@item --no-show-raw-insn
1319When disassembling instructions, do not print the instruction bytes.
1320This is the default when @code{--prefix-addresses} is used.
1321
c5f0c938
JG
1322@item --stabs
1323@cindex stab
1324@cindex .stab
1325@cindex debug symbols
1326@cindex ELF object file format
c3c93fda
JG
1327Display the full contents of any sections requested. Display the
1328contents of the .stab and .stab.index and .stab.excl sections from an
1329ELF file. This is only useful on systems (such as Solaris 2.0) in which
1330@code{.stab} debugging symbol-table entries are carried in an ELF
1331section. In most other file formats, debugging symbol-table entries are
c5f0c938 1332interleaved with linkage symbols, and are visible in the @samp{--syms}
85d4b870
ILT
1333output. For more information on stabs symbols, see @ref{Top,Stabs,Stabs
1334Overview,stabs.info, The ``stabs'' debug format}.
c5f0c938 1335
aa21a2a9
ILT
1336@item --start-address=@var{address}
1337@cindex start-address
1338Start displaying data at the specified address. This affects the output
1339of the @code{-d}, @code{-r} and @code{-s} options.
1340
1341@item --stop-address=@var{address}
1342@cindex stop-address
1343Stop displaying data at the specified address. This affects the output
1344of the @code{-d}, @code{-r} and @code{-s} options.
1345
c72af735 1346@item -t
c5f0c938 1347@itemx --syms
c72af735 1348@cindex symbol table entries, printing
eae04238 1349Print the symbol table entries of the file.
c72af735
RP
1350This is similar to the information provided by the @samp{nm} program.
1351
de3b08ac
ILT
1352@item -T
1353@itemx --dynamic-syms
1354@cindex dynamic symbol table entries, printing
1355Print the dynamic symbol table entries of the file. This is only
1356meaningful for dynamic objects, such as certain types of shared
1357libraries. This is similar to the information provided by the @samp{nm}
1358program when given the @samp{-D} (@samp{--dynamic}) option.
1359
b26ac613
DM
1360@item --version
1361Print the version number of @code{objdump} and exit.
1362
c72af735 1363@item -x
eae04238 1364@itemx --all-header
c72af735
RP
1365@cindex all header information, object file
1366@cindex header information, all
1367Display all available header information, including the symbol table and
1368relocation entries. Using @samp{-x} is equivalent to specifying all of
1369@samp{-a -f -h -r -t}.
4b6d0f78
MM
1370
1371@item -w
ac0835f2 1372@itemx --wide
4b6d0f78
MM
1373@cindex wide output, printing
1374Format some lines for output devices that have more than 80 columns.
c72af735
RP
1375@end table
1376
eae04238 1377@node ranlib
c72af735
RP
1378@chapter ranlib
1379
1380@kindex ranlib
1381@cindex archive contents
1382@cindex symbol index
1383
1384@smallexample
4d9b5d5a 1385ranlib [-vV] @var{archive}
c72af735
RP
1386@end smallexample
1387
ec40bbb8 1388@code{ranlib} generates an index to the contents of an archive and
c72af735
RP
1389stores it in the archive. The index lists each symbol defined by a
1390member of an archive that is a relocatable object file.
1391
918c2f61 1392You may use @samp{nm -s} or @samp{nm --print-armap} to list this index.
c72af735 1393
ec40bbb8 1394An archive with such an index speeds up linking to the library and
c72af735
RP
1395allows routines in the library to call each other without regard to
1396their placement in the archive.
1397
b94ff924 1398The @sc{gnu} @code{ranlib} program is another form of @sc{gnu} @code{ar}; running
c72af735
RP
1399@code{ranlib} is completely equivalent to executing @samp{ar -s}.
1400@xref{ar}.
1401
4d9b5d5a
DM
1402@table @code
1403@item -v
1404@itemx -V
1405Show the version number of @code{ranlib}.
c3f471a4 1406@end table
4d9b5d5a 1407
eae04238 1408@node size
c72af735
RP
1409@chapter size
1410
1411@kindex size
1412@cindex section sizes
1413
1414@smallexample
4d9b5d5a
DM
1415size [ -A | -B | --format=@var{compatibility} ]
1416 [ --help ] [ -d | -o | -x | --radix=@var{number} ]
1417 [ --target=@var{bfdname} ] [ -V | --version ]
f2843a17 1418 [ @var{objfile}@dots{} ]
c72af735
RP
1419@end smallexample
1420
b94ff924 1421The @sc{gnu} @code{size} utility lists the section sizes---and the total
ec40bbb8
DM
1422size---for each of the object or archive files @var{objfile} in its
1423argument list. By default, one line of output is generated for each
1424object file or each module in an archive.
c72af735 1425
b26ac613 1426@var{objfile}@dots{} are the object files to be examined.
f2843a17 1427If none are specified, the file @code{a.out} will be used.
b26ac613 1428
c72af735 1429The command line options have the following meanings:
c72af735 1430
b26ac613 1431@table @code
c72af735
RP
1432@item -A
1433@itemx -B
ec40bbb8 1434@itemx --format=@var{compatibility}
68dd5295 1435@cindex @code{size} display format
b94ff924 1436Using one of these options, you can choose whether the output from @sc{gnu}
c72af735 1437@code{size} resembles output from System V @code{size} (using @samp{-A},
ec40bbb8
DM
1438or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or
1439@samp{--format=berkeley}). The default is the one-line format similar to
c72af735 1440Berkeley's.
918c2f61
PB
1441@c Bonus for doc-source readers: you can also say --format=strange (or
1442@c anything else that starts with 's') for sysv, and --format=boring (or
c72af735
RP
1443@c anything else that starts with 'b') for Berkeley.
1444
1445Here is an example of the Berkeley (default) format of output from
1446@code{size}:
1447@smallexample
eae04238 1448size --format=Berkeley ranlib size
c72af735
RP
1449text data bss dec hex filename
1450294880 81920 11592 388392 5ed28 ranlib
1451294880 81920 11888 388688 5ee50 size
1452@end smallexample
1453
1454@noindent
1455This is the same data, but displayed closer to System V conventions:
1456
1457@smallexample
eae04238 1458size --format=SysV ranlib size
c72af735
RP
1459ranlib :
1460section size addr
1461.text 294880 8192
1462.data 81920 303104
1463.bss 11592 385024
1464Total 388392
1465
1466
1467size :
1468section size addr
1469.text 294880 8192
1470.data 81920 303104
1471.bss 11888 385024
1472Total 388688
1473@end smallexample
1474
918c2f61 1475@item --help
c72af735
RP
1476Show a summary of acceptable arguments and options.
1477
1478@item -d
1479@itemx -o
1480@itemx -x
ec40bbb8 1481@itemx --radix=@var{number}
68dd5295 1482@cindex @code{size} number format
c72af735
RP
1483@cindex radix for section sizes
1484Using one of these options, you can control whether the size of each
ec40bbb8
DM
1485section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal
1486(@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or
1487@samp{--radix=16}). In @samp{--radix=@var{number}}, only the three
c72af735
RP
1488values (8, 10, 16) are supported. The total size is always given in two
1489radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or
1490octal and hexadecimal if you're using @samp{-o}.
1491
ec40bbb8 1492@item --target=@var{bfdname}
c72af735 1493@cindex object code format
ec40bbb8
DM
1494Specify that the object-code format for @var{objfile} is
1495@var{bfdname}. This option may not be necessary; @code{size} can
eae04238
DM
1496automatically recognize many formats.
1497@xref{Target Selection}, for more information.
c72af735
RP
1498
1499@item -V
918c2f61 1500@itemx --version
4d9b5d5a 1501Display the version number of @code{size}.
c72af735
RP
1502@end table
1503
eae04238 1504@node strings
ba7c8e29
DM
1505@chapter strings
1506@kindex strings
1507@cindex listings strings
1508@cindex printing strings
1509@cindex strings, printing
1510
1511@smallexample
b26ac613 1512strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-]
650a49f0 1513 [--all] [--print-file-name] [--bytes=@var{min-len}]
eae04238
DM
1514 [--radix=@var{radix}] [--target=@var{bfdname}]
1515 [--help] [--version] @var{file}@dots{}
ba7c8e29
DM
1516@end smallexample
1517
b94ff924 1518For each @var{file} given, @sc{gnu} @code{strings} prints the printable
ba7c8e29 1519character sequences that are at least 4 characters long (or the number
67ace729 1520given with the options below) and are followed by an unprintable
ba7c8e29 1521character. By default, it only prints the strings from the initialized
5f057047
ILT
1522and loaded sections of object files; for other types of files, it prints
1523the strings from the whole file.
ba7c8e29
DM
1524
1525@code{strings} is mainly useful for determining the contents of non-text
1526files.
1527
1528@table @code
1529@item -a
1530@itemx --all
1531@itemx -
5f057047
ILT
1532Do not scan only the initialized and loaded sections of object files;
1533scan the whole files.
ba7c8e29
DM
1534
1535@item -f
1536@itemx --print-file-name
1537Print the name of the file before each string.
1538
b26ac613 1539@item --help
ba7c8e29
DM
1540Print a summary of the program usage on the standard output and exit.
1541
ac0835f2
ILT
1542@item -@var{min-len}
1543@itemx -n @var{min-len}
ba7c8e29
DM
1544@itemx --bytes=@var{min-len}
1545Print sequences of characters that are at least @var{min-len} characters
1546long, instead of the default 4.
1547
1548@item -o
b26ac613
DM
1549Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o}
1550act like @samp{-t d} instead. Since we can not be compatible with both
1551ways, we simply chose one.
ba7c8e29
DM
1552
1553@item -t @var{radix}
1554@itemx --radix=@var{radix}
1555Print the offset within the file before each string. The single
1556character argument specifies the radix of the offset---@samp{o} for
1557octal, @samp{x} for hexadecimal, or @samp{d} for decimal.
1558
eae04238
DM
1559@item --target=@var{bfdname}
1560@cindex object code format
1561Specify an object code format other than your system's default format.
1562@xref{Target Selection}, for more information.
1563
ba7c8e29
DM
1564@item -v
1565@itemx --version
1566Print the program version number on the standard output and exit.
1567@end table
1568
eae04238 1569@node strip
c72af735
RP
1570@chapter strip
1571
1572@kindex strip
1573@cindex removing symbols
1574@cindex discarding symbols
1815e42c 1575@cindex symbols, discarding
c72af735
RP
1576
1577@smallexample
18ef0a3d 1578strip [ -F @var{bfdname} | --target=@var{bfdname} ]
eae04238
DM
1579 [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1580 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
b703c078 1581 [ -s | --strip-all ] [ -S | -g | --strip-debug ]
dff604a7 1582 [ -K @var{symbolname} | --keep-symbol=@var{symbolname} ]
29c0d15c 1583 [ -N @var{symbolname} | --strip-symbol=@var{symbolname} ]
b703c078 1584 [ -x | --discard-all ] [ -X | --discard-locals ]
0aca460e 1585 [ -R @var{sectionname} | --remove-section=@var{sectionname} ]
2483354d 1586 [ -o @var{file} ] [ -p | --preserve-dates ]
b26ac613 1587 [ -v | --verbose ] [ -V | --version ] [ --help ]
b703c078 1588 @var{objfile}@dots{}
c72af735
RP
1589@end smallexample
1590
b94ff924 1591@sc{gnu} @code{strip} discards all symbols from object files
ec40bbb8 1592@var{objfile}. The list of object files may include archives.
b26ac613 1593At least one object file must be given.
c72af735 1594
ec40bbb8 1595@code{strip} modifies the files named in its argument,
c72af735 1596rather than writing modified copies under different names.
c72af735 1597
c72af735 1598@table @code
eae04238
DM
1599@item -F @var{bfdname}
1600@itemx --target=@var{bfdname}
b26ac613 1601Treat the original @var{objfile} as a file with the object
eae04238
DM
1602code format @var{bfdname}, and rewrite it in the same format.
1603@xref{Target Selection}, for more information.
b26ac613
DM
1604
1605@item --help
1606Show a summary of the options to @code{strip} and exit.
1607
eae04238
DM
1608@item -I @var{bfdname}
1609@itemx --input-target=@var{bfdname}
ec40bbb8 1610Treat the original @var{objfile} as a file with the object
eae04238
DM
1611code format @var{bfdname}.
1612@xref{Target Selection}, for more information.
918c2f61 1613
eae04238
DM
1614@item -O @var{bfdname}
1615@itemx --output-target=@var{bfdname}
1616Replace @var{objfile} with a file in the output format @var{bfdname}.
1617@xref{Target Selection}, for more information.
918c2f61 1618
0aca460e
ILT
1619@item -R @var{sectionname}
1620@itemx --remove-section=@var{sectionname}
1621Remove any section named @var{sectionname} from the output file. This
1622option may be given more than once. Note that using this option
1623inappropriately may make the output file unusable.
1624
b703c078
DM
1625@item -s
1626@itemx --strip-all
1627Remove all symbols.
1628
918c2f61
PB
1629@item -g
1630@itemx -S
1631@itemx --strip-debug
1632Remove debugging symbols only.
1633
9135e5f8
ILT
1634@item --strip-unneeded
1635Remove all symbols that are not needed for relocation processing.
1636
dff604a7
ILT
1637@item -K @var{symbolname}
1638@itemx --keep-symbol=@var{symbolname}
1639Keep only symbol @var{symbolname} from the source file. This option may
1640be given more than once.
1641
29c0d15c
ILT
1642@item -N @var{symbolname}
1643@itemx --strip-symbol=@var{symbolname}
dff604a7
ILT
1644Remove symbol @var{symbolname} from the source file. This option may be
1645given more than once, and may be combined with strip options other than
1646@code{-K}.
29c0d15c 1647
16c3e32a
ILT
1648@item -o @var{file}
1649Put the stripped output in @var{file}, rather than replacing the
1650existing file. When this argument is used, only one @var{objfile}
1651argument may be specified.
1652
2483354d
ILT
1653@item -p
1654@itemx --preserve-dates
1655Preserve the access and modification dates of the file.
1656
918c2f61
PB
1657@item -x
1658@itemx --discard-all
1659Remove non-global symbols.
1660
1661@item -X
1662@itemx --discard-locals
1663Remove compiler-generated local symbols.
ec40bbb8 1664(These usually start with @samp{L} or @samp{.}.)
918c2f61
PB
1665
1666@item -V
1667@itemx --version
ec40bbb8 1668Show the version number for @code{strip}.
918c2f61 1669
1815e42c 1670@item -v
918c2f61
PB
1671@itemx --verbose
1672Verbose output: list all object files modified. In the case of
1269d441 1673archives, @samp{strip -v} lists all members of the archive.
c72af735
RP
1674@end table
1675
eae04238 1676@node c++filt
b6216af2
PB
1677@chapter c++filt
1678
1679@kindex c++filt
1680@cindex demangling C++ symbols
1681
b26ac613
DM
1682@smallexample
1683c++filt [ -_ | --strip-underscores ]
6f88f031 1684 [ -n | --no-strip-underscores ]
b26ac613 1685 [ -s @var{format} | --format=@var{format} ]
d6a4c375 1686 [ --help ] [ --version ] [ @var{symbol}@dots{} ]
b26ac613
DM
1687@end smallexample
1688
6c69b6bd
JO
1689The C++ language provides function overloading, which means that you can
1690write many functions with the same name (providing each takes parameters
1691of different types). All C++ function names are encoded into a
b26ac613 1692low-level assembly label (this process is known as
6c69b6bd
JO
1693@dfn{mangling}). The @code{c++filt} program does the inverse mapping: it
1694decodes (@dfn{demangles}) low-level names into user-level names so that
1695the linker can keep these overloaded functions from clashing.
1696
1697Every alphanumeric word (consisting of letters, digits, underscores,
1698dollars, or periods) seen in the input is a potential label. If the
1699label decodes into a C++ name, the C++ name replaces the low-level
1700name in the output.
b6216af2 1701
d6a4c375 1702You can use @code{c++filt} to decipher individual symbols:
6c69b6bd
JO
1703
1704@example
1705c++filt @var{symbol}
1706@end example
1707
d6a4c375
DM
1708If no @var{symbol} arguments are given, @code{c++filt} reads symbol
1709names from the standard input and writes the demangled names to the
1710standard output. All results are printed on the standard output.
b6216af2 1711
b26ac613
DM
1712@table @code
1713@item -_
94e9ad77 1714@itemx --strip-underscores
b26ac613
DM
1715On some systems, both the C and C++ compilers put an underscore in front
1716of every name. For example, the C name @code{foo} gets the low-level
6f88f031
ILT
1717name @code{_foo}. This option removes the initial underscore. Whether
1718@code{c++filt} removes the underscore by default is target dependent.
1719
1720@item -n
1721@itemx --no-strip-underscores
1722Do not remove the initial underscore.
b26ac613
DM
1723
1724@item -s @var{format}
1725@itemx --format=@var{format}
b94ff924 1726@sc{gnu} @code{nm} can decode three different methods of mangling, used by
b26ac613
DM
1727different C++ compilers. The argument to this option selects which
1728method it uses:
1729
1730@table @code
1731@item gnu
b94ff924 1732the one used by the @sc{gnu} compiler (the default method)
b26ac613
DM
1733@item lucid
1734the one used by the Lucid compiler
1735@item arm
1736the one specified by the C++ Annotated Reference Manual
1737@end table
1738
1739@item --help
1740Print a summary of the options to @code{c++filt} and exit.
1741
1742@item --version
1743Print the version number of @code{c++filt} and exit.
1744@end table
b6216af2 1745
5eac46ae
JO
1746@quotation
1747@emph{Warning:} @code{c++filt} is a new utility, and the details of its
1748user interface are subject to change in future releases. In particular,
1749a command-line option may be required in the the future to decode a name
1750passed as an argument on the command line; in other words,
1751
1752@example
b26ac613 1753c++filt @var{symbol}
5eac46ae
JO
1754@end example
1755
1756@noindent
1757may in a future release become
1758
1759@example
b26ac613 1760c++filt @var{option} @var{symbol}
5eac46ae
JO
1761@end example
1762@end quotation
1763
fb38844d
ILT
1764@node addr2line
1765@chapter addr2line
1766
1767@kindex addr2line
1768@cindex address to file name and line number
1769
1770@smallexample
1771addr2line [ -b @var{bfdname} | --target=@var{bfdname} ]
1772 [ -C | --demangle ]
1773 [ -e @var{filename} | --exe=@var{filename} ]
1774 [ -f | --functions ] [ -s | --basename ]
1775 [ -H | --help ] [ -V | --version ]
1776 [ addr addr ... ]
1777@end smallexample
1778
1779@code{addr2line} translates program addresses into file names and line
1780numbers. Given an address and an executable, it uses the debugging
1781information in the executable to figure out which file name and line
1782number are associated with a given address.
1783
1784The executable to use is specified with the @code{-e} option. The
1785default is @file{a.out}.
1786
1787@code{addr2line} has two modes of operation.
1788
1789In the first, hexadecimal addresses are specified on the command line,
1790and @code{addr2line} displays the file name and line number for each
1791address.
1792
1793In the second, @code{addr2line} reads hexadecimal addresses from
1794standard input, and prints the file name and line number for each
1795address on standard output. In this mode, @code{addr2line} may be used
1796in a pipe to convert dynamically chosen addresses.
1797
1798The format of the output is @samp{FILENAME:LINENO}. The file name and
1799line number for each address is printed on a separate line. If the
1800@code{-f} option is used, then each @samp{FILENAME:LINENO} line is
1801preceded by a @samp{FUNCTIONNAME} line which is the name of the function
1802containing the address.
1803
1804If the file name or function name can not be determined,
1805@code{addr2line} will print two question marks in their place. If the
1806line number can not be determined, @code{addr2line} will print 0.
1807
1808The long and short forms of options, shown here as alternatives, are
1809equivalent.
1810
1811@table @code
1812@item -b @var{bfdname}
1813@itemx --target=@var{bfdname}
1814@cindex object code format
1815Specify that the object-code format for the object files is
1816@var{bfdname}.
1817
1818@item -C
1819@itemx --demangle
1820@cindex demangling in objdump
1821Decode (@dfn{demangle}) low-level symbol names into user-level names.
1822Besides removing any initial underscore prepended by the system, this
1823makes C++ function names readable. @xref{c++filt}, for more information
1824on demangling.
1825
1826@item -e @var{filename}
1827@itemx --exe=@var{filename}
1828Specify the name of the executable for which addresses should be
1829translated. The default file is @file{a.out}.
1830
1831@item -f
1832@itemx --functions
1833Display function names as well as file and line number information.
1834
1835@item -s
1836@itemx --basenames
1837Display only the base of each file name.
1838@end table
1839
eae04238 1840@node nlmconv
94e9ad77
JO
1841@chapter nlmconv
1842
1843@code{nlmconv} converts a relocatable object file into a NetWare
8981cac5
JO
1844Loadable Module.
1845
1846@ignore
1847@code{nlmconv} currently works with @samp{i386} object
4961ce5b
JO
1848files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC}
1849object files in @sc{elf}, or @code{a.out} format@footnote{
1850@code{nlmconv} should work with any @samp{i386} or @sc{sparc} object
1851format in the Binary File Descriptor library. It has only been tested
1852with the above formats.}.
8981cac5 1853@end ignore
4961ce5b
JO
1854
1855@quotation
1856@emph{Warning:} @code{nlmconv} is not always built as part of the binary
1857utilities, since it is only useful for NLM targets.
1858@end quotation
94e9ad77
JO
1859
1860@smallexample
eae04238
DM
1861nlmconv [ -I @var{bfdname} | --input-target=@var{bfdname} ]
1862 [ -O @var{bfdname} | --output-target=@var{bfdname} ]
94e9ad77 1863 [ -T @var{headerfile} | --header-file=@var{headerfile} ]
20465f8b 1864 [ -d | --debug] [ -l @var{linker} | --linker=@var{linker} ]
94e9ad77
JO
1865 [ -h | --help ] [ -V | --version ]
1866 @var{infile} @var{outfile}
1867@end smallexample
1868
1869@code{nlmconv} converts the relocatable @samp{i386} object file
1870@var{infile} into the NetWare Loadable Module @var{outfile}, optionally
1871reading @var{headerfile} for NLM header information. For instructions
5b0ba16d
JO
1872on writing the NLM command file language used in header files, see the
1873@samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM
1874Development and Tools Overview}, which is part of the NLM Software
1875Developer's Kit (``NLM SDK''), available from Novell, Inc.
1876@code{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read
eae04238 1877@var{infile}; see @ref{BFD,,BFD,ld.info,Using LD}, for
5b0ba16d 1878more information.
94e9ad77 1879
20465f8b
JO
1880@code{nlmconv} can perform a link step. In other words, you can list
1881more than one object file for input if you list them in the definitions
1882file (rather than simply specifying one input file on the command line).
1883In this case, @code{nlmconv} calls the linker for you.
1884
94e9ad77 1885@table @code
eae04238
DM
1886@item -I @var{bfdname}
1887@itemx --input-target=@var{bfdname}
94e9ad77 1888Object format of the input file. @code{nlmconv} can usually determine
eae04238
DM
1889the format of a given file (so no default is necessary).
1890@xref{Target Selection}, for more information.
94e9ad77 1891
eae04238
DM
1892@item -O @var{bfdname}
1893@itemx --output-target=@var{bfdname}
94e9ad77
JO
1894Object format of the output file. @code{nlmconv} infers the output
1895format based on the input format, e.g. for a @samp{i386} input file the
eae04238
DM
1896output format is @samp{nlm32-i386}.
1897@xref{Target Selection}, for more information.
94e9ad77
JO
1898
1899@item -T @var{headerfile}
1900@itemx --header-file=@var{headerfile}
1901Reads @var{headerfile} for NLM header information. For instructions on
5b0ba16d
JO
1902writing the NLM command file language used in header files, see@ see the
1903@samp{linkers} section, of the @cite{NLM Development and Tools
1904Overview}, which is part of the NLM Software Developer's Kit, available
1905from Novell, Inc.
94e9ad77 1906
20465f8b
JO
1907@item -d
1908@itemx --debug
1909Displays (on standard error) the linker command line used by @code{nlmconv}.
1910
1911@item -l @var{linker}
1912@itemx --linker=@var{linker}
061ed861 1913Use @var{linker} for any linking. @var{linker} can be an absolute or a
20465f8b
JO
1914relative pathname.
1915
94e9ad77
JO
1916@item -h
1917@itemx --help
1918Prints a usage summary.
1919
1920@item -V
1921@itemx --version
1922Prints the version number for @code{nlmconv}.
1923@end table
1924
217947b2
ILT
1925@node windres
1926@chapter windres
1927
1928@code{windres} may be used to manipulate Windows resources.
1929
1930@quotation
1931@emph{Warning:} @code{windres} is not always built as part of the binary
1932utilities, since it is only useful for Windows targets.
1933@end quotation
1934
1935@smallexample
1936windres [options] [input-file] [output-file]
1937@end smallexample
1938
1939@code{windres} reads resources from an input file and copies them into
1940an output file. Either file may be in one of three formats:
1941
1942@table @code
1943@item rc
1944A text format read by the Resource Compiler.
1945
1946@item res
1947A binary format generated by the Resource Compiler.
1948
1949@item coff
1950A COFF object or executable.
1951@end table
1952
1953The exact description of these different formats is available in
1954documentation from Microsoft.
1955
1956When @code{windres} converts from the @code{rc} format to the @code{res}
1957format, it is acting like the Windows Resource Compiler. When
1958@code{windres} converts from the @code{res} format to the @code{coff}
1959format, it is acting like the Windows @code{CVTRES} program.
1960
1961When @code{windres} generates an @code{rc} file, the output is similar
1962but not identical to the format expected for the input. When an input
1963@code{rc} file refers to an external filename, an output @code{rc} file
1964will instead include the file contents.
1965
1966If the input or output format is not specified, @code{windres} will
1967guess based on the file name, or, for the input file, the file contents.
1968A file with an extension of @file{.rc} will be treated as an @code{rc}
1969file, a file with an extension of @file{.res} will be treated as a
1970@code{res} file, and a file with an extension of @file{.o} or
1971@file{.exe} will be treated as a @code{coff} file.
1972
1973If no output file is specified, @code{windres} will print the resources
1974in @code{rc} format to standard output.
1975
1976The normal use is for you to write an @code{rc} file, use @code{windres}
1977to convert it to a COFF object file, and then link the COFF file into
1978your application. This will make the resources described in the
1979@code{rc} file available to Windows.
1980
1981@table @code
1982@item -i @var{filename}
1983@itemx --input @var{filename}
1984The name of the input file. If this option is not used, then
1985@code{windres} will use the first non-option argument as the input file
1986name. If there are no non-option arguments, then @code{windres} will
1987read from standard input. @code{windres} can not read a COFF file from
1988standard input.
1989
1990@item -o @var{filename}
1991@itemx --output @var{filename}
1992The name of the output file. If this option is not used, then
1993@code{windres} will use the first non-option argument, after any used
1994for the input file name, as the output file name. If there is no
1995non-option argument, then @code{windres} will write to standard output.
1996@code{windres} can not write a COFF file to standard output.
1997
1998@item -I @var{format}
1999@itemx --input-format @var{format}
2000The input format to read. @var{format} may be @samp{res}, @samp{rc}, or
2001@samp{coff}. If no input format is specified, @code{windres} will
2002guess, as described above.
2003
2004@item -O @var{format}
2005@itemx --output-format @var{format}
2006The output format to generate. @var{format} may be @samp{res},
2007@samp{rc}, or @samp{coff}. If no output format is specified,
2008@code{windres} will guess, as described above.
2009
2010@item -F @var{target}
2011@itemx --target @var{target}
2012Specify the BFD format to use for a COFF file as input or output. This
2013is a BFD target name; you can use the @code{--help} option to see a list
2014of supported targets. Normally @code{windres} will use the default
2015format, which is the first one listed by the @code{--help} option.
2016@ref{Target Selection}.
2017
2018@item --preprocessor @var{program}
2019When @code{windres} reads an @code{rc} file, it runs it through the C
2020preprocessor first. This option may be used to specify the preprocessor
2021to use, including any leading arguments. The default preprocessor
2022argument is @code{gcc -E -xc-header -DRC_INVOKED}.
2023
2024@item --include-dir @var{directory}
2025Specify an include directory to use when reading an @code{rc} file.
2026@code{windres} will pass this to the preprocessor as an @code{-I}
2027option. @code{windres} will also search this directory when looking for
2028files named in the @code{rc} file.
2029
2030@item --define @var{sym[=val]}
2031Specify a @code{-D} option to pass to the preprocessor when reading an
2032@code{rc} file.
2033
2034@item --language @var{val}
2035Specify the default language to use when reading an @code{rc} file.
2036@var{val} should be a hexadecimal language code. The low eight bits are
2037the language, and the high eight bits are the sublanguage.
2038
2039@item --help
2040Prints a usage summary.
2041
2042@item --version
2043Prints the version number for @code{windres}.
2044
2045@item --yydebug
2046If @code{windres} is compiled with @code{YYDEBUG} defined as @code{1},
2047this will turn on parser debugging.
2048@end table
2049
061ed861
NC
2050
2051@node dlltool
2052@chapter Create files needed to build and use DLLs
2053@cindex DLL
2054@kindex dlltool
2055
2056@code{dlltool} may be used to create the files needed to build and use
2057dynamic link libraries (DLLs).
2058
2059@quotation
2060@emph{Warning:} @code{dlltool} is not always built as part of the binary
2061utilities, since it is only useful for those targets which support DLLs.
2062@end quotation
2063
2064@smallexample
2065dlltool [-d|--input-def <def-file-name>]
2066 [-b|--base-file <base-file-name>]
2067 [-e|--output-exp <exports-file-name>]
2068 [-z|--output-def <def-file-name>]
2069 [-l|--output-lib <library-file-name>]
2070 [-S|--as <path-to-assembler>] [-f|--as-flags <options>]
2071 [-D|--dllname <name>] [-m|--machine <machine>]
2072 [-a|--add-indirect] [-U|--add-underscore] [-k|--kill-at]
2073 [-x|--no-idata4] [-c|--no-idata5] [-i|--interwork]
2074 [-n|--nodelete] [-v|--verbose] [-h|--help] [-V|--version]
2075 [object-file @dots{}]
2076@end smallexample
2077
2078@code{dlltool} reads its inputs, which can come from the @samp{-d} and
2079@samp{-b} options as well as object files specified on the command
2080line. It then processes these inputs and if the @samp{-e} option has
2081been specified it creates a exports file. If the @samp{-l} option
2082has been specified it creates a library file and if the @samp{-z} option
2083has been specified it creates a def file. Any or all of the -e, -l
2084and -z options can be present in one invocation of dlltool.
2085
2086When creating a DLL, along with the source for the DLL, it is necessary
2087to have three other files. @code{dlltool} can help with the creation of
2088these files.
2089
2090The first file is a @samp{.def} file which specifies which functions are
2091exported from the DLL, which functions the DLL imports, and so on. This
2092is a text file and can be created by hand, or @code{dlltool} can be used
2093to create it using the @samp{-z} option. In this case @code{dlltool}
2094will scan the object files specified on its command line looking for
2095those functions which have been specially marked as being exported and
2096put entries for them in the .def file it creates.
2097
2098In order to mark a function as being exported from a DLL, it needs to
2099have an @samp{-export:<name_of_function>} entry in the @samp{.drective}
2100section of the object file. This can be done in C by using the
2101asm() operator:
2102
2103@smallexample
2104 asm (".section .drective");
2105 asm (".ascii \"-export:my_func\"");
2106
2107 int my_func (void) @{ @dots{} @}
2108@end smallexample
2109
2110The second file needed for DLL creation is an exports file. This file
2111is linked with the object files that make up the body of the DLL and it
2112handles the interface between the DLL and the outside world. This is a
2113binary file and it can be created by giving the @samp{-e} option to
2114@code{dlltool} when it is creating or reading in a .def file.
2115
2116The third file needed for DLL creation is the library file that programs
2117will link with in order to access the functions in the DLL. This file
2118can be created by giving the @samp{-l} option to dlltool when it
2119is creating or reading in a .def file.
2120
2121@code{dlltool} builds the library file by hand, but it builds the
2122exports file by creating temporary files containing assembler statements
2123and then assembling these. The @samp{-S} command line option can be
2124used to specify the path to the assembler that dlltool will use,
2125and the @samp{-f} option can be used to pass specific flags to that
2126assembler. The @samp{-n} can be used to prevent dlltool from deleting
2127these temporary assembler files when it is done, and if @samp{-n} is
2128specified twice then this will prevent dlltool from deleting the
2129temporary object files it used to build the library.
2130
2131Here is an example of creating a DLL from a source file @samp{dll.c} and
2132also creating a program (from an object file called @samp{program.o})
2133that uses that DLL:
2134
2135@smallexample
2136 gcc -c dll.c
2137 dlltool -e exports.o -l dll.lib dll.o
2138 gcc dll.o exports.o -o dll.dll
2139 gcc program.o dll.lib -o program
2140@end smallexample
2141
2142The command line options have the following meanings:
2143
2144@table @code
2145
2146@item -d FILENAME
2147@itemx --input-def FILENAME
2148@cindex input .def file
2149Specifies the name of a .def file to be read in and processed.
2150
2151@item -b FILENAME
2152@itemx --base-file FILENAME
2153@cindex base files
2154Specifies the name of a base file to be read in and processed. The
2155contents of this file will be added to the relocation section in the
2156exports file generated by dlltool.
2157
2158@item -e FILENAME
2159@itemx --output-exp FILENAME
2160Specifies the name of the export file to be created by dlltool.
2161
2162@item -z FILENAME
2163@itemx --output-def FILENAME
2164Specifies the name of the .def file to be created by dlltool.
2165
2166@item -l FILENAME
2167@itemx --output-lib FILENAME
2168Specifies the name of the library file to be created by dlltool.
2169
2170@item -S PATH
2171@itemx --as PATH
2172Specifies the path, including the filename, of the assembler to be used
2173to create the exports file.
2174
2175@item -f SWITCHES
2176@itemx --as-flags SWITCHES
2177Specifies any specific command line switches to be passed to the
2178assembler when building the exports file. This option will work even if
2179the @samp{-S} option is not used. This option only takes one argument,
2180and if it occurs more than once on the command line, then later
2181occurrences will override earlier occurrences. So if it is necessary to
2182pass multiple switches to the assembler they should be enclosed in
2183double quotes.
2184
2185@item -D NAME
2186@itemx --dll-name NAME
2187Specifies the name to be stored in the .def file as the name of the DLL
2188when the @samp{-e} option is used. If this option is not present, then
2189the filename given to the @samp{-e} option will be used as the name of
2190the DLL.
2191
2192@item -m MACHINE
2193@itemx -machine MACHINE
2194Specifies the type of machine for which the library file should be
2195built. @code{dlltool} has a built in default type, depending upon how
2196it was created, but this option can be used to override that. This is
2197normally only useful when creating DLLs for an ARM processor, when the
2198contents of the DLL are actually encode using THUMB instructions.
2199
2200@item -a
2201@itemx --add-indirect
2202Specifies that when @code{dlltool} is creating the exports file it
2203should add a section which allows the exported functions to be
2204referenced without using the import library. Whatever the hell that
2205means!
2206
2207@item -U
2208@itemx --add-underscore
2209Specifies that when @code{dlltool} is creating the exports file it
2210should prepend an underscore to the names of the exported functions.
2211
2212@item -k
2213@itemx --kill-at
2214Specifies that when @code{dlltool} is creating the exports file it
2215should not append the string @samp{@@ <number>}. These numbers are
2216called ordinal numbers and they represent another way of accessing the
2217function in a DLL, other than by name.
2218
2219@item -x
2220@itemx --no-idata4
2221Specifies that when @code{dlltool} is creating the exports and library
2222files it should omit the .idata4 section. This is for compatibility
2223with certain operating systems.
2224
2225@item -c
2226@itemx --no-idata5
2227Specifies that when @code{dlltool} is creating the exports and library
2228files it should omit the .idata5 section. This is for compatibility
2229with certain operating systems.
2230
2231@item -i
2232@itemx --interwork
2233Specifies that @code{dlltool} should mark the objects in the library
2234file and exports file that it produces as supporting interworking
2235between ARM and THUMB code.
2236
2237@item -n
2238@itemx --nodelete
2239Makes @code{dlltool} preserve the temporary assembler files it used to
2240create the exports file. If this option is repeated then dlltool will
2241also preserve the temporary object files it uses to create the library
2242file.
2243
2244@item -v
2245@itemx --verbose
2246Make dlltool describe what it is doing.
2247
2248@item -h
2249@itemx --help
2250Displays a list of command line options and then exits.
2251
2252@item -V
2253@itemx --version
2254Displays dlltool's version number and then exits.
2255
2256@end table
2257
2258
2259
eae04238
DM
2260@node Selecting The Target System
2261@chapter Selecting the target system
2262
8981cac5
JO
2263You can specify three aspects of the target system to the @sc{gnu}
2264binary file utilities, each in several ways:
eae04238
DM
2265
2266@itemize @bullet
2267@item
8981cac5 2268the target
eae04238
DM
2269
2270@item
8981cac5 2271the architecture
eae04238
DM
2272
2273@item
8981cac5 2274the linker emulation (which applies to the linker only)
eae04238
DM
2275@end itemize
2276
2277In the following summaries, the lists of ways to specify values are in
8981cac5
JO
2278order of decreasing precedence. The ways listed first override those
2279listed later.
eae04238 2280
8981cac5
JO
2281The commands to list valid values only list the values for which the
2282programs you are running were configured. If they were configured with
8490169d 2283@samp{--enable-targets=all}, the commands list most of the available
eae04238 2284values, but a few are left out; not all targets can be configured in at
8981cac5
JO
2285once because some of them can only be configured @dfn{native} (on hosts
2286with the same type as the target system).
eae04238
DM
2287
2288@menu
2289* Target Selection::
2290* Architecture Selection::
2291* Linker Emulation Selection::
2292@end menu
2293
2294@node Target Selection
8981cac5 2295@section Target Selection
eae04238
DM
2296
2297A @dfn{target} is an object file format. A given target may be
2298supported for multiple architectures (@pxref{Architecture Selection}).
8981cac5
JO
2299A target selection may also have variations for different operating
2300systems or architectures.
eae04238 2301
8981cac5
JO
2302The command to list valid target values is @samp{objdump -i}
2303(the first column of output contains the relevant information).
eae04238 2304
10f2a7f6
JO
2305Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips},
2306@samp{a.out-sunos-big}.
eae04238 2307
55311d1c
ILT
2308You can also specify a target using a configuration triplet. This is
2309the same sort of name that is passed to configure to specify a target.
2310When you use a configuration triplet as an argument, it must be fully
2311canonicalized. You can see the canonical version of a triplet by
2312running the shell script @file{config.sub} which is included with the
2313sources.
2314
2315Some sample configuration triplets are: @samp{m68k-hp-bsd},
2316@samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}.
2317
8981cac5 2318@subheading @code{objdump} Target
eae04238
DM
2319
2320Ways to specify:
2321
2322@enumerate
2323@item
8981cac5 2324command line option: @samp{-b} or @samp{--target}
eae04238
DM
2325
2326@item
2327environment variable @code{GNUTARGET}
2328
2329@item
2330deduced from the input file
2331@end enumerate
2332
8981cac5 2333@subheading @code{objcopy} and @code{strip} Input Target
eae04238
DM
2334
2335Ways to specify:
2336
2337@enumerate
2338@item
8981cac5 2339command line options: @samp{-I} or @samp{--input-target}, or @samp{-F} or @samp{--target}
eae04238
DM
2340
2341@item
2342environment variable @code{GNUTARGET}
2343
2344@item
2345deduced from the input file
2346@end enumerate
2347
8981cac5 2348@subheading @code{objcopy} and @code{strip} Output Target
eae04238
DM
2349
2350Ways to specify:
2351
2352@enumerate
2353@item
8981cac5 2354command line options: @samp{-O} or @samp{--output-target}, or @samp{-F} or @samp{--target}
eae04238
DM
2355
2356@item
8981cac5 2357the input target (see ``@code{objcopy} and @code{strip} Input Target'' above)
eae04238
DM
2358
2359@item
2360environment variable @code{GNUTARGET}
2361
2362@item
2363deduced from the input file
2364@end enumerate
2365
8981cac5 2366@subheading @code{nm}, @code{size}, and @code{strings} Target
eae04238
DM
2367
2368Ways to specify:
2369
2370@enumerate
2371@item
8981cac5 2372command line option: @samp{--target}
eae04238
DM
2373
2374@item
2375environment variable @code{GNUTARGET}
2376
2377@item
2378deduced from the input file
2379@end enumerate
2380
8981cac5 2381@subheading Linker Input Target
eae04238
DM
2382
2383Ways to specify:
2384
2385@enumerate
2386@item
8981cac5 2387command line option: @samp{-b} or @samp{--format}
eae04238
DM
2388(@pxref{Options,,Options,ld.info,Using LD})
2389
2390@item
2391script command @code{TARGET}
2392(@pxref{Option Commands,,Option Commands,ld.info,Using LD})
2393
2394@item
2395environment variable @code{GNUTARGET}
2396(@pxref{Environment,,Environment,ld.info,Using LD})
2397
2398@item
2399the default target of the selected linker emulation
2400(@pxref{Linker Emulation Selection})
2401@end enumerate
2402
8981cac5 2403@subheading Linker Output Target
eae04238
DM
2404
2405Ways to specify:
2406
2407@enumerate
2408@item
8981cac5 2409command line option: @samp{-oformat}
eae04238
DM
2410(@pxref{Options,,Options,ld.info,Using LD})
2411
2412@item
2413script command @code{OUTPUT_FORMAT}
2414(@pxref{Option Commands,,Option Commands,ld.info,Using LD})
2415
2416@item
8981cac5 2417the linker input target (see ``Linker Input Target'' above)
eae04238
DM
2418@end enumerate
2419
2420@node Architecture Selection
2421@section Architecture selection
2422
8981cac5
JO
2423An @dfn{architecture} is a type of @sc{cpu} on which an object file is
2424to run. Its name may contain a colon, separating the name of the
2425processor family from the name of the particular @sc{cpu}.
eae04238 2426
8981cac5
JO
2427The command to list valid architecture values is @samp{objdump -i} (the
2428second column contains the relevant information).
eae04238
DM
2429
2430Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}.
2431
8981cac5 2432@subheading @code{objdump} Architecture
eae04238
DM
2433
2434Ways to specify:
2435
2436@enumerate
2437@item
8981cac5 2438command line option: @samp{-m} or @samp{--architecture}
eae04238
DM
2439
2440@item
2441deduced from the input file
2442@end enumerate
2443
8981cac5 2444@subheading @code{objcopy}, @code{nm}, @code{size}, @code{strings} Architecture
eae04238
DM
2445
2446Ways to specify:
2447
2448@enumerate
2449@item
2450deduced from the input file
2451@end enumerate
2452
8981cac5 2453@subheading Linker Input Architecture
eae04238
DM
2454
2455Ways to specify:
2456
2457@enumerate
2458@item
2459deduced from the input file
2460@end enumerate
2461
8981cac5 2462@subheading Linker Output Architecture
eae04238
DM
2463
2464Ways to specify:
2465
2466@enumerate
2467@item
2468script command @code{OUTPUT_ARCH}
2469(@pxref{Option Commands,,Option Commands,ld.info,Using LD})
2470
2471@item
2472the default architecture from the linker output target
8981cac5 2473(@pxref{Target Selection})
eae04238
DM
2474@end enumerate
2475
2476@node Linker Emulation Selection
2477@section Linker emulation selection
2478
2479A linker @dfn{emulation} is a ``personality'' of the linker, which gives
2480the linker default values for the other aspects of the target system.
2481In particular, it consists of
2482
2483@itemize @bullet
2484@item
8981cac5 2485the linker script
eae04238
DM
2486
2487@item
8981cac5 2488the target
eae04238
DM
2489
2490@item
2491several ``hook'' functions that are run at certain stages of the linking
8981cac5 2492process to do special things that some targets require
eae04238
DM
2493@end itemize
2494
8981cac5 2495The command to list valid linker emulation values is @samp{ld -V}.
eae04238
DM
2496
2497Sample values: @samp{hp300bsd}, @samp{mipslit}, @samp{sun4}.
2498
2499Ways to specify:
2500
2501@enumerate
2502@item
8981cac5 2503command line option: @samp{-m}
eae04238
DM
2504(@pxref{Options,,Options,ld.info,Using LD})
2505
2506@item
2507environment variable @code{LDEMULATION}
2508
2509@item
2510compiled-in @code{DEFAULT_EMULATION} from @file{Makefile},
2511which comes from @code{EMUL} in @file{config/@var{target}.mt}
2512@end enumerate
2513
cbcfa129
ILT
2514@node Reporting Bugs
2515@chapter Reporting Bugs
2516@cindex bugs
2517@cindex reporting bugs
2518
2519Your bug reports play an essential role in making the binary utilities
2520reliable.
2521
2522Reporting a bug may help you by bringing a solution to your problem, or
2523it may not. But in any case the principal function of a bug report is
2524to help the entire community by making the next version of the binary
2525utilities work better. Bug reports are your contribution to their
2526maintenance.
2527
2528In order for a bug report to serve its purpose, you must include the
2529information that enables us to fix the bug.
2530
2531@menu
2532* Bug Criteria:: Have you found a bug?
2533* Bug Reporting:: How to report bugs
2534@end menu
2535
2536@node Bug Criteria
2537@section Have you found a bug?
2538@cindex bug criteria
2539
2540If you are not sure whether you have found a bug, here are some guidelines:
2541
2542@itemize @bullet
2543@cindex fatal signal
2544@cindex crash
2545@item
2546If a binary utility gets a fatal signal, for any input whatever, that is
2547a bug. Reliable utilities never crash.
2548
2549@cindex error on valid input
2550@item
2551If a binary utility produces an error message for valid input, that is a
2552bug.
2553
2554@item
2555If you are an experienced user of binary utilities, your suggestions for
2556improvement are welcome in any case.
2557@end itemize
2558
2559@node Bug Reporting
2560@section How to report bugs
2561@cindex bug reports
2562@cindex bugs, reporting
2563
2564A number of companies and individuals offer support for @sc{gnu}
2565products. If you obtained the binary utilities from a support
2566organization, we recommend you contact that organization first.
2567
2568You can find contact information for many support companies and
2569individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
2570distribution.
2571
2572In any event, we also recommend that you send bug reports for the binary
eaa147a6 2573utilities to @samp{bug-gnu-utils@@gnu.org}.
cbcfa129
ILT
2574
2575The fundamental principle of reporting bugs usefully is this:
2576@strong{report all the facts}. If you are not sure whether to state a
2577fact or leave it out, state it!
2578
2579Often people omit facts because they think they know what causes the
2580problem and assume that some details do not matter. Thus, you might
2581assume that the name of a file you use in an example does not matter.
2582Well, probably it does not, but one cannot be sure. Perhaps the bug is
2583a stray memory reference which happens to fetch from the location where
2584that pathname is stored in memory; perhaps, if the pathname were
2585different, the contents of that location would fool the utility into
2586doing the right thing despite the bug. Play it safe and give a
2587specific, complete example. That is the easiest thing for you to do,
2588and the most helpful.
2589
2590Keep in mind that the purpose of a bug report is to enable us to fix the bug if
2591it is new to us. Therefore, always write your bug reports on the assumption
2592that the bug has not been reported previously.
2593
2594Sometimes people give a few sketchy facts and ask, ``Does this ring a
2595bell?'' Those bug reports are useless, and we urge everyone to
2596@emph{refuse to respond to them} except to chide the sender to report
2597bugs properly.
2598
2599To enable us to fix the bug, you should include all these things:
2600
2601@itemize @bullet
2602@item
2603The version of the utility. Each utility announces it if you start it
2604with the @samp{--version} argument.
2605
2606Without this, we will not know whether there is any point in looking for
2607the bug in the current version of the binary utilities.
2608
2609@item
2610Any patches you may have applied to the source, including any patches
2611made to the @code{BFD} library.
2612
2613@item
2614The type of machine you are using, and the operating system name and
2615version number.
2616
2617@item
2618What compiler (and its version) was used to compile the utilities---e.g.
2619``@code{gcc-2.7}''.
2620
2621@item
2622The command arguments you gave the utility to observe the bug. To
2623guarantee you will not omit something important, list them all. A copy
2624of the Makefile (or the output from make) is sufficient.
2625
2626If we were to try to guess the arguments, we would probably guess wrong
2627and then we might not encounter the bug.
2628
2629@item
2630A complete input file, or set of input files, that will reproduce the
2631bug. If the utility is reading an object file or files, then it is
2632generally most helpful to send the actual object files, uuencoded if
2633necessary to get them through the mail system. Making them available
2634for anonymous FTP is not as good, but may be the only reasonable choice
2635for large object files.
2636
2637If the source files were produced exclusively using @sc{gnu} programs
2638(e.g., @code{gcc}, @code{gas}, and/or the @sc{gnu} @code{ld}), then it
2639may be OK to send the source files rather than the object files. In
2640this case, be sure to say exactly what version of @code{gcc}, or
2641whatever, was used to produce the object files. Also say how
2642@code{gcc}, or whatever, was configured.
2643
2644@item
2645A description of what behavior you observe that you believe is
2646incorrect. For example, ``It gets a fatal signal.''
2647
2648Of course, if the bug is that the utility gets a fatal signal, then we
2649will certainly notice it. But if the bug is incorrect output, we might
2650not notice unless it is glaringly wrong. You might as well not give us
2651a chance to make a mistake.
2652
2653Even if the problem you experience is a fatal signal, you should still
2654say so explicitly. Suppose something strange is going on, such as, your
2655copy of the utility is out of synch, or you have encountered a bug in
2656the C library on your system. (This has happened!) Your copy might
2657crash and ours would not. If you told us to expect a crash, then when
2658ours fails to crash, we would know that the bug was not happening for
2659us. If you had not told us to expect a crash, then we would not be able
2660to draw any conclusion from our observations.
2661
2662@item
2663If you wish to suggest changes to the source, send us context diffs, as
2664generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p}
2665option. Always send diffs from the old file to the new file. If you
2666even discuss something in the @code{ld} source, refer to it by context,
2667not by line number.
2668
2669The line numbers in our development sources will not match those in your
2670sources. Your line numbers would convey no useful information to us.
2671@end itemize
2672
2673Here are some things that are not necessary:
2674
2675@itemize @bullet
2676@item
2677A description of the envelope of the bug.
2678
2679Often people who encounter a bug spend a lot of time investigating
2680which changes to the input file will make the bug go away and which
2681changes will not affect it.
2682
2683This is often time consuming and not very useful, because the way we
2684will find the bug is by running a single example under the debugger
2685with breakpoints, not by pure deduction from a series of examples.
2686We recommend that you save your time for something else.
2687
2688Of course, if you can find a simpler example to report @emph{instead}
2689of the original one, that is a convenience for us. Errors in the
2690output will be easier to spot, running under the debugger will take
2691less time, and so on.
2692
2693However, simplification is not vital; if you do not want to do this,
2694report the bug anyway and send us the entire test case you used.
2695
2696@item
2697A patch for the bug.
2698
2699A patch for the bug does help us if it is a good one. But do not omit
2700the necessary information, such as the test case, on the assumption that
2701a patch is all we need. We might see problems with your patch and decide
2702to fix the problem another way, or we might not understand it at all.
2703
2704Sometimes with programs as complicated as the binary utilities it is
2705very hard to construct an example that will make the program follow a
2706certain path through the code. If you do not send us the example, we
2707will not be able to construct one, so we will not be able to verify that
2708the bug is fixed.
2709
2710And if we cannot understand what bug you are trying to fix, or why your
2711patch should be an improvement, we will not install it. A test case will
2712help us to understand.
2713
2714@item
2715A guess about what the bug is or what it depends on.
2716
2717Such guesses are usually wrong. Even we cannot guess right about such
2718things without first using the debugger to find the facts.
2719@end itemize
2720
eae04238 2721@node Index
c72af735
RP
2722@unnumbered Index
2723
2724@printindex cp
2725
2726@contents
2727@bye
This page took 0.347216 seconds and 4 git commands to generate.