bfd/
[deliverable/binutils-gdb.git] / ld / ld.texinfo
index c9691a0a01e283a8706348a5611123bbe6d871cc..1713294cac6191e545be7830e5beeb5a9db354e7 100644 (file)
@@ -875,29 +875,68 @@ for Solaris compatibility.
 
 @kindex -z @var{keyword}
 @item -z @var{keyword}
-The recognized keywords are @code{initfirst}, @code{interpose},
-@code{loadfltr}, @code{nodefaultlib}, @code{nodelete}, @code{nodlopen},
-@code{nodump}, @code{now}, @code{origin}, @code{combreloc}, @code{nocombreloc} 
-and @code{nocopyreloc}.
-The other keywords are
-ignored for Solaris compatibility. @code{initfirst} marks the object
-to be initialized first at runtime before any other objects.
-@code{interpose} marks the object that its symbol table interposes
-before all symbols but the primary executable. @code{loadfltr} marks
-the object that its filtees be processed immediately at runtime.
-@code{nodefaultlib} marks the object that the search for dependencies
-of this object will ignore any default library search paths.
-@code{nodelete} marks the object shouldn't be unloaded at runtime.
-@code{nodlopen} marks the object not available to @code{dlopen}.
-@code{nodump} marks the object can not be dumped by @code{dldump}.
-@code{now} marks the object with the non-lazy runtime binding.
-@code{origin} marks the object may contain $ORIGIN.
-@code{defs} disallows undefined symbols.
-@code{muldefs} allows multiple definitions.
-@code{combreloc} combines multiple reloc sections and sorts them
-to make dynamic symbol lookup caching possible.
-@code{nocombreloc} disables multiple reloc sections combining.
-@code{nocopyreloc} disables production of copy relocs.
+The recognized keywords are:
+@table @samp
+
+@item combreloc
+Combines multiple reloc sections and sorts them to make dynamic symbol
+lookup caching possible.
+
+@item defs
+Disallows undefined symbols in object files.  Undefined symbols in
+shared libaries are still allowed.
+
+@item initfirst
+This option is only meaningful when building a shared object.
+It marks the object so that its runtime initialization will occur
+before the runtime initialization of any other objects brought into
+the process at the same time.  Similarly the runtime finalization of
+the object will occur after the runtime finalization of any other
+objects.
+
+@item interpose
+Marks the object that its symbol table interposes before all symbols
+but the primary executable.
+
+@item loadfltr
+Marks  the object that its filters be processed immediately at
+runtime.
+
+@item muldefs
+Allows multiple definitions.
+
+@item nocombreloc
+Disables multiple reloc sections combining.
+
+@item nocopyreloc
+Disables production of copy relocs.
+
+@item nodefaultlib
+Marks the object that the search for dependencies of this object will
+ignore any default library search paths.
+
+@item nodelete
+Marks the object shouldn't be unloaded at runtime.
+
+@item nodlopen
+Marks the object not available to @code{dlopen}.
+
+@item nodump
+Marks the object can not be dumped by @code{dldump}.
+
+@item now
+When generating an executable or shared library, mark it to tell the
+dynamic linker to resolve all symbols when the program is started, or
+when the shared library is linked to using dlopen, instead of
+deferring function call resolution to the point when the function is
+first called.
+
+@item origin
+Marks the object may contain $ORIGIN.
+
+@end table
+
+Other keywords are ignored for Solaris compatibility.  
 
 @kindex -(
 @cindex groups of archives
@@ -946,15 +985,16 @@ for which shared libraries are supported.  This option is normally the
 default on such platforms.  The different variants of this option are
 for compatibility with various systems.  You may use this option
 multiple times on the command line: it affects library searching for
-@option{-l} options which follow it.
+@option{-l} options which follow it.  This
+option also implies @option{--unresolved-symbols=ignore-all}.
 
 @kindex -Bgroup
 @item -Bgroup
 Set the @code{DF_1_GROUP} flag in the @code{DT_FLAGS_1} entry in the dynamic
 section.  This causes the runtime linker to handle lookups in this
 object and its dependencies to be performed only inside the group.
-@option{--no-undefined} is implied.  This option is only meaningful on ELF
-platforms which support shared libraries.
+@option{--unresolved-symbols=report-all} is implied.  This option is
+only meaningful on ELF platforms which support shared libraries.
 
 @kindex -Bstatic
 @kindex -dn
@@ -968,7 +1008,8 @@ Do not link against shared libraries.  This is only meaningful on
 platforms for which shared libraries are supported.  The different
 variants of this option are for compatibility with various systems.  You
 may use this option multiple times on the command line: it affects
-library searching for @option{-l} options which follow it.
+library searching for @option{-l} options which follow it.  This
+option also implies @option{--unresolved-symbols=report-all}.
 
 @kindex -Bsymbolic
 @item -Bsymbolic
@@ -987,7 +1028,7 @@ been assigned to see if there any overlaps.  Normally the linker will
 perform this check, and if it finds any overlaps it will produce
 suitable error messages.  The linker does know about, and does make
 allowances for sections in overlays.  The default behaviour can be
-restored by using the command line switch @samp{--check-sections}.
+restored by using the command line switch @option{--check-sections}.
 
 @cindex cross reference table
 @kindex --cref
@@ -1108,7 +1149,7 @@ Print a summary of all target specific options on the standard output and exit.
 @kindex -Map
 @item -Map @var{mapfile}
 Print a link map to the file @var{mapfile}.  See the description of the
-@samp{-M} option, above.
+@option{-M} option, above.
 
 @cindex memory usage
 @kindex --no-keep-memory
@@ -1123,11 +1164,11 @@ while linking a large executable.
 @kindex -z defs
 @item --no-undefined
 @itemx -z defs
-Normally when creating a non-symbolic shared library, undefined symbols
-are allowed and left to be resolved by the runtime loader.  This option
-disallows such undefined symbols if they come from regular object
-files.  The switch @samp{--no-allow-shlib-undefined} controls the
-behaviour for shared objects being linked into the shared library.
+Report unresolved symbol references from regular object files.  This
+is done even if the linker is creating a non-symbolic shared library.
+The switch @option{--[no-]allow-shlib-undefined} controls the
+behaviour for reporting unresolved references found in shared
+libraries being linked in.  
 
 @kindex --allow-multiple-definition
 @kindex -z muldefs
@@ -1141,22 +1182,21 @@ first definition will be used.
 @kindex --no-allow-shlib-undefined
 @item --allow-shlib-undefined
 @itemx --no-allow-shlib-undefined
-Allow (the default) or disallow undefined symbols in shared objects.
-The setting of this switch overrides @samp{--no-undefined} where
-shared objects are concerned.  Thus if @samp{--no-undefined} is set
-but @samp{--no-allow-shlib-undefined} is not, the net result will be
-that undefined symbols in regular object files will trigger an error,
-but undefined symbols in shared objects will be ignored.
-
-The reason that @samp{--allow-shlib-undefined} is the default is that
-the shared object being specified at link time may not be the same one
-that is available at load time, so the symbols might actually be
+Allows (the default) or disallows undefined symbols in shared libraries.
+This switch is similar to @option{--no-undefined} except that it
+determines the behaviour when the undefined symbols are in a
+shared library rather than a regular object file.  It does not affect
+how undefined symbols in regular object files are handled.
+
+The reason that @option{--allow-shlib-undefined} is the default is that
+the shared library being specified at link time may not be the same as
+the one that is available at load time, so the symbols might actually be
 resolvable at load time.  Plus there are some systems, (eg BeOS) where
-undefined symbols in shared libraries is normal since the kernel
-patches them at load time to select which function is most appropriate
-for the current architecture. eg. to dynamically select an appropriate
-memset function.  Apparently it is also normal for HPPA shared
-libraries to have undefined symbols.
+undefined symbols in shared libraries is normal.  (The kernel patches
+them at load time to select which function is most appropriate 
+for the current architecture.  This is used for example to dynamically
+select an appropriate memset function).  Apparently it is also normal
+for HPPA shared libraries to have undefined symbols.
 
 @kindex --no-undefined-version
 @item --no-undefined-version
@@ -1217,7 +1257,7 @@ this option overrides it.  @xref{BFD}.
 Create a position independent executable.  This is currently only supported on
 ELF platforms.  Position independent executables are similar to shared
 libraries in that they are relocated by the dynamic linker to the virtual
-address OS chooses for them (which can varry between invocations), like
+address the OS chooses for them (which can vary between invocations).  Like
 normal dynamically linked executables they can be executed and symbols
 defined in the executable cannot be overridden by shared libraries.
 
@@ -1448,6 +1488,39 @@ sign (``@key{=}''), and @var{org}.
 Same as --section-start, with @code{.bss}, @code{.data} or
 @code{.text} as the @var{sectionname}.
 
+@kindex --unresolved-symbols
+@item --unresolved-symbols=@var{method}
+Determine how to handle unresolved symbols.  There are four possible
+values for @samp{method}:
+
+@table @samp
+@item ignore-all
+Do not report any unresolved symbols.  This is the default when
+creating shared libraries or dynamic executables.
+
+@item report-all
+Report all unresolved symbols.  This is the default when creating
+static binaries.
+
+@item ignore-in-object-files
+Report unresolved symbols that are contained in shared libraries, but
+ignore them if they come from regular object files.
+
+@item ignore-in-shared-libs
+Report unresolved symbols that come from regular object files, but
+ignore them if they come from shared libraries.  This can be useful
+when creating a dynamic binary and it is known that all the shared
+libraries that it should be referencing are included on the linker's
+command line.
+@end table
+
+The behaviour for shared libraries on their own can also be controlled
+by the @option{--[no-]allow-shlib-undefined} option.
+
+Normally the linker will generate an error message for each reported
+unresolved symbol but the option @option{--warn-unresolved-symbols}
+can change this to a warning.
+
 @kindex --verbose
 @cindex verbose
 @item --dll-verbose
@@ -1470,10 +1543,10 @@ is only meaningful on ELF platforms which support shared libraries.
 @cindex combining symbols, warnings on
 @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,
+a symbol definition.  Unix linkers allow this somewhat sloppy practise,
 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
+Unfortunately, some C libraries use this practise, 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:
@@ -1587,6 +1660,17 @@ The address will only be changed if it not explicitly specified; that
 is, if the @code{SECTIONS} command does not specify a start address for
 the section (@pxref{SECTIONS}).
 
+@kindex --warn-unresolved-symbols
+@item --warn-unresolved-symbols
+If the linker is going to report an unresolved symbol (see the option
+@option{--unresolved-symbols}) it will normally generate an error.
+This option makes it generate a warning instead.
+
+@kindex --error-unresolved-symbols
+@item --error-unresolved-symbols
+This restores the linker's default behaviour of generating errors when
+it is reporting unresolved symbols.
+
 @kindex --whole-archive
 @cindex including an entire archive
 @item --whole-archive
@@ -1833,7 +1917,7 @@ automatically or implicitly exported symbols.
 The linker will create the file @var{file} which will contain an
 import lib corresponding to the DLL the linker is generating. This
 import lib (which should be called @code{*.dll.a} or @code{*.a}
-may be used to link clients against the generated DLL; this behavior
+may be used to link clients against the generated DLL; this behaviour
 makes it possible to skip a separate @code{dlltool} import library
 creation step.
 [This option is specific to the i386 PE targeted port of the linker]
@@ -1859,7 +1943,7 @@ default.
 @item --dll-search-prefix @var{string}
 When linking dynamically to a dll without an import library,
 search for @code{<string><basename>.dll} in preference to 
-@code{lib<basename>.dll}. This behavior allows easy distinction
+@code{lib<basename>.dll}. This behaviour allows easy distinction
 between DLLs built for the various "subplatforms": native, cygwin,
 uwin, pw, etc.  For instance, cygwin DLLs typically use
 @code{--dll-search-prefix=cyg}. 
@@ -1890,7 +1974,7 @@ data type of the exported variable:
 
 One way is to use --enable-runtime-pseudo-reloc switch. This leaves the task
 of adjusting references in your client code for runtime environment, so
-this method works only when runtime environtment supports this feature.
+this method works only when runtime environment supports this feature.
 
 A second solution is to force one of the 'constants' to be a variable -- 
 that is, unknown and un-optimizable at compile time.  For arrays, 
@@ -1930,7 +2014,7 @@ extern_ll -->
 
 A third method of dealing with this difficulty is to abandon
 'auto-import' for the offending symbol and mark it with 
-@code{__declspec(dllimport)}.  However, in practice that
+@code{__declspec(dllimport)}.  However, in practise that
 requires using compile-time #defines to indicate whether you are
 building a DLL, building client code that will link to the DLL, or 
 merely building/linking to a static library.   In making the choice 
@@ -1987,7 +2071,7 @@ functions).
 
 @kindex --disable-auto-import
 @item --disable-auto-import
-Do not attempt to do sophisticalted linking of @code{_symbol} to 
+Do not attempt to do sophisticated linking of @code{_symbol} to 
 @code{__imp__symbol} for DATA imports from DLLs.
 [This option is specific to the i386 PE targeted port of the linker]
 
@@ -2045,7 +2129,7 @@ subsystem version also.
 
 @c man begin ENVIRONMENT
 
-You can change the behavior of @command{ld} with the environment variables
+You can change the behaviour of @command{ld} with the environment variables
 @ifclear SingleFormat
 @code{GNUTARGET},
 @end ifclear
@@ -2686,7 +2770,8 @@ in the first input file.  The first section will be at address zero.
 The full description of an output section looks like this:
 @smallexample
 @group
-@var{section} [@var{address}] [(@var{type})] : [AT(@var{lma})]
+@var{section} [@var{address}] [(@var{type})] :
+  [AT(@var{lma})] [SUBALIGN(@var{subsection_align})]
   @{
     @var{output-section-command}
     @var{output-section-command}
@@ -3207,7 +3292,8 @@ We showed above that the full description of an output section looked
 like this:
 @smallexample
 @group
-@var{section} [@var{address}] [(@var{type})] : [AT(@var{lma})]
+@var{section} [@var{address}] [(@var{type})] :
+  [AT(@var{lma})] [SUBALIGN(@var{subsection_align})]
   @{
     @var{output-section-command}
     @var{output-section-command}
@@ -3222,6 +3308,7 @@ remaining section attributes.
 @menu
 * Output Section Type::                Output section type
 * Output Section LMA::         Output section LMA
+* Forced Input Alignment::     Forced Input Alignment
 * Output Section Region::      Output section region
 * Output Section Phdr::                Output section phdr
 * Output Section Fill::                Output section fill
@@ -3329,6 +3416,15 @@ for (dst = &_bstart; dst< &_bend; dst++)
 @end group
 @end smallexample
 
+@node Forced Input Alignment
+@subsubsection Forced Input Alignment
+@kindex SUBALIGN(@var{subsection_align})
+@cindex forcing input section alignment
+@cindex input section alignment
+You can force input section alignment within an output section by using
+SUBALIGN.  The value specified overrides any alignment given by input
+sections, whether larger or smaller.
+
 @node Output Section Region
 @subsubsection Output Section Region
 @kindex >@var{region}
@@ -4356,7 +4452,8 @@ evaluation purposes.
 @kindex DEFINED(@var{symbol})
 @cindex symbol defaults
 Return 1 if @var{symbol} is in the linker global symbol table and is
-defined, otherwise return 0.  You can use this function to provide
+defined before the statement using DEFINED in the script, otherwise
+return 0.  You can use this function to provide
 default values for symbols.  For example, the following script fragment
 shows how to set a global symbol @samp{begin} to the first location in
 the @samp{.text} section---but if a symbol called @samp{begin} already
This page took 0.027374 seconds and 4 git commands to generate.