update from FSF
[deliverable/binutils-gdb.git] / ld / ld.texinfo
index 33317d6c1b9156c831d2f5475676a9375600384c..41d26dbe4893a4922a754dc9b6f7a5c32ea09b7b 100644 (file)
@@ -163,18 +163,19 @@ line:
 
 @c FIXME!  -relax only avail h8/300, i960.  Conditionals screwed in examples.
 @smallexample
-ld [-o @var{output} ] @var{objfile}@dots{}
+ld [ -o @var{output} ]  @var{objfile}@dots{}
   [ -A@var{architecture} ]  [ -b @var{input-format} ]  [ -Bstatic ]  
   [ -c @var{MRI-commandfile} ]  [ -d | -dc | -dp ]  
   [ -defsym @var{symbol}=@var{expression} ]
   [ -e @var{entry} ]  [ -F ]  [ -F @var{format} ]
-  [ -format @var{input-format} ]  [ -g ]  [ -G @var{size} ]  [ -i ]
-  [ -l@var{ar} ]  [ -L@var{searchdir} ]  [ -M ]  [ -m @var{emulation} ]
-  [ -N | -n ]  [ -noinhibit-exec ]  [ -R @var{filename} ]
-  [ -relax ]  [ -r | -Ur ]  [ -S ]  [ -s ]  [ -T @var{commandfile} ]  
-  [ -Ttext @var{textorg} ]  [ -Tdata @var{dataorg} ]  [ -Tbss @var{bssorg} ]
-  [ -t ]  [ -u @var{sym}]  [-V]  [-v]  [ -X ]  [ -x ]  [ -y@var{symbol} ]
-  [ @{ @var{script} @} ] 
+  [ -format @var{input-format} ]  [ -g ]  [ -G @var{size} ]  [ --help ]  [ -i ]
+  [ -l@var{archive} ]  [ -L@var{searchdir} ]  [ -M ]  [ -Map @var{mapfile} ]
+  [ -m @var{emulation} ]  [ -N | -n ]  [ -noinhibit-exec ]
+  [ -oformat @var{output-format} ]  [ -R @var{filename} ]  [ -relax ]
+  [ -r | -Ur ]  [ -S ]  [ -s ]  [ -sort-common ]  [ -T @var{commandfile} ]
+  [ -Ttext @var{org} ]  [ -Tdata @var{org} ]
+  [ -Tbss @var{org} ]  [ -t ]  [ -u @var{symbol}]  [-V]  [-v]  [ --version ]
+  [ -warn-common ]  [ -y@var{symbol} ]  [ -X ]  [-x ]
 @end smallexample
 
 This plethora of command-line options may seem intimidating, but in
@@ -226,9 +227,6 @@ whitespace, or be given as separate arguments immediately following the
 option that requires them.
 
 @table @code
-@item @var{objfile}@dots{}
-The object files to be linked.
-
 @ifset I960
 @cindex architectures
 @kindex -A@var{arch}
@@ -255,7 +253,9 @@ on the command line.  You don't usually need to specify this, as
 @code{ld} is configured to expect as a default input format the most
 usual format on each machine.  @var{input-format} is a text string, the
 name of a particular format supported by the BFD libraries.
-@w{@samp{-format @var{input-format}}} has the same effect.  @xref{BFD}.
+(You can list the available binary formats with @samp{objdump -i}.)
+@w{@samp{-format @var{input-format}}} has the same effect, as does the
+script command @code{TARGET}.  @xref{BFD}.
 
 You may want to use this option if you are linking files with an unusual
 binary format.  You can also use @samp{-b} to switch formats explicitly (when
@@ -269,7 +269,7 @@ The default format is taken from the environment variable
 @xref{Environment}.
 @end ifset
 You can also define the input
-format from a script, using the command @code{TARGET}; see @ref{Other
+format from a script, using the command @code{TARGET}; see @ref{Option
 Commands}.
 @end ifclear
 
@@ -300,7 +300,7 @@ These three options are equivalent; multiple forms are supported for
 compatibility with other linkers.  They
 assign space to common symbols even if a relocatable output file is
 specified (with @samp{-r}).  The script command
-@code{FORCE_COMMON_ALLOCATION} has the same effect.  @xref{Other
+@code{FORCE_COMMON_ALLOCATION} has the same effect.  @xref{Option
 Commands}.
 
 @cindex symbols, from command line
@@ -333,11 +333,11 @@ entry point.
 Ignored.  Some older linkers used this option throughout a compilation
 toolchain for specifying object-file format for both input and output
 object files.  The mechanisms @code{ld} uses for this purpose (the
-@samp{-b} or @samp{-format} options for input files, the @code{TARGET}
-command in linker scripts for output files, the @code{GNUTARGET}
-environment variable) are more flexible, but @code{ld} accepts the
-@samp{-F} option for compatibility with scripts written to call the old
-linker.
+@samp{-b} or @samp{-format} options for input files, @samp{-oformat}
+option or the @code{TARGET} command in linker scripts for output files,
+the @code{GNUTARGET} environment variable) are more flexible, but
+@code{ld} accepts the @samp{-F} option for compatibility with scripts
+written to call the old linker.
 
 @kindex -format
 @item -format @var{input-format}
@@ -355,17 +355,26 @@ Ignored.  Provided for compatibility with other tools.
 Set the maximum size of objects to be optimized using the GP register to
 @var{size} under MIPS ECOFF.  Ignored for other object file formats.
 
+@item --help
+@kindex --help
+@cindex help
+@cindex usage
+Print a summary of the command-line options on the standard output and exit.
+This option and @samp{--version} begin with two dashes instead of one
+for compatibility with other GNU programs.  The other options start with
+only one dash for compatibility with other linkers.
+
 @kindex -i
 @cindex incremental link
 @item -i
 Perform an incremental link (same as option @samp{-r}).
 
 @cindex archive files, from cmd line
-@kindex -l@var{ar}
+@kindex -l@var{archive}
 @item -l@var{ar} 
-Add archive file @var{ar} to the list of files to link.  This 
+Add archive file @var{archive} to the list of files to link.  This 
 option may be used any number of times.  @code{ld} will search its
-path-list for occurrences of @code{lib@var{ar}.a} for every @var{ar}
+path-list for occurrences of @code{lib@var{ar}.a} for every @var{archive}
 specified.
 
 @cindex search directory, from cmd line
@@ -391,6 +400,13 @@ Print (to the standard output) a link map---diagnostic information
 about where symbols are mapped by @code{ld}, and information on global
 common storage allocation.
 
+@cindex link map
+@kindex -Map
+@item -Map @var{mapfile}
+Print to the file @var{mapfile} a link map---diagnostic information
+about where symbols are mapped by @code{ld}, and information on global
+common storage allocation.
+
 @cindex emulation
 @kindex -m @var{emulation}
 @item -m@var{emulation}
@@ -429,13 +445,24 @@ Use @var{output} as the name for the program produced by @code{ld}; if this
 option is not specified, the name @file{a.out} is used by default.  The
 script command @code{OUTPUT} can also specify the output file name.
 
+@kindex -oformat
+@item -oformat @var{output-format}
+Specify the binary format for the output object file.  You don't usually
+need to specify this, as @code{ld} is configured to produce as a default
+output format the most usual format on each machine.
+@var{output-format} is a text string, the name of a particular format
+supported by the BFD libraries.  (You can list the available binary
+formats with @samp{objdump -i}.)  The script command
+@code{OUTPUT_FORMAT} can also specify the output format, but this option
+overrides it.  @xref{BFD}.
+
 @item -R @var{filename}
 @kindex -R @var{file}
 @cindex symbol-only input
-On some platforms, this option performs global optimizations
-that become possible when the linker resolves addressing in the
-program, such as relaxing address modes and synthesizing new
-instructions in the output object file.
+Read symbol names and their addresses from @var{filename}, but do not
+relocate it or include it in the output.  This allows your output file
+to refer symbolically to absolute locations of memory defined in other
+programs.
  
 @item -relax
 @kindex -relax
@@ -469,7 +496,7 @@ If this option is not specified, an absolute file is produced.  When
 linking C++ programs, this option @emph{will not} resolve references to
 constructors; to do that, use @samp{-Ur}.
 
-This option does the same as @code{-i}.
+This option does the same thing as @samp{-i}.
 
 @item -S 
 @kindex -S
@@ -481,23 +508,18 @@ Omit debugger symbol information (but not all symbols) from the output file.
 @cindex strip all symbols
 Omit all symbol information from the output file.
 
-@item @{ @var{script} @}
-@kindex @{ @var{script} @}
-@cindex scripts on command line
-You can, if you wish, include a script of linker commands directly in
-the command line instead of referring to it via an input file.  When the
-character @samp{@{} occurs on the command line, the linker switches to
-interpreting the command language until the end of the list of commands
-is reached; the end is indicated with a closing brace @samp{@}}.
-@code{ld} does not recognize other command-line options while parsing
-the script.  @xref{Commands}, for a description of the command language.
-
-@item -Tbss @var{bssorg}
-@kindex -Tbss @var{bssorg}
-@itemx -Tdata @var{dataorg}
-@kindex -Tdata @var{dataorg}
-@itemx -Ttext @var{textorg}
-@kindex -Ttext @var{textorg}
+@item -sort-common
+Normally, when @code{ld} places the global common symbols in the
+appropriate output sections, it sorts them by size.  First come all the
+one byte symbols, then all the two bytes, then all the four bytes, and
+then everything else.  This option disables that sorting.
+
+@item -Tbss @var{org}
+@kindex -Tbss @var{org}
+@itemx -Tdata @var{org}
+@kindex -Tdata @var{org}
+@itemx -Ttext @var{org}
+@kindex -Ttext @var{org}
 @cindex segment origins, cmd line
 Use @var{org} as the starting address for---respectively---the
 @code{bss}, @code{data}, or the @code{text} segment of the output file.
@@ -509,16 +531,12 @@ for compatibility with other linkers, you may omit the leading
 @itemx -T@var{commandfile}
 @kindex -T @var{script}
 @cindex script files
-Read link commands from the file
-@var{commandfile}.  These commands completely override @code{ld}'s
-default link format (rather than adding to it); @var{commandfile} must
-specify everything necessary to describe the target format.
-@xref{Commands}.
-If @var{commandfile} does not exist, @code{ld} looks for it in the directories
-specified by any @samp{-L} options.
-
-You may also include a script of link commands directly in the command
-line by bracketing it between @samp{@{} and @samp{@}}.
+Read link commands from the file @var{commandfile}.  These commands
+completely override @code{ld}'s default link format (rather than adding
+to it); @var{commandfile} must specify everything necessary to describe
+the target format.  @xref{Commands}.  If @var{commandfile} does not
+exist, @code{ld} looks for it in the directories specified by any
+preceding @samp{-L} options.  Multiple @samp{-T} options accumulate.
 
 @item -t 
 @kindex -t
@@ -526,10 +544,10 @@ line by bracketing it between @samp{@{} and @samp{@}}.
 @cindex input files, displaying
 Print the names of the input files as @code{ld} processes them.
 
-@item -u @var{sym}
-@kindex -u @var{sym}
+@item -u @var{symbol}
+@kindex -u @var{symbol}
 @cindex undefined symbol
-Force @var{sym} to be entered in the output file as an undefined symbol.
+Force @var{symbol} to be entered in the output file as an undefined symbol.
 Doing this may, for example, trigger linking of additional modules from
 standard libraries.  @samp{-u} may be repeated with different option
 arguments to enter additional undefined symbols.
@@ -543,18 +561,102 @@ For anything other than C++ programs, this option is equivalent to
 @samp{-r}: it generates relocatable output---i.e., an output file that can in
 turn serve as input to @code{ld}.  When linking C++ programs, @samp{-Ur}
 @emph{will} resolve references to constructors, unlike @samp{-r}.
+It does not work to use @samp{-Ur} on files that were themselves linked
+with @samp{-Ur}; once the constructor table has been built, it can not
+be added to.  Use @samp{-Ur} only for the last partial link, and
+@samp{-r} for the others.
 
 @item -V
 @kindex -V
 @cindex version
 Display the version number for @code{ld} and list the supported emulations.
-Print which input files can and can not be opened.
+Display which input files can and can not be opened.
 
 @item -v
 @kindex -v
 @cindex version
 Display the version number for @code{ld}.
-Print which input files can and can not be opened.
+
+@item --version
+@kindex --version
+Display the version number for @code{ld} and exit.
+
+@item -warn-common
+Warn when a common symbol is combined with another common symbol or with
+a symbol definition.  Unix linkers allow this somewhat sloppy practice,
+but linkers on some other operating systems do not.  This option allows
+you to find potential problems from combining global symbols.
+Unfortunately, some C libraries use this practice, so you may get some
+warnings about symbols in the libraries as well as in your programs.
+
+There are three kinds of global symbols, illustrated here by C examples:
+
+@table @samp
+@item int i = 1;
+A definition, which goes in the initialized data section of the output
+file.
+
+@item extern int i;
+An undefined reference, which does not allocate space.
+There must be either a definition or a common symbol for the
+variable somewhere.
+
+@item int i;
+A common symbol.  If there are only (one or more) common symbols for a
+variable, it goes in the uninitialized data area of the output file.
+The linker merges multiple common symbols for the same variable into a
+single symbol.  If they are of different sizes, it picks the largest
+size.  The linker turns a common symbol into a declaration, if there is
+a definition of the same variable.
+@end table
+
+The @samp{-warn-common} option can produce five kinds of warnings.  Each
+warning consists of a pair of lines: the first describes the symbol just
+encountered, and the second describes the previous symbol encountered
+with the same name.  One or both of the two symbols will be a common
+symbol.
+
+@enumerate
+@item
+Turning a common symbol into a reference, because there is already a
+definition for the symbol.
+@smallexample
+@var{file}(@var{section}): warning: common of `@var{symbol}' overridden by definition
+@var{file}(@var{section}): warning: defined here
+@end smallexample
+
+@item
+Turning a common symbol into a reference, because a later definition for
+the symbol is encountered.  This is the same as the previous case,
+except that the symbols are encountered in a different order.
+@smallexample
+@var{file}(@var{section}): warning: definition of `@var{symbol}' overriding common
+@var{file}(@var{section}): warning: common is here
+@end smallexample
+
+@item
+Merging a common symbol with a previous same-sized common symbol.
+@smallexample
+@var{file}(@var{section}): warning: multiple common of `@var{symbol}'
+@var{file}(@var{section}): warning: previous common is here
+@end smallexample
+
+@item
+Merging a common symbol with a previous larger common symbol.
+@smallexample
+@var{file}(@var{section}): warning: common of `@var{symbol}' overridden by larger common
+@var{file}(@var{section}): warning: larger common is here
+@end smallexample
+
+@item
+Merging a common symbol with a previous smaller common symbol.  This is
+the same as the previous case, except that the symbols are
+encountered in a different order.
+@smallexample
+@var{file}(@var{section}): warning: common of `@var{symbol}' overriding smaller common
+@var{file}(@var{section}): warning: smaller common is here
+@end smallexample
+@end enumerate
 
 @item -X 
 @kindex -X
@@ -615,7 +717,7 @@ input files
 @item 
 file formats
 @item 
-output file format
+output file layout
 @item 
 addresses of sections
 @item 
@@ -625,11 +727,7 @@ placement of common blocks
 You may supply a command file (also known as a link script) to the
 linker either explicitly through the @samp{-T} option, or implicitly as
 an ordinary file. If the linker opens a file which it cannot recognize
-as a supported object or archive format, it tries to interpret the file
-as a command file.
-
-You can also include a script directly on the @code{ld} command line,
-delimited by the characters @samp{@{} and @samp{@}}.
+as a supported object or archive format, it reports an error.
 
 @menu
 * Scripts::                     Linker Scripts
@@ -637,7 +735,7 @@ delimited by the characters @samp{@{} and @samp{@}}.
 * MEMORY::                      MEMORY Command
 * SECTIONS::                    SECTIONS Command
 * Entry Point::                 The Entry Point
-* Other Commands::              Other Commands
+* Option Commands::             Option Commands
 @end menu
 
 @node Scripts
@@ -696,7 +794,7 @@ You may call special purpose built-in functions.
 * Operators::                   Operators
 * Evaluation::                  Evaluation
 * Assignment::                  Assignment: Defining Symbols
-* Built-ins::                   Built-In Functions
+* Arithmetic Functions::        Built-In Functions
 @end menu
 
 @node Integers
@@ -944,7 +1042,7 @@ relative to a particular section (@pxref{SECTIONS}).
 When a linker expression is evaluated and assigned to a variable, it is
 given either an absolute or a relocatable type. An absolute expression
 type is one in which the symbol contains the value that it will have in
-the output file, a relocatable expression type is one in which the
+the output file; a relocatable expression type is one in which the
 value is expressed as a fixed offset from the base of a section.
 
 The type of the expression is controlled by its position in the script
@@ -987,8 +1085,8 @@ SECTIONS @{ @dots{}
 will cause the error message ``@code{Non constant expression for initial
 address}''. 
 
-@node Built-ins
-@subsection Built-In Functions
+@node Arithmetic Functions
+@subsection Arithmetic Functions
 @cindex functions in expression language
 The command language includes a number of built-in
 functions for use in link script expressions.
@@ -1112,7 +1210,7 @@ paging.
 @end table
 
 @node MEMORY
-@section MEMORY Command
+@section Memory Layout
 @kindex MEMORY
 @cindex regions of memory
 @cindex discontinuous memory
@@ -1126,7 +1224,7 @@ must avoid.  The linker does not shuffle sections to fit into the
 available regions, but does move the requested sections into the correct
 regions and issue errors when the regions become too full.  
 
-The command files may contain at most one use of the @code{MEMORY}
+A command file may contain at most one use of the @code{MEMORY}
 command; however, you can define as many blocks of memory within it as
 you wish.  The syntax is:
         
@@ -1158,7 +1256,7 @@ omit the parentheses around it as well.
 is the start address of the region in physical memory.  It is
 an expression that must evaluate to a constant before
 memory allocation is performed. The keyword @code{ORIGIN} may be
-abbreviated to @code{org} or @code{o}.
+abbreviated to @code{org} or @code{o} (but not, for example, @samp{ORG}).
 @item @var{len}
 @kindex LENGTH =
 @kindex len =
@@ -1186,13 +1284,13 @@ Options}).  If the combined output sections directed to a region are too
 big for the region, the linker will issue an error message.
 
 @node SECTIONS
-@section SECTIONS Command
+@section Specifying Output Sections
 @kindex SECTIONS
 The @code{SECTIONS} command controls exactly where input sections are
-placed into output sections, their order and to which output sections
-they are allocated.
+placed into output sections, their order in the output file, and to
+which output sections they are allocated.
 
-You may use at most one @code{SECTIONS} command in a commands file,
+You may use at most one @code{SECTIONS} command in a script file,
 but you can have as many statements within it as you wish.  Statements
 within the @code{SECTIONS} command can do one of three things:
 @itemize @bullet
@@ -1201,27 +1299,27 @@ define the entry point;
 @item 
 assign a value to a symbol;
 @item 
-describe the placement of a named output section, and what input
-sections make it up.
+describe the placement of a named output section, and which input
+sections go into it.
 @end itemize
 
-The first two possibilities---defining the entry point, and defining
+The first two operations---defining the entry point and defining
 symbols---can also be done outside the @code{SECTIONS} command:
-@pxref{Entry Point}, @pxref{Assignment}.  They are permitted here as
-well for your convenience in reading the script, so that symbols or the
+@pxref{Entry Point}, and @pxref{Assignment}.  They are permitted here as
+well for your convenience in reading the script, so that symbols and the
 entry point can be defined at meaningful points in your output-file
 layout.
 
-When no @code{SECTIONS} command is specified, the default action
-of the linker is to place each input section into an identically named
-output section in the order that the sections are first encountered in
-the input files; if all input sections are present in the first file,
-for example, the order of sections in the output file will match the
-order in the first input file.
+When no @code{SECTIONS} command is given, the linker places each input
+section into an identically named output section in the order that the
+sections are first encountered in the input files.  If all input sections
+are present in the first file, for example, the order of sections in the
+output file will match the order in the first input file.
 
 @menu
 * Section Definition::          Section Definitions
-* Section Contents::            Section Contents
+* Section Placement::           Section Placement
+* Section Data Expressions::    Section Data Expressions
 * Section Options::             Optional Section Attributes
 @end menu
 
@@ -1229,7 +1327,7 @@ order in the first input file.
 @subsection Section Definitions
 @cindex section definition
 The most frequently used statement in the @code{SECTIONS} command is
-the @dfn{section definition}, which you can use to specify the
+the @dfn{section definition}, which specifies the
 properties of an output section: its location, alignment, contents,
 fill pattern, and target memory region.  Most of
 these specifications are optional; the simplest form of a section
@@ -1245,9 +1343,9 @@ SECTIONS @{ @dots{}
 @noindent
 @var{secname} is the name of the output section, and @var{contents} a
 specification of what goes there---for example, a list of input files or
-sections of input files.  As you might assume, the whitespace shown is
-optional.  You do need the colon @samp{:} and the braces @samp{@{@}},
-however. 
+sections of input files (@pxref{Section Placement}).  As you might
+assume, the whitespace shown is optional.  You do need the colon
+@samp{:} and the braces @samp{@{@}}, however.
 
 @var{secname} must meet the constraints of your output format.  In
 formats which only support a limited number of sections, such as
@@ -1256,15 +1354,15 @@ formats which only support a limited number of sections, such as
 @code{.bss}). If the output format supports any number of sections, but
 with numbers and not names (as is the case for Oasys), the name should be
 supplied as a quoted numeric string.  A section name may consist of any
-sequence characters, but any name which does not conform to the standard
+sequence of characters, but any name which does not conform to the standard
 @code{ld} symbol name syntax must be quoted.
 @xref{Symbols, , Symbol Names}.
 
-@node Section Contents
-@subsection Section Contents
+@node Section Placement
+@subsection Section Placement
 @cindex contents of a section
 In a section definition, you can specify the contents of an output section by
-listing particular object files, by listing particular input-file
+listing particular input files, by listing particular input-file
 sections, or by a combination of the two.  You can also place arbitrary
 data in the section, and define symbols relative to the beginning of the
 section. 
@@ -1281,8 +1379,11 @@ whitespace.
 @cindex files, including in output sections
 You may simply name a particular input file to be placed in the current
 output section; @emph{all} sections from that file are placed in the
-current section definition. To specify a list of particular files by
-name:
+current section definition.  If the file name has already been mentioned
+in another section definition, with an explicit section name list, then
+only those sections which have not yet been allocated are used.
+
+To specify a list of particular files by name:
 @example
 .data : @{ afile.o bfile.o cfile.o @}
 @end example
@@ -1291,10 +1392,6 @@ The example also illustrates that multiple statements can be included in
 the contents of a section definition, since each file name is a separate
 statement. 
 
-If the file name has already been mentioned in another section
-definition, with an explicit section name list, then only those sections
-which have not yet been allocated are used.
-
 @item @var{filename}( @var{section} )
 @itemx @var{filename}( @var{section}, @var{section}, @dots{} )
 @itemx @var{filename}( @var{section} @var{section} @dots{} )
@@ -1315,6 +1412,10 @@ script, you can refer to @emph{all} files from the @code{ld} command
 line: use @samp{*} instead of a particular file name before the
 parenthesized input-file section list.  
 
+If you have already explicitly included some files by name, @samp{*}
+refers to all @emph{remaining} files---those whose places in the output
+file have not yet been defined.
+
 For example, to copy sections @code{1} through @code{4} from an Oasys file
 into the @code{.text} section of an @code{a.out} file, and sections @code{13}
 and @code{14} into the @code{.data} section:
@@ -1330,10 +1431,6 @@ SECTIONS @{
 @}
 @end example
 
-If you have already explicitly included some files by name, @samp{*}
-refers to all @emph{remaining} files---those whose places in the output
-file have not yet been defined.
-
 @item [ @var{section} ]
 @itemx [ @var{section}, @var{section}, @dots{} ]
 @itemx [ @var{section} @var{section} @dots{} ]
@@ -1399,8 +1496,10 @@ SECTIONS @{
 @}
 @end example        
 
-There are still more kinds of statements permitted in the contents of
-output section definitions.  The foregoing statements permitted you to
+@node Section Data Expressions
+@subsection Section Data Expressions
+@cindex expressions in a section
+The foregoing statements
 arrange, in your output file, data originating from your input files.
 You can also place data directly in an output section from the link
 command script.  Most of these additional statements involve
@@ -1416,7 +1515,7 @@ intermix them freely with any of the statements we've just described.
 @cindex filename symbols
 Create a symbol for each input file
 in the current section, set to the address of the first byte of
-data written from the input file.  For instance, with @code{a.out}
+data written from that input file.  For instance, with @code{a.out}
 files it is conventional to have a symbol for each input file.  You can
 accomplish this by defining the output @code{.text} section as follows:
 @example
@@ -1431,7 +1530,7 @@ SECTIONS @{
 @}
 @end example
 
-If @code{objsym} is a file containing this script, and @code{a.o},
+If @code{sample.ld} is a file containing this script, and @code{a.o},
 @code{b.o}, @code{c.o}, and @code{d.o} are four input files with
 contents like the following---
 @example
@@ -1443,7 +1542,7 @@ int abss;
 @end example
 
 @noindent
-@samp{ld -M sample a.o b.o c.o d.o} would create a map like this,
+@samp{ld -M -T sample.ld a.o b.o c.o d.o} would create a map like this,
 containing symbols matching the object file names:
 @example
 00000000 A __DYNAMIC
@@ -1514,7 +1613,7 @@ appropriate for the output file format (@pxref{BFD}).
 @kindex FILL(@var{expression})
 @cindex holes, filling
 @cindex unspecified memory
-Specifies the ``fill pattern'' for the current section.  Any otherwise
+Specify the ``fill pattern'' for the current section.  Any otherwise
 unspecified regions of memory within the section (for example, regions
 you skip over by assigning a new value to the location counter @samp{.})
 are filled with the two least significant bytes from the
@@ -1539,7 +1638,7 @@ SECTIONS @{
 @end smallexample
 
 @var{secname} and @var{contents} are required.  @xref{Section
-Definition}, and @pxref{Section Contents} for details on @var{contents}.
+Definition}, and @pxref{Section Placement} for details on @var{contents}.
 The remaining elements---@var{start}, @code{BLOCK(@var{align)}},
 @code{(NOLOAD)} @code{=@var{fill}}, and @code{>@var{region}}---are all
 optional.
@@ -1663,8 +1762,8 @@ whatever symbol contains the start address to @code{start}:
 start = other_symbol ;
 @end example
 
-@node Other Commands
-@section Other Commands
+@node Option Commands
+@section Option Commands
 The command language includes a number of other commands that you can
 use for specialized purposes.  They are similar in purpose to
 command-line options.
@@ -1709,10 +1808,10 @@ way are treated identically to object files listed on the command line.
 @cindex naming the output file
 Use this command to name the link output file @var{filename}.  The
 effect of @code{OUTPUT(@var{filename})} is identical to the effect of
-@w{@samp{-o @var{filename}}}, and whichever is encountered last will
-control the name actually used to name the output file.  In particular,
-you can use this command to supply a default output-file name other than
-@code{a.out}.
+@w{@samp{-o @var{filename}}}, and whichever is encountered last
+(@samp{-T} or @samp{-o} will control the name actually used to name the
+output file.  In particular, you can use this command to supply a
+default output-file name other than @code{a.out}.
 
 @ifclear SingleFormat
 @item OUTPUT_ARCH ( @var{bfdname} )
@@ -1728,7 +1827,9 @@ command.
 @kindex OUTPUT_FORMAT ( @var{bfdname} )
 @cindex format, output file
 Specify a particular output format, with one of the names used by the
-BFD back-end routines (@pxref{BFD}).  This selection will only affect
+BFD back-end routines (@pxref{BFD}).  The effect is identical to the
+effect of the @samp{-oformat} command-line option.
+This selection will only affect
 the output file; the related command @code{TARGET} affects primarily
 input files.
 @end ifclear
@@ -1753,11 +1854,10 @@ process.
 @kindex TARGET ( @var{format} )
 Change the input-file object code format (like the command-line option
 @samp{-b} or its synonym @samp{-format}).  The argument @var{format} is
-one of the strings used by BFD to name binary formats.  In the current
-@code{ld} implementation, if @code{TARGET} is specified but
-@code{OUTPUT_FORMAT} is not, the last @code{TARGET} argument is also
-used as the default format for the @code{ld} output file.
-@xref{BFD}.
+one of the strings used by BFD to name binary formats.  If @code{TARGET}
+is specified but @code{OUTPUT_FORMAT} is not, the last @code{TARGET}
+argument is also used as the default format for the @code{ld} output
+file.  @xref{BFD}.
 
 @kindex GNUTARGET
 If you don't use the @code{TARGET} command, @code{ld} uses the value of
@@ -1991,155 +2091,12 @@ conversion and during output. @xref{BFD information loss}.
 
 @menu
 * BFD outline::                 How it works: an outline of BFD
-* BFD information loss::        Information Loss
-* Mechanism::                   Mechanism 
 @end menu
 
 @node BFD outline
 @section How it works: an outline of BFD
 @cindex opening object files
-When an object file is opened, BFD subroutines automatically
-determine the format of the input object file, and build a descriptor in
-memory with pointers to routines that will be used to access elements of
-the object file's data structures.
-
-As different information from the the object files is required,
-BFD reads from different sections of the file and processes them.
-For example, a very common operation for the linker is processing symbol
-tables.  Each BFD back end provides a routine for converting
-between the object file's representation of symbols and an internal
-canonical format. When the linker asks for the symbol table of an object
-file, it calls through the memory pointer to the BFD
-back end routine which reads and converts the table into a canonical
-form.  The linker then operates upon the common form. When the link is
-finished and the linker writes the symbol table of the output file,
-another BFD back end routine is called which takes the newly
-created symbol table and converts it into the chosen output format.
-
-@node BFD information loss
-@section Information Loss
-@emph{Information can be lost during output.} The output formats
-supported by BFD do not provide identical facilities, and
-information which may be described in one form has nowhere to go in
-another format. One example of this is alignment information in
-@code{b.out}. There is nowhere in an @code{a.out} format file to store
-alignment information on the contained data, so when a file is linked
-from @code{b.out} and an @code{a.out} image is produced, alignment
-information will not propagate to the output file. (The linker will
-still use the alignment information internally, so the link is performed
-correctly).
-
-Another example is COFF section names. COFF files may contain an
-unlimited number of sections, each one with a textual section name. If
-the target of the link is a format which does not have many sections (e.g.,
-@code{a.out}) or has sections without names (e.g., the Oasys format) the
-link cannot be done simply. You can circumvent this problem by
-describing the desired input-to-output section mapping with the command
-language.
-
-@emph{Information can be lost during canonicalization.} The BFD
-internal canonical form of the external formats is not exhaustive; there
-are structures in input formats for which there is no direct
-representation internally.  This means that the BFD back ends
-cannot maintain all possible data richness through the transformation
-between external to internal and back to external formats.
-
-This limitation is only a problem when using the linker to read one
-format and write another. Each BFD back end is responsible for
-maintaining as much data as possible, and the internal BFD
-canonical form has structures which are opaque to the BFD core,
-and exported only to the back ends. When a file is read in one format,
-the canonical form is generated for BFD and the linker. At the
-same time, the back end saves away any information which would otherwise
-be lost. If the data is then written back in the same format, the back
-end routine will be able to use the canonical form provided by the
-BFD core as well as the information it prepared earlier.  Since
-there is a great deal of commonality between back ends,
-there is no information lost when
-linking big endian COFF to little endian COFF, or from @code{a.out} to
-@code{b.out}.  When a mixture of formats is linked, the information is
-only lost from the files whose format differs from the destination.
-
-@node Mechanism
-@section Mechanism 
-The greatest potential for loss of information occurs when there is the least
-overlap between the information provided by the source format, that
-stored by the canonical format, and that needed by the
-destination format. A brief description of the canonical form may help
-you understand which kinds of data you can count on preserving across
-conversions.
-@cindex BFD canonical format
-@cindex internal object-file format
-
-@table @emph
-@item files
-Information on target machine architecture, particular implementation,
-and format type are stored on a per-file basis. Other information
-includes a demand pagable bit and a write protected bit.
-Information like Unix magic numbers is not stored here---only the magic
-numbers' meaning, so a @code{ZMAGIC} file would have both the demand pagable
-bit and the write protected text bit set.
-
-The byte order of the target is stored on a per-file basis, so that big-
-and little-endian object files may be linked with one another.
-
-@item sections
-Each section in the input file contains the name of the section, the
-original address in the object file, various options, size and alignment
-information and pointers into other BFD data structures.
-
-@item symbols
-Each symbol contains a pointer to the object file which originally
-defined it, its name, its value, and various option bits.  When a
-BFD back end reads in a symbol table, the back end relocates all
-symbols to make them relative to the base of the section where they were
-defined.  Doing this ensures that each symbol points to its containing
-section.  Each symbol also has a varying amount of hidden
-private data for the BFD back end.  Since the symbol points to the
-original file, the private data format for that symbol is accessible.
-@code{ld} can operate on a collection of symbols of wildly different
-formats without problems.
-
-Normal global and simple local symbols are maintained on output, so an
-output file (no matter its format) will retain symbols pointing to
-functions and to global, static, and common variables.  Some symbol
-information is not worth retaining; in @code{a.out}, type information is
-stored in the symbol table as long symbol names. This information would
-be useless to most COFF debuggers and may be thrown away with
-appropriate command line switches. (The GNU debugger @code{gdb} does
-support @code{a.out} style debugging information in COFF).
-
-There is one word of type information within the symbol, so if the
-format supports symbol type information within symbols (for example, COFF,
-IEEE, Oasys) and the type is simple enough to fit within one word
-(nearly everything but aggregates), the information will be preserved.
-
-@item relocation level
-Each canonical BFD relocation record contains a pointer to the symbol to
-relocate to, the offset of the data to relocate, the section the data
-is in, and a pointer to a relocation type descriptor. Relocation is
-performed by passing messages through the relocation type
-descriptor and the symbol pointer. Therefore, relocations can be performed
-on output data using a relocation method that is only available in one of the
-input formats. For instance, Oasys provides a byte relocation format.
-A relocation record requesting this relocation type would point
-indirectly to a routine to perform this, so the relocation may be
-performed on a byte being written to a COFF file, even though 68k COFF
-has no such relocation type.
-@c FIXME why specific reference to 68K above?
-
-@item line numbers
-Object formats can contain, for debugging purposes, some form of mapping
-between symbols, source line numbers, and addresses in the output file.
-These addresses have to be relocated along with the symbol information.
-Each symbol with an associated list of line number records points to the
-first record of the list.  The head of a line number list consists of a
-pointer to the symbol, which allows finding out the address of the
-function whose line number is being described. The rest of the list is
-made up of pairs: offsets into the section and line numbers. Any format
-which can simply derive this information can pass it successfully
-between formats (COFF, IEEE and Oasys).
-@end table
+@include bfdsumm.texi
 @end ifclear
 
 @node MRI
@@ -2153,6 +2110,10 @@ scripts have a much simpler command set than the scripting language
 otherwise used with @code{ld}.  @sc{gnu} @code{ld} supports the most
 commonly used MRI linker commands; these commands are described here.
 
+In general, MRI scripts aren't of much use with the @code{a.out} object
+file format, since it only has three sections and MRI scripts lack some
+features to make use of them.
+
 You can specify a file containing an MRI-compatible script using the
 @samp{-c} command-line option.
 
This page took 0.03675 seconds and 4 git commands to generate.