1629 lines
		
	
	
	
		
			110 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			1629 lines
		
	
	
	
		
			110 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<html lang="en">
 | 
						|
<head>
 | 
						|
<title>Options - Untitled</title>
 | 
						|
<meta http-equiv="Content-Type" content="text/html">
 | 
						|
<meta name="description" content="Untitled">
 | 
						|
<meta name="generator" content="makeinfo 4.7">
 | 
						|
<link title="Top" rel="start" href="index.html#Top">
 | 
						|
<link rel="up" href="Invocation.html#Invocation" title="Invocation">
 | 
						|
<link rel="next" href="Environment.html#Environment" title="Environment">
 | 
						|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
 | 
						|
<!--
 | 
						|
This file documents the GNU linker LD
 | 
						|
(GNU Binutils)
 | 
						|
version 2.19.
 | 
						|
 | 
						|
Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000,
 | 
						|
2001, 2002, 2003, 2004, 2005, 2006, 2007 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
 | 
						|
or any later version published by the Free Software Foundation;
 | 
						|
with no Invariant Sections, with no Front-Cover Texts, and with no
 | 
						|
Back-Cover Texts.  A copy of the license is included in the
 | 
						|
section entitled ``GNU Free Documentation License''.-->
 | 
						|
<meta http-equiv="Content-Style-Type" content="text/css">
 | 
						|
<style type="text/css"><!--
 | 
						|
  pre.display { font-family:inherit }
 | 
						|
  pre.format  { font-family:inherit }
 | 
						|
  pre.smalldisplay { font-family:inherit; font-size:smaller }
 | 
						|
  pre.smallformat  { font-family:inherit; font-size:smaller }
 | 
						|
  pre.smallexample { font-size:smaller }
 | 
						|
  pre.smalllisp    { font-size:smaller }
 | 
						|
  span.sc { font-variant:small-caps }
 | 
						|
  span.roman { font-family: serif; font-weight: normal; } 
 | 
						|
--></style>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
<div class="node">
 | 
						|
<p>
 | 
						|
<a name="Options"></a>Next: <a rel="next" accesskey="n" href="Environment.html#Environment">Environment</a>,
 | 
						|
Up: <a rel="up" accesskey="u" href="Invocation.html#Invocation">Invocation</a>
 | 
						|
<hr><br>
 | 
						|
</div>
 | 
						|
 | 
						|
<h3 class="section">2.1 Command Line Options</h3>
 | 
						|
 | 
						|
   <p><a name="index-command-line-3"></a><a name="index-options-4"></a>
 | 
						|
<!-- man begin OPTIONS -->
 | 
						|
 | 
						|
   <p>The linker supports a plethora of command-line options, but in actual
 | 
						|
practice few of them are used in any particular context. 
 | 
						|
<a name="index-standard-Unix-system-5"></a>For instance, a frequent use of <span class="command">ld</span> is to link standard Unix
 | 
						|
object files on a standard, supported Unix system.  On such a system, to
 | 
						|
link a file <code>hello.o</code>:
 | 
						|
 | 
						|
<pre class="smallexample">     ld -o <var>output</var> /lib/crt0.o hello.o -lc
 | 
						|
</pre>
 | 
						|
   <p>This tells <span class="command">ld</span> to produce a file called <var>output</var> as the
 | 
						|
result of linking the file <code>/lib/crt0.o</code> with <code>hello.o</code> and
 | 
						|
the library <code>libc.a</code>, which will come from the standard search
 | 
						|
directories.  (See the discussion of the <span class="samp">-l</span> option below.)
 | 
						|
 | 
						|
   <p>Some of the command-line options to <span class="command">ld</span> may be specified at any
 | 
						|
point in the command line.  However, options which refer to files, such
 | 
						|
as <span class="samp">-l</span> or <span class="samp">-T</span>, cause the file to be read at the point at
 | 
						|
which the option appears in the command line, relative to the object
 | 
						|
files and other file options.  Repeating non-file options with a
 | 
						|
different argument will either have no further effect, or override prior
 | 
						|
occurrences (those further to the left on the command line) of that
 | 
						|
option.  Options which may be meaningfully specified more than once are
 | 
						|
noted in the descriptions below.
 | 
						|
 | 
						|
   <p><a name="index-object-files-6"></a>Non-option arguments are object files or archives which are to be linked
 | 
						|
together.  They may follow, precede, or be mixed in with command-line
 | 
						|
options, except that an object file argument may not be placed between
 | 
						|
an option and its argument.
 | 
						|
 | 
						|
   <p>Usually the linker is invoked with at least one object file, but you can
 | 
						|
specify other forms of binary input files using <span class="samp">-l</span>, <span class="samp">-R</span>,
 | 
						|
and the script command language.  If <em>no</em> binary input files at all
 | 
						|
are specified, the linker does not produce any output, and issues the
 | 
						|
message <span class="samp">No input files</span>.
 | 
						|
 | 
						|
   <p>If the linker cannot recognize the format of an object file, it will
 | 
						|
assume that it is a linker script.  A script specified in this way
 | 
						|
augments the main linker script used for the link (either the default
 | 
						|
linker script or the one specified by using <span class="samp">-T</span>).  This feature
 | 
						|
permits the linker to link against a file which appears to be an object
 | 
						|
or an archive, but actually merely defines some symbol values, or uses
 | 
						|
<code>INPUT</code> or <code>GROUP</code> to load other objects.  Specifying a
 | 
						|
script in this way merely augments the main linker script, with the
 | 
						|
extra commands placed after the main script; use the <span class="samp">-T</span> option
 | 
						|
to replace the default linker script entirely, but note the effect of
 | 
						|
the <code>INSERT</code> command.  See <a href="Scripts.html#Scripts">Scripts</a>.
 | 
						|
 | 
						|
   <p>For options whose names are a single letter,
 | 
						|
option arguments must either follow the option letter without intervening
 | 
						|
whitespace, or be given as separate arguments immediately following the
 | 
						|
option that requires them.
 | 
						|
 | 
						|
   <p>For options whose names are multiple letters, either one dash or two can
 | 
						|
precede the option name; for example, <span class="samp">-trace-symbol</span> and
 | 
						|
<span class="samp">--trace-symbol</span> are equivalent.  Note—there is one exception to
 | 
						|
this rule.  Multiple letter options that start with a lower case 'o' can
 | 
						|
only be preceded by two dashes.  This is to reduce confusion with the
 | 
						|
<span class="samp">-o</span> option.  So for example <span class="samp">-omagic</span> sets the output file
 | 
						|
name to <span class="samp">magic</span> whereas <span class="samp">--omagic</span> sets the NMAGIC flag on the
 | 
						|
output.
 | 
						|
 | 
						|
   <p>Arguments to multiple-letter options must either be separated from the
 | 
						|
option name by an equals sign, or be given as separate arguments
 | 
						|
immediately following the option that requires them.  For example,
 | 
						|
<span class="samp">--trace-symbol foo</span> and <span class="samp">--trace-symbol=foo</span> are equivalent. 
 | 
						|
Unique abbreviations of the names of multiple-letter options are
 | 
						|
accepted.
 | 
						|
 | 
						|
   <p>Note—if the linker is being invoked indirectly, via a compiler driver
 | 
						|
(e.g. <span class="samp">gcc</span>) then all the linker command line options should be
 | 
						|
prefixed by <span class="samp">-Wl,</span> (or whatever is appropriate for the particular
 | 
						|
compiler driver) like this:
 | 
						|
 | 
						|
<pre class="smallexample">       gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup
 | 
						|
</pre>
 | 
						|
   <p>This is important, because otherwise the compiler driver program may
 | 
						|
silently drop the linker options, resulting in a bad link.
 | 
						|
 | 
						|
   <p>Here is a table of the generic command line switches accepted by the GNU
 | 
						|
linker:
 | 
						|
 | 
						|
     <dl>
 | 
						|
<!-- This file is designed to be included in manuals that use -->
 | 
						|
<!-- expandargv. -->
 | 
						|
 | 
						|
     <dt><code>@</code><var>file</var><dd>Read command-line options from <var>file</var>.  The options read are
 | 
						|
inserted in place of the original @<var>file</var> option.  If <var>file</var>
 | 
						|
does not exist, or cannot be read, then the option will be treated
 | 
						|
literally, and not removed.
 | 
						|
 | 
						|
     <p>Options in <var>file</var> are separated by whitespace.  A whitespace
 | 
						|
character may be included in an option by surrounding the entire
 | 
						|
option in either single or double quotes.  Any character (including a
 | 
						|
backslash) may be included by prefixing the character to be included
 | 
						|
with a backslash.  The <var>file</var> may itself contain additional
 | 
						|
@<var>file</var> options; any such options will be processed recursively.
 | 
						|
 | 
						|
     <p><a name="index-_002da_0040var_007bkeyword_007d-7"></a><br><dt><code>-a</code><var>keyword</var><dd>This option is supported for HP/UX compatibility.  The <var>keyword</var>
 | 
						|
argument must be one of the strings <span class="samp">archive</span>, <span class="samp">shared</span>, or
 | 
						|
<span class="samp">default</span>.  <span class="samp">-aarchive</span> is functionally equivalent to
 | 
						|
<span class="samp">-Bstatic</span>, and the other two keywords are functionally equivalent
 | 
						|
to <span class="samp">-Bdynamic</span>.  This option may be used any number of times.
 | 
						|
 | 
						|
     <p><a name="index-architectures-8"></a><a name="index-_002dA_0040var_007barch_007d-9"></a><br><dt><code>-A</code><var>architecture</var><dd><a name="index-_002d_002darchitecture_003d_0040var_007barch_007d-10"></a><dt><code>--architecture=</code><var>architecture</var><dd>In the current release of <span class="command">ld</span>, this option is useful only for the
 | 
						|
Intel 960 family of architectures.  In that <span class="command">ld</span> configuration, the
 | 
						|
<var>architecture</var> argument identifies the particular architecture in
 | 
						|
the 960 family, enabling some safeguards and modifying the
 | 
						|
archive-library search path.  See <a href="i960.html#i960"><span class="command">ld</span> and the Intel 960 family</a>, for details.
 | 
						|
 | 
						|
     <p>Future releases of <span class="command">ld</span> may support similar functionality for
 | 
						|
other architecture families.
 | 
						|
 | 
						|
     <p><a name="index-binary-input-format-11"></a><a name="index-_002db-_0040var_007bformat_007d-12"></a><a name="index-_002d_002dformat_003d_0040var_007bformat_007d-13"></a><a name="index-input-format-14"></a><a name="index-input-format-15"></a><br><dt><code>-b </code><var>input-format</var><dt><code>--format=</code><var>input-format</var><dd><span class="command">ld</span> may be configured to support more than one kind of object
 | 
						|
file.  If your <span class="command">ld</span> is configured this way, you can use the
 | 
						|
<span class="samp">-b</span> option to specify the binary format for input object files
 | 
						|
that follow this option on the command line.  Even when <span class="command">ld</span> is
 | 
						|
configured to support alternative object formats, you don't usually need
 | 
						|
to specify this, as <span class="command">ld</span> should be configured to expect as a
 | 
						|
default input format the most usual format on each machine. 
 | 
						|
<var>input-format</var> is a text string, the name of a particular format
 | 
						|
supported by the BFD libraries.  (You can list the available binary
 | 
						|
formats with <span class="samp">objdump -i</span>.) 
 | 
						|
See <a href="BFD.html#BFD">BFD</a>.
 | 
						|
 | 
						|
     <p>You may want to use this option if you are linking files with an unusual
 | 
						|
binary format.  You can also use <span class="samp">-b</span> to switch formats explicitly (when
 | 
						|
linking object files of different formats), by including
 | 
						|
<span class="samp">-b </span><var>input-format</var> before each group of object files in a
 | 
						|
particular format.
 | 
						|
 | 
						|
     <p>The default format is taken from the environment variable
 | 
						|
<code>GNUTARGET</code>. 
 | 
						|
See <a href="Environment.html#Environment">Environment</a>. 
 | 
						|
You can also define the input format from a script, using the command
 | 
						|
<code>TARGET</code>;
 | 
						|
see <a href="Format-Commands.html#Format-Commands">Format Commands</a>.
 | 
						|
 | 
						|
     <p><a name="index-_002dc-_0040var_007bMRI_002dcmdfile_007d-16"></a><a name="index-_002d_002dmri_002dscript_003d_0040var_007bMRI_002dcmdfile_007d-17"></a><a name="index-compatibility_002c-MRI-18"></a><br><dt><code>-c </code><var>MRI-commandfile</var><dt><code>--mri-script=</code><var>MRI-commandfile</var><dd>For compatibility with linkers produced by MRI, <span class="command">ld</span> accepts script
 | 
						|
files written in an alternate, restricted command language, described in
 | 
						|
<a href="MRI.html#MRI">MRI Compatible Script Files</a>. 
 | 
						|
Introduce MRI script files with
 | 
						|
the option <span class="samp">-c</span>; use the <span class="samp">-T</span> option to run linker
 | 
						|
scripts written in the general-purpose <span class="command">ld</span> scripting language. 
 | 
						|
If <var>MRI-cmdfile</var> does not exist, <span class="command">ld</span> looks for it in the directories
 | 
						|
specified by any <span class="samp">-L</span> options.
 | 
						|
 | 
						|
     <p><a name="index-common-allocation-19"></a><a name="index-_002dd-20"></a><a name="index-_002ddc-21"></a><a name="index-_002ddp-22"></a><br><dt><code>-d</code><dt><code>-dc</code><dt><code>-dp</code><dd>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 <span class="samp">-r</span>).  The
 | 
						|
script command <code>FORCE_COMMON_ALLOCATION</code> has the same effect. 
 | 
						|
See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
 | 
						|
 | 
						|
     <p><a name="index-entry-point_002c-from-command-line-23"></a><a name="index-_002de-_0040var_007bentry_007d-24"></a><a name="index-_002d_002dentry_003d_0040var_007bentry_007d-25"></a><br><dt><code>-e </code><var>entry</var><dt><code>--entry=</code><var>entry</var><dd>Use <var>entry</var> as the explicit symbol for beginning execution of your
 | 
						|
program, rather than the default entry point.  If there is no symbol
 | 
						|
named <var>entry</var>, the linker will try to parse <var>entry</var> as a number,
 | 
						|
and use that as the entry address (the number will be interpreted in
 | 
						|
base 10; you may use a leading <span class="samp">0x</span> for base 16, or a leading
 | 
						|
<span class="samp">0</span> for base 8).  See <a href="Entry-Point.html#Entry-Point">Entry Point</a>, for a discussion of defaults
 | 
						|
and other ways of specifying the entry point.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dexclude_002dlibs-26"></a><br><dt><code>--exclude-libs </code><var>lib</var><code>,</code><var>lib</var><code>,...</code><dd>Specifies a list of archive libraries from which symbols should not be automatically
 | 
						|
exported. The library names may be delimited by commas or colons.  Specifying
 | 
						|
<code>--exclude-libs ALL</code> excludes symbols in all archive libraries from
 | 
						|
automatic export.  This option is available only for the i386 PE targeted
 | 
						|
port of the linker and for ELF targeted ports.  For i386 PE, symbols
 | 
						|
explicitly listed in a .def file are still exported, regardless of this
 | 
						|
option.  For ELF targeted ports, symbols affected by this option will
 | 
						|
be treated as hidden.
 | 
						|
 | 
						|
     <p><a name="index-dynamic-symbol-table-27"></a><a name="index-_002dE-28"></a><a name="index-_002d_002dexport_002ddynamic-29"></a><br><dt><code>-E</code><dt><code>--export-dynamic</code><dd>When creating a dynamically linked executable, add all symbols to the
 | 
						|
dynamic symbol table.  The dynamic symbol table is the set of symbols
 | 
						|
which are visible from dynamic objects at run time.
 | 
						|
 | 
						|
     <p>If you do not use this option, the dynamic symbol table will normally
 | 
						|
contain only those symbols which are referenced by some dynamic object
 | 
						|
mentioned in the link.
 | 
						|
 | 
						|
     <p>If you use <code>dlopen</code> to load a dynamic object which needs to refer
 | 
						|
back to the symbols defined by the program, rather than some other
 | 
						|
dynamic object, then you will probably need to use this option when
 | 
						|
linking the program itself.
 | 
						|
 | 
						|
     <p>You can also use the dynamic list to control what symbols should
 | 
						|
be added to the dynamic symbol table if the output format supports it. 
 | 
						|
See the description of <span class="samp">--dynamic-list</span>.
 | 
						|
 | 
						|
     <p><a name="index-big_002dendian-objects-30"></a><a name="index-endianness-31"></a><a name="index-_002dEB-32"></a><br><dt><code>-EB</code><dd>Link big-endian objects.  This affects the default output format.
 | 
						|
 | 
						|
     <p><a name="index-little_002dendian-objects-33"></a><a name="index-_002dEL-34"></a><br><dt><code>-EL</code><dd>Link little-endian objects.  This affects the default output format.
 | 
						|
 | 
						|
     <p><a name="index-_002df-35"></a><a name="index-_002d_002dauxiliary-36"></a><br><dt><code>-f</code><dt><code>--auxiliary </code><var>name</var><dd>When creating an ELF shared object, set the internal DT_AUXILIARY field
 | 
						|
to the specified name.  This tells the dynamic linker that the symbol
 | 
						|
table of the shared object should be used as an auxiliary filter on the
 | 
						|
symbol table of the shared object <var>name</var>.
 | 
						|
 | 
						|
     <p>If you later link a program against this filter object, then, when you
 | 
						|
run the program, the dynamic linker will see the DT_AUXILIARY field.  If
 | 
						|
the dynamic linker resolves any symbols from the filter object, it will
 | 
						|
first check whether there is a definition in the shared object
 | 
						|
<var>name</var>.  If there is one, it will be used instead of the definition
 | 
						|
in the filter object.  The shared object <var>name</var> need not exist. 
 | 
						|
Thus the shared object <var>name</var> may be used to provide an alternative
 | 
						|
implementation of certain functions, perhaps for debugging or for
 | 
						|
machine specific performance.
 | 
						|
 | 
						|
     <p>This option may be specified more than once.  The DT_AUXILIARY entries
 | 
						|
will be created in the order in which they appear on the command line.
 | 
						|
 | 
						|
     <p><a name="index-_002dF-37"></a><a name="index-_002d_002dfilter-38"></a><br><dt><code>-F </code><var>name</var><dt><code>--filter </code><var>name</var><dd>When creating an ELF shared object, set the internal DT_FILTER field to
 | 
						|
the specified name.  This tells the dynamic linker that the symbol table
 | 
						|
of the shared object which is being created should be used as a filter
 | 
						|
on the symbol table of the shared object <var>name</var>.
 | 
						|
 | 
						|
     <p>If you later link a program against this filter object, then, when you
 | 
						|
run the program, the dynamic linker will see the DT_FILTER field.  The
 | 
						|
dynamic linker will resolve symbols according to the symbol table of the
 | 
						|
filter object as usual, but it will actually link to the definitions
 | 
						|
found in the shared object <var>name</var>.  Thus the filter object can be
 | 
						|
used to select a subset of the symbols provided by the object
 | 
						|
<var>name</var>.
 | 
						|
 | 
						|
     <p>Some older linkers used the <span class="option">-F</span> option throughout a compilation
 | 
						|
toolchain for specifying object-file format for both input and output
 | 
						|
object files. 
 | 
						|
The <span class="sc">gnu</span> linker uses other mechanisms for this purpose: the
 | 
						|
<span class="option">-b</span>, <span class="option">--format</span>, <span class="option">--oformat</span> options, the
 | 
						|
<code>TARGET</code> command in linker scripts, and the <code>GNUTARGET</code>
 | 
						|
environment variable. 
 | 
						|
The <span class="sc">gnu</span> linker will ignore the <span class="option">-F</span> option when not
 | 
						|
creating an ELF shared object.
 | 
						|
 | 
						|
     <p><a name="index-finalization-function-39"></a><a name="index-_002dfini-40"></a><br><dt><code>-fini </code><var>name</var><dd>When creating an ELF executable or shared object, call NAME when the
 | 
						|
executable or shared object is unloaded, by setting DT_FINI to the
 | 
						|
address of the function.  By default, the linker uses <code>_fini</code> as
 | 
						|
the function to call.
 | 
						|
 | 
						|
     <p><a name="index-_002dg-41"></a><br><dt><code>-g</code><dd>Ignored.  Provided for compatibility with other tools.
 | 
						|
 | 
						|
     <p><a name="index-_002dG-42"></a><a name="index-_002d_002dgpsize-43"></a><a name="index-object-size-44"></a><br><dt><code>-G</code><var>value</var><dt><code>--gpsize=</code><var>value</var><dd>Set the maximum size of objects to be optimized using the GP register to
 | 
						|
<var>size</var>.  This is only meaningful for object file formats such as
 | 
						|
MIPS ECOFF which supports putting large and small objects into different
 | 
						|
sections.  This is ignored for other object file formats.
 | 
						|
 | 
						|
     <p><a name="index-runtime-library-name-45"></a><a name="index-_002dh_0040var_007bname_007d-46"></a><a name="index-_002dsoname_003d_0040var_007bname_007d-47"></a><br><dt><code>-h</code><var>name</var><dt><code>-soname=</code><var>name</var><dd>When creating an ELF shared object, set the internal DT_SONAME field to
 | 
						|
the specified name.  When an executable is linked with a shared object
 | 
						|
which has a DT_SONAME field, then when the executable is run the dynamic
 | 
						|
linker will attempt to load the shared object specified by the DT_SONAME
 | 
						|
field rather than the using the file name given to the linker.
 | 
						|
 | 
						|
     <p><a name="index-_002di-48"></a><a name="index-incremental-link-49"></a><br><dt><code>-i</code><dd>Perform an incremental link (same as option <span class="samp">-r</span>).
 | 
						|
 | 
						|
     <p><a name="index-initialization-function-50"></a><a name="index-_002dinit-51"></a><br><dt><code>-init </code><var>name</var><dd>When creating an ELF executable or shared object, call NAME when the
 | 
						|
executable or shared object is loaded, by setting DT_INIT to the address
 | 
						|
of the function.  By default, the linker uses <code>_init</code> as the
 | 
						|
function to call.
 | 
						|
 | 
						|
     <p><a name="index-archive-files_002c-from-cmd-line-52"></a><a name="index-_002dl_0040var_007bnamespec_007d-53"></a><a name="index-_002d_002dlibrary_003d_0040var_007bnamespec_007d-54"></a><br><dt><code>-l</code><var>namespec</var><dt><code>--library=</code><var>namespec</var><dd>Add the archive or object file specified by <var>namespec</var> to the
 | 
						|
list of files to link.  This option may be used any number of times. 
 | 
						|
If <var>namespec</var> is of the form <span class="file">:</span><var>filename</var>, <span class="command">ld</span>
 | 
						|
will search the library path for a file called <var>filename</var>, otherise it
 | 
						|
will search the library path for a file called <span class="file">lib</span><var>namespec</var><span class="file">.a</span>.
 | 
						|
 | 
						|
     <p>On systems which support shared libraries, <span class="command">ld</span> may also search for
 | 
						|
files other than <span class="file">lib</span><var>namespec</var><span class="file">.a</span>.  Specifically, on ELF
 | 
						|
and SunOS systems, <span class="command">ld</span> will search a directory for a library
 | 
						|
called <span class="file">lib</span><var>namespec</var><span class="file">.so</span> before searching for one called
 | 
						|
<span class="file">lib</span><var>namespec</var><span class="file">.a</span>.  (By convention, a <code>.so</code> extension
 | 
						|
indicates a shared library.)  Note that this behavior does not apply
 | 
						|
to <span class="file">:</span><var>filename</var>, which always specifies a file called
 | 
						|
<var>filename</var>.
 | 
						|
 | 
						|
     <p>The linker will search an archive only once, at the location where it is
 | 
						|
specified on the command line.  If the archive defines a symbol which
 | 
						|
was undefined in some object which appeared before the archive on the
 | 
						|
command line, the linker will include the appropriate file(s) from the
 | 
						|
archive.  However, an undefined symbol in an object appearing later on
 | 
						|
the command line will not cause the linker to search the archive again.
 | 
						|
 | 
						|
     <p>See the <span class="option">-(</span> option for a way to force the linker to search
 | 
						|
archives multiple times.
 | 
						|
 | 
						|
     <p>You may list the same archive multiple times on the command line.
 | 
						|
 | 
						|
     <p>This type of archive searching is standard for Unix linkers.  However,
 | 
						|
if you are using <span class="command">ld</span> on AIX, note that it is different from the
 | 
						|
behaviour of the AIX linker.
 | 
						|
 | 
						|
     <p><a name="index-search-directory_002c-from-cmd-line-55"></a><a name="index-_002dL_0040var_007bdir_007d-56"></a><a name="index-_002d_002dlibrary_002dpath_003d_0040var_007bdir_007d-57"></a><br><dt><code>-L</code><var>searchdir</var><dt><code>--library-path=</code><var>searchdir</var><dd>Add path <var>searchdir</var> to the list of paths that <span class="command">ld</span> will search
 | 
						|
for archive libraries and <span class="command">ld</span> control scripts.  You may use this
 | 
						|
option any number of times.  The directories are searched in the order
 | 
						|
in which they are specified on the command line.  Directories specified
 | 
						|
on the command line are searched before the default directories.  All
 | 
						|
<span class="option">-L</span> options apply to all <span class="option">-l</span> options, regardless of the
 | 
						|
order in which the options appear.
 | 
						|
 | 
						|
     <p>If <var>searchdir</var> begins with <code>=</code>, then the <code>=</code> will be replaced
 | 
						|
by the <dfn>sysroot prefix</dfn>, a path specified when the linker is configured.
 | 
						|
 | 
						|
     <p>The default set of paths searched (without being specified with
 | 
						|
<span class="samp">-L</span>) depends on which emulation mode <span class="command">ld</span> is using, and in
 | 
						|
some cases also on how it was configured.  See <a href="Environment.html#Environment">Environment</a>.
 | 
						|
 | 
						|
     <p>The paths can also be specified in a link script with the
 | 
						|
<code>SEARCH_DIR</code> command.  Directories specified this way are searched
 | 
						|
at the point in which the linker script appears in the command line.
 | 
						|
 | 
						|
     <p><a name="index-emulation-58"></a><a name="index-_002dm-_0040var_007bemulation_007d-59"></a><br><dt><code>-m</code><var>emulation</var><dd>Emulate the <var>emulation</var> linker.  You can list the available
 | 
						|
emulations with the <span class="samp">--verbose</span> or <span class="samp">-V</span> options.
 | 
						|
 | 
						|
     <p>If the <span class="samp">-m</span> option is not used, the emulation is taken from the
 | 
						|
<code>LDEMULATION</code> environment variable, if that is defined.
 | 
						|
 | 
						|
     <p>Otherwise, the default emulation depends upon how the linker was
 | 
						|
configured.
 | 
						|
 | 
						|
     <p><a name="index-link-map-60"></a><a name="index-_002dM-61"></a><a name="index-_002d_002dprint_002dmap-62"></a><br><dt><code>-M</code><dt><code>--print-map</code><dd>Print a link map to the standard output.  A link map provides
 | 
						|
information about the link, including the following:
 | 
						|
 | 
						|
          <ul>
 | 
						|
<li>Where object files are mapped into memory. 
 | 
						|
<li>How common symbols are allocated. 
 | 
						|
<li>All archive members included in the link, with a mention of the symbol
 | 
						|
which caused the archive member to be brought in. 
 | 
						|
<li>The values assigned to symbols.
 | 
						|
 | 
						|
          <p>Note - symbols whose values are computed by an expression which
 | 
						|
involves a reference to a previous value of the same symbol may not
 | 
						|
have correct result displayed in the link map.  This is because the
 | 
						|
linker discards intermediate results and only retains the final value
 | 
						|
of an expression.  Under such circumstances the linker will display
 | 
						|
the final value enclosed by square brackets.  Thus for example a
 | 
						|
linker script containing:
 | 
						|
 | 
						|
          <pre class="smallexample">                  foo = 1
 | 
						|
                  foo = foo * 4
 | 
						|
                  foo = foo + 8
 | 
						|
          </pre>
 | 
						|
          <p>will produce the following output in the link map if the <span class="option">-M</span>
 | 
						|
option is used:
 | 
						|
 | 
						|
          <pre class="smallexample">                  0x00000001                foo = 0x1
 | 
						|
                  [0x0000000c]                foo = (foo * 0x4)
 | 
						|
                  [0x0000000c]                foo = (foo + 0x8)
 | 
						|
          </pre>
 | 
						|
          <p>See <a href="Expressions.html#Expressions">Expressions</a> for more information about expressions in linker
 | 
						|
scripts. 
 | 
						|
</ul>
 | 
						|
 | 
						|
     <p><a name="index-_002dn-63"></a><a name="index-read_002donly-text-64"></a><a name="index-NMAGIC-65"></a><a name="index-_002d_002dnmagic-66"></a><br><dt><code>-n</code><dt><code>--nmagic</code><dd>Turn off page alignment of sections, and mark the output as
 | 
						|
<code>NMAGIC</code> if possible.
 | 
						|
 | 
						|
     <p><a name="index-_002dN-67"></a><a name="index-_002d_002domagic-68"></a><a name="index-read_002fwrite-from-cmd-line-69"></a><a name="index-OMAGIC-70"></a><br><dt><code>-N</code><dt><code>--omagic</code><dd>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</code>. Note: Although a writable text section
 | 
						|
is allowed for PE-COFF targets, it does not conform to the format
 | 
						|
specification published by Microsoft.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dno_002domagic-71"></a><a name="index-OMAGIC-72"></a><br><dt><code>--no-omagic</code><dd>This option negates most of the effects of the <span class="option">-N</span> option.  It
 | 
						|
sets the text section to be read-only, and forces the data segment to
 | 
						|
be page-aligned.  Note - this option does not enable linking against
 | 
						|
shared libraries.  Use <span class="option">-Bdynamic</span> for this.
 | 
						|
 | 
						|
     <p><a name="index-_002do-_0040var_007boutput_007d-73"></a><a name="index-_002d_002doutput_003d_0040var_007boutput_007d-74"></a><a name="index-naming-the-output-file-75"></a><br><dt><code>-o </code><var>output</var><dt><code>--output=</code><var>output</var><dd>Use <var>output</var> as the name for the program produced by <span class="command">ld</span>; if this
 | 
						|
option is not specified, the name <span class="file">a.out</span> is used by default.  The
 | 
						|
script command <code>OUTPUT</code> can also specify the output file name.
 | 
						|
 | 
						|
     <p><a name="index-_002dO-_0040var_007blevel_007d-76"></a><a name="index-generating-optimized-output-77"></a><br><dt><code>-O </code><var>level</var><dd>If <var>level</var> is a numeric values greater than zero <span class="command">ld</span> optimizes
 | 
						|
the output.  This might take significantly longer and therefore probably
 | 
						|
should only be enabled for the final binary.  At the moment this
 | 
						|
option only affects ELF shared library generation.  Future releases of
 | 
						|
the linker may make more use of this option.  Also currently there is
 | 
						|
no difference in the linker's behaviour for different non-zero values
 | 
						|
of this option.  Again this may change with future releases.
 | 
						|
 | 
						|
     <p><a name="index-_002dq-78"></a><a name="index-_002d_002demit_002drelocs-79"></a><a name="index-retain-relocations-in-final-executable-80"></a><br><dt><code>-q</code><dt><code>--emit-relocs</code><dd>Leave relocation sections and contents in fully linked executables. 
 | 
						|
Post link analysis and optimization tools may need this information in
 | 
						|
order to perform correct modifications of executables.  This results
 | 
						|
in larger executables.
 | 
						|
 | 
						|
     <p>This option is currently only supported on ELF platforms.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dforce_002ddynamic-81"></a><a name="index-forcing-the-creation-of-dynamic-sections-82"></a><br><dt><code>--force-dynamic</code><dd>Force the output file to have dynamic sections.  This option is specific
 | 
						|
to VxWorks targets.
 | 
						|
 | 
						|
     <p><a name="index-partial-link-83"></a><a name="index-relocatable-output-84"></a><a name="index-_002dr-85"></a><a name="index-_002d_002drelocatable-86"></a><br><dt><code>-r</code><dt><code>--relocatable</code><dd>Generate relocatable output—i.e., generate an output file that can in
 | 
						|
turn serve as input to <span class="command">ld</span>.  This is often called <dfn>partial
 | 
						|
linking</dfn>.  As a side effect, in environments that support standard Unix
 | 
						|
magic numbers, this option also sets the output file's magic number to
 | 
						|
<code>OMAGIC</code>. 
 | 
						|
<!-- ; see @option{-N}. -->
 | 
						|
If this option is not specified, an absolute file is produced.  When
 | 
						|
linking C++ programs, this option <em>will not</em> resolve references to
 | 
						|
constructors; to do that, use <span class="samp">-Ur</span>.
 | 
						|
 | 
						|
     <p>When an input file does not have the same format as the output file,
 | 
						|
partial linking is only supported if that input file does not contain any
 | 
						|
relocations.  Different output formats can have further restrictions; for
 | 
						|
example some <code>a.out</code>-based formats do not support partial linking
 | 
						|
with input files in other formats at all.
 | 
						|
 | 
						|
     <p>This option does the same thing as <span class="samp">-i</span>.
 | 
						|
 | 
						|
     <p><a name="index-_002dR-_0040var_007bfile_007d-87"></a><a name="index-_002d_002djust_002dsymbols_003d_0040var_007bfile_007d-88"></a><a name="index-symbol_002donly-input-89"></a><br><dt><code>-R </code><var>filename</var><dt><code>--just-symbols=</code><var>filename</var><dd>Read symbol names and their addresses from <var>filename</var>, 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.  You may use this option more than once.
 | 
						|
 | 
						|
     <p>For compatibility with other ELF linkers, if the <span class="option">-R</span> option is
 | 
						|
followed by a directory name, rather than a file name, it is treated as
 | 
						|
the <span class="option">-rpath</span> option.
 | 
						|
 | 
						|
     <p><a name="index-_002ds-90"></a><a name="index-_002d_002dstrip_002dall-91"></a><a name="index-strip-all-symbols-92"></a><br><dt><code>-s</code><dt><code>--strip-all</code><dd>Omit all symbol information from the output file.
 | 
						|
 | 
						|
     <p><a name="index-_002dS-93"></a><a name="index-_002d_002dstrip_002ddebug-94"></a><a name="index-strip-debugger-symbols-95"></a><br><dt><code>-S</code><dt><code>--strip-debug</code><dd>Omit debugger symbol information (but not all symbols) from the output file.
 | 
						|
 | 
						|
     <p><a name="index-_002dt-96"></a><a name="index-_002d_002dtrace-97"></a><a name="index-input-files_002c-displaying-98"></a><br><dt><code>-t</code><dt><code>--trace</code><dd>Print the names of the input files as <span class="command">ld</span> processes them.
 | 
						|
 | 
						|
     <p><a name="index-_002dT-_0040var_007bscript_007d-99"></a><a name="index-_002d_002dscript_003d_0040var_007bscript_007d-100"></a><a name="index-script-files-101"></a><br><dt><code>-T </code><var>scriptfile</var><dt><code>--script=</code><var>scriptfile</var><dd>Use <var>scriptfile</var> as the linker script.  This script replaces
 | 
						|
<span class="command">ld</span>'s default linker script (rather than adding to it), so
 | 
						|
<var>commandfile</var> must specify everything necessary to describe the
 | 
						|
output file.  See <a href="Scripts.html#Scripts">Scripts</a>.  If <var>scriptfile</var> does not exist in
 | 
						|
the current directory, <code>ld</code> looks for it in the directories
 | 
						|
specified by any preceding <span class="samp">-L</span> options.  Multiple <span class="samp">-T</span>
 | 
						|
options accumulate.
 | 
						|
 | 
						|
     <p><a name="index-_002ddT-_0040var_007bscript_007d-102"></a><a name="index-_002d_002ddefault_002dscript_003d_0040var_007bscript_007d-103"></a><a name="index-script-files-104"></a><br><dt><code>-dT </code><var>scriptfile</var><dt><code>--default-script=</code><var>scriptfile</var><dd>Use <var>scriptfile</var> as the default linker script.  See <a href="Scripts.html#Scripts">Scripts</a>.
 | 
						|
 | 
						|
     <p>This option is similar to the <span class="option">--script</span> option except that
 | 
						|
processing of the script is delayed until after the rest of the
 | 
						|
command line has been processed.  This allows options placed after the
 | 
						|
<span class="option">--default-script</span> option on the command line to affect the
 | 
						|
behaviour of the linker script, which can be important when the linker
 | 
						|
command line cannot be directly controlled by the user.  (eg because
 | 
						|
the command line is being constructed by another tool, such as
 | 
						|
<span class="samp">gcc</span>).
 | 
						|
 | 
						|
     <p><a name="index-_002du-_0040var_007bsymbol_007d-105"></a><a name="index-_002d_002dundefined_003d_0040var_007bsymbol_007d-106"></a><a name="index-undefined-symbol-107"></a><br><dt><code>-u </code><var>symbol</var><dt><code>--undefined=</code><var>symbol</var><dd>Force <var>symbol</var> to be entered in the output file as an undefined
 | 
						|
symbol.  Doing this may, for example, trigger linking of additional
 | 
						|
modules from standard libraries.  <span class="samp">-u</span> may be repeated with
 | 
						|
different option arguments to enter additional undefined symbols.  This
 | 
						|
option is equivalent to the <code>EXTERN</code> linker script command.
 | 
						|
 | 
						|
     <p><a name="index-_002dUr-108"></a><a name="index-constructors-109"></a><br><dt><code>-Ur</code><dd>For anything other than C++ programs, this option is equivalent to
 | 
						|
<span class="samp">-r</span>: it generates relocatable output—i.e., an output file that can in
 | 
						|
turn serve as input to <span class="command">ld</span>.  When linking C++ programs, <span class="samp">-Ur</span>
 | 
						|
<em>does</em> resolve references to constructors, unlike <span class="samp">-r</span>. 
 | 
						|
It does not work to use <span class="samp">-Ur</span> on files that were themselves linked
 | 
						|
with <span class="samp">-Ur</span>; once the constructor table has been built, it cannot
 | 
						|
be added to.  Use <span class="samp">-Ur</span> only for the last partial link, and
 | 
						|
<span class="samp">-r</span> for the others.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dunique_005b_003d_0040var_007bSECTION_007d_005d-110"></a><br><dt><code>--unique[=</code><var>SECTION</var><code>]</code><dd>Creates a separate output section for every input section matching
 | 
						|
<var>SECTION</var>, or if the optional wildcard <var>SECTION</var> argument is
 | 
						|
missing, for every orphan input section.  An orphan section is one not
 | 
						|
specifically mentioned in a linker script.  You may use this option
 | 
						|
multiple times on the command line;  It prevents the normal merging of
 | 
						|
input sections with the same name, overriding output section assignments
 | 
						|
in a linker script.
 | 
						|
 | 
						|
     <p><a name="index-_002dv-111"></a><a name="index-_002dV-112"></a><a name="index-_002d_002dversion-113"></a><a name="index-version-114"></a><br><dt><code>-v</code><dt><code>--version</code><dt><code>-V</code><dd>Display the version number for <span class="command">ld</span>.  The <span class="option">-V</span> option also
 | 
						|
lists the supported emulations.
 | 
						|
 | 
						|
     <p><a name="index-_002dx-115"></a><a name="index-_002d_002ddiscard_002dall-116"></a><a name="index-deleting-local-symbols-117"></a><br><dt><code>-x</code><dt><code>--discard-all</code><dd>Delete all local symbols.
 | 
						|
 | 
						|
     <p><a name="index-_002dX-118"></a><a name="index-_002d_002ddiscard_002dlocals-119"></a><a name="index-local-symbols_002c-deleting-120"></a><br><dt><code>-X</code><dt><code>--discard-locals</code><dd>Delete all temporary local symbols.  (These symbols start with
 | 
						|
system-specific local label prefixes, typically <span class="samp">.L</span> for ELF systems
 | 
						|
or <span class="samp">L</span> for traditional a.out systems.)
 | 
						|
 | 
						|
     <p><a name="index-_002dy-_0040var_007bsymbol_007d-121"></a><a name="index-_002d_002dtrace_002dsymbol_003d_0040var_007bsymbol_007d-122"></a><a name="index-symbol-tracing-123"></a><br><dt><code>-y </code><var>symbol</var><dt><code>--trace-symbol=</code><var>symbol</var><dd>Print the name of each linked file in which <var>symbol</var> appears.  This
 | 
						|
option may be given any number of times.  On many systems it is necessary
 | 
						|
to prepend an underscore.
 | 
						|
 | 
						|
     <p>This option is useful when you have an undefined symbol in your link but
 | 
						|
don't know where the reference is coming from.
 | 
						|
 | 
						|
     <p><a name="index-_002dY-_0040var_007bpath_007d-124"></a><br><dt><code>-Y </code><var>path</var><dd>Add <var>path</var> to the default library search path.  This option exists
 | 
						|
for Solaris compatibility.
 | 
						|
 | 
						|
     <p><a name="index-_002dz-_0040var_007bkeyword_007d-125"></a><br><dt><code>-z </code><var>keyword</var><dd>The recognized keywords are:
 | 
						|
          <dl>
 | 
						|
<dt><span class="samp">combreloc</span><dd>Combines multiple reloc sections and sorts them to make dynamic symbol
 | 
						|
lookup caching possible.
 | 
						|
 | 
						|
          <br><dt><span class="samp">defs</span><dd>Disallows undefined symbols in object files.  Undefined symbols in
 | 
						|
shared libraries are still allowed.
 | 
						|
 | 
						|
          <br><dt><span class="samp">execstack</span><dd>Marks the object as requiring executable stack.
 | 
						|
 | 
						|
          <br><dt><span class="samp">initfirst</span><dd>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.
 | 
						|
 | 
						|
          <br><dt><span class="samp">interpose</span><dd>Marks the object that its symbol table interposes before all symbols
 | 
						|
but the primary executable.
 | 
						|
 | 
						|
          <br><dt><span class="samp">lazy</span><dd>When generating an executable or shared library, mark it to tell the
 | 
						|
dynamic linker to defer function call resolution to the point when
 | 
						|
the function is called (lazy binding), rather than at load time. 
 | 
						|
Lazy binding is the default.
 | 
						|
 | 
						|
          <br><dt><span class="samp">loadfltr</span><dd>Marks  the object that its filters be processed immediately at
 | 
						|
runtime.
 | 
						|
 | 
						|
          <br><dt><span class="samp">muldefs</span><dd>Allows multiple definitions.
 | 
						|
 | 
						|
          <br><dt><span class="samp">nocombreloc</span><dd>Disables multiple reloc sections combining.
 | 
						|
 | 
						|
          <br><dt><span class="samp">nocopyreloc</span><dd>Disables production of copy relocs.
 | 
						|
 | 
						|
          <br><dt><span class="samp">nodefaultlib</span><dd>Marks the object that the search for dependencies of this object will
 | 
						|
ignore any default library search paths.
 | 
						|
 | 
						|
          <br><dt><span class="samp">nodelete</span><dd>Marks the object shouldn't be unloaded at runtime.
 | 
						|
 | 
						|
          <br><dt><span class="samp">nodlopen</span><dd>Marks the object not available to <code>dlopen</code>.
 | 
						|
 | 
						|
          <br><dt><span class="samp">nodump</span><dd>Marks the object can not be dumped by <code>dldump</code>.
 | 
						|
 | 
						|
          <br><dt><span class="samp">noexecstack</span><dd>Marks the object as not requiring executable stack.
 | 
						|
 | 
						|
          <br><dt><span class="samp">norelro</span><dd>Don't create an ELF <code>PT_GNU_RELRO</code> segment header in the object.
 | 
						|
 | 
						|
          <br><dt><span class="samp">now</span><dd>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.
 | 
						|
 | 
						|
          <br><dt><span class="samp">origin</span><dd>Marks the object may contain $ORIGIN.
 | 
						|
 | 
						|
          <br><dt><span class="samp">relro</span><dd>Create an ELF <code>PT_GNU_RELRO</code> segment header in the object.
 | 
						|
 | 
						|
          <br><dt><span class="samp">max-page-size=</span><var>value</var><dd>Set the emulation maximum page size to <var>value</var>.
 | 
						|
 | 
						|
          <br><dt><span class="samp">common-page-size=</span><var>value</var><dd>Set the emulation common page size to <var>value</var>.
 | 
						|
 | 
						|
     </dl>
 | 
						|
 | 
						|
     <p>Other keywords are ignored for Solaris compatibility.
 | 
						|
 | 
						|
     <p><a name="index-_002d_0028-126"></a><a name="index-groups-of-archives-127"></a><br><dt><code>-( </code><var>archives</var><code> -)</code><dt><code>--start-group </code><var>archives</var><code> --end-group</code><dd>The <var>archives</var> should be a list of archive files.  They may be
 | 
						|
either explicit file names, or <span class="samp">-l</span> options.
 | 
						|
 | 
						|
     <p>The specified archives are searched repeatedly until no new undefined
 | 
						|
references are created.  Normally, an archive is searched only once in
 | 
						|
the order that it is specified on the command line.  If a symbol in that
 | 
						|
archive is needed to resolve an undefined symbol referred to by an
 | 
						|
object in an archive that appears later on the command line, the linker
 | 
						|
would not be able to resolve that reference.  By grouping the archives,
 | 
						|
they all be searched repeatedly until all possible references are
 | 
						|
resolved.
 | 
						|
 | 
						|
     <p>Using this option has a significant performance cost.  It is best to use
 | 
						|
it only when there are unavoidable circular references between two or
 | 
						|
more archives.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002daccept_002dunknown_002dinput_002darch-128"></a><a name="index-_002d_002dno_002daccept_002dunknown_002dinput_002darch-129"></a><br><dt><code>--accept-unknown-input-arch</code><dt><code>--no-accept-unknown-input-arch</code><dd>Tells the linker to accept input files whose architecture cannot be
 | 
						|
recognised.  The assumption is that the user knows what they are doing
 | 
						|
and deliberately wants to link in these unknown input files.  This was
 | 
						|
the default behaviour of the linker, before release 2.14.  The default
 | 
						|
behaviour from release 2.14 onwards is to reject such input files, and
 | 
						|
so the <span class="samp">--accept-unknown-input-arch</span> option has been added to
 | 
						|
restore the old behaviour.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002das_002dneeded-130"></a><a name="index-_002d_002dno_002das_002dneeded-131"></a><br><dt><code>--as-needed</code><dt><code>--no-as-needed</code><dd>This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
 | 
						|
on the command line after the <span class="option">--as-needed</span> 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.  <span class="option">--as-needed</span> causes DT_NEEDED tags to only be emitted
 | 
						|
for libraries that satisfy some symbol reference from regular objects
 | 
						|
which is undefined at the point that the library was linked. 
 | 
						|
<span class="option">--no-as-needed</span> restores the default behaviour.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dadd_002dneeded-132"></a><a name="index-_002d_002dno_002dadd_002dneeded-133"></a><br><dt><code>--add-needed</code><dt><code>--no-add-needed</code><dd>This option affects the treatment of dynamic libraries from ELF
 | 
						|
DT_NEEDED tags in dynamic libraries mentioned on the command line after
 | 
						|
the <span class="option">--no-add-needed</span> option.  Normally, the linker will add
 | 
						|
a DT_NEEDED tag for each dynamic library from DT_NEEDED tags. 
 | 
						|
<span class="option">--no-add-needed</span> causes DT_NEEDED tags will never be emitted
 | 
						|
for those libraries from DT_NEEDED tags. <span class="option">--add-needed</span> restores
 | 
						|
the default behaviour.
 | 
						|
 | 
						|
     <p><a name="index-_002dassert-_0040var_007bkeyword_007d-134"></a><br><dt><code>-assert </code><var>keyword</var><dd>This option is ignored for SunOS compatibility.
 | 
						|
 | 
						|
     <p><a name="index-_002dBdynamic-135"></a><a name="index-_002ddy-136"></a><a name="index-_002dcall_005fshared-137"></a><br><dt><code>-Bdynamic</code><dt><code>-dy</code><dt><code>-call_shared</code><dd>Link against dynamic libraries.  This is only meaningful on platforms
 | 
						|
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
 | 
						|
<span class="option">-l</span> options which follow it.
 | 
						|
 | 
						|
     <p><a name="index-_002dBgroup-138"></a><br><dt><code>-Bgroup</code><dd>Set the <code>DF_1_GROUP</code> flag in the <code>DT_FLAGS_1</code> 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. 
 | 
						|
<span class="option">--unresolved-symbols=report-all</span> is implied.  This option is
 | 
						|
only meaningful on ELF platforms which support shared libraries.
 | 
						|
 | 
						|
     <p><a name="index-_002dBstatic-139"></a><a name="index-_002ddn-140"></a><a name="index-_002dnon_005fshared-141"></a><a name="index-_002dstatic-142"></a><br><dt><code>-Bstatic</code><dt><code>-dn</code><dt><code>-non_shared</code><dt><code>-static</code><dd>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 <span class="option">-l</span> options which follow it.  This
 | 
						|
option also implies <span class="option">--unresolved-symbols=report-all</span>.  This
 | 
						|
option can be used with <span class="option">-shared</span>.  Doing so means that a
 | 
						|
shared library is being created but that all of the library's external
 | 
						|
references must be resolved by pulling in entries from static
 | 
						|
libraries.
 | 
						|
 | 
						|
     <p><a name="index-_002dBsymbolic-143"></a><br><dt><code>-Bsymbolic</code><dd>When creating a shared library, bind references to global symbols to the
 | 
						|
definition within the shared library, if any.  Normally, it is possible
 | 
						|
for a program linked against a shared library to override the definition
 | 
						|
within the shared library.  This option is only meaningful on ELF
 | 
						|
platforms which support shared libraries.
 | 
						|
 | 
						|
     <p><a name="index-_002dBsymbolic_002dfunctions-144"></a><br><dt><code>-Bsymbolic-functions</code><dd>When creating a shared library, bind references to global function
 | 
						|
symbols to the definition within the shared library, if any. 
 | 
						|
This option is only meaningful on ELF platforms which support shared
 | 
						|
libraries.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddynamic_002dlist_003d_0040var_007bdynamic_002dlist_002dfile_007d-145"></a><br><dt><code>--dynamic-list=</code><var>dynamic-list-file</var><dd>Specify the name of a dynamic list file to the linker.  This is
 | 
						|
typically used when creating shared libraries to specify a list of
 | 
						|
global symbols whose references shouldn't be bound to the definition
 | 
						|
within the shared library, or creating dynamically linked executables
 | 
						|
to specify a list of symbols which should be added to the symbol table
 | 
						|
in the executable.  This option is only meaningful on ELF platforms
 | 
						|
which support shared libraries.
 | 
						|
 | 
						|
     <p>The format of the dynamic list is the same as the version node without
 | 
						|
scope and node name.  See <a href="VERSION.html#VERSION">VERSION</a> for more information.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddynamic_002dlist_002ddata-146"></a><br><dt><code>--dynamic-list-data</code><dd>Include all global data symbols to the dynamic list.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddynamic_002dlist_002dcpp_002dnew-147"></a><br><dt><code>--dynamic-list-cpp-new</code><dd>Provide the builtin dynamic list for C++ operator new and delete.  It
 | 
						|
is mainly useful for building shared libstdc++.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddynamic_002dlist_002dcpp_002dtypeinfo-148"></a><br><dt><code>--dynamic-list-cpp-typeinfo</code><dd>Provide the builtin dynamic list for C++ runtime type identification.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dcheck_002dsections-149"></a><a name="index-_002d_002dno_002dcheck_002dsections-150"></a><br><dt><code>--check-sections</code><dt><code>--no-check-sections</code><dd>Asks the linker <em>not</em> to check section addresses after they have
 | 
						|
been assigned to see if there are 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 <span class="option">--check-sections</span>.
 | 
						|
 | 
						|
     <p><a name="index-cross-reference-table-151"></a><a name="index-_002d_002dcref-152"></a><br><dt><code>--cref</code><dd>Output a cross reference table.  If a linker map file is being
 | 
						|
generated, the cross reference table is printed to the map file. 
 | 
						|
Otherwise, it is printed on the standard output.
 | 
						|
 | 
						|
     <p>The format of the table is intentionally simple, so that it may be
 | 
						|
easily processed by a script if necessary.  The symbols are printed out,
 | 
						|
sorted by name.  For each symbol, a list of file names is given.  If the
 | 
						|
symbol is defined, the first file listed is the location of the
 | 
						|
definition.  The remaining files contain references to the symbol.
 | 
						|
 | 
						|
     <p><a name="index-common-allocation-153"></a><a name="index-_002d_002dno_002ddefine_002dcommon-154"></a><br><dt><code>--no-define-common</code><dd>This option inhibits the assignment of addresses to common symbols. 
 | 
						|
The script command <code>INHIBIT_COMMON_ALLOCATION</code> has the same effect. 
 | 
						|
See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>.
 | 
						|
 | 
						|
     <p>The <span class="samp">--no-define-common</span> option allows decoupling
 | 
						|
the decision to assign addresses to Common symbols from the choice
 | 
						|
of the output file type; otherwise a non-Relocatable output type
 | 
						|
forces assigning addresses to Common symbols. 
 | 
						|
Using <span class="samp">--no-define-common</span> allows Common symbols that are referenced
 | 
						|
from a shared library to be assigned addresses only in the main program. 
 | 
						|
This eliminates the unused duplicate space in the shared library,
 | 
						|
and also prevents any possible confusion over resolving to the wrong
 | 
						|
duplicate when there are many dynamic modules with specialized search
 | 
						|
paths for runtime symbol resolution.
 | 
						|
 | 
						|
     <p><a name="index-symbols_002c-from-command-line-155"></a><a name="index-_002d_002ddefsym-_0040var_007bsymbol_007d_003d_0040var_007bexp_007d-156"></a><br><dt><code>--defsym </code><var>symbol</var><code>=</code><var>expression</var><dd>Create a global symbol in the output file, containing the absolute
 | 
						|
address given by <var>expression</var>.  You may use this option as many
 | 
						|
times as necessary to define multiple symbols in the command line.  A
 | 
						|
limited form of arithmetic is supported for the <var>expression</var> in this
 | 
						|
context: you may give a hexadecimal constant or the name of an existing
 | 
						|
symbol, or use <code>+</code> and <code>-</code> to add or subtract hexadecimal
 | 
						|
constants or symbols.  If you need more elaborate expressions, consider
 | 
						|
using the linker command language from a script (see <a href="Assignments.html#Assignments">Assignment: Symbol Definitions</a>).  <em>Note:</em> there should be no white
 | 
						|
space between <var>symbol</var>, the equals sign (“<=>”), and
 | 
						|
<var>expression</var>.
 | 
						|
 | 
						|
     <p><a name="index-demangling_002c-from-command-line-157"></a><a name="index-_002d_002ddemangle_005b_003d_0040var_007bstyle_007d_005d-158"></a><a name="index-_002d_002dno_002ddemangle-159"></a><br><dt><code>--demangle[=</code><var>style</var><code>]</code><dt><code>--no-demangle</code><dd>These options control whether to demangle symbol names in error messages
 | 
						|
and other output.  When the linker is told to demangle, it tries to
 | 
						|
present symbol names in a readable fashion: it strips leading
 | 
						|
underscores if they are used by the object file format, and converts C++
 | 
						|
mangled symbol names into user readable names.  Different compilers have
 | 
						|
different mangling styles.  The optional demangling style argument can be used
 | 
						|
to choose an appropriate demangling style for your compiler.  The linker will
 | 
						|
demangle by default unless the environment variable <span class="samp">COLLECT_NO_DEMANGLE</span>
 | 
						|
is set.  These options may be used to override the default.
 | 
						|
 | 
						|
     <p><a name="index-dynamic-linker_002c-from-command-line-160"></a><a name="index-_002dI_0040var_007bfile_007d-161"></a><a name="index-_002d_002ddynamic_002dlinker-_0040var_007bfile_007d-162"></a><br><dt><code>--dynamic-linker </code><var>file</var><dd>Set the name of the dynamic linker.  This is only meaningful when
 | 
						|
generating dynamically linked ELF executables.  The default dynamic
 | 
						|
linker is normally correct; don't use this unless you know what you are
 | 
						|
doing.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dfatal_002dwarnings-163"></a><a name="index-_002d_002dno_002dfatal_002dwarnings-164"></a><br><dt><code>--fatal-warnings</code><dt><code>--no-fatal-warnings</code><dd>Treat all warnings as errors.  The default behaviour can be restored
 | 
						|
with the option <span class="option">--no-fatal-warnings</span>.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dforce_002dexe_002dsuffix-165"></a><br><dt><code>--force-exe-suffix</code><dd>Make sure that an output file has a .exe suffix.
 | 
						|
 | 
						|
     <p>If a successfully built fully linked output file does not have a
 | 
						|
<code>.exe</code> or <code>.dll</code> suffix, this option forces the linker to copy
 | 
						|
the output file to one of the same name with a <code>.exe</code> suffix. This
 | 
						|
option is useful when using unmodified Unix makefiles on a Microsoft
 | 
						|
Windows host, since some versions of Windows won't run an image unless
 | 
						|
it ends in a <code>.exe</code> suffix.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dgc_002dsections-166"></a><a name="index-_002d_002dno_002dgc_002dsections-167"></a><a name="index-garbage-collection-168"></a><br><dt><code>--gc-sections</code><dt><code>--no-gc-sections</code><dd>Enable garbage collection of unused input sections.  It is ignored on
 | 
						|
targets that do not support this option.  The default behaviour (of not
 | 
						|
performing this garbage collection) can be restored by specifying
 | 
						|
<span class="samp">--no-gc-sections</span> on the command line.
 | 
						|
 | 
						|
     <p><span class="samp">--gc-sections</span> decides which input sections are used by
 | 
						|
examining symbols and relocations.  The section containing the entry
 | 
						|
symbol and all sections containing symbols undefined on the
 | 
						|
command-line will be kept, as will sections containing symbols
 | 
						|
referenced by dynamic objects.  Note that when building shared
 | 
						|
libraries, the linker must assume that any visible symbol is
 | 
						|
referenced.  Once this initial set of sections has been determined,
 | 
						|
the linker recursively marks as used any section referenced by their
 | 
						|
relocations.  See <span class="samp">--entry</span> and <span class="samp">--undefined</span>.
 | 
						|
 | 
						|
     <p>This option can be set when doing a partial link (enabled with option
 | 
						|
<span class="samp">-r</span>).  In this case the root of symbols kept must be explicitely
 | 
						|
specified either by an <span class="samp">--entry</span> or <span class="samp">--undefined</span> option or by
 | 
						|
a <code>ENTRY</code> command in the linker script.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dprint_002dgc_002dsections-169"></a><a name="index-_002d_002dno_002dprint_002dgc_002dsections-170"></a><a name="index-garbage-collection-171"></a><br><dt><code>--print-gc-sections</code><dt><code>--no-print-gc-sections</code><dd>List all sections removed by garbage collection.  The listing is
 | 
						|
printed on stderr.  This option is only effective if garbage
 | 
						|
collection has been enabled via the <span class="samp">--gc-sections</span>) option.  The
 | 
						|
default behaviour (of not listing the sections that are removed) can
 | 
						|
be restored by specifying <span class="samp">--no-print-gc-sections</span> on the command
 | 
						|
line.
 | 
						|
 | 
						|
     <p><a name="index-help-172"></a><a name="index-usage-173"></a><a name="index-_002d_002dhelp-174"></a><br><dt><code>--help</code><dd>Print a summary of the command-line options on the standard output and exit.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dtarget_002dhelp-175"></a><br><dt><code>--target-help</code><dd>Print a summary of all target specific options on the standard output and exit.
 | 
						|
 | 
						|
     <p><a name="index-_002dMap-176"></a><br><dt><code>-Map </code><var>mapfile</var><dd>Print a link map to the file <var>mapfile</var>.  See the description of the
 | 
						|
<span class="option">-M</span> option, above.
 | 
						|
 | 
						|
     <p><a name="index-memory-usage-177"></a><a name="index-_002d_002dno_002dkeep_002dmemory-178"></a><br><dt><code>--no-keep-memory</code><dd><span class="command">ld</span> normally optimizes for speed over memory usage by caching the
 | 
						|
symbol tables of input files in memory.  This option tells <span class="command">ld</span> to
 | 
						|
instead optimize for memory usage, by rereading the symbol tables as
 | 
						|
necessary.  This may be required if <span class="command">ld</span> runs out of memory space
 | 
						|
while linking a large executable.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dno_002dundefined-179"></a><a name="index-_002dz-defs-180"></a><br><dt><code>--no-undefined</code><dt><code>-z defs</code><dd>Report unresolved symbol references from regular object files.  This
 | 
						|
is done even if the linker is creating a non-symbolic shared library. 
 | 
						|
The switch <span class="option">--[no-]allow-shlib-undefined</span> controls the
 | 
						|
behaviour for reporting unresolved references found in shared
 | 
						|
libraries being linked in.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dallow_002dmultiple_002ddefinition-181"></a><a name="index-_002dz-muldefs-182"></a><br><dt><code>--allow-multiple-definition</code><dt><code>-z muldefs</code><dd>Normally when a symbol is defined multiple times, the linker will
 | 
						|
report a fatal error. These options allow multiple definitions and the
 | 
						|
first definition will be used.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dallow_002dshlib_002dundefined-183"></a><a name="index-_002d_002dno_002dallow_002dshlib_002dundefined-184"></a><br><dt><code>--allow-shlib-undefined</code><dt><code>--no-allow-shlib-undefined</code><dd>Allows (the default) or disallows undefined symbols in shared libraries. 
 | 
						|
This switch is similar to <span class="option">--no-undefined</span> 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.
 | 
						|
 | 
						|
     <p>The reason that <span class="option">--allow-shlib-undefined</span> 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.  (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.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dno_002dundefined_002dversion-185"></a><br><dt><code>--no-undefined-version</code><dd>Normally when a symbol has an undefined version, the linker will ignore
 | 
						|
it. This option disallows symbols with undefined version and a fatal error
 | 
						|
will be issued instead.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddefault_002dsymver-186"></a><br><dt><code>--default-symver</code><dd>Create and use a default symbol version (the soname) for unversioned
 | 
						|
exported symbols.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddefault_002dimported_002dsymver-187"></a><br><dt><code>--default-imported-symver</code><dd>Create and use a default symbol version (the soname) for unversioned
 | 
						|
imported symbols.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dno_002dwarn_002dmismatch-188"></a><br><dt><code>--no-warn-mismatch</code><dd>Normally <span class="command">ld</span> will give an error if you try to link together input
 | 
						|
files that are mismatched for some reason, perhaps because they have
 | 
						|
been compiled for different processors or for different endiannesses. 
 | 
						|
This option tells <span class="command">ld</span> that it should silently permit such possible
 | 
						|
errors.  This option should only be used with care, in cases when you
 | 
						|
have taken some special action that ensures that the linker errors are
 | 
						|
inappropriate.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dno_002dwarn_002dsearch_002dmismatch-189"></a><br><dt><code>--no-warn-search-mismatch</code><dd>Normally <span class="command">ld</span> will give a warning if it finds an incompatible
 | 
						|
library during a library search.  This option silences the warning.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dno_002dwhole_002darchive-190"></a><br><dt><code>--no-whole-archive</code><dd>Turn off the effect of the <span class="option">--whole-archive</span> option for subsequent
 | 
						|
archive files.
 | 
						|
 | 
						|
     <p><a name="index-output-file-after-errors-191"></a><a name="index-_002d_002dnoinhibit_002dexec-192"></a><br><dt><code>--noinhibit-exec</code><dd>Retain the executable output file whenever it is still usable. 
 | 
						|
Normally, the linker will not produce an output file if it encounters
 | 
						|
errors during the link process; it exits without writing an output file
 | 
						|
when it issues any error whatsoever.
 | 
						|
 | 
						|
     <p><a name="index-_002dnostdlib-193"></a><br><dt><code>-nostdlib</code><dd>Only search library directories explicitly specified on the
 | 
						|
command line.  Library directories specified in linker scripts
 | 
						|
(including linker scripts specified on the command line) are ignored.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002doformat-194"></a><br><dt><code>--oformat </code><var>output-format</var><dd><span class="command">ld</span> may be configured to support more than one kind of object
 | 
						|
file.  If your <span class="command">ld</span> is configured this way, you can use the
 | 
						|
<span class="samp">--oformat</span> option to specify the binary format for the output
 | 
						|
object file.  Even when <span class="command">ld</span> is configured to support alternative
 | 
						|
object formats, you don't usually need to specify this, as <span class="command">ld</span>
 | 
						|
should be configured to produce as a default output format the most
 | 
						|
usual format on each machine.  <var>output-format</var> is a text string, the
 | 
						|
name of a particular format supported by the BFD libraries.  (You can
 | 
						|
list the available binary formats with <span class="samp">objdump -i</span>.)  The script
 | 
						|
command <code>OUTPUT_FORMAT</code> can also specify the output format, but
 | 
						|
this option overrides it.  See <a href="BFD.html#BFD">BFD</a>.
 | 
						|
 | 
						|
     <p><a name="index-_002dpie-195"></a><a name="index-_002d_002dpic_002dexecutable-196"></a><br><dt><code>-pie</code><dt><code>--pic-executable</code><dd><a name="index-position-independent-executables-197"></a>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 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.
 | 
						|
 | 
						|
     <p><a name="index-_002dqmagic-198"></a><br><dt><code>-qmagic</code><dd>This option is ignored for Linux compatibility.
 | 
						|
 | 
						|
     <p><a name="index-_002dQy-199"></a><br><dt><code>-Qy</code><dd>This option is ignored for SVR4 compatibility.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002drelax-200"></a><a name="index-synthesizing-linker-201"></a><a name="index-relaxing-addressing-modes-202"></a><br><dt><code>--relax</code><dd>An option with machine dependent effects. 
 | 
						|
This option is only supported on a few targets. 
 | 
						|
See <a href="H8_002f300.html#H8_002f300"><span class="command">ld</span> and the H8/300</a>. 
 | 
						|
See <a href="i960.html#i960"><span class="command">ld</span> and the Intel 960 family</a>. 
 | 
						|
See <a href="Xtensa.html#Xtensa"><span class="command">ld</span> and Xtensa Processors</a>. 
 | 
						|
See <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12"><span class="command">ld</span> and the 68HC11 and 68HC12</a>. 
 | 
						|
See <a href="PowerPC-ELF32.html#PowerPC-ELF32"><span class="command">ld</span> and PowerPC 32-bit ELF Support</a>.
 | 
						|
 | 
						|
     <p>On some platforms, the <span class="samp">--relax</span> 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.
 | 
						|
 | 
						|
     <p>On some platforms these link time global optimizations may make symbolic
 | 
						|
debugging of the resulting executable impossible. 
 | 
						|
This is known to be
 | 
						|
the case for the Matsushita MN10200 and MN10300 family of processors.
 | 
						|
 | 
						|
     <p>On platforms where this is not supported, <span class="samp">--relax</span> is accepted,
 | 
						|
but ignored.
 | 
						|
 | 
						|
     <p><a name="index-retaining-specified-symbols-203"></a><a name="index-stripping-all-but-some-symbols-204"></a><a name="index-symbols_002c-retaining-selectively-205"></a><br><dt><code>--retain-symbols-file </code><var>filename</var><dd>Retain <em>only</em> the symbols listed in the file <var>filename</var>,
 | 
						|
discarding all others.  <var>filename</var> is simply a flat file, with one
 | 
						|
symbol name per line.  This option is especially useful in environments
 | 
						|
(such as VxWorks)
 | 
						|
where a large global symbol table is accumulated gradually, to conserve
 | 
						|
run-time memory.
 | 
						|
 | 
						|
     <p><span class="samp">--retain-symbols-file</span> does <em>not</em> discard undefined symbols,
 | 
						|
or symbols needed for relocations.
 | 
						|
 | 
						|
     <p>You may only specify <span class="samp">--retain-symbols-file</span> once in the command
 | 
						|
line.  It overrides <span class="samp">-s</span> and <span class="samp">-S</span>.
 | 
						|
 | 
						|
     <br><dt><code>-rpath </code><var>dir</var><dd><a name="index-runtime-library-search-path-206"></a><a name="index-_002drpath-207"></a>Add a directory to the runtime library search path.  This is used when
 | 
						|
linking an ELF executable with shared objects.  All <span class="option">-rpath</span>
 | 
						|
arguments are concatenated and passed to the runtime linker, which uses
 | 
						|
them to locate shared objects at runtime.  The <span class="option">-rpath</span> option is
 | 
						|
also used when locating shared objects which are needed by shared
 | 
						|
objects explicitly included in the link; see the description of the
 | 
						|
<span class="option">-rpath-link</span> option.  If <span class="option">-rpath</span> is not used when linking an
 | 
						|
ELF executable, the contents of the environment variable
 | 
						|
<code>LD_RUN_PATH</code> will be used if it is defined.
 | 
						|
 | 
						|
     <p>The <span class="option">-rpath</span> option may also be used on SunOS.  By default, on
 | 
						|
SunOS, the linker will form a runtime search patch out of all the
 | 
						|
<span class="option">-L</span> options it is given.  If a <span class="option">-rpath</span> option is used, the
 | 
						|
runtime search path will be formed exclusively using the <span class="option">-rpath</span>
 | 
						|
options, ignoring the <span class="option">-L</span> options.  This can be useful when using
 | 
						|
gcc, which adds many <span class="option">-L</span> options which may be on NFS mounted
 | 
						|
file systems.
 | 
						|
 | 
						|
     <p>For compatibility with other ELF linkers, if the <span class="option">-R</span> option is
 | 
						|
followed by a directory name, rather than a file name, it is treated as
 | 
						|
the <span class="option">-rpath</span> option.
 | 
						|
 | 
						|
     <p><a name="index-link_002dtime-runtime-library-search-path-208"></a><a name="index-_002drpath_002dlink-209"></a><br><dt><code>-rpath-link </code><var>DIR</var><dd>When using ELF or SunOS, one shared library may require another.  This
 | 
						|
happens when an <code>ld -shared</code> link includes a shared library as one
 | 
						|
of the input files.
 | 
						|
 | 
						|
     <p>When the linker encounters such a dependency when doing a non-shared,
 | 
						|
non-relocatable link, it will automatically try to locate the required
 | 
						|
shared library and include it in the link, if it is not included
 | 
						|
explicitly.  In such a case, the <span class="option">-rpath-link</span> option
 | 
						|
specifies the first set of directories to search.  The
 | 
						|
<span class="option">-rpath-link</span> option may specify a sequence of directory names
 | 
						|
either by specifying a list of names separated by colons, or by
 | 
						|
appearing multiple times.
 | 
						|
 | 
						|
     <p>This option should be used with caution as it overrides the search path
 | 
						|
that may have been hard compiled into a shared library. In such a case it
 | 
						|
is possible to use unintentionally a different search path than the
 | 
						|
runtime linker would do.
 | 
						|
 | 
						|
     <p>The linker uses the following search paths to locate required shared
 | 
						|
libraries:
 | 
						|
          <ol type=1 start=1>
 | 
						|
<li>Any directories specified by <span class="option">-rpath-link</span> options. 
 | 
						|
<li>Any directories specified by <span class="option">-rpath</span> options.  The difference
 | 
						|
between <span class="option">-rpath</span> and <span class="option">-rpath-link</span> is that directories
 | 
						|
specified by <span class="option">-rpath</span> options are included in the executable and
 | 
						|
used at runtime, whereas the <span class="option">-rpath-link</span> option is only effective
 | 
						|
at link time. Searching <span class="option">-rpath</span> in this way is only supported
 | 
						|
by native linkers and cross linkers which have been configured with
 | 
						|
the <span class="option">--with-sysroot</span> option. 
 | 
						|
<li>On an ELF system, for native linkers, if the <span class="option">-rpath</span> and
 | 
						|
<span class="option">-rpath-link</span> options were not used, search the contents of the
 | 
						|
environment variable <code>LD_RUN_PATH</code>. 
 | 
						|
<li>On SunOS, if the <span class="option">-rpath</span> option was not used, search any
 | 
						|
directories specified using <span class="option">-L</span> options. 
 | 
						|
<li>For a native linker, the search the contents of the environment
 | 
						|
variable <code>LD_LIBRARY_PATH</code>. 
 | 
						|
<li>For a native ELF linker, the directories in <code>DT_RUNPATH</code> or
 | 
						|
<code>DT_RPATH</code> of a shared library are searched for shared
 | 
						|
libraries needed by it. The <code>DT_RPATH</code> entries are ignored if
 | 
						|
<code>DT_RUNPATH</code> entries exist. 
 | 
						|
<li>The default directories, normally <span class="file">/lib</span> and <span class="file">/usr/lib</span>. 
 | 
						|
<li>For a native linker on an ELF system, if the file <span class="file">/etc/ld.so.conf</span>
 | 
						|
exists, the list of directories found in that file.
 | 
						|
          </ol>
 | 
						|
 | 
						|
     <p>If the required shared library is not found, the linker will issue a
 | 
						|
warning and continue with the link.
 | 
						|
 | 
						|
     <p><a name="index-_002dshared-210"></a><a name="index-_002dBshareable-211"></a><br><dt><code>-shared</code><dt><code>-Bshareable</code><dd><a name="index-shared-libraries-212"></a>Create a shared library.  This is currently only supported on ELF, XCOFF
 | 
						|
and SunOS platforms.  On SunOS, the linker will automatically create a
 | 
						|
shared library if the <span class="option">-e</span> option is not used and there are
 | 
						|
undefined symbols in the link.
 | 
						|
 | 
						|
     <br><dt><code>--sort-common [= ascending | descending]</code><dd><a name="index-_002d_002dsort_002dcommon-213"></a>This option tells <span class="command">ld</span> to sort the common symbols by alignment in
 | 
						|
ascending or descending order when it places them in the appropriate output
 | 
						|
sections.  The symbol alignments considered are sixteen-byte or larger,
 | 
						|
eight-byte, four-byte, two-byte, and one-byte. This is to prevent gaps
 | 
						|
between symbols due to alignment constraints.  If no sorting order is
 | 
						|
specified, then descending order is assumed.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsort_002dsection-name-214"></a><br><dt><code>--sort-section name</code><dd>This option will apply <code>SORT_BY_NAME</code> to all wildcard section
 | 
						|
patterns in the linker script.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsort_002dsection-alignment-215"></a><br><dt><code>--sort-section alignment</code><dd>This option will apply <code>SORT_BY_ALIGNMENT</code> to all wildcard section
 | 
						|
patterns in the linker script.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsplit_002dby_002dfile-216"></a><br><dt><code>--split-by-file [</code><var>size</var><code>]</code><dd>Similar to <span class="option">--split-by-reloc</span> but creates a new output section for
 | 
						|
each input file when <var>size</var> is reached.  <var>size</var> defaults to a
 | 
						|
size of 1 if not given.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsplit_002dby_002dreloc-217"></a><br><dt><code>--split-by-reloc [</code><var>count</var><code>]</code><dd>Tries to creates extra sections in the output file so that no single
 | 
						|
output section in the file contains more than <var>count</var> relocations. 
 | 
						|
This is useful when generating huge relocatable files for downloading into
 | 
						|
certain real time kernels with the COFF object file format; since COFF
 | 
						|
cannot represent more than 65535 relocations in a single section.  Note
 | 
						|
that this will fail to work with object file formats which do not
 | 
						|
support arbitrary sections.  The linker will not split up individual
 | 
						|
input sections for redistribution, so if a single input section contains
 | 
						|
more than <var>count</var> relocations one output section will contain that
 | 
						|
many relocations.  <var>count</var> defaults to a value of 32768.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dstats-218"></a><br><dt><code>--stats</code><dd>Compute and display statistics about the operation of the linker, such
 | 
						|
as execution time and memory usage.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsysroot-219"></a><br><dt><code>--sysroot=</code><var>directory</var><dd>Use <var>directory</var> as the location of the sysroot, overriding the
 | 
						|
configure-time default.  This option is only supported by linkers
 | 
						|
that were configured using <span class="option">--with-sysroot</span>.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dtraditional_002dformat-220"></a><a name="index-traditional-format-221"></a><br><dt><code>--traditional-format</code><dd>For some targets, the output of <span class="command">ld</span> is different in some ways from
 | 
						|
the output of some existing linker.  This switch requests <span class="command">ld</span> to
 | 
						|
use the traditional format instead.
 | 
						|
 | 
						|
     <p><a name="index-dbx-222"></a>For example, on SunOS, <span class="command">ld</span> combines duplicate entries in the
 | 
						|
symbol string table.  This can reduce the size of an output file with
 | 
						|
full debugging information by over 30 percent.  Unfortunately, the SunOS
 | 
						|
<code>dbx</code> program can not read the resulting program (<code>gdb</code> has no
 | 
						|
trouble).  The <span class="samp">--traditional-format</span> switch tells <span class="command">ld</span> to not
 | 
						|
combine duplicate entries.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsection_002dstart-_0040var_007bsectionname_007d_003d_0040var_007borg_007d-223"></a><br><dt><code>--section-start </code><var>sectionname</var><code>=</code><var>org</var><dd>Locate a section in the output file at the absolute
 | 
						|
address given by <var>org</var>.  You may use this option as many
 | 
						|
times as necessary to locate multiple sections in the command
 | 
						|
line. 
 | 
						|
<var>org</var> must be a single hexadecimal integer;
 | 
						|
for compatibility with other linkers, you may omit the leading
 | 
						|
<span class="samp">0x</span> usually associated with hexadecimal values.  <em>Note:</em> there
 | 
						|
should be no white space between <var>sectionname</var>, the equals
 | 
						|
sign (“<=>”), and <var>org</var>.
 | 
						|
 | 
						|
     <p><a name="index-_002dTbss-_0040var_007borg_007d-224"></a><a name="index-_002dTdata-_0040var_007borg_007d-225"></a><a name="index-_002dTtext-_0040var_007borg_007d-226"></a><a name="index-segment-origins_002c-cmd-line-227"></a><br><dt><code>-Tbss </code><var>org</var><dt><code>-Tdata </code><var>org</var><dt><code>-Ttext </code><var>org</var><dd>Same as –section-start, with <code>.bss</code>, <code>.data</code> or
 | 
						|
<code>.text</code> as the <var>sectionname</var>.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dunresolved_002dsymbols-228"></a><br><dt><code>--unresolved-symbols=</code><var>method</var><dd>Determine how to handle unresolved symbols.  There are four possible
 | 
						|
values for <span class="samp">method</span>:
 | 
						|
 | 
						|
          <dl>
 | 
						|
<dt><span class="samp">ignore-all</span><dd>Do not report any unresolved symbols.
 | 
						|
 | 
						|
          <br><dt><span class="samp">report-all</span><dd>Report all unresolved symbols.  This is the default.
 | 
						|
 | 
						|
          <br><dt><span class="samp">ignore-in-object-files</span><dd>Report unresolved symbols that are contained in shared libraries, but
 | 
						|
ignore them if they come from regular object files.
 | 
						|
 | 
						|
          <br><dt><span class="samp">ignore-in-shared-libs</span><dd>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. 
 | 
						|
</dl>
 | 
						|
 | 
						|
     <p>The behaviour for shared libraries on their own can also be controlled
 | 
						|
by the <span class="option">--[no-]allow-shlib-undefined</span> option.
 | 
						|
 | 
						|
     <p>Normally the linker will generate an error message for each reported
 | 
						|
unresolved symbol but the option <span class="option">--warn-unresolved-symbols</span>
 | 
						|
can change this to a warning.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dverbose-229"></a><a name="index-verbose-230"></a><br><dt><code>--dll-verbose</code><dt><code>--verbose</code><dd>Display the version number for <span class="command">ld</span> and list the linker emulations
 | 
						|
supported.  Display which input files can and cannot be opened.  Display
 | 
						|
the linker script being used by the linker.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dversion_002dscript_003d_0040var_007bversion_002dscriptfile_007d-231"></a><a name="index-version-script_002c-symbol-versions-232"></a><dt><code>--version-script=</code><var>version-scriptfile</var><dd>Specify the name of a version script to the linker.  This is typically
 | 
						|
used when creating shared libraries to specify additional information
 | 
						|
about the version hierarchy for the library being created.  This option
 | 
						|
is only meaningful on ELF platforms which support shared libraries. 
 | 
						|
See <a href="VERSION.html#VERSION">VERSION</a>.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002dcommon-233"></a><a name="index-warnings_002c-on-combining-symbols-234"></a><a name="index-combining-symbols_002c-warnings-on-235"></a><br><dt><code>--warn-common</code><dd>Warn when a common symbol is combined with another common symbol or with
 | 
						|
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 practise, so you may get some
 | 
						|
warnings about symbols in the libraries as well as in your programs.
 | 
						|
 | 
						|
     <p>There are three kinds of global symbols, illustrated here by C examples:
 | 
						|
 | 
						|
          <dl>
 | 
						|
<dt><span class="samp">int i = 1;</span><dd>A definition, which goes in the initialized data section of the output
 | 
						|
file.
 | 
						|
 | 
						|
          <br><dt><span class="samp">extern int i;</span><dd>An undefined reference, which does not allocate space. 
 | 
						|
There must be either a definition or a common symbol for the
 | 
						|
variable somewhere.
 | 
						|
 | 
						|
          <br><dt><span class="samp">int i;</span><dd>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. 
 | 
						|
</dl>
 | 
						|
 | 
						|
     <p>The <span class="samp">--warn-common</span> 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.
 | 
						|
 | 
						|
          <ol type=1 start=1>
 | 
						|
<li>Turning a common symbol into a reference, because there is already a
 | 
						|
definition for the symbol.
 | 
						|
          <pre class="smallexample">               <var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
 | 
						|
                  overridden by definition
 | 
						|
               <var>file</var>(<var>section</var>): warning: defined here
 | 
						|
          </pre>
 | 
						|
          <li>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.
 | 
						|
          <pre class="smallexample">               <var>file</var>(<var>section</var>): warning: definition of `<var>symbol</var>'
 | 
						|
                  overriding common
 | 
						|
               <var>file</var>(<var>section</var>): warning: common is here
 | 
						|
          </pre>
 | 
						|
          <li>Merging a common symbol with a previous same-sized common symbol.
 | 
						|
          <pre class="smallexample">               <var>file</var>(<var>section</var>): warning: multiple common
 | 
						|
                  of `<var>symbol</var>'
 | 
						|
               <var>file</var>(<var>section</var>): warning: previous common is here
 | 
						|
          </pre>
 | 
						|
          <li>Merging a common symbol with a previous larger common symbol.
 | 
						|
          <pre class="smallexample">               <var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
 | 
						|
                  overridden by larger common
 | 
						|
               <var>file</var>(<var>section</var>): warning: larger common is here
 | 
						|
          </pre>
 | 
						|
          <li>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.
 | 
						|
          <pre class="smallexample">               <var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>'
 | 
						|
                  overriding smaller common
 | 
						|
               <var>file</var>(<var>section</var>): warning: smaller common is here
 | 
						|
          </pre>
 | 
						|
          </ol>
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002dconstructors-236"></a><br><dt><code>--warn-constructors</code><dd>Warn if any global constructors are used.  This is only useful for a few
 | 
						|
object file formats.  For formats like COFF or ELF, the linker can not
 | 
						|
detect the use of global constructors.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002dmultiple_002dgp-237"></a><br><dt><code>--warn-multiple-gp</code><dd>Warn if multiple global pointer values are required in the output file. 
 | 
						|
This is only meaningful for certain processors, such as the Alpha. 
 | 
						|
Specifically, some processors put large-valued constants in a special
 | 
						|
section.  A special register (the global pointer) points into the middle
 | 
						|
of this section, so that constants can be loaded efficiently via a
 | 
						|
base-register relative addressing mode.  Since the offset in
 | 
						|
base-register relative mode is fixed and relatively small (e.g., 16
 | 
						|
bits), this limits the maximum size of the constant pool.  Thus, in
 | 
						|
large programs, it is often necessary to use multiple global pointer
 | 
						|
values in order to be able to address all possible constants.  This
 | 
						|
option causes a warning to be issued whenever this case occurs.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002donce-238"></a><a name="index-warnings_002c-on-undefined-symbols-239"></a><a name="index-undefined-symbols_002c-warnings-on-240"></a><br><dt><code>--warn-once</code><dd>Only warn once for each undefined symbol, rather than once per module
 | 
						|
which refers to it.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002dsection_002dalign-241"></a><a name="index-warnings_002c-on-section-alignment-242"></a><a name="index-section-alignment_002c-warnings-on-243"></a><br><dt><code>--warn-section-align</code><dd>Warn if the address of an output section is changed because of
 | 
						|
alignment.  Typically, the alignment will be set by an input section. 
 | 
						|
The address will only be changed if it not explicitly specified; that
 | 
						|
is, if the <code>SECTIONS</code> command does not specify a start address for
 | 
						|
the section (see <a href="SECTIONS.html#SECTIONS">SECTIONS</a>).
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002dshared_002dtextrel-244"></a><br><dt><code>--warn-shared-textrel</code><dd>Warn if the linker adds a DT_TEXTREL to a shared object.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwarn_002dunresolved_002dsymbols-245"></a><br><dt><code>--warn-unresolved-symbols</code><dd>If the linker is going to report an unresolved symbol (see the option
 | 
						|
<span class="option">--unresolved-symbols</span>) it will normally generate an error. 
 | 
						|
This option makes it generate a warning instead.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002derror_002dunresolved_002dsymbols-246"></a><br><dt><code>--error-unresolved-symbols</code><dd>This restores the linker's default behaviour of generating errors when
 | 
						|
it is reporting unresolved symbols.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwhole_002darchive-247"></a><a name="index-including-an-entire-archive-248"></a><br><dt><code>--whole-archive</code><dd>For each archive mentioned on the command line after the
 | 
						|
<span class="option">--whole-archive</span> option, include every object file in the archive
 | 
						|
in the link, rather than searching the archive for the required object
 | 
						|
files.  This is normally used to turn an archive file into a shared
 | 
						|
library, forcing every object to be included in the resulting shared
 | 
						|
library.  This option may be used more than once.
 | 
						|
 | 
						|
     <p>Two notes when using this option from gcc: First, gcc doesn't know
 | 
						|
about this option, so you have to use <span class="option">-Wl,-whole-archive</span>. 
 | 
						|
Second, don't forget to use <span class="option">-Wl,-no-whole-archive</span> after your
 | 
						|
list of archives, because gcc will add its own list of archives to
 | 
						|
your link and you may not want this flag to affect those as well.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dwrap-249"></a><br><dt><code>--wrap </code><var>symbol</var><dd>Use a wrapper function for <var>symbol</var>.  Any undefined reference to
 | 
						|
<var>symbol</var> will be resolved to <code>__wrap_</code><var>symbol</var>.  Any
 | 
						|
undefined reference to <code>__real_</code><var>symbol</var> will be resolved to
 | 
						|
<var>symbol</var>.
 | 
						|
 | 
						|
     <p>This can be used to provide a wrapper for a system function.  The
 | 
						|
wrapper function should be called <code>__wrap_</code><var>symbol</var>.  If it
 | 
						|
wishes to call the system function, it should call
 | 
						|
<code>__real_</code><var>symbol</var>.
 | 
						|
 | 
						|
     <p>Here is a trivial example:
 | 
						|
 | 
						|
     <pre class="smallexample">          void *
 | 
						|
          __wrap_malloc (size_t c)
 | 
						|
          {
 | 
						|
            printf ("malloc called with %zu\n", c);
 | 
						|
            return __real_malloc (c);
 | 
						|
          }
 | 
						|
     </pre>
 | 
						|
     <p>If you link other code with this file using <span class="option">--wrap malloc</span>, then
 | 
						|
all calls to <code>malloc</code> will call the function <code>__wrap_malloc</code>
 | 
						|
instead.  The call to <code>__real_malloc</code> in <code>__wrap_malloc</code> will
 | 
						|
call the real <code>malloc</code> function.
 | 
						|
 | 
						|
     <p>You may wish to provide a <code>__real_malloc</code> function as well, so that
 | 
						|
links without the <span class="option">--wrap</span> option will succeed.  If you do this,
 | 
						|
you should not put the definition of <code>__real_malloc</code> in the same
 | 
						|
file as <code>__wrap_malloc</code>; if you do, the assembler may resolve the
 | 
						|
call before the linker has a chance to wrap it to <code>malloc</code>.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002deh_002dframe_002dhdr-250"></a><br><dt><code>--eh-frame-hdr</code><dd>Request creation of <code>.eh_frame_hdr</code> section and ELF
 | 
						|
<code>PT_GNU_EH_FRAME</code> segment header.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002denable_002dnew_002ddtags-251"></a><a name="index-_002d_002ddisable_002dnew_002ddtags-252"></a><br><dt><code>--enable-new-dtags</code><dt><code>--disable-new-dtags</code><dd>This linker can create the new dynamic tags in ELF. But the older ELF
 | 
						|
systems may not understand them. If you specify
 | 
						|
<span class="option">--enable-new-dtags</span>, the dynamic tags will be created as needed. 
 | 
						|
If you specify <span class="option">--disable-new-dtags</span>, 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.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dhash_002dsize_003d_0040var_007bnumber_007d-253"></a><br><dt><code>--hash-size=</code><var>number</var><dd>Set the default size of the linker's hash tables to a prime number
 | 
						|
close to <var>number</var>.  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.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dhash_002dstyle_003d_0040var_007bstyle_007d-254"></a><br><dt><code>--hash-style=</code><var>style</var><dd>Set the type of linker's hash table(s).  <var>style</var> can be either
 | 
						|
<code>sysv</code> for classic ELF <code>.hash</code> section, <code>gnu</code> for
 | 
						|
new style GNU <code>.gnu.hash</code> section or <code>both</code> for both
 | 
						|
the classic ELF <code>.hash</code> and new style GNU <code>.gnu.hash</code>
 | 
						|
hash tables.  The default is <code>sysv</code>.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dreduce_002dmemory_002doverheads-255"></a><br><dt><code>--reduce-memory-overheads</code><dd>This option reduces memory requirements at ld runtime, at the expense of
 | 
						|
linking speed.  This was introduced 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.
 | 
						|
 | 
						|
     <p>Another effect 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 <span class="option">--hash-size</span> switch
 | 
						|
has been used.
 | 
						|
 | 
						|
     <p>The <span class="option">--reduce-memory-overheads</span> switch may be also be used to
 | 
						|
enable other tradeoffs in future versions of the linker.
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dbuild_002did-256"></a><a name="index-_002d_002dbuild_002did_003d_0040var_007bstyle_007d-257"></a><br><dt><code>--build-id</code><dt><code>--build-id=</code><var>style</var><dd>Request creation of <code>.note.gnu.build-id</code> ELF note section. 
 | 
						|
The contents of the note are unique bits identifying this linked
 | 
						|
file.  <var>style</var> can be <code>uuid</code> to use 128 random bits,
 | 
						|
<code>sha1</code> to use a 160-bit <span class="sc">SHA1</span> hash on the normative
 | 
						|
parts of the output contents, <code>md5</code> to use a 128-bit
 | 
						|
<span class="sc">MD5</span> hash on the normative parts of the output contents, or
 | 
						|
<code>0x</code><var>hexstring</var> to use a chosen bit string specified as
 | 
						|
an even number of hexadecimal digits (<code>-</code> and <code>:</code>
 | 
						|
characters between digit pairs are ignored).  If <var>style</var> is
 | 
						|
omitted, <code>sha1</code> is used.
 | 
						|
 | 
						|
     <p>The <code>md5</code> and <code>sha1</code> styles produces an identifier
 | 
						|
that is always the same in an identical output file, but will be
 | 
						|
unique among all nonidentical output files.  It is not intended
 | 
						|
to be compared as a checksum for the file's contents.  A linked
 | 
						|
file may be changed later by other tools, but the build ID bit
 | 
						|
string identifying the original linked file does not change.
 | 
						|
 | 
						|
     <p>Passing <code>none</code> for <var>style</var> disables the setting from any
 | 
						|
<code>--build-id</code> options earlier on the command line. 
 | 
						|
</dl>
 | 
						|
 | 
						|
<!-- man end -->
 | 
						|
<h4 class="subsection">2.1.1 Options Specific to i386 PE Targets</h4>
 | 
						|
 | 
						|
<!-- man begin OPTIONS -->
 | 
						|
<p>The i386 PE linker supports the <span class="option">-shared</span> option, which causes
 | 
						|
the output to be a dynamically linked library (DLL) instead of a
 | 
						|
normal executable.  You should name the output <code>*.dll</code> when you
 | 
						|
use this option.  In addition, the linker fully supports the standard
 | 
						|
<code>*.def</code> files, which may be specified on the linker command line
 | 
						|
like an object file (in fact, it should precede archives it exports
 | 
						|
symbols from, to ensure that they get linked in, just like a normal
 | 
						|
object file).
 | 
						|
 | 
						|
   <p>In addition to the options common to all targets, the i386 PE linker
 | 
						|
support additional command line options that are specific to the i386
 | 
						|
PE target.  Options that take values may be separated from their
 | 
						|
values by either a space or an equals sign.
 | 
						|
 | 
						|
     
 | 
						|
<a name="index-_002d_002dadd_002dstdcall_002dalias-258"></a>
 | 
						|
<dl><dt><code>--add-stdcall-alias</code><dd>If given, symbols with a stdcall suffix (@<var>nn</var>) will be exported
 | 
						|
as-is and also with the suffix stripped. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dbase_002dfile-259"></a><br><dt><code>--base-file </code><var>file</var><dd>Use <var>file</var> as the name of a file in which to save the base
 | 
						|
addresses of all the relocations needed for generating DLLs with
 | 
						|
<span class="file">dlltool</span>. 
 | 
						|
[This is an i386 PE specific option]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddll-260"></a><br><dt><code>--dll</code><dd>Create a DLL instead of a regular executable.  You may also use
 | 
						|
<span class="option">-shared</span> or specify a <code>LIBRARY</code> in a given <code>.def</code>
 | 
						|
file. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002denable_002dstdcall_002dfixup-261"></a><a name="index-_002d_002ddisable_002dstdcall_002dfixup-262"></a><br><dt><code>--enable-stdcall-fixup</code><dt><code>--disable-stdcall-fixup</code><dd>If the link finds a symbol that it cannot resolve, it will attempt to
 | 
						|
do “fuzzy linking” by looking for another defined symbol that differs
 | 
						|
only in the format of the symbol name (cdecl vs stdcall) and will
 | 
						|
resolve that symbol by linking to the match.  For example, the
 | 
						|
undefined symbol <code>_foo</code> might be linked to the function
 | 
						|
<code>_foo@12</code>, or the undefined symbol <code>_bar@16</code> might be linked
 | 
						|
to the function <code>_bar</code>.  When the linker does this, it prints a
 | 
						|
warning, since it normally should have failed to link, but sometimes
 | 
						|
import libraries generated from third-party dlls may need this feature
 | 
						|
to be usable.  If you specify <span class="option">--enable-stdcall-fixup</span>, this
 | 
						|
feature is fully enabled and warnings are not printed.  If you specify
 | 
						|
<span class="option">--disable-stdcall-fixup</span>, this feature is disabled and such
 | 
						|
mismatches are considered to be errors. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-DLLs_002c-creating-263"></a><a name="index-_002d_002dexport_002dall_002dsymbols-264"></a><br><dt><code>--export-all-symbols</code><dd>If given, all global symbols in the objects used to build a DLL will
 | 
						|
be exported by the DLL.  Note that this is the default if there
 | 
						|
otherwise wouldn't be any exported symbols.  When symbols are
 | 
						|
explicitly exported via DEF files or implicitly exported via function
 | 
						|
attributes, the default is to not export anything else unless this
 | 
						|
option is given.  Note that the symbols <code>DllMain@12</code>,
 | 
						|
<code>DllEntryPoint@0</code>, <code>DllMainCRTStartup@12</code>, and
 | 
						|
<code>impure_ptr</code> will not be automatically
 | 
						|
exported.  Also, symbols imported from other DLLs will not be
 | 
						|
re-exported, nor will symbols specifying the DLL's internal layout
 | 
						|
such as those beginning with <code>_head_</code> or ending with
 | 
						|
<code>_iname</code>.  In addition, no symbols from <code>libgcc</code>,
 | 
						|
<code>libstd++</code>, <code>libmingw32</code>, or <code>crtX.o</code> will be exported. 
 | 
						|
Symbols whose names begin with <code>__rtti_</code> or <code>__builtin_</code> will
 | 
						|
not be exported, to help with C++ DLLs.  Finally, there is an
 | 
						|
extensive list of cygwin-private symbols that are not exported
 | 
						|
(obviously, this applies on when building DLLs for cygwin targets). 
 | 
						|
These cygwin-excludes are: <code>_cygwin_dll_entry@12</code>,
 | 
						|
<code>_cygwin_crt0_common@8</code>, <code>_cygwin_noncygwin_dll_entry@12</code>,
 | 
						|
<code>_fmode</code>, <code>_impure_ptr</code>, <code>cygwin_attach_dll</code>,
 | 
						|
<code>cygwin_premain0</code>, <code>cygwin_premain1</code>, <code>cygwin_premain2</code>,
 | 
						|
<code>cygwin_premain3</code>, and <code>environ</code>. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dexclude_002dsymbols-265"></a><br><dt><code>--exclude-symbols </code><var>symbol</var><code>,</code><var>symbol</var><code>,...</code><dd>Specifies a list of symbols which should not be automatically
 | 
						|
exported.  The symbol names may be delimited by commas or colons. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dfile_002dalignment-266"></a><br><dt><code>--file-alignment</code><dd>Specify the file alignment.  Sections in the file will always begin at
 | 
						|
file offsets which are multiples of this number.  This defaults to
 | 
						|
512. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-heap-size-267"></a><a name="index-_002d_002dheap-268"></a><br><dt><code>--heap </code><var>reserve</var><dt><code>--heap </code><var>reserve</var><code>,</code><var>commit</var><dd>Specify the number of bytes of memory to reserve (and optionally commit)
 | 
						|
to be used as heap for this program.  The default is 1Mb reserved, 4K
 | 
						|
committed. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-image-base-269"></a><a name="index-_002d_002dimage_002dbase-270"></a><br><dt><code>--image-base </code><var>value</var><dd>Use <var>value</var> as the base address of your program or dll.  This is
 | 
						|
the lowest memory location that will be used when your program or dll
 | 
						|
is loaded.  To reduce the need to relocate and improve performance of
 | 
						|
your dlls, each should have a unique base address and not overlap any
 | 
						|
other dlls.  The default is 0x400000 for executables, and 0x10000000
 | 
						|
for dlls. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dkill_002dat-271"></a><br><dt><code>--kill-at</code><dd>If given, the stdcall suffixes (@<var>nn</var>) will be stripped from
 | 
						|
symbols before they are exported. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dlarge_002daddress_002daware-272"></a><br><dt><code>--large-address-aware</code><dd>If given, the appropriate bit in the “Characteristics” field of the COFF
 | 
						|
header is set to indicate that this executable supports virtual addresses
 | 
						|
greater than 2 gigabytes.  This should be used in conjunction with the /3GB
 | 
						|
or /USERVA=<var>value</var> 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]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dmajor_002dimage_002dversion-273"></a><br><dt><code>--major-image-version </code><var>value</var><dd>Sets the major number of the “image version”.  Defaults to 1. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dmajor_002dos_002dversion-274"></a><br><dt><code>--major-os-version </code><var>value</var><dd>Sets the major number of the “os version”.  Defaults to 4. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dmajor_002dsubsystem_002dversion-275"></a><br><dt><code>--major-subsystem-version </code><var>value</var><dd>Sets the major number of the “subsystem version”.  Defaults to 4. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dminor_002dimage_002dversion-276"></a><br><dt><code>--minor-image-version </code><var>value</var><dd>Sets the minor number of the “image version”.  Defaults to 0. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dminor_002dos_002dversion-277"></a><br><dt><code>--minor-os-version </code><var>value</var><dd>Sets the minor number of the “os version”.  Defaults to 0. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dminor_002dsubsystem_002dversion-278"></a><br><dt><code>--minor-subsystem-version </code><var>value</var><dd>Sets the minor number of the “subsystem version”.  Defaults to 0. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-DEF-files_002c-creating-279"></a><a name="index-DLLs_002c-creating-280"></a><a name="index-_002d_002doutput_002ddef-281"></a><br><dt><code>--output-def </code><var>file</var><dd>The linker will create the file <var>file</var> which will contain a DEF
 | 
						|
file corresponding to the DLL the linker is generating.  This DEF file
 | 
						|
(which should be called <code>*.def</code>) may be used to create an import
 | 
						|
library with <code>dlltool</code> or may be used as a reference to
 | 
						|
automatically or implicitly exported symbols. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-DLLs_002c-creating-282"></a><a name="index-_002d_002dout_002dimplib-283"></a><br><dt><code>--out-implib </code><var>file</var><dd>The linker will create the file <var>file</var> which will contain an
 | 
						|
import lib corresponding to the DLL the linker is generating. This
 | 
						|
import lib (which should be called <code>*.dll.a</code> or <code>*.a</code>
 | 
						|
may be used to link clients against the generated DLL; this behaviour
 | 
						|
makes it possible to skip a separate <code>dlltool</code> import library
 | 
						|
creation step. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002denable_002dauto_002dimage_002dbase-284"></a><br><dt><code>--enable-auto-image-base</code><dd>Automatically choose the image base for DLLs, unless one is specified
 | 
						|
using the <code>--image-base</code> argument.  By using a hash generated
 | 
						|
from the dllname to create unique image bases for each DLL, in-memory
 | 
						|
collisions and relocations which can delay program execution are
 | 
						|
avoided. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddisable_002dauto_002dimage_002dbase-285"></a><br><dt><code>--disable-auto-image-base</code><dd>Do not automatically generate a unique image base.  If there is no
 | 
						|
user-specified image base (<code>--image-base</code>) then use the platform
 | 
						|
default. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-DLLs_002c-linking-to-286"></a><a name="index-_002d_002ddll_002dsearch_002dprefix-287"></a><br><dt><code>--dll-search-prefix </code><var>string</var><dd>When linking dynamically to a dll without an import library,
 | 
						|
search for <code><string><basename>.dll</code> in preference to
 | 
						|
<code>lib<basename>.dll</code>. 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</code>. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002denable_002dauto_002dimport-288"></a><br><dt><code>--enable-auto-import</code><dd>Do sophisticated linking of <code>_symbol</code> to <code>__imp__symbol</code> for
 | 
						|
DATA imports from DLLs, and create the necessary thunking symbols when
 | 
						|
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.
 | 
						|
 | 
						|
     <p>Note - use of the 'auto-import' extension will also cause read only
 | 
						|
data which would normally be placed into the .rdata section to be
 | 
						|
placed into the .data section instead.  This is in order to work
 | 
						|
around a problem with consts that is described here:
 | 
						|
http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
 | 
						|
 | 
						|
     <p>Using 'auto-import' generally will 'just work' – but sometimes you may
 | 
						|
see this message:
 | 
						|
 | 
						|
     <p>"variable '<var>' can't be auto-imported. Please read the
 | 
						|
documentation for ld's <code>--enable-auto-import</code> for details."
 | 
						|
 | 
						|
     <p>This message occurs when some (sub)expression accesses an address
 | 
						|
ultimately given by the sum of two constants (Win32 import tables only
 | 
						|
allow one).  Instances where this may occur include accesses to member
 | 
						|
fields of struct variables imported from a DLL, as well as using a
 | 
						|
constant index into an array variable imported from a DLL.  Any
 | 
						|
multiword variable (arrays, structs, long long, etc) may trigger
 | 
						|
this error condition.  However, regardless of the exact data type
 | 
						|
of the offending exported variable, ld will always detect it, issue
 | 
						|
the warning, and exit.
 | 
						|
 | 
						|
     <p>There are several ways to address this difficulty, regardless of the
 | 
						|
data type of the exported variable:
 | 
						|
 | 
						|
     <p>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 environment supports this feature.
 | 
						|
 | 
						|
     <p>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,
 | 
						|
there are two possibilities: a) make the indexee (the array's address)
 | 
						|
a variable, or b) make the 'constant' index a variable.  Thus:
 | 
						|
 | 
						|
     <pre class="example">          extern type extern_array[];
 | 
						|
          extern_array[1] -->
 | 
						|
             { volatile type *t=extern_array; t[1] }
 | 
						|
     </pre>
 | 
						|
     <p>or
 | 
						|
 | 
						|
     <pre class="example">          extern type extern_array[];
 | 
						|
          extern_array[1] -->
 | 
						|
             { volatile int t=1; extern_array[t] }
 | 
						|
     </pre>
 | 
						|
     <p>For structs (and most other multiword data types) the only option
 | 
						|
is to make the struct itself (or the long long, or the ...) variable:
 | 
						|
 | 
						|
     <pre class="example">          extern struct s extern_struct;
 | 
						|
          extern_struct.field -->
 | 
						|
             { volatile struct s *t=&extern_struct; t->field }
 | 
						|
     </pre>
 | 
						|
     <p>or
 | 
						|
 | 
						|
     <pre class="example">          extern long long extern_ll;
 | 
						|
          extern_ll -->
 | 
						|
            { volatile long long * local_ll=&extern_ll; *local_ll }
 | 
						|
     </pre>
 | 
						|
     <p>A third method of dealing with this difficulty is to abandon
 | 
						|
'auto-import' for the offending symbol and mark it with
 | 
						|
<code>__declspec(dllimport)</code>.  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
 | 
						|
between the various methods of resolving the 'direct address with
 | 
						|
constant offset' problem, you should consider typical real-world usage:
 | 
						|
 | 
						|
     <p>Original:
 | 
						|
     <pre class="example">          --foo.h
 | 
						|
          extern int arr[];
 | 
						|
          --foo.c
 | 
						|
          #include "foo.h"
 | 
						|
          void main(int argc, char **argv){
 | 
						|
            printf("%d\n",arr[1]);
 | 
						|
          }
 | 
						|
     </pre>
 | 
						|
     <p>Solution 1:
 | 
						|
     <pre class="example">          --foo.h
 | 
						|
          extern int arr[];
 | 
						|
          --foo.c
 | 
						|
          #include "foo.h"
 | 
						|
          void main(int argc, char **argv){
 | 
						|
            /* This workaround is for win32 and cygwin; do not "optimize" */
 | 
						|
            volatile int *parr = arr;
 | 
						|
            printf("%d\n",parr[1]);
 | 
						|
          }
 | 
						|
     </pre>
 | 
						|
     <p>Solution 2:
 | 
						|
     <pre class="example">          --foo.h
 | 
						|
          /* Note: auto-export is assumed (no __declspec(dllexport)) */
 | 
						|
          #if (defined(_WIN32) || defined(__CYGWIN__)) && \
 | 
						|
            !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
 | 
						|
          #define FOO_IMPORT __declspec(dllimport)
 | 
						|
          #else
 | 
						|
          #define FOO_IMPORT
 | 
						|
          #endif
 | 
						|
          extern FOO_IMPORT int arr[];
 | 
						|
          --foo.c
 | 
						|
          #include "foo.h"
 | 
						|
          void main(int argc, char **argv){
 | 
						|
            printf("%d\n",arr[1]);
 | 
						|
          }
 | 
						|
     </pre>
 | 
						|
     <p>A fourth way to avoid this problem is to re-code your
 | 
						|
library to use a functional interface rather than a data interface
 | 
						|
for the offending variables (e.g. set_foo() and get_foo() accessor
 | 
						|
functions). 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddisable_002dauto_002dimport-289"></a><br><dt><code>--disable-auto-import</code><dd>Do not attempt to do sophisticated linking of <code>_symbol</code> to
 | 
						|
<code>__imp__symbol</code> for DATA imports from DLLs. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002denable_002druntime_002dpseudo_002dreloc-290"></a><br><dt><code>--enable-runtime-pseudo-reloc</code><dd>If your code contains expressions described in –enable-auto-import section,
 | 
						|
that is, DATA imports from DLL with non-zero offset, this switch will create
 | 
						|
a vector of 'runtime pseudo relocations' which can be used by runtime
 | 
						|
environment to adjust references to such data in your client code. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002ddisable_002druntime_002dpseudo_002dreloc-291"></a><br><dt><code>--disable-runtime-pseudo-reloc</code><dd>Do not create pseudo relocations for non-zero offset DATA imports from
 | 
						|
DLLs.  This is the default. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002denable_002dextra_002dpe_002ddebug-292"></a><br><dt><code>--enable-extra-pe-debug</code><dd>Show additional debug info related to auto-import symbol thunking. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsection_002dalignment-293"></a><br><dt><code>--section-alignment</code><dd>Sets the section alignment.  Sections in memory will always begin at
 | 
						|
addresses which are a multiple of this number.  Defaults to 0x1000. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-stack-size-294"></a><a name="index-_002d_002dstack-295"></a><br><dt><code>--stack </code><var>reserve</var><dt><code>--stack </code><var>reserve</var><code>,</code><var>commit</var><dd>Specify the number of bytes of memory to reserve (and optionally commit)
 | 
						|
to be used as stack for this program.  The default is 2Mb reserved, 4K
 | 
						|
committed. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dsubsystem-296"></a><br><dt><code>--subsystem </code><var>which</var><dt><code>--subsystem </code><var>which</var><code>:</code><var>major</var><dt><code>--subsystem </code><var>which</var><code>:</code><var>major</var><code>.</code><var>minor</var><dd>Specifies the subsystem under which your program will execute.  The
 | 
						|
legal values for <var>which</var> are <code>native</code>, <code>windows</code>,
 | 
						|
<code>console</code>, <code>posix</code>, and <code>xbox</code>.  You may optionally set
 | 
						|
the subsystem version also.  Numeric values are also accepted for
 | 
						|
<var>which</var>. 
 | 
						|
[This option is specific to the i386 PE targeted port of the linker]
 | 
						|
 | 
						|
   </dl>
 | 
						|
 | 
						|
<!-- man end -->
 | 
						|
<h4 class="subsection">2.1.2 Options specific to Motorola 68HC11 and 68HC12 targets</h4>
 | 
						|
 | 
						|
<!-- man begin OPTIONS -->
 | 
						|
<p>The 68HC11 and 68HC12 linkers support specific options to control the
 | 
						|
memory bank switching mapping and trampoline code generation.
 | 
						|
 | 
						|
     
 | 
						|
<a name="index-_002d_002dno_002dtrampoline-297"></a>
 | 
						|
<dl><dt><code>--no-trampoline</code><dd>This option disables the generation of trampoline. By default a trampoline
 | 
						|
is generated for each far function which is called using a <code>jsr</code>
 | 
						|
instruction (this happens when a pointer to a far function is taken).
 | 
						|
 | 
						|
     <p><a name="index-_002d_002dbank_002dwindow-298"></a><br><dt><code>--bank-window </code><var>name</var><dd>This option indicates to the linker the name of the memory region in
 | 
						|
the <span class="samp">MEMORY</span> 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.
 | 
						|
 | 
						|
   </dl>
 | 
						|
 | 
						|
<!-- man end -->
 | 
						|
<h4 class="subsection">2.1.3 Options specific to Motorola 68K target</h4>
 | 
						|
 | 
						|
<!-- man begin OPTIONS -->
 | 
						|
<p>The following options are supported to control handling of GOT generation
 | 
						|
when linking for 68K targets.
 | 
						|
 | 
						|
     
 | 
						|
<a name="index-_002d_002dgot-299"></a>
 | 
						|
<dl><dt><code>--got=</code><var>type</var><dd>This option tells the linker which GOT generation scheme to use. 
 | 
						|
<var>type</var> should be one of <span class="samp">single</span>, <span class="samp">negative</span>,
 | 
						|
<span class="samp">multigot</span> or <span class="samp">target</span>.  For more information refer to the
 | 
						|
Info entry for <span class="file">ld</span>.
 | 
						|
 | 
						|
   </dl>
 | 
						|
 | 
						|
<!-- man end -->
 | 
						|
</body></html>
 | 
						|
 |