bfd/
[deliverable/binutils-gdb.git] / ld / ld.texinfo
index 1e0ede51f0f25df2ed4259e4d2e17016a83f8c41..8acc3c49ada36e50baa25e3a5cf3837a2fc72177 100644 (file)
@@ -1,7 +1,7 @@
 \input texinfo
 @setfilename ld.info
 @c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-@c 2001, 2002, 2003 Free Software Foundation, Inc.
+@c 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 @syncodeindex ky cp
 @include configdoc.texi
 @c (configdoc.texi is generated by the Makefile)
@@ -61,7 +61,7 @@ END-INFO-DIR-ENTRY
 This file documents the @sc{gnu} linker LD version @value{VERSION}.
 
 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000,
-2001, 2002, 2003 Free Software Foundation, Inc.
+2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 @ignore
 
@@ -106,7 +106,7 @@ notice identical to this one except for the removal of this paragraph
 @vskip 0pt plus 1filll
 @c man begin COPYRIGHT
 Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001,
-2002, 2003 Free Software Foundation, Inc.
+2002, 2003, 2004 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.1
@@ -152,6 +152,9 @@ section entitled ``GNU Free Documentation License''.
 @ifset HPPA
 * HPPA ELF32::                  ld and HPPA 32-bit ELF
 @end ifset
+@ifset M68HC11
+* M68HC11/68HC12::              ld and the Motorola 68HC11 and 68HC12 families
+@end ifset
 @ifset TICOFF
 * TI COFF::                     ld and the TI COFF
 @end ifset
@@ -687,7 +690,9 @@ Turn off page alignment of sections, and mark the output as
 Set the text and data sections to be readable and writable.  Also, do
 not page-align the data segment, and disable linking against shared
 libraries.  If the output format supports Unix style magic numbers,
-mark the output as @code{OMAGIC}.
+mark the output as @code{OMAGIC}. Note: Although a writable text section
+is allowed for PE-COFF targets, it does not conform to the format
+specification published by Microsoft.
 
 @kindex --no-omagic
 @cindex OMAGIC
@@ -970,6 +975,30 @@ behaviour from release 2.14 onwards is to reject such input files, and
 so the @samp{--accept-unknown-input-arch} option has been added to
 restore the old behaviour.
 
+@kindex --as-needed
+@kindex --no-as-needed
+@item --as-needed
+@itemx --no-as-needed
+This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
+on the command line after the @option{--as-needed} option.  Normally,
+the linker will add a DT_NEEDED tag for each dynamic library mentioned
+on the command line, regardless of whether the library is actually
+needed. @option{--as-needed} causes DT_NEEDED tags to only be emitted
+for libraries that satisfy some reference from regular objects.
+@option{--no-as-needed} restores the default behaviour.
+
+@kindex --add-needed
+@kindex --no-add-needed
+@item --add-needed
+@itemx --no-add-needed
+This option affects the treatment of dynamic libraries from ELF
+DT_NEEDED tags in dynamic libraries mentioned on the command line after
+the @option{--no-add-needed} option.  Normally, the linker will add
+a DT_NEEDED tag for each dynamic library from DT_NEEDED tags.
+@option{--no-add-needed} causes DT_NEEDED tags will never be emitted
+for those libraries from DT_NEEDED tags. @option{--add-needed} restores
+the default behaviour.
+
 @kindex -assert @var{keyword}
 @item -assert @var{keyword}
 This option is ignored for SunOS compatibility.
@@ -985,8 +1014,7 @@ 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.  This
-option also implies @option{--unresolved-symbols=ignore-all}.
+@option{-l} options which follow it.
 
 @kindex -Bgroup
 @item -Bgroup
@@ -1100,15 +1128,6 @@ generating dynamically linked ELF executables.  The default dynamic
 linker is normally correct; don't use this unless you know what you are
 doing.
 
-@cindex MIPS embedded PIC code
-@kindex --embedded-relocs
-@item --embedded-relocs
-This option is only meaningful when linking MIPS embedded PIC code,
-generated by the -membedded-pic option to the @sc{gnu} compiler and
-assembler.  It causes the linker to create a table which may be used at
-runtime to relocate any data which was statically initialized to pointer
-values.  See the code in testsuite/ld-empic for details.
-
 
 @kindex --fatal-warnings
 @item --fatal-warnings
@@ -1132,9 +1151,9 @@ it ends in a @code{.exe} suffix.
 @itemx --gc-sections
 Enable garbage collection of unused input sections.  It is ignored on
 targets that do not support this option.  This option is not compatible
-with @samp{-r}, nor should it be used with dynamic linking.  The default
-behaviour (of not performing this garbage collection) can be restored by
-specifying @samp{--no-gc-sections} on the command line.
+with @samp{-r}. The default behaviour (of not performing this garbage
+collection) can be restored by specifying @samp{--no-gc-sections} on
+the command line.
 
 @cindex help
 @cindex usage
@@ -1286,6 +1305,9 @@ This option is only supported on a few targets.
 @ifset XTENSA
 @xref{Xtensa,, @command{ld} and Xtensa Processors}.
 @end ifset
+@ifset M68HC11
+@xref{M68HC11/68HC12,,@command{ld} and the 68HC11 and 68HC12}.
+@end ifset
 
 On some platforms, the @samp{--relax} option performs global
 optimizations that become possible when the linker resolves addressing
@@ -1495,12 +1517,10 @@ 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.
+Do not report any unresolved symbols.
 
 @item report-all
-Report all unresolved symbols.  This is the default when creating
-static binaries.
+Report all unresolved symbols.  This is the default.
 
 @item ignore-in-object-files
 Report unresolved symbols that are contained in shared libraries, but
@@ -1703,9 +1723,9 @@ Here is a trivial example:
 
 @smallexample
 void *
-__wrap_malloc (int c)
+__wrap_malloc (size_t c)
 @{
-  printf ("malloc called with %ld\n", c);
+  printf ("malloc called with %zu\n", c);
   return __real_malloc (c);
 @}
 @end smallexample
@@ -1732,6 +1752,28 @@ If you specify @option{--disable-new-dtags}, no new dynamic tags will be
 created. By default, the new dynamic tags are not created. Note that
 those options are only available for ELF systems.
 
+@kindex --hash-size=@var{number}
+Set the default size of the linker's hash tables to a prime number
+close to @var{number}.  Increasing this value can reduce the length of
+time it takes the linker to perform its tasks, at the expense of
+increasing the linker's memory requirements.  Similarly reducing this
+value can reduce the memory requirements at the expense of speed.
+
+@kindex --reduce-memory-overheads
+@item --reduce-memory-overheads
+This option reduces memory requirements at ld runtime, at the expense of
+linking speed.  This was introduced to to select the old O(n^2) algorithm
+for link map file generation, rather than the new O(n) algorithm which uses
+about 40% more memory for symbol storage.
+
+Another affect of the switch is to set the default hash table size to
+1021, which again saves memory at the cost of lengthening the linker's
+run time.  This is not done however if the @option{--hash-size} switch
+has been used.
+
+The @option{--reduce-memory-overheads} switch may be also be used to
+enable other tradeoffs in future versions of the linker.
+
 @end table
 
 @c man end
@@ -1870,6 +1912,15 @@ If given, the stdcall suffixes (@@@var{nn}) will be stripped from
 symbols before they are exported.
 [This option is specific to the i386 PE targeted port of the linker]
 
+@kindex --large-address-aware
+@item --large-address-aware
+If given, the appropriate bit in the ``Charateristics'' field of the COFF
+header is set to indicate that this executable supports virtual addresses
+greater than 2 gigabytes.  This should be used in conjuction with the /3GB
+or /USERVA=@var{value} megabytes switch in the ``[operating systems]''
+section of the BOOT.INI.  Otherwise, this bit has no effect.
+[This option is specific to PE targeted ports of the linker]
+
 @kindex --major-image-version
 @item --major-image-version @var{value}
 Sets the major number of the ``image version''.  Defaults to 1.
@@ -1953,8 +2004,13 @@ uwin, pw, etc.  For instance, cygwin DLLs typically use
 @item --enable-auto-import
 Do sophisticated linking of @code{_symbol} to @code{__imp__symbol} for 
 DATA imports from DLLs, and create the necessary thunking symbols when 
-building the import libraries with those DATA exports.  This generally 
-will 'just work' -- but sometimes you may see this message:
+building the import libraries with those DATA exports. Note: Use of the
+'auto-import' extension will cause the text section of the image file
+to be made writable. This does not conform to the PE-COFF format
+specification published by Microsoft.
+
+Using 'auto-import' generally will 'just work' -- but sometimes you may
+see this message:
 
 "variable '<var>' can't be auto-imported. Please read the 
 documentation for ld's @code{--enable-auto-import} for details."
@@ -2123,6 +2179,34 @@ subsystem version also.
 
 @c man end
 
+@ifset M68HC11
+@subsection Options specific to Motorola 68HC11 and 68HC12 targets
+
+@c man begin OPTIONS
+
+The 68HC11 and 68HC12 linkers support specific options to control the
+memory bank switching mapping and trampoline code generation.
+
+@table @gcctabopt
+
+@kindex --no-trampoline
+@item --no-trampoline
+This option disables the generation of trampoline. By default a trampoline
+is generated for each far function which is called using a @code{jsr}
+instruction (this happens when a pointer to a far function is taken).
+
+@kindex --bank-window
+@item --bank-window @var{name}
+This option indicates to the linker the name of the memory region in
+the @samp{MEMORY} specification that describes the memory bank window.
+The definition of such region is then used by the linker to compute
+paging and addresses within the memory window.
+
+@end table
+
+@c man end
+@end ifset
+
 @ifset UsesEnvVars
 @node Environment
 @section Environment Variables
@@ -2349,7 +2433,7 @@ 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
+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
@@ -2818,7 +2902,7 @@ The output section name @samp{/DISCARD/} is special; @ref{Output Section
 Discarding}.
 
 @node Output Section Address
-@subsection Output Section Description
+@subsection Output Section Address
 @cindex address, section
 @cindex section address
 The @var{address} is an expression for the VMA (the virtual memory
@@ -3365,8 +3449,13 @@ Address}).
 The linker will normally set the LMA equal to the VMA.  You can change
 that by using the @code{AT} keyword.  The expression @var{lma} that
 follows the @code{AT} keyword specifies the load address of the
-section.  Alternatively, with @samp{AT>@var{lma_region}} expression,
-you may specify a memory region for the section's load address. @xref{MEMORY}.
+section.
+
+Alternatively, with @samp{AT>@var{lma_region}} expression, you may
+specify a memory region for the section's load address. @xref{MEMORY}.
+Note that if the section has not had a VMA assigned to it then the
+linker will use the @var{lma_region} as the VMA region as well.
+@xref{Output Section Region}.
 
 @cindex ROM initialized data
 @cindex initialized data in ROM
@@ -4374,17 +4463,25 @@ SECTIONS @{ @dots{}
 @end group
 @end smallexample
 
-@item ALIGN(@var{exp})
-@kindex ALIGN(@var{exp})
+@item ALIGN(@var{align})
+@itemx ALIGN(@var{exp},@var{align})
+@kindex ALIGN(@var{align})
+@kindex ALIGN(@var{exp},@var{align})
 @cindex round up location counter
 @cindex align location counter
-Return the location counter (@code{.}) aligned to the next @var{exp}
-boundary.
-@code{ALIGN} doesn't change the value of the location counter---it just
-does arithmetic on it.  Here is an example which aligns the output
-@code{.data} section to the next @code{0x2000} byte boundary after the
-preceding section and sets a variable within the section to the next
-@code{0x8000} boundary after the input sections:
+@cindex round up expression
+@cindex align expression
+Return the location counter (@code{.}) or arbitrary expression aligned
+to the next @var{align} boundary.  The single operand @code{ALIGN}
+doesn't change the value of the location counter---it just does
+arithmetic on it.  The two operand @code{ALIGN} allows an arbitrary
+expression to be aligned upwards (@code{ALIGN(@var{align})} is
+equivalent to @code{ALIGN(., @var{align})}).
+
+Here is an example which aligns the output @code{.data} section to the
+next @code{0x2000} byte boundary after the preceding section and sets a
+variable within the section to the next @code{0x8000} boundary after the
+input sections:
 @smallexample
 @group
 SECTIONS @{ @dots{}
@@ -4585,6 +4682,9 @@ functionality are not listed.
 @ifset MSP430
 * MSP430::                     @command{ld} and MSP430
 @end ifset
+@ifset M68HC11
+* M68HC11/68HC12::             @code{ld} and the Motorola 68HC11 and 68HC12 families
+@end ifset
 @ifset TICOFF
 * TI COFF::                     @command{ld} and TI COFF
 @end ifset
@@ -4626,6 +4726,23 @@ page of memory, and changes them to use the eight-bit address form.
 (That is: the linker turns @samp{mov.b @code{@@}@var{aa}:16} into
 @samp{mov.b @code{@@}@var{aa}:8} whenever the address @var{aa} is in the
 top page of memory).
+
+@item bit manipulation instructions
+@command{ld} finds all bit manipulation instructions like @code{band, bclr, 
+biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst, bxor}
+which use 32 bit and 16 bit absolute address form, but refer to the top 
+page of memory, and changes them to use the 8 bit address form.
+(That is: the linker turns @samp{bset #xx:3,@code{@@}@var{aa}:32} into
+@samp{bset #xx:3,@code{@@}@var{aa}:8} whenever the address @var{aa} is in 
+the top page of memory).
+
+@item system control instructions
+@command{ld} finds all @code{ldc.w, stc.w} instrcutions which use the 
+32 bit absolute address form, but refer to the top page of memory, and 
+changes them to use 16 bit address form.
+(That is: the linker turns @samp{ldc.w @code{@@}@var{aa}:32,ccr} into
+@samp{ldc.w @code{@@}@var{aa}:16,ccr} whenever the address @var{aa} is in 
+the top page of memory).
 @end table
 
 @ifclear GENERIC
@@ -4708,8 +4825,59 @@ not itself call any subroutines).
 @raisesections
 @end ifclear
 
+@ifset M68HC11
+@ifclear GENERIC
+@raisesections
+@end ifclear
+
+@node M68HC11/68HC12
+@section @command{ld} and the Motorola 68HC11 and 68HC12 families
+
+@cindex M68HC11 and 68HC12 support
+
+@subsection Linker Relaxation
+
+For the Motorola 68HC11, @command{ld} can perform these global
+optimizations when you specify the @samp{--relax} command-line option.
+
+@table @emph
+@cindex relaxing on M68HC11
+@item relaxing address modes
+@command{ld} finds all @code{jsr} and @code{jmp} instructions whose
+targets are within eight bits, and turns them into eight-bit
+program-counter relative @code{bsr} and @code{bra} instructions,
+respectively.
+
+@command{ld} also looks at all 16-bit extended addressing modes and
+transforms them in a direct addressing mode when the address is in
+page 0 (between 0 and 0x0ff).
+
+@item relaxing gcc instruction group
+When @command{gcc} is called with @option{-mrelax}, it can emit group
+of instructions that the linker can optimize to use a 68HC11 direct
+addressing mode. These instructions consists of @code{bclr} or
+@code{bset} instructions.
+
+@end table
+
+@subsection Trampoline Generation
+
+@cindex trampoline generation on M68HC11
+@cindex trampoline generation on M68HC12
+For 68HC11 and 68HC12, @command{ld} can generate trampoline code to
+call a far function using a normal @code{jsr} instruction. The linker
+will also change the relocation to some far function to use the 
+trampoline address instead of the function address. This is typically the
+case when a pointer to a function is taken. The pointer will in fact
+point to the function trampoline.
+
+@ifclear GENERIC
+@lowersections
+@end ifclear
+@end ifset
+
 @node ARM
-@section @command{ld}'s Support for Interworking Between ARM and Thumb Code
+@section @command{ld} and the ARM family
 
 @cindex ARM interworking support
 @kindex --support-old-code
@@ -4733,6 +4901,32 @@ But it also sets the bottom bit of the address, so that it can be
 branched to using a BX instruction, and the program will start
 executing in Thumb mode straight away.
 
+@cindex BE8
+@kindex --be8
+The @samp{--be8} switch instructs @command{ld} to generate BE8 format
+executables.  This option is only valid when linking big-endian objects.
+The resulting image will contain big-endian data and little-endian code.
+
+@cindex TARGET1
+@kindex --target1-rel
+@kindex --target1-abs
+The @samp{R_ARM_TARGET1} relocation is typically used for entries in the
+@samp{.init_array} section.  It is interpreted as either @samp{R_ARM_REL32}
+or @samp{R_ARM_ABS32}, depending on the target.  The @samp{--target1-rel}
+and @samp{--target1-abs} switches override the default.
+
+@cindex TARGET2
+@kindex --target2=@var{type}
+The @samp{--target2=type} switch overrides the default definition of the
+@samp{R_ARM_TARGET2} relocation.  Valid values for @samp{type}, their
+meanings, and target defaults are as follows:
+@table @samp
+@item rel
+@samp{R_ARM_REL32} (arm*-*-symbianelf, arm*-*-elf, arm*-*-eabi)
+@item got-rel
+@samp{R_ARM_GOT_PREL} (arm*-*-linux, arm*-*-*bsd)
+@end table
+
 @ifclear GENERIC
 @lowersections
 @end ifclear
@@ -5215,9 +5409,27 @@ that are not being renamed, and do @emph{not} use the
 @samp{--export-all-symbols} option.  If you list only the 
 renamed symbols in the DEF file, and use @samp{--export-all-symbols} 
 to handle the other symbols, then the both the new names @emph{and} 
-the original names for the the renamed symbols will be exported.  
+the original names for the renamed symbols will be exported.  
 In effect, you'd be aliasing those symbols, not renaming them, 
 which is probably not what you wanted.
+
+@cindex weak externals
+@item weak externals
+The Windows object format, PE, specifies a form of weak symbols called
+weak externals.  When a weak symbol is linked and the symbol is not
+defined, the weak symbol becomes an alias for some other symbol.  There
+are three variants of weak externals:
+@itemize
+@item Definition is searched for in objects and libraries, historically
+called lazy externals.
+@item Definition is searched for only in other objects, not in libraries.
+This form is not presently implemented.
+@item No search; the symbol is an alias.  This form is not presently
+implemented.
+@end itemize
+As a GNU extension, weak symbols that do not specify an alternate symbol
+are supported.  If the symbol is undefined when linking, the symbol
+uses a default value.
 @end table
 
 @ifclear GENERIC
This page took 0.029533 seconds and 4 git commands to generate.