1\input texinfo @c -*- Texinfo -*- 2@setfilename binutils.info 3@settitle @sc{gnu} Binary Utilities 4@finalout 5@synindex ky cp 6 7@c man begin INCLUDE 8@include bfdver.texi 9@c man end 10 11@copying 12@c man begin COPYRIGHT 13Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 141999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 152010, 2011, 2012 16Free Software Foundation, Inc. 17 18Permission is granted to copy, distribute and/or modify this document 19under the terms of the GNU Free Documentation License, Version 1.3 20or any later version published by the Free Software Foundation; 21with no Invariant Sections, with no Front-Cover Texts, and with no 22Back-Cover Texts. A copy of the license is included in the 23section entitled ``GNU Free Documentation License''. 24 25@c man end 26@end copying 27 28@dircategory Software development 29@direntry 30* Binutils: (binutils). The GNU binary utilities. 31@end direntry 32 33@dircategory Individual utilities 34@direntry 35* addr2line: (binutils)addr2line. Convert addresses to file and line. 36* ar: (binutils)ar. Create, modify, and extract from archives. 37* c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols. 38* cxxfilt: (binutils)c++filt. MS-DOS name for c++filt. 39* dlltool: (binutils)dlltool. Create files needed to build and use DLLs. 40* nlmconv: (binutils)nlmconv. Converts object code into an NLM. 41* nm: (binutils)nm. List symbols from object files. 42* objcopy: (binutils)objcopy. Copy and translate object files. 43* objdump: (binutils)objdump. Display information from object files. 44* ranlib: (binutils)ranlib. Generate index to archive contents. 45* readelf: (binutils)readelf. Display the contents of ELF format files. 46* size: (binutils)size. List section sizes and total size. 47* strings: (binutils)strings. List printable strings from files. 48* strip: (binutils)strip. Discard symbols. 49* elfedit: (binutils)elfedit. Update the ELF header of ELF files. 50* windmc: (binutils)windmc. Generator for Windows message resources. 51* windres: (binutils)windres. Manipulate Windows resources. 52@end direntry 53 54@titlepage 55@title The @sc{gnu} Binary Utilities 56@ifset VERSION_PACKAGE 57@subtitle @value{VERSION_PACKAGE} 58@end ifset 59@subtitle Version @value{VERSION} 60@sp 1 61@subtitle @value{UPDATED} 62@author Roland H. Pesch 63@author Jeffrey M. Osier 64@author Cygnus Support 65@page 66 67@tex 68{\parskip=0pt \hfill Cygnus Support\par \hfill 69Texinfo \texinfoversion\par } 70@end tex 71 72@vskip 0pt plus 1filll 73@insertcopying 74@end titlepage 75@contents 76 77@node Top 78@top Introduction 79 80@cindex version 81This brief manual contains documentation for the @sc{gnu} binary 82utilities 83@ifset VERSION_PACKAGE 84@value{VERSION_PACKAGE} 85@end ifset 86version @value{VERSION}: 87 88@iftex 89@table @code 90@item ar 91Create, modify, and extract from archives 92 93@item nm 94List symbols from object files 95 96@item objcopy 97Copy and translate object files 98 99@item objdump 100Display information from object files 101 102@item ranlib 103Generate index to archive contents 104 105@item readelf 106Display the contents of ELF format files. 107 108@item size 109List file section sizes and total size 110 111@item strings 112List printable strings from files 113 114@item strip 115Discard symbols 116 117@item elfedit 118Update the ELF header of ELF files. 119 120@item c++filt 121Demangle encoded C++ symbols (on MS-DOS, this program is named 122@code{cxxfilt}) 123 124@item addr2line 125Convert addresses into file names and line numbers 126 127@item nlmconv 128Convert object code into a Netware Loadable Module 129 130@item windres 131Manipulate Windows resources 132 133@item windmc 134Genertor for Windows message resources 135 136@item dlltool 137Create the files needed to build and use Dynamic Link Libraries 138@end table 139@end iftex 140 141This document is distributed under the terms of the GNU Free 142Documentation License version 1.3. A copy of the license is included 143in the section entitled ``GNU Free Documentation License''. 144 145@menu 146* ar:: Create, modify, and extract from archives 147* nm:: List symbols from object files 148* objcopy:: Copy and translate object files 149* objdump:: Display information from object files 150* ranlib:: Generate index to archive contents 151* readelf:: Display the contents of ELF format files 152* size:: List section sizes and total size 153* strings:: List printable strings from files 154* strip:: Discard symbols 155* elfedit:: Update the ELF header of ELF files 156* c++filt:: Filter to demangle encoded C++ symbols 157* cxxfilt: c++filt. MS-DOS name for c++filt 158* addr2line:: Convert addresses to file and line 159* nlmconv:: Converts object code into an NLM 160* windres:: Manipulate Windows resources 161* windmc:: Generator for Windows message resources 162* dlltool:: Create files needed to build and use DLLs 163* Common Options:: Command-line options for all utilities 164* Selecting the Target System:: How these utilities determine the target 165* Reporting Bugs:: Reporting Bugs 166* GNU Free Documentation License:: GNU Free Documentation License 167* Binutils Index:: Binutils Index 168@end menu 169 170@node ar 171@chapter ar 172 173@kindex ar 174@cindex archives 175@cindex collections of files 176 177@c man title ar create, modify, and extract from archives 178 179@smallexample 180ar [@option{--plugin} @var{name}] [-]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] [@option{--target} @var{bfdname}] @var{archive} [@var{member}@dots{}] 181ar -M [ <mri-script ] 182@end smallexample 183 184@c man begin DESCRIPTION ar 185 186The @sc{gnu} @command{ar} program creates, modifies, and extracts from 187archives. An @dfn{archive} is a single file holding a collection of 188other files in a structure that makes it possible to retrieve 189the original individual files (called @dfn{members} of the archive). 190 191The original files' contents, mode (permissions), timestamp, owner, and 192group are preserved in the archive, and can be restored on 193extraction. 194 195@cindex name length 196@sc{gnu} @command{ar} can maintain archives whose members have names of any 197length; however, depending on how @command{ar} is configured on your 198system, a limit on member-name length may be imposed for compatibility 199with archive formats maintained with other tools. If it exists, the 200limit is often 15 characters (typical of formats related to a.out) or 16 201characters (typical of formats related to coff). 202 203@cindex libraries 204@command{ar} is considered a binary utility because archives of this sort 205are most often used as @dfn{libraries} holding commonly needed 206subroutines. 207 208@cindex symbol index 209@command{ar} creates an index to the symbols defined in relocatable 210object modules in the archive when you specify the modifier @samp{s}. 211Once created, this index is updated in the archive whenever @command{ar} 212makes a change to its contents (save for the @samp{q} update operation). 213An archive with such an index speeds up linking to the library, and 214allows routines in the library to call each other without regard to 215their placement in the archive. 216 217You may use @samp{nm -s} or @samp{nm --print-armap} to list this index 218table. If an archive lacks the table, another form of @command{ar} called 219@command{ranlib} can be used to add just the table. 220 221@cindex thin archives 222@sc{gnu} @command{ar} can optionally create a @emph{thin} archive, 223which contains a symbol index and references to the original copies 224of the member files of the archives. Such an archive is useful 225for building libraries for use within a local build, where the 226relocatable objects are expected to remain available, and copying the 227contents of each object would only waste time and space. Thin archives 228are also @emph{flattened}, so that adding one or more archives to a 229thin archive will add the elements of the nested archive individually. 230The paths to the elements of the archive are stored relative to the 231archive itself. 232 233@cindex compatibility, @command{ar} 234@cindex @command{ar} compatibility 235@sc{gnu} @command{ar} is designed to be compatible with two different 236facilities. You can control its activity using command-line options, 237like the different varieties of @command{ar} on Unix systems; or, if you 238specify the single command-line option @option{-M}, you can control it 239with a script supplied via standard input, like the MRI ``librarian'' 240program. 241 242@c man end 243 244@menu 245* ar cmdline:: Controlling @command{ar} on the command line 246* ar scripts:: Controlling @command{ar} with a script 247@end menu 248 249@page 250@node ar cmdline 251@section Controlling @command{ar} on the Command Line 252 253@smallexample 254@c man begin SYNOPSIS ar 255ar [@option{--plugin} @var{name}] [@option{-X32_64}] [@option{-}]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] [@option{--target} @var{bfdname}] @var{archive} [@var{member}@dots{}] 256@c man end 257@end smallexample 258 259@cindex Unix compatibility, @command{ar} 260When you use @command{ar} in the Unix style, @command{ar} insists on at least two 261arguments to execute: one keyletter specifying the @emph{operation} 262(optionally accompanied by other keyletters specifying 263@emph{modifiers}), and the archive name to act on. 264 265Most operations can also accept further @var{member} arguments, 266specifying particular files to operate on. 267 268@c man begin OPTIONS ar 269 270@sc{gnu} @command{ar} allows you to mix the operation code @var{p} and modifier 271flags @var{mod} in any order, within the first command-line argument. 272 273If you wish, you may begin the first command-line argument with a 274dash. 275 276@cindex operations on archive 277The @var{p} keyletter specifies what operation to execute; it may be 278any of the following, but you must specify only one of them: 279 280@table @samp 281@item d 282@cindex deleting from archive 283@emph{Delete} modules from the archive. Specify the names of modules to 284be deleted as @var{member}@dots{}; the archive is untouched if you 285specify no files to delete. 286 287If you specify the @samp{v} modifier, @command{ar} lists each module 288as it is deleted. 289 290@item m 291@cindex moving in archive 292Use this operation to @emph{move} members in an archive. 293 294The ordering of members in an archive can make a difference in how 295programs are linked using the library, if a symbol is defined in more 296than one member. 297 298If no modifiers are used with @code{m}, any members you name in the 299@var{member} arguments are moved to the @emph{end} of the archive; 300you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a 301specified place instead. 302 303@item p 304@cindex printing from archive 305@emph{Print} the specified members of the archive, to the standard 306output file. If the @samp{v} modifier is specified, show the member 307name before copying its contents to standard output. 308 309If you specify no @var{member} arguments, all the files in the archive are 310printed. 311 312@item q 313@cindex quick append to archive 314@emph{Quick append}; Historically, add the files @var{member}@dots{} to the end of 315@var{archive}, without checking for replacement. 316 317The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this 318operation; new members are always placed at the end of the archive. 319 320The modifier @samp{v} makes @command{ar} list each file as it is appended. 321 322Since the point of this operation is speed, the archive's symbol table 323index is not updated, even if it already existed; you can use @samp{ar s} or 324@command{ranlib} explicitly to update the symbol table index. 325 326However, too many different systems assume quick append rebuilds the 327index, so @sc{gnu} @command{ar} implements @samp{q} as a synonym for @samp{r}. 328 329@item r 330@cindex replacement in archive 331Insert the files @var{member}@dots{} into @var{archive} (with 332@emph{replacement}). This operation differs from @samp{q} in that any 333previously existing members are deleted if their names match those being 334added. 335 336If one of the files named in @var{member}@dots{} does not exist, @command{ar} 337displays an error message, and leaves undisturbed any existing members 338of the archive matching that name. 339 340By default, new members are added at the end of the file; but you may 341use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request 342placement relative to some existing member. 343 344The modifier @samp{v} used with this operation elicits a line of 345output for each file inserted, along with one of the letters @samp{a} or 346@samp{r} to indicate whether the file was appended (no old member 347deleted) or replaced. 348 349@item s 350@cindex ranlib 351Add an index to the archive, or update it if it already exists. Note 352this command is an exception to the rule that there can only be one 353command letter, as it is possible to use it as either a command or a 354modifier. In either case it does the same thing. 355 356@item t 357@cindex contents of archive 358Display a @emph{table} listing the contents of @var{archive}, or those 359of the files listed in @var{member}@dots{} that are present in the 360archive. Normally only the member name is shown; if you also want to 361see the modes (permissions), timestamp, owner, group, and size, you can 362request that by also specifying the @samp{v} modifier. 363 364If you do not specify a @var{member}, all files in the archive 365are listed. 366 367@cindex repeated names in archive 368@cindex name duplication in archive 369If there is more than one file with the same name (say, @samp{fie}) in 370an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the 371first instance; to see them all, you must ask for a complete 372listing---in our example, @samp{ar t b.a}. 373@c WRS only; per Gumby, this is implementation-dependent, and in a more 374@c recent case in fact works the other way. 375 376@item x 377@cindex extract from archive 378@emph{Extract} members (named @var{member}) from the archive. You can 379use the @samp{v} modifier with this operation, to request that 380@command{ar} list each name as it extracts it. 381 382If you do not specify a @var{member}, all files in the archive 383are extracted. 384 385Files cannot be extracted from a thin archive. 386 387@item --help 388Displays the list of command line options supported by @command{ar} 389and then exits. 390 391@item --version 392Displays the version information of @command{ar} and then exits. 393 394@end table 395 396A number of modifiers (@var{mod}) may immediately follow the @var{p} 397keyletter, to specify variations on an operation's behavior: 398 399@table @samp 400@item a 401@cindex relative placement in archive 402Add new files @emph{after} an existing member of the 403archive. If you use the modifier @samp{a}, the name of an existing archive 404member must be present as the @var{relpos} argument, before the 405@var{archive} specification. 406 407@item b 408Add new files @emph{before} an existing member of the 409archive. If you use the modifier @samp{b}, the name of an existing archive 410member must be present as the @var{relpos} argument, before the 411@var{archive} specification. (same as @samp{i}). 412 413@item c 414@cindex creating archives 415@emph{Create} the archive. The specified @var{archive} is always 416created if it did not exist, when you request an update. But a warning is 417issued unless you specify in advance that you expect to create it, by 418using this modifier. 419 420@item D 421@cindex deterministic archives 422@kindex --enable-deterministic-archives 423Operate in @emph{deterministic} mode. When adding files and the archive 424index use zero for UIDs, GIDs, timestamps, and use consistent file modes 425for all files. When this option is used, if @command{ar} is used with 426identical options and identical input files, multiple runs will create 427identical output files regardless of the input files' owners, groups, 428file modes, or modification times. 429 430If @file{binutils} was configured with 431@option{--enable-deterministic-archives}, then this mode is on by default. 432It can be disabled with the @samp{U} modifier, below. 433 434@item f 435Truncate names in the archive. @sc{gnu} @command{ar} will normally permit file 436names of any length. This will cause it to create archives which are 437not compatible with the native @command{ar} program on some systems. If 438this is a concern, the @samp{f} modifier may be used to truncate file 439names when putting them in the archive. 440 441@item i 442Insert new files @emph{before} an existing member of the 443archive. If you use the modifier @samp{i}, the name of an existing archive 444member must be present as the @var{relpos} argument, before the 445@var{archive} specification. (same as @samp{b}). 446 447@item l 448This modifier is accepted but not used. 449@c whaffor ar l modifier??? presumably compat; with 450@c what???---doc@@cygnus.com, 25jan91 451 452@item N 453Uses the @var{count} parameter. This is used if there are multiple 454entries in the archive with the same name. Extract or delete instance 455@var{count} of the given name from the archive. 456 457@item o 458@cindex dates in archive 459Preserve the @emph{original} dates of members when extracting them. If 460you do not specify this modifier, files extracted from the archive 461are stamped with the time of extraction. 462 463@item P 464Use the full path name when matching names in the archive. @sc{gnu} 465@command{ar} can not create an archive with a full path name (such archives 466are not POSIX complaint), but other archive creators can. This option 467will cause @sc{gnu} @command{ar} to match file names using a complete path 468name, which can be convenient when extracting a single file from an 469archive created by another tool. 470 471@item s 472@cindex writing archive index 473Write an object-file index into the archive, or update an existing one, 474even if no other change is made to the archive. You may use this modifier 475flag either with any operation, or alone. Running @samp{ar s} on an 476archive is equivalent to running @samp{ranlib} on it. 477 478@item S 479@cindex not writing archive index 480Do not generate an archive symbol table. This can speed up building a 481large library in several steps. The resulting archive can not be used 482with the linker. In order to build a symbol table, you must omit the 483@samp{S} modifier on the last execution of @samp{ar}, or you must run 484@samp{ranlib} on the archive. 485 486@item T 487@cindex creating thin archive 488Make the specified @var{archive} a @emph{thin} archive. If it already 489exists and is a regular archive, the existing members must be present 490in the same directory as @var{archive}. 491 492@item u 493@cindex updating an archive 494Normally, @samp{ar r}@dots{} inserts all files 495listed into the archive. If you would like to insert @emph{only} those 496of the files you list that are newer than existing members of the same 497names, use this modifier. The @samp{u} modifier is allowed only for the 498operation @samp{r} (replace). In particular, the combination @samp{qu} is 499not allowed, since checking the timestamps would lose any speed 500advantage from the operation @samp{q}. 501 502@item U 503@cindex deterministic archives 504@kindex --enable-deterministic-archives 505Do @emph{not} operate in @emph{deterministic} mode. This is the inverse 506of the @samp{D} modifier, above: added files and the archive index will 507get their actual UID, GID, timestamp, and file mode values. 508 509This is the default unless @file{binutils} was configured with 510@option{--enable-deterministic-archives}. 511 512@item v 513This modifier requests the @emph{verbose} version of an operation. Many 514operations display additional information, such as filenames processed, 515when the modifier @samp{v} is appended. 516 517@item V 518This modifier shows the version number of @command{ar}. 519@end table 520 521@command{ar} ignores an initial option spelt @samp{-X32_64}, for 522compatibility with AIX. The behaviour produced by this option is the 523default for @sc{gnu} @command{ar}. @command{ar} does not support any of the other 524@samp{-X} options; in particular, it does not support @option{-X32} 525which is the default for AIX @command{ar}. 526 527The optional command line switch @option{--plugin} @var{name} causes 528@command{ar} to load the plugin called @var{name} which adds support 529for more file formats. This option is only available if the toolchain 530has been built with plugin support enabled. 531 532The optional command line switch @option{--target} @var{bfdname} 533specifies that the archive members are in an object code format 534different from your system's default format. See 535@xref{Target Selection}, for more information. 536 537@c man end 538 539@ignore 540@c man begin SEEALSO ar 541nm(1), ranlib(1), and the Info entries for @file{binutils}. 542@c man end 543@end ignore 544 545@node ar scripts 546@section Controlling @command{ar} with a Script 547 548@smallexample 549ar -M [ <@var{script} ] 550@end smallexample 551 552@cindex MRI compatibility, @command{ar} 553@cindex scripts, @command{ar} 554If you use the single command-line option @samp{-M} with @command{ar}, you 555can control its operation with a rudimentary command language. This 556form of @command{ar} operates interactively if standard input is coming 557directly from a terminal. During interactive use, @command{ar} prompts for 558input (the prompt is @samp{AR >}), and continues executing even after 559errors. If you redirect standard input to a script file, no prompts are 560issued, and @command{ar} abandons execution (with a nonzero exit code) 561on any error. 562 563The @command{ar} command language is @emph{not} designed to be equivalent 564to the command-line options; in fact, it provides somewhat less control 565over archives. The only purpose of the command language is to ease the 566transition to @sc{gnu} @command{ar} for developers who already have scripts 567written for the MRI ``librarian'' program. 568 569The syntax for the @command{ar} command language is straightforward: 570@itemize @bullet 571@item 572commands are recognized in upper or lower case; for example, @code{LIST} 573is the same as @code{list}. In the following descriptions, commands are 574shown in upper case for clarity. 575 576@item 577a single command may appear on each line; it is the first word on the 578line. 579 580@item 581empty lines are allowed, and have no effect. 582 583@item 584comments are allowed; text after either of the characters @samp{*} 585or @samp{;} is ignored. 586 587@item 588Whenever you use a list of names as part of the argument to an @command{ar} 589command, you can separate the individual names with either commas or 590blanks. Commas are shown in the explanations below, for clarity. 591 592@item 593@samp{+} is used as a line continuation character; if @samp{+} appears 594at the end of a line, the text on the following line is considered part 595of the current command. 596@end itemize 597 598Here are the commands you can use in @command{ar} scripts, or when using 599@command{ar} interactively. Three of them have special significance: 600 601@code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is 602a temporary file required for most of the other commands. 603 604@code{SAVE} commits the changes so far specified by the script. Prior 605to @code{SAVE}, commands affect only the temporary copy of the current 606archive. 607 608@table @code 609@item ADDLIB @var{archive} 610@itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module}) 611Add all the contents of @var{archive} (or, if specified, each named 612@var{module} from @var{archive}) to the current archive. 613 614Requires prior use of @code{OPEN} or @code{CREATE}. 615 616@item ADDMOD @var{member}, @var{member}, @dots{} @var{member} 617@c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}" 618@c else like "ar q..." 619Add each named @var{member} as a module in the current archive. 620 621Requires prior use of @code{OPEN} or @code{CREATE}. 622 623@item CLEAR 624Discard the contents of the current archive, canceling the effect of 625any operations since the last @code{SAVE}. May be executed (with no 626effect) even if no current archive is specified. 627 628@item CREATE @var{archive} 629Creates an archive, and makes it the current archive (required for many 630other commands). The new archive is created with a temporary name; it 631is not actually saved as @var{archive} until you use @code{SAVE}. 632You can overwrite existing archives; similarly, the contents of any 633existing file named @var{archive} will not be destroyed until @code{SAVE}. 634 635@item DELETE @var{module}, @var{module}, @dots{} @var{module} 636Delete each listed @var{module} from the current archive; equivalent to 637@samp{ar -d @var{archive} @var{module} @dots{} @var{module}}. 638 639Requires prior use of @code{OPEN} or @code{CREATE}. 640 641@item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) 642@itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile} 643List each named @var{module} present in @var{archive}. The separate 644command @code{VERBOSE} specifies the form of the output: when verbose 645output is off, output is like that of @samp{ar -t @var{archive} 646@var{module}@dots{}}. When verbose output is on, the listing is like 647@samp{ar -tv @var{archive} @var{module}@dots{}}. 648 649Output normally goes to the standard output stream; however, if you 650specify @var{outputfile} as a final argument, @command{ar} directs the 651output to that file. 652 653@item END 654Exit from @command{ar}, with a @code{0} exit code to indicate successful 655completion. This command does not save the output file; if you have 656changed the current archive since the last @code{SAVE} command, those 657changes are lost. 658 659@item EXTRACT @var{module}, @var{module}, @dots{} @var{module} 660Extract each named @var{module} from the current archive, writing them 661into the current directory as separate files. Equivalent to @samp{ar -x 662@var{archive} @var{module}@dots{}}. 663 664Requires prior use of @code{OPEN} or @code{CREATE}. 665 666@ignore 667@c FIXME Tokens but no commands??? 668@item FULLDIR 669 670@item HELP 671@end ignore 672 673@item LIST 674Display full contents of the current archive, in ``verbose'' style 675regardless of the state of @code{VERBOSE}. The effect is like @samp{ar 676tv @var{archive}}. (This single command is a @sc{gnu} @command{ar} 677enhancement, rather than present for MRI compatibility.) 678 679Requires prior use of @code{OPEN} or @code{CREATE}. 680 681@item OPEN @var{archive} 682Opens an existing archive for use as the current archive (required for 683many other commands). Any changes as the result of subsequent commands 684will not actually affect @var{archive} until you next use @code{SAVE}. 685 686@item REPLACE @var{module}, @var{module}, @dots{} @var{module} 687In the current archive, replace each existing @var{module} (named in 688the @code{REPLACE} arguments) from files in the current working directory. 689To execute this command without errors, both the file, and the module in 690the current archive, must exist. 691 692Requires prior use of @code{OPEN} or @code{CREATE}. 693 694@item VERBOSE 695Toggle an internal flag governing the output from @code{DIRECTORY}. 696When the flag is on, @code{DIRECTORY} output matches output from 697@samp{ar -tv }@dots{}. 698 699@item SAVE 700Commit your changes to the current archive, and actually save it as a 701file with the name specified in the last @code{CREATE} or @code{OPEN} 702command. 703 704Requires prior use of @code{OPEN} or @code{CREATE}. 705 706@end table 707 708@iftex 709@node ld 710@chapter ld 711@cindex linker 712@kindex ld 713The @sc{gnu} linker @command{ld} is now described in a separate manual. 714@xref{Top,, Overview,, Using LD: the @sc{gnu} linker}. 715@end iftex 716 717@node nm 718@chapter nm 719@cindex symbols 720@kindex nm 721 722@c man title nm list symbols from object files 723 724@smallexample 725@c man begin SYNOPSIS nm 726nm [@option{-a}|@option{--debug-syms}] 727 [@option{-g}|@option{--extern-only}][@option{--plugin} @var{name}] 728 [@option{-B}] [@option{-C}|@option{--demangle}[=@var{style}]] [@option{-D}|@option{--dynamic}] 729 [@option{-S}|@option{--print-size}] [@option{-s}|@option{--print-armap}] 730 [@option{-A}|@option{-o}|@option{--print-file-name}][@option{--special-syms}] 731 [@option{-n}|@option{-v}|@option{--numeric-sort}] [@option{-p}|@option{--no-sort}] 732 [@option{-r}|@option{--reverse-sort}] [@option{--size-sort}] [@option{-u}|@option{--undefined-only}] 733 [@option{-t} @var{radix}|@option{--radix=}@var{radix}] [@option{-P}|@option{--portability}] 734 [@option{--target=}@var{bfdname}] [@option{-f}@var{format}|@option{--format=}@var{format}] 735 [@option{--defined-only}] [@option{-l}|@option{--line-numbers}] [@option{--no-demangle}] 736 [@option{-V}|@option{--version}] [@option{-X 32_64}] [@option{--help}] [@var{objfile}@dots{}] 737@c man end 738@end smallexample 739 740@c man begin DESCRIPTION nm 741@sc{gnu} @command{nm} lists the symbols from object files @var{objfile}@dots{}. 742If no object files are listed as arguments, @command{nm} assumes the file 743@file{a.out}. 744 745For each symbol, @command{nm} shows: 746 747@itemize @bullet 748@item 749The symbol value, in the radix selected by options (see below), or 750hexadecimal by default. 751 752@item 753The symbol type. At least the following types are used; others are, as 754well, depending on the object file format. If lowercase, the symbol is 755usually local; if uppercase, the symbol is global (external). There 756are however a few lowercase symbols that are shown for special global 757symbols (@code{u}, @code{v} and @code{w}). 758 759@c Some more detail on exactly what these symbol types are used for 760@c would be nice. 761@table @code 762@item A 763The symbol's value is absolute, and will not be changed by further 764linking. 765 766@item B 767@itemx b 768The symbol is in the uninitialized data section (known as BSS). 769 770@item C 771The symbol is common. Common symbols are uninitialized data. When 772linking, multiple common symbols may appear with the same name. If the 773symbol is defined anywhere, the common symbols are treated as undefined 774references. 775@ifclear man 776For more details on common symbols, see the discussion of 777--warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}. 778@end ifclear 779 780@item D 781@itemx d 782The symbol is in the initialized data section. 783 784@item G 785@itemx g 786The symbol is in an initialized data section for small objects. Some 787object file formats permit more efficient access to small data objects, 788such as a global int variable as opposed to a large global array. 789 790@item i 791For PE format files this indicates that the symbol is in a section 792specific to the implementation of DLLs. For ELF format files this 793indicates that the symbol is an indirect function. This is a GNU 794extension to the standard set of ELF symbol types. It indicates a 795symbol which if referenced by a relocation does not evaluate to its 796address, but instead must be invoked at runtime. The runtime 797execution will then return the value to be used in the relocation. 798 799@item N 800The symbol is a debugging symbol. 801 802@item p 803The symbols is in a stack unwind section. 804 805@item R 806@itemx r 807The symbol is in a read only data section. 808 809@item S 810@itemx s 811The symbol is in an uninitialized data section for small objects. 812 813@item T 814@itemx t 815The symbol is in the text (code) section. 816 817@item U 818The symbol is undefined. 819 820@item u 821The symbol is a unique global symbol. This is a GNU extension to the 822standard set of ELF symbol bindings. For such a symbol the dynamic linker 823will make sure that in the entire process there is just one symbol with 824this name and type in use. 825 826@item V 827@itemx v 828The symbol is a weak object. When a weak defined symbol is linked with 829a normal defined symbol, the normal defined symbol is used with no error. 830When a weak undefined symbol is linked and the symbol is not defined, 831the value of the weak symbol becomes zero with no error. On some 832systems, uppercase indicates that a default value has been specified. 833 834@item W 835@itemx w 836The symbol is a weak symbol that has not been specifically tagged as a 837weak object symbol. When a weak defined symbol is linked with a normal 838defined symbol, the normal defined symbol is used with no error. 839When a weak undefined symbol is linked and the symbol is not defined, 840the value of the symbol is determined in a system-specific manner without 841error. On some systems, uppercase indicates that a default value has been 842specified. 843 844@item - 845The symbol is a stabs symbol in an a.out object file. In this case, the 846next values printed are the stabs other field, the stabs desc field, and 847the stab type. Stabs symbols are used to hold debugging information. 848@ifclear man 849For more information, see @ref{Top,Stabs,Stabs Overview,stabs.info, The 850``stabs'' debug format}. 851@end ifclear 852 853@item ? 854The symbol type is unknown, or object file format specific. 855@end table 856 857@item 858The symbol name. 859@end itemize 860 861@c man end 862 863@c man begin OPTIONS nm 864The long and short forms of options, shown here as alternatives, are 865equivalent. 866 867@table @env 868@item -A 869@itemx -o 870@itemx --print-file-name 871@cindex input file name 872@cindex file name 873@cindex source file name 874Precede each symbol by the name of the input file (or archive member) 875in which it was found, rather than identifying the input file once only, 876before all of its symbols. 877 878@item -a 879@itemx --debug-syms 880@cindex debugging symbols 881Display all symbols, even debugger-only symbols; normally these are not 882listed. 883 884@item -B 885@cindex @command{nm} format 886@cindex @command{nm} compatibility 887The same as @option{--format=bsd} (for compatibility with the MIPS @command{nm}). 888 889@item -C 890@itemx --demangle[=@var{style}] 891@cindex demangling in nm 892Decode (@dfn{demangle}) low-level symbol names into user-level names. 893Besides removing any initial underscore prepended by the system, this 894makes C++ function names readable. Different compilers have different 895mangling styles. The optional demangling style argument can be used to 896choose an appropriate demangling style for your compiler. @xref{c++filt}, 897for more information on demangling. 898 899@item --no-demangle 900Do not demangle low-level symbol names. This is the default. 901 902@item -D 903@itemx --dynamic 904@cindex dynamic symbols 905Display the dynamic symbols rather than the normal symbols. This is 906only meaningful for dynamic objects, such as certain types of shared 907libraries. 908 909@item -f @var{format} 910@itemx --format=@var{format} 911@cindex @command{nm} format 912@cindex @command{nm} compatibility 913Use the output format @var{format}, which can be @code{bsd}, 914@code{sysv}, or @code{posix}. The default is @code{bsd}. 915Only the first character of @var{format} is significant; it can be 916either upper or lower case. 917 918@item -g 919@itemx --extern-only 920@cindex external symbols 921Display only external symbols. 922 923@item --plugin @var{name} 924@cindex load plugin 925Load the plugin called @var{name} to add support for extra target 926types. This option is only available if the toolchain has been built 927with plugin support enabled. 928 929@item -l 930@itemx --line-numbers 931@cindex symbol line numbers 932For each symbol, use debugging information to try to find a filename and 933line number. For a defined symbol, look for the line number of the 934address of the symbol. For an undefined symbol, look for the line 935number of a relocation entry which refers to the symbol. If line number 936information can be found, print it after the other symbol information. 937 938@item -n 939@itemx -v 940@itemx --numeric-sort 941Sort symbols numerically by their addresses, rather than alphabetically 942by their names. 943 944@item -p 945@itemx --no-sort 946@cindex sorting symbols 947Do not bother to sort the symbols in any order; print them in the order 948encountered. 949 950@item -P 951@itemx --portability 952Use the POSIX.2 standard output format instead of the default format. 953Equivalent to @samp{-f posix}. 954 955@item -S 956@itemx --print-size 957Print both value and size of defined symbols for the @code{bsd} output style. 958This option has no effect for object formats that do not record symbol 959sizes, unless @samp{--size-sort} is also used in which case a 960calculated size is displayed. 961 962@item -s 963@itemx --print-armap 964@cindex symbol index, listing 965When listing symbols from archive members, include the index: a mapping 966(stored in the archive by @command{ar} or @command{ranlib}) of which modules 967contain definitions for which names. 968 969@item -r 970@itemx --reverse-sort 971Reverse the order of the sort (whether numeric or alphabetic); let the 972last come first. 973 974@item --size-sort 975Sort symbols by size. The size is computed as the difference between 976the value of the symbol and the value of the symbol with the next higher 977value. If the @code{bsd} output format is used the size of the symbol 978is printed, rather than the value, and @samp{-S} must be used in order 979both size and value to be printed. 980 981@item --special-syms 982Display symbols which have a target-specific special meaning. These 983symbols are usually used by the target for some special processing and 984are not normally helpful when included included in the normal symbol 985lists. For example for ARM targets this option would skip the mapping 986symbols used to mark transitions between ARM code, THUMB code and 987data. 988 989@item -t @var{radix} 990@itemx --radix=@var{radix} 991Use @var{radix} as the radix for printing the symbol values. It must be 992@samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal. 993 994@item --target=@var{bfdname} 995@cindex object code format 996Specify an object code format other than your system's default format. 997@xref{Target Selection}, for more information. 998 999@item -u 1000@itemx --undefined-only 1001@cindex external symbols 1002@cindex undefined symbols 1003Display only undefined symbols (those external to each object file). 1004 1005@item --defined-only 1006@cindex external symbols 1007@cindex undefined symbols 1008Display only defined symbols for each object file. 1009 1010@item -V 1011@itemx --version 1012Show the version number of @command{nm} and exit. 1013 1014@item -X 1015This option is ignored for compatibility with the AIX version of 1016@command{nm}. It takes one parameter which must be the string 1017@option{32_64}. The default mode of AIX @command{nm} corresponds 1018to @option{-X 32}, which is not supported by @sc{gnu} @command{nm}. 1019 1020@item --help 1021Show a summary of the options to @command{nm} and exit. 1022@end table 1023 1024@c man end 1025 1026@ignore 1027@c man begin SEEALSO nm 1028ar(1), objdump(1), ranlib(1), and the Info entries for @file{binutils}. 1029@c man end 1030@end ignore 1031 1032@node objcopy 1033@chapter objcopy 1034 1035@c man title objcopy copy and translate object files 1036 1037@smallexample 1038@c man begin SYNOPSIS objcopy 1039objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}] 1040 [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}] 1041 [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}] 1042 [@option{-B} @var{bfdarch}|@option{--binary-architecture=}@var{bfdarch}] 1043 [@option{-S}|@option{--strip-all}] 1044 [@option{-g}|@option{--strip-debug}] 1045 [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}] 1046 [@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}] 1047 [@option{--strip-unneeded-symbol=}@var{symbolname}] 1048 [@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}] 1049 [@option{--localize-hidden}] 1050 [@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}] 1051 [@option{--globalize-symbol=}@var{symbolname}] 1052 [@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}] 1053 [@option{-w}|@option{--wildcard}] 1054 [@option{-x}|@option{--discard-all}] 1055 [@option{-X}|@option{--discard-locals}] 1056 [@option{-b} @var{byte}|@option{--byte=}@var{byte}] 1057 [@option{-i} [@var{breadth}]|@option{--interleave}[=@var{breadth}]] 1058 [@option{--interleave-width=}@var{width}] 1059 [@option{-j} @var{sectionname}|@option{--only-section=}@var{sectionname}] 1060 [@option{-R} @var{sectionname}|@option{--remove-section=}@var{sectionname}] 1061 [@option{-p}|@option{--preserve-dates}] 1062 [@option{-D}|@option{--enable-deterministic-archives}] 1063 [@option{-U}|@option{--disable-deterministic-archives}] 1064 [@option{--debugging}] 1065 [@option{--gap-fill=}@var{val}] 1066 [@option{--pad-to=}@var{address}] 1067 [@option{--set-start=}@var{val}] 1068 [@option{--adjust-start=}@var{incr}] 1069 [@option{--change-addresses=}@var{incr}] 1070 [@option{--change-section-address} @var{section}@{=,+,-@}@var{val}] 1071 [@option{--change-section-lma} @var{section}@{=,+,-@}@var{val}] 1072 [@option{--change-section-vma} @var{section}@{=,+,-@}@var{val}] 1073 [@option{--change-warnings}] [@option{--no-change-warnings}] 1074 [@option{--set-section-flags} @var{section}=@var{flags}] 1075 [@option{--add-section} @var{sectionname}=@var{filename}] 1076 [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]] 1077 [@option{--long-section-names} @{enable,disable,keep@}] 1078 [@option{--change-leading-char}] [@option{--remove-leading-char}] 1079 [@option{--reverse-bytes=}@var{num}] 1080 [@option{--srec-len=}@var{ival}] [@option{--srec-forceS3}] 1081 [@option{--redefine-sym} @var{old}=@var{new}] 1082 [@option{--redefine-syms=}@var{filename}] 1083 [@option{--weaken}] 1084 [@option{--keep-symbols=}@var{filename}] 1085 [@option{--strip-symbols=}@var{filename}] 1086 [@option{--strip-unneeded-symbols=}@var{filename}] 1087 [@option{--keep-global-symbols=}@var{filename}] 1088 [@option{--localize-symbols=}@var{filename}] 1089 [@option{--globalize-symbols=}@var{filename}] 1090 [@option{--weaken-symbols=}@var{filename}] 1091 [@option{--alt-machine-code=}@var{index}] 1092 [@option{--prefix-symbols=}@var{string}] 1093 [@option{--prefix-sections=}@var{string}] 1094 [@option{--prefix-alloc-sections=}@var{string}] 1095 [@option{--add-gnu-debuglink=}@var{path-to-file}] 1096 [@option{--keep-file-symbols}] 1097 [@option{--only-keep-debug}] 1098 [@option{--strip-dwo}] 1099 [@option{--extract-dwo}] 1100 [@option{--extract-symbol}] 1101 [@option{--writable-text}] 1102 [@option{--readonly-text}] 1103 [@option{--pure}] 1104 [@option{--impure}] 1105 [@option{--file-alignment=}@var{num}] 1106 [@option{--heap=}@var{size}] 1107 [@option{--image-base=}@var{address}] 1108 [@option{--section-alignment=}@var{num}] 1109 [@option{--stack=}@var{size}] 1110 [@option{--subsystem=}@var{which}:@var{major}.@var{minor}] 1111 [@option{--compress-debug-sections}] 1112 [@option{--decompress-debug-sections}] 1113 [@option{--dwarf-depth=@var{n}}] 1114 [@option{--dwarf-start=@var{n}}] 1115 [@option{-v}|@option{--verbose}] 1116 [@option{-V}|@option{--version}] 1117 [@option{--help}] [@option{--info}] 1118 @var{infile} [@var{outfile}] 1119@c man end 1120@end smallexample 1121 1122@c man begin DESCRIPTION objcopy 1123The @sc{gnu} @command{objcopy} utility copies the contents of an object 1124file to another. @command{objcopy} uses the @sc{gnu} @sc{bfd} Library to 1125read and write the object files. It can write the destination object 1126file in a format different from that of the source object file. The 1127exact behavior of @command{objcopy} is controlled by command-line options. 1128Note that @command{objcopy} should be able to copy a fully linked file 1129between any two formats. However, copying a relocatable object file 1130between any two formats may not work as expected. 1131 1132@command{objcopy} creates temporary files to do its translations and 1133deletes them afterward. @command{objcopy} uses @sc{bfd} to do all its 1134translation work; it has access to all the formats described in @sc{bfd} 1135and thus is able to recognize most formats without being told 1136explicitly. @xref{BFD,,BFD,ld.info,Using LD}. 1137 1138@command{objcopy} can be used to generate S-records by using an output 1139target of @samp{srec} (e.g., use @samp{-O srec}). 1140 1141@command{objcopy} can be used to generate a raw binary file by using an 1142output target of @samp{binary} (e.g., use @option{-O binary}). When 1143@command{objcopy} generates a raw binary file, it will essentially produce 1144a memory dump of the contents of the input object file. All symbols and 1145relocation information will be discarded. The memory dump will start at 1146the load address of the lowest section copied into the output file. 1147 1148When generating an S-record or a raw binary file, it may be helpful to 1149use @option{-S} to remove sections containing debugging information. In 1150some cases @option{-R} will be useful to remove sections which contain 1151information that is not needed by the binary file. 1152 1153Note---@command{objcopy} is not able to change the endianness of its input 1154files. If the input format has an endianness (some formats do not), 1155@command{objcopy} can only copy the inputs into file formats that have the 1156same endianness or which have no endianness (e.g., @samp{srec}). 1157(However, see the @option{--reverse-bytes} option.) 1158 1159@c man end 1160 1161@c man begin OPTIONS objcopy 1162 1163@table @env 1164@item @var{infile} 1165@itemx @var{outfile} 1166The input and output files, respectively. 1167If you do not specify @var{outfile}, @command{objcopy} creates a 1168temporary file and destructively renames the result with 1169the name of @var{infile}. 1170 1171@item -I @var{bfdname} 1172@itemx --input-target=@var{bfdname} 1173Consider the source file's object format to be @var{bfdname}, rather than 1174attempting to deduce it. @xref{Target Selection}, for more information. 1175 1176@item -O @var{bfdname} 1177@itemx --output-target=@var{bfdname} 1178Write the output file using the object format @var{bfdname}. 1179@xref{Target Selection}, for more information. 1180 1181@item -F @var{bfdname} 1182@itemx --target=@var{bfdname} 1183Use @var{bfdname} as the object format for both the input and the output 1184file; i.e., simply transfer data from source to destination with no 1185translation. @xref{Target Selection}, for more information. 1186 1187@item -B @var{bfdarch} 1188@itemx --binary-architecture=@var{bfdarch} 1189Useful when transforming a architecture-less input file into an object file. 1190In this case the output architecture can be set to @var{bfdarch}. This 1191option will be ignored if the input file has a known @var{bfdarch}. You 1192can access this binary data inside a program by referencing the special 1193symbols that are created by the conversion process. These symbols are 1194called _binary_@var{objfile}_start, _binary_@var{objfile}_end and 1195_binary_@var{objfile}_size. e.g. you can transform a picture file into 1196an object file and then access it in your code using these symbols. 1197 1198@item -j @var{sectionname} 1199@itemx --only-section=@var{sectionname} 1200Copy only the named section from the input file to the output file. 1201This option may be given more than once. Note that using this option 1202inappropriately may make the output file unusable. 1203 1204@item -R @var{sectionname} 1205@itemx --remove-section=@var{sectionname} 1206Remove any section named @var{sectionname} from the output file. This 1207option may be given more than once. Note that using this option 1208inappropriately may make the output file unusable. 1209 1210@item -S 1211@itemx --strip-all 1212Do not copy relocation and symbol information from the source file. 1213 1214@item -g 1215@itemx --strip-debug 1216Do not copy debugging symbols or sections from the source file. 1217 1218@item --strip-unneeded 1219Strip all symbols that are not needed for relocation processing. 1220 1221@item -K @var{symbolname} 1222@itemx --keep-symbol=@var{symbolname} 1223When stripping symbols, keep symbol @var{symbolname} even if it would 1224normally be stripped. This option may be given more than once. 1225 1226@item -N @var{symbolname} 1227@itemx --strip-symbol=@var{symbolname} 1228Do not copy symbol @var{symbolname} from the source file. This option 1229may be given more than once. 1230 1231@item --strip-unneeded-symbol=@var{symbolname} 1232Do not copy symbol @var{symbolname} from the source file unless it is needed 1233by a relocation. This option may be given more than once. 1234 1235@item -G @var{symbolname} 1236@itemx --keep-global-symbol=@var{symbolname} 1237Keep only symbol @var{symbolname} global. Make all other symbols local 1238to the file, so that they are not visible externally. This option may 1239be given more than once. 1240 1241@item --localize-hidden 1242In an ELF object, mark all symbols that have hidden or internal visibility 1243as local. This option applies on top of symbol-specific localization options 1244such as @option{-L}. 1245 1246@item -L @var{symbolname} 1247@itemx --localize-symbol=@var{symbolname} 1248Make symbol @var{symbolname} local to the file, so that it is not 1249visible externally. This option may be given more than once. 1250 1251@item -W @var{symbolname} 1252@itemx --weaken-symbol=@var{symbolname} 1253Make symbol @var{symbolname} weak. This option may be given more than once. 1254 1255@item --globalize-symbol=@var{symbolname} 1256Give symbol @var{symbolname} global scoping so that it is visible 1257outside of the file in which it is defined. This option may be given 1258more than once. 1259 1260@item -w 1261@itemx --wildcard 1262Permit regular expressions in @var{symbolname}s used in other command 1263line options. The question mark (?), asterisk (*), backslash (\) and 1264square brackets ([]) operators can be used anywhere in the symbol 1265name. If the first character of the symbol name is the exclamation 1266point (!) then the sense of the switch is reversed for that symbol. 1267For example: 1268 1269@smallexample 1270 -w -W !foo -W fo* 1271@end smallexample 1272 1273would cause objcopy to weaken all symbols that start with ``fo'' 1274except for the symbol ``foo''. 1275 1276@item -x 1277@itemx --discard-all 1278Do not copy non-global symbols from the source file. 1279@c FIXME any reason to prefer "non-global" to "local" here? 1280 1281@item -X 1282@itemx --discard-locals 1283Do not copy compiler-generated local symbols. 1284(These usually start with @samp{L} or @samp{.}.) 1285 1286@item -b @var{byte} 1287@itemx --byte=@var{byte} 1288If interleaving has been enabled via the @option{--interleave} option 1289then start the range of bytes to keep at the @var{byte}th byte. 1290@var{byte} can be in the range from 0 to @var{breadth}-1, where 1291@var{breadth} is the value given by the @option{--interleave} option. 1292 1293@item -i [@var{breadth}] 1294@itemx --interleave[=@var{breadth}] 1295Only copy a range out of every @var{breadth} bytes. (Header data is 1296not affected). Select which byte in the range begins the copy with 1297the @option{--byte} option. Select the width of the range with the 1298@option{--interleave-width} option. 1299 1300This option is useful for creating files to program @sc{rom}. It is 1301typically used with an @code{srec} output target. Note that 1302@command{objcopy} will complain if you do not specify the 1303@option{--byte} option as well. 1304 1305The default interleave breadth is 4, so with @option{--byte} set to 0, 1306@command{objcopy} would copy the first byte out of every four bytes 1307from the input to the output. 1308 1309@item --interleave-width=@var{width} 1310When used with the @option{--interleave} option, copy @var{width} 1311bytes at a time. The start of the range of bytes to be copied is set 1312by the @option{--byte} option, and the extent of the range is set with 1313the @option{--interleave} option. 1314 1315The default value for this option is 1. The value of @var{width} plus 1316the @var{byte} value set by the @option{--byte} option must not exceed 1317the interleave breadth set by the @option{--interleave} option. 1318 1319This option can be used to create images for two 16-bit flashes interleaved 1320in a 32-bit bus by passing @option{-b 0 -i 4 --interleave-width=2} 1321and @option{-b 2 -i 4 --interleave-width=2} to two @command{objcopy} 1322commands. If the input was '12345678' then the outputs would be 1323'1256' and '3478' respectively. 1324 1325@item -p 1326@itemx --preserve-dates 1327Set the access and modification dates of the output file to be the same 1328as those of the input file. 1329 1330@item -D 1331@itemx --enable-deterministic-archives 1332@cindex deterministic archives 1333@kindex --enable-deterministic-archives 1334Operate in @emph{deterministic} mode. When copying archive members 1335and writing the archive index, use zero for UIDs, GIDs, timestamps, 1336and use consistent file modes for all files. 1337 1338If @file{binutils} was configured with 1339@option{--enable-deterministic-archives}, then this mode is on by default. 1340It can be disabled with the @samp{-U} option, below. 1341 1342@item -U 1343@itemx --disable-deterministic-archives 1344@cindex deterministic archives 1345@kindex --enable-deterministic-archives 1346Do @emph{not} operate in @emph{deterministic} mode. This is the 1347inverse of the @option{-D} option, above: when copying archive members 1348and writing the archive index, use their actual UID, GID, timestamp, 1349and file mode values. 1350 1351This is the default unless @file{binutils} was configured with 1352@option{--enable-deterministic-archives}. 1353 1354@item --debugging 1355Convert debugging information, if possible. This is not the default 1356because only certain debugging formats are supported, and the 1357conversion process can be time consuming. 1358 1359@item --gap-fill @var{val} 1360Fill gaps between sections with @var{val}. This operation applies to 1361the @emph{load address} (LMA) of the sections. It is done by increasing 1362the size of the section with the lower address, and filling in the extra 1363space created with @var{val}. 1364 1365@item --pad-to @var{address} 1366Pad the output file up to the load address @var{address}. This is 1367done by increasing the size of the last section. The extra space is 1368filled in with the value specified by @option{--gap-fill} (default zero). 1369 1370@item --set-start @var{val} 1371Set the start address of the new file to @var{val}. Not all object file 1372formats support setting the start address. 1373 1374@item --change-start @var{incr} 1375@itemx --adjust-start @var{incr} 1376@cindex changing start address 1377Change the start address by adding @var{incr}. Not all object file 1378formats support setting the start address. 1379 1380@item --change-addresses @var{incr} 1381@itemx --adjust-vma @var{incr} 1382@cindex changing object addresses 1383Change the VMA and LMA addresses of all sections, as well as the start 1384address, by adding @var{incr}. Some object file formats do not permit 1385section addresses to be changed arbitrarily. Note that this does not 1386relocate the sections; if the program expects sections to be loaded at a 1387certain address, and this option is used to change the sections such 1388that they are loaded at a different address, the program may fail. 1389 1390@item --change-section-address @var{section}@{=,+,-@}@var{val} 1391@itemx --adjust-section-vma @var{section}@{=,+,-@}@var{val} 1392@cindex changing section address 1393Set or change both the VMA address and the LMA address of the named 1394@var{section}. If @samp{=} is used, the section address is set to 1395@var{val}. Otherwise, @var{val} is added to or subtracted from the 1396section address. See the comments under @option{--change-addresses}, 1397above. If @var{section} does not exist in the input file, a warning will 1398be issued, unless @option{--no-change-warnings} is used. 1399 1400@item --change-section-lma @var{section}@{=,+,-@}@var{val} 1401@cindex changing section LMA 1402Set or change the LMA address of the named @var{section}. The LMA 1403address is the address where the section will be loaded into memory at 1404program load time. Normally this is the same as the VMA address, which 1405is the address of the section at program run time, but on some systems, 1406especially those where a program is held in ROM, the two can be 1407different. If @samp{=} is used, the section address is set to 1408@var{val}. Otherwise, @var{val} is added to or subtracted from the 1409section address. See the comments under @option{--change-addresses}, 1410above. If @var{section} does not exist in the input file, a warning 1411will be issued, unless @option{--no-change-warnings} is used. 1412 1413@item --change-section-vma @var{section}@{=,+,-@}@var{val} 1414@cindex changing section VMA 1415Set or change the VMA address of the named @var{section}. The VMA 1416address is the address where the section will be located once the 1417program has started executing. Normally this is the same as the LMA 1418address, which is the address where the section will be loaded into 1419memory, but on some systems, especially those where a program is held in 1420ROM, the two can be different. If @samp{=} is used, the section address 1421is set to @var{val}. Otherwise, @var{val} is added to or subtracted 1422from the section address. See the comments under 1423@option{--change-addresses}, above. If @var{section} does not exist in 1424the input file, a warning will be issued, unless 1425@option{--no-change-warnings} is used. 1426 1427@item --change-warnings 1428@itemx --adjust-warnings 1429If @option{--change-section-address} or @option{--change-section-lma} or 1430@option{--change-section-vma} is used, and the named section does not 1431exist, issue a warning. This is the default. 1432 1433@item --no-change-warnings 1434@itemx --no-adjust-warnings 1435Do not issue a warning if @option{--change-section-address} or 1436@option{--adjust-section-lma} or @option{--adjust-section-vma} is used, even 1437if the named section does not exist. 1438 1439@item --set-section-flags @var{section}=@var{flags} 1440Set the flags for the named section. The @var{flags} argument is a 1441comma separated string of flag names. The recognized names are 1442@samp{alloc}, @samp{contents}, @samp{load}, @samp{noload}, 1443@samp{readonly}, @samp{code}, @samp{data}, @samp{rom}, @samp{share}, and 1444@samp{debug}. You can set the @samp{contents} flag for a section which 1445does not have contents, but it is not meaningful to clear the 1446@samp{contents} flag of a section which does have contents--just remove 1447the section instead. Not all flags are meaningful for all object file 1448formats. 1449 1450@item --add-section @var{sectionname}=@var{filename} 1451Add a new section named @var{sectionname} while copying the file. The 1452contents of the new section are taken from the file @var{filename}. The 1453size of the section will be the size of the file. This option only 1454works on file formats which can support sections with arbitrary names. 1455 1456@item --rename-section @var{oldname}=@var{newname}[,@var{flags}] 1457Rename a section from @var{oldname} to @var{newname}, optionally 1458changing the section's flags to @var{flags} in the process. This has 1459the advantage over usng a linker script to perform the rename in that 1460the output stays as an object file and does not become a linked 1461executable. 1462 1463This option is particularly helpful when the input format is binary, 1464since this will always create a section called .data. If for example, 1465you wanted instead to create a section called .rodata containing binary 1466data you could use the following command line to achieve it: 1467 1468@smallexample 1469 objcopy -I binary -O <output_format> -B <architecture> \ 1470 --rename-section .data=.rodata,alloc,load,readonly,data,contents \ 1471 <input_binary_file> <output_object_file> 1472@end smallexample 1473 1474@item --long-section-names @{enable,disable,keep@} 1475Controls the handling of long section names when processing @code{COFF} 1476and @code{PE-COFF} object formats. The default behaviour, @samp{keep}, 1477is to preserve long section names if any are present in the input file. 1478The @samp{enable} and @samp{disable} options forcibly enable or disable 1479the use of long section names in the output object; when @samp{disable} 1480is in effect, any long section names in the input object will be truncated. 1481The @samp{enable} option will only emit long section names if any are 1482present in the inputs; this is mostly the same as @samp{keep}, but it 1483is left undefined whether the @samp{enable} option might force the 1484creation of an empty string table in the output file. 1485 1486@item --change-leading-char 1487Some object file formats use special characters at the start of 1488symbols. The most common such character is underscore, which compilers 1489often add before every symbol. This option tells @command{objcopy} to 1490change the leading character of every symbol when it converts between 1491object file formats. If the object file formats use the same leading 1492character, this option has no effect. Otherwise, it will add a 1493character, or remove a character, or change a character, as 1494appropriate. 1495 1496@item --remove-leading-char 1497If the first character of a global symbol is a special symbol leading 1498character used by the object file format, remove the character. The 1499most common symbol leading character is underscore. This option will 1500remove a leading underscore from all global symbols. This can be useful 1501if you want to link together objects of different file formats with 1502different conventions for symbol names. This is different from 1503@option{--change-leading-char} because it always changes the symbol name 1504when appropriate, regardless of the object file format of the output 1505file. 1506 1507@item --reverse-bytes=@var{num} 1508Reverse the bytes in a section with output contents. A section length must 1509be evenly divisible by the value given in order for the swap to be able to 1510take place. Reversing takes place before the interleaving is performed. 1511 1512This option is used typically in generating ROM images for problematic 1513target systems. For example, on some target boards, the 32-bit words 1514fetched from 8-bit ROMs are re-assembled in little-endian byte order 1515regardless of the CPU byte order. Depending on the programming model, the 1516endianness of the ROM may need to be modified. 1517 1518Consider a simple file with a section containing the following eight 1519bytes: @code{12345678}. 1520 1521Using @samp{--reverse-bytes=2} for the above example, the bytes in the 1522output file would be ordered @code{21436587}. 1523 1524Using @samp{--reverse-bytes=4} for the above example, the bytes in the 1525output file would be ordered @code{43218765}. 1526 1527By using @samp{--reverse-bytes=2} for the above example, followed by 1528@samp{--reverse-bytes=4} on the output file, the bytes in the second 1529output file would be ordered @code{34127856}. 1530 1531@item --srec-len=@var{ival} 1532Meaningful only for srec output. Set the maximum length of the Srecords 1533being produced to @var{ival}. This length covers both address, data and 1534crc fields. 1535 1536@item --srec-forceS3 1537Meaningful only for srec output. Avoid generation of S1/S2 records, 1538creating S3-only record format. 1539 1540@item --redefine-sym @var{old}=@var{new} 1541Change the name of a symbol @var{old}, to @var{new}. This can be useful 1542when one is trying link two things together for which you have no 1543source, and there are name collisions. 1544 1545@item --redefine-syms=@var{filename} 1546Apply @option{--redefine-sym} to each symbol pair "@var{old} @var{new}" 1547listed in the file @var{filename}. @var{filename} is simply a flat file, 1548with one symbol pair per line. Line comments may be introduced by the hash 1549character. This option may be given more than once. 1550 1551@item --weaken 1552Change all global symbols in the file to be weak. This can be useful 1553when building an object which will be linked against other objects using 1554the @option{-R} option to the linker. This option is only effective when 1555using an object file format which supports weak symbols. 1556 1557@item --keep-symbols=@var{filename} 1558Apply @option{--keep-symbol} option to each symbol listed in the file 1559@var{filename}. @var{filename} is simply a flat file, with one symbol 1560name per line. Line comments may be introduced by the hash character. 1561This option may be given more than once. 1562 1563@item --strip-symbols=@var{filename} 1564Apply @option{--strip-symbol} option to each symbol listed in the file 1565@var{filename}. @var{filename} is simply a flat file, with one symbol 1566name per line. Line comments may be introduced by the hash character. 1567This option may be given more than once. 1568 1569@item --strip-unneeded-symbols=@var{filename} 1570Apply @option{--strip-unneeded-symbol} option to each symbol listed in 1571the file @var{filename}. @var{filename} is simply a flat file, with one 1572symbol name per line. Line comments may be introduced by the hash 1573character. This option may be given more than once. 1574 1575@item --keep-global-symbols=@var{filename} 1576Apply @option{--keep-global-symbol} option to each symbol listed in the 1577file @var{filename}. @var{filename} is simply a flat file, with one 1578symbol name per line. Line comments may be introduced by the hash 1579character. This option may be given more than once. 1580 1581@item --localize-symbols=@var{filename} 1582Apply @option{--localize-symbol} option to each symbol listed in the file 1583@var{filename}. @var{filename} is simply a flat file, with one symbol 1584name per line. Line comments may be introduced by the hash character. 1585This option may be given more than once. 1586 1587@item --globalize-symbols=@var{filename} 1588Apply @option{--globalize-symbol} option to each symbol listed in the file 1589@var{filename}. @var{filename} is simply a flat file, with one symbol 1590name per line. Line comments may be introduced by the hash character. 1591This option may be given more than once. 1592 1593@item --weaken-symbols=@var{filename} 1594Apply @option{--weaken-symbol} option to each symbol listed in the file 1595@var{filename}. @var{filename} is simply a flat file, with one symbol 1596name per line. Line comments may be introduced by the hash character. 1597This option may be given more than once. 1598 1599@item --alt-machine-code=@var{index} 1600If the output architecture has alternate machine codes, use the 1601@var{index}th code instead of the default one. This is useful in case 1602a machine is assigned an official code and the tool-chain adopts the 1603new code, but other applications still depend on the original code 1604being used. For ELF based architectures if the @var{index} 1605alternative does not exist then the value is treated as an absolute 1606number to be stored in the e_machine field of the ELF header. 1607 1608@item --writable-text 1609Mark the output text as writable. This option isn't meaningful for all 1610object file formats. 1611 1612@item --readonly-text 1613Make the output text write protected. This option isn't meaningful for all 1614object file formats. 1615 1616@item --pure 1617Mark the output file as demand paged. This option isn't meaningful for all 1618object file formats. 1619 1620@item --impure 1621Mark the output file as impure. This option isn't meaningful for all 1622object file formats. 1623 1624@item --prefix-symbols=@var{string} 1625Prefix all symbols in the output file with @var{string}. 1626 1627@item --prefix-sections=@var{string} 1628Prefix all section names in the output file with @var{string}. 1629 1630@item --prefix-alloc-sections=@var{string} 1631Prefix all the names of all allocated sections in the output file with 1632@var{string}. 1633 1634@item --add-gnu-debuglink=@var{path-to-file} 1635Creates a .gnu_debuglink section which contains a reference to @var{path-to-file} 1636and adds it to the output file. 1637 1638@item --keep-file-symbols 1639When stripping a file, perhaps with @option{--strip-debug} or 1640@option{--strip-unneeded}, retain any symbols specifying source file names, 1641which would otherwise get stripped. 1642 1643@item --only-keep-debug 1644Strip a file, removing contents of any sections that would not be 1645stripped by @option{--strip-debug} and leaving the debugging sections 1646intact. In ELF files, this preserves all note sections in the output. 1647 1648The intention is that this option will be used in conjunction with 1649@option{--add-gnu-debuglink} to create a two part executable. One a 1650stripped binary which will occupy less space in RAM and in a 1651distribution and the second a debugging information file which is only 1652needed if debugging abilities are required. The suggested procedure 1653to create these files is as follows: 1654 1655@enumerate 1656@item Link the executable as normal. Assuming that is is called 1657@code{foo} then... 1658@item Run @code{objcopy --only-keep-debug foo foo.dbg} to 1659create a file containing the debugging info. 1660@item Run @code{objcopy --strip-debug foo} to create a 1661stripped executable. 1662@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo} 1663to add a link to the debugging info into the stripped executable. 1664@end enumerate 1665 1666Note---the choice of @code{.dbg} as an extension for the debug info 1667file is arbitrary. Also the @code{--only-keep-debug} step is 1668optional. You could instead do this: 1669 1670@enumerate 1671@item Link the executable as normal. 1672@item Copy @code{foo} to @code{foo.full} 1673@item Run @code{objcopy --strip-debug foo} 1674@item Run @code{objcopy --add-gnu-debuglink=foo.full foo} 1675@end enumerate 1676 1677i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the 1678full executable. It does not have to be a file created by the 1679@option{--only-keep-debug} switch. 1680 1681Note---this switch is only intended for use on fully linked files. It 1682does not make sense to use it on object files where the debugging 1683information may be incomplete. Besides the gnu_debuglink feature 1684currently only supports the presence of one filename containing 1685debugging information, not multiple filenames on a one-per-object-file 1686basis. 1687 1688@item --strip-dwo 1689Remove the contents of all DWARF .dwo sections, leaving the 1690remaining debugging sections and all symbols intact. 1691This option is intended for use by the compiler as part of 1692the @option{-gsplit-dwarf} option, which splits debug information 1693between the .o file and a separate .dwo file. The compiler 1694generates all debug information in the same file, then uses 1695the @option{--extract-dwo} option to copy the .dwo sections to 1696the .dwo file, then the @option{--strip-dwo} option to remove 1697those sections from the original .o file. 1698 1699@item --extract-dwo 1700Extract the contents of all DWARF .dwo sections. See the 1701@option{--strip-dwo} option for more information. 1702 1703@item --file-alignment @var{num} 1704Specify the file alignment. Sections in the file will always begin at 1705file offsets which are multiples of this number. This defaults to 1706512. 1707[This option is specific to PE targets.] 1708 1709@item --heap @var{reserve} 1710@itemx --heap @var{reserve},@var{commit} 1711Specify the number of bytes of memory to reserve (and optionally commit) 1712to be used as heap for this program. 1713[This option is specific to PE targets.] 1714 1715@item --image-base @var{value} 1716Use @var{value} as the base address of your program or dll. This is 1717the lowest memory location that will be used when your program or dll 1718is loaded. To reduce the need to relocate and improve performance of 1719your dlls, each should have a unique base address and not overlap any 1720other dlls. The default is 0x400000 for executables, and 0x10000000 1721for dlls. 1722[This option is specific to PE targets.] 1723 1724@item --section-alignment @var{num} 1725Sets the section alignment. Sections in memory will always begin at 1726addresses which are a multiple of this number. Defaults to 0x1000. 1727[This option is specific to PE targets.] 1728 1729@item --stack @var{reserve} 1730@itemx --stack @var{reserve},@var{commit} 1731Specify the number of bytes of memory to reserve (and optionally commit) 1732to be used as stack for this program. 1733[This option is specific to PE targets.] 1734 1735@item --subsystem @var{which} 1736@itemx --subsystem @var{which}:@var{major} 1737@itemx --subsystem @var{which}:@var{major}.@var{minor} 1738Specifies the subsystem under which your program will execute. The 1739legal values for @var{which} are @code{native}, @code{windows}, 1740@code{console}, @code{posix}, @code{efi-app}, @code{efi-bsd}, 1741@code{efi-rtd}, @code{sal-rtd}, and @code{xbox}. You may optionally set 1742the subsystem version also. Numeric values are also accepted for 1743@var{which}. 1744[This option is specific to PE targets.] 1745 1746@item --extract-symbol 1747Keep the file's section flags and symbols but remove all section data. 1748Specifically, the option: 1749 1750@itemize 1751@item removes the contents of all sections; 1752@item sets the size of every section to zero; and 1753@item sets the file's start address to zero. 1754@end itemize 1755 1756This option is used to build a @file{.sym} file for a VxWorks kernel. 1757It can also be a useful way of reducing the size of a @option{--just-symbols} 1758linker input file. 1759 1760@item --compress-debug-sections 1761Compress DWARF debug sections using zlib. 1762 1763@item --decompress-debug-sections 1764Decompress DWARF debug sections using zlib. 1765 1766@item -V 1767@itemx --version 1768Show the version number of @command{objcopy}. 1769 1770@item -v 1771@itemx --verbose 1772Verbose output: list all object files modified. In the case of 1773archives, @samp{objcopy -V} lists all members of the archive. 1774 1775@item --help 1776Show a summary of the options to @command{objcopy}. 1777 1778@item --info 1779Display a list showing all architectures and object formats available. 1780@end table 1781 1782@c man end 1783 1784@ignore 1785@c man begin SEEALSO objcopy 1786ld(1), objdump(1), and the Info entries for @file{binutils}. 1787@c man end 1788@end ignore 1789 1790@node objdump 1791@chapter objdump 1792 1793@cindex object file information 1794@kindex objdump 1795 1796@c man title objdump display information from object files. 1797 1798@smallexample 1799@c man begin SYNOPSIS objdump 1800objdump [@option{-a}|@option{--archive-headers}] 1801 [@option{-b} @var{bfdname}|@option{--target=@var{bfdname}}] 1802 [@option{-C}|@option{--demangle}[=@var{style}] ] 1803 [@option{-d}|@option{--disassemble}] 1804 [@option{-D}|@option{--disassemble-all}] 1805 [@option{-z}|@option{--disassemble-zeroes}] 1806 [@option{-EB}|@option{-EL}|@option{--endian=}@{big | little @}] 1807 [@option{-f}|@option{--file-headers}] 1808 [@option{-F}|@option{--file-offsets}] 1809 [@option{--file-start-context}] 1810 [@option{-g}|@option{--debugging}] 1811 [@option{-e}|@option{--debugging-tags}] 1812 [@option{-h}|@option{--section-headers}|@option{--headers}] 1813 [@option{-i}|@option{--info}] 1814 [@option{-j} @var{section}|@option{--section=}@var{section}] 1815 [@option{-l}|@option{--line-numbers}] 1816 [@option{-S}|@option{--source}] 1817 [@option{-m} @var{machine}|@option{--architecture=}@var{machine}] 1818 [@option{-M} @var{options}|@option{--disassembler-options=}@var{options}] 1819 [@option{-p}|@option{--private-headers}] 1820 [@option{-P} @var{options}|@option{--private=}@var{options}] 1821 [@option{-r}|@option{--reloc}] 1822 [@option{-R}|@option{--dynamic-reloc}] 1823 [@option{-s}|@option{--full-contents}] 1824 [@option{-W[lLiaprmfFsoRt]}| 1825 @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]] 1826 [@option{-G}|@option{--stabs}] 1827 [@option{-t}|@option{--syms}] 1828 [@option{-T}|@option{--dynamic-syms}] 1829 [@option{-x}|@option{--all-headers}] 1830 [@option{-w}|@option{--wide}] 1831 [@option{--start-address=}@var{address}] 1832 [@option{--stop-address=}@var{address}] 1833 [@option{--prefix-addresses}] 1834 [@option{--[no-]show-raw-insn}] 1835 [@option{--adjust-vma=}@var{offset}] 1836 [@option{--special-syms}] 1837 [@option{--prefix=}@var{prefix}] 1838 [@option{--prefix-strip=}@var{level}] 1839 [@option{--insn-width=}@var{width}] 1840 [@option{-V}|@option{--version}] 1841 [@option{-H}|@option{--help}] 1842 @var{objfile}@dots{} 1843@c man end 1844@end smallexample 1845 1846@c man begin DESCRIPTION objdump 1847 1848@command{objdump} displays information about one or more object files. 1849The options control what particular information to display. This 1850information is mostly useful to programmers who are working on the 1851compilation tools, as opposed to programmers who just want their 1852program to compile and work. 1853 1854@var{objfile}@dots{} are the object files to be examined. When you 1855specify archives, @command{objdump} shows information on each of the member 1856object files. 1857 1858@c man end 1859 1860@c man begin OPTIONS objdump 1861 1862The long and short forms of options, shown here as alternatives, are 1863equivalent. At least one option from the list 1864@option{-a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-P,-r,-R,-s,-S,-t,-T,-V,-x} must be given. 1865 1866@table @env 1867@item -a 1868@itemx --archive-header 1869@cindex archive headers 1870If any of the @var{objfile} files are archives, display the archive 1871header information (in a format similar to @samp{ls -l}). Besides the 1872information you could list with @samp{ar tv}, @samp{objdump -a} shows 1873the object file format of each archive member. 1874 1875@item --adjust-vma=@var{offset} 1876@cindex section addresses in objdump 1877@cindex VMA in objdump 1878When dumping information, first add @var{offset} to all the section 1879addresses. This is useful if the section addresses do not correspond to 1880the symbol table, which can happen when putting sections at particular 1881addresses when using a format which can not represent section addresses, 1882such as a.out. 1883 1884@item -b @var{bfdname} 1885@itemx --target=@var{bfdname} 1886@cindex object code format 1887Specify that the object-code format for the object files is 1888@var{bfdname}. This option may not be necessary; @var{objdump} can 1889automatically recognize many formats. 1890 1891For example, 1892@example 1893objdump -b oasys -m vax -h fu.o 1894@end example 1895@noindent 1896displays summary information from the section headers (@option{-h}) of 1897@file{fu.o}, which is explicitly identified (@option{-m}) as a VAX object 1898file in the format produced by Oasys compilers. You can list the 1899formats available with the @option{-i} option. 1900@xref{Target Selection}, for more information. 1901 1902@item -C 1903@itemx --demangle[=@var{style}] 1904@cindex demangling in objdump 1905Decode (@dfn{demangle}) low-level symbol names into user-level names. 1906Besides removing any initial underscore prepended by the system, this 1907makes C++ function names readable. Different compilers have different 1908mangling styles. The optional demangling style argument can be used to 1909choose an appropriate demangling style for your compiler. @xref{c++filt}, 1910for more information on demangling. 1911 1912@item -g 1913@itemx --debugging 1914Display debugging information. This attempts to parse STABS and IEEE 1915debugging format information stored in the file and print it out using 1916a C like syntax. If neither of these formats are found this option 1917falls back on the @option{-W} option to print any DWARF information in 1918the file. 1919 1920@item -e 1921@itemx --debugging-tags 1922Like @option{-g}, but the information is generated in a format compatible 1923with ctags tool. 1924 1925@item -d 1926@itemx --disassemble 1927@cindex disassembling object code 1928@cindex machine instructions 1929Display the assembler mnemonics for the machine instructions from 1930@var{objfile}. This option only disassembles those sections which are 1931expected to contain instructions. 1932 1933@item -D 1934@itemx --disassemble-all 1935Like @option{-d}, but disassemble the contents of all sections, not just 1936those expected to contain instructions. 1937 1938If the target is an ARM architecture this switch also has the effect 1939of forcing the disassembler to decode pieces of data found in code 1940sections as if they were instructions. 1941 1942@item --prefix-addresses 1943When disassembling, print the complete address on each line. This is 1944the older disassembly format. 1945 1946@item -EB 1947@itemx -EL 1948@itemx --endian=@{big|little@} 1949@cindex endianness 1950@cindex disassembly endianness 1951Specify the endianness of the object files. This only affects 1952disassembly. This can be useful when disassembling a file format which 1953does not describe endianness information, such as S-records. 1954 1955@item -f 1956@itemx --file-headers 1957@cindex object file header 1958Display summary information from the overall header of 1959each of the @var{objfile} files. 1960 1961@item -F 1962@itemx --file-offsets 1963@cindex object file offsets 1964When disassembling sections, whenever a symbol is displayed, also 1965display the file offset of the region of data that is about to be 1966dumped. If zeroes are being skipped, then when disassembly resumes, 1967tell the user how many zeroes were skipped and the file offset of the 1968location from where the disassembly resumes. When dumping sections, 1969display the file offset of the location from where the dump starts. 1970 1971@item --file-start-context 1972@cindex source code context 1973Specify that when displaying interlisted source code/disassembly 1974(assumes @option{-S}) from a file that has not yet been displayed, extend the 1975context to the start of the file. 1976 1977@item -h 1978@itemx --section-headers 1979@itemx --headers 1980@cindex section headers 1981Display summary information from the section headers of the 1982object file. 1983 1984File segments may be relocated to nonstandard addresses, for example by 1985using the @option{-Ttext}, @option{-Tdata}, or @option{-Tbss} options to 1986@command{ld}. However, some object file formats, such as a.out, do not 1987store the starting address of the file segments. In those situations, 1988although @command{ld} relocates the sections correctly, using @samp{objdump 1989-h} to list the file section headers cannot show the correct addresses. 1990Instead, it shows the usual addresses, which are implicit for the 1991target. 1992 1993@item -H 1994@itemx --help 1995Print a summary of the options to @command{objdump} and exit. 1996 1997@item -i 1998@itemx --info 1999@cindex architectures available 2000@cindex object formats available 2001Display a list showing all architectures and object formats available 2002for specification with @option{-b} or @option{-m}. 2003 2004@item -j @var{name} 2005@itemx --section=@var{name} 2006@cindex section information 2007Display information only for section @var{name}. 2008 2009@item -l 2010@itemx --line-numbers 2011@cindex source filenames for object files 2012Label the display (using debugging information) with the filename and 2013source line numbers corresponding to the object code or relocs shown. 2014Only useful with @option{-d}, @option{-D}, or @option{-r}. 2015 2016@item -m @var{machine} 2017@itemx --architecture=@var{machine} 2018@cindex architecture 2019@cindex disassembly architecture 2020Specify the architecture to use when disassembling object files. This 2021can be useful when disassembling object files which do not describe 2022architecture information, such as S-records. You can list the available 2023architectures with the @option{-i} option. 2024 2025If the target is an ARM architecture then this switch has an 2026additional effect. It restricts the disassembly to only those 2027instructions supported by the architecture specified by @var{machine}. 2028If it is necessary to use this switch because the input file does not 2029contain any architecture information, but it is also desired to 2030disassemble all the instructions use @option{-marm}. 2031 2032@item -M @var{options} 2033@itemx --disassembler-options=@var{options} 2034Pass target specific information to the disassembler. Only supported on 2035some targets. If it is necessary to specify more than one 2036disassembler option then multiple @option{-M} options can be used or 2037can be placed together into a comma separated list. 2038 2039If the target is an ARM architecture then this switch can be used to 2040select which register name set is used during disassembler. Specifying 2041@option{-M reg-names-std} (the default) will select the register names as 2042used in ARM's instruction set documentation, but with register 13 called 2043'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying 2044@option{-M reg-names-apcs} will select the name set used by the ARM 2045Procedure Call Standard, whilst specifying @option{-M reg-names-raw} will 2046just use @samp{r} followed by the register number. 2047 2048There are also two variants on the APCS register naming scheme enabled 2049by @option{-M reg-names-atpcs} and @option{-M reg-names-special-atpcs} which 2050use the ARM/Thumb Procedure Call Standard naming conventions. (Either 2051with the normal register names or the special register names). 2052 2053This option can also be used for ARM architectures to force the 2054disassembler to interpret all instructions as Thumb instructions by 2055using the switch @option{--disassembler-options=force-thumb}. This can be 2056useful when attempting to disassemble thumb code produced by other 2057compilers. 2058 2059For the x86, some of the options duplicate functions of the @option{-m} 2060switch, but allow finer grained control. Multiple selections from the 2061following may be specified as a comma separated string. 2062@option{x86-64}, @option{i386} and @option{i8086} select disassembly for 2063the given architecture. @option{intel} and @option{att} select between 2064intel syntax mode and AT&T syntax mode. 2065@option{intel-mnemonic} and @option{att-mnemonic} select between 2066intel mnemonic mode and AT&T mnemonic mode. @option{intel-mnemonic} 2067implies @option{intel} and @option{att-mnemonic} implies @option{att}. 2068@option{addr64}, @option{addr32}, 2069@option{addr16}, @option{data32} and @option{data16} specify the default 2070address size and operand size. These four options will be overridden if 2071@option{x86-64}, @option{i386} or @option{i8086} appear later in the 2072option string. Lastly, @option{suffix}, when in AT&T mode, 2073instructs the disassembler to print a mnemonic suffix even when the 2074suffix could be inferred by the operands. 2075 2076For PowerPC, @option{booke} controls the disassembly of BookE 2077instructions. @option{32} and @option{64} select PowerPC and 2078PowerPC64 disassembly, respectively. @option{e300} selects 2079disassembly for the e300 family. @option{440} selects disassembly for 2080the PowerPC 440. @option{ppcps} selects disassembly for the paired 2081single instructions of the PPC750CL. 2082 2083For MIPS, this option controls the printing of instruction mnemonic 2084names and register names in disassembled instructions. Multiple 2085selections from the following may be specified as a comma separated 2086string, and invalid options are ignored: 2087 2088@table @code 2089@item no-aliases 2090Print the 'raw' instruction mnemonic instead of some pseudo 2091instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move', 2092'sll' instead of 'nop', etc. 2093 2094@item gpr-names=@var{ABI} 2095Print GPR (general-purpose register) names as appropriate 2096for the specified ABI. By default, GPR names are selected according to 2097the ABI of the binary being disassembled. 2098 2099@item fpr-names=@var{ABI} 2100Print FPR (floating-point register) names as 2101appropriate for the specified ABI. By default, FPR numbers are printed 2102rather than names. 2103 2104@item cp0-names=@var{ARCH} 2105Print CP0 (system control coprocessor; coprocessor 0) register names 2106as appropriate for the CPU or architecture specified by 2107@var{ARCH}. By default, CP0 register names are selected according to 2108the architecture and CPU of the binary being disassembled. 2109 2110@item hwr-names=@var{ARCH} 2111Print HWR (hardware register, used by the @code{rdhwr} instruction) names 2112as appropriate for the CPU or architecture specified by 2113@var{ARCH}. By default, HWR names are selected according to 2114the architecture and CPU of the binary being disassembled. 2115 2116@item reg-names=@var{ABI} 2117Print GPR and FPR names as appropriate for the selected ABI. 2118 2119@item reg-names=@var{ARCH} 2120Print CPU-specific register names (CP0 register and HWR names) 2121as appropriate for the selected CPU or architecture. 2122@end table 2123 2124For any of the options listed above, @var{ABI} or 2125@var{ARCH} may be specified as @samp{numeric} to have numbers printed 2126rather than names, for the selected types of registers. 2127You can list the available values of @var{ABI} and @var{ARCH} using 2128the @option{--help} option. 2129 2130For VAX, you can specify function entry addresses with @option{-M 2131entry:0xf00ba}. You can use this multiple times to properly 2132disassemble VAX binary files that don't contain symbol tables (like 2133ROM dumps). In these cases, the function entry mask would otherwise 2134be decoded as VAX instructions, which would probably lead the rest 2135of the function being wrongly disassembled. 2136 2137@item -p 2138@itemx --private-headers 2139Print information that is specific to the object file format. The exact 2140information printed depends upon the object file format. For some 2141object file formats, no additional information is printed. 2142 2143@item -P @var{options} 2144@itemx --private=@var{options} 2145Print information that is specific to the object file format. The 2146argument @var{options} is a comma separated list that depends on the 2147format (the lists of options is displayed with the help). 2148 2149For XCOFF, the available options are: @option{header}, @option{aout}, 2150@option{sections}, @option{syms}, @option{relocs}, @option{lineno}, 2151@option{loader}, @option{except}, @option{typchk}, @option{traceback} 2152and @option{toc}. 2153 2154@item -r 2155@itemx --reloc 2156@cindex relocation entries, in object file 2157Print the relocation entries of the file. If used with @option{-d} or 2158@option{-D}, the relocations are printed interspersed with the 2159disassembly. 2160 2161@item -R 2162@itemx --dynamic-reloc 2163@cindex dynamic relocation entries, in object file 2164Print the dynamic relocation entries of the file. This is only 2165meaningful for dynamic objects, such as certain types of shared 2166libraries. As for @option{-r}, if used with @option{-d} or 2167@option{-D}, the relocations are printed interspersed with the 2168disassembly. 2169 2170@item -s 2171@itemx --full-contents 2172@cindex sections, full contents 2173@cindex object file sections 2174Display the full contents of any sections requested. By default all 2175non-empty sections are displayed. 2176 2177@item -S 2178@itemx --source 2179@cindex source disassembly 2180@cindex disassembly, with source 2181Display source code intermixed with disassembly, if possible. Implies 2182@option{-d}. 2183 2184@item --prefix=@var{prefix} 2185@cindex Add prefix to absolute paths 2186Specify @var{prefix} to add to the absolute paths when used with 2187@option{-S}. 2188 2189@item --prefix-strip=@var{level} 2190@cindex Strip absolute paths 2191Indicate how many initial directory names to strip off the hardwired 2192absolute paths. It has no effect without @option{--prefix=}@var{prefix}. 2193 2194@item --show-raw-insn 2195When disassembling instructions, print the instruction in hex as well as 2196in symbolic form. This is the default except when 2197@option{--prefix-addresses} is used. 2198 2199@item --no-show-raw-insn 2200When disassembling instructions, do not print the instruction bytes. 2201This is the default when @option{--prefix-addresses} is used. 2202 2203@item --insn-width=@var{width} 2204@cindex Instruction width 2205Display @var{width} bytes on a single line when disassembling 2206instructions. 2207 2208@item -W[lLiaprmfFsoRt] 2209@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index] 2210@cindex DWARF 2211@cindex debug symbols 2212Displays the contents of the debug sections in the file, if any are 2213present. If one of the optional letters or words follows the switch 2214then only data found in those specific sections will be dumped. 2215 2216Note that there is no single letter option to display the content of 2217trace sections or .gdb_index. 2218 2219Note: the output from the @option{=info} option can also be affected 2220by the options @option{--dwarf-depth}, the @option{--dwarf-start} and 2221the @option{--dwarf-check}. 2222 2223@item --dwarf-depth=@var{n} 2224Limit the dump of the @code{.debug_info} section to @var{n} children. 2225This is only useful with @option{--dwarf=info}. The default is 2226to print all DIEs; the special value 0 for @var{n} will also have this 2227effect. 2228 2229With a non-zero value for @var{n}, DIEs at or deeper than @var{n} 2230levels will not be printed. The range for @var{n} is zero-based. 2231 2232@item --dwarf-start=@var{n} 2233Print only DIEs beginning with the DIE numbered @var{n}. This is only 2234useful with @option{--dwarf=info}. 2235 2236If specified, this option will suppress printing of any header 2237information and all DIEs before the DIE numbered @var{n}. Only 2238siblings and children of the specified DIE will be printed. 2239 2240This can be used in conjunction with @option{--dwarf-depth}. 2241 2242@item --dwarf-check 2243Enable additional checks for consistency of Dwarf information. 2244 2245@item -G 2246@itemx --stabs 2247@cindex stab 2248@cindex .stab 2249@cindex debug symbols 2250@cindex ELF object file format 2251Display the full contents of any sections requested. Display the 2252contents of the .stab and .stab.index and .stab.excl sections from an 2253ELF file. This is only useful on systems (such as Solaris 2.0) in which 2254@code{.stab} debugging symbol-table entries are carried in an ELF 2255section. In most other file formats, debugging symbol-table entries are 2256interleaved with linkage symbols, and are visible in the @option{--syms} 2257output. 2258@ifclear man 2259For more information on stabs symbols, see @ref{Top,Stabs,Stabs 2260Overview,stabs.info, The ``stabs'' debug format}. 2261@end ifclear 2262 2263@item --start-address=@var{address} 2264@cindex start-address 2265Start displaying data at the specified address. This affects the output 2266of the @option{-d}, @option{-r} and @option{-s} options. 2267 2268@item --stop-address=@var{address} 2269@cindex stop-address 2270Stop displaying data at the specified address. This affects the output 2271of the @option{-d}, @option{-r} and @option{-s} options. 2272 2273@item -t 2274@itemx --syms 2275@cindex symbol table entries, printing 2276Print the symbol table entries of the file. 2277This is similar to the information provided by the @samp{nm} program, 2278although the display format is different. The format of the output 2279depends upon the format of the file being dumped, but there are two main 2280types. One looks like this: 2281 2282@smallexample 2283[ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss 2284[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred 2285@end smallexample 2286 2287where the number inside the square brackets is the number of the entry 2288in the symbol table, the @var{sec} number is the section number, the 2289@var{fl} value are the symbol's flag bits, the @var{ty} number is the 2290symbol's type, the @var{scl} number is the symbol's storage class and 2291the @var{nx} value is the number of auxilary entries associated with 2292the symbol. The last two fields are the symbol's value and its name. 2293 2294The other common output format, usually seen with ELF based files, 2295looks like this: 2296 2297@smallexample 229800000000 l d .bss 00000000 .bss 229900000000 g .text 00000000 fred 2300@end smallexample 2301 2302Here the first number is the symbol's value (sometimes refered to as 2303its address). The next field is actually a set of characters and 2304spaces indicating the flag bits that are set on the symbol. These 2305characters are described below. Next is the section with which the 2306symbol is associated or @emph{*ABS*} if the section is absolute (ie 2307not connected with any section), or @emph{*UND*} if the section is 2308referenced in the file being dumped, but not defined there. 2309 2310After the section name comes another field, a number, which for common 2311symbols is the alignment and for other symbol is the size. Finally 2312the symbol's name is displayed. 2313 2314The flag characters are divided into 7 groups as follows: 2315@table @code 2316@item l 2317@itemx g 2318@itemx u 2319@itemx ! 2320The symbol is a local (l), global (g), unique global (u), neither 2321global nor local (a space) or both global and local (!). A 2322symbol can be neither local or global for a variety of reasons, e.g., 2323because it is used for debugging, but it is probably an indication of 2324a bug if it is ever both local and global. Unique global symbols are 2325a GNU extension to the standard set of ELF symbol bindings. For such 2326a symbol the dynamic linker will make sure that in the entire process 2327there is just one symbol with this name and type in use. 2328 2329@item w 2330The symbol is weak (w) or strong (a space). 2331 2332@item C 2333The symbol denotes a constructor (C) or an ordinary symbol (a space). 2334 2335@item W 2336The symbol is a warning (W) or a normal symbol (a space). A warning 2337symbol's name is a message to be displayed if the symbol following the 2338warning symbol is ever referenced. 2339 2340@item I 2341@item i 2342The symbol is an indirect reference to another symbol (I), a function 2343to be evaluated during reloc processing (i) or a normal symbol (a 2344space). 2345 2346@item d 2347@itemx D 2348The symbol is a debugging symbol (d) or a dynamic symbol (D) or a 2349normal symbol (a space). 2350 2351@item F 2352@item f 2353@item O 2354The symbol is the name of a function (F) or a file (f) or an object 2355(O) or just a normal symbol (a space). 2356@end table 2357 2358@item -T 2359@itemx --dynamic-syms 2360@cindex dynamic symbol table entries, printing 2361Print the dynamic symbol table entries of the file. This is only 2362meaningful for dynamic objects, such as certain types of shared 2363libraries. This is similar to the information provided by the @samp{nm} 2364program when given the @option{-D} (@option{--dynamic}) option. 2365 2366@item --special-syms 2367When displaying symbols include those which the target considers to be 2368special in some way and which would not normally be of interest to the 2369user. 2370 2371@item -V 2372@itemx --version 2373Print the version number of @command{objdump} and exit. 2374 2375@item -x 2376@itemx --all-headers 2377@cindex all header information, object file 2378@cindex header information, all 2379Display all available header information, including the symbol table and 2380relocation entries. Using @option{-x} is equivalent to specifying all of 2381@option{-a -f -h -p -r -t}. 2382 2383@item -w 2384@itemx --wide 2385@cindex wide output, printing 2386Format some lines for output devices that have more than 80 columns. 2387Also do not truncate symbol names when they are displayed. 2388 2389@item -z 2390@itemx --disassemble-zeroes 2391Normally the disassembly output will skip blocks of zeroes. This 2392option directs the disassembler to disassemble those blocks, just like 2393any other data. 2394@end table 2395 2396@c man end 2397 2398@ignore 2399@c man begin SEEALSO objdump 2400nm(1), readelf(1), and the Info entries for @file{binutils}. 2401@c man end 2402@end ignore 2403 2404@node ranlib 2405@chapter ranlib 2406 2407@kindex ranlib 2408@cindex archive contents 2409@cindex symbol index 2410 2411@c man title ranlib generate index to archive. 2412 2413@smallexample 2414@c man begin SYNOPSIS ranlib 2415ranlib [@option{--plugin} @var{name}] [@option{-DhHvVt}] @var{archive} 2416@c man end 2417@end smallexample 2418 2419@c man begin DESCRIPTION ranlib 2420 2421@command{ranlib} generates an index to the contents of an archive and 2422stores it in the archive. The index lists each symbol defined by a 2423member of an archive that is a relocatable object file. 2424 2425You may use @samp{nm -s} or @samp{nm --print-armap} to list this index. 2426 2427An archive with such an index speeds up linking to the library and 2428allows routines in the library to call each other without regard to 2429their placement in the archive. 2430 2431The @sc{gnu} @command{ranlib} program is another form of @sc{gnu} @command{ar}; running 2432@command{ranlib} is completely equivalent to executing @samp{ar -s}. 2433@xref{ar}. 2434 2435@c man end 2436 2437@c man begin OPTIONS ranlib 2438 2439@table @env 2440@item -h 2441@itemx -H 2442@itemx --help 2443Show usage information for @command{ranlib}. 2444 2445@item -v 2446@itemx -V 2447@itemx --version 2448Show the version number of @command{ranlib}. 2449 2450@item -D 2451@cindex deterministic archives 2452@kindex --enable-deterministic-archives 2453Operate in @emph{deterministic} mode. The symbol map archive member's 2454header will show zero for the UID, GID, and timestamp. When this 2455option is used, multiple runs will produce identical output files. 2456 2457This is the default unless @file{binutils} was configured with 2458@option{--enable-deterministic-archives}. 2459 2460@item -t 2461Update the timestamp of the symbol map of an archive. 2462 2463@item -U 2464@cindex deterministic archives 2465@kindex --enable-deterministic-archives 2466Do @emph{not} operate in @emph{deterministic} mode. This is the 2467inverse of the @samp{-D} option, above: the archive index will get 2468actual UID, GID, timestamp, and file mode values. 2469 2470This is the default unless @file{binutils} was configured with 2471@option{--enable-deterministic-archives}. 2472@end table 2473 2474@c man end 2475 2476@ignore 2477@c man begin SEEALSO ranlib 2478ar(1), nm(1), and the Info entries for @file{binutils}. 2479@c man end 2480@end ignore 2481 2482@node size 2483@chapter size 2484 2485@kindex size 2486@cindex section sizes 2487 2488@c man title size list section sizes and total size. 2489 2490@smallexample 2491@c man begin SYNOPSIS size 2492size [@option{-A}|@option{-B}|@option{--format=}@var{compatibility}] 2493 [@option{--help}] 2494 [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}] 2495 [@option{--common}] 2496 [@option{-t}|@option{--totals}] 2497 [@option{--target=}@var{bfdname}] [@option{-V}|@option{--version}] 2498 [@var{objfile}@dots{}] 2499@c man end 2500@end smallexample 2501 2502@c man begin DESCRIPTION size 2503 2504The @sc{gnu} @command{size} utility lists the section sizes---and the total 2505size---for each of the object or archive files @var{objfile} in its 2506argument list. By default, one line of output is generated for each 2507object file or each module in an archive. 2508 2509@var{objfile}@dots{} are the object files to be examined. 2510If none are specified, the file @code{a.out} will be used. 2511 2512@c man end 2513 2514@c man begin OPTIONS size 2515 2516The command line options have the following meanings: 2517 2518@table @env 2519@item -A 2520@itemx -B 2521@itemx --format=@var{compatibility} 2522@cindex @command{size} display format 2523Using one of these options, you can choose whether the output from @sc{gnu} 2524@command{size} resembles output from System V @command{size} (using @option{-A}, 2525or @option{--format=sysv}), or Berkeley @command{size} (using @option{-B}, or 2526@option{--format=berkeley}). The default is the one-line format similar to 2527Berkeley's. 2528@c Bonus for doc-source readers: you can also say --format=strange (or 2529@c anything else that starts with 's') for sysv, and --format=boring (or 2530@c anything else that starts with 'b') for Berkeley. 2531 2532Here is an example of the Berkeley (default) format of output from 2533@command{size}: 2534@smallexample 2535$ size --format=Berkeley ranlib size 2536text data bss dec hex filename 2537294880 81920 11592 388392 5ed28 ranlib 2538294880 81920 11888 388688 5ee50 size 2539@end smallexample 2540 2541@noindent 2542This is the same data, but displayed closer to System V conventions: 2543 2544@smallexample 2545$ size --format=SysV ranlib size 2546ranlib : 2547section size addr 2548.text 294880 8192 2549.data 81920 303104 2550.bss 11592 385024 2551Total 388392 2552 2553 2554size : 2555section size addr 2556.text 294880 8192 2557.data 81920 303104 2558.bss 11888 385024 2559Total 388688 2560@end smallexample 2561 2562@item --help 2563Show a summary of acceptable arguments and options. 2564 2565@item -d 2566@itemx -o 2567@itemx -x 2568@itemx --radix=@var{number} 2569@cindex @command{size} number format 2570@cindex radix for section sizes 2571Using one of these options, you can control whether the size of each 2572section is given in decimal (@option{-d}, or @option{--radix=10}); octal 2573(@option{-o}, or @option{--radix=8}); or hexadecimal (@option{-x}, or 2574@option{--radix=16}). In @option{--radix=@var{number}}, only the three 2575values (8, 10, 16) are supported. The total size is always given in two 2576radices; decimal and hexadecimal for @option{-d} or @option{-x} output, or 2577octal and hexadecimal if you're using @option{-o}. 2578 2579@item --common 2580Print total size of common symbols in each file. When using Berkeley 2581format these are included in the bss size. 2582 2583@item -t 2584@itemx --totals 2585Show totals of all objects listed (Berkeley format listing mode only). 2586 2587@item --target=@var{bfdname} 2588@cindex object code format 2589Specify that the object-code format for @var{objfile} is 2590@var{bfdname}. This option may not be necessary; @command{size} can 2591automatically recognize many formats. 2592@xref{Target Selection}, for more information. 2593 2594@item -V 2595@itemx --version 2596Display the version number of @command{size}. 2597@end table 2598 2599@c man end 2600 2601@ignore 2602@c man begin SEEALSO size 2603ar(1), objdump(1), readelf(1), and the Info entries for @file{binutils}. 2604@c man end 2605@end ignore 2606 2607@node strings 2608@chapter strings 2609@kindex strings 2610@cindex listings strings 2611@cindex printing strings 2612@cindex strings, printing 2613 2614@c man title strings print the strings of printable characters in files. 2615 2616@smallexample 2617@c man begin SYNOPSIS strings 2618strings [@option{-afovV}] [@option{-}@var{min-len}] 2619 [@option{-n} @var{min-len}] [@option{--bytes=}@var{min-len}] 2620 [@option{-t} @var{radix}] [@option{--radix=}@var{radix}] 2621 [@option{-e} @var{encoding}] [@option{--encoding=}@var{encoding}] 2622 [@option{-}] [@option{--all}] [@option{--print-file-name}] 2623 [@option{-T} @var{bfdname}] [@option{--target=}@var{bfdname}] 2624 [@option{--help}] [@option{--version}] @var{file}@dots{} 2625@c man end 2626@end smallexample 2627 2628@c man begin DESCRIPTION strings 2629 2630For each @var{file} given, @sc{gnu} @command{strings} prints the printable 2631character sequences that are at least 4 characters long (or the number 2632given with the options below) and are followed by an unprintable 2633character. By default, it only prints the strings from the initialized 2634and loaded sections of object files; for other types of files, it prints 2635the strings from the whole file. 2636 2637@command{strings} is mainly useful for determining the contents of non-text 2638files. 2639 2640@c man end 2641 2642@c man begin OPTIONS strings 2643 2644@table @env 2645@item -a 2646@itemx --all 2647@itemx - 2648Do not scan only the initialized and loaded sections of object files; 2649scan the whole files. 2650 2651@item -f 2652@itemx --print-file-name 2653Print the name of the file before each string. 2654 2655@item --help 2656Print a summary of the program usage on the standard output and exit. 2657 2658@item -@var{min-len} 2659@itemx -n @var{min-len} 2660@itemx --bytes=@var{min-len} 2661Print sequences of characters that are at least @var{min-len} characters 2662long, instead of the default 4. 2663 2664@item -o 2665Like @samp{-t o}. Some other versions of @command{strings} have @option{-o} 2666act like @samp{-t d} instead. Since we can not be compatible with both 2667ways, we simply chose one. 2668 2669@item -t @var{radix} 2670@itemx --radix=@var{radix} 2671Print the offset within the file before each string. The single 2672character argument specifies the radix of the offset---@samp{o} for 2673octal, @samp{x} for hexadecimal, or @samp{d} for decimal. 2674 2675@item -e @var{encoding} 2676@itemx --encoding=@var{encoding} 2677Select the character encoding of the strings that are to be found. 2678Possible values for @var{encoding} are: @samp{s} = single-7-bit-byte 2679characters (ASCII, ISO 8859, etc., default), @samp{S} = 2680single-8-bit-byte characters, @samp{b} = 16-bit bigendian, @samp{l} = 268116-bit littleendian, @samp{B} = 32-bit bigendian, @samp{L} = 32-bit 2682littleendian. Useful for finding wide character strings. (@samp{l} 2683and @samp{b} apply to, for example, Unicode UTF-16/UCS-2 encodings). 2684 2685@item -T @var{bfdname} 2686@itemx --target=@var{bfdname} 2687@cindex object code format 2688Specify an object code format other than your system's default format. 2689@xref{Target Selection}, for more information. 2690 2691@item -v 2692@itemx -V 2693@itemx --version 2694Print the program version number on the standard output and exit. 2695@end table 2696 2697@c man end 2698 2699@ignore 2700@c man begin SEEALSO strings 2701ar(1), nm(1), objdump(1), ranlib(1), readelf(1) 2702and the Info entries for @file{binutils}. 2703@c man end 2704@end ignore 2705 2706@node strip 2707@chapter strip 2708 2709@kindex strip 2710@cindex removing symbols 2711@cindex discarding symbols 2712@cindex symbols, discarding 2713 2714@c man title strip Discard symbols from object files. 2715 2716@smallexample 2717@c man begin SYNOPSIS strip 2718strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}] 2719 [@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname}] 2720 [@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}] 2721 [@option{-s}|@option{--strip-all}] 2722 [@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}] 2723 [@option{--strip-dwo}] 2724 [@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname}] 2725 [@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}] 2726 [@option{-w}|@option{--wildcard}] 2727 [@option{-x}|@option{--discard-all}] [@option{-X} |@option{--discard-locals}] 2728 [@option{-R} @var{sectionname} |@option{--remove-section=}@var{sectionname}] 2729 [@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}] 2730 [@option{-D}|@option{--enable-deterministic-archives}] 2731 [@option{-U}|@option{--disable-deterministic-archives}] 2732 [@option{--keep-file-symbols}] 2733 [@option{--only-keep-debug}] 2734 [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}] 2735 [@option{--help}] [@option{--info}] 2736 @var{objfile}@dots{} 2737@c man end 2738@end smallexample 2739 2740@c man begin DESCRIPTION strip 2741 2742@sc{gnu} @command{strip} discards all symbols from object files 2743@var{objfile}. The list of object files may include archives. 2744At least one object file must be given. 2745 2746@command{strip} modifies the files named in its argument, 2747rather than writing modified copies under different names. 2748 2749@c man end 2750 2751@c man begin OPTIONS strip 2752 2753@table @env 2754@item -F @var{bfdname} 2755@itemx --target=@var{bfdname} 2756Treat the original @var{objfile} as a file with the object 2757code format @var{bfdname}, and rewrite it in the same format. 2758@xref{Target Selection}, for more information. 2759 2760@item --help 2761Show a summary of the options to @command{strip} and exit. 2762 2763@item --info 2764Display a list showing all architectures and object formats available. 2765 2766@item -I @var{bfdname} 2767@itemx --input-target=@var{bfdname} 2768Treat the original @var{objfile} as a file with the object 2769code format @var{bfdname}. 2770@xref{Target Selection}, for more information. 2771 2772@item -O @var{bfdname} 2773@itemx --output-target=@var{bfdname} 2774Replace @var{objfile} with a file in the output format @var{bfdname}. 2775@xref{Target Selection}, for more information. 2776 2777@item -R @var{sectionname} 2778@itemx --remove-section=@var{sectionname} 2779Remove any section named @var{sectionname} from the output file. This 2780option may be given more than once. Note that using this option 2781inappropriately may make the output file unusable. 2782 2783@item -s 2784@itemx --strip-all 2785Remove all symbols. 2786 2787@item -g 2788@itemx -S 2789@itemx -d 2790@itemx --strip-debug 2791Remove debugging symbols only. 2792 2793@item --strip-dwo 2794Remove the contents of all DWARF .dwo sections, leaving the 2795remaining debugging sections and all symbols intact. 2796See the description of this option in the @command{objcopy} section 2797for more information. 2798 2799@item --strip-unneeded 2800Remove all symbols that are not needed for relocation processing. 2801 2802@item -K @var{symbolname} 2803@itemx --keep-symbol=@var{symbolname} 2804When stripping symbols, keep symbol @var{symbolname} even if it would 2805normally be stripped. This option may be given more than once. 2806 2807@item -N @var{symbolname} 2808@itemx --strip-symbol=@var{symbolname} 2809Remove symbol @var{symbolname} from the source file. This option may be 2810given more than once, and may be combined with strip options other than 2811@option{-K}. 2812 2813@item -o @var{file} 2814Put the stripped output in @var{file}, rather than replacing the 2815existing file. When this argument is used, only one @var{objfile} 2816argument may be specified. 2817 2818@item -p 2819@itemx --preserve-dates 2820Preserve the access and modification dates of the file. 2821 2822@item -D 2823@itemx --enable-deterministic-archives 2824@cindex deterministic archives 2825@kindex --enable-deterministic-archives 2826Operate in @emph{deterministic} mode. When copying archive members 2827and writing the archive index, use zero for UIDs, GIDs, timestamps, 2828and use consistent file modes for all files. 2829 2830If @file{binutils} was configured with 2831@option{--enable-deterministic-archives}, then this mode is on by default. 2832It can be disabled with the @samp{-U} option, below. 2833 2834@item -U 2835@itemx --disable-deterministic-archives 2836@cindex deterministic archives 2837@kindex --enable-deterministic-archives 2838Do @emph{not} operate in @emph{deterministic} mode. This is the 2839inverse of the @option{-D} option, above: when copying archive members 2840and writing the archive index, use their actual UID, GID, timestamp, 2841and file mode values. 2842 2843This is the default unless @file{binutils} was configured with 2844@option{--enable-deterministic-archives}. 2845 2846@item -w 2847@itemx --wildcard 2848Permit regular expressions in @var{symbolname}s used in other command 2849line options. The question mark (?), asterisk (*), backslash (\) and 2850square brackets ([]) operators can be used anywhere in the symbol 2851name. If the first character of the symbol name is the exclamation 2852point (!) then the sense of the switch is reversed for that symbol. 2853For example: 2854 2855@smallexample 2856 -w -K !foo -K fo* 2857@end smallexample 2858 2859would cause strip to only keep symbols that start with the letters 2860``fo'', but to discard the symbol ``foo''. 2861 2862@item -x 2863@itemx --discard-all 2864Remove non-global symbols. 2865 2866@item -X 2867@itemx --discard-locals 2868Remove compiler-generated local symbols. 2869(These usually start with @samp{L} or @samp{.}.) 2870 2871@item --keep-file-symbols 2872When stripping a file, perhaps with @option{--strip-debug} or 2873@option{--strip-unneeded}, retain any symbols specifying source file names, 2874which would otherwise get stripped. 2875 2876@item --only-keep-debug 2877Strip a file, removing contents of any sections that would not be 2878stripped by @option{--strip-debug} and leaving the debugging sections 2879intact. In ELF files, this preserves all note sections in the output. 2880 2881The intention is that this option will be used in conjunction with 2882@option{--add-gnu-debuglink} to create a two part executable. One a 2883stripped binary which will occupy less space in RAM and in a 2884distribution and the second a debugging information file which is only 2885needed if debugging abilities are required. The suggested procedure 2886to create these files is as follows: 2887 2888@enumerate 2889@item Link the executable as normal. Assuming that is is called 2890@code{foo} then... 2891@item Run @code{objcopy --only-keep-debug foo foo.dbg} to 2892create a file containing the debugging info. 2893@item Run @code{objcopy --strip-debug foo} to create a 2894stripped executable. 2895@item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo} 2896to add a link to the debugging info into the stripped executable. 2897@end enumerate 2898 2899Note---the choice of @code{.dbg} as an extension for the debug info 2900file is arbitrary. Also the @code{--only-keep-debug} step is 2901optional. You could instead do this: 2902 2903@enumerate 2904@item Link the executable as normal. 2905@item Copy @code{foo} to @code{foo.full} 2906@item Run @code{strip --strip-debug foo} 2907@item Run @code{objcopy --add-gnu-debuglink=foo.full foo} 2908@end enumerate 2909 2910i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the 2911full executable. It does not have to be a file created by the 2912@option{--only-keep-debug} switch. 2913 2914Note---this switch is only intended for use on fully linked files. It 2915does not make sense to use it on object files where the debugging 2916information may be incomplete. Besides the gnu_debuglink feature 2917currently only supports the presence of one filename containing 2918debugging information, not multiple filenames on a one-per-object-file 2919basis. 2920 2921@item -V 2922@itemx --version 2923Show the version number for @command{strip}. 2924 2925@item -v 2926@itemx --verbose 2927Verbose output: list all object files modified. In the case of 2928archives, @samp{strip -v} lists all members of the archive. 2929@end table 2930 2931@c man end 2932 2933@ignore 2934@c man begin SEEALSO strip 2935the Info entries for @file{binutils}. 2936@c man end 2937@end ignore 2938 2939@node c++filt, addr2line, elfedit, Top 2940@chapter c++filt 2941 2942@kindex c++filt 2943@cindex demangling C++ symbols 2944 2945@c man title cxxfilt Demangle C++ and Java symbols. 2946 2947@smallexample 2948@c man begin SYNOPSIS cxxfilt 2949c++filt [@option{-_}|@option{--strip-underscore}] 2950 [@option{-n}|@option{--no-strip-underscore}] 2951 [@option{-p}|@option{--no-params}] 2952 [@option{-t}|@option{--types}] 2953 [@option{-i}|@option{--no-verbose}] 2954 [@option{-s} @var{format}|@option{--format=}@var{format}] 2955 [@option{--help}] [@option{--version}] [@var{symbol}@dots{}] 2956@c man end 2957@end smallexample 2958 2959@c man begin DESCRIPTION cxxfilt 2960 2961@kindex cxxfilt 2962The C++ and Java languages provide function overloading, which means 2963that you can write many functions with the same name, providing that 2964each function takes parameters of different types. In order to be 2965able to distinguish these similarly named functions C++ and Java 2966encode them into a low-level assembler name which uniquely identifies 2967each different version. This process is known as @dfn{mangling}. The 2968@command{c++filt} 2969@footnote{MS-DOS does not allow @kbd{+} characters in file names, so on 2970MS-DOS this program is named @command{CXXFILT}.} 2971program does the inverse mapping: it decodes (@dfn{demangles}) low-level 2972names into user-level names so that they can be read. 2973 2974Every alphanumeric word (consisting of letters, digits, underscores, 2975dollars, or periods) seen in the input is a potential mangled name. 2976If the name decodes into a C++ name, the C++ name replaces the 2977low-level name in the output, otherwise the original word is output. 2978In this way you can pass an entire assembler source file, containing 2979mangled names, through @command{c++filt} and see the same source file 2980containing demangled names. 2981 2982You can also use @command{c++filt} to decipher individual symbols by 2983passing them on the command line: 2984 2985@example 2986c++filt @var{symbol} 2987@end example 2988 2989If no @var{symbol} arguments are given, @command{c++filt} reads symbol 2990names from the standard input instead. All the results are printed on 2991the standard output. The difference between reading names from the 2992command line versus reading names from the standard input is that 2993command line arguments are expected to be just mangled names and no 2994checking is performed to separate them from surrounding text. Thus 2995for example: 2996 2997@smallexample 2998c++filt -n _Z1fv 2999@end smallexample 3000 3001will work and demangle the name to ``f()'' whereas: 3002 3003@smallexample 3004c++filt -n _Z1fv, 3005@end smallexample 3006 3007will not work. (Note the extra comma at the end of the mangled 3008name which makes it invalid). This command however will work: 3009 3010@smallexample 3011echo _Z1fv, | c++filt -n 3012@end smallexample 3013 3014and will display ``f(),'', i.e., the demangled name followed by a 3015trailing comma. This behaviour is because when the names are read 3016from the standard input it is expected that they might be part of an 3017assembler source file where there might be extra, extraneous 3018characters trailing after a mangled name. For example: 3019 3020@smallexample 3021 .type _Z1fv, @@function 3022@end smallexample 3023 3024@c man end 3025 3026@c man begin OPTIONS cxxfilt 3027 3028@table @env 3029@item -_ 3030@itemx --strip-underscore 3031On some systems, both the C and C++ compilers put an underscore in front 3032of every name. For example, the C name @code{foo} gets the low-level 3033name @code{_foo}. This option removes the initial underscore. Whether 3034@command{c++filt} removes the underscore by default is target dependent. 3035 3036@item -n 3037@itemx --no-strip-underscore 3038Do not remove the initial underscore. 3039 3040@item -p 3041@itemx --no-params 3042When demangling the name of a function, do not display the types of 3043the function's parameters. 3044 3045@item -t 3046@itemx --types 3047Attempt to demangle types as well as function names. This is disabled 3048by default since mangled types are normally only used internally in 3049the compiler, and they can be confused with non-mangled names. For example, 3050a function called ``a'' treated as a mangled type name would be 3051demangled to ``signed char''. 3052 3053@item -i 3054@itemx --no-verbose 3055Do not include implementation details (if any) in the demangled 3056output. 3057 3058@item -s @var{format} 3059@itemx --format=@var{format} 3060@command{c++filt} can decode various methods of mangling, used by 3061different compilers. The argument to this option selects which 3062method it uses: 3063 3064@table @code 3065@item auto 3066Automatic selection based on executable (the default method) 3067@item gnu 3068the one used by the @sc{gnu} C++ compiler (g++) 3069@item lucid 3070the one used by the Lucid compiler (lcc) 3071@item arm 3072the one specified by the C++ Annotated Reference Manual 3073@item hp 3074the one used by the HP compiler (aCC) 3075@item edg 3076the one used by the EDG compiler 3077@item gnu-v3 3078the one used by the @sc{gnu} C++ compiler (g++) with the V3 ABI. 3079@item java 3080the one used by the @sc{gnu} Java compiler (gcj) 3081@item gnat 3082the one used by the @sc{gnu} Ada compiler (GNAT). 3083@end table 3084 3085@item --help 3086Print a summary of the options to @command{c++filt} and exit. 3087 3088@item --version 3089Print the version number of @command{c++filt} and exit. 3090@end table 3091 3092@c man end 3093 3094@ignore 3095@c man begin SEEALSO cxxfilt 3096the Info entries for @file{binutils}. 3097@c man end 3098@end ignore 3099 3100@quotation 3101@emph{Warning:} @command{c++filt} is a new utility, and the details of its 3102user interface are subject to change in future releases. In particular, 3103a command-line option may be required in the future to decode a name 3104passed as an argument on the command line; in other words, 3105 3106@example 3107c++filt @var{symbol} 3108@end example 3109 3110@noindent 3111may in a future release become 3112 3113@example 3114c++filt @var{option} @var{symbol} 3115@end example 3116@end quotation 3117 3118@node addr2line 3119@chapter addr2line 3120 3121@kindex addr2line 3122@cindex address to file name and line number 3123 3124@c man title addr2line convert addresses into file names and line numbers. 3125 3126@smallexample 3127@c man begin SYNOPSIS addr2line 3128addr2line [@option{-a}|@option{--addresses}] 3129 [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] 3130 [@option{-C}|@option{--demangle}[=@var{style}]] 3131 [@option{-e} @var{filename}|@option{--exe=}@var{filename}] 3132 [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}] 3133 [@option{-i}|@option{--inlines}] 3134 [@option{-p}|@option{--pretty-print}] 3135 [@option{-j}|@option{--section=}@var{name}] 3136 [@option{-H}|@option{--help}] [@option{-V}|@option{--version}] 3137 [addr addr @dots{}] 3138@c man end 3139@end smallexample 3140 3141@c man begin DESCRIPTION addr2line 3142 3143@command{addr2line} translates addresses into file names and line numbers. 3144Given an address in an executable or an offset in a section of a relocatable 3145object, it uses the debugging information to figure out which file name and 3146line number are associated with it. 3147 3148The executable or relocatable object to use is specified with the @option{-e} 3149option. The default is the file @file{a.out}. The section in the relocatable 3150object to use is specified with the @option{-j} option. 3151 3152@command{addr2line} has two modes of operation. 3153 3154In the first, hexadecimal addresses are specified on the command line, 3155and @command{addr2line} displays the file name and line number for each 3156address. 3157 3158In the second, @command{addr2line} reads hexadecimal addresses from 3159standard input, and prints the file name and line number for each 3160address on standard output. In this mode, @command{addr2line} may be used 3161in a pipe to convert dynamically chosen addresses. 3162 3163The format of the output is @samp{FILENAME:LINENO}. The file name and 3164line number for each input address is printed on separate lines. 3165 3166If the @option{-f} option is used, then each @samp{FILENAME:LINENO} 3167line is preceded by @samp{FUNCTIONNAME} which is the name of the 3168function containing the address. 3169 3170If the @option{-i} option is used and the code at the given address is 3171present there because of inlining by the compiler then the 3172@samp{@{FUNCTIONNAME@} FILENAME:LINENO} information for the inlining 3173function will be displayed afterwards. This continues recursively 3174until there is no more inlining to report. 3175 3176If the @option{-a} option is used then the output is prefixed by the 3177input address. 3178 3179If the @option{-p} option is used then the output for each input 3180address is displayed on one, possibly quite long, line. If 3181@option{-p} is not used then the output is broken up into multiple 3182lines, based on the paragraphs above. 3183 3184If the file name or function name can not be determined, 3185@command{addr2line} will print two question marks in their place. If the 3186line number can not be determined, @command{addr2line} will print 0. 3187 3188@c man end 3189 3190@c man begin OPTIONS addr2line 3191 3192The long and short forms of options, shown here as alternatives, are 3193equivalent. 3194 3195@table @env 3196@item -a 3197@itemx --addresses 3198Display the address before the function name, file and line number 3199information. The address is printed with a @samp{0x} prefix to easily 3200identify it. 3201 3202@item -b @var{bfdname} 3203@itemx --target=@var{bfdname} 3204@cindex object code format 3205Specify that the object-code format for the object files is 3206@var{bfdname}. 3207 3208@item -C 3209@itemx --demangle[=@var{style}] 3210@cindex demangling in objdump 3211Decode (@dfn{demangle}) low-level symbol names into user-level names. 3212Besides removing any initial underscore prepended by the system, this 3213makes C++ function names readable. Different compilers have different 3214mangling styles. The optional demangling style argument can be used to 3215choose an appropriate demangling style for your compiler. @xref{c++filt}, 3216for more information on demangling. 3217 3218@item -e @var{filename} 3219@itemx --exe=@var{filename} 3220Specify the name of the executable for which addresses should be 3221translated. The default file is @file{a.out}. 3222 3223@item -f 3224@itemx --functions 3225Display function names as well as file and line number information. 3226 3227@item -s 3228@itemx --basenames 3229Display only the base of each file name. 3230 3231@item -i 3232@itemx --inlines 3233If the address belongs to a function that was inlined, the source 3234information for all enclosing scopes back to the first non-inlined 3235function will also be printed. For example, if @code{main} inlines 3236@code{callee1} which inlines @code{callee2}, and address is from 3237@code{callee2}, the source information for @code{callee1} and @code{main} 3238will also be printed. 3239 3240@item -j 3241@itemx --section 3242Read offsets relative to the specified section instead of absolute addresses. 3243 3244@item -p 3245@itemx --pretty-print 3246Make the output more human friendly: each location are printed on one line. 3247If option @option{-i} is specified, lines for all enclosing scopes are 3248prefixed with @samp{(inlined by)}. 3249@end table 3250 3251@c man end 3252 3253@ignore 3254@c man begin SEEALSO addr2line 3255Info entries for @file{binutils}. 3256@c man end 3257@end ignore 3258 3259@node nlmconv 3260@chapter nlmconv 3261 3262@command{nlmconv} converts a relocatable object file into a NetWare 3263Loadable Module. 3264 3265@ignore 3266@command{nlmconv} currently works with @samp{i386} object 3267files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC} 3268object files in @sc{elf}, or @code{a.out} format@footnote{ 3269@command{nlmconv} should work with any @samp{i386} or @sc{sparc} object 3270format in the Binary File Descriptor library. It has only been tested 3271with the above formats.}. 3272@end ignore 3273 3274@quotation 3275@emph{Warning:} @command{nlmconv} is not always built as part of the binary 3276utilities, since it is only useful for NLM targets. 3277@end quotation 3278 3279@c man title nlmconv converts object code into an NLM. 3280 3281@smallexample 3282@c man begin SYNOPSIS nlmconv 3283nlmconv [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}] 3284 [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}] 3285 [@option{-T} @var{headerfile}|@option{--header-file=}@var{headerfile}] 3286 [@option{-d}|@option{--debug}] [@option{-l} @var{linker}|@option{--linker=}@var{linker}] 3287 [@option{-h}|@option{--help}] [@option{-V}|@option{--version}] 3288 @var{infile} @var{outfile} 3289@c man end 3290@end smallexample 3291 3292@c man begin DESCRIPTION nlmconv 3293 3294@command{nlmconv} converts the relocatable @samp{i386} object file 3295@var{infile} into the NetWare Loadable Module @var{outfile}, optionally 3296reading @var{headerfile} for NLM header information. For instructions 3297on writing the NLM command file language used in header files, see the 3298@samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM 3299Development and Tools Overview}, which is part of the NLM Software 3300Developer's Kit (``NLM SDK''), available from Novell, Inc. 3301@command{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read 3302@var{infile}; 3303@ifclear man 3304see @ref{BFD,,BFD,ld.info,Using LD}, for more information. 3305@end ifclear 3306 3307@command{nlmconv} can perform a link step. In other words, you can list 3308more than one object file for input if you list them in the definitions 3309file (rather than simply specifying one input file on the command line). 3310In this case, @command{nlmconv} calls the linker for you. 3311 3312@c man end 3313 3314@c man begin OPTIONS nlmconv 3315 3316@table @env 3317@item -I @var{bfdname} 3318@itemx --input-target=@var{bfdname} 3319Object format of the input file. @command{nlmconv} can usually determine 3320the format of a given file (so no default is necessary). 3321@xref{Target Selection}, for more information. 3322 3323@item -O @var{bfdname} 3324@itemx --output-target=@var{bfdname} 3325Object format of the output file. @command{nlmconv} infers the output 3326format based on the input format, e.g. for a @samp{i386} input file the 3327output format is @samp{nlm32-i386}. 3328@xref{Target Selection}, for more information. 3329 3330@item -T @var{headerfile} 3331@itemx --header-file=@var{headerfile} 3332Reads @var{headerfile} for NLM header information. For instructions on 3333writing the NLM command file language used in header files, see@ see the 3334@samp{linkers} section, of the @cite{NLM Development and Tools 3335Overview}, which is part of the NLM Software Developer's Kit, available 3336from Novell, Inc. 3337 3338@item -d 3339@itemx --debug 3340Displays (on standard error) the linker command line used by @command{nlmconv}. 3341 3342@item -l @var{linker} 3343@itemx --linker=@var{linker} 3344Use @var{linker} for any linking. @var{linker} can be an absolute or a 3345relative pathname. 3346 3347@item -h 3348@itemx --help 3349Prints a usage summary. 3350 3351@item -V 3352@itemx --version 3353Prints the version number for @command{nlmconv}. 3354@end table 3355 3356@c man end 3357 3358@ignore 3359@c man begin SEEALSO nlmconv 3360the Info entries for @file{binutils}. 3361@c man end 3362@end ignore 3363 3364@node windmc 3365@chapter windmc 3366 3367@command{windmc} may be used to generator Windows message resources. 3368 3369@quotation 3370@emph{Warning:} @command{windmc} is not always built as part of the binary 3371utilities, since it is only useful for Windows targets. 3372@end quotation 3373 3374@c man title windmc generates Windows message resources. 3375 3376@smallexample 3377@c man begin SYNOPSIS windmc 3378windmc [options] input-file 3379@c man end 3380@end smallexample 3381 3382@c man begin DESCRIPTION windmc 3383 3384@command{windmc} reads message definitions from an input file (.mc) and 3385translate them into a set of output files. The output files may be of 3386four kinds: 3387 3388@table @code 3389@item h 3390A C header file containing the message definitions. 3391 3392@item rc 3393A resource file compilable by the @command{windres} tool. 3394 3395@item bin 3396One or more binary files containing the resource data for a specific 3397message language. 3398 3399@item dbg 3400A C include file that maps message id's to their symbolic name. 3401@end table 3402 3403The exact description of these different formats is available in 3404documentation from Microsoft. 3405 3406When @command{windmc} converts from the @code{mc} format to the @code{bin} 3407format, @code{rc}, @code{h}, and optional @code{dbg} it is acting like the 3408Windows Message Compiler. 3409 3410@c man end 3411 3412@c man begin OPTIONS windmc 3413 3414@table @env 3415@item -a 3416@itemx --ascii_in 3417Specifies that the input file specified is ASCII. This is the default 3418behaviour. 3419 3420@item -A 3421@itemx --ascii_out 3422Specifies that messages in the output @code{bin} files should be in ASCII 3423format. 3424 3425@item -b 3426@itemx --binprefix 3427Specifies that @code{bin} filenames should have to be prefixed by the 3428basename of the source file. 3429 3430@item -c 3431@itemx --customflag 3432Sets the customer bit in all message id's. 3433 3434@item -C @var{codepage} 3435@itemx --codepage_in @var{codepage} 3436Sets the default codepage to be used to convert input file to UTF16. The 3437default is ocdepage 1252. 3438 3439@item -d 3440@itemx --decimal_values 3441Outputs the constants in the header file in decimal. Default is using 3442hexadecimal output. 3443 3444@item -e @var{ext} 3445@itemx --extension @var{ext} 3446The extension for the header file. The default is .h extension. 3447 3448@item -F @var{target} 3449@itemx --target @var{target} 3450Specify the BFD format to use for a bin file as output. This 3451is a BFD target name; you can use the @option{--help} option to see a list 3452of supported targets. Normally @command{windmc} will use the default 3453format, which is the first one listed by the @option{--help} option. 3454@ifclear man 3455@ref{Target Selection}. 3456@end ifclear 3457 3458@item -h @var{path} 3459@itemx --headerdir @var{path} 3460The target directory of the generated header file. The default is the 3461current directory. 3462 3463@item -H 3464@itemx --help 3465Displays a list of command line options and then exits. 3466 3467@item -m @var{characters} 3468@itemx --maxlength @var{characters} 3469Instructs @command{windmc} to generate a warning if the length 3470of any message exceeds the number specified. 3471 3472@item -n 3473@itemx --nullterminate 3474Terminate message text in @code{bin} files by zero. By default they are 3475terminated by CR/LF. 3476 3477@item -o 3478@itemx --hresult_use 3479Not yet implemented. Instructs @code{windmc} to generate an OLE2 header 3480file, using HRESULT definitions. Status codes are used if the flag is not 3481specified. 3482 3483@item -O @var{codepage} 3484@itemx --codepage_out @var{codepage} 3485Sets the default codepage to be used to output text files. The default 3486is ocdepage 1252. 3487 3488@item -r @var{path} 3489@itemx --rcdir @var{path} 3490The target directory for the generated @code{rc} script and the generated 3491@code{bin} files that the resource compiler script includes. The default 3492is the current directory. 3493 3494@item -u 3495@itemx --unicode_in 3496Specifies that the input file is UTF16. 3497 3498@item -U 3499@itemx --unicode_out 3500Specifies that messages in the output @code{bin} file should be in UTF16 3501format. This is the default behaviour. 3502 3503@item -v 3504@item --verbose 3505Enable verbose mode. 3506 3507@item -V 3508@item --version 3509Prints the version number for @command{windmc}. 3510 3511@item -x @var{path} 3512@itemx --xdgb @var{path} 3513The path of the @code{dbg} C include file that maps message id's to the 3514symbolic name. No such file is generated without specifying the switch. 3515@end table 3516 3517@c man end 3518 3519@ignore 3520@c man begin SEEALSO windmc 3521the Info entries for @file{binutils}. 3522@c man end 3523@end ignore 3524 3525@node windres 3526@chapter windres 3527 3528@command{windres} may be used to manipulate Windows resources. 3529 3530@quotation 3531@emph{Warning:} @command{windres} is not always built as part of the binary 3532utilities, since it is only useful for Windows targets. 3533@end quotation 3534 3535@c man title windres manipulate Windows resources. 3536 3537@smallexample 3538@c man begin SYNOPSIS windres 3539windres [options] [input-file] [output-file] 3540@c man end 3541@end smallexample 3542 3543@c man begin DESCRIPTION windres 3544 3545@command{windres} reads resources from an input file and copies them into 3546an output file. Either file may be in one of three formats: 3547 3548@table @code 3549@item rc 3550A text format read by the Resource Compiler. 3551 3552@item res 3553A binary format generated by the Resource Compiler. 3554 3555@item coff 3556A COFF object or executable. 3557@end table 3558 3559The exact description of these different formats is available in 3560documentation from Microsoft. 3561 3562When @command{windres} converts from the @code{rc} format to the @code{res} 3563format, it is acting like the Windows Resource Compiler. When 3564@command{windres} converts from the @code{res} format to the @code{coff} 3565format, it is acting like the Windows @code{CVTRES} program. 3566 3567When @command{windres} generates an @code{rc} file, the output is similar 3568but not identical to the format expected for the input. When an input 3569@code{rc} file refers to an external filename, an output @code{rc} file 3570will instead include the file contents. 3571 3572If the input or output format is not specified, @command{windres} will 3573guess based on the file name, or, for the input file, the file contents. 3574A file with an extension of @file{.rc} will be treated as an @code{rc} 3575file, a file with an extension of @file{.res} will be treated as a 3576@code{res} file, and a file with an extension of @file{.o} or 3577@file{.exe} will be treated as a @code{coff} file. 3578 3579If no output file is specified, @command{windres} will print the resources 3580in @code{rc} format to standard output. 3581 3582The normal use is for you to write an @code{rc} file, use @command{windres} 3583to convert it to a COFF object file, and then link the COFF file into 3584your application. This will make the resources described in the 3585@code{rc} file available to Windows. 3586 3587@c man end 3588 3589@c man begin OPTIONS windres 3590 3591@table @env 3592@item -i @var{filename} 3593@itemx --input @var{filename} 3594The name of the input file. If this option is not used, then 3595@command{windres} will use the first non-option argument as the input file 3596name. If there are no non-option arguments, then @command{windres} will 3597read from standard input. @command{windres} can not read a COFF file from 3598standard input. 3599 3600@item -o @var{filename} 3601@itemx --output @var{filename} 3602The name of the output file. If this option is not used, then 3603@command{windres} will use the first non-option argument, after any used 3604for the input file name, as the output file name. If there is no 3605non-option argument, then @command{windres} will write to standard output. 3606@command{windres} can not write a COFF file to standard output. Note, 3607for compatibility with @command{rc} the option @option{-fo} is also 3608accepted, but its use is not recommended. 3609 3610@item -J @var{format} 3611@itemx --input-format @var{format} 3612The input format to read. @var{format} may be @samp{res}, @samp{rc}, or 3613@samp{coff}. If no input format is specified, @command{windres} will 3614guess, as described above. 3615 3616@item -O @var{format} 3617@itemx --output-format @var{format} 3618The output format to generate. @var{format} may be @samp{res}, 3619@samp{rc}, or @samp{coff}. If no output format is specified, 3620@command{windres} will guess, as described above. 3621 3622@item -F @var{target} 3623@itemx --target @var{target} 3624Specify the BFD format to use for a COFF file as input or output. This 3625is a BFD target name; you can use the @option{--help} option to see a list 3626of supported targets. Normally @command{windres} will use the default 3627format, which is the first one listed by the @option{--help} option. 3628@ifclear man 3629@ref{Target Selection}. 3630@end ifclear 3631 3632@item --preprocessor @var{program} 3633When @command{windres} reads an @code{rc} file, it runs it through the C 3634preprocessor first. This option may be used to specify the preprocessor 3635to use, including any leading arguments. The default preprocessor 3636argument is @code{gcc -E -xc-header -DRC_INVOKED}. 3637 3638@item --preprocessor-arg @var{option} 3639When @command{windres} reads an @code{rc} file, it runs it through 3640the C preprocessor first. This option may be used to specify additional 3641text to be passed to preprocessor on its command line. 3642This option can be used multiple times to add multiple options to the 3643preprocessor command line. 3644 3645@item -I @var{directory} 3646@itemx --include-dir @var{directory} 3647Specify an include directory to use when reading an @code{rc} file. 3648@command{windres} will pass this to the preprocessor as an @option{-I} 3649option. @command{windres} will also search this directory when looking for 3650files named in the @code{rc} file. If the argument passed to this command 3651matches any of the supported @var{formats} (as described in the @option{-J} 3652option), it will issue a deprecation warning, and behave just like the 3653@option{-J} option. New programs should not use this behaviour. If a 3654directory happens to match a @var{format}, simple prefix it with @samp{./} 3655to disable the backward compatibility. 3656 3657@item -D @var{target} 3658@itemx --define @var{sym}[=@var{val}] 3659Specify a @option{-D} option to pass to the preprocessor when reading an 3660@code{rc} file. 3661 3662@item -U @var{target} 3663@itemx --undefine @var{sym} 3664Specify a @option{-U} option to pass to the preprocessor when reading an 3665@code{rc} file. 3666 3667@item -r 3668Ignored for compatibility with rc. 3669 3670@item -v 3671Enable verbose mode. This tells you what the preprocessor is if you 3672didn't specify one. 3673 3674@item -c @var{val} 3675@item --codepage @var{val} 3676Specify the default codepage to use when reading an @code{rc} file. 3677@var{val} should be a hexadecimal prefixed by @samp{0x} or decimal 3678codepage code. The valid range is from zero up to 0xffff, but the 3679validity of the codepage is host and configuration dependent. 3680 3681@item -l @var{val} 3682@item --language @var{val} 3683Specify the default language to use when reading an @code{rc} file. 3684@var{val} should be a hexadecimal language code. The low eight bits are 3685the language, and the high eight bits are the sublanguage. 3686 3687@item --use-temp-file 3688Use a temporary file to instead of using popen to read the output of 3689the preprocessor. Use this option if the popen implementation is buggy 3690on the host (eg., certain non-English language versions of Windows 95 and 3691Windows 98 are known to have buggy popen where the output will instead 3692go the console). 3693 3694@item --no-use-temp-file 3695Use popen, not a temporary file, to read the output of the preprocessor. 3696This is the default behaviour. 3697 3698@item -h 3699@item --help 3700Prints a usage summary. 3701 3702@item -V 3703@item --version 3704Prints the version number for @command{windres}. 3705 3706@item --yydebug 3707If @command{windres} is compiled with @code{YYDEBUG} defined as @code{1}, 3708this will turn on parser debugging. 3709@end table 3710 3711@c man end 3712 3713@ignore 3714@c man begin SEEALSO windres 3715the Info entries for @file{binutils}. 3716@c man end 3717@end ignore 3718 3719@node dlltool 3720@chapter dlltool 3721@cindex DLL 3722@kindex dlltool 3723 3724@command{dlltool} is used to create the files needed to create dynamic 3725link libraries (DLLs) on systems which understand PE format image 3726files such as Windows. A DLL contains an export table which contains 3727information that the runtime loader needs to resolve references from a 3728referencing program. 3729 3730The export table is generated by this program by reading in a 3731@file{.def} file or scanning the @file{.a} and @file{.o} files which 3732will be in the DLL. A @file{.o} file can contain information in 3733special @samp{.drectve} sections with export information. 3734 3735@quotation 3736@emph{Note:} @command{dlltool} is not always built as part of the 3737binary utilities, since it is only useful for those targets which 3738support DLLs. 3739@end quotation 3740 3741@c man title dlltool Create files needed to build and use DLLs. 3742 3743@smallexample 3744@c man begin SYNOPSIS dlltool 3745dlltool [@option{-d}|@option{--input-def} @var{def-file-name}] 3746 [@option{-b}|@option{--base-file} @var{base-file-name}] 3747 [@option{-e}|@option{--output-exp} @var{exports-file-name}] 3748 [@option{-z}|@option{--output-def} @var{def-file-name}] 3749 [@option{-l}|@option{--output-lib} @var{library-file-name}] 3750 [@option{-y}|@option{--output-delaylib} @var{library-file-name}] 3751 [@option{--export-all-symbols}] [@option{--no-export-all-symbols}] 3752 [@option{--exclude-symbols} @var{list}] 3753 [@option{--no-default-excludes}] 3754 [@option{-S}|@option{--as} @var{path-to-assembler}] [@option{-f}|@option{--as-flags} @var{options}] 3755 [@option{-D}|@option{--dllname} @var{name}] [@option{-m}|@option{--machine} @var{machine}] 3756 [@option{-a}|@option{--add-indirect}] 3757 [@option{-U}|@option{--add-underscore}] [@option{--add-stdcall-underscore}] 3758 [@option{-k}|@option{--kill-at}] [@option{-A}|@option{--add-stdcall-alias}] 3759 [@option{-p}|@option{--ext-prefix-alias} @var{prefix}] 3760 [@option{-x}|@option{--no-idata4}] [@option{-c}|@option{--no-idata5}] 3761 [@option{--use-nul-prefixed-import-tables}] 3762 [@option{-I}|@option{--identify} @var{library-file-name}] [@option{--identify-strict}] 3763 [@option{-i}|@option{--interwork}] 3764 [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}] 3765 [@option{-v}|@option{--verbose}] 3766 [@option{-h}|@option{--help}] [@option{-V}|@option{--version}] 3767 [@option{--no-leading-underscore}] [@option{--leading-underscore}] 3768 [object-file @dots{}] 3769@c man end 3770@end smallexample 3771 3772@c man begin DESCRIPTION dlltool 3773 3774@command{dlltool} reads its inputs, which can come from the @option{-d} and 3775@option{-b} options as well as object files specified on the command 3776line. It then processes these inputs and if the @option{-e} option has 3777been specified it creates a exports file. If the @option{-l} option 3778has been specified it creates a library file and if the @option{-z} option 3779has been specified it creates a def file. Any or all of the @option{-e}, 3780@option{-l} and @option{-z} options can be present in one invocation of 3781dlltool. 3782 3783When creating a DLL, along with the source for the DLL, it is necessary 3784to have three other files. @command{dlltool} can help with the creation of 3785these files. 3786 3787The first file is a @file{.def} file which specifies which functions are 3788exported from the DLL, which functions the DLL imports, and so on. This 3789is a text file and can be created by hand, or @command{dlltool} can be used 3790to create it using the @option{-z} option. In this case @command{dlltool} 3791will scan the object files specified on its command line looking for 3792those functions which have been specially marked as being exported and 3793put entries for them in the @file{.def} file it creates. 3794 3795In order to mark a function as being exported from a DLL, it needs to 3796have an @option{-export:<name_of_function>} entry in the @samp{.drectve} 3797section of the object file. This can be done in C by using the 3798asm() operator: 3799 3800@smallexample 3801 asm (".section .drectve"); 3802 asm (".ascii \"-export:my_func\""); 3803 3804 int my_func (void) @{ @dots{} @} 3805@end smallexample 3806 3807The second file needed for DLL creation is an exports file. This file 3808is linked with the object files that make up the body of the DLL and it 3809handles the interface between the DLL and the outside world. This is a 3810binary file and it can be created by giving the @option{-e} option to 3811@command{dlltool} when it is creating or reading in a @file{.def} file. 3812 3813The third file needed for DLL creation is the library file that programs 3814will link with in order to access the functions in the DLL (an `import 3815library'). This file can be created by giving the @option{-l} option to 3816dlltool when it is creating or reading in a @file{.def} file. 3817 3818If the @option{-y} option is specified, dlltool generates a delay-import 3819library that can be used instead of the normal import library to allow 3820a program to link to the dll only as soon as an imported function is 3821called for the first time. The resulting executable will need to be 3822linked to the static delayimp library containing __delayLoadHelper2(), 3823which in turn will import LoadLibraryA and GetProcAddress from kernel32. 3824 3825@command{dlltool} builds the library file by hand, but it builds the 3826exports file by creating temporary files containing assembler statements 3827and then assembling these. The @option{-S} command line option can be 3828used to specify the path to the assembler that dlltool will use, 3829and the @option{-f} option can be used to pass specific flags to that 3830assembler. The @option{-n} can be used to prevent dlltool from deleting 3831these temporary assembler files when it is done, and if @option{-n} is 3832specified twice then this will prevent dlltool from deleting the 3833temporary object files it used to build the library. 3834 3835Here is an example of creating a DLL from a source file @samp{dll.c} and 3836also creating a program (from an object file called @samp{program.o}) 3837that uses that DLL: 3838 3839@smallexample 3840 gcc -c dll.c 3841 dlltool -e exports.o -l dll.lib dll.o 3842 gcc dll.o exports.o -o dll.dll 3843 gcc program.o dll.lib -o program 3844@end smallexample 3845 3846 3847@command{dlltool} may also be used to query an existing import library 3848to determine the name of the DLL to which it is associated. See the 3849description of the @option{-I} or @option{--identify} option. 3850 3851@c man end 3852 3853@c man begin OPTIONS dlltool 3854 3855The command line options have the following meanings: 3856 3857@table @env 3858 3859@item -d @var{filename} 3860@itemx --input-def @var{filename} 3861@cindex input .def file 3862Specifies the name of a @file{.def} file to be read in and processed. 3863 3864@item -b @var{filename} 3865@itemx --base-file @var{filename} 3866@cindex base files 3867Specifies the name of a base file to be read in and processed. The 3868contents of this file will be added to the relocation section in the 3869exports file generated by dlltool. 3870 3871@item -e @var{filename} 3872@itemx --output-exp @var{filename} 3873Specifies the name of the export file to be created by dlltool. 3874 3875@item -z @var{filename} 3876@itemx --output-def @var{filename} 3877Specifies the name of the @file{.def} file to be created by dlltool. 3878 3879@item -l @var{filename} 3880@itemx --output-lib @var{filename} 3881Specifies the name of the library file to be created by dlltool. 3882 3883@item -y @var{filename} 3884@itemx --output-delaylib @var{filename} 3885Specifies the name of the delay-import library file to be created by dlltool. 3886 3887@item --export-all-symbols 3888Treat all global and weak defined symbols found in the input object 3889files as symbols to be exported. There is a small list of symbols which 3890are not exported by default; see the @option{--no-default-excludes} 3891option. You may add to the list of symbols to not export by using the 3892@option{--exclude-symbols} option. 3893 3894@item --no-export-all-symbols 3895Only export symbols explicitly listed in an input @file{.def} file or in 3896@samp{.drectve} sections in the input object files. This is the default 3897behaviour. The @samp{.drectve} sections are created by @samp{dllexport} 3898attributes in the source code. 3899 3900@item --exclude-symbols @var{list} 3901Do not export the symbols in @var{list}. This is a list of symbol names 3902separated by comma or colon characters. The symbol names should not 3903contain a leading underscore. This is only meaningful when 3904@option{--export-all-symbols} is used. 3905 3906@item --no-default-excludes 3907When @option{--export-all-symbols} is used, it will by default avoid 3908exporting certain special symbols. The current list of symbols to avoid 3909exporting is @samp{DllMain@@12}, @samp{DllEntryPoint@@0}, 3910@samp{impure_ptr}. You may use the @option{--no-default-excludes} option 3911to go ahead and export these special symbols. This is only meaningful 3912when @option{--export-all-symbols} is used. 3913 3914@item -S @var{path} 3915@itemx --as @var{path} 3916Specifies the path, including the filename, of the assembler to be used 3917to create the exports file. 3918 3919@item -f @var{options} 3920@itemx --as-flags @var{options} 3921Specifies any specific command line options to be passed to the 3922assembler when building the exports file. This option will work even if 3923the @option{-S} option is not used. This option only takes one argument, 3924and if it occurs more than once on the command line, then later 3925occurrences will override earlier occurrences. So if it is necessary to 3926pass multiple options to the assembler they should be enclosed in 3927double quotes. 3928 3929@item -D @var{name} 3930@itemx --dll-name @var{name} 3931Specifies the name to be stored in the @file{.def} file as the name of 3932the DLL when the @option{-e} option is used. If this option is not 3933present, then the filename given to the @option{-e} option will be 3934used as the name of the DLL. 3935 3936@item -m @var{machine} 3937@itemx -machine @var{machine} 3938Specifies the type of machine for which the library file should be 3939built. @command{dlltool} has a built in default type, depending upon how 3940it was created, but this option can be used to override that. This is 3941normally only useful when creating DLLs for an ARM processor, when the 3942contents of the DLL are actually encode using Thumb instructions. 3943 3944@item -a 3945@itemx --add-indirect 3946Specifies that when @command{dlltool} is creating the exports file it 3947should add a section which allows the exported functions to be 3948referenced without using the import library. Whatever the hell that 3949means! 3950 3951@item -U 3952@itemx --add-underscore 3953Specifies that when @command{dlltool} is creating the exports file it 3954should prepend an underscore to the names of @emph{all} exported symbols. 3955 3956@item --no-leading-underscore 3957@item --leading-underscore 3958Specifies whether standard symbol should be forced to be prefixed, or 3959not. 3960 3961@item --add-stdcall-underscore 3962Specifies that when @command{dlltool} is creating the exports file it 3963should prepend an underscore to the names of exported @emph{stdcall} 3964functions. Variable names and non-stdcall function names are not modified. 3965This option is useful when creating GNU-compatible import libs for third 3966party DLLs that were built with MS-Windows tools. 3967 3968@item -k 3969@itemx --kill-at 3970Specifies that when @command{dlltool} is creating the exports file it 3971should not append the string @samp{@@ <number>}. These numbers are 3972called ordinal numbers and they represent another way of accessing the 3973function in a DLL, other than by name. 3974 3975@item -A 3976@itemx --add-stdcall-alias 3977Specifies that when @command{dlltool} is creating the exports file it 3978should add aliases for stdcall symbols without @samp{@@ <number>} 3979in addition to the symbols with @samp{@@ <number>}. 3980 3981@item -p 3982@itemx --ext-prefix-alias @var{prefix} 3983Causes @command{dlltool} to create external aliases for all DLL 3984imports with the specified prefix. The aliases are created for both 3985external and import symbols with no leading underscore. 3986 3987@item -x 3988@itemx --no-idata4 3989Specifies that when @command{dlltool} is creating the exports and library 3990files it should omit the @code{.idata4} section. This is for compatibility 3991with certain operating systems. 3992 3993@item --use-nul-prefixed-import-tables 3994Specifies that when @command{dlltool} is creating the exports and library 3995files it should prefix the @code{.idata4} and @code{.idata5} by zero an 3996element. This emulates old gnu import library generation of 3997@code{dlltool}. By default this option is turned off. 3998 3999@item -c 4000@itemx --no-idata5 4001Specifies that when @command{dlltool} is creating the exports and library 4002files it should omit the @code{.idata5} section. This is for compatibility 4003with certain operating systems. 4004 4005@item -I @var{filename} 4006@itemx --identify @var{filename} 4007Specifies that @command{dlltool} should inspect the import library 4008indicated by @var{filename} and report, on @code{stdout}, the name(s) 4009of the associated DLL(s). This can be performed in addition to any 4010other operations indicated by the other options and arguments. 4011@command{dlltool} fails if the import library does not exist or is not 4012actually an import library. See also @option{--identify-strict}. 4013 4014@item --identify-strict 4015Modifies the behavior of the @option{--identify} option, such 4016that an error is reported if @var{filename} is associated with 4017more than one DLL. 4018 4019@item -i 4020@itemx --interwork 4021Specifies that @command{dlltool} should mark the objects in the library 4022file and exports file that it produces as supporting interworking 4023between ARM and Thumb code. 4024 4025@item -n 4026@itemx --nodelete 4027Makes @command{dlltool} preserve the temporary assembler files it used to 4028create the exports file. If this option is repeated then dlltool will 4029also preserve the temporary object files it uses to create the library 4030file. 4031 4032@item -t @var{prefix} 4033@itemx --temp-prefix @var{prefix} 4034Makes @command{dlltool} use @var{prefix} when constructing the names of 4035temporary assembler and object files. By default, the temp file prefix 4036is generated from the pid. 4037 4038@item -v 4039@itemx --verbose 4040Make dlltool describe what it is doing. 4041 4042@item -h 4043@itemx --help 4044Displays a list of command line options and then exits. 4045 4046@item -V 4047@itemx --version 4048Displays dlltool's version number and then exits. 4049 4050@end table 4051 4052@c man end 4053 4054@menu 4055* def file format:: The format of the dlltool @file{.def} file 4056@end menu 4057 4058@node def file format 4059@section The format of the @command{dlltool} @file{.def} file 4060 4061A @file{.def} file contains any number of the following commands: 4062 4063@table @asis 4064 4065@item @code{NAME} @var{name} @code{[ ,} @var{base} @code{]} 4066The result is going to be named @var{name}@code{.exe}. 4067 4068@item @code{LIBRARY} @var{name} @code{[ ,} @var{base} @code{]} 4069The result is going to be named @var{name}@code{.dll}. 4070Note: If you want to use LIBRARY as name then you need to quote. Otherwise 4071this will fail due a necessary hack for libtool (see PR binutils/13710 for more 4072details). 4073 4074@item @code{EXPORTS ( ( (} @var{name1} @code{[ = } @var{name2} @code{] ) | ( } @var{name1} @code{=} @var{module-name} @code{.} @var{external-name} @code{) ) [ == } @var{its_name} @code{]} 4075@item @code{[} @var{integer} @code{] [ NONAME ] [ CONSTANT ] [ DATA ] [ PRIVATE ] ) *} 4076Declares @var{name1} as an exported symbol from the DLL, with optional 4077ordinal number @var{integer}, or declares @var{name1} as an alias 4078(forward) of the function @var{external-name} in the DLL. 4079If @var{its_name} is specified, this name is used as string in export table. 4080@var{module-name}. 4081Note: The @code{EXPORTS} has to be the last command in .def file, as keywords 4082are treated - beside @code{LIBRARY} - as simple name-identifiers. 4083If you want to use LIBRARY as name then you need to quote it. 4084 4085@item @code{IMPORTS ( (} @var{internal-name} @code{=} @var{module-name} @code{.} @var{integer} @code{) | [} @var{internal-name} @code{= ]} @var{module-name} @code{.} @var{external-name} @code{) [ == ) @var{its_name} @code{]} *} 4086Declares that @var{external-name} or the exported function whose 4087ordinal number is @var{integer} is to be imported from the file 4088@var{module-name}. If @var{internal-name} is specified then this is 4089the name that the imported function will be referred to in the body of 4090the DLL. 4091If @var{its_name} is specified, this name is used as string in import table. 4092Note: The @code{IMPORTS} has to be the last command in .def file, as keywords 4093are treated - beside @code{LIBRARY} - as simple name-identifiers. 4094If you want to use LIBRARY as name then you need to quote it. 4095 4096@item @code{DESCRIPTION} @var{string} 4097Puts @var{string} into the output @file{.exp} file in the 4098@code{.rdata} section. 4099 4100@item @code{STACKSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]} 4101@item @code{HEAPSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]} 4102Generates @code{--stack} or @code{--heap} 4103@var{number-reserve},@var{number-commit} in the output @code{.drectve} 4104section. The linker will see this and act upon it. 4105 4106@item @code{CODE} @var{attr} @code{+} 4107@item @code{DATA} @var{attr} @code{+} 4108@item @code{SECTIONS (} @var{section-name} @var{attr}@code{ + ) *} 4109Generates @code{--attr} @var{section-name} @var{attr} in the output 4110@code{.drectve} section, where @var{attr} is one of @code{READ}, 4111@code{WRITE}, @code{EXECUTE} or @code{SHARED}. The linker will see 4112this and act upon it. 4113 4114@end table 4115 4116@ignore 4117@c man begin SEEALSO dlltool 4118The Info pages for @file{binutils}. 4119@c man end 4120@end ignore 4121 4122@node readelf 4123@chapter readelf 4124 4125@cindex ELF file information 4126@kindex readelf 4127 4128@c man title readelf Displays information about ELF files. 4129 4130@smallexample 4131@c man begin SYNOPSIS readelf 4132readelf [@option{-a}|@option{--all}] 4133 [@option{-h}|@option{--file-header}] 4134 [@option{-l}|@option{--program-headers}|@option{--segments}] 4135 [@option{-S}|@option{--section-headers}|@option{--sections}] 4136 [@option{-g}|@option{--section-groups}] 4137 [@option{-t}|@option{--section-details}] 4138 [@option{-e}|@option{--headers}] 4139 [@option{-s}|@option{--syms}|@option{--symbols}] 4140 [@option{--dyn-syms}] 4141 [@option{-n}|@option{--notes}] 4142 [@option{-r}|@option{--relocs}] 4143 [@option{-u}|@option{--unwind}] 4144 [@option{-d}|@option{--dynamic}] 4145 [@option{-V}|@option{--version-info}] 4146 [@option{-A}|@option{--arch-specific}] 4147 [@option{-D}|@option{--use-dynamic}] 4148 [@option{-x} <number or name>|@option{--hex-dump=}<number or name>] 4149 [@option{-p} <number or name>|@option{--string-dump=}<number or name>] 4150 [@option{-R} <number or name>|@option{--relocated-dump=}<number or name>] 4151 [@option{-c}|@option{--archive-index}] 4152 [@option{-w[lLiaprmfFsoRt]}| 4153 @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]] 4154 [@option{--dwarf-depth=@var{n}}] 4155 [@option{--dwarf-start=@var{n}}] 4156 [@option{-I}|@option{--histogram}] 4157 [@option{-v}|@option{--version}] 4158 [@option{-W}|@option{--wide}] 4159 [@option{-H}|@option{--help}] 4160 @var{elffile}@dots{} 4161@c man end 4162@end smallexample 4163 4164@c man begin DESCRIPTION readelf 4165 4166@command{readelf} displays information about one or more ELF format object 4167files. The options control what particular information to display. 4168 4169@var{elffile}@dots{} are the object files to be examined. 32-bit and 417064-bit ELF files are supported, as are archives containing ELF files. 4171 4172This program performs a similar function to @command{objdump} but it 4173goes into more detail and it exists independently of the @sc{bfd} 4174library, so if there is a bug in @sc{bfd} then readelf will not be 4175affected. 4176 4177@c man end 4178 4179@c man begin OPTIONS readelf 4180 4181The long and short forms of options, shown here as alternatives, are 4182equivalent. At least one option besides @samp{-v} or @samp{-H} must be 4183given. 4184 4185@table @env 4186@item -a 4187@itemx --all 4188Equivalent to specifying @option{--file-header}, 4189@option{--program-headers}, @option{--sections}, @option{--symbols}, 4190@option{--relocs}, @option{--dynamic}, @option{--notes} and 4191@option{--version-info}. 4192 4193@item -h 4194@itemx --file-header 4195@cindex ELF file header information 4196Displays the information contained in the ELF header at the start of the 4197file. 4198 4199@item -l 4200@itemx --program-headers 4201@itemx --segments 4202@cindex ELF program header information 4203@cindex ELF segment information 4204Displays the information contained in the file's segment headers, if it 4205has any. 4206 4207@item -S 4208@itemx --sections 4209@itemx --section-headers 4210@cindex ELF section information 4211Displays the information contained in the file's section headers, if it 4212has any. 4213 4214@item -g 4215@itemx --section-groups 4216@cindex ELF section group information 4217Displays the information contained in the file's section groups, if it 4218has any. 4219 4220@item -t 4221@itemx --section-details 4222@cindex ELF section information 4223Displays the detailed section information. Implies @option{-S}. 4224 4225@item -s 4226@itemx --symbols 4227@itemx --syms 4228@cindex ELF symbol table information 4229Displays the entries in symbol table section of the file, if it has one. 4230 4231@item --dyn-syms 4232@cindex ELF dynamic symbol table information 4233Displays the entries in dynamic symbol table section of the file, if it 4234has one. 4235 4236@item -e 4237@itemx --headers 4238Display all the headers in the file. Equivalent to @option{-h -l -S}. 4239 4240@item -n 4241@itemx --notes 4242@cindex ELF notes 4243Displays the contents of the NOTE segments and/or sections, if any. 4244 4245@item -r 4246@itemx --relocs 4247@cindex ELF reloc information 4248Displays the contents of the file's relocation section, if it has one. 4249 4250@item -u 4251@itemx --unwind 4252@cindex unwind information 4253Displays the contents of the file's unwind section, if it has one. Only 4254the unwind sections for IA64 ELF files, as well as ARM unwind tables 4255(@code{.ARM.exidx} / @code{.ARM.extab}) are currently supported. 4256 4257@item -d 4258@itemx --dynamic 4259@cindex ELF dynamic section information 4260Displays the contents of the file's dynamic section, if it has one. 4261 4262@item -V 4263@itemx --version-info 4264@cindex ELF version sections informations 4265Displays the contents of the version sections in the file, it they 4266exist. 4267 4268@item -A 4269@itemx --arch-specific 4270Displays architecture-specific information in the file, if there 4271is any. 4272 4273@item -D 4274@itemx --use-dynamic 4275When displaying symbols, this option makes @command{readelf} use the 4276symbol hash tables in the file's dynamic section, rather than the 4277symbol table sections. 4278 4279@item -x <number or name> 4280@itemx --hex-dump=<number or name> 4281Displays the contents of the indicated section as a hexadecimal bytes. 4282A number identifies a particular section by index in the section table; 4283any other string identifies all sections with that name in the object file. 4284 4285@item -R <number or name> 4286@itemx --relocated-dump=<number or name> 4287Displays the contents of the indicated section as a hexadecimal 4288bytes. A number identifies a particular section by index in the 4289section table; any other string identifies all sections with that name 4290in the object file. The contents of the section will be relocated 4291before they are displayed. 4292 4293@item -p <number or name> 4294@itemx --string-dump=<number or name> 4295Displays the contents of the indicated section as printable strings. 4296A number identifies a particular section by index in the section table; 4297any other string identifies all sections with that name in the object file. 4298 4299@item -c 4300@itemx --archive-index 4301@cindex Archive file symbol index information 4302Displays the file symbol index infomation contained in the header part 4303of binary archives. Performs the same function as the @option{t} 4304command to @command{ar}, but without using the BFD library. @xref{ar}. 4305 4306@item -w[lLiaprmfFsoRt] 4307@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index] 4308Displays the contents of the debug sections in the file, if any are 4309present. If one of the optional letters or words follows the switch 4310then only data found in those specific sections will be dumped. 4311 4312Note that there is no single letter option to display the content of 4313trace sections or .gdb_index. 4314 4315Note: the @option{=decodedline} option will display the interpreted 4316contents of a .debug_line section whereas the @option{=rawline} option 4317dumps the contents in a raw format. 4318 4319Note: the @option{=frames-interp} option will display the interpreted 4320contents of a .debug_frame section whereas the @option{=frames} option 4321dumps the contents in a raw format. 4322 4323Note: the output from the @option{=info} option can also be affected 4324by the options @option{--dwarf-depth} and @option{--dwarf-start}. 4325 4326@item --dwarf-depth=@var{n} 4327Limit the dump of the @code{.debug_info} section to @var{n} children. 4328This is only useful with @option{--debug-dump=info}. The default is 4329to print all DIEs; the special value 0 for @var{n} will also have this 4330effect. 4331 4332With a non-zero value for @var{n}, DIEs at or deeper than @var{n} 4333levels will not be printed. The range for @var{n} is zero-based. 4334 4335@item --dwarf-start=@var{n} 4336Print only DIEs beginning with the DIE numbered @var{n}. This is only 4337useful with @option{--debug-dump=info}. 4338 4339If specified, this option will suppress printing of any header 4340information and all DIEs before the DIE numbered @var{n}. Only 4341siblings and children of the specified DIE will be printed. 4342 4343This can be used in conjunction with @option{--dwarf-depth}. 4344 4345@item -I 4346@itemx --histogram 4347Display a histogram of bucket list lengths when displaying the contents 4348of the symbol tables. 4349 4350@item -v 4351@itemx --version 4352Display the version number of readelf. 4353 4354@item -W 4355@itemx --wide 4356Don't break output lines to fit into 80 columns. By default 4357@command{readelf} breaks section header and segment listing lines for 435864-bit ELF files, so that they fit into 80 columns. This option causes 4359@command{readelf} to print each section header resp. each segment one a 4360single line, which is far more readable on terminals wider than 80 columns. 4361 4362@item -H 4363@itemx --help 4364Display the command line options understood by @command{readelf}. 4365 4366@end table 4367 4368@c man end 4369 4370@ignore 4371@c man begin SEEALSO readelf 4372objdump(1), and the Info entries for @file{binutils}. 4373@c man end 4374@end ignore 4375 4376@node elfedit 4377@chapter elfedit 4378 4379@cindex Update ELF header 4380@kindex elfedit 4381 4382@c man title elfedit Update the ELF header of ELF files. 4383 4384@smallexample 4385@c man begin SYNOPSIS elfedit 4386elfedit [@option{--input-mach=}@var{machine}] 4387 [@option{--input-type=}@var{type}] 4388 [@option{--input-osabi=}@var{osabi}] 4389 @option{--output-mach=}@var{machine} 4390 @option{--output-type=}@var{type} 4391 @option{--output-osabi=}@var{osabi} 4392 [@option{-v}|@option{--version}] 4393 [@option{-h}|@option{--help}] 4394 @var{elffile}@dots{} 4395@c man end 4396@end smallexample 4397 4398@c man begin DESCRIPTION elfedit 4399 4400@command{elfedit} updates the ELF header of ELF files which have 4401the matching ELF machine and file types. The options control how and 4402which fields in the ELF header should be updated. 4403 4404@var{elffile}@dots{} are the ELF files to be updated. 32-bit and 440564-bit ELF files are supported, as are archives containing ELF files. 4406@c man end 4407 4408@c man begin OPTIONS elfedit 4409 4410The long and short forms of options, shown here as alternatives, are 4411equivalent. At least one of the @option{--output-mach}, 4412@option{--output-type} and @option{--output-osabi} options must be given. 4413 4414@table @env 4415 4416@itemx --input-mach=@var{machine} 4417Set the matching input ELF machine type to @var{machine}. If 4418@option{--input-mach} isn't specified, it will match any ELF 4419machine types. 4420 4421The supported ELF machine types are, @var{L1OM}, @var{K1OM} and 4422@var{x86-64}. 4423 4424@itemx --output-mach=@var{machine} 4425Change the ELF machine type in the ELF header to @var{machine}. The 4426supported ELF machine types are the same as @option{--input-mach}. 4427 4428@itemx --input-type=@var{type} 4429Set the matching input ELF file type to @var{type}. If 4430@option{--input-type} isn't specified, it will match any ELF file types. 4431 4432The supported ELF file types are, @var{rel}, @var{exec} and @var{dyn}. 4433 4434@itemx --output-type=@var{type} 4435Change the ELF file type in the ELF header to @var{type}. The 4436supported ELF types are the same as @option{--input-type}. 4437 4438@itemx --input-osabi=@var{osabi} 4439Set the matching input ELF file OSABI to @var{osabi}. If 4440@option{--input-osabi} isn't specified, it will match any ELF OSABIs. 4441 4442The supported ELF OSABIs are, @var{none}, @var{HPUX}, @var{NetBSD}, 4443@var{GNU}, @var{Linux} (alias for @var{GNU}), 4444@var{Solaris}, @var{AIX}, @var{Irix}, 4445@var{FreeBSD}, @var{TRU64}, @var{Modesto}, @var{OpenBSD}, @var{OpenVMS}, 4446@var{NSK}, @var{AROS} and @var{FenixOS}. 4447 4448@itemx --output-osabi=@var{osabi} 4449Change the ELF OSABI in the ELF header to @var{osabi}. The 4450supported ELF OSABI are the same as @option{--input-osabi}. 4451 4452@item -v 4453@itemx --version 4454Display the version number of @command{elfedit}. 4455 4456@item -h 4457@itemx --help 4458Display the command line options understood by @command{elfedit}. 4459 4460@end table 4461 4462@c man end 4463 4464@ignore 4465@c man begin SEEALSO elfedit 4466readelf(1), and the Info entries for @file{binutils}. 4467@c man end 4468@end ignore 4469 4470@node Common Options 4471@chapter Common Options 4472 4473The following command-line options are supported by all of the 4474programs described in this manual. 4475 4476@c man begin OPTIONS 4477@table @env 4478@include at-file.texi 4479@c man end 4480 4481@item --help 4482Display the command-line options supported by the program. 4483 4484@item --version 4485Display the version number of the program. 4486 4487@c man begin OPTIONS 4488@end table 4489@c man end 4490 4491@node Selecting the Target System 4492@chapter Selecting the Target System 4493 4494You can specify two aspects of the target system to the @sc{gnu} 4495binary file utilities, each in several ways: 4496 4497@itemize @bullet 4498@item 4499the target 4500 4501@item 4502the architecture 4503@end itemize 4504 4505In the following summaries, the lists of ways to specify values are in 4506order of decreasing precedence. The ways listed first override those 4507listed later. 4508 4509The commands to list valid values only list the values for which the 4510programs you are running were configured. If they were configured with 4511@option{--enable-targets=all}, the commands list most of the available 4512values, but a few are left out; not all targets can be configured in at 4513once because some of them can only be configured @dfn{native} (on hosts 4514with the same type as the target system). 4515 4516@menu 4517* Target Selection:: 4518* Architecture Selection:: 4519@end menu 4520 4521@node Target Selection 4522@section Target Selection 4523 4524A @dfn{target} is an object file format. A given target may be 4525supported for multiple architectures (@pxref{Architecture Selection}). 4526A target selection may also have variations for different operating 4527systems or architectures. 4528 4529The command to list valid target values is @samp{objdump -i} 4530(the first column of output contains the relevant information). 4531 4532Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips}, 4533@samp{a.out-sunos-big}. 4534 4535You can also specify a target using a configuration triplet. This is 4536the same sort of name that is passed to @file{configure} to specify a 4537target. When you use a configuration triplet as an argument, it must be 4538fully canonicalized. You can see the canonical version of a triplet by 4539running the shell script @file{config.sub} which is included with the 4540sources. 4541 4542Some sample configuration triplets are: @samp{m68k-hp-bsd}, 4543@samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}. 4544 4545@subheading @command{objdump} Target 4546 4547Ways to specify: 4548 4549@enumerate 4550@item 4551command line option: @option{-b} or @option{--target} 4552 4553@item 4554environment variable @code{GNUTARGET} 4555 4556@item 4557deduced from the input file 4558@end enumerate 4559 4560@subheading @command{objcopy} and @command{strip} Input Target 4561 4562Ways to specify: 4563 4564@enumerate 4565@item 4566command line options: @option{-I} or @option{--input-target}, or @option{-F} or @option{--target} 4567 4568@item 4569environment variable @code{GNUTARGET} 4570 4571@item 4572deduced from the input file 4573@end enumerate 4574 4575@subheading @command{objcopy} and @command{strip} Output Target 4576 4577Ways to specify: 4578 4579@enumerate 4580@item 4581command line options: @option{-O} or @option{--output-target}, or @option{-F} or @option{--target} 4582 4583@item 4584the input target (see ``@command{objcopy} and @command{strip} Input Target'' above) 4585 4586@item 4587environment variable @code{GNUTARGET} 4588 4589@item 4590deduced from the input file 4591@end enumerate 4592 4593@subheading @command{nm}, @command{size}, and @command{strings} Target 4594 4595Ways to specify: 4596 4597@enumerate 4598@item 4599command line option: @option{--target} 4600 4601@item 4602environment variable @code{GNUTARGET} 4603 4604@item 4605deduced from the input file 4606@end enumerate 4607 4608@node Architecture Selection 4609@section Architecture Selection 4610 4611An @dfn{architecture} is a type of @sc{cpu} on which an object file is 4612to run. Its name may contain a colon, separating the name of the 4613processor family from the name of the particular @sc{cpu}. 4614 4615The command to list valid architecture values is @samp{objdump -i} (the 4616second column contains the relevant information). 4617 4618Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}. 4619 4620@subheading @command{objdump} Architecture 4621 4622Ways to specify: 4623 4624@enumerate 4625@item 4626command line option: @option{-m} or @option{--architecture} 4627 4628@item 4629deduced from the input file 4630@end enumerate 4631 4632@subheading @command{objcopy}, @command{nm}, @command{size}, @command{strings} Architecture 4633 4634Ways to specify: 4635 4636@enumerate 4637@item 4638deduced from the input file 4639@end enumerate 4640 4641@node Reporting Bugs 4642@chapter Reporting Bugs 4643@cindex bugs 4644@cindex reporting bugs 4645 4646Your bug reports play an essential role in making the binary utilities 4647reliable. 4648 4649Reporting a bug may help you by bringing a solution to your problem, or 4650it may not. But in any case the principal function of a bug report is 4651to help the entire community by making the next version of the binary 4652utilities work better. Bug reports are your contribution to their 4653maintenance. 4654 4655In order for a bug report to serve its purpose, you must include the 4656information that enables us to fix the bug. 4657 4658@menu 4659* Bug Criteria:: Have you found a bug? 4660* Bug Reporting:: How to report bugs 4661@end menu 4662 4663@node Bug Criteria 4664@section Have You Found a Bug? 4665@cindex bug criteria 4666 4667If you are not sure whether you have found a bug, here are some guidelines: 4668 4669@itemize @bullet 4670@cindex fatal signal 4671@cindex crash 4672@item 4673If a binary utility gets a fatal signal, for any input whatever, that is 4674a bug. Reliable utilities never crash. 4675 4676@cindex error on valid input 4677@item 4678If a binary utility produces an error message for valid input, that is a 4679bug. 4680 4681@item 4682If you are an experienced user of binary utilities, your suggestions for 4683improvement are welcome in any case. 4684@end itemize 4685 4686@node Bug Reporting 4687@section How to Report Bugs 4688@cindex bug reports 4689@cindex bugs, reporting 4690 4691A number of companies and individuals offer support for @sc{gnu} 4692products. If you obtained the binary utilities from a support 4693organization, we recommend you contact that organization first. 4694 4695You can find contact information for many support companies and 4696individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs 4697distribution. 4698 4699@ifset BUGURL 4700In any event, we also recommend that you send bug reports for the binary 4701utilities to @value{BUGURL}. 4702@end ifset 4703 4704The fundamental principle of reporting bugs usefully is this: 4705@strong{report all the facts}. If you are not sure whether to state a 4706fact or leave it out, state it! 4707 4708Often people omit facts because they think they know what causes the 4709problem and assume that some details do not matter. Thus, you might 4710assume that the name of a file you use in an example does not matter. 4711Well, probably it does not, but one cannot be sure. Perhaps the bug is 4712a stray memory reference which happens to fetch from the location where 4713that pathname is stored in memory; perhaps, if the pathname were 4714different, the contents of that location would fool the utility into 4715doing the right thing despite the bug. Play it safe and give a 4716specific, complete example. That is the easiest thing for you to do, 4717and the most helpful. 4718 4719Keep in mind that the purpose of a bug report is to enable us to fix the bug if 4720it is new to us. Therefore, always write your bug reports on the assumption 4721that the bug has not been reported previously. 4722 4723Sometimes people give a few sketchy facts and ask, ``Does this ring a 4724bell?'' This cannot help us fix a bug, so it is basically useless. We 4725respond by asking for enough details to enable us to investigate. 4726You might as well expedite matters by sending them to begin with. 4727 4728To enable us to fix the bug, you should include all these things: 4729 4730@itemize @bullet 4731@item 4732The version of the utility. Each utility announces it if you start it 4733with the @option{--version} argument. 4734 4735Without this, we will not know whether there is any point in looking for 4736the bug in the current version of the binary utilities. 4737 4738@item 4739Any patches you may have applied to the source, including any patches 4740made to the @code{BFD} library. 4741 4742@item 4743The type of machine you are using, and the operating system name and 4744version number. 4745 4746@item 4747What compiler (and its version) was used to compile the utilities---e.g. 4748``@code{gcc-2.7}''. 4749 4750@item 4751The command arguments you gave the utility to observe the bug. To 4752guarantee you will not omit something important, list them all. A copy 4753of the Makefile (or the output from make) is sufficient. 4754 4755If we were to try to guess the arguments, we would probably guess wrong 4756and then we might not encounter the bug. 4757 4758@item 4759A complete input file, or set of input files, that will reproduce the 4760bug. If the utility is reading an object file or files, then it is 4761generally most helpful to send the actual object files. 4762 4763If the source files were produced exclusively using @sc{gnu} programs 4764(e.g., @command{gcc}, @command{gas}, and/or the @sc{gnu} @command{ld}), then it 4765may be OK to send the source files rather than the object files. In 4766this case, be sure to say exactly what version of @command{gcc}, or 4767whatever, was used to produce the object files. Also say how 4768@command{gcc}, or whatever, was configured. 4769 4770@item 4771A description of what behavior you observe that you believe is 4772incorrect. For example, ``It gets a fatal signal.'' 4773 4774Of course, if the bug is that the utility gets a fatal signal, then we 4775will certainly notice it. But if the bug is incorrect output, we might 4776not notice unless it is glaringly wrong. You might as well not give us 4777a chance to make a mistake. 4778 4779Even if the problem you experience is a fatal signal, you should still 4780say so explicitly. Suppose something strange is going on, such as your 4781copy of the utility is out of sync, or you have encountered a bug in 4782the C library on your system. (This has happened!) Your copy might 4783crash and ours would not. If you told us to expect a crash, then when 4784ours fails to crash, we would know that the bug was not happening for 4785us. If you had not told us to expect a crash, then we would not be able 4786to draw any conclusion from our observations. 4787 4788@item 4789If you wish to suggest changes to the source, send us context diffs, as 4790generated by @command{diff} with the @option{-u}, @option{-c}, or @option{-p} 4791option. Always send diffs from the old file to the new file. If you 4792wish to discuss something in the @command{ld} source, refer to it by 4793context, not by line number. 4794 4795The line numbers in our development sources will not match those in your 4796sources. Your line numbers would convey no useful information to us. 4797@end itemize 4798 4799Here are some things that are not necessary: 4800 4801@itemize @bullet 4802@item 4803A description of the envelope of the bug. 4804 4805Often people who encounter a bug spend a lot of time investigating 4806which changes to the input file will make the bug go away and which 4807changes will not affect it. 4808 4809This is often time consuming and not very useful, because the way we 4810will find the bug is by running a single example under the debugger 4811with breakpoints, not by pure deduction from a series of examples. 4812We recommend that you save your time for something else. 4813 4814Of course, if you can find a simpler example to report @emph{instead} 4815of the original one, that is a convenience for us. Errors in the 4816output will be easier to spot, running under the debugger will take 4817less time, and so on. 4818 4819However, simplification is not vital; if you do not want to do this, 4820report the bug anyway and send us the entire test case you used. 4821 4822@item 4823A patch for the bug. 4824 4825A patch for the bug does help us if it is a good one. But do not omit 4826the necessary information, such as the test case, on the assumption that 4827a patch is all we need. We might see problems with your patch and decide 4828to fix the problem another way, or we might not understand it at all. 4829 4830Sometimes with programs as complicated as the binary utilities it is 4831very hard to construct an example that will make the program follow a 4832certain path through the code. If you do not send us the example, we 4833will not be able to construct one, so we will not be able to verify that 4834the bug is fixed. 4835 4836And if we cannot understand what bug you are trying to fix, or why your 4837patch should be an improvement, we will not install it. A test case will 4838help us to understand. 4839 4840@item 4841A guess about what the bug is or what it depends on. 4842 4843Such guesses are usually wrong. Even we cannot guess right about such 4844things without first using the debugger to find the facts. 4845@end itemize 4846 4847@node GNU Free Documentation License 4848@appendix GNU Free Documentation License 4849 4850@include fdl.texi 4851 4852@node Binutils Index 4853@unnumbered Binutils Index 4854 4855@printindex cp 4856 4857@bye 4858