1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- This file documents the GNU linker LD 4(GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 5version 2.36.1. 6 7Copyright (C) 1991-2021 Free Software Foundation, Inc. 8 9Permission is granted to copy, distribute and/or modify this document 10under the terms of the GNU Free Documentation License, Version 1.3 11or any later version published by the Free Software Foundation; 12with no Invariant Sections, with no Front-Cover Texts, and with no 13Back-Cover Texts. A copy of the license is included in the 14section entitled "GNU Free Documentation License". --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>LD: Options</title> 18 19<meta name="description" content="LD: Options"> 20<meta name="keywords" content="LD: Options"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="LD-Index.html#LD-Index" rel="index" title="LD Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Invocation.html#Invocation" rel="up" title="Invocation"> 29<link href="Environment.html#Environment" rel="next" title="Environment"> 30<link href="Invocation.html#Invocation" rel="previous" title="Invocation"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Options"></a> 65<div class="header"> 66<p> 67Next: <a href="Environment.html#Environment" accesskey="n" rel="next">Environment</a>, Up: <a href="Invocation.html#Invocation" accesskey="u" rel="up">Invocation</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p> 68</div> 69<hr> 70<a name="Command_002dline-Options"></a> 71<h3 class="section">2.1 Command-line Options</h3> 72 73<a name="index-command-line"></a> 74<a name="index-options"></a> 75 76 77<p>The linker supports a plethora of command-line options, but in actual 78practice few of them are used in any particular context. 79<a name="index-standard-Unix-system"></a> 80For instance, a frequent use of <code>ld</code> is to link standard Unix 81object files on a standard, supported Unix system. On such a system, to 82link a file <code>hello.o</code>: 83</p> 84<div class="smallexample"> 85<pre class="smallexample">ld -o <var>output</var> /lib/crt0.o hello.o -lc 86</pre></div> 87 88<p>This tells <code>ld</code> to produce a file called <var>output</var> as the 89result of linking the file <code>/lib/crt0.o</code> with <code>hello.o</code> and 90the library <code>libc.a</code>, which will come from the standard search 91directories. (See the discussion of the ‘<samp>-l</samp>’ option below.) 92</p> 93<p>Some of the command-line options to <code>ld</code> may be specified at any 94point in the command line. However, options which refer to files, such 95as ‘<samp>-l</samp>’ or ‘<samp>-T</samp>’, cause the file to be read at the point at 96which the option appears in the command line, relative to the object 97files and other file options. Repeating non-file options with a 98different argument will either have no further effect, or override prior 99occurrences (those further to the left on the command line) of that 100option. Options which may be meaningfully specified more than once are 101noted in the descriptions below. 102</p> 103<a name="index-object-files"></a> 104<p>Non-option arguments are object files or archives which are to be linked 105together. They may follow, precede, or be mixed in with command-line 106options, except that an object file argument may not be placed between 107an option and its argument. 108</p> 109<p>Usually the linker is invoked with at least one object file, but you can 110specify other forms of binary input files using ‘<samp>-l</samp>’, ‘<samp>-R</samp>’, 111and the script command language. If <em>no</em> binary input files at all 112are specified, the linker does not produce any output, and issues the 113message ‘<samp>No input files</samp>’. 114</p> 115<p>If the linker cannot recognize the format of an object file, it will 116assume that it is a linker script. A script specified in this way 117augments the main linker script used for the link (either the default 118linker script or the one specified by using ‘<samp>-T</samp>’). This feature 119permits the linker to link against a file which appears to be an object 120or an archive, but actually merely defines some symbol values, or uses 121<code>INPUT</code> or <code>GROUP</code> to load other objects. Specifying a 122script in this way merely augments the main linker script, with the 123extra commands placed after the main script; use the ‘<samp>-T</samp>’ option 124to replace the default linker script entirely, but note the effect of 125the <code>INSERT</code> command. See <a href="Scripts.html#Scripts">Scripts</a>. 126</p> 127<p>For options whose names are a single letter, 128option arguments must either follow the option letter without intervening 129whitespace, or be given as separate arguments immediately following the 130option that requires them. 131</p> 132<p>For options whose names are multiple letters, either one dash or two can 133precede the option name; for example, ‘<samp>-trace-symbol</samp>’ and 134‘<samp>--trace-symbol</samp>’ are equivalent. Note—there is one exception to 135this rule. Multiple letter options that start with a lower case ’o’ can 136only be preceded by two dashes. This is to reduce confusion with the 137‘<samp>-o</samp>’ option. So for example ‘<samp>-omagic</samp>’ sets the output file 138name to ‘<samp>magic</samp>’ whereas ‘<samp>--omagic</samp>’ sets the NMAGIC flag on the 139output. 140</p> 141<p>Arguments to multiple-letter options must either be separated from the 142option name by an equals sign, or be given as separate arguments 143immediately following the option that requires them. For example, 144‘<samp>--trace-symbol foo</samp>’ and ‘<samp>--trace-symbol=foo</samp>’ are equivalent. 145Unique abbreviations of the names of multiple-letter options are 146accepted. 147</p> 148<p>Note—if the linker is being invoked indirectly, via a compiler driver 149(e.g. ‘<samp>gcc</samp>’) then all the linker command-line options should be 150prefixed by ‘<samp>-Wl,</samp>’ (or whatever is appropriate for the particular 151compiler driver) like this: 152</p> 153<div class="smallexample"> 154<pre class="smallexample"> gcc -Wl,--start-group foo.o bar.o -Wl,--end-group 155</pre></div> 156 157<p>This is important, because otherwise the compiler driver program may 158silently drop the linker options, resulting in a bad link. Confusion 159may also arise when passing options that require values through a 160driver, as the use of a space between option and argument acts as 161a separator, and causes the driver to pass only the option to the linker 162and the argument to the compiler. In this case, it is simplest to use 163the joined forms of both single- and multiple-letter options, such as: 164</p> 165<div class="smallexample"> 166<pre class="smallexample"> gcc foo.o bar.o -Wl,-eENTRY -Wl,-Map=a.map 167</pre></div> 168 169<p>Here is a table of the generic command-line switches accepted by the GNU 170linker: 171</p> 172<dl compact="compact"> 173<dt><code>@<var>file</var></code></dt> 174<dd><p>Read command-line options from <var>file</var>. The options read are 175inserted in place of the original @<var>file</var> option. If <var>file</var> 176does not exist, or cannot be read, then the option will be treated 177literally, and not removed. 178</p> 179<p>Options in <var>file</var> are separated by whitespace. A whitespace 180character may be included in an option by surrounding the entire 181option in either single or double quotes. Any character (including a 182backslash) may be included by prefixing the character to be included 183with a backslash. The <var>file</var> may itself contain additional 184@<var>file</var> options; any such options will be processed recursively. 185</p> 186<a name="index-_002da-keyword"></a> 187</dd> 188<dt><code>-a <var>keyword</var></code></dt> 189<dd><p>This option is supported for HP/UX compatibility. The <var>keyword</var> 190argument must be one of the strings ‘<samp>archive</samp>’, ‘<samp>shared</samp>’, or 191‘<samp>default</samp>’. ‘<samp>-aarchive</samp>’ is functionally equivalent to 192‘<samp>-Bstatic</samp>’, and the other two keywords are functionally equivalent 193to ‘<samp>-Bdynamic</samp>’. This option may be used any number of times. 194</p> 195<a name="index-_002d_002daudit-AUDITLIB"></a> 196</dd> 197<dt><code>--audit <var>AUDITLIB</var></code></dt> 198<dd><p>Adds <var>AUDITLIB</var> to the <code>DT_AUDIT</code> entry of the dynamic section. 199<var>AUDITLIB</var> is not checked for existence, nor will it use the DT_SONAME 200specified in the library. If specified multiple times <code>DT_AUDIT</code> 201will contain a colon separated list of audit interfaces to use. If the linker 202finds an object with an audit entry while searching for shared libraries, 203it will add a corresponding <code>DT_DEPAUDIT</code> entry in the output file. 204This option is only meaningful on ELF platforms supporting the rtld-audit 205interface. 206</p> 207<a name="index-binary-input-format"></a> 208<a name="index-_002db-format"></a> 209<a name="index-_002d_002dformat_003dformat"></a> 210<a name="index-input-format"></a> 211<a name="index-input-format-1"></a> 212</dd> 213<dt><code>-b <var>input-format</var></code></dt> 214<dt><code>--format=<var>input-format</var></code></dt> 215<dd><p><code>ld</code> may be configured to support more than one kind of object 216file. If your <code>ld</code> is configured this way, you can use the 217‘<samp>-b</samp>’ option to specify the binary format for input object files 218that follow this option on the command line. Even when <code>ld</code> is 219configured to support alternative object formats, you don’t usually need 220to specify this, as <code>ld</code> should be configured to expect as a 221default input format the most usual format on each machine. 222<var>input-format</var> is a text string, the name of a particular format 223supported by the BFD libraries. (You can list the available binary 224formats with ‘<samp>objdump -i</samp>’.) 225See <a href="BFD.html#BFD">BFD</a>. 226</p> 227<p>You may want to use this option if you are linking files with an unusual 228binary format. You can also use ‘<samp>-b</samp>’ to switch formats explicitly (when 229linking object files of different formats), by including 230‘<samp>-b <var>input-format</var></samp>’ before each group of object files in a 231particular format. 232</p> 233<p>The default format is taken from the environment variable 234<code>GNUTARGET</code>. 235See <a href="Environment.html#Environment">Environment</a>. 236You can also define the input format from a script, using the command 237<code>TARGET</code>; 238see <a href="Format-Commands.html#Format-Commands">Format Commands</a>. 239</p> 240<a name="index-_002dc-MRI_002dcmdfile"></a> 241<a name="index-_002d_002dmri_002dscript_003dMRI_002dcmdfile"></a> 242<a name="index-compatibility_002c-MRI"></a> 243</dd> 244<dt><code>-c <var>MRI-commandfile</var></code></dt> 245<dt><code>--mri-script=<var>MRI-commandfile</var></code></dt> 246<dd><p>For compatibility with linkers produced by MRI, <code>ld</code> accepts script 247files written in an alternate, restricted command language, described in 248<a href="MRI.html#MRI">MRI Compatible Script Files</a>. 249Introduce MRI script files with 250the option ‘<samp>-c</samp>’; use the ‘<samp>-T</samp>’ option to run linker 251scripts written in the general-purpose <code>ld</code> scripting language. 252If <var>MRI-cmdfile</var> does not exist, <code>ld</code> looks for it in the directories 253specified by any ‘<samp>-L</samp>’ options. 254</p> 255<a name="index-common-allocation"></a> 256<a name="index-_002dd"></a> 257<a name="index-_002ddc"></a> 258<a name="index-_002ddp"></a> 259</dd> 260<dt><code>-d</code></dt> 261<dt><code>-dc</code></dt> 262<dt><code>-dp</code></dt> 263<dd><p>These three options are equivalent; multiple forms are supported for 264compatibility with other linkers. They assign space to common symbols 265even if a relocatable output file is specified (with ‘<samp>-r</samp>’). The 266script command <code>FORCE_COMMON_ALLOCATION</code> has the same effect. 267See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>. 268</p> 269<a name="index-_002d_002ddepaudit-AUDITLIB"></a> 270<a name="index-_002dP-AUDITLIB"></a> 271</dd> 272<dt><code>--depaudit <var>AUDITLIB</var></code></dt> 273<dt><code>-P <var>AUDITLIB</var></code></dt> 274<dd><p>Adds <var>AUDITLIB</var> to the <code>DT_DEPAUDIT</code> entry of the dynamic section. 275<var>AUDITLIB</var> is not checked for existence, nor will it use the DT_SONAME 276specified in the library. If specified multiple times <code>DT_DEPAUDIT</code> 277will contain a colon separated list of audit interfaces to use. This 278option is only meaningful on ELF platforms supporting the rtld-audit interface. 279The -P option is provided for Solaris compatibility. 280</p> 281<a name="index-_002d_002denable_002dnon_002dcontiguous_002dregions"></a> 282</dd> 283<dt><code>--enable-non-contiguous-regions</code></dt> 284<dd><p>This option avoids generating an error if an input section does not 285fit a matching output section. The linker tries to allocate the input 286section to subseque nt matching output sections, and generates an 287error only if no output section is large enough. This is useful when 288several non-contiguous memory regions are available and the input 289section does not require a particular one. The order in which input 290sections are evaluated does not change, for instance: 291</p> 292<div class="smallexample"> 293<pre class="smallexample"> MEMORY { 294 MEM1 (rwx) : ORIGIN : 0x1000, LENGTH = 0x14 295 MEM2 (rwx) : ORIGIN : 0x1000, LENGTH = 0x40 296 MEM3 (rwx) : ORIGIN : 0x2000, LENGTH = 0x40 297 } 298 SECTIONS { 299 mem1 : { *(.data.*); } > MEM1 300 mem2 : { *(.data.*); } > MEM2 301 mem3 : { *(.data.*); } > MEM2 302 } 303 304 with input sections: 305 .data.1: size 8 306 .data.2: size 0x10 307 .data.3: size 4 308 309 results in .data.1 affected to mem1, and .data.2 and .data.3 310 affected to mem2, even though .data.3 would fit in mem3. 311</pre></div> 312 313<p>This option is incompatible with INSERT statements because it changes 314the way input sections are mapped to output sections. 315</p> 316<a name="index-_002d_002denable_002dnon_002dcontiguous_002dregions_002dwarnings"></a> 317</dd> 318<dt><code>--enable-non-contiguous-regions-warnings</code></dt> 319<dd><p>This option enables warnings when 320<code>--enable-non-contiguous-regions</code> allows possibly unexpected 321matches in sections mapping, potentially leading to silently 322discarding a section instead of failing because it does not fit any 323output region. 324</p> 325<a name="index-entry-point_002c-from-command-line"></a> 326<a name="index-_002de-entry"></a> 327<a name="index-_002d_002dentry_003dentry"></a> 328</dd> 329<dt><code>-e <var>entry</var></code></dt> 330<dt><code>--entry=<var>entry</var></code></dt> 331<dd><p>Use <var>entry</var> as the explicit symbol for beginning execution of your 332program, rather than the default entry point. If there is no symbol 333named <var>entry</var>, the linker will try to parse <var>entry</var> as a number, 334and use that as the entry address (the number will be interpreted in 335base 10; you may use a leading ‘<samp>0x</samp>’ for base 16, or a leading 336‘<samp>0</samp>’ for base 8). See <a href="Entry-Point.html#Entry-Point">Entry Point</a>, for a discussion of defaults 337and other ways of specifying the entry point. 338</p> 339<a name="index-_002d_002dexclude_002dlibs"></a> 340</dd> 341<dt><code>--exclude-libs <var>lib</var>,<var>lib</var>,...</code></dt> 342<dd><p>Specifies a list of archive libraries from which symbols should not be automatically 343exported. The library names may be delimited by commas or colons. Specifying 344<code>--exclude-libs ALL</code> excludes symbols in all archive libraries from 345automatic export. This option is available only for the i386 PE targeted 346port of the linker and for ELF targeted ports. For i386 PE, symbols 347explicitly listed in a .def file are still exported, regardless of this 348option. For ELF targeted ports, symbols affected by this option will 349be treated as hidden. 350</p> 351<a name="index-_002d_002dexclude_002dmodules_002dfor_002dimplib"></a> 352</dd> 353<dt><code>--exclude-modules-for-implib <var>module</var>,<var>module</var>,...</code></dt> 354<dd><p>Specifies a list of object files or archive members, from which symbols 355should not be automatically exported, but which should be copied wholesale 356into the import library being generated during the link. The module names 357may be delimited by commas or colons, and must match exactly the filenames 358used by <code>ld</code> to open the files; for archive members, this is simply 359the member name, but for object files the name listed must include and 360match precisely any path used to specify the input file on the linker’s 361command-line. This option is available only for the i386 PE targeted port 362of the linker. Symbols explicitly listed in a .def file are still exported, 363regardless of this option. 364</p> 365<a name="index-dynamic-symbol-table"></a> 366<a name="index-_002dE"></a> 367<a name="index-_002d_002dexport_002ddynamic"></a> 368<a name="index-_002d_002dno_002dexport_002ddynamic"></a> 369</dd> 370<dt><code>-E</code></dt> 371<dt><code>--export-dynamic</code></dt> 372<dt><code>--no-export-dynamic</code></dt> 373<dd><p>When creating a dynamically linked executable, using the <samp>-E</samp> 374option or the <samp>--export-dynamic</samp> option causes the linker to add 375all symbols to the dynamic symbol table. The dynamic symbol table is the 376set of symbols which are visible from dynamic objects at run time. 377</p> 378<p>If you do not use either of these options (or use the 379<samp>--no-export-dynamic</samp> option to restore the default behavior), the 380dynamic symbol table will normally contain only those symbols which are 381referenced by some dynamic object mentioned in the link. 382</p> 383<p>If you use <code>dlopen</code> to load a dynamic object which needs to refer 384back to the symbols defined by the program, rather than some other 385dynamic object, then you will probably need to use this option when 386linking the program itself. 387</p> 388<p>You can also use the dynamic list to control what symbols should 389be added to the dynamic symbol table if the output format supports it. 390See the description of ‘<samp>--dynamic-list</samp>’. 391</p> 392<p>Note that this option is specific to ELF targeted ports. PE targets 393support a similar function to export all symbols from a DLL or EXE; see 394the description of ‘<samp>--export-all-symbols</samp>’ below. 395</p> 396<a name="index-_002d_002dexport_002ddynamic_002dsymbol_003dglob"></a> 397<a name="index-export-dynamic-symbol"></a> 398</dd> 399<dt><code>--export-dynamic-symbol=<var>glob</var></code></dt> 400<dd><p>When creating a dynamically linked executable, symbols matching 401<var>glob</var> will be added to the dynamic symbol table. When creating a 402shared library, references to symbols matching <var>glob</var> will not be 403bound to the definitions within the shared library. This option is a 404no-op when creating a shared library and ‘<samp>-Bsymbolic</samp>’ or 405‘<samp>--dynamic-list</samp>’ are not specified. This option is only meaningful 406on ELF platforms which support shared libraries. 407</p> 408<a name="index-_002d_002dexport_002ddynamic_002dsymbol_002dlist_003dfile"></a> 409<a name="index-export-dynamic-symbol-list"></a> 410</dd> 411<dt><code>--export-dynamic-symbol-list=<var>file</var></code></dt> 412<dd><p>Specify a ‘<samp>--export-dynamic-symbol</samp>’ for each pattern in the file. 413The format of the file is the same as the version node without 414scope and node name. See <a href="VERSION.html#VERSION">VERSION</a> for more information. 415</p> 416<a name="index-big_002dendian-objects"></a> 417<a name="index-endianness"></a> 418<a name="index-_002dEB"></a> 419</dd> 420<dt><code>-EB</code></dt> 421<dd><p>Link big-endian objects. This affects the default output format. 422</p> 423<a name="index-little_002dendian-objects"></a> 424<a name="index-_002dEL"></a> 425</dd> 426<dt><code>-EL</code></dt> 427<dd><p>Link little-endian objects. This affects the default output format. 428</p> 429<a name="index-_002df-name"></a> 430<a name="index-_002d_002dauxiliary_003dname"></a> 431</dd> 432<dt><code>-f <var>name</var></code></dt> 433<dt><code>--auxiliary=<var>name</var></code></dt> 434<dd><p>When creating an ELF shared object, set the internal DT_AUXILIARY field 435to the specified name. This tells the dynamic linker that the symbol 436table of the shared object should be used as an auxiliary filter on the 437symbol table of the shared object <var>name</var>. 438</p> 439<p>If you later link a program against this filter object, then, when you 440run the program, the dynamic linker will see the DT_AUXILIARY field. If 441the dynamic linker resolves any symbols from the filter object, it will 442first check whether there is a definition in the shared object 443<var>name</var>. If there is one, it will be used instead of the definition 444in the filter object. The shared object <var>name</var> need not exist. 445Thus the shared object <var>name</var> may be used to provide an alternative 446implementation of certain functions, perhaps for debugging or for 447machine-specific performance. 448</p> 449<p>This option may be specified more than once. The DT_AUXILIARY entries 450will be created in the order in which they appear on the command line. 451</p> 452<a name="index-_002dF-name"></a> 453<a name="index-_002d_002dfilter_003dname"></a> 454</dd> 455<dt><code>-F <var>name</var></code></dt> 456<dt><code>--filter=<var>name</var></code></dt> 457<dd><p>When creating an ELF shared object, set the internal DT_FILTER field to 458the specified name. This tells the dynamic linker that the symbol table 459of the shared object which is being created should be used as a filter 460on the symbol table of the shared object <var>name</var>. 461</p> 462<p>If you later link a program against this filter object, then, when you 463run the program, the dynamic linker will see the DT_FILTER field. The 464dynamic linker will resolve symbols according to the symbol table of the 465filter object as usual, but it will actually link to the definitions 466found in the shared object <var>name</var>. Thus the filter object can be 467used to select a subset of the symbols provided by the object 468<var>name</var>. 469</p> 470<p>Some older linkers used the <samp>-F</samp> option throughout a compilation 471toolchain for specifying object-file format for both input and output 472object files. 473The <small>GNU</small> linker uses other mechanisms for this purpose: the 474<samp>-b</samp>, <samp>--format</samp>, <samp>--oformat</samp> options, the 475<code>TARGET</code> command in linker scripts, and the <code>GNUTARGET</code> 476environment variable. 477The <small>GNU</small> linker will ignore the <samp>-F</samp> option when not 478creating an ELF shared object. 479</p> 480<a name="index-finalization-function"></a> 481<a name="index-_002dfini_003dname"></a> 482</dd> 483<dt><code>-fini=<var>name</var></code></dt> 484<dd><p>When creating an ELF executable or shared object, call NAME when the 485executable or shared object is unloaded, by setting DT_FINI to the 486address of the function. By default, the linker uses <code>_fini</code> as 487the function to call. 488</p> 489<a name="index-_002dg"></a> 490</dd> 491<dt><code>-g</code></dt> 492<dd><p>Ignored. Provided for compatibility with other tools. 493</p> 494<a name="index-_002dG-value"></a> 495<a name="index-_002d_002dgpsize_003dvalue"></a> 496<a name="index-object-size"></a> 497</dd> 498<dt><code>-G <var>value</var></code></dt> 499<dt><code>--gpsize=<var>value</var></code></dt> 500<dd><p>Set the maximum size of objects to be optimized using the GP register to 501<var>size</var>. This is only meaningful for object file formats such as 502MIPS ELF that support putting large and small objects into different 503sections. This is ignored for other object file formats. 504</p> 505<a name="index-runtime-library-name"></a> 506<a name="index-_002dh-name"></a> 507<a name="index-_002dsoname_003dname"></a> 508</dd> 509<dt><code>-h <var>name</var></code></dt> 510<dt><code>-soname=<var>name</var></code></dt> 511<dd><p>When creating an ELF shared object, set the internal DT_SONAME field to 512the specified name. When an executable is linked with a shared object 513which has a DT_SONAME field, then when the executable is run the dynamic 514linker will attempt to load the shared object specified by the DT_SONAME 515field rather than the using the file name given to the linker. 516</p> 517<a name="index-_002di"></a> 518<a name="index-incremental-link"></a> 519</dd> 520<dt><code>-i</code></dt> 521<dd><p>Perform an incremental link (same as option ‘<samp>-r</samp>’). 522</p> 523<a name="index-initialization-function"></a> 524<a name="index-_002dinit_003dname"></a> 525</dd> 526<dt><code>-init=<var>name</var></code></dt> 527<dd><p>When creating an ELF executable or shared object, call NAME when the 528executable or shared object is loaded, by setting DT_INIT to the address 529of the function. By default, the linker uses <code>_init</code> as the 530function to call. 531</p> 532<a name="index-archive-files_002c-from-cmd-line"></a> 533<a name="index-_002dl-namespec"></a> 534<a name="index-_002d_002dlibrary_003dnamespec"></a> 535</dd> 536<dt><code>-l <var>namespec</var></code></dt> 537<dt><code>--library=<var>namespec</var></code></dt> 538<dd><p>Add the archive or object file specified by <var>namespec</var> to the 539list of files to link. This option may be used any number of times. 540If <var>namespec</var> is of the form <samp>:<var>filename</var></samp>, <code>ld</code> 541will search the library path for a file called <var>filename</var>, otherwise it 542will search the library path for a file called <samp>lib<var>namespec</var>.a</samp>. 543</p> 544<p>On systems which support shared libraries, <code>ld</code> may also search for 545files other than <samp>lib<var>namespec</var>.a</samp>. Specifically, on ELF 546and SunOS systems, <code>ld</code> will search a directory for a library 547called <samp>lib<var>namespec</var>.so</samp> before searching for one called 548<samp>lib<var>namespec</var>.a</samp>. (By convention, a <code>.so</code> extension 549indicates a shared library.) Note that this behavior does not apply 550to <samp>:<var>filename</var></samp>, which always specifies a file called 551<var>filename</var>. 552</p> 553<p>The linker will search an archive only once, at the location where it is 554specified on the command line. If the archive defines a symbol which 555was undefined in some object which appeared before the archive on the 556command line, the linker will include the appropriate file(s) from the 557archive. However, an undefined symbol in an object appearing later on 558the command line will not cause the linker to search the archive again. 559</p> 560<p>See the <samp>-(</samp> option for a way to force the linker to search 561archives multiple times. 562</p> 563<p>You may list the same archive multiple times on the command line. 564</p> 565<p>This type of archive searching is standard for Unix linkers. However, 566if you are using <code>ld</code> on AIX, note that it is different from the 567behaviour of the AIX linker. 568</p> 569<a name="index-search-directory_002c-from-cmd-line"></a> 570<a name="index-_002dL-dir"></a> 571<a name="index-_002d_002dlibrary_002dpath_003ddir"></a> 572</dd> 573<dt><code>-L <var>searchdir</var></code></dt> 574<dt><code>--library-path=<var>searchdir</var></code></dt> 575<dd><p>Add path <var>searchdir</var> to the list of paths that <code>ld</code> will search 576for archive libraries and <code>ld</code> control scripts. You may use this 577option any number of times. The directories are searched in the order 578in which they are specified on the command line. Directories specified 579on the command line are searched before the default directories. All 580<samp>-L</samp> options apply to all <samp>-l</samp> options, regardless of the 581order in which the options appear. <samp>-L</samp> options do not affect 582how <code>ld</code> searches for a linker script unless <samp>-T</samp> 583option is specified. 584</p> 585<p>If <var>searchdir</var> begins with <code>=</code> or <code>$SYSROOT</code>, then this 586prefix will be replaced by the <em>sysroot prefix</em>, controlled by the 587‘<samp>--sysroot</samp>’ option, or specified when the linker is configured. 588</p> 589<p>The default set of paths searched (without being specified with 590‘<samp>-L</samp>’) depends on which emulation mode <code>ld</code> is using, and in 591some cases also on how it was configured. See <a href="Environment.html#Environment">Environment</a>. 592</p> 593<p>The paths can also be specified in a link script with the 594<code>SEARCH_DIR</code> command. Directories specified this way are searched 595at the point in which the linker script appears in the command line. 596</p> 597<a name="index-emulation"></a> 598<a name="index-_002dm-emulation"></a> 599</dd> 600<dt><code>-m <var>emulation</var></code></dt> 601<dd><p>Emulate the <var>emulation</var> linker. You can list the available 602emulations with the ‘<samp>--verbose</samp>’ or ‘<samp>-V</samp>’ options. 603</p> 604<p>If the ‘<samp>-m</samp>’ option is not used, the emulation is taken from the 605<code>LDEMULATION</code> environment variable, if that is defined. 606</p> 607<p>Otherwise, the default emulation depends upon how the linker was 608configured. 609</p> 610<a name="index-link-map"></a> 611<a name="index-_002dM"></a> 612<a name="index-_002d_002dprint_002dmap"></a> 613</dd> 614<dt><code>-M</code></dt> 615<dt><code>--print-map</code></dt> 616<dd><p>Print a link map to the standard output. A link map provides 617information about the link, including the following: 618</p> 619<ul> 620<li> Where object files are mapped into memory. 621</li><li> How common symbols are allocated. 622</li><li> All archive members included in the link, with a mention of the symbol 623which caused the archive member to be brought in. 624</li><li> The values assigned to symbols. 625 626<p>Note - symbols whose values are computed by an expression which 627involves a reference to a previous value of the same symbol may not 628have correct result displayed in the link map. This is because the 629linker discards intermediate results and only retains the final value 630of an expression. Under such circumstances the linker will display 631the final value enclosed by square brackets. Thus for example a 632linker script containing: 633</p> 634<div class="smallexample"> 635<pre class="smallexample"> foo = 1 636 foo = foo * 4 637 foo = foo + 8 638</pre></div> 639 640<p>will produce the following output in the link map if the <samp>-M</samp> 641option is used: 642</p> 643<div class="smallexample"> 644<pre class="smallexample"> 0x00000001 foo = 0x1 645 [0x0000000c] foo = (foo * 0x4) 646 [0x0000000c] foo = (foo + 0x8) 647</pre></div> 648 649<p>See <a href="Expressions.html#Expressions">Expressions</a> for more information about expressions in linker 650scripts. 651</p> 652</li><li> How GNU properties are merged. 653 654<p>When the linker merges input .note.gnu.property sections into one output 655.note.gnu.property section, some properties are removed or updated. 656These actions are reported in the link map. For example: 657</p> 658<div class="smallexample"> 659<pre class="smallexample">Removed property 0xc0000002 to merge foo.o (0x1) and bar.o (not found) 660</pre></div> 661 662<p>This indicates that property 0xc0000002 is removed from output when 663merging properties in <samp>foo.o</samp>, whose property 0xc0000002 value 664is 0x1, and <samp>bar.o</samp>, which doesn’t have property 0xc0000002. 665</p> 666<div class="smallexample"> 667<pre class="smallexample">Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1) 668</pre></div> 669 670<p>This indicates that property 0xc0010001 value is updated to 0x1 in output 671when merging properties in <samp>foo.o</samp>, whose 0xc0010001 property value 672is 0x1, and <samp>bar.o</samp>, whose 0xc0010001 property value is 0x1. 673</p></li></ul> 674 675<a name="index-link-map-discarded"></a> 676<a name="index-_002d_002dprint_002dmap_002ddiscarded"></a> 677<a name="index-_002d_002dno_002dprint_002dmap_002ddiscarded"></a> 678</dd> 679<dt><code>--print-map-discarded</code></dt> 680<dt><code>--no-print-map-discarded</code></dt> 681<dd><p>Print (or do not print) the list of discarded and garbage collected sections 682in the link map. Enabled by default. 683</p> 684<a name="index-_002dn"></a> 685<a name="index-read_002donly-text"></a> 686<a name="index-NMAGIC"></a> 687<a name="index-_002d_002dnmagic"></a> 688</dd> 689<dt><code>-n</code></dt> 690<dt><code>--nmagic</code></dt> 691<dd><p>Turn off page alignment of sections, and disable linking against shared 692libraries. If the output format supports Unix style magic numbers, 693mark the output as <code>NMAGIC</code>. 694</p> 695<a name="index-_002dN"></a> 696<a name="index-_002d_002domagic"></a> 697<a name="index-read_002fwrite-from-cmd-line"></a> 698<a name="index-OMAGIC"></a> 699</dd> 700<dt><code>-N</code></dt> 701<dt><code>--omagic</code></dt> 702<dd><p>Set the text and data sections to be readable and writable. Also, do 703not page-align the data segment, and disable linking against shared 704libraries. If the output format supports Unix style magic numbers, 705mark the output as <code>OMAGIC</code>. Note: Although a writable text section 706is allowed for PE-COFF targets, it does not conform to the format 707specification published by Microsoft. 708</p> 709<a name="index-_002d_002dno_002domagic"></a> 710<a name="index-OMAGIC-1"></a> 711</dd> 712<dt><code>--no-omagic</code></dt> 713<dd><p>This option negates most of the effects of the <samp>-N</samp> option. It 714sets the text section to be read-only, and forces the data segment to 715be page-aligned. Note - this option does not enable linking against 716shared libraries. Use <samp>-Bdynamic</samp> for this. 717</p> 718<a name="index-_002do-output"></a> 719<a name="index-_002d_002doutput_003doutput"></a> 720<a name="index-naming-the-output-file"></a> 721</dd> 722<dt><code>-o <var>output</var></code></dt> 723<dt><code>--output=<var>output</var></code></dt> 724<dd><p>Use <var>output</var> as the name for the program produced by <code>ld</code>; if this 725option is not specified, the name <samp>a.out</samp> is used by default. The 726script command <code>OUTPUT</code> can also specify the output file name. 727</p> 728<a name="index-_002d_002ddependency_002dfile_003ddepfile"></a> 729<a name="index-dependency-file"></a> 730</dd> 731<dt><code>--dependency-file=<var>depfile</var></code></dt> 732<dd><p>Write a <em>dependency file</em> to <var>depfile</var>. This file contains a rule 733suitable for <code>make</code> describing the output file and all the input files 734that were read to produce it. The output is similar to the compiler’s 735output with ‘<samp>-M -MP</samp>’ (see <a href="http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options">Options 736Controlling the Preprocessor</a> in <cite>Using the GNU Compiler 737Collection</cite>). Note that there is no option like the compiler’s ‘<samp>-MM</samp>’, 738to exclude “system files” (which is not a well-specified concept in the 739linker, unlike “system headers” in the compiler). So the output from 740‘<samp>--dependency-file</samp>’ is always specific to the exact state of the 741installation where it was produced, and should not be copied into 742distributed makefiles without careful editing. 743</p> 744<a name="index-_002dO-level"></a> 745<a name="index-generating-optimized-output"></a> 746</dd> 747<dt><code>-O <var>level</var></code></dt> 748<dd><p>If <var>level</var> is a numeric values greater than zero <code>ld</code> optimizes 749the output. This might take significantly longer and therefore probably 750should only be enabled for the final binary. At the moment this 751option only affects ELF shared library generation. Future releases of 752the linker may make more use of this option. Also currently there is 753no difference in the linker’s behaviour for different non-zero values 754of this option. Again this may change with future releases. 755</p> 756<a name="index-_002dplugin-name"></a> 757</dd> 758<dt><code>-plugin <var>name</var></code></dt> 759<dd><p>Involve a plugin in the linking process. The <var>name</var> parameter is 760the absolute filename of the plugin. Usually this parameter is 761automatically added by the complier, when using link time 762optimization, but users can also add their own plugins if they so 763wish. 764</p> 765<p>Note that the location of the compiler originated plugins is different 766from the place where the <code>ar</code>, <code>nm</code> and 767<code>ranlib</code> programs search for their plugins. In order for 768those commands to make use of a compiler based plugin it must first be 769copied into the <samp>${libdir}/bfd-plugins</samp> directory. All gcc 770based linker plugins are backward compatible, so it is sufficient to 771just copy in the newest one. 772</p> 773<a name="index-_002d_002dpush_002dstate"></a> 774<a name="index-push-state-governing-input-file-handling"></a> 775</dd> 776<dt><code>--push-state</code></dt> 777<dd><p>The <samp>--push-state</samp> allows one to preserve the current state of the 778flags which govern the input file handling so that they can all be 779restored with one corresponding <samp>--pop-state</samp> option. 780</p> 781<p>The option which are covered are: <samp>-Bdynamic</samp>, <samp>-Bstatic</samp>, 782<samp>-dn</samp>, <samp>-dy</samp>, <samp>-call_shared</samp>, <samp>-non_shared</samp>, 783<samp>-static</samp>, <samp>-N</samp>, <samp>-n</samp>, <samp>--whole-archive</samp>, 784<samp>--no-whole-archive</samp>, <samp>-r</samp>, <samp>-Ur</samp>, 785<samp>--copy-dt-needed-entries</samp>, <samp>--no-copy-dt-needed-entries</samp>, 786<samp>--as-needed</samp>, <samp>--no-as-needed</samp>, and <samp>-a</samp>. 787</p> 788<p>One target for this option are specifications for <samp>pkg-config</samp>. When 789used with the <samp>--libs</samp> option all possibly needed libraries are 790listed and then possibly linked with all the time. It is better to return 791something as follows: 792</p> 793<div class="smallexample"> 794<pre class="smallexample">-Wl,--push-state,--as-needed -libone -libtwo -Wl,--pop-state 795</pre></div> 796 797<a name="index-_002d_002dpop_002dstate"></a> 798<a name="index-pop-state-governing-input-file-handling"></a> 799</dd> 800<dt><code>--pop-state</code></dt> 801<dd><p>Undoes the effect of –push-state, restores the previous values of the 802flags governing input file handling. 803</p> 804<a name="index-_002dq"></a> 805<a name="index-_002d_002demit_002drelocs"></a> 806<a name="index-retain-relocations-in-final-executable"></a> 807</dd> 808<dt><code>-q</code></dt> 809<dt><code>--emit-relocs</code></dt> 810<dd><p>Leave relocation sections and contents in fully linked executables. 811Post link analysis and optimization tools may need this information in 812order to perform correct modifications of executables. This results 813in larger executables. 814</p> 815<p>This option is currently only supported on ELF platforms. 816</p> 817<a name="index-_002d_002dforce_002ddynamic"></a> 818<a name="index-forcing-the-creation-of-dynamic-sections"></a> 819</dd> 820<dt><code>--force-dynamic</code></dt> 821<dd><p>Force the output file to have dynamic sections. This option is specific 822to VxWorks targets. 823</p> 824<a name="index-partial-link"></a> 825<a name="index-relocatable-output"></a> 826<a name="index-_002dr"></a> 827<a name="index-_002d_002drelocatable"></a> 828</dd> 829<dt><code>-r</code></dt> 830<dt><code>--relocatable</code></dt> 831<dd><p>Generate relocatable output—i.e., generate an output file that can in 832turn serve as input to <code>ld</code>. This is often called <em>partial 833linking</em>. As a side effect, in environments that support standard Unix 834magic numbers, this option also sets the output file’s magic number to 835<code>OMAGIC</code>. 836If this option is not specified, an absolute file is produced. When 837linking C++ programs, this option <em>will not</em> resolve references to 838constructors; to do that, use ‘<samp>-Ur</samp>’. 839</p> 840<p>When an input file does not have the same format as the output file, 841partial linking is only supported if that input file does not contain any 842relocations. Different output formats can have further restrictions; for 843example some <code>a.out</code>-based formats do not support partial linking 844with input files in other formats at all. 845</p> 846<p>This option does the same thing as ‘<samp>-i</samp>’. 847</p> 848<a name="index-_002dR-file"></a> 849<a name="index-_002d_002djust_002dsymbols_003dfile"></a> 850<a name="index-symbol_002donly-input"></a> 851</dd> 852<dt><code>-R <var>filename</var></code></dt> 853<dt><code>--just-symbols=<var>filename</var></code></dt> 854<dd><p>Read symbol names and their addresses from <var>filename</var>, but do not 855relocate it or include it in the output. This allows your output file 856to refer symbolically to absolute locations of memory defined in other 857programs. You may use this option more than once. 858</p> 859<p>For compatibility with other ELF linkers, if the <samp>-R</samp> option is 860followed by a directory name, rather than a file name, it is treated as 861the <samp>-rpath</samp> option. 862</p> 863<a name="index-_002ds"></a> 864<a name="index-_002d_002dstrip_002dall"></a> 865<a name="index-strip-all-symbols"></a> 866</dd> 867<dt><code>-s</code></dt> 868<dt><code>--strip-all</code></dt> 869<dd><p>Omit all symbol information from the output file. 870</p> 871<a name="index-_002dS"></a> 872<a name="index-_002d_002dstrip_002ddebug"></a> 873<a name="index-strip-debugger-symbols"></a> 874</dd> 875<dt><code>-S</code></dt> 876<dt><code>--strip-debug</code></dt> 877<dd><p>Omit debugger symbol information (but not all symbols) from the output file. 878</p> 879<a name="index-_002d_002dstrip_002ddiscarded"></a> 880<a name="index-_002d_002dno_002dstrip_002ddiscarded"></a> 881</dd> 882<dt><code>--strip-discarded</code></dt> 883<dt><code>--no-strip-discarded</code></dt> 884<dd><p>Omit (or do not omit) global symbols defined in discarded sections. 885Enabled by default. 886</p> 887<a name="index-_002dt"></a> 888<a name="index-_002d_002dtrace"></a> 889<a name="index-input-files_002c-displaying"></a> 890</dd> 891<dt><code>-t</code></dt> 892<dt><code>--trace</code></dt> 893<dd><p>Print the names of the input files as <code>ld</code> processes them. If 894‘<samp>-t</samp>’ is given twice then members within archives are also printed. 895‘<samp>-t</samp>’ output is useful to generate a list of all the object files 896and scripts involved in linking, for example, when packaging files for 897a linker bug report. 898</p> 899<a name="index-_002dT-script"></a> 900<a name="index-_002d_002dscript_003dscript"></a> 901<a name="index-script-files"></a> 902</dd> 903<dt><code>-T <var>scriptfile</var></code></dt> 904<dt><code>--script=<var>scriptfile</var></code></dt> 905<dd><p>Use <var>scriptfile</var> as the linker script. This script replaces 906<code>ld</code>’s default linker script (rather than adding to it), so 907<var>commandfile</var> must specify everything necessary to describe the 908output file. See <a href="Scripts.html#Scripts">Scripts</a>. If <var>scriptfile</var> does not exist in 909the current directory, <code>ld</code> looks for it in the directories 910specified by any preceding ‘<samp>-L</samp>’ options. Multiple ‘<samp>-T</samp>’ 911options accumulate. 912</p> 913<a name="index-_002ddT-script"></a> 914<a name="index-_002d_002ddefault_002dscript_003dscript"></a> 915<a name="index-script-files-1"></a> 916</dd> 917<dt><code>-dT <var>scriptfile</var></code></dt> 918<dt><code>--default-script=<var>scriptfile</var></code></dt> 919<dd><p>Use <var>scriptfile</var> as the default linker script. See <a href="Scripts.html#Scripts">Scripts</a>. 920</p> 921<p>This option is similar to the <samp>--script</samp> option except that 922processing of the script is delayed until after the rest of the 923command line has been processed. This allows options placed after the 924<samp>--default-script</samp> option on the command line to affect the 925behaviour of the linker script, which can be important when the linker 926command line cannot be directly controlled by the user. (eg because 927the command line is being constructed by another tool, such as 928‘<samp>gcc</samp>’). 929</p> 930<a name="index-_002du-symbol"></a> 931<a name="index-_002d_002dundefined_003dsymbol"></a> 932<a name="index-undefined-symbol"></a> 933</dd> 934<dt><code>-u <var>symbol</var></code></dt> 935<dt><code>--undefined=<var>symbol</var></code></dt> 936<dd><p>Force <var>symbol</var> to be entered in the output file as an undefined 937symbol. Doing this may, for example, trigger linking of additional 938modules from standard libraries. ‘<samp>-u</samp>’ may be repeated with 939different option arguments to enter additional undefined symbols. This 940option is equivalent to the <code>EXTERN</code> linker script command. 941</p> 942<p>If this option is being used to force additional modules to be pulled 943into the link, and if it is an error for the symbol to remain 944undefined, then the option <samp>--require-defined</samp> should be used 945instead. 946</p> 947<a name="index-_002d_002drequire_002ddefined_003dsymbol"></a> 948<a name="index-symbols_002c-require-defined"></a> 949<a name="index-defined-symbol"></a> 950</dd> 951<dt><code>--require-defined=<var>symbol</var></code></dt> 952<dd><p>Require that <var>symbol</var> is defined in the output file. This option 953is the same as option <samp>--undefined</samp> except that if <var>symbol</var> 954is not defined in the output file then the linker will issue an error 955and exit. The same effect can be achieved in a linker script by using 956<code>EXTERN</code>, <code>ASSERT</code> and <code>DEFINED</code> together. This option 957can be used multiple times to require additional symbols. 958</p> 959<a name="index-_002dUr"></a> 960<a name="index-constructors"></a> 961</dd> 962<dt><code>-Ur</code></dt> 963<dd><p>For anything other than C++ programs, this option is equivalent to 964‘<samp>-r</samp>’: it generates relocatable output—i.e., an output file that can in 965turn serve as input to <code>ld</code>. When linking C++ programs, ‘<samp>-Ur</samp>’ 966<em>does</em> resolve references to constructors, unlike ‘<samp>-r</samp>’. 967It does not work to use ‘<samp>-Ur</samp>’ on files that were themselves linked 968with ‘<samp>-Ur</samp>’; once the constructor table has been built, it cannot 969be added to. Use ‘<samp>-Ur</samp>’ only for the last partial link, and 970‘<samp>-r</samp>’ for the others. 971</p> 972<a name="index-_002d_002dorphan_002dhandling_003dMODE"></a> 973<a name="index-orphan-sections"></a> 974<a name="index-sections_002c-orphan"></a> 975</dd> 976<dt><code>--orphan-handling=<var>MODE</var></code></dt> 977<dd><p>Control how orphan sections are handled. An orphan section is one not 978specifically mentioned in a linker script. See <a href="Orphan-Sections.html#Orphan-Sections">Orphan Sections</a>. 979</p> 980<p><var>MODE</var> can have any of the following values: 981</p> 982<dl compact="compact"> 983<dt><code>place</code></dt> 984<dd><p>Orphan sections are placed into a suitable output section following 985the strategy described in <a href="Orphan-Sections.html#Orphan-Sections">Orphan Sections</a>. The option 986‘<samp>--unique</samp>’ also affects how sections are placed. 987</p> 988</dd> 989<dt><code>discard</code></dt> 990<dd><p>All orphan sections are discarded, by placing them in the 991‘<samp>/DISCARD/</samp>’ section (see <a href="Output-Section-Discarding.html#Output-Section-Discarding">Output Section Discarding</a>). 992</p> 993</dd> 994<dt><code>warn</code></dt> 995<dd><p>The linker will place the orphan section as for <code>place</code> and also 996issue a warning. 997</p> 998</dd> 999<dt><code>error</code></dt> 1000<dd><p>The linker will exit with an error if any orphan section is found. 1001</p></dd> 1002</dl> 1003 1004<p>The default if ‘<samp>--orphan-handling</samp>’ is not given is <code>place</code>. 1005</p> 1006<a name="index-_002d_002dunique_005b_003dSECTION_005d"></a> 1007</dd> 1008<dt><code>--unique[=<var>SECTION</var>]</code></dt> 1009<dd><p>Creates a separate output section for every input section matching 1010<var>SECTION</var>, or if the optional wildcard <var>SECTION</var> argument is 1011missing, for every orphan input section. An orphan section is one not 1012specifically mentioned in a linker script. You may use this option 1013multiple times on the command line; It prevents the normal merging of 1014input sections with the same name, overriding output section assignments 1015in a linker script. 1016</p> 1017<a name="index-_002dv"></a> 1018<a name="index-_002dV"></a> 1019<a name="index-_002d_002dversion"></a> 1020<a name="index-version"></a> 1021</dd> 1022<dt><code>-v</code></dt> 1023<dt><code>--version</code></dt> 1024<dt><code>-V</code></dt> 1025<dd><p>Display the version number for <code>ld</code>. The <samp>-V</samp> option also 1026lists the supported emulations. 1027</p> 1028<a name="index-_002dx"></a> 1029<a name="index-_002d_002ddiscard_002dall"></a> 1030<a name="index-deleting-local-symbols"></a> 1031</dd> 1032<dt><code>-x</code></dt> 1033<dt><code>--discard-all</code></dt> 1034<dd><p>Delete all local symbols. 1035</p> 1036<a name="index-_002dX"></a> 1037<a name="index-_002d_002ddiscard_002dlocals"></a> 1038<a name="index-local-symbols_002c-deleting"></a> 1039</dd> 1040<dt><code>-X</code></dt> 1041<dt><code>--discard-locals</code></dt> 1042<dd><p>Delete all temporary local symbols. (These symbols start with 1043system-specific local label prefixes, typically ‘<samp>.L</samp>’ for ELF systems 1044or ‘<samp>L</samp>’ for traditional a.out systems.) 1045</p> 1046<a name="index-_002dy-symbol"></a> 1047<a name="index-_002d_002dtrace_002dsymbol_003dsymbol"></a> 1048<a name="index-symbol-tracing"></a> 1049</dd> 1050<dt><code>-y <var>symbol</var></code></dt> 1051<dt><code>--trace-symbol=<var>symbol</var></code></dt> 1052<dd><p>Print the name of each linked file in which <var>symbol</var> appears. This 1053option may be given any number of times. On many systems it is necessary 1054to prepend an underscore. 1055</p> 1056<p>This option is useful when you have an undefined symbol in your link but 1057don’t know where the reference is coming from. 1058</p> 1059<a name="index-_002dY-path"></a> 1060</dd> 1061<dt><code>-Y <var>path</var></code></dt> 1062<dd><p>Add <var>path</var> to the default library search path. This option exists 1063for Solaris compatibility. 1064</p> 1065<a name="index-_002dz-keyword"></a> 1066</dd> 1067<dt><code>-z <var>keyword</var></code></dt> 1068<dd><p>The recognized keywords are: 1069</p><dl compact="compact"> 1070<dt>‘<samp>bndplt</samp>’</dt> 1071<dd><p>Always generate BND prefix in PLT entries. Supported for Linux/x86_64. 1072</p> 1073</dd> 1074<dt>‘<samp>call-nop=prefix-addr</samp>’</dt> 1075<dt>‘<samp>call-nop=suffix-nop</samp>’</dt> 1076<dt>‘<samp>call-nop=prefix-<var>byte</var></samp>’</dt> 1077<dt>‘<samp>call-nop=suffix-<var>byte</var></samp>’</dt> 1078<dd><p>Specify the 1-byte <code>NOP</code> padding when transforming indirect call 1079to a locally defined function, foo, via its GOT slot. 1080<samp>call-nop=prefix-addr</samp> generates <code>0x67 call foo</code>. 1081<samp>call-nop=suffix-nop</samp> generates <code>call foo 0x90</code>. 1082<samp>call-nop=prefix-<var>byte</var></samp> generates <code><var>byte</var> call foo</code>. 1083<samp>call-nop=suffix-<var>byte</var></samp> generates <code>call foo <var>byte</var></code>. 1084Supported for i386 and x86_64. 1085</p> 1086</dd> 1087<dt>‘<samp>cet-report=none</samp>’</dt> 1088<dt>‘<samp>cet-report=warning</samp>’</dt> 1089<dt>‘<samp>cet-report=error</samp>’</dt> 1090<dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT and 1091GNU_PROPERTY_X86_FEATURE_1_SHSTK properties in input .note.gnu.property 1092section. <samp>cet-report=none</samp>, which is the default, will make the 1093linker not report missing properties in input files. 1094<samp>cet-report=warning</samp> will make the linker issue a warning for 1095missing properties in input files. <samp>cet-report=error</samp> will make 1096the linker issue an error for missing properties in input files. 1097Note that <samp>ibt</samp> will turn off the missing 1098GNU_PROPERTY_X86_FEATURE_1_IBT property report and <samp>shstk</samp> will 1099turn off the missing GNU_PROPERTY_X86_FEATURE_1_SHSTK property report. 1100Supported for Linux/i386 and Linux/x86_64. 1101</p> 1102</dd> 1103<dt>‘<samp>combreloc</samp>’</dt> 1104<dt>‘<samp>nocombreloc</samp>’</dt> 1105<dd><p>Combine multiple dynamic relocation sections and sort to improve 1106dynamic symbol lookup caching. Do not do this if ‘<samp>nocombreloc</samp>’. 1107</p> 1108</dd> 1109<dt>‘<samp>common</samp>’</dt> 1110<dt>‘<samp>nocommon</samp>’</dt> 1111<dd><p>Generate common symbols with STT_COMMON type during a relocatable 1112link. Use STT_OBJECT type if ‘<samp>nocommon</samp>’. 1113</p> 1114</dd> 1115<dt>‘<samp>common-page-size=<var>value</var></samp>’</dt> 1116<dd><p>Set the page size most commonly used to <var>value</var>. Memory image 1117layout will be optimized to minimize memory pages if the system is 1118using pages of this size. 1119</p> 1120</dd> 1121<dt>‘<samp>defs</samp>’</dt> 1122<dd><p>Report unresolved symbol references from regular object files. This 1123is done even if the linker is creating a non-symbolic shared library. 1124This option is the inverse of ‘<samp>-z undefs</samp>’. 1125</p> 1126</dd> 1127<dt>‘<samp>dynamic-undefined-weak</samp>’</dt> 1128<dt>‘<samp>nodynamic-undefined-weak</samp>’</dt> 1129<dd><p>Make undefined weak symbols dynamic when building a dynamic object, 1130if they are referenced from a regular object file and not forced local 1131by symbol visibility or versioning. Do not make them dynamic if 1132‘<samp>nodynamic-undefined-weak</samp>’. If neither option is given, a target 1133may default to either option being in force, or make some other 1134selection of undefined weak symbols dynamic. Not all targets support 1135these options. 1136</p> 1137</dd> 1138<dt>‘<samp>execstack</samp>’</dt> 1139<dd><p>Marks the object as requiring executable stack. 1140</p> 1141</dd> 1142<dt>‘<samp>global</samp>’</dt> 1143<dd><p>This option is only meaningful when building a shared object. It makes 1144the symbols defined by this shared object available for symbol resolution 1145of subsequently loaded libraries. 1146</p> 1147</dd> 1148<dt>‘<samp>globalaudit</samp>’</dt> 1149<dd><p>This option is only meaningful when building a dynamic executable. 1150This option marks the executable as requiring global auditing by 1151setting the <code>DF_1_GLOBAUDIT</code> bit in the <code>DT_FLAGS_1</code> dynamic 1152tag. Global auditing requires that any auditing library defined via 1153the <samp>--depaudit</samp> or <samp>-P</samp> command-line options be run for 1154all dynamic objects loaded by the application. 1155</p> 1156</dd> 1157<dt>‘<samp>ibtplt</samp>’</dt> 1158<dd><p>Generate Intel Indirect Branch Tracking (IBT) enabled PLT entries. 1159Supported for Linux/i386 and Linux/x86_64. 1160</p> 1161</dd> 1162<dt>‘<samp>ibt</samp>’</dt> 1163<dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_IBT in .note.gnu.property section 1164to indicate compatibility with IBT. This also implies <samp>ibtplt</samp>. 1165Supported for Linux/i386 and Linux/x86_64. 1166</p> 1167</dd> 1168<dt>‘<samp>initfirst</samp>’</dt> 1169<dd><p>This option is only meaningful when building a shared object. 1170It marks the object so that its runtime initialization will occur 1171before the runtime initialization of any other objects brought into 1172the process at the same time. Similarly the runtime finalization of 1173the object will occur after the runtime finalization of any other 1174objects. 1175</p> 1176</dd> 1177<dt>‘<samp>interpose</samp>’</dt> 1178<dd><p>Specify that the dynamic loader should modify its symbol search order 1179so that symbols in this shared library interpose all other shared 1180libraries not so marked. 1181</p> 1182</dd> 1183<dt>‘<samp>unique</samp>’</dt> 1184<dt>‘<samp>nounique</samp>’</dt> 1185<dd><p>When generating a shared library or other dynamically loadable ELF 1186object mark it as one that should (by default) only ever be loaded once, 1187and only in the main namespace (when using <code>dlmopen</code>). This is 1188primarily used to mark fundamental libraries such as libc, libpthread et 1189al which do not usually function correctly unless they are the sole instances 1190of themselves. This behaviour can be overridden by the <code>dlmopen</code> caller 1191and does not apply to certain loading mechanisms (such as audit libraries). 1192</p> 1193</dd> 1194<dt>‘<samp>lam-u48</samp>’</dt> 1195<dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U48 in .note.gnu.property section 1196to indicate compatibility with Intel LAM_U48. Supported for Linux/x86_64. 1197</p> 1198</dd> 1199<dt>‘<samp>lam-u57</samp>’</dt> 1200<dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U57 in .note.gnu.property section 1201to indicate compatibility with Intel LAM_U57. Supported for Linux/x86_64. 1202</p> 1203</dd> 1204<dt>‘<samp>lam-u48-report=none</samp>’</dt> 1205<dt>‘<samp>lam-u48-report=warning</samp>’</dt> 1206<dt>‘<samp>lam-u48-report=error</samp>’</dt> 1207<dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U48 1208property in input .note.gnu.property section. 1209<samp>lam-u48-report=none</samp>, which is the default, will make the 1210linker not report missing properties in input files. 1211<samp>lam-u48-report=warning</samp> will make the linker issue a warning for 1212missing properties in input files. <samp>lam-u48-report=error</samp> will 1213make the linker issue an error for missing properties in input files. 1214Supported for Linux/x86_64. 1215</p> 1216</dd> 1217<dt>‘<samp>lam-u57-report=none</samp>’</dt> 1218<dt>‘<samp>lam-u57-report=warning</samp>’</dt> 1219<dt>‘<samp>lam-u57-report=error</samp>’</dt> 1220<dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U57 1221property in input .note.gnu.property section. 1222<samp>lam-u57-report=none</samp>, which is the default, will make the 1223linker not report missing properties in input files. 1224<samp>lam-u57-report=warning</samp> will make the linker issue a warning for 1225missing properties in input files. <samp>lam-u57-report=error</samp> will 1226make the linker issue an error for missing properties in input files. 1227Supported for Linux/x86_64. 1228</p> 1229</dd> 1230<dt>‘<samp>lam-report=none</samp>’</dt> 1231<dt>‘<samp>lam-report=warning</samp>’</dt> 1232<dt>‘<samp>lam-report=error</samp>’</dt> 1233<dd><p>Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and 1234GNU_PROPERTY_X86_FEATURE_1_LAM_U57 properties in input .note.gnu.property 1235section. <samp>lam-report=none</samp>, which is the default, will make the 1236linker not report missing properties in input files. 1237<samp>lam-report=warning</samp> will make the linker issue a warning for 1238missing properties in input files. <samp>lam-report=error</samp> will make 1239the linker issue an error for missing properties in input files. 1240Supported for Linux/x86_64. 1241</p> 1242</dd> 1243<dt>‘<samp>lazy</samp>’</dt> 1244<dd><p>When generating an executable or shared library, mark it to tell the 1245dynamic linker to defer function call resolution to the point when 1246the function is called (lazy binding), rather than at load time. 1247Lazy binding is the default. 1248</p> 1249</dd> 1250<dt>‘<samp>loadfltr</samp>’</dt> 1251<dd><p>Specify that the object’s filters be processed immediately at runtime. 1252</p> 1253</dd> 1254<dt>‘<samp>max-page-size=<var>value</var></samp>’</dt> 1255<dd><p>Set the maximum memory page size supported to <var>value</var>. 1256</p> 1257</dd> 1258<dt>‘<samp>muldefs</samp>’</dt> 1259<dd><p>Allow multiple definitions. 1260</p> 1261</dd> 1262<dt>‘<samp>nocopyreloc</samp>’</dt> 1263<dd><p>Disable linker generated .dynbss variables used in place of variables 1264defined in shared libraries. May result in dynamic text relocations. 1265</p> 1266</dd> 1267<dt>‘<samp>nodefaultlib</samp>’</dt> 1268<dd><p>Specify that the dynamic loader search for dependencies of this object 1269should ignore any default library search paths. 1270</p> 1271</dd> 1272<dt>‘<samp>nodelete</samp>’</dt> 1273<dd><p>Specify that the object shouldn’t be unloaded at runtime. 1274</p> 1275</dd> 1276<dt>‘<samp>nodlopen</samp>’</dt> 1277<dd><p>Specify that the object is not available to <code>dlopen</code>. 1278</p> 1279</dd> 1280<dt>‘<samp>nodump</samp>’</dt> 1281<dd><p>Specify that the object can not be dumped by <code>dldump</code>. 1282</p> 1283</dd> 1284<dt>‘<samp>noexecstack</samp>’</dt> 1285<dd><p>Marks the object as not requiring executable stack. 1286</p> 1287</dd> 1288<dt>‘<samp>noextern-protected-data</samp>’</dt> 1289<dd><p>Don’t treat protected data symbols as external when building a shared 1290library. This option overrides the linker backend default. It can be 1291used to work around incorrect relocations against protected data symbols 1292generated by compiler. Updates on protected data symbols by another 1293module aren’t visible to the resulting shared library. Supported for 1294i386 and x86-64. 1295</p> 1296</dd> 1297<dt>‘<samp>noreloc-overflow</samp>’</dt> 1298<dd><p>Disable relocation overflow check. This can be used to disable 1299relocation overflow check if there will be no dynamic relocation 1300overflow at run-time. Supported for x86_64. 1301</p> 1302</dd> 1303<dt>‘<samp>now</samp>’</dt> 1304<dd><p>When generating an executable or shared library, mark it to tell the 1305dynamic linker to resolve all symbols when the program is started, or 1306when the shared library is loaded by dlopen, instead of deferring 1307function call resolution to the point when the function is first 1308called. 1309</p> 1310</dd> 1311<dt>‘<samp>origin</samp>’</dt> 1312<dd><p>Specify that the object requires ‘<samp>$ORIGIN</samp>’ handling in paths. 1313</p> 1314</dd> 1315<dt>‘<samp>relro</samp>’</dt> 1316<dt>‘<samp>norelro</samp>’</dt> 1317<dd><p>Create an ELF <code>PT_GNU_RELRO</code> segment header in the object. This 1318specifies a memory segment that should be made read-only after 1319relocation, if supported. Specifying ‘<samp>common-page-size</samp>’ smaller 1320than the system page size will render this protection ineffective. 1321Don’t create an ELF <code>PT_GNU_RELRO</code> segment if ‘<samp>norelro</samp>’. 1322</p> 1323</dd> 1324<dt>‘<samp>separate-code</samp>’</dt> 1325<dt>‘<samp>noseparate-code</samp>’</dt> 1326<dd><p>Create separate code <code>PT_LOAD</code> segment header in the object. This 1327specifies a memory segment that should contain only instructions and must 1328be in wholly disjoint pages from any other data. Don’t create separate 1329code <code>PT_LOAD</code> segment if ‘<samp>noseparate-code</samp>’ is used. 1330</p> 1331</dd> 1332<dt>‘<samp>unique-symbol</samp>’</dt> 1333<dt>‘<samp>nounique-symbol</samp>’</dt> 1334<dd><p>Avoid duplicated local symbol names in the symbol string table. Append 1335".<code>number</code>" to duplicated local symbol names if ‘<samp>unique-symbol</samp>’ 1336is used. <samp>nounique-symbol</samp> is the default. 1337</p> 1338</dd> 1339<dt>‘<samp>shstk</samp>’</dt> 1340<dd><p>Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in .note.gnu.property section 1341to indicate compatibility with Intel Shadow Stack. Supported for 1342Linux/i386 and Linux/x86_64. 1343</p> 1344</dd> 1345<dt>‘<samp>stack-size=<var>value</var></samp>’</dt> 1346<dd><p>Specify a stack size for an ELF <code>PT_GNU_STACK</code> segment. 1347Specifying zero will override any default non-zero sized 1348<code>PT_GNU_STACK</code> segment creation. 1349</p> 1350</dd> 1351<dt>‘<samp>start-stop-visibility=<var>value</var></samp>’</dt> 1352<dd><a name="index-visibility"></a> 1353<a name="index-ELF-symbol-visibility"></a> 1354<p>Specify the ELF symbol visibility for synthesized 1355<code>__start_SECNAME</code> and <code>__stop_SECNAME</code> symbols (see <a href="Input-Section-Example.html#Input-Section-Example">Input Section Example</a>). <var>value</var> must be exactly ‘<samp>default</samp>’, 1356‘<samp>internal</samp>’, ‘<samp>hidden</samp>’, or ‘<samp>protected</samp>’. If no ‘<samp>-z 1357start-stop-visibility</samp>’ option is given, ‘<samp>protected</samp>’ is used for 1358compatibility with historical practice. However, it’s highly 1359recommended to use ‘<samp>-z start-stop-visibility=hidden</samp>’ in new 1360programs and shared libraries so that these symbols are not exported 1361between shared objects, which is not usually what’s intended. 1362</p> 1363</dd> 1364<dt>‘<samp>text</samp>’</dt> 1365<dt>‘<samp>notext</samp>’</dt> 1366<dt>‘<samp>textoff</samp>’</dt> 1367<dd><p>Report an error if DT_TEXTREL is set, i.e., if the position-independent 1368or shared object has dynamic relocations in read-only sections. Don’t 1369report an error if ‘<samp>notext</samp>’ or ‘<samp>textoff</samp>’. 1370</p> 1371</dd> 1372<dt>‘<samp>undefs</samp>’</dt> 1373<dd><p>Do not report unresolved symbol references from regular object files, 1374either when creating an executable, or when creating a shared library. 1375This option is the inverse of ‘<samp>-z defs</samp>’. 1376</p> 1377</dd> 1378<dt>‘<samp>x86-64-baseline</samp>’</dt> 1379<dt>‘<samp>x86-64-v2</samp>’</dt> 1380<dt>‘<samp>x86-64-v3</samp>’</dt> 1381<dt>‘<samp>x86-64-v4</samp>’</dt> 1382<dd><p>Specify the x86-64 ISA level needed in .note.gnu.property section. 1383<samp>x86-64-baseline</samp> generates <code>GNU_PROPERTY_X86_ISA_1_BASELINE</code>. 1384<samp>x86-64-v2</samp> generates <code>GNU_PROPERTY_X86_ISA_1_V2</code>. 1385<samp>x86-64-v3</samp> generates <code>GNU_PROPERTY_X86_ISA_1_V3</code>. 1386<samp>x86-64-v4</samp> generates <code>GNU_PROPERTY_X86_ISA_1_V4</code>. 1387Supported for Linux/i386 and Linux/x86_64. 1388</p> 1389</dd> 1390</dl> 1391 1392<p>Other keywords are ignored for Solaris compatibility. 1393</p> 1394<a name="index-_002d_0028"></a> 1395<a name="index-groups-of-archives"></a> 1396</dd> 1397<dt><code>-( <var>archives</var> -)</code></dt> 1398<dt><code>--start-group <var>archives</var> --end-group</code></dt> 1399<dd><p>The <var>archives</var> should be a list of archive files. They may be 1400either explicit file names, or ‘<samp>-l</samp>’ options. 1401</p> 1402<p>The specified archives are searched repeatedly until no new undefined 1403references are created. Normally, an archive is searched only once in 1404the order that it is specified on the command line. If a symbol in that 1405archive is needed to resolve an undefined symbol referred to by an 1406object in an archive that appears later on the command line, the linker 1407would not be able to resolve that reference. By grouping the archives, 1408they will all be searched repeatedly until all possible references are 1409resolved. 1410</p> 1411<p>Using this option has a significant performance cost. It is best to use 1412it only when there are unavoidable circular references between two or 1413more archives. 1414</p> 1415<a name="index-_002d_002daccept_002dunknown_002dinput_002darch"></a> 1416<a name="index-_002d_002dno_002daccept_002dunknown_002dinput_002darch"></a> 1417</dd> 1418<dt><code>--accept-unknown-input-arch</code></dt> 1419<dt><code>--no-accept-unknown-input-arch</code></dt> 1420<dd><p>Tells the linker to accept input files whose architecture cannot be 1421recognised. The assumption is that the user knows what they are doing 1422and deliberately wants to link in these unknown input files. This was 1423the default behaviour of the linker, before release 2.14. The default 1424behaviour from release 2.14 onwards is to reject such input files, and 1425so the ‘<samp>--accept-unknown-input-arch</samp>’ option has been added to 1426restore the old behaviour. 1427</p> 1428<a name="index-_002d_002das_002dneeded"></a> 1429<a name="index-_002d_002dno_002das_002dneeded"></a> 1430</dd> 1431<dt><code>--as-needed</code></dt> 1432<dt><code>--no-as-needed</code></dt> 1433<dd><p>This option affects ELF DT_NEEDED tags for dynamic libraries mentioned 1434on the command line after the <samp>--as-needed</samp> option. Normally 1435the linker will add a DT_NEEDED tag for each dynamic library mentioned 1436on the command line, regardless of whether the library is actually 1437needed or not. <samp>--as-needed</samp> causes a DT_NEEDED tag to only be 1438emitted for a library that <em>at that point in the link</em> satisfies a 1439non-weak undefined symbol reference from a regular object file or, if 1440the library is not found in the DT_NEEDED lists of other needed libraries, a 1441non-weak undefined symbol reference from another needed dynamic library. 1442Object files or libraries appearing on the command line <em>after</em> 1443the library in question do not affect whether the library is seen as 1444needed. This is similar to the rules for extraction of object files 1445from archives. <samp>--no-as-needed</samp> restores the default behaviour. 1446</p> 1447<a name="index-_002d_002dadd_002dneeded"></a> 1448<a name="index-_002d_002dno_002dadd_002dneeded"></a> 1449</dd> 1450<dt><code>--add-needed</code></dt> 1451<dt><code>--no-add-needed</code></dt> 1452<dd><p>These two options have been deprecated because of the similarity of 1453their names to the <samp>--as-needed</samp> and <samp>--no-as-needed</samp> 1454options. They have been replaced by <samp>--copy-dt-needed-entries</samp> 1455and <samp>--no-copy-dt-needed-entries</samp>. 1456</p> 1457<a name="index-_002dassert-keyword"></a> 1458</dd> 1459<dt><code>-assert <var>keyword</var></code></dt> 1460<dd><p>This option is ignored for SunOS compatibility. 1461</p> 1462<a name="index-_002dBdynamic"></a> 1463<a name="index-_002ddy"></a> 1464<a name="index-_002dcall_005fshared"></a> 1465</dd> 1466<dt><code>-Bdynamic</code></dt> 1467<dt><code>-dy</code></dt> 1468<dt><code>-call_shared</code></dt> 1469<dd><p>Link against dynamic libraries. This is only meaningful on platforms 1470for which shared libraries are supported. This option is normally the 1471default on such platforms. The different variants of this option are 1472for compatibility with various systems. You may use this option 1473multiple times on the command line: it affects library searching for 1474<samp>-l</samp> options which follow it. 1475</p> 1476<a name="index-_002dBgroup"></a> 1477</dd> 1478<dt><code>-Bgroup</code></dt> 1479<dd><p>Set the <code>DF_1_GROUP</code> flag in the <code>DT_FLAGS_1</code> entry in the dynamic 1480section. This causes the runtime linker to handle lookups in this 1481object and its dependencies to be performed only inside the group. 1482<samp>--unresolved-symbols=report-all</samp> is implied. This option is 1483only meaningful on ELF platforms which support shared libraries. 1484</p> 1485<a name="index-_002dBstatic"></a> 1486<a name="index-_002ddn"></a> 1487<a name="index-_002dnon_005fshared"></a> 1488<a name="index-_002dstatic"></a> 1489</dd> 1490<dt><code>-Bstatic</code></dt> 1491<dt><code>-dn</code></dt> 1492<dt><code>-non_shared</code></dt> 1493<dt><code>-static</code></dt> 1494<dd><p>Do not link against shared libraries. This is only meaningful on 1495platforms for which shared libraries are supported. The different 1496variants of this option are for compatibility with various systems. You 1497may use this option multiple times on the command line: it affects 1498library searching for <samp>-l</samp> options which follow it. This 1499option also implies <samp>--unresolved-symbols=report-all</samp>. This 1500option can be used with <samp>-shared</samp>. Doing so means that a 1501shared library is being created but that all of the library’s external 1502references must be resolved by pulling in entries from static 1503libraries. 1504</p> 1505<a name="index-_002dBsymbolic"></a> 1506</dd> 1507<dt><code>-Bsymbolic</code></dt> 1508<dd><p>When creating a shared library, bind references to global symbols to the 1509definition within the shared library, if any. Normally, it is possible 1510for a program linked against a shared library to override the definition 1511within the shared library. This option is only meaningful on ELF 1512platforms which support shared libraries. 1513</p> 1514<a name="index-_002dBsymbolic_002dfunctions"></a> 1515</dd> 1516<dt><code>-Bsymbolic-functions</code></dt> 1517<dd><p>When creating a shared library, bind references to global function 1518symbols to the definition within the shared library, if any. 1519This option is only meaningful on ELF platforms which support shared 1520libraries. 1521</p> 1522<a name="index-_002d_002ddynamic_002dlist_003ddynamic_002dlist_002dfile"></a> 1523</dd> 1524<dt><code>--dynamic-list=<var>dynamic-list-file</var></code></dt> 1525<dd><p>Specify the name of a dynamic list file to the linker. This is 1526typically used when creating shared libraries to specify a list of 1527global symbols whose references shouldn’t be bound to the definition 1528within the shared library, or creating dynamically linked executables 1529to specify a list of symbols which should be added to the symbol table 1530in the executable. This option is only meaningful on ELF platforms 1531which support shared libraries. 1532</p> 1533<p>The format of the dynamic list is the same as the version node without 1534scope and node name. See <a href="VERSION.html#VERSION">VERSION</a> for more information. 1535</p> 1536<a name="index-_002d_002ddynamic_002dlist_002ddata"></a> 1537</dd> 1538<dt><code>--dynamic-list-data</code></dt> 1539<dd><p>Include all global data symbols to the dynamic list. 1540</p> 1541<a name="index-_002d_002ddynamic_002dlist_002dcpp_002dnew"></a> 1542</dd> 1543<dt><code>--dynamic-list-cpp-new</code></dt> 1544<dd><p>Provide the builtin dynamic list for C++ operator new and delete. It 1545is mainly useful for building shared libstdc++. 1546</p> 1547<a name="index-_002d_002ddynamic_002dlist_002dcpp_002dtypeinfo"></a> 1548</dd> 1549<dt><code>--dynamic-list-cpp-typeinfo</code></dt> 1550<dd><p>Provide the builtin dynamic list for C++ runtime type identification. 1551</p> 1552<a name="index-_002d_002dcheck_002dsections"></a> 1553<a name="index-_002d_002dno_002dcheck_002dsections"></a> 1554</dd> 1555<dt><code>--check-sections</code></dt> 1556<dt><code>--no-check-sections</code></dt> 1557<dd><p>Asks the linker <em>not</em> to check section addresses after they have 1558been assigned to see if there are any overlaps. Normally the linker will 1559perform this check, and if it finds any overlaps it will produce 1560suitable error messages. The linker does know about, and does make 1561allowances for sections in overlays. The default behaviour can be 1562restored by using the command-line switch <samp>--check-sections</samp>. 1563Section overlap is not usually checked for relocatable links. You can 1564force checking in that case by using the <samp>--check-sections</samp> 1565option. 1566</p> 1567<a name="index-_002d_002dcopy_002ddt_002dneeded_002dentries"></a> 1568<a name="index-_002d_002dno_002dcopy_002ddt_002dneeded_002dentries"></a> 1569</dd> 1570<dt><code>--copy-dt-needed-entries</code></dt> 1571<dt><code>--no-copy-dt-needed-entries</code></dt> 1572<dd><p>This option affects the treatment of dynamic libraries referred to 1573by DT_NEEDED tags <em>inside</em> ELF dynamic libraries mentioned on the 1574command line. Normally the linker won’t add a DT_NEEDED tag to the 1575output binary for each library mentioned in a DT_NEEDED tag in an 1576input dynamic library. With <samp>--copy-dt-needed-entries</samp> 1577specified on the command line however any dynamic libraries that 1578follow it will have their DT_NEEDED entries added. The default 1579behaviour can be restored with <samp>--no-copy-dt-needed-entries</samp>. 1580</p> 1581<p>This option also has an effect on the resolution of symbols in dynamic 1582libraries. With <samp>--copy-dt-needed-entries</samp> dynamic libraries 1583mentioned on the command line will be recursively searched, following 1584their DT_NEEDED tags to other libraries, in order to resolve symbols 1585required by the output binary. With the default setting however 1586the searching of dynamic libraries that follow it will stop with the 1587dynamic library itself. No DT_NEEDED links will be traversed to resolve 1588symbols. 1589</p> 1590<a name="index-cross-reference-table"></a> 1591<a name="index-_002d_002dcref"></a> 1592</dd> 1593<dt><code>--cref</code></dt> 1594<dd><p>Output a cross reference table. If a linker map file is being 1595generated, the cross reference table is printed to the map file. 1596Otherwise, it is printed on the standard output. 1597</p> 1598<p>The format of the table is intentionally simple, so that it may be 1599easily processed by a script if necessary. The symbols are printed out, 1600sorted by name. For each symbol, a list of file names is given. If the 1601symbol is defined, the first file listed is the location of the 1602definition. If the symbol is defined as a common value then any files 1603where this happens appear next. Finally any files that reference the 1604symbol are listed. 1605</p> 1606<a name="index-ctf-variables"></a> 1607<a name="index-_002d_002dctf_002dvariables"></a> 1608<a name="index-_002d_002dno_002dctf_002dvariables"></a> 1609</dd> 1610<dt><code>--ctf-variables</code></dt> 1611<dt><code>--no-ctf-variables</code></dt> 1612<dd><p>The CTF debuginfo format supports a section which encodes the names and 1613types of variables found in the program which do not appear in any symbol 1614table. These variables clearly cannot be looked up by address by 1615conventional debuggers, so the space used for their types and names is 1616usually wasted: the types are usually small but the names are often not. 1617<samp>--ctf-variables</samp> causes the generation of such a section. 1618The default behaviour can be restored with <samp>--no-ctf-variables</samp>. 1619</p> 1620<a name="index-ctf-type-sharing"></a> 1621<a name="index-_002d_002dctf_002dshare_002dtypes"></a> 1622</dd> 1623<dt><code>--ctf-share-types=<var>method</var></code></dt> 1624<dd><p>Adjust the method used to share types between translation units in CTF. 1625</p> 1626<dl compact="compact"> 1627<dt>‘<samp>share-unconflicted</samp>’</dt> 1628<dd><p>Put all types that do not have ambiguous definitions into the shared dictionary, 1629where debuggers can easily access them, even if they only occur in one 1630translation unit. This is the default. 1631</p> 1632</dd> 1633<dt>‘<samp>share-duplicated</samp>’</dt> 1634<dd><p>Put only types that occur in multiple translation units into the shared 1635dictionary: types with only one definition go into per-translation-unit 1636dictionaries. Types with ambiguous definitions in multiple translation units 1637always go into per-translation-unit dictionaries. This tends to make the CTF 1638larger, but may reduce the amount of CTF in the shared dictionary. For very 1639large projects this may speed up opening the CTF and save memory in the CTF 1640consumer at runtime. 1641</p></dd> 1642</dl> 1643 1644<a name="index-common-allocation-1"></a> 1645<a name="index-_002d_002dno_002ddefine_002dcommon"></a> 1646</dd> 1647<dt><code>--no-define-common</code></dt> 1648<dd><p>This option inhibits the assignment of addresses to common symbols. 1649The script command <code>INHIBIT_COMMON_ALLOCATION</code> has the same effect. 1650See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>. 1651</p> 1652<p>The ‘<samp>--no-define-common</samp>’ option allows decoupling 1653the decision to assign addresses to Common symbols from the choice 1654of the output file type; otherwise a non-Relocatable output type 1655forces assigning addresses to Common symbols. 1656Using ‘<samp>--no-define-common</samp>’ allows Common symbols that are referenced 1657from a shared library to be assigned addresses only in the main program. 1658This eliminates the unused duplicate space in the shared library, 1659and also prevents any possible confusion over resolving to the wrong 1660duplicate when there are many dynamic modules with specialized search 1661paths for runtime symbol resolution. 1662</p> 1663<a name="index-group-allocation-in-linker-script"></a> 1664<a name="index-section-groups"></a> 1665<a name="index-COMDAT"></a> 1666<a name="index-_002d_002dforce_002dgroup_002dallocation"></a> 1667</dd> 1668<dt><code>--force-group-allocation</code></dt> 1669<dd><p>This option causes the linker to place section group members like 1670normal input sections, and to delete the section groups. This is the 1671default behaviour for a final link but this option can be used to 1672change the behaviour of a relocatable link (‘<samp>-r</samp>’). The script 1673command <code>FORCE_GROUP_ALLOCATION</code> has the same 1674effect. See <a href="Miscellaneous-Commands.html#Miscellaneous-Commands">Miscellaneous Commands</a>. 1675</p> 1676<a name="index-symbols_002c-from-command-line"></a> 1677<a name="index-_002d_002ddefsym_003dsymbol_003dexp"></a> 1678</dd> 1679<dt><code>--defsym=<var>symbol</var>=<var>expression</var></code></dt> 1680<dd><p>Create a global symbol in the output file, containing the absolute 1681address given by <var>expression</var>. You may use this option as many 1682times as necessary to define multiple symbols in the command line. A 1683limited form of arithmetic is supported for the <var>expression</var> in this 1684context: you may give a hexadecimal constant or the name of an existing 1685symbol, or use <code>+</code> and <code>-</code> to add or subtract hexadecimal 1686constants or symbols. If you need more elaborate expressions, consider 1687using the linker command language from a script (see <a href="Assignments.html#Assignments">Assignments</a>). 1688<em>Note:</em> there should be no white space between <var>symbol</var>, the 1689equals sign (“<tt class="key">=</tt>”), and <var>expression</var>. 1690</p> 1691<p>The linker processes ‘<samp>--defsym</samp>’ arguments and ‘<samp>-T</samp>’ arguments 1692in order, placing ‘<samp>--defsym</samp>’ before ‘<samp>-T</samp>’ will define the 1693symbol before the linker script from ‘<samp>-T</samp>’ is processed, while 1694placing ‘<samp>--defsym</samp>’ after ‘<samp>-T</samp>’ will define the symbol after 1695the linker script has been processed. This difference has 1696consequences for expressions within the linker script that use the 1697‘<samp>--defsym</samp>’ symbols, which order is correct will depend on what 1698you are trying to achieve. 1699</p> 1700<a name="index-demangling_002c-from-command-line"></a> 1701<a name="index-_002d_002ddemangle_005b_003dstyle_005d"></a> 1702<a name="index-_002d_002dno_002ddemangle"></a> 1703</dd> 1704<dt><code>--demangle[=<var>style</var>]</code></dt> 1705<dt><code>--no-demangle</code></dt> 1706<dd><p>These options control whether to demangle symbol names in error messages 1707and other output. When the linker is told to demangle, it tries to 1708present symbol names in a readable fashion: it strips leading 1709underscores if they are used by the object file format, and converts C++ 1710mangled symbol names into user readable names. Different compilers have 1711different mangling styles. The optional demangling style argument can be used 1712to choose an appropriate demangling style for your compiler. The linker will 1713demangle by default unless the environment variable ‘<samp>COLLECT_NO_DEMANGLE</samp>’ 1714is set. These options may be used to override the default. 1715</p> 1716<a name="index-dynamic-linker_002c-from-command-line"></a> 1717<a name="index-_002dIfile"></a> 1718<a name="index-_002d_002ddynamic_002dlinker_003dfile"></a> 1719</dd> 1720<dt><code>-I<var>file</var></code></dt> 1721<dt><code>--dynamic-linker=<var>file</var></code></dt> 1722<dd><p>Set the name of the dynamic linker. This is only meaningful when 1723generating dynamically linked ELF executables. The default dynamic 1724linker is normally correct; don’t use this unless you know what you are 1725doing. 1726</p> 1727<a name="index-_002d_002dno_002ddynamic_002dlinker"></a> 1728</dd> 1729<dt><code>--no-dynamic-linker</code></dt> 1730<dd><p>When producing an executable file, omit the request for a dynamic 1731linker to be used at load-time. This is only meaningful for ELF 1732executables that contain dynamic relocations, and usually requires 1733entry point code that is capable of processing these relocations. 1734</p> 1735<a name="index-_002d_002dembedded_002drelocs"></a> 1736</dd> 1737<dt><code>--embedded-relocs</code></dt> 1738<dd><p>This option is similar to the <samp>--emit-relocs</samp> option except 1739that the relocs are stored in a target-specific section. This option 1740is only supported by the ‘<samp>BFIN</samp>’, ‘<samp>CR16</samp>’ and <em>M68K</em> 1741targets. 1742</p> 1743<a name="index-_002d_002ddisable_002dmultiple_002dabs_002ddefs"></a> 1744</dd> 1745<dt><code>--disable-multiple-abs-defs</code></dt> 1746<dd><p>Do not allow multiple definitions with symbols included 1747in filename invoked by -R or –just-symbols 1748</p> 1749<a name="index-_002d_002dfatal_002dwarnings"></a> 1750<a name="index-_002d_002dno_002dfatal_002dwarnings"></a> 1751</dd> 1752<dt><code>--fatal-warnings</code></dt> 1753<dt><code>--no-fatal-warnings</code></dt> 1754<dd><p>Treat all warnings as errors. The default behaviour can be restored 1755with the option <samp>--no-fatal-warnings</samp>. 1756</p> 1757<a name="index-_002d_002dforce_002dexe_002dsuffix"></a> 1758</dd> 1759<dt><code>--force-exe-suffix</code></dt> 1760<dd><p>Make sure that an output file has a .exe suffix. 1761</p> 1762<p>If a successfully built fully linked output file does not have a 1763<code>.exe</code> or <code>.dll</code> suffix, this option forces the linker to copy 1764the output file to one of the same name with a <code>.exe</code> suffix. This 1765option is useful when using unmodified Unix makefiles on a Microsoft 1766Windows host, since some versions of Windows won’t run an image unless 1767it ends in a <code>.exe</code> suffix. 1768</p> 1769<a name="index-_002d_002dgc_002dsections"></a> 1770<a name="index-_002d_002dno_002dgc_002dsections"></a> 1771<a name="index-garbage-collection"></a> 1772</dd> 1773<dt><code>--gc-sections</code></dt> 1774<dt><code>--no-gc-sections</code></dt> 1775<dd><p>Enable garbage collection of unused input sections. It is ignored on 1776targets that do not support this option. The default behaviour (of not 1777performing this garbage collection) can be restored by specifying 1778‘<samp>--no-gc-sections</samp>’ on the command line. Note that garbage 1779collection for COFF and PE format targets is supported, but the 1780implementation is currently considered to be experimental. 1781</p> 1782<p>‘<samp>--gc-sections</samp>’ decides which input sections are used by 1783examining symbols and relocations. The section containing the entry 1784symbol and all sections containing symbols undefined on the 1785command-line will be kept, as will sections containing symbols 1786referenced by dynamic objects. Note that when building shared 1787libraries, the linker must assume that any visible symbol is 1788referenced. Once this initial set of sections has been determined, 1789the linker recursively marks as used any section referenced by their 1790relocations. See ‘<samp>--entry</samp>’, ‘<samp>--undefined</samp>’, and 1791‘<samp>--gc-keep-exported</samp>’. 1792</p> 1793<p>This option can be set when doing a partial link (enabled with option 1794‘<samp>-r</samp>’). In this case the root of symbols kept must be explicitly 1795specified either by one of the options ‘<samp>--entry</samp>’, 1796‘<samp>--undefined</samp>’, or ‘<samp>--gc-keep-exported</samp>’ or by a <code>ENTRY</code> 1797command in the linker script. 1798</p> 1799<p>As a GNU extension, ELF input sections marked with the 1800<code>SHF_GNU_RETAIN</code> flag will not be garbage collected. 1801</p> 1802<a name="index-_002d_002dprint_002dgc_002dsections"></a> 1803<a name="index-_002d_002dno_002dprint_002dgc_002dsections"></a> 1804<a name="index-garbage-collection-1"></a> 1805</dd> 1806<dt><code>--print-gc-sections</code></dt> 1807<dt><code>--no-print-gc-sections</code></dt> 1808<dd><p>List all sections removed by garbage collection. The listing is 1809printed on stderr. This option is only effective if garbage 1810collection has been enabled via the ‘<samp>--gc-sections</samp>’) option. The 1811default behaviour (of not listing the sections that are removed) can 1812be restored by specifying ‘<samp>--no-print-gc-sections</samp>’ on the command 1813line. 1814</p> 1815<a name="index-_002d_002dgc_002dkeep_002dexported"></a> 1816<a name="index-garbage-collection-2"></a> 1817</dd> 1818<dt><code>--gc-keep-exported</code></dt> 1819<dd><p>When ‘<samp>--gc-sections</samp>’ is enabled, this option prevents garbage 1820collection of unused input sections that contain global symbols having 1821default or protected visibility. This option is intended to be used for 1822executables where unreferenced sections would otherwise be garbage 1823collected regardless of the external visibility of contained symbols. 1824Note that this option has no effect when linking shared objects since 1825it is already the default behaviour. This option is only supported for 1826ELF format targets. 1827</p> 1828<a name="index-_002d_002dprint_002doutput_002dformat"></a> 1829<a name="index-output-format"></a> 1830</dd> 1831<dt><code>--print-output-format</code></dt> 1832<dd><p>Print the name of the default output format (perhaps influenced by 1833other command-line options). This is the string that would appear 1834in an <code>OUTPUT_FORMAT</code> linker script command (see <a href="File-Commands.html#File-Commands">File Commands</a>). 1835</p> 1836<a name="index-_002d_002dprint_002dmemory_002dusage"></a> 1837<a name="index-memory-usage"></a> 1838</dd> 1839<dt><code>--print-memory-usage</code></dt> 1840<dd><p>Print used size, total size and used size of memory regions created with 1841the <a href="MEMORY.html#MEMORY">MEMORY</a> command. This is useful on embedded targets to have a 1842quick view of amount of free memory. The format of the output has one 1843headline and one line per region. It is both human readable and easily 1844parsable by tools. Here is an example of an output: 1845</p> 1846<div class="smallexample"> 1847<pre class="smallexample">Memory region Used Size Region Size %age Used 1848 ROM: 256 KB 1 MB 25.00% 1849 RAM: 32 B 2 GB 0.00% 1850</pre></div> 1851 1852<a name="index-help"></a> 1853<a name="index-usage"></a> 1854<a name="index-_002d_002dhelp"></a> 1855</dd> 1856<dt><code>--help</code></dt> 1857<dd><p>Print a summary of the command-line options on the standard output and exit. 1858</p> 1859<a name="index-_002d_002dtarget_002dhelp"></a> 1860</dd> 1861<dt><code>--target-help</code></dt> 1862<dd><p>Print a summary of all target-specific options on the standard output and exit. 1863</p> 1864<a name="index-_002dMap_003dmapfile"></a> 1865</dd> 1866<dt><code>-Map=<var>mapfile</var></code></dt> 1867<dd><p>Print a link map to the file <var>mapfile</var>. See the description of the 1868<samp>-M</samp> option, above. If <var>mapfile</var> is just the character 1869<code>-</code> then the map will be written to stdout. 1870</p> 1871<p>Specifying a directory as <var>mapfile</var> causes the linker map to be 1872written as a file inside the directory. Normally name of the file 1873inside the directory is computed as the basename of the <var>output</var> 1874file with <code>.map</code> appended. If however the special character 1875<code>%</code> is used then this will be replaced by the full path of the 1876output file. Additionally if there are any characters after the 1877<var>%</var> symbol then <code>.map</code> will no longer be appended. 1878</p> 1879<div class="smallexample"> 1880<pre class="smallexample"> -o foo.exe -Map=bar [Creates ./bar] 1881 -o ../dir/foo.exe -Map=bar [Creates ./bar] 1882 -o foo.exe -Map=../dir [Creates ../dir/foo.exe.map] 1883 -o ../dir2/foo.exe -Map=../dir [Creates ../dir/foo.exe.map] 1884 -o foo.exe -Map=% [Creates ./foo.exe.map] 1885 -o ../dir/foo.exe -Map=% [Creates ../dir/foo.exe.map] 1886 -o foo.exe -Map=%.bar [Creates ./foo.exe.bar] 1887 -o ../dir/foo.exe -Map=%.bar [Creates ../dir/foo.exe.bar] 1888 -o ../dir2/foo.exe -Map=../dir/% [Creates ../dir/../dir2/foo.exe.map] 1889 -o ../dir2/foo.exe -Map=../dir/%.bar [Creates ../dir/../dir2/foo.exe.bar] 1890</pre></div> 1891 1892<p>It is an error to specify more than one <code>%</code> character. 1893</p> 1894<p>If the map file already exists then it will be overwritten by this 1895operation. 1896</p> 1897<a name="index-memory-usage-1"></a> 1898<a name="index-_002d_002dno_002dkeep_002dmemory"></a> 1899</dd> 1900<dt><code>--no-keep-memory</code></dt> 1901<dd><p><code>ld</code> normally optimizes for speed over memory usage by caching the 1902symbol tables of input files in memory. This option tells <code>ld</code> to 1903instead optimize for memory usage, by rereading the symbol tables as 1904necessary. This may be required if <code>ld</code> runs out of memory space 1905while linking a large executable. 1906</p> 1907<a name="index-_002d_002dno_002dundefined"></a> 1908<a name="index-_002dz-defs"></a> 1909<a name="index-_002dz-undefs"></a> 1910</dd> 1911<dt><code>--no-undefined</code></dt> 1912<dt><code>-z defs</code></dt> 1913<dd><p>Report unresolved symbol references from regular object files. This 1914is done even if the linker is creating a non-symbolic shared library. 1915The switch <samp>--[no-]allow-shlib-undefined</samp> controls the 1916behaviour for reporting unresolved references found in shared 1917libraries being linked in. 1918</p> 1919<p>The effects of this option can be reverted by using <code>-z undefs</code>. 1920</p> 1921<a name="index-_002d_002dallow_002dmultiple_002ddefinition"></a> 1922<a name="index-_002dz-muldefs"></a> 1923</dd> 1924<dt><code>--allow-multiple-definition</code></dt> 1925<dt><code>-z muldefs</code></dt> 1926<dd><p>Normally when a symbol is defined multiple times, the linker will 1927report a fatal error. These options allow multiple definitions and the 1928first definition will be used. 1929</p> 1930<a name="index-_002d_002dallow_002dshlib_002dundefined"></a> 1931<a name="index-_002d_002dno_002dallow_002dshlib_002dundefined"></a> 1932</dd> 1933<dt><code>--allow-shlib-undefined</code></dt> 1934<dt><code>--no-allow-shlib-undefined</code></dt> 1935<dd><p>Allows or disallows undefined symbols in shared libraries. 1936This switch is similar to <samp>--no-undefined</samp> except that it 1937determines the behaviour when the undefined symbols are in a 1938shared library rather than a regular object file. It does not affect 1939how undefined symbols in regular object files are handled. 1940</p> 1941<p>The default behaviour is to report errors for any undefined symbols 1942referenced in shared libraries if the linker is being used to create 1943an executable, but to allow them if the linker is being used to create 1944a shared library. 1945</p> 1946<p>The reasons for allowing undefined symbol references in shared 1947libraries specified at link time are that: 1948</p> 1949<ul> 1950<li> A shared library specified at link time may not be the same as the one 1951that is available at load time, so the symbol might actually be 1952resolvable at load time. 1953</li><li> There are some operating systems, eg BeOS and HPPA, where undefined 1954symbols in shared libraries are normal. 1955 1956<p>The BeOS kernel for example patches shared libraries at load time to 1957select whichever function is most appropriate for the current 1958architecture. This is used, for example, to dynamically select an 1959appropriate memset function. 1960</p></li></ul> 1961 1962<a name="index-_002d_002derror_002dhandling_002dscript_003dscriptname"></a> 1963</dd> 1964<dt><code>--error-handling-script=<var>scriptname</var></code></dt> 1965<dd><p>If this option is provided then the linker will invoke 1966<var>scriptname</var> whenever an error is encountered. Currently however 1967only two kinds of error are supported: missing symbols and missing 1968libraries. Two arguments will be passed to script: the keyword 1969“undefined-symbol” or ‘missing-lib” and the <var>name</var> of the 1970undefined symbol or missing library. The intention is that the script 1971will provide suggestions to the user as to where the symbol or library 1972might be found. After the script has finished then the normal linker 1973error message will be displayed. 1974</p> 1975<p>The availability of this option is controlled by a configure time 1976switch, so it may not be present in specific implementations. 1977</p> 1978<a name="index-_002d_002dno_002dundefined_002dversion"></a> 1979</dd> 1980<dt><code>--no-undefined-version</code></dt> 1981<dd><p>Normally when a symbol has an undefined version, the linker will ignore 1982it. This option disallows symbols with undefined version and a fatal error 1983will be issued instead. 1984</p> 1985<a name="index-_002d_002ddefault_002dsymver"></a> 1986</dd> 1987<dt><code>--default-symver</code></dt> 1988<dd><p>Create and use a default symbol version (the soname) for unversioned 1989exported symbols. 1990</p> 1991<a name="index-_002d_002ddefault_002dimported_002dsymver"></a> 1992</dd> 1993<dt><code>--default-imported-symver</code></dt> 1994<dd><p>Create and use a default symbol version (the soname) for unversioned 1995imported symbols. 1996</p> 1997<a name="index-_002d_002dno_002dwarn_002dmismatch"></a> 1998</dd> 1999<dt><code>--no-warn-mismatch</code></dt> 2000<dd><p>Normally <code>ld</code> will give an error if you try to link together input 2001files that are mismatched for some reason, perhaps because they have 2002been compiled for different processors or for different endiannesses. 2003This option tells <code>ld</code> that it should silently permit such possible 2004errors. This option should only be used with care, in cases when you 2005have taken some special action that ensures that the linker errors are 2006inappropriate. 2007</p> 2008<a name="index-_002d_002dno_002dwarn_002dsearch_002dmismatch"></a> 2009</dd> 2010<dt><code>--no-warn-search-mismatch</code></dt> 2011<dd><p>Normally <code>ld</code> will give a warning if it finds an incompatible 2012library during a library search. This option silences the warning. 2013</p> 2014<a name="index-_002d_002dno_002dwhole_002darchive"></a> 2015</dd> 2016<dt><code>--no-whole-archive</code></dt> 2017<dd><p>Turn off the effect of the <samp>--whole-archive</samp> option for subsequent 2018archive files. 2019</p> 2020<a name="index-output-file-after-errors"></a> 2021<a name="index-_002d_002dnoinhibit_002dexec"></a> 2022</dd> 2023<dt><code>--noinhibit-exec</code></dt> 2024<dd><p>Retain the executable output file whenever it is still usable. 2025Normally, the linker will not produce an output file if it encounters 2026errors during the link process; it exits without writing an output file 2027when it issues any error whatsoever. 2028</p> 2029<a name="index-_002dnostdlib"></a> 2030</dd> 2031<dt><code>-nostdlib</code></dt> 2032<dd><p>Only search library directories explicitly specified on the 2033command line. Library directories specified in linker scripts 2034(including linker scripts specified on the command line) are ignored. 2035</p> 2036<a name="index-_002d_002doformat_003doutput_002dformat"></a> 2037</dd> 2038<dt><code>--oformat=<var>output-format</var></code></dt> 2039<dd><p><code>ld</code> may be configured to support more than one kind of object 2040file. If your <code>ld</code> is configured this way, you can use the 2041‘<samp>--oformat</samp>’ option to specify the binary format for the output 2042object file. Even when <code>ld</code> is configured to support alternative 2043object formats, you don’t usually need to specify this, as <code>ld</code> 2044should be configured to produce as a default output format the most 2045usual format on each machine. <var>output-format</var> is a text string, the 2046name of a particular format supported by the BFD libraries. (You can 2047list the available binary formats with ‘<samp>objdump -i</samp>’.) The script 2048command <code>OUTPUT_FORMAT</code> can also specify the output format, but 2049this option overrides it. See <a href="BFD.html#BFD">BFD</a>. 2050</p> 2051<a name="index-_002d_002dout_002dimplib"></a> 2052</dd> 2053<dt><code>--out-implib <var>file</var></code></dt> 2054<dd><p>Create an import library in <var>file</var> corresponding to the executable 2055the linker is generating (eg. a DLL or ELF program). This import 2056library (which should be called <code>*.dll.a</code> or <code>*.a</code> for DLLs) 2057may be used to link clients against the generated executable; this 2058behaviour makes it possible to skip a separate import library creation 2059step (eg. <code>dlltool</code> for DLLs). This option is only available for 2060the i386 PE and ELF targetted ports of the linker. 2061</p> 2062<a name="index-_002dpie"></a> 2063<a name="index-_002d_002dpic_002dexecutable"></a> 2064</dd> 2065<dt><code>-pie</code></dt> 2066<dt><code>--pic-executable</code></dt> 2067<dd><a name="index-position-independent-executables"></a> 2068<p>Create a position independent executable. This is currently only supported on 2069ELF platforms. Position independent executables are similar to shared 2070libraries in that they are relocated by the dynamic linker to the virtual 2071address the OS chooses for them (which can vary between invocations). Like 2072normal dynamically linked executables they can be executed and symbols 2073defined in the executable cannot be overridden by shared libraries. 2074</p> 2075<a name="index-_002dqmagic"></a> 2076</dd> 2077<dt><code>-qmagic</code></dt> 2078<dd><p>This option is ignored for Linux compatibility. 2079</p> 2080<a name="index-_002dQy"></a> 2081</dd> 2082<dt><code>-Qy</code></dt> 2083<dd><p>This option is ignored for SVR4 compatibility. 2084</p> 2085<a name="index-_002d_002drelax"></a> 2086<a name="index-synthesizing-linker"></a> 2087<a name="index-relaxing-addressing-modes"></a> 2088<a name="index-_002d_002dno_002drelax"></a> 2089</dd> 2090<dt><code>--relax</code></dt> 2091<dt><code>--no-relax</code></dt> 2092<dd><p>An option with machine dependent effects. 2093This option is only supported on a few targets. 2094See <a href="H8_002f300.html#H8_002f300"><code>ld</code> and the H8/300</a>. 2095See <a href="Xtensa.html#Xtensa"><code>ld</code> and Xtensa Processors</a>. 2096See <a href="M68HC11_002f68HC12.html#M68HC11_002f68HC12"><code>ld</code> and the 68HC11 and 68HC12</a>. 2097See <a href="Nios-II.html#Nios-II"><code>ld</code> and the Altera Nios II</a>. 2098See <a href="PowerPC-ELF32.html#PowerPC-ELF32"><code>ld</code> and PowerPC 32-bit ELF Support</a>. 2099</p> 2100<p>On some platforms the <samp>--relax</samp> option performs target specific, 2101global optimizations that become possible when the linker resolves 2102addressing in the program, such as relaxing address modes, 2103synthesizing new instructions, selecting shorter version of current 2104instructions, and combining constant values. 2105</p> 2106<p>On some platforms these link time global optimizations may make symbolic 2107debugging of the resulting executable impossible. 2108This is known to be the case for the Matsushita MN10200 and MN10300 2109family of processors. 2110</p> 2111<p>On platforms where the feature is supported, the option 2112<samp>--no-relax</samp> will disable it. 2113</p> 2114<p>On platforms where the feature is not supported, both <samp>--relax</samp> 2115and <samp>--no-relax</samp> are accepted, but ignored. 2116</p> 2117<a name="index-retaining-specified-symbols"></a> 2118<a name="index-stripping-all-but-some-symbols"></a> 2119<a name="index-symbols_002c-retaining-selectively"></a> 2120<a name="index-_002d_002dretain_002dsymbols_002dfile_003dfilename"></a> 2121</dd> 2122<dt><code>--retain-symbols-file=<var>filename</var></code></dt> 2123<dd><p>Retain <em>only</em> the symbols listed in the file <var>filename</var>, 2124discarding all others. <var>filename</var> is simply a flat file, with one 2125symbol name per line. This option is especially useful in environments 2126(such as VxWorks) 2127where a large global symbol table is accumulated gradually, to conserve 2128run-time memory. 2129</p> 2130<p>‘<samp>--retain-symbols-file</samp>’ does <em>not</em> discard undefined symbols, 2131or symbols needed for relocations. 2132</p> 2133<p>You may only specify ‘<samp>--retain-symbols-file</samp>’ once in the command 2134line. It overrides ‘<samp>-s</samp>’ and ‘<samp>-S</samp>’. 2135</p> 2136</dd> 2137<dt><code>-rpath=<var>dir</var></code></dt> 2138<dd><a name="index-runtime-library-search-path"></a> 2139<a name="index-_002drpath_003ddir"></a> 2140<p>Add a directory to the runtime library search path. This is used when 2141linking an ELF executable with shared objects. All <samp>-rpath</samp> 2142arguments are concatenated and passed to the runtime linker, which uses 2143them to locate shared objects at runtime. 2144</p> 2145<p>The <samp>-rpath</samp> option is also used when locating shared objects which 2146are needed by shared objects explicitly included in the link; see the 2147description of the <samp>-rpath-link</samp> option. Searching <samp>-rpath</samp> 2148in this way is only supported by native linkers and cross linkers which 2149have been configured with the <samp>--with-sysroot</samp> option. 2150</p> 2151<p>If <samp>-rpath</samp> is not used when linking an ELF executable, the 2152contents of the environment variable <code>LD_RUN_PATH</code> will be used if it 2153is defined. 2154</p> 2155<p>The <samp>-rpath</samp> option may also be used on SunOS. By default, on 2156SunOS, the linker will form a runtime search path out of all the 2157<samp>-L</samp> options it is given. If a <samp>-rpath</samp> option is used, the 2158runtime search path will be formed exclusively using the <samp>-rpath</samp> 2159options, ignoring the <samp>-L</samp> options. This can be useful when using 2160gcc, which adds many <samp>-L</samp> options which may be on NFS mounted 2161file systems. 2162</p> 2163<p>For compatibility with other ELF linkers, if the <samp>-R</samp> option is 2164followed by a directory name, rather than a file name, it is treated as 2165the <samp>-rpath</samp> option. 2166</p> 2167<a name="index-link_002dtime-runtime-library-search-path"></a> 2168<a name="index-_002drpath_002dlink_003ddir"></a> 2169</dd> 2170<dt><code>-rpath-link=<var>dir</var></code></dt> 2171<dd><p>When using ELF or SunOS, one shared library may require another. This 2172happens when an <code>ld -shared</code> link includes a shared library as one 2173of the input files. 2174</p> 2175<p>When the linker encounters such a dependency when doing a non-shared, 2176non-relocatable link, it will automatically try to locate the required 2177shared library and include it in the link, if it is not included 2178explicitly. In such a case, the <samp>-rpath-link</samp> option 2179specifies the first set of directories to search. The 2180<samp>-rpath-link</samp> option may specify a sequence of directory names 2181either by specifying a list of names separated by colons, or by 2182appearing multiple times. 2183</p> 2184<p>The tokens <var>$ORIGIN</var> and <var>$LIB</var> can appear in these search 2185directories. They will be replaced by the full path to the directory 2186containing the program or shared object in the case of <var>$ORIGIN</var> 2187and either ‘<samp>lib</samp>’ - for 32-bit binaries - or ‘<samp>lib64</samp>’ - for 218864-bit binaries - in the case of <var>$LIB</var>. 2189</p> 2190<p>The alternative form of these tokens - <var>${ORIGIN}</var> and 2191<var>${LIB}</var> can also be used. The token <var>$PLATFORM</var> is not 2192supported. 2193</p> 2194<p>This option should be used with caution as it overrides the search path 2195that may have been hard compiled into a shared library. In such a case it 2196is possible to use unintentionally a different search path than the 2197runtime linker would do. 2198</p> 2199<p>The linker uses the following search paths to locate required shared 2200libraries: 2201</p> 2202<ol> 2203<li> Any directories specified by <samp>-rpath-link</samp> options. 2204</li><li> Any directories specified by <samp>-rpath</samp> options. The difference 2205between <samp>-rpath</samp> and <samp>-rpath-link</samp> is that directories 2206specified by <samp>-rpath</samp> options are included in the executable and 2207used at runtime, whereas the <samp>-rpath-link</samp> option is only effective 2208at link time. Searching <samp>-rpath</samp> in this way is only supported 2209by native linkers and cross linkers which have been configured with 2210the <samp>--with-sysroot</samp> option. 2211</li><li> On an ELF system, for native linkers, if the <samp>-rpath</samp> and 2212<samp>-rpath-link</samp> options were not used, search the contents of the 2213environment variable <code>LD_RUN_PATH</code>. 2214</li><li> On SunOS, if the <samp>-rpath</samp> option was not used, search any 2215directories specified using <samp>-L</samp> options. 2216</li><li> For a native linker, search the contents of the environment 2217variable <code>LD_LIBRARY_PATH</code>. 2218</li><li> For a native ELF linker, the directories in <code>DT_RUNPATH</code> or 2219<code>DT_RPATH</code> of a shared library are searched for shared 2220libraries needed by it. The <code>DT_RPATH</code> entries are ignored if 2221<code>DT_RUNPATH</code> entries exist. 2222</li><li> The default directories, normally <samp>/lib</samp> and <samp>/usr/lib</samp>. 2223</li><li> For a linker for a Linux system, if the file <samp>/etc/ld.so.conf</samp> 2224exists, the list of directories found in that file. Note: the path 2225to this file is prefixed with the <code>sysroot</code> value, if that is 2226defined, and then any <code>prefix</code> string if the linker was 2227configured with the <code>--prefix=<path></code> option. 2228</li><li> For a native linker on a FreeBSD system, any directories specified by 2229the <code>_PATH_ELF_HINTS</code> macro defined in the <samp>elf-hints.h</samp> 2230header file. 2231</li><li> Any directories specifed by a <code>SEARCH_DIR</code> command in the 2232linker script being used. 2233</li></ol> 2234 2235<p>If the required shared library is not found, the linker will issue a 2236warning and continue with the link. 2237</p> 2238<a name="index-_002dshared"></a> 2239<a name="index-_002dBshareable"></a> 2240</dd> 2241<dt><code>-shared</code></dt> 2242<dt><code>-Bshareable</code></dt> 2243<dd><a name="index-shared-libraries"></a> 2244<p>Create a shared library. This is currently only supported on ELF, XCOFF 2245and SunOS platforms. On SunOS, the linker will automatically create a 2246shared library if the <samp>-e</samp> option is not used and there are 2247undefined symbols in the link. 2248</p> 2249<a name="index-_002d_002dsort_002dcommon"></a> 2250</dd> 2251<dt><code>--sort-common</code></dt> 2252<dt><code>--sort-common=ascending</code></dt> 2253<dt><code>--sort-common=descending</code></dt> 2254<dd><p>This option tells <code>ld</code> to sort the common symbols by alignment in 2255ascending or descending order when it places them in the appropriate output 2256sections. The symbol alignments considered are sixteen-byte or larger, 2257eight-byte, four-byte, two-byte, and one-byte. This is to prevent gaps 2258between symbols due to alignment constraints. If no sorting order is 2259specified, then descending order is assumed. 2260</p> 2261<a name="index-_002d_002dsort_002dsection_003dname"></a> 2262</dd> 2263<dt><code>--sort-section=name</code></dt> 2264<dd><p>This option will apply <code>SORT_BY_NAME</code> to all wildcard section 2265patterns in the linker script. 2266</p> 2267<a name="index-_002d_002dsort_002dsection_003dalignment"></a> 2268</dd> 2269<dt><code>--sort-section=alignment</code></dt> 2270<dd><p>This option will apply <code>SORT_BY_ALIGNMENT</code> to all wildcard section 2271patterns in the linker script. 2272</p> 2273<a name="index-_002d_002dspare_002ddynamic_002dtags"></a> 2274</dd> 2275<dt><code>--spare-dynamic-tags=<var>count</var></code></dt> 2276<dd><p>This option specifies the number of empty slots to leave in the 2277.dynamic section of ELF shared objects. Empty slots may be needed by 2278post processing tools, such as the prelinker. The default is 5. 2279</p> 2280<a name="index-_002d_002dsplit_002dby_002dfile"></a> 2281</dd> 2282<dt><code>--split-by-file[=<var>size</var>]</code></dt> 2283<dd><p>Similar to <samp>--split-by-reloc</samp> but creates a new output section for 2284each input file when <var>size</var> is reached. <var>size</var> defaults to a 2285size of 1 if not given. 2286</p> 2287<a name="index-_002d_002dsplit_002dby_002dreloc"></a> 2288</dd> 2289<dt><code>--split-by-reloc[=<var>count</var>]</code></dt> 2290<dd><p>Tries to creates extra sections in the output file so that no single 2291output section in the file contains more than <var>count</var> relocations. 2292This is useful when generating huge relocatable files for downloading into 2293certain real time kernels with the COFF object file format; since COFF 2294cannot represent more than 65535 relocations in a single section. Note 2295that this will fail to work with object file formats which do not 2296support arbitrary sections. The linker will not split up individual 2297input sections for redistribution, so if a single input section contains 2298more than <var>count</var> relocations one output section will contain that 2299many relocations. <var>count</var> defaults to a value of 32768. 2300</p> 2301<a name="index-_002d_002dstats"></a> 2302</dd> 2303<dt><code>--stats</code></dt> 2304<dd><p>Compute and display statistics about the operation of the linker, such 2305as execution time and memory usage. 2306</p> 2307<a name="index-_002d_002dsysroot_003ddirectory"></a> 2308</dd> 2309<dt><code>--sysroot=<var>directory</var></code></dt> 2310<dd><p>Use <var>directory</var> as the location of the sysroot, overriding the 2311configure-time default. This option is only supported by linkers 2312that were configured using <samp>--with-sysroot</samp>. 2313</p> 2314<a name="index-_002d_002dtask_002dlink"></a> 2315</dd> 2316<dt><code>--task-link</code></dt> 2317<dd><p>This is used by COFF/PE based targets to create a task-linked object 2318file where all of the global symbols have been converted to statics. 2319</p> 2320<a name="index-_002d_002dtraditional_002dformat"></a> 2321<a name="index-traditional-format"></a> 2322</dd> 2323<dt><code>--traditional-format</code></dt> 2324<dd><p>For some targets, the output of <code>ld</code> is different in some ways from 2325the output of some existing linker. This switch requests <code>ld</code> to 2326use the traditional format instead. 2327</p> 2328<a name="index-dbx"></a> 2329<p>For example, on SunOS, <code>ld</code> combines duplicate entries in the 2330symbol string table. This can reduce the size of an output file with 2331full debugging information by over 30 percent. Unfortunately, the SunOS 2332<code>dbx</code> program can not read the resulting program (<code>gdb</code> has no 2333trouble). The ‘<samp>--traditional-format</samp>’ switch tells <code>ld</code> to not 2334combine duplicate entries. 2335</p> 2336<a name="index-_002d_002dsection_002dstart_003dsectionname_003dorg"></a> 2337</dd> 2338<dt><code>--section-start=<var>sectionname</var>=<var>org</var></code></dt> 2339<dd><p>Locate a section in the output file at the absolute 2340address given by <var>org</var>. You may use this option as many 2341times as necessary to locate multiple sections in the command 2342line. 2343<var>org</var> must be a single hexadecimal integer; 2344for compatibility with other linkers, you may omit the leading 2345‘<samp>0x</samp>’ usually associated with hexadecimal values. <em>Note:</em> there 2346should be no white space between <var>sectionname</var>, the equals 2347sign (“<tt class="key">=</tt>”), and <var>org</var>. 2348</p> 2349<a name="index-_002dTbss_003dorg"></a> 2350<a name="index-_002dTdata_003dorg"></a> 2351<a name="index-_002dTtext_003dorg"></a> 2352<a name="index-segment-origins_002c-cmd-line"></a> 2353</dd> 2354<dt><code>-Tbss=<var>org</var></code></dt> 2355<dt><code>-Tdata=<var>org</var></code></dt> 2356<dt><code>-Ttext=<var>org</var></code></dt> 2357<dd><p>Same as <samp>--section-start</samp>, with <code>.bss</code>, <code>.data</code> or 2358<code>.text</code> as the <var>sectionname</var>. 2359</p> 2360<a name="index-_002dTtext_002dsegment_003dorg"></a> 2361</dd> 2362<dt><code>-Ttext-segment=<var>org</var></code></dt> 2363<dd><a name="index-text-segment-origin_002c-cmd-line"></a> 2364<p>When creating an ELF executable, it will set the address of the first 2365byte of the text segment. 2366</p> 2367<a name="index-_002dTrodata_002dsegment_003dorg"></a> 2368</dd> 2369<dt><code>-Trodata-segment=<var>org</var></code></dt> 2370<dd><a name="index-rodata-segment-origin_002c-cmd-line"></a> 2371<p>When creating an ELF executable or shared object for a target where 2372the read-only data is in its own segment separate from the executable 2373text, it will set the address of the first byte of the read-only data segment. 2374</p> 2375<a name="index-_002dTldata_002dsegment_003dorg"></a> 2376</dd> 2377<dt><code>-Tldata-segment=<var>org</var></code></dt> 2378<dd><a name="index-ldata-segment-origin_002c-cmd-line"></a> 2379<p>When creating an ELF executable or shared object for x86-64 medium memory 2380model, it will set the address of the first byte of the ldata segment. 2381</p> 2382<a name="index-_002d_002dunresolved_002dsymbols"></a> 2383</dd> 2384<dt><code>--unresolved-symbols=<var>method</var></code></dt> 2385<dd><p>Determine how to handle unresolved symbols. There are four possible 2386values for ‘<samp>method</samp>’: 2387</p> 2388<dl compact="compact"> 2389<dt>‘<samp>ignore-all</samp>’</dt> 2390<dd><p>Do not report any unresolved symbols. 2391</p> 2392</dd> 2393<dt>‘<samp>report-all</samp>’</dt> 2394<dd><p>Report all unresolved symbols. This is the default. 2395</p> 2396</dd> 2397<dt>‘<samp>ignore-in-object-files</samp>’</dt> 2398<dd><p>Report unresolved symbols that are contained in shared libraries, but 2399ignore them if they come from regular object files. 2400</p> 2401</dd> 2402<dt>‘<samp>ignore-in-shared-libs</samp>’</dt> 2403<dd><p>Report unresolved symbols that come from regular object files, but 2404ignore them if they come from shared libraries. This can be useful 2405when creating a dynamic binary and it is known that all the shared 2406libraries that it should be referencing are included on the linker’s 2407command line. 2408</p></dd> 2409</dl> 2410 2411<p>The behaviour for shared libraries on their own can also be controlled 2412by the <samp>--[no-]allow-shlib-undefined</samp> option. 2413</p> 2414<p>Normally the linker will generate an error message for each reported 2415unresolved symbol but the option <samp>--warn-unresolved-symbols</samp> 2416can change this to a warning. 2417</p> 2418<a name="index-_002d_002dverbose_005b_003dNUMBER_005d"></a> 2419<a name="index-verbose_005b_003dNUMBER_005d"></a> 2420</dd> 2421<dt><code>--dll-verbose</code></dt> 2422<dt><code>--verbose[=<var>NUMBER</var>]</code></dt> 2423<dd><p>Display the version number for <code>ld</code> and list the linker emulations 2424supported. Display which input files can and cannot be opened. Display 2425the linker script being used by the linker. If the optional <var>NUMBER</var> 2426argument > 1, plugin symbol status will also be displayed. 2427</p> 2428<a name="index-_002d_002dversion_002dscript_003dversion_002dscriptfile"></a> 2429<a name="index-version-script_002c-symbol-versions"></a> 2430</dd> 2431<dt><code>--version-script=<var>version-scriptfile</var></code></dt> 2432<dd><p>Specify the name of a version script to the linker. This is typically 2433used when creating shared libraries to specify additional information 2434about the version hierarchy for the library being created. This option 2435is only fully supported on ELF platforms which support shared libraries; 2436see <a href="VERSION.html#VERSION">VERSION</a>. It is partially supported on PE platforms, which can 2437use version scripts to filter symbol visibility in auto-export mode: any 2438symbols marked ‘<samp>local</samp>’ in the version script will not be exported. 2439See <a href="WIN32.html#WIN32">WIN32</a>. 2440</p> 2441<a name="index-_002d_002dwarn_002dcommon"></a> 2442<a name="index-warnings_002c-on-combining-symbols"></a> 2443<a name="index-combining-symbols_002c-warnings-on"></a> 2444</dd> 2445<dt><code>--warn-common</code></dt> 2446<dd><p>Warn when a common symbol is combined with another common symbol or with 2447a symbol definition. Unix linkers allow this somewhat sloppy practice, 2448but linkers on some other operating systems do not. This option allows 2449you to find potential problems from combining global symbols. 2450Unfortunately, some C libraries use this practice, so you may get some 2451warnings about symbols in the libraries as well as in your programs. 2452</p> 2453<p>There are three kinds of global symbols, illustrated here by C examples: 2454</p> 2455<dl compact="compact"> 2456<dt>‘<samp>int i = 1;</samp>’</dt> 2457<dd><p>A definition, which goes in the initialized data section of the output 2458file. 2459</p> 2460</dd> 2461<dt>‘<samp>extern int i;</samp>’</dt> 2462<dd><p>An undefined reference, which does not allocate space. 2463There must be either a definition or a common symbol for the 2464variable somewhere. 2465</p> 2466</dd> 2467<dt>‘<samp>int i;</samp>’</dt> 2468<dd><p>A common symbol. If there are only (one or more) common symbols for a 2469variable, it goes in the uninitialized data area of the output file. 2470The linker merges multiple common symbols for the same variable into a 2471single symbol. If they are of different sizes, it picks the largest 2472size. The linker turns a common symbol into a declaration, if there is 2473a definition of the same variable. 2474</p></dd> 2475</dl> 2476 2477<p>The ‘<samp>--warn-common</samp>’ option can produce five kinds of warnings. 2478Each warning consists of a pair of lines: the first describes the symbol 2479just encountered, and the second describes the previous symbol 2480encountered with the same name. One or both of the two symbols will be 2481a common symbol. 2482</p> 2483<ol> 2484<li> Turning a common symbol into a reference, because there is already a 2485definition for the symbol. 2486<div class="smallexample"> 2487<pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>' 2488 overridden by definition 2489<var>file</var>(<var>section</var>): warning: defined here 2490</pre></div> 2491 2492</li><li> Turning a common symbol into a reference, because a later definition for 2493the symbol is encountered. This is the same as the previous case, 2494except that the symbols are encountered in a different order. 2495<div class="smallexample"> 2496<pre class="smallexample"><var>file</var>(<var>section</var>): warning: definition of `<var>symbol</var>' 2497 overriding common 2498<var>file</var>(<var>section</var>): warning: common is here 2499</pre></div> 2500 2501</li><li> Merging a common symbol with a previous same-sized common symbol. 2502<div class="smallexample"> 2503<pre class="smallexample"><var>file</var>(<var>section</var>): warning: multiple common 2504 of `<var>symbol</var>' 2505<var>file</var>(<var>section</var>): warning: previous common is here 2506</pre></div> 2507 2508</li><li> Merging a common symbol with a previous larger common symbol. 2509<div class="smallexample"> 2510<pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>' 2511 overridden by larger common 2512<var>file</var>(<var>section</var>): warning: larger common is here 2513</pre></div> 2514 2515</li><li> Merging a common symbol with a previous smaller common symbol. This is 2516the same as the previous case, except that the symbols are 2517encountered in a different order. 2518<div class="smallexample"> 2519<pre class="smallexample"><var>file</var>(<var>section</var>): warning: common of `<var>symbol</var>' 2520 overriding smaller common 2521<var>file</var>(<var>section</var>): warning: smaller common is here 2522</pre></div> 2523</li></ol> 2524 2525<a name="index-_002d_002dwarn_002dconstructors"></a> 2526</dd> 2527<dt><code>--warn-constructors</code></dt> 2528<dd><p>Warn if any global constructors are used. This is only useful for a few 2529object file formats. For formats like COFF or ELF, the linker can not 2530detect the use of global constructors. 2531</p> 2532<a name="index-_002d_002dwarn_002dmultiple_002dgp"></a> 2533</dd> 2534<dt><code>--warn-multiple-gp</code></dt> 2535<dd><p>Warn if multiple global pointer values are required in the output file. 2536This is only meaningful for certain processors, such as the Alpha. 2537Specifically, some processors put large-valued constants in a special 2538section. A special register (the global pointer) points into the middle 2539of this section, so that constants can be loaded efficiently via a 2540base-register relative addressing mode. Since the offset in 2541base-register relative mode is fixed and relatively small (e.g., 16 2542bits), this limits the maximum size of the constant pool. Thus, in 2543large programs, it is often necessary to use multiple global pointer 2544values in order to be able to address all possible constants. This 2545option causes a warning to be issued whenever this case occurs. 2546</p> 2547<a name="index-_002d_002dwarn_002donce"></a> 2548<a name="index-warnings_002c-on-undefined-symbols"></a> 2549<a name="index-undefined-symbols_002c-warnings-on"></a> 2550</dd> 2551<dt><code>--warn-once</code></dt> 2552<dd><p>Only warn once for each undefined symbol, rather than once per module 2553which refers to it. 2554</p> 2555<a name="index-_002d_002dwarn_002dsection_002dalign"></a> 2556<a name="index-warnings_002c-on-section-alignment"></a> 2557<a name="index-section-alignment_002c-warnings-on"></a> 2558</dd> 2559<dt><code>--warn-section-align</code></dt> 2560<dd><p>Warn if the address of an output section is changed because of 2561alignment. Typically, the alignment will be set by an input section. 2562The address will only be changed if it not explicitly specified; that 2563is, if the <code>SECTIONS</code> command does not specify a start address for 2564the section (see <a href="SECTIONS.html#SECTIONS">SECTIONS</a>). 2565</p> 2566<a name="index-_002d_002dwarn_002dtextrel"></a> 2567</dd> 2568<dt><code>--warn-textrel</code></dt> 2569<dd><p>Warn if the linker adds DT_TEXTREL to a position-independent executable 2570or shared object. 2571</p> 2572<a name="index-_002d_002dwarn_002dalternate_002dem"></a> 2573</dd> 2574<dt><code>--warn-alternate-em</code></dt> 2575<dd><p>Warn if an object has alternate ELF machine code. 2576</p> 2577<a name="index-_002d_002dwarn_002dunresolved_002dsymbols"></a> 2578</dd> 2579<dt><code>--warn-unresolved-symbols</code></dt> 2580<dd><p>If the linker is going to report an unresolved symbol (see the option 2581<samp>--unresolved-symbols</samp>) it will normally generate an error. 2582This option makes it generate a warning instead. 2583</p> 2584<a name="index-_002d_002derror_002dunresolved_002dsymbols"></a> 2585</dd> 2586<dt><code>--error-unresolved-symbols</code></dt> 2587<dd><p>This restores the linker’s default behaviour of generating errors when 2588it is reporting unresolved symbols. 2589</p> 2590<a name="index-_002d_002dwhole_002darchive"></a> 2591<a name="index-including-an-entire-archive"></a> 2592</dd> 2593<dt><code>--whole-archive</code></dt> 2594<dd><p>For each archive mentioned on the command line after the 2595<samp>--whole-archive</samp> option, include every object file in the archive 2596in the link, rather than searching the archive for the required object 2597files. This is normally used to turn an archive file into a shared 2598library, forcing every object to be included in the resulting shared 2599library. This option may be used more than once. 2600</p> 2601<p>Two notes when using this option from gcc: First, gcc doesn’t know 2602about this option, so you have to use <samp>-Wl,-whole-archive</samp>. 2603Second, don’t forget to use <samp>-Wl,-no-whole-archive</samp> after your 2604list of archives, because gcc will add its own list of archives to 2605your link and you may not want this flag to affect those as well. 2606</p> 2607<a name="index-_002d_002dwrap_003dsymbol"></a> 2608</dd> 2609<dt><code>--wrap=<var>symbol</var></code></dt> 2610<dd><p>Use a wrapper function for <var>symbol</var>. Any undefined reference to 2611<var>symbol</var> will be resolved to <code>__wrap_<var>symbol</var></code>. Any 2612undefined reference to <code>__real_<var>symbol</var></code> will be resolved to 2613<var>symbol</var>. 2614</p> 2615<p>This can be used to provide a wrapper for a system function. The 2616wrapper function should be called <code>__wrap_<var>symbol</var></code>. If it 2617wishes to call the system function, it should call 2618<code>__real_<var>symbol</var></code>. 2619</p> 2620<p>Here is a trivial example: 2621</p> 2622<div class="smallexample"> 2623<pre class="smallexample">void * 2624__wrap_malloc (size_t c) 2625{ 2626 printf ("malloc called with %zu\n", c); 2627 return __real_malloc (c); 2628} 2629</pre></div> 2630 2631<p>If you link other code with this file using <samp>--wrap malloc</samp>, then 2632all calls to <code>malloc</code> will call the function <code>__wrap_malloc</code> 2633instead. The call to <code>__real_malloc</code> in <code>__wrap_malloc</code> will 2634call the real <code>malloc</code> function. 2635</p> 2636<p>You may wish to provide a <code>__real_malloc</code> function as well, so that 2637links without the <samp>--wrap</samp> option will succeed. If you do this, 2638you should not put the definition of <code>__real_malloc</code> in the same 2639file as <code>__wrap_malloc</code>; if you do, the assembler may resolve the 2640call before the linker has a chance to wrap it to <code>malloc</code>. 2641</p> 2642<p>Only undefined references are replaced by the linker. So, translation unit 2643internal references to <var>symbol</var> are not resolved to 2644<code>__wrap_<var>symbol</var></code>. In the next example, the call to <code>f</code> in 2645<code>g</code> is not resolved to <code>__wrap_f</code>. 2646</p> 2647<div class="smallexample"> 2648<pre class="smallexample">int 2649f (void) 2650{ 2651 return 123; 2652} 2653 2654int 2655g (void) 2656{ 2657 return f(); 2658} 2659</pre></div> 2660 2661<a name="index-_002d_002deh_002dframe_002dhdr"></a> 2662<a name="index-_002d_002dno_002deh_002dframe_002dhdr"></a> 2663</dd> 2664<dt><code>--eh-frame-hdr</code></dt> 2665<dt><code>--no-eh-frame-hdr</code></dt> 2666<dd><p>Request (<samp>--eh-frame-hdr</samp>) or suppress 2667(<samp>--no-eh-frame-hdr</samp>) the creation of <code>.eh_frame_hdr</code> 2668section and ELF <code>PT_GNU_EH_FRAME</code> segment header. 2669</p> 2670<a name="index-_002d_002dld_002dgenerated_002dunwind_002dinfo"></a> 2671</dd> 2672<dt><code>--no-ld-generated-unwind-info</code></dt> 2673<dd><p>Request creation of <code>.eh_frame</code> unwind info for linker 2674generated code sections like PLT. This option is on by default 2675if linker generated unwind info is supported. 2676</p> 2677<a name="index-_002d_002denable_002dnew_002ddtags"></a> 2678<a name="index-_002d_002ddisable_002dnew_002ddtags"></a> 2679</dd> 2680<dt><code>--enable-new-dtags</code></dt> 2681<dt><code>--disable-new-dtags</code></dt> 2682<dd><p>This linker can create the new dynamic tags in ELF. But the older ELF 2683systems may not understand them. If you specify 2684<samp>--enable-new-dtags</samp>, the new dynamic tags will be created as needed 2685and older dynamic tags will be omitted. 2686If you specify <samp>--disable-new-dtags</samp>, no new dynamic tags will be 2687created. By default, the new dynamic tags are not created. Note that 2688those options are only available for ELF systems. 2689</p> 2690<a name="index-_002d_002dhash_002dsize_003dnumber"></a> 2691</dd> 2692<dt><code>--hash-size=<var>number</var></code></dt> 2693<dd><p>Set the default size of the linker’s hash tables to a prime number 2694close to <var>number</var>. Increasing this value can reduce the length of 2695time it takes the linker to perform its tasks, at the expense of 2696increasing the linker’s memory requirements. Similarly reducing this 2697value can reduce the memory requirements at the expense of speed. 2698</p> 2699<a name="index-_002d_002dhash_002dstyle_003dstyle"></a> 2700</dd> 2701<dt><code>--hash-style=<var>style</var></code></dt> 2702<dd><p>Set the type of linker’s hash table(s). <var>style</var> can be either 2703<code>sysv</code> for classic ELF <code>.hash</code> section, <code>gnu</code> for 2704new style GNU <code>.gnu.hash</code> section or <code>both</code> for both 2705the classic ELF <code>.hash</code> and new style GNU <code>.gnu.hash</code> 2706hash tables. The default depends upon how the linker was configured, 2707but for most Linux based systems it will be <code>both</code>. 2708</p> 2709<a name="index-_002d_002dcompress_002ddebug_002dsections_003dnone"></a> 2710<a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib"></a> 2711<a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib_002dgnu"></a> 2712<a name="index-_002d_002dcompress_002ddebug_002dsections_003dzlib_002dgabi"></a> 2713</dd> 2714<dt><code>--compress-debug-sections=none</code></dt> 2715<dt><code>--compress-debug-sections=zlib</code></dt> 2716<dt><code>--compress-debug-sections=zlib-gnu</code></dt> 2717<dt><code>--compress-debug-sections=zlib-gabi</code></dt> 2718<dd><p>On ELF platforms, these options control how DWARF debug sections are 2719compressed using zlib. 2720</p> 2721<p><samp>--compress-debug-sections=none</samp> doesn’t compress DWARF debug 2722sections. <samp>--compress-debug-sections=zlib-gnu</samp> compresses 2723DWARF debug sections and renames them to begin with ‘<samp>.zdebug</samp>’ 2724instead of ‘<samp>.debug</samp>’. <samp>--compress-debug-sections=zlib-gabi</samp> 2725also compresses DWARF debug sections, but rather than renaming them it 2726sets the SHF_COMPRESSED flag in the sections’ headers. 2727</p> 2728<p>The <samp>--compress-debug-sections=zlib</samp> option is an alias for 2729<samp>--compress-debug-sections=zlib-gabi</samp>. 2730</p> 2731<p>Note that this option overrides any compression in input debug 2732sections, so if a binary is linked with <samp>--compress-debug-sections=none</samp> 2733for example, then any compressed debug sections in input files will be 2734uncompressed before they are copied into the output binary. 2735</p> 2736<p>The default compression behaviour varies depending upon the target 2737involved and the configure options used to build the toolchain. The 2738default can be determined by examining the output from the linker’s 2739<samp>--help</samp> option. 2740</p> 2741<a name="index-_002d_002dreduce_002dmemory_002doverheads"></a> 2742</dd> 2743<dt><code>--reduce-memory-overheads</code></dt> 2744<dd><p>This option reduces memory requirements at ld runtime, at the expense of 2745linking speed. This was introduced to select the old O(n^2) algorithm 2746for link map file generation, rather than the new O(n) algorithm which uses 2747about 40% more memory for symbol storage. 2748</p> 2749<p>Another effect of the switch is to set the default hash table size to 27501021, which again saves memory at the cost of lengthening the linker’s 2751run time. This is not done however if the <samp>--hash-size</samp> switch 2752has been used. 2753</p> 2754<p>The <samp>--reduce-memory-overheads</samp> switch may be also be used to 2755enable other tradeoffs in future versions of the linker. 2756</p> 2757<a name="index-_002d_002dbuild_002did"></a> 2758<a name="index-_002d_002dbuild_002did_003dstyle"></a> 2759</dd> 2760<dt><code>--build-id</code></dt> 2761<dt><code>--build-id=<var>style</var></code></dt> 2762<dd><p>Request the creation of a <code>.note.gnu.build-id</code> ELF note section 2763or a <code>.buildid</code> COFF section. The contents of the note are 2764unique bits identifying this linked file. <var>style</var> can be 2765<code>uuid</code> to use 128 random bits, <code>sha1</code> to use a 160-bit 2766<small>SHA1</small> hash on the normative parts of the output contents, 2767<code>md5</code> to use a 128-bit <small>MD5</small> hash on the normative parts of 2768the output contents, or <code>0x<var>hexstring</var></code> to use a chosen bit 2769string specified as an even number of hexadecimal digits (<code>-</code> and 2770<code>:</code> characters between digit pairs are ignored). If <var>style</var> 2771is omitted, <code>sha1</code> is used. 2772</p> 2773<p>The <code>md5</code> and <code>sha1</code> styles produces an identifier 2774that is always the same in an identical output file, but will be 2775unique among all nonidentical output files. It is not intended 2776to be compared as a checksum for the file’s contents. A linked 2777file may be changed later by other tools, but the build ID bit 2778string identifying the original linked file does not change. 2779</p> 2780<p>Passing <code>none</code> for <var>style</var> disables the setting from any 2781<code>--build-id</code> options earlier on the command line. 2782</p></dd> 2783</dl> 2784 2785 2786<a name="Options-Specific-to-i386-PE-Targets"></a> 2787<h4 class="subsection">2.1.1 Options Specific to i386 PE Targets</h4> 2788 2789 2790<p>The i386 PE linker supports the <samp>-shared</samp> option, which causes 2791the output to be a dynamically linked library (DLL) instead of a 2792normal executable. You should name the output <code>*.dll</code> when you 2793use this option. In addition, the linker fully supports the standard 2794<code>*.def</code> files, which may be specified on the linker command line 2795like an object file (in fact, it should precede archives it exports 2796symbols from, to ensure that they get linked in, just like a normal 2797object file). 2798</p> 2799<p>In addition to the options common to all targets, the i386 PE linker 2800support additional command-line options that are specific to the i386 2801PE target. Options that take values may be separated from their 2802values by either a space or an equals sign. 2803</p> 2804<dl compact="compact"> 2805<dd> 2806<a name="index-_002d_002dadd_002dstdcall_002dalias"></a> 2807</dd> 2808<dt><code>--add-stdcall-alias</code></dt> 2809<dd><p>If given, symbols with a stdcall suffix (@<var>nn</var>) will be exported 2810as-is and also with the suffix stripped. 2811[This option is specific to the i386 PE targeted port of the linker] 2812</p> 2813<a name="index-_002d_002dbase_002dfile"></a> 2814</dd> 2815<dt><code>--base-file <var>file</var></code></dt> 2816<dd><p>Use <var>file</var> as the name of a file in which to save the base 2817addresses of all the relocations needed for generating DLLs with 2818<samp>dlltool</samp>. 2819[This is an i386 PE specific option] 2820</p> 2821<a name="index-_002d_002ddll"></a> 2822</dd> 2823<dt><code>--dll</code></dt> 2824<dd><p>Create a DLL instead of a regular executable. You may also use 2825<samp>-shared</samp> or specify a <code>LIBRARY</code> in a given <code>.def</code> 2826file. 2827[This option is specific to the i386 PE targeted port of the linker] 2828</p> 2829<a name="index-_002d_002denable_002dlong_002dsection_002dnames"></a> 2830<a name="index-_002d_002ddisable_002dlong_002dsection_002dnames"></a> 2831</dd> 2832<dt><code>--enable-long-section-names</code></dt> 2833<dt><code>--disable-long-section-names</code></dt> 2834<dd><p>The PE variants of the COFF object format add an extension that permits 2835the use of section names longer than eight characters, the normal limit 2836for COFF. By default, these names are only allowed in object files, as 2837fully-linked executable images do not carry the COFF string table required 2838to support the longer names. As a GNU extension, it is possible to 2839allow their use in executable images as well, or to (probably pointlessly!) 2840disallow it in object files, by using these two options. Executable images 2841generated with these long section names are slightly non-standard, carrying 2842as they do a string table, and may generate confusing output when examined 2843with non-GNU PE-aware tools, such as file viewers and dumpers. However, 2844GDB relies on the use of PE long section names to find Dwarf-2 debug 2845information sections in an executable image at runtime, and so if neither 2846option is specified on the command-line, <code>ld</code> will enable long 2847section names, overriding the default and technically correct behaviour, 2848when it finds the presence of debug information while linking an executable 2849image and not stripping symbols. 2850[This option is valid for all PE targeted ports of the linker] 2851</p> 2852<a name="index-_002d_002denable_002dstdcall_002dfixup"></a> 2853<a name="index-_002d_002ddisable_002dstdcall_002dfixup"></a> 2854</dd> 2855<dt><code>--enable-stdcall-fixup</code></dt> 2856<dt><code>--disable-stdcall-fixup</code></dt> 2857<dd><p>If the link finds a symbol that it cannot resolve, it will attempt to 2858do “fuzzy linking” by looking for another defined symbol that differs 2859only in the format of the symbol name (cdecl vs stdcall) and will 2860resolve that symbol by linking to the match. For example, the 2861undefined symbol <code>_foo</code> might be linked to the function 2862<code>_foo@12</code>, or the undefined symbol <code>_bar@16</code> might be linked 2863to the function <code>_bar</code>. When the linker does this, it prints a 2864warning, since it normally should have failed to link, but sometimes 2865import libraries generated from third-party dlls may need this feature 2866to be usable. If you specify <samp>--enable-stdcall-fixup</samp>, this 2867feature is fully enabled and warnings are not printed. If you specify 2868<samp>--disable-stdcall-fixup</samp>, this feature is disabled and such 2869mismatches are considered to be errors. 2870[This option is specific to the i386 PE targeted port of the linker] 2871</p> 2872<a name="index-_002d_002dleading_002dunderscore"></a> 2873<a name="index-_002d_002dno_002dleading_002dunderscore"></a> 2874</dd> 2875<dt><code>--leading-underscore</code></dt> 2876<dt><code>--no-leading-underscore</code></dt> 2877<dd><p>For most targets default symbol-prefix is an underscore and is defined 2878in target’s description. By this option it is possible to 2879disable/enable the default underscore symbol-prefix. 2880</p> 2881<a name="index-DLLs_002c-creating"></a> 2882<a name="index-_002d_002dexport_002dall_002dsymbols"></a> 2883</dd> 2884<dt><code>--export-all-symbols</code></dt> 2885<dd><p>If given, all global symbols in the objects used to build a DLL will 2886be exported by the DLL. Note that this is the default if there 2887otherwise wouldn’t be any exported symbols. When symbols are 2888explicitly exported via DEF files or implicitly exported via function 2889attributes, the default is to not export anything else unless this 2890option is given. Note that the symbols <code>DllMain@12</code>, 2891<code>DllEntryPoint@0</code>, <code>DllMainCRTStartup@12</code>, and 2892<code>impure_ptr</code> will not be automatically 2893exported. Also, symbols imported from other DLLs will not be 2894re-exported, nor will symbols specifying the DLL’s internal layout 2895such as those beginning with <code>_head_</code> or ending with 2896<code>_iname</code>. In addition, no symbols from <code>libgcc</code>, 2897<code>libstd++</code>, <code>libmingw32</code>, or <code>crtX.o</code> will be exported. 2898Symbols whose names begin with <code>__rtti_</code> or <code>__builtin_</code> will 2899not be exported, to help with C++ DLLs. Finally, there is an 2900extensive list of cygwin-private symbols that are not exported 2901(obviously, this applies on when building DLLs for cygwin targets). 2902These cygwin-excludes are: <code>_cygwin_dll_entry@12</code>, 2903<code>_cygwin_crt0_common@8</code>, <code>_cygwin_noncygwin_dll_entry@12</code>, 2904<code>_fmode</code>, <code>_impure_ptr</code>, <code>cygwin_attach_dll</code>, 2905<code>cygwin_premain0</code>, <code>cygwin_premain1</code>, <code>cygwin_premain2</code>, 2906<code>cygwin_premain3</code>, and <code>environ</code>. 2907[This option is specific to the i386 PE targeted port of the linker] 2908</p> 2909<a name="index-_002d_002dexclude_002dsymbols"></a> 2910</dd> 2911<dt><code>--exclude-symbols <var>symbol</var>,<var>symbol</var>,...</code></dt> 2912<dd><p>Specifies a list of symbols which should not be automatically 2913exported. The symbol names may be delimited by commas or colons. 2914[This option is specific to the i386 PE targeted port of the linker] 2915</p> 2916<a name="index-_002d_002dexclude_002dall_002dsymbols"></a> 2917</dd> 2918<dt><code>--exclude-all-symbols</code></dt> 2919<dd><p>Specifies no symbols should be automatically exported. 2920[This option is specific to the i386 PE targeted port of the linker] 2921</p> 2922<a name="index-_002d_002dfile_002dalignment"></a> 2923</dd> 2924<dt><code>--file-alignment</code></dt> 2925<dd><p>Specify the file alignment. Sections in the file will always begin at 2926file offsets which are multiples of this number. This defaults to 2927512. 2928[This option is specific to the i386 PE targeted port of the linker] 2929</p> 2930<a name="index-heap-size"></a> 2931<a name="index-_002d_002dheap"></a> 2932</dd> 2933<dt><code>--heap <var>reserve</var></code></dt> 2934<dt><code>--heap <var>reserve</var>,<var>commit</var></code></dt> 2935<dd><p>Specify the number of bytes of memory to reserve (and optionally commit) 2936to be used as heap for this program. The default is 1MB reserved, 4K 2937committed. 2938[This option is specific to the i386 PE targeted port of the linker] 2939</p> 2940<a name="index-image-base"></a> 2941<a name="index-_002d_002dimage_002dbase"></a> 2942</dd> 2943<dt><code>--image-base <var>value</var></code></dt> 2944<dd><p>Use <var>value</var> as the base address of your program or dll. This is 2945the lowest memory location that will be used when your program or dll 2946is loaded. To reduce the need to relocate and improve performance of 2947your dlls, each should have a unique base address and not overlap any 2948other dlls. The default is 0x400000 for executables, and 0x10000000 2949for dlls. 2950[This option is specific to the i386 PE targeted port of the linker] 2951</p> 2952<a name="index-_002d_002dkill_002dat"></a> 2953</dd> 2954<dt><code>--kill-at</code></dt> 2955<dd><p>If given, the stdcall suffixes (@<var>nn</var>) will be stripped from 2956symbols before they are exported. 2957[This option is specific to the i386 PE targeted port of the linker] 2958</p> 2959<a name="index-_002d_002dlarge_002daddress_002daware"></a> 2960</dd> 2961<dt><code>--large-address-aware</code></dt> 2962<dd><p>If given, the appropriate bit in the “Characteristics” field of the COFF 2963header is set to indicate that this executable supports virtual addresses 2964greater than 2 gigabytes. This should be used in conjunction with the /3GB 2965or /USERVA=<var>value</var> megabytes switch in the “[operating systems]” 2966section of the BOOT.INI. Otherwise, this bit has no effect. 2967[This option is specific to PE targeted ports of the linker] 2968</p> 2969<a name="index-_002d_002ddisable_002dlarge_002daddress_002daware"></a> 2970</dd> 2971<dt><code>--disable-large-address-aware</code></dt> 2972<dd><p>Reverts the effect of a previous ‘<samp>--large-address-aware</samp>’ option. 2973This is useful if ‘<samp>--large-address-aware</samp>’ is always set by the compiler 2974driver (e.g. Cygwin gcc) and the executable does not support virtual 2975addresses greater than 2 gigabytes. 2976[This option is specific to PE targeted ports of the linker] 2977</p> 2978<a name="index-_002d_002dmajor_002dimage_002dversion"></a> 2979</dd> 2980<dt><code>--major-image-version <var>value</var></code></dt> 2981<dd><p>Sets the major number of the “image version”. Defaults to 1. 2982[This option is specific to the i386 PE targeted port of the linker] 2983</p> 2984<a name="index-_002d_002dmajor_002dos_002dversion"></a> 2985</dd> 2986<dt><code>--major-os-version <var>value</var></code></dt> 2987<dd><p>Sets the major number of the “os version”. Defaults to 4. 2988[This option is specific to the i386 PE targeted port of the linker] 2989</p> 2990<a name="index-_002d_002dmajor_002dsubsystem_002dversion"></a> 2991</dd> 2992<dt><code>--major-subsystem-version <var>value</var></code></dt> 2993<dd><p>Sets the major number of the “subsystem version”. Defaults to 4. 2994[This option is specific to the i386 PE targeted port of the linker] 2995</p> 2996<a name="index-_002d_002dminor_002dimage_002dversion"></a> 2997</dd> 2998<dt><code>--minor-image-version <var>value</var></code></dt> 2999<dd><p>Sets the minor number of the “image version”. Defaults to 0. 3000[This option is specific to the i386 PE targeted port of the linker] 3001</p> 3002<a name="index-_002d_002dminor_002dos_002dversion"></a> 3003</dd> 3004<dt><code>--minor-os-version <var>value</var></code></dt> 3005<dd><p>Sets the minor number of the “os version”. Defaults to 0. 3006[This option is specific to the i386 PE targeted port of the linker] 3007</p> 3008<a name="index-_002d_002dminor_002dsubsystem_002dversion"></a> 3009</dd> 3010<dt><code>--minor-subsystem-version <var>value</var></code></dt> 3011<dd><p>Sets the minor number of the “subsystem version”. Defaults to 0. 3012[This option is specific to the i386 PE targeted port of the linker] 3013</p> 3014<a name="index-DEF-files_002c-creating"></a> 3015<a name="index-DLLs_002c-creating-1"></a> 3016<a name="index-_002d_002doutput_002ddef"></a> 3017</dd> 3018<dt><code>--output-def <var>file</var></code></dt> 3019<dd><p>The linker will create the file <var>file</var> which will contain a DEF 3020file corresponding to the DLL the linker is generating. This DEF file 3021(which should be called <code>*.def</code>) may be used to create an import 3022library with <code>dlltool</code> or may be used as a reference to 3023automatically or implicitly exported symbols. 3024[This option is specific to the i386 PE targeted port of the linker] 3025</p> 3026<a name="index-DLLs_002c-creating-2"></a> 3027<a name="index-_002d_002denable_002dauto_002dimage_002dbase"></a> 3028</dd> 3029<dt><code>--enable-auto-image-base</code></dt> 3030<dt><code>--enable-auto-image-base=<var>value</var></code></dt> 3031<dd><p>Automatically choose the image base for DLLs, optionally starting with base 3032<var>value</var>, unless one is specified using the <code>--image-base</code> argument. 3033By using a hash generated from the dllname to create unique image bases 3034for each DLL, in-memory collisions and relocations which can delay program 3035execution are avoided. 3036[This option is specific to the i386 PE targeted port of the linker] 3037</p> 3038<a name="index-_002d_002ddisable_002dauto_002dimage_002dbase"></a> 3039</dd> 3040<dt><code>--disable-auto-image-base</code></dt> 3041<dd><p>Do not automatically generate a unique image base. If there is no 3042user-specified image base (<code>--image-base</code>) then use the platform 3043default. 3044[This option is specific to the i386 PE targeted port of the linker] 3045</p> 3046<a name="index-DLLs_002c-linking-to"></a> 3047<a name="index-_002d_002ddll_002dsearch_002dprefix"></a> 3048</dd> 3049<dt><code>--dll-search-prefix <var>string</var></code></dt> 3050<dd><p>When linking dynamically to a dll without an import library, 3051search for <code><string><basename>.dll</code> in preference to 3052<code>lib<basename>.dll</code>. This behaviour allows easy distinction 3053between DLLs built for the various "subplatforms": native, cygwin, 3054uwin, pw, etc. For instance, cygwin DLLs typically use 3055<code>--dll-search-prefix=cyg</code>. 3056[This option is specific to the i386 PE targeted port of the linker] 3057</p> 3058<a name="index-_002d_002denable_002dauto_002dimport"></a> 3059</dd> 3060<dt><code>--enable-auto-import</code></dt> 3061<dd><p>Do sophisticated linking of <code>_symbol</code> to <code>__imp__symbol</code> for 3062DATA imports from DLLs, thus making it possible to bypass the dllimport 3063mechanism on the user side and to reference unmangled symbol names. 3064[This option is specific to the i386 PE targeted port of the linker] 3065</p> 3066<p>The following remarks pertain to the original implementation of the 3067feature and are obsolete nowadays for Cygwin and MinGW targets. 3068</p> 3069<p>Note: Use of the ’auto-import’ extension will cause the text section 3070of the image file to be made writable. This does not conform to the 3071PE-COFF format specification published by Microsoft. 3072</p> 3073<p>Note - use of the ’auto-import’ extension will also cause read only 3074data which would normally be placed into the .rdata section to be 3075placed into the .data section instead. This is in order to work 3076around a problem with consts that is described here: 3077http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html 3078</p> 3079<p>Using ’auto-import’ generally will ’just work’ – but sometimes you may 3080see this message: 3081</p> 3082<p>"variable ’<var>’ can’t be auto-imported. Please read the 3083documentation for ld’s <code>--enable-auto-import</code> for details." 3084</p> 3085<p>This message occurs when some (sub)expression accesses an address 3086ultimately given by the sum of two constants (Win32 import tables only 3087allow one). Instances where this may occur include accesses to member 3088fields of struct variables imported from a DLL, as well as using a 3089constant index into an array variable imported from a DLL. Any 3090multiword variable (arrays, structs, long long, etc) may trigger 3091this error condition. However, regardless of the exact data type 3092of the offending exported variable, ld will always detect it, issue 3093the warning, and exit. 3094</p> 3095<p>There are several ways to address this difficulty, regardless of the 3096data type of the exported variable: 3097</p> 3098<p>One way is to use –enable-runtime-pseudo-reloc switch. This leaves the task 3099of adjusting references in your client code for runtime environment, so 3100this method works only when runtime environment supports this feature. 3101</p> 3102<p>A second solution is to force one of the ’constants’ to be a variable – 3103that is, unknown and un-optimizable at compile time. For arrays, 3104there are two possibilities: a) make the indexee (the array’s address) 3105a variable, or b) make the ’constant’ index a variable. Thus: 3106</p> 3107<div class="example"> 3108<pre class="example">extern type extern_array[]; 3109extern_array[1] --> 3110 { volatile type *t=extern_array; t[1] } 3111</pre></div> 3112 3113<p>or 3114</p> 3115<div class="example"> 3116<pre class="example">extern type extern_array[]; 3117extern_array[1] --> 3118 { volatile int t=1; extern_array[t] } 3119</pre></div> 3120 3121<p>For structs (and most other multiword data types) the only option 3122is to make the struct itself (or the long long, or the ...) variable: 3123</p> 3124<div class="example"> 3125<pre class="example">extern struct s extern_struct; 3126extern_struct.field --> 3127 { volatile struct s *t=&extern_struct; t->field } 3128</pre></div> 3129 3130<p>or 3131</p> 3132<div class="example"> 3133<pre class="example">extern long long extern_ll; 3134extern_ll --> 3135 { volatile long long * local_ll=&extern_ll; *local_ll } 3136</pre></div> 3137 3138<p>A third method of dealing with this difficulty is to abandon 3139’auto-import’ for the offending symbol and mark it with 3140<code>__declspec(dllimport)</code>. However, in practice that 3141requires using compile-time #defines to indicate whether you are 3142building a DLL, building client code that will link to the DLL, or 3143merely building/linking to a static library. In making the choice 3144between the various methods of resolving the ’direct address with 3145constant offset’ problem, you should consider typical real-world usage: 3146</p> 3147<p>Original: 3148</p><div class="example"> 3149<pre class="example">--foo.h 3150extern int arr[]; 3151--foo.c 3152#include "foo.h" 3153void main(int argc, char **argv){ 3154 printf("%d\n",arr[1]); 3155} 3156</pre></div> 3157 3158<p>Solution 1: 3159</p><div class="example"> 3160<pre class="example">--foo.h 3161extern int arr[]; 3162--foo.c 3163#include "foo.h" 3164void main(int argc, char **argv){ 3165 /* This workaround is for win32 and cygwin; do not "optimize" */ 3166 volatile int *parr = arr; 3167 printf("%d\n",parr[1]); 3168} 3169</pre></div> 3170 3171<p>Solution 2: 3172</p><div class="example"> 3173<pre class="example">--foo.h 3174/* Note: auto-export is assumed (no __declspec(dllexport)) */ 3175#if (defined(_WIN32) || defined(__CYGWIN__)) && \ 3176 !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) 3177#define FOO_IMPORT __declspec(dllimport) 3178#else 3179#define FOO_IMPORT 3180#endif 3181extern FOO_IMPORT int arr[]; 3182--foo.c 3183#include "foo.h" 3184void main(int argc, char **argv){ 3185 printf("%d\n",arr[1]); 3186} 3187</pre></div> 3188 3189<p>A fourth way to avoid this problem is to re-code your 3190library to use a functional interface rather than a data interface 3191for the offending variables (e.g. set_foo() and get_foo() accessor 3192functions). 3193</p> 3194<a name="index-_002d_002ddisable_002dauto_002dimport"></a> 3195</dd> 3196<dt><code>--disable-auto-import</code></dt> 3197<dd><p>Do not attempt to do sophisticated linking of <code>_symbol</code> to 3198<code>__imp__symbol</code> for DATA imports from DLLs. 3199[This option is specific to the i386 PE targeted port of the linker] 3200</p> 3201<a name="index-_002d_002denable_002druntime_002dpseudo_002dreloc"></a> 3202</dd> 3203<dt><code>--enable-runtime-pseudo-reloc</code></dt> 3204<dd><p>If your code contains expressions described in –enable-auto-import section, 3205that is, DATA imports from DLL with non-zero offset, this switch will create 3206a vector of ’runtime pseudo relocations’ which can be used by runtime 3207environment to adjust references to such data in your client code. 3208[This option is specific to the i386 PE targeted port of the linker] 3209</p> 3210<a name="index-_002d_002ddisable_002druntime_002dpseudo_002dreloc"></a> 3211</dd> 3212<dt><code>--disable-runtime-pseudo-reloc</code></dt> 3213<dd><p>Do not create pseudo relocations for non-zero offset DATA imports from DLLs. 3214[This option is specific to the i386 PE targeted port of the linker] 3215</p> 3216<a name="index-_002d_002denable_002dextra_002dpe_002ddebug"></a> 3217</dd> 3218<dt><code>--enable-extra-pe-debug</code></dt> 3219<dd><p>Show additional debug info related to auto-import symbol thunking. 3220[This option is specific to the i386 PE targeted port of the linker] 3221</p> 3222<a name="index-_002d_002dsection_002dalignment"></a> 3223</dd> 3224<dt><code>--section-alignment</code></dt> 3225<dd><p>Sets the section alignment. Sections in memory will always begin at 3226addresses which are a multiple of this number. Defaults to 0x1000. 3227[This option is specific to the i386 PE targeted port of the linker] 3228</p> 3229<a name="index-stack-size"></a> 3230<a name="index-_002d_002dstack"></a> 3231</dd> 3232<dt><code>--stack <var>reserve</var></code></dt> 3233<dt><code>--stack <var>reserve</var>,<var>commit</var></code></dt> 3234<dd><p>Specify the number of bytes of memory to reserve (and optionally commit) 3235to be used as stack for this program. The default is 2MB reserved, 4K 3236committed. 3237[This option is specific to the i386 PE targeted port of the linker] 3238</p> 3239<a name="index-_002d_002dsubsystem"></a> 3240</dd> 3241<dt><code>--subsystem <var>which</var></code></dt> 3242<dt><code>--subsystem <var>which</var>:<var>major</var></code></dt> 3243<dt><code>--subsystem <var>which</var>:<var>major</var>.<var>minor</var></code></dt> 3244<dd><p>Specifies the subsystem under which your program will execute. The 3245legal values for <var>which</var> are <code>native</code>, <code>windows</code>, 3246<code>console</code>, <code>posix</code>, and <code>xbox</code>. You may optionally set 3247the subsystem version also. Numeric values are also accepted for 3248<var>which</var>. 3249[This option is specific to the i386 PE targeted port of the linker] 3250</p> 3251<p>The following options set flags in the <code>DllCharacteristics</code> field 3252of the PE file header: 3253[These options are specific to PE targeted ports of the linker] 3254</p> 3255<a name="index-_002d_002dhigh_002dentropy_002dva"></a> 3256</dd> 3257<dt><code>--high-entropy-va</code></dt> 3258<dt><code>--disable-high-entropy-va</code></dt> 3259<dd><p>Image is compatible with 64-bit address space layout randomization 3260(ASLR). This option is enabled by default for 64-bit PE images. 3261</p> 3262<p>This option also implies <samp>--dynamicbase</samp> and 3263<samp>--enable-reloc-section</samp>. 3264</p> 3265<a name="index-_002d_002ddynamicbase"></a> 3266</dd> 3267<dt><code>--dynamicbase</code></dt> 3268<dt><code>--disable-dynamicbase</code></dt> 3269<dd><p>The image base address may be relocated using address space layout 3270randomization (ASLR). This feature was introduced with MS Windows 3271Vista for i386 PE targets. This option is enabled by default but 3272can be disabled via the <samp>--disable-dynamicbase</samp> option. 3273This option also implies <samp>--enable-reloc-section</samp>. 3274</p> 3275<a name="index-_002d_002dforceinteg"></a> 3276</dd> 3277<dt><code>--forceinteg</code></dt> 3278<dt><code>--disable-forceinteg</code></dt> 3279<dd><p>Code integrity checks are enforced. This option is disabled by 3280default. 3281</p> 3282<a name="index-_002d_002dnxcompat"></a> 3283</dd> 3284<dt><code>--nxcompat</code></dt> 3285<dt><code>--disable-nxcompat</code></dt> 3286<dd><p>The image is compatible with the Data Execution Prevention. 3287This feature was introduced with MS Windows XP SP2 for i386 PE 3288targets. The option is enabled by default. 3289</p> 3290<a name="index-_002d_002dno_002disolation"></a> 3291</dd> 3292<dt><code>--no-isolation</code></dt> 3293<dt><code>--disable-no-isolation</code></dt> 3294<dd><p>Although the image understands isolation, do not isolate the image. 3295This option is disabled by default. 3296</p> 3297<a name="index-_002d_002dno_002dseh"></a> 3298</dd> 3299<dt><code>--no-seh</code></dt> 3300<dt><code>--disable-no-seh</code></dt> 3301<dd><p>The image does not use SEH. No SE handler may be called from 3302this image. This option is disabled by default. 3303</p> 3304<a name="index-_002d_002dno_002dbind"></a> 3305</dd> 3306<dt><code>--no-bind</code></dt> 3307<dt><code>--disable-no-bind</code></dt> 3308<dd><p>Do not bind this image. This option is disabled by default. 3309</p> 3310<a name="index-_002d_002dwdmdriver"></a> 3311</dd> 3312<dt><code>--wdmdriver</code></dt> 3313<dt><code>--disable-wdmdriver</code></dt> 3314<dd><p>The driver uses the MS Windows Driver Model. This option is disabled 3315by default. 3316</p> 3317<a name="index-_002d_002dtsaware"></a> 3318</dd> 3319<dt><code>--tsaware</code></dt> 3320<dt><code>--disable-tsaware</code></dt> 3321<dd><p>The image is Terminal Server aware. This option is disabled by 3322default. 3323</p> 3324<a name="index-_002d_002dinsert_002dtimestamp"></a> 3325</dd> 3326<dt><code>--insert-timestamp</code></dt> 3327<dt><code>--no-insert-timestamp</code></dt> 3328<dd><p>Insert a real timestamp into the image. This is the default behaviour 3329as it matches legacy code and it means that the image will work with 3330other, proprietary tools. The problem with this default is that it 3331will result in slightly different images being produced each time the 3332same sources are linked. The option <samp>--no-insert-timestamp</samp> 3333can be used to insert a zero value for the timestamp, this ensuring 3334that binaries produced from identical sources will compare 3335identically. 3336</p> 3337<a name="index-_002d_002denable_002dreloc_002dsection"></a> 3338</dd> 3339<dt><code>--enable-reloc-section</code></dt> 3340<dt><code>--disable-reloc-section</code></dt> 3341<dd><p>Create the base relocation table, which is necessary if the image 3342is loaded at a different image base than specified in the PE header. 3343This option is enabled by default. 3344</p></dd> 3345</dl> 3346 3347 3348<a name="Options-specific-to-C6X-uClinux-targets"></a> 3349<h4 class="subsection">2.1.2 Options specific to C6X uClinux targets</h4> 3350 3351 3352<p>The C6X uClinux target uses a binary format called DSBT to support shared 3353libraries. Each shared library in the system needs to have a unique index; 3354all executables use an index of 0. 3355</p> 3356<dl compact="compact"> 3357<dd> 3358<a name="index-_002d_002ddsbt_002dsize"></a> 3359</dd> 3360<dt><code>--dsbt-size <var>size</var></code></dt> 3361<dd><p>This option sets the number of entries in the DSBT of the current executable 3362or shared library to <var>size</var>. The default is to create a table with 64 3363entries. 3364</p> 3365<a name="index-_002d_002ddsbt_002dindex"></a> 3366</dd> 3367<dt><code>--dsbt-index <var>index</var></code></dt> 3368<dd><p>This option sets the DSBT index of the current executable or shared library 3369to <var>index</var>. The default is 0, which is appropriate for generating 3370executables. If a shared library is generated with a DSBT index of 0, the 3371<code>R_C6000_DSBT_INDEX</code> relocs are copied into the output file. 3372</p> 3373<a name="index-_002d_002dno_002dmerge_002dexidx_002dentries"></a> 3374<p>The ‘<samp>--no-merge-exidx-entries</samp>’ switch disables the merging of adjacent 3375exidx entries in frame unwind info. 3376</p> 3377</dd> 3378</dl> 3379 3380 3381<a name="Options-specific-to-C_002dSKY-targets"></a> 3382<h4 class="subsection">2.1.3 Options specific to C-SKY targets</h4> 3383 3384 3385<dl compact="compact"> 3386<dd> 3387<a name="index-_002d_002dbranch_002dstub-on-C_002dSKY"></a> 3388</dd> 3389<dt><code>--branch-stub</code></dt> 3390<dd><p>This option enables linker branch relaxation by inserting branch stub 3391sections when needed to extend the range of branches. This option is 3392usually not required since C-SKY supports branch and call instructions that 3393can access the full memory range and branch relaxation is normally handled by 3394the compiler or assembler. 3395</p> 3396<a name="index-_002d_002dstub_002dgroup_002dsize-on-C_002dSKY"></a> 3397</dd> 3398<dt><code>--stub-group-size=<var>N</var></code></dt> 3399<dd><p>This option allows finer control of linker branch stub creation. 3400It sets the maximum size of a group of input sections that can 3401be handled by one stub section. A negative value of <var>N</var> locates 3402stub sections after their branches, while a positive value allows stub 3403sections to appear either before or after the branches. Values of 3404‘<samp>1</samp>’ or ‘<samp>-1</samp>’ indicate that the 3405linker should choose suitable defaults. 3406</p> 3407</dd> 3408</dl> 3409 3410 3411<a name="Options-specific-to-Motorola-68HC11-and-68HC12-targets"></a> 3412<h4 class="subsection">2.1.4 Options specific to Motorola 68HC11 and 68HC12 targets</h4> 3413 3414 3415<p>The 68HC11 and 68HC12 linkers support specific options to control the 3416memory bank switching mapping and trampoline code generation. 3417</p> 3418<dl compact="compact"> 3419<dd> 3420<a name="index-_002d_002dno_002dtrampoline"></a> 3421</dd> 3422<dt><code>--no-trampoline</code></dt> 3423<dd><p>This option disables the generation of trampoline. By default a trampoline 3424is generated for each far function which is called using a <code>jsr</code> 3425instruction (this happens when a pointer to a far function is taken). 3426</p> 3427<a name="index-_002d_002dbank_002dwindow"></a> 3428</dd> 3429<dt><code>--bank-window <var>name</var></code></dt> 3430<dd><p>This option indicates to the linker the name of the memory region in 3431the ‘<samp>MEMORY</samp>’ specification that describes the memory bank window. 3432The definition of such region is then used by the linker to compute 3433paging and addresses within the memory window. 3434</p> 3435</dd> 3436</dl> 3437 3438 3439<a name="Options-specific-to-Motorola-68K-target"></a> 3440<h4 class="subsection">2.1.5 Options specific to Motorola 68K target</h4> 3441 3442 3443<p>The following options are supported to control handling of GOT generation 3444when linking for 68K targets. 3445</p> 3446<dl compact="compact"> 3447<dd> 3448<a name="index-_002d_002dgot"></a> 3449</dd> 3450<dt><code>--got=<var>type</var></code></dt> 3451<dd><p>This option tells the linker which GOT generation scheme to use. 3452<var>type</var> should be one of ‘<samp>single</samp>’, ‘<samp>negative</samp>’, 3453‘<samp>multigot</samp>’ or ‘<samp>target</samp>’. For more information refer to the 3454Info entry for <samp>ld</samp>. 3455</p> 3456</dd> 3457</dl> 3458 3459 3460<a name="Options-specific-to-MIPS-targets"></a> 3461<h4 class="subsection">2.1.6 Options specific to MIPS targets</h4> 3462 3463 3464<p>The following options are supported to control microMIPS instruction 3465generation and branch relocation checks for ISA mode transitions when 3466linking for MIPS targets. 3467</p> 3468<dl compact="compact"> 3469<dd> 3470<a name="index-_002d_002dinsn32"></a> 3471</dd> 3472<dt><code>--insn32</code></dt> 3473<dd><a name="index-_002d_002dno_002dinsn32"></a> 3474</dd> 3475<dt><code>--no-insn32</code></dt> 3476<dd><p>These options control the choice of microMIPS instructions used in code 3477generated by the linker, such as that in the PLT or lazy binding stubs, 3478or in relaxation. If ‘<samp>--insn32</samp>’ is used, then the linker only uses 347932-bit instruction encodings. By default or if ‘<samp>--no-insn32</samp>’ is 3480used, all instruction encodings are used, including 16-bit ones where 3481possible. 3482</p> 3483<a name="index-_002d_002dignore_002dbranch_002disa"></a> 3484</dd> 3485<dt><code>--ignore-branch-isa</code></dt> 3486<dd><a name="index-_002d_002dno_002dignore_002dbranch_002disa"></a> 3487</dd> 3488<dt><code>--no-ignore-branch-isa</code></dt> 3489<dd><p>These options control branch relocation checks for invalid ISA mode 3490transitions. If ‘<samp>--ignore-branch-isa</samp>’ is used, then the linker 3491accepts any branch relocations and any ISA mode transition required 3492is lost in relocation calculation, except for some cases of <code>BAL</code> 3493instructions which meet relaxation conditions and are converted to 3494equivalent <code>JALX</code> instructions as the associated relocation is 3495calculated. By default or if ‘<samp>--no-ignore-branch-isa</samp>’ is used 3496a check is made causing the loss of an ISA mode transition to produce 3497an error. 3498</p> 3499<a name="index-_002d_002dcompact_002dbranches"></a> 3500</dd> 3501<dt><code>--compact-branches</code></dt> 3502<dd><a name="index-_002d_002dno_002dcompact_002dbranches"></a> 3503</dd> 3504<dt><code>--no-compact-branches</code></dt> 3505<dd><p>These options control the generation of compact instructions by the linker 3506in the PLT entries for MIPS R6. 3507</p> 3508</dd> 3509</dl> 3510 3511 3512 3513<a name="Options-specific-to-PDP11-targets"></a> 3514<h4 class="subsection">2.1.7 Options specific to PDP11 targets</h4> 3515 3516 3517<p>For the pdp11-aout target, three variants of the output format can be 3518produced as selected by the following options. The default variant 3519for pdp11-aout is the ‘<samp>--omagic</samp>’ option, whereas for other 3520targets ‘<samp>--nmagic</samp>’ is the default. The ‘<samp>--imagic</samp>’ option is 3521defined only for the pdp11-aout target, while the others are described 3522here as they apply to the pdp11-aout target. 3523</p> 3524<dl compact="compact"> 3525<dd> 3526<a name="index-_002dN-1"></a> 3527</dd> 3528<dt><code>-N</code></dt> 3529<dd><a name="index-_002d_002domagic-1"></a> 3530</dd> 3531<dt><code>--omagic</code></dt> 3532<dd> 3533<p>Mark the output as <code>OMAGIC</code> (0407) in the <samp>a.out</samp> header to 3534indicate that the text segment is not to be write-protected and 3535shared. Since the text and data sections are both readable and 3536writable, the data section is allocated immediately contiguous after 3537the text segment. This is the oldest format for PDP11 executable 3538programs and is the default for <code>ld</code> on PDP11 Unix systems 3539from the beginning through 2.11BSD. 3540</p> 3541<a name="index-_002dn-1"></a> 3542</dd> 3543<dt><code>-n</code></dt> 3544<dd><a name="index-_002d_002dnmagic-1"></a> 3545</dd> 3546<dt><code>--nmagic</code></dt> 3547<dd> 3548<p>Mark the output as <code>NMAGIC</code> (0410) in the <samp>a.out</samp> header to 3549indicate that when the output file is executed, the text portion will 3550be read-only and shareable among all processes executing the same 3551file. This involves moving the data areas up to the first possible 8K 3552byte page boundary following the end of the text. This option creates 3553a <em>pure executable</em> format. 3554</p> 3555<a name="index-_002dz"></a> 3556</dd> 3557<dt><code>-z</code></dt> 3558<dd><a name="index-_002d_002dimagic"></a> 3559</dd> 3560<dt><code>--imagic</code></dt> 3561<dd> 3562<p>Mark the output as <code>IMAGIC</code> (0411) in the <samp>a.out</samp> header to 3563indicate that when the output file is executed, the program text and 3564data areas will be loaded into separate address spaces using the split 3565instruction and data space feature of the memory management unit in 3566larger models of the PDP11. This doubles the address space available 3567to the program. The text segment is again pure, write-protected, and 3568shareable. The only difference in the output format between this 3569option and the others, besides the magic number, is that both the text 3570and data sections start at location 0. The ‘<samp>-z</samp>’ option selected 3571this format in 2.11BSD. This option creates a <em>separate 3572executable</em> format. 3573</p> 3574<a name="index-_002d_002dno_002domagic-1"></a> 3575</dd> 3576<dt><code>--no-omagic</code></dt> 3577<dd> 3578<p>Equivalent to ‘<samp>--nmagic</samp>’ for pdp11-aout. 3579</p> 3580</dd> 3581</dl> 3582 3583 3584<hr> 3585<div class="header"> 3586<p> 3587Next: <a href="Environment.html#Environment" accesskey="n" rel="next">Environment</a>, Up: <a href="Invocation.html#Invocation" accesskey="u" rel="up">Invocation</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p> 3588</div> 3589 3590 3591 3592</body> 3593</html> 3594