If xgettext fails, make Sanitize fail
[deliverable/binutils-gdb.git] / ld / ld.texinfo
index 5acea12e95e42cce54bb61f5b9f3332cdab45a19..ddcba358c86721a26fd3f33379cf076759f4c87b 100644 (file)
@@ -48,15 +48,16 @@ notice identical to this one except for the removal of this paragraph
 @subtitle The GNU linker
 @sp 1
 @subtitle @code{ld} version 2
-@subtitle January 1994
+@subtitle April 1998
 @author Steve Chamberlain
-@author Cygnus Support
+@author Ian Lance Taylor
+@author Cygnus Solutions
 @page
 
 @tex
 {\parskip=0pt
-\hfill Cygnus Support\par
-\hfill steve\@cygnus.com, doc\@cygnus.com\par
+\hfill Cygnus Solutions\par
+\hfill ian\@cygnus.com, doc\@cygnus.com\par
 \hfill {\it Using LD, the GNU linker}\par
 \hfill Edited by Jeffrey Osier (jeffrey\@cygnus.com)\par
 }
@@ -1293,14 +1294,8 @@ line option.  When you do this, your linker script will replace the
 default linker script.
 
 You may also use linker scripts implicitly by naming them as input files
-to the linker, as though they were files to be linked.  If the linker
-opens a file which it can not recognize as an object file or as an
-archive file, it will try to read it as a linker script.  If the file
-can not be parsed as a linker script, the linker will report an error.
-
-An implicit linker script will not replace the default linker script.
-Typically an implicit linker script would contain only the @code{INPUT},
-@code{GROUP}, or @code{VERSION} commands.
+to the linker, as though they were files to be linked.  @xref{Implicit
+Linker Scripts}.
 
 @menu
 * Basic Script Concepts::      Basic Linker Script Concepts
@@ -1313,6 +1308,7 @@ Typically an implicit linker script would contain only the @code{INPUT},
 * PHDRS::                      PHDRS Command
 * VERSION::                    VERSION Command
 * Expressions::                        Expressions in Linker Scripts
+* Implicit Linker Scripts::    Implicit Linker Scripts
 @end menu
 
 @node Basic Script Concepts
@@ -1342,7 +1338,7 @@ of debugging information.
 
 Every loadable or allocatable output section has two addresses.  The
 first is the @dfn{VMA}, or virtual memory address.  This is the address
-the sectin will have when the output file is run.  The second is the
+the section will have when the output file is run.  The second is the
 @dfn{LMA}, or load memory address.  This is the address at which the
 section will be loaded.  In most cases the two addresses will be the
 same.  An example of when they might be different is when a data section
@@ -1427,6 +1423,14 @@ output section in some other way (other ways are described later), the
 address is set from the current value of the location counter.  The
 location counter is then incremented by the size of the output section.
 
+The first line inside the @samp{SECTIONS} command of the above example
+sets the value of the special symbol @samp{.}, which is the location
+counter.  If you do not specify the address of an output section in some
+other way (other ways are described later), the address is set from the
+current value of the location counter.  The location counter is then
+incremented by the size of the output section.  At the start of the
+@samp{SECTIONS} command, the location counter has the value @samp{0}.
+
 The second line defines an output section, @samp{.text}.  The colon is
 required syntax which may be ignored for now.  Within the curly braces
 after the output section name, you list the names of the input sections
@@ -1439,12 +1443,19 @@ Since the location counter is @samp{0x10000} when the output section
 @samp{.text} section in the output file to be @samp{0x10000}.
 
 The remaining lines define the @samp{.data} and @samp{.bss} sections in
-the output file.  The @samp{.data} output section will be at address
-@samp{0x8000000}.  When the @samp{.bss} output section is defined, the
-value of the location counter will be @samp{0x8000000} plus the size of
-the @samp{.data} output section.  The effect is that the @samp{.bss}
-output section will follow immediately after the @samp{.data} output
-section in memory.
+the output file.  The linker will place the @samp{.data} output section
+at address @samp{0x8000000}.  After the linker places the @samp{.data}
+output section, the value of the location counter will be
+@samp{0x8000000} plus the size of the @samp{.data} output section.  The
+effect is that the linker will place the @samp{.bss} output section
+immediately after the @samp{.data} output section in memory
+
+The linker will ensure that each output section has the required
+alignment, by increasing the location counter if necessary.  In this
+example, the specified addresses for the @samp{.text} and @samp{.data}
+sections will probably satisfy any alignment constraints, but the linker
+may have to create a small gap between the @samp{.data} and @samp{.bss}
+sections.
 
 That's it!  That's a simple and complete linker script.
 
@@ -1633,7 +1644,7 @@ There are a few other linker scripts commands.
 @table @code
 @item FORCE_COMMON_ALLOCATION
 @kindex FORCE_COMMON_ALLOCATION
-@cindex common allocation
+@cindex common allocation in linker script
 This command has the same effect as the @samp{-d} command-line option:
 to make @code{ld} assign space to common symbols even if a relocatable
 output file is specified (@samp{-r}).
@@ -1764,11 +1775,12 @@ SECTIONS
 @}
 @end smallexample
 
-In this example, if the program defines @samp{_etext}, the linker will
-give a multiple definition error.  If, on the other hand, the program
-defines @samp{etext}, the linker will silently use the definition in the
-program.  If the program references @samp{etext} but does not define it,
-the linker will use the definition in the linker script.
+In this example, if the program defines @samp{_etext} (with a leading
+underscore), the linker will give a multiple definition error.  If, on
+the other hand, the program defines @samp{etext} (with no leading
+underscore), the linker will silently use the definition in the program.
+If the program references @samp{etext} but does not define it, the
+linker will use the definition in the linker script.
 
 @node SECTIONS
 @section SECTIONS command
@@ -2443,8 +2455,8 @@ You can assign a section to a previously defined program segment by
 using @samp{:@var{phdr}}.  @xref{PHDRS}.  If a section is assigned to
 one or more segments, then all subsequent allocated sections will be
 assigned to those segments as well, unless they use an explicitly
-@code{:@var{phdr}} modifier.  To prevent a section from being assigned
-to a segment when it would normally default to one, use @code{:NONE}.
+@code{:@var{phdr}} modifier.  You can use @code{:NONE} to tell the
+linker to not put the section in any segment at all.
 
 Here is a simple example:
 @smallexample
@@ -2696,14 +2708,15 @@ MEMORY
 @end group
 @end smallexample
 
-If you have defined a memory region named @samp{mem}, you can direct the
-linker to place specific output sections into that memory region by
-using the @samp{>@var{region}} output section attribute.  @xref{Output
-Section Region}.  If no address was specified for the output section,
-the linker will set the address to the next available address within the
-memory region.  If the combined output sections directed to a memory
-region are too large for the region, the linker will issue an error
-message.
+Once you define a memory region, you can direct the linker to place
+specific output sections into that memory region by using the
+@samp{>@var{region}} output section attribute.  For example, if you have
+a memory region named @samp{mem}, you would use @samp{>mem} in the
+output section definition.  @xref{Output Section Region}.  If no address
+was specified for the output section, the linker will set the address to
+the next available address within the memory region.  If the combined
+output sections directed to a memory region are too large for the
+region, the linker will issue an error message.
 
 @node PHDRS
 @section PHDRS Command
@@ -2768,8 +2781,9 @@ If you place a section in one or more segments using @samp{:@var{phdr}},
 then the linker will place all subsequent allocatable sections which do
 not specify @samp{:@var{phdr}} in the same segments.  This is for
 convenience, since generally a whole set of contiguous sections will be
-placed in a single segment.  To prevent a section from being assigned to
-a segment when it would normally default to one, use @code{:NONE}.
+placed in a single segment.  You can use @code{:NONE} to override the
+default segment and tell the linker to not put the section in any
+segment at all.
 
 @kindex FILEHDR
 @kindex PHDRS
@@ -3431,6 +3445,24 @@ you must define the program headers yourself using the @code{PHDRS}
 command (@pxref{PHDRS}).
 @end table
 
+@node Implicit Linker Scripts
+@section Implicit Linker Scripts
+@cindex implicit linker scripts
+If you specify a linker input file which the linker can not recognize as
+an object file or an archive file, it will try to read the file as a
+linker script.  If the file can not be parsed as a linker script, the
+linker will report an error.
+
+An implicit linker script will not replace the default linker script.
+
+Typically an implicit linker script would contain only symbol
+assignments, or the @code{INPUT}, @code{GROUP}, or @code{VERSION}
+commands.
+
+Any input files read because of an implicit linker script will be read
+at the position in the command line where the implicit linker script was
+read.  This can affect archive searching.
+
 @ifset GENERIC
 @node Machine Dependent
 @chapter Machine Dependent Features
This page took 0.026066 seconds and 4 git commands to generate.