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