Merge branch 'vendor/TNFTP'
[dragonfly.git] / contrib / binutils-2.24 / ld / ld.1
1 .\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 'br\}
42 .\"
43 .\" Escape single quotes in literal strings from groff's Unicode transform.
44 .ie \n(.g .ds Aq \(aq
45 .el       .ds Aq '
46 .\"
47 .\" If the F register is turned on, we'll generate index entries on stderr for
48 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
49 .\" entries marked with X<> in POD.  Of course, you'll have to process the
50 .\" output yourself in some meaningful fashion.
51 .ie \nF \{\
52 .    de IX
53 .    tm Index:\\$1\t\\n%\t"\\$2"
54 ..
55 .    nr % 0
56 .    rr F
57 .\}
58 .el \{\
59 .    de IX
60 ..
61 .\}
62 .\"
63 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
65 .    \" fudge factors for nroff and troff
66 .if n \{\
67 .    ds #H 0
68 .    ds #V .8m
69 .    ds #F .3m
70 .    ds #[ \f1
71 .    ds #] \fP
72 .\}
73 .if t \{\
74 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
75 .    ds #V .6m
76 .    ds #F 0
77 .    ds #[ \&
78 .    ds #] \&
79 .\}
80 .    \" simple accents for nroff and troff
81 .if n \{\
82 .    ds ' \&
83 .    ds ` \&
84 .    ds ^ \&
85 .    ds , \&
86 .    ds ~ ~
87 .    ds /
88 .\}
89 .if t \{\
90 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
91 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
92 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
93 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
94 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
95 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
96 .\}
97 .    \" troff and (daisy-wheel) nroff accents
98 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
99 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
100 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
101 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
102 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
103 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
104 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
105 .ds ae a\h'-(\w'a'u*4/10)'e
106 .ds Ae A\h'-(\w'A'u*4/10)'E
107 .    \" corrections for vroff
108 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
109 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
110 .    \" for low resolution devices (crt and lpr)
111 .if \n(.H>23 .if \n(.V>19 \
112 \{\
113 .    ds : e
114 .    ds 8 ss
115 .    ds o a
116 .    ds d- d\h'-1'\(ga
117 .    ds D- D\h'-1'\(hy
118 .    ds th \o'bp'
119 .    ds Th \o'LP'
120 .    ds ae ae
121 .    ds Ae AE
122 .\}
123 .rm #[ #] #H #V #F C
124 .\" ========================================================================
125 .\"
126 .IX Title "LD 1"
127 .TH LD 1 "2013-11-26" "binutils-2.23.92" "GNU Development Tools"
128 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
129 .\" way too many mistakes in technical documents.
130 .if n .ad l
131 .nh
132 .SH "NAME"
133 ld \- The GNU linker
134 .SH "SYNOPSIS"
135 .IX Header "SYNOPSIS"
136 ld [\fBoptions\fR] \fIobjfile\fR ...
137 .SH "DESCRIPTION"
138 .IX Header "DESCRIPTION"
139 \&\fBld\fR combines a number of object and archive files, relocates
140 their data and ties up symbol references. Usually the last step in
141 compiling a program is to run \fBld\fR.
142 .PP
143 \&\fBld\fR accepts Linker Command Language files written in
144 a superset of \s-1AT&T\s0's Link Editor Command Language syntax,
145 to provide explicit and total control over the linking process.
146 .PP
147 This man page does not describe the command language; see the
148 \&\fBld\fR entry in \f(CW\*(C`info\*(C'\fR for full details on the command
149 language and on other aspects of the \s-1GNU\s0 linker.
150 .PP
151 This version of \fBld\fR uses the general purpose \s-1BFD\s0 libraries
152 to operate on object files. This allows \fBld\fR to read, combine, and
153 write object files in many different formats\-\-\-for example, \s-1COFF\s0 or
154 \&\f(CW\*(C`a.out\*(C'\fR.  Different formats may be linked together to produce any
155 available kind of object file.
156 .PP
157 Aside from its flexibility, the \s-1GNU\s0 linker is more helpful than other
158 linkers in providing diagnostic information.  Many linkers abandon
159 execution immediately upon encountering an error; whenever possible,
160 \&\fBld\fR continues executing, allowing you to identify other errors
161 (or, in some cases, to get an output file in spite of the error).
162 .PP
163 The \s-1GNU\s0 linker \fBld\fR is meant to cover a broad range of situations,
164 and to be as compatible as possible with other linkers.  As a result,
165 you have many choices to control its behavior.
166 .SH "OPTIONS"
167 .IX Header "OPTIONS"
168 The linker supports a plethora of command-line options, but in actual
169 practice few of them are used in any particular context.
170 For instance, a frequent use of \fBld\fR is to link standard Unix
171 object files on a standard, supported Unix system.  On such a system, to
172 link a file \f(CW\*(C`hello.o\*(C'\fR:
173 .PP
174 .Vb 1
175 \&        ld \-o <output> /lib/crt0.o hello.o \-lc
176 .Ve
177 .PP
178 This tells \fBld\fR to produce a file called \fIoutput\fR as the
179 result of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR and
180 the library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard search
181 directories.  (See the discussion of the \fB\-l\fR option below.)
182 .PP
183 Some of the command-line options to \fBld\fR may be specified at any
184 point in the command line.  However, options which refer to files, such
185 as \fB\-l\fR or \fB\-T\fR, cause the file to be read at the point at
186 which the option appears in the command line, relative to the object
187 files and other file options.  Repeating non-file options with a
188 different argument will either have no further effect, or override prior
189 occurrences (those further to the left on the command line) of that
190 option.  Options which may be meaningfully specified more than once are
191 noted in the descriptions below.
192 .PP
193 Non-option arguments are object files or archives which are to be linked
194 together.  They may follow, precede, or be mixed in with command-line
195 options, except that an object file argument may not be placed between
196 an option and its argument.
197 .PP
198 Usually the linker is invoked with at least one object file, but you can
199 specify other forms of binary input files using \fB\-l\fR, \fB\-R\fR,
200 and the script command language.  If \fIno\fR binary input files at all
201 are specified, the linker does not produce any output, and issues the
202 message \fBNo input files\fR.
203 .PP
204 If the linker cannot recognize the format of an object file, it will
205 assume that it is a linker script.  A script specified in this way
206 augments the main linker script used for the link (either the default
207 linker script or the one specified by using \fB\-T\fR).  This feature
208 permits the linker to link against a file which appears to be an object
209 or an archive, but actually merely defines some symbol values, or uses
210 \&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects.  Specifying a
211 script in this way merely augments the main linker script, with the
212 extra commands placed after the main script; use the \fB\-T\fR option
213 to replace the default linker script entirely, but note the effect of
214 the \f(CW\*(C`INSERT\*(C'\fR command.
215 .PP
216 For options whose names are a single letter,
217 option arguments must either follow the option letter without intervening
218 whitespace, or be given as separate arguments immediately following the
219 option that requires them.
220 .PP
221 For options whose names are multiple letters, either one dash or two can
222 precede the option name; for example, \fB\-trace\-symbol\fR and
223 \&\fB\-\-trace\-symbol\fR are equivalent.  Note\-\-\-there is one exception to
224 this rule.  Multiple letter options that start with a lower case 'o' can
225 only be preceded by two dashes.  This is to reduce confusion with the
226 \&\fB\-o\fR option.  So for example \fB\-omagic\fR sets the output file
227 name to \fBmagic\fR whereas \fB\-\-omagic\fR sets the \s-1NMAGIC\s0 flag on the
228 output.
229 .PP
230 Arguments to multiple-letter options must either be separated from the
231 option name by an equals sign, or be given as separate arguments
232 immediately following the option that requires them.  For example,
233 \&\fB\-\-trace\-symbol foo\fR and \fB\-\-trace\-symbol=foo\fR are equivalent.
234 Unique abbreviations of the names of multiple-letter options are
235 accepted.
236 .PP
237 Note\-\-\-if the linker is being invoked indirectly, via a compiler driver
238 (e.g. \fBgcc\fR) then all the linker command line options should be
239 prefixed by \fB\-Wl,\fR (or whatever is appropriate for the particular
240 compiler driver) like this:
241 .PP
242 .Vb 1
243 \&          gcc \-Wl,\-\-start\-group foo.o bar.o \-Wl,\-\-end\-group
244 .Ve
245 .PP
246 This is important, because otherwise the compiler driver program may
247 silently drop the linker options, resulting in a bad link.  Confusion
248 may also arise when passing options that require values through a
249 driver, as the use of a space between option and argument acts as
250 a separator, and causes the driver to pass only the option to the linker
251 and the argument to the compiler.  In this case, it is simplest to use
252 the joined forms of both single\- and multiple-letter options, such as:
253 .PP
254 .Vb 1
255 \&          gcc foo.o bar.o \-Wl,\-eENTRY \-Wl,\-Map=a.map
256 .Ve
257 .PP
258 Here is a table of the generic command line switches accepted by the \s-1GNU\s0
259 linker:
260 .IP "\fB@\fR\fIfile\fR" 4
261 .IX Item "@file"
262 Read command-line options from \fIfile\fR.  The options read are
263 inserted in place of the original @\fIfile\fR option.  If \fIfile\fR
264 does not exist, or cannot be read, then the option will be treated
265 literally, and not removed.
266 .Sp
267 Options in \fIfile\fR are separated by whitespace.  A whitespace
268 character may be included in an option by surrounding the entire
269 option in either single or double quotes.  Any character (including a
270 backslash) may be included by prefixing the character to be included
271 with a backslash.  The \fIfile\fR may itself contain additional
272 @\fIfile\fR options; any such options will be processed recursively.
273 .IP "\fB\-a\fR \fIkeyword\fR" 4
274 .IX Item "-a keyword"
275 This option is supported for \s-1HP/UX\s0 compatibility.  The \fIkeyword\fR
276 argument must be one of the strings \fBarchive\fR, \fBshared\fR, or
277 \&\fBdefault\fR.  \fB\-aarchive\fR is functionally equivalent to
278 \&\fB\-Bstatic\fR, and the other two keywords are functionally equivalent
279 to \fB\-Bdynamic\fR.  This option may be used any number of times.
280 .IP "\fB\-\-audit\fR \fI\s-1AUDITLIB\s0\fR" 4
281 .IX Item "--audit AUDITLIB"
282 Adds \fI\s-1AUDITLIB\s0\fR to the \f(CW\*(C`DT_AUDIT\*(C'\fR entry of the dynamic section.
283 \&\fI\s-1AUDITLIB\s0\fR is not checked for existence, nor will it use the \s-1DT_SONAME\s0
284 specified in the library.  If specified multiple times \f(CW\*(C`DT_AUDIT\*(C'\fR
285 will contain a colon separated list of audit interfaces to use. If the linker
286 finds an object with an audit entry while searching for shared libraries,
287 it will add a corresponding \f(CW\*(C`DT_DEPAUDIT\*(C'\fR entry in the output file.
288 This option is only meaningful on \s-1ELF\s0 platforms supporting the rtld-audit
289 interface.
290 .IP "\fB\-A\fR \fIarchitecture\fR" 4
291 .IX Item "-A architecture"
292 .PD 0
293 .IP "\fB\-\-architecture=\fR\fIarchitecture\fR" 4
294 .IX Item "--architecture=architecture"
295 .PD
296 In the current release of \fBld\fR, this option is useful only for the
297 Intel 960 family of architectures.  In that \fBld\fR configuration, the
298 \&\fIarchitecture\fR argument identifies the particular architecture in
299 the 960 family, enabling some safeguards and modifying the
300 archive-library search path.
301 .Sp
302 Future releases of \fBld\fR may support similar functionality for
303 other architecture families.
304 .IP "\fB\-b\fR \fIinput-format\fR" 4
305 .IX Item "-b input-format"
306 .PD 0
307 .IP "\fB\-\-format=\fR\fIinput-format\fR" 4
308 .IX Item "--format=input-format"
309 .PD
310 \&\fBld\fR may be configured to support more than one kind of object
311 file.  If your \fBld\fR is configured this way, you can use the
312 \&\fB\-b\fR option to specify the binary format for input object files
313 that follow this option on the command line.  Even when \fBld\fR is
314 configured to support alternative object formats, you don't usually need
315 to specify this, as \fBld\fR should be configured to expect as a
316 default input format the most usual format on each machine.
317 \&\fIinput-format\fR is a text string, the name of a particular format
318 supported by the \s-1BFD\s0 libraries.  (You can list the available binary
319 formats with \fBobjdump \-i\fR.)
320 .Sp
321 You may want to use this option if you are linking files with an unusual
322 binary format.  You can also use \fB\-b\fR to switch formats explicitly (when
323 linking object files of different formats), by including
324 \&\fB\-b\fR \fIinput-format\fR before each group of object files in a
325 particular format.
326 .Sp
327 The default format is taken from the environment variable
328 \&\f(CW\*(C`GNUTARGET\*(C'\fR.
329 .Sp
330 You can also define the input format from a script, using the command
331 \&\f(CW\*(C`TARGET\*(C'\fR;
332 .IP "\fB\-c\fR \fIMRI-commandfile\fR" 4
333 .IX Item "-c MRI-commandfile"
334 .PD 0
335 .IP "\fB\-\-mri\-script=\fR\fIMRI-commandfile\fR" 4
336 .IX Item "--mri-script=MRI-commandfile"
337 .PD
338 For compatibility with linkers produced by \s-1MRI\s0, \fBld\fR accepts script
339 files written in an alternate, restricted command language, described in
340 the \s-1MRI\s0 Compatible Script Files section of \s-1GNU\s0 ld documentation.
341 Introduce \s-1MRI\s0 script files with
342 the option \fB\-c\fR; use the \fB\-T\fR option to run linker
343 scripts written in the general-purpose \fBld\fR scripting language.
344 If \fIMRI-cmdfile\fR does not exist, \fBld\fR looks for it in the directories
345 specified by any \fB\-L\fR options.
346 .IP "\fB\-d\fR" 4
347 .IX Item "-d"
348 .PD 0
349 .IP "\fB\-dc\fR" 4
350 .IX Item "-dc"
351 .IP "\fB\-dp\fR" 4
352 .IX Item "-dp"
353 .PD
354 These three options are equivalent; multiple forms are supported for
355 compatibility with other linkers.  They assign space to common symbols
356 even if a relocatable output file is specified (with \fB\-r\fR).  The
357 script command \f(CW\*(C`FORCE_COMMON_ALLOCATION\*(C'\fR has the same effect.
358 .IP "\fB\-\-depaudit\fR \fI\s-1AUDITLIB\s0\fR" 4
359 .IX Item "--depaudit AUDITLIB"
360 .PD 0
361 .IP "\fB\-P\fR \fI\s-1AUDITLIB\s0\fR" 4
362 .IX Item "-P AUDITLIB"
363 .PD
364 Adds \fI\s-1AUDITLIB\s0\fR to the \f(CW\*(C`DT_DEPAUDIT\*(C'\fR entry of the dynamic section.
365 \&\fI\s-1AUDITLIB\s0\fR is not checked for existence, nor will it use the \s-1DT_SONAME\s0
366 specified in the library.  If specified multiple times \f(CW\*(C`DT_DEPAUDIT\*(C'\fR
367 will contain a colon separated list of audit interfaces to use.  This
368 option is only meaningful on \s-1ELF\s0 platforms supporting the rtld-audit interface.
369 The \-P option is provided for Solaris compatibility.
370 .IP "\fB\-e\fR \fIentry\fR" 4
371 .IX Item "-e entry"
372 .PD 0
373 .IP "\fB\-\-entry=\fR\fIentry\fR" 4
374 .IX Item "--entry=entry"
375 .PD
376 Use \fIentry\fR as the explicit symbol for beginning execution of your
377 program, rather than the default entry point.  If there is no symbol
378 named \fIentry\fR, the linker will try to parse \fIentry\fR as a number,
379 and use that as the entry address (the number will be interpreted in
380 base 10; you may use a leading \fB0x\fR for base 16, or a leading
381 \&\fB0\fR for base 8).
382 .IP "\fB\-\-exclude\-libs\fR \fIlib\fR\fB,\fR\fIlib\fR\fB,...\fR" 4
383 .IX Item "--exclude-libs lib,lib,..."
384 Specifies a list of archive libraries from which symbols should not be automatically
385 exported.  The library names may be delimited by commas or colons.  Specifying
386 \&\f(CW\*(C`\-\-exclude\-libs ALL\*(C'\fR excludes symbols in all archive libraries from
387 automatic export.  This option is available only for the i386 \s-1PE\s0 targeted
388 port of the linker and for \s-1ELF\s0 targeted ports.  For i386 \s-1PE\s0, symbols
389 explicitly listed in a .def file are still exported, regardless of this
390 option.  For \s-1ELF\s0 targeted ports, symbols affected by this option will
391 be treated as hidden.
392 .IP "\fB\-\-exclude\-modules\-for\-implib\fR \fImodule\fR\fB,\fR\fImodule\fR\fB,...\fR" 4
393 .IX Item "--exclude-modules-for-implib module,module,..."
394 Specifies a list of object files or archive members, from which symbols
395 should not be automatically exported, but which should be copied wholesale
396 into the import library being generated during the link.  The module names
397 may be delimited by commas or colons, and must match exactly the filenames
398 used by \fBld\fR to open the files; for archive members, this is simply
399 the member name, but for object files the name listed must include and
400 match precisely any path used to specify the input file on the linker's
401 command-line.  This option is available only for the i386 \s-1PE\s0 targeted port
402 of the linker.  Symbols explicitly listed in a .def file are still exported,
403 regardless of this option.
404 .IP "\fB\-E\fR" 4
405 .IX Item "-E"
406 .PD 0
407 .IP "\fB\-\-export\-dynamic\fR" 4
408 .IX Item "--export-dynamic"
409 .IP "\fB\-\-no\-export\-dynamic\fR" 4
410 .IX Item "--no-export-dynamic"
411 .PD
412 When creating a dynamically linked executable, using the \fB\-E\fR
413 option or the \fB\-\-export\-dynamic\fR option causes the linker to add
414 all symbols to the dynamic symbol table.  The dynamic symbol table is the
415 set of symbols which are visible from dynamic objects at run time.
416 .Sp
417 If you do not use either of these options (or use the
418 \&\fB\-\-no\-export\-dynamic\fR option to restore the default behavior), the
419 dynamic symbol table will normally contain only those symbols which are
420 referenced by some dynamic object mentioned in the link.
421 .Sp
422 If you use \f(CW\*(C`dlopen\*(C'\fR to load a dynamic object which needs to refer
423 back to the symbols defined by the program, rather than some other
424 dynamic object, then you will probably need to use this option when
425 linking the program itself.
426 .Sp
427 You can also use the dynamic list to control what symbols should
428 be added to the dynamic symbol table if the output format supports it.
429 See the description of \fB\-\-dynamic\-list\fR.
430 .Sp
431 Note that this option is specific to \s-1ELF\s0 targeted ports.  \s-1PE\s0 targets
432 support a similar function to export all symbols from a \s-1DLL\s0 or \s-1EXE\s0; see
433 the description of \fB\-\-export\-all\-symbols\fR below.
434 .IP "\fB\-EB\fR" 4
435 .IX Item "-EB"
436 Link big-endian objects.  This affects the default output format.
437 .IP "\fB\-EL\fR" 4
438 .IX Item "-EL"
439 Link little-endian objects.  This affects the default output format.
440 .IP "\fB\-f\fR \fIname\fR" 4
441 .IX Item "-f name"
442 .PD 0
443 .IP "\fB\-\-auxiliary=\fR\fIname\fR" 4
444 .IX Item "--auxiliary=name"
445 .PD
446 When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_AUXILIARY\s0 field
447 to the specified name.  This tells the dynamic linker that the symbol
448 table of the shared object should be used as an auxiliary filter on the
449 symbol table of the shared object \fIname\fR.
450 .Sp
451 If you later link a program against this filter object, then, when you
452 run the program, the dynamic linker will see the \s-1DT_AUXILIARY\s0 field.  If
453 the dynamic linker resolves any symbols from the filter object, it will
454 first check whether there is a definition in the shared object
455 \&\fIname\fR.  If there is one, it will be used instead of the definition
456 in the filter object.  The shared object \fIname\fR need not exist.
457 Thus the shared object \fIname\fR may be used to provide an alternative
458 implementation of certain functions, perhaps for debugging or for
459 machine specific performance.
460 .Sp
461 This option may be specified more than once.  The \s-1DT_AUXILIARY\s0 entries
462 will be created in the order in which they appear on the command line.
463 .IP "\fB\-F\fR \fIname\fR" 4
464 .IX Item "-F name"
465 .PD 0
466 .IP "\fB\-\-filter=\fR\fIname\fR" 4
467 .IX Item "--filter=name"
468 .PD
469 When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_FILTER\s0 field to
470 the specified name.  This tells the dynamic linker that the symbol table
471 of the shared object which is being created should be used as a filter
472 on the symbol table of the shared object \fIname\fR.
473 .Sp
474 If you later link a program against this filter object, then, when you
475 run the program, the dynamic linker will see the \s-1DT_FILTER\s0 field.  The
476 dynamic linker will resolve symbols according to the symbol table of the
477 filter object as usual, but it will actually link to the definitions
478 found in the shared object \fIname\fR.  Thus the filter object can be
479 used to select a subset of the symbols provided by the object
480 \&\fIname\fR.
481 .Sp
482 Some older linkers used the \fB\-F\fR option throughout a compilation
483 toolchain for specifying object-file format for both input and output
484 object files.
485 The \s-1GNU\s0 linker uses other mechanisms for this purpose: the
486 \&\fB\-b\fR, \fB\-\-format\fR, \fB\-\-oformat\fR options, the
487 \&\f(CW\*(C`TARGET\*(C'\fR command in linker scripts, and the \f(CW\*(C`GNUTARGET\*(C'\fR
488 environment variable.
489 The \s-1GNU\s0 linker will ignore the \fB\-F\fR option when not
490 creating an \s-1ELF\s0 shared object.
491 .IP "\fB\-fini=\fR\fIname\fR" 4
492 .IX Item "-fini=name"
493 When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the
494 executable or shared object is unloaded, by setting \s-1DT_FINI\s0 to the
495 address of the function.  By default, the linker uses \f(CW\*(C`_fini\*(C'\fR as
496 the function to call.
497 .IP "\fB\-g\fR" 4
498 .IX Item "-g"
499 Ignored.  Provided for compatibility with other tools.
500 .IP "\fB\-G\fR \fIvalue\fR" 4
501 .IX Item "-G value"
502 .PD 0
503 .IP "\fB\-\-gpsize=\fR\fIvalue\fR" 4
504 .IX Item "--gpsize=value"
505 .PD
506 Set the maximum size of objects to be optimized using the \s-1GP\s0 register to
507 \&\fIsize\fR.  This is only meaningful for object file formats such as
508 \&\s-1MIPS\s0 \s-1ELF\s0 that support putting large and small objects into different
509 sections.  This is ignored for other object file formats.
510 .IP "\fB\-h\fR \fIname\fR" 4
511 .IX Item "-h name"
512 .PD 0
513 .IP "\fB\-soname=\fR\fIname\fR" 4
514 .IX Item "-soname=name"
515 .PD
516 When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_SONAME\s0 field to
517 the specified name.  When an executable is linked with a shared object
518 which has a \s-1DT_SONAME\s0 field, then when the executable is run the dynamic
519 linker will attempt to load the shared object specified by the \s-1DT_SONAME\s0
520 field rather than the using the file name given to the linker.
521 .IP "\fB\-i\fR" 4
522 .IX Item "-i"
523 Perform an incremental link (same as option \fB\-r\fR).
524 .IP "\fB\-init=\fR\fIname\fR" 4
525 .IX Item "-init=name"
526 When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the
527 executable or shared object is loaded, by setting \s-1DT_INIT\s0 to the address
528 of the function.  By default, the linker uses \f(CW\*(C`_init\*(C'\fR as the
529 function to call.
530 .IP "\fB\-l\fR \fInamespec\fR" 4
531 .IX Item "-l namespec"
532 .PD 0
533 .IP "\fB\-\-library=\fR\fInamespec\fR" 4
534 .IX Item "--library=namespec"
535 .PD
536 Add the archive or object file specified by \fInamespec\fR to the
537 list of files to link.  This option may be used any number of times.
538 If \fInamespec\fR is of the form \fI:\fIfilename\fI\fR, \fBld\fR
539 will search the library path for a file called \fIfilename\fR, otherwise it
540 will search the library path for a file called \fIlib\fInamespec\fI.a\fR.
541 .Sp
542 On systems which support shared libraries, \fBld\fR may also search for
543 files other than \fIlib\fInamespec\fI.a\fR.  Specifically, on \s-1ELF\s0
544 and SunOS systems, \fBld\fR will search a directory for a library
545 called \fIlib\fInamespec\fI.so\fR before searching for one called
546 \&\fIlib\fInamespec\fI.a\fR.  (By convention, a \f(CW\*(C`.so\*(C'\fR extension
547 indicates a shared library.)  Note that this behavior does not apply
548 to \fI:\fIfilename\fI\fR, which always specifies a file called
549 \&\fIfilename\fR.
550 .Sp
551 The linker will search an archive only once, at the location where it is
552 specified on the command line.  If the archive defines a symbol which
553 was undefined in some object which appeared before the archive on the
554 command line, the linker will include the appropriate file(s) from the
555 archive.  However, an undefined symbol in an object appearing later on
556 the command line will not cause the linker to search the archive again.
557 .Sp
558 See the \fB\-(\fR option for a way to force the linker to search
559 archives multiple times.
560 .Sp
561 You may list the same archive multiple times on the command line.
562 .Sp
563 This type of archive searching is standard for Unix linkers.  However,
564 if you are using \fBld\fR on \s-1AIX\s0, note that it is different from the
565 behaviour of the \s-1AIX\s0 linker.
566 .IP "\fB\-L\fR \fIsearchdir\fR" 4
567 .IX Item "-L searchdir"
568 .PD 0
569 .IP "\fB\-\-library\-path=\fR\fIsearchdir\fR" 4
570 .IX Item "--library-path=searchdir"
571 .PD
572 Add path \fIsearchdir\fR to the list of paths that \fBld\fR will search
573 for archive libraries and \fBld\fR control scripts.  You may use this
574 option any number of times.  The directories are searched in the order
575 in which they are specified on the command line.  Directories specified
576 on the command line are searched before the default directories.  All
577 \&\fB\-L\fR options apply to all \fB\-l\fR options, regardless of the
578 order in which the options appear.  \fB\-L\fR options do not affect
579 how \fBld\fR searches for a linker script unless \fB\-T\fR
580 option is specified.
581 .Sp
582 If \fIsearchdir\fR begins with \f(CW\*(C`=\*(C'\fR, then the \f(CW\*(C`=\*(C'\fR will be replaced
583 by the \fIsysroot prefix\fR, a path specified when the linker is configured.
584 .Sp
585 The default set of paths searched (without being specified with
586 \&\fB\-L\fR) depends on which emulation mode \fBld\fR is using, and in
587 some cases also on how it was configured.
588 .Sp
589 The paths can also be specified in a link script with the
590 \&\f(CW\*(C`SEARCH_DIR\*(C'\fR command.  Directories specified this way are searched
591 at the point in which the linker script appears in the command line.
592 .IP "\fB\-m\fR \fIemulation\fR" 4
593 .IX Item "-m emulation"
594 Emulate the \fIemulation\fR linker.  You can list the available
595 emulations with the \fB\-\-verbose\fR or \fB\-V\fR options.
596 .Sp
597 If the \fB\-m\fR option is not used, the emulation is taken from the
598 \&\f(CW\*(C`LDEMULATION\*(C'\fR environment variable, if that is defined.
599 .Sp
600 Otherwise, the default emulation depends upon how the linker was
601 configured.
602 .IP "\fB\-M\fR" 4
603 .IX Item "-M"
604 .PD 0
605 .IP "\fB\-\-print\-map\fR" 4
606 .IX Item "--print-map"
607 .PD
608 Print a link map to the standard output.  A link map provides
609 information about the link, including the following:
610 .RS 4
611 .IP "\(bu" 4
612 Where object files are mapped into memory.
613 .IP "\(bu" 4
614 How common symbols are allocated.
615 .IP "\(bu" 4
616 All archive members included in the link, with a mention of the symbol
617 which caused the archive member to be brought in.
618 .IP "\(bu" 4
619 The values assigned to symbols.
620 .Sp
621 Note \- symbols whose values are computed by an expression which
622 involves a reference to a previous value of the same symbol may not
623 have correct result displayed in the link map.  This is because the
624 linker discards intermediate results and only retains the final value
625 of an expression.  Under such circumstances the linker will display
626 the final value enclosed by square brackets.  Thus for example a
627 linker script containing:
628 .Sp
629 .Vb 3
630 \&           foo = 1
631 \&           foo = foo * 4
632 \&           foo = foo + 8
633 .Ve
634 .Sp
635 will produce the following output in the link map if the \fB\-M\fR
636 option is used:
637 .Sp
638 .Vb 3
639 \&           0x00000001                foo = 0x1
640 \&           [0x0000000c]                foo = (foo * 0x4)
641 \&           [0x0000000c]                foo = (foo + 0x8)
642 .Ve
643 .Sp
644 See \fBExpressions\fR for more information about expressions in linker
645 scripts.
646 .RE
647 .RS 4
648 .RE
649 .IP "\fB\-n\fR" 4
650 .IX Item "-n"
651 .PD 0
652 .IP "\fB\-\-nmagic\fR" 4
653 .IX Item "--nmagic"
654 .PD
655 Turn off page alignment of sections, and disable linking against shared
656 libraries.  If the output format supports Unix style magic numbers,
657 mark the output as \f(CW\*(C`NMAGIC\*(C'\fR.
658 .IP "\fB\-N\fR" 4
659 .IX Item "-N"
660 .PD 0
661 .IP "\fB\-\-omagic\fR" 4
662 .IX Item "--omagic"
663 .PD
664 Set the text and data sections to be readable and writable.  Also, do
665 not page-align the data segment, and disable linking against shared
666 libraries.  If the output format supports Unix style magic numbers,
667 mark the output as \f(CW\*(C`OMAGIC\*(C'\fR. Note: Although a writable text section
668 is allowed for PE-COFF targets, it does not conform to the format
669 specification published by Microsoft.
670 .IP "\fB\-\-no\-omagic\fR" 4
671 .IX Item "--no-omagic"
672 This option negates most of the effects of the \fB\-N\fR option.  It
673 sets the text section to be read-only, and forces the data segment to
674 be page-aligned.  Note \- this option does not enable linking against
675 shared libraries.  Use \fB\-Bdynamic\fR for this.
676 .IP "\fB\-o\fR \fIoutput\fR" 4
677 .IX Item "-o output"
678 .PD 0
679 .IP "\fB\-\-output=\fR\fIoutput\fR" 4
680 .IX Item "--output=output"
681 .PD
682 Use \fIoutput\fR as the name for the program produced by \fBld\fR; if this
683 option is not specified, the name \fIa.out\fR is used by default.  The
684 script command \f(CW\*(C`OUTPUT\*(C'\fR can also specify the output file name.
685 .IP "\fB\-O\fR \fIlevel\fR" 4
686 .IX Item "-O level"
687 If \fIlevel\fR is a numeric values greater than zero \fBld\fR optimizes
688 the output.  This might take significantly longer and therefore probably
689 should only be enabled for the final binary.  At the moment this
690 option only affects \s-1ELF\s0 shared library generation.  Future releases of
691 the linker may make more use of this option.  Also currently there is
692 no difference in the linker's behaviour for different non-zero values
693 of this option.  Again this may change with future releases.
694 .IP "\fB\-q\fR" 4
695 .IX Item "-q"
696 .PD 0
697 .IP "\fB\-\-emit\-relocs\fR" 4
698 .IX Item "--emit-relocs"
699 .PD
700 Leave relocation sections and contents in fully linked executables.
701 Post link analysis and optimization tools may need this information in
702 order to perform correct modifications of executables.  This results
703 in larger executables.
704 .Sp
705 This option is currently only supported on \s-1ELF\s0 platforms.
706 .IP "\fB\-\-force\-dynamic\fR" 4
707 .IX Item "--force-dynamic"
708 Force the output file to have dynamic sections.  This option is specific
709 to VxWorks targets.
710 .IP "\fB\-r\fR" 4
711 .IX Item "-r"
712 .PD 0
713 .IP "\fB\-\-relocatable\fR" 4
714 .IX Item "--relocatable"
715 .PD
716 Generate relocatable output\-\-\-i.e., generate an output file that can in
717 turn serve as input to \fBld\fR.  This is often called \fIpartial
718 linking\fR.  As a side effect, in environments that support standard Unix
719 magic numbers, this option also sets the output file's magic number to
720 \&\f(CW\*(C`OMAGIC\*(C'\fR.
721 If this option is not specified, an absolute file is produced.  When
722 linking \*(C+ programs, this option \fIwill not\fR resolve references to
723 constructors; to do that, use \fB\-Ur\fR.
724 .Sp
725 When an input file does not have the same format as the output file,
726 partial linking is only supported if that input file does not contain any
727 relocations.  Different output formats can have further restrictions; for
728 example some \f(CW\*(C`a.out\*(C'\fR\-based formats do not support partial linking
729 with input files in other formats at all.
730 .Sp
731 This option does the same thing as \fB\-i\fR.
732 .IP "\fB\-R\fR \fIfilename\fR" 4
733 .IX Item "-R filename"
734 .PD 0
735 .IP "\fB\-\-just\-symbols=\fR\fIfilename\fR" 4
736 .IX Item "--just-symbols=filename"
737 .PD
738 Read symbol names and their addresses from \fIfilename\fR, but do not
739 relocate it or include it in the output.  This allows your output file
740 to refer symbolically to absolute locations of memory defined in other
741 programs.  You may use this option more than once.
742 .Sp
743 For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is
744 followed by a directory name, rather than a file name, it is treated as
745 the \fB\-rpath\fR option.
746 .IP "\fB\-s\fR" 4
747 .IX Item "-s"
748 .PD 0
749 .IP "\fB\-\-strip\-all\fR" 4
750 .IX Item "--strip-all"
751 .PD
752 Omit all symbol information from the output file.
753 .IP "\fB\-S\fR" 4
754 .IX Item "-S"
755 .PD 0
756 .IP "\fB\-\-strip\-debug\fR" 4
757 .IX Item "--strip-debug"
758 .PD
759 Omit debugger symbol information (but not all symbols) from the output file.
760 .IP "\fB\-t\fR" 4
761 .IX Item "-t"
762 .PD 0
763 .IP "\fB\-\-trace\fR" 4
764 .IX Item "--trace"
765 .PD
766 Print the names of the input files as \fBld\fR processes them.
767 .IP "\fB\-T\fR \fIscriptfile\fR" 4
768 .IX Item "-T scriptfile"
769 .PD 0
770 .IP "\fB\-\-script=\fR\fIscriptfile\fR" 4
771 .IX Item "--script=scriptfile"
772 .PD
773 Use \fIscriptfile\fR as the linker script.  This script replaces
774 \&\fBld\fR's default linker script (rather than adding to it), so
775 \&\fIcommandfile\fR must specify everything necessary to describe the
776 output file.    If \fIscriptfile\fR does not exist in
777 the current directory, \f(CW\*(C`ld\*(C'\fR looks for it in the directories
778 specified by any preceding \fB\-L\fR options.  Multiple \fB\-T\fR
779 options accumulate.
780 .IP "\fB\-dT\fR \fIscriptfile\fR" 4
781 .IX Item "-dT scriptfile"
782 .PD 0
783 .IP "\fB\-\-default\-script=\fR\fIscriptfile\fR" 4
784 .IX Item "--default-script=scriptfile"
785 .PD
786 Use \fIscriptfile\fR as the default linker script.
787 .Sp
788 This option is similar to the \fB\-\-script\fR option except that
789 processing of the script is delayed until after the rest of the
790 command line has been processed.  This allows options placed after the
791 \&\fB\-\-default\-script\fR option on the command line to affect the
792 behaviour of the linker script, which can be important when the linker
793 command line cannot be directly controlled by the user.  (eg because
794 the command line is being constructed by another tool, such as
795 \&\fBgcc\fR).
796 .IP "\fB\-u\fR \fIsymbol\fR" 4
797 .IX Item "-u symbol"
798 .PD 0
799 .IP "\fB\-\-undefined=\fR\fIsymbol\fR" 4
800 .IX Item "--undefined=symbol"
801 .PD
802 Force \fIsymbol\fR to be entered in the output file as an undefined
803 symbol.  Doing this may, for example, trigger linking of additional
804 modules from standard libraries.  \fB\-u\fR may be repeated with
805 different option arguments to enter additional undefined symbols.  This
806 option is equivalent to the \f(CW\*(C`EXTERN\*(C'\fR linker script command.
807 .IP "\fB\-Ur\fR" 4
808 .IX Item "-Ur"
809 For anything other than \*(C+ programs, this option is equivalent to
810 \&\fB\-r\fR: it generates relocatable output\-\-\-i.e., an output file that can in
811 turn serve as input to \fBld\fR.  When linking \*(C+ programs, \fB\-Ur\fR
812 \&\fIdoes\fR resolve references to constructors, unlike \fB\-r\fR.
813 It does not work to use \fB\-Ur\fR on files that were themselves linked
814 with \fB\-Ur\fR; once the constructor table has been built, it cannot
815 be added to.  Use \fB\-Ur\fR only for the last partial link, and
816 \&\fB\-r\fR for the others.
817 .IP "\fB\-\-unique[=\fR\fI\s-1SECTION\s0\fR\fB]\fR" 4
818 .IX Item "--unique[=SECTION]"
819 Creates a separate output section for every input section matching
820 \&\fI\s-1SECTION\s0\fR, or if the optional wildcard \fI\s-1SECTION\s0\fR argument is
821 missing, for every orphan input section.  An orphan section is one not
822 specifically mentioned in a linker script.  You may use this option
823 multiple times on the command line;  It prevents the normal merging of
824 input sections with the same name, overriding output section assignments
825 in a linker script.
826 .IP "\fB\-v\fR" 4
827 .IX Item "-v"
828 .PD 0
829 .IP "\fB\-\-version\fR" 4
830 .IX Item "--version"
831 .IP "\fB\-V\fR" 4
832 .IX Item "-V"
833 .PD
834 Display the version number for \fBld\fR.  The \fB\-V\fR option also
835 lists the supported emulations.
836 .IP "\fB\-x\fR" 4
837 .IX Item "-x"
838 .PD 0
839 .IP "\fB\-\-discard\-all\fR" 4
840 .IX Item "--discard-all"
841 .PD
842 Delete all local symbols.
843 .IP "\fB\-X\fR" 4
844 .IX Item "-X"
845 .PD 0
846 .IP "\fB\-\-discard\-locals\fR" 4
847 .IX Item "--discard-locals"
848 .PD
849 Delete all temporary local symbols.  (These symbols start with
850 system-specific local label prefixes, typically \fB.L\fR for \s-1ELF\s0 systems
851 or \fBL\fR for traditional a.out systems.)
852 .IP "\fB\-y\fR \fIsymbol\fR" 4
853 .IX Item "-y symbol"
854 .PD 0
855 .IP "\fB\-\-trace\-symbol=\fR\fIsymbol\fR" 4
856 .IX Item "--trace-symbol=symbol"
857 .PD
858 Print the name of each linked file in which \fIsymbol\fR appears.  This
859 option may be given any number of times.  On many systems it is necessary
860 to prepend an underscore.
861 .Sp
862 This option is useful when you have an undefined symbol in your link but
863 don't know where the reference is coming from.
864 .IP "\fB\-Y\fR \fIpath\fR" 4
865 .IX Item "-Y path"
866 Add \fIpath\fR to the default library search path.  This option exists
867 for Solaris compatibility.
868 .IP "\fB\-z\fR \fIkeyword\fR" 4
869 .IX Item "-z keyword"
870 The recognized keywords are:
871 .RS 4
872 .IP "\fBcombreloc\fR" 4
873 .IX Item "combreloc"
874 Combines multiple reloc sections and sorts them to make dynamic symbol
875 lookup caching possible.
876 .IP "\fBdefs\fR" 4
877 .IX Item "defs"
878 Disallows undefined symbols in object files.  Undefined symbols in
879 shared libraries are still allowed.
880 .IP "\fBexecstack\fR" 4
881 .IX Item "execstack"
882 Marks the object as requiring executable stack.
883 .IP "\fBglobal\fR" 4
884 .IX Item "global"
885 This option is only meaningful when building a shared object.  It makes
886 the symbols defined by this shared object available for symbol resolution
887 of subsequently loaded libraries.
888 .IP "\fBinitfirst\fR" 4
889 .IX Item "initfirst"
890 This option is only meaningful when building a shared object.
891 It marks the object so that its runtime initialization will occur
892 before the runtime initialization of any other objects brought into
893 the process at the same time.  Similarly the runtime finalization of
894 the object will occur after the runtime finalization of any other
895 objects.
896 .IP "\fBinterpose\fR" 4
897 .IX Item "interpose"
898 Marks the object that its symbol table interposes before all symbols
899 but the primary executable.
900 .IP "\fBlazy\fR" 4
901 .IX Item "lazy"
902 When generating an executable or shared library, mark it to tell the
903 dynamic linker to defer function call resolution to the point when
904 the function is called (lazy binding), rather than at load time.
905 Lazy binding is the default.
906 .IP "\fBloadfltr\fR" 4
907 .IX Item "loadfltr"
908 Marks  the object that its filters be processed immediately at
909 runtime.
910 .IP "\fBmuldefs\fR" 4
911 .IX Item "muldefs"
912 Allows multiple definitions.
913 .IP "\fBnocombreloc\fR" 4
914 .IX Item "nocombreloc"
915 Disables multiple reloc sections combining.
916 .IP "\fBnocopyreloc\fR" 4
917 .IX Item "nocopyreloc"
918 Disables production of copy relocs.
919 .IP "\fBnodefaultlib\fR" 4
920 .IX Item "nodefaultlib"
921 Marks the object that the search for dependencies of this object will
922 ignore any default library search paths.
923 .IP "\fBnodelete\fR" 4
924 .IX Item "nodelete"
925 Marks the object shouldn't be unloaded at runtime.
926 .IP "\fBnodlopen\fR" 4
927 .IX Item "nodlopen"
928 Marks the object not available to \f(CW\*(C`dlopen\*(C'\fR.
929 .IP "\fBnodump\fR" 4
930 .IX Item "nodump"
931 Marks the object can not be dumped by \f(CW\*(C`dldump\*(C'\fR.
932 .IP "\fBnoexecstack\fR" 4
933 .IX Item "noexecstack"
934 Marks the object as not requiring executable stack.
935 .IP "\fBnorelro\fR" 4
936 .IX Item "norelro"
937 Don't create an \s-1ELF\s0 \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object.
938 .IP "\fBnow\fR" 4
939 .IX Item "now"
940 When generating an executable or shared library, mark it to tell the
941 dynamic linker to resolve all symbols when the program is started, or
942 when the shared library is linked to using dlopen, instead of
943 deferring function call resolution to the point when the function is
944 first called.
945 .IP "\fBorigin\fR" 4
946 .IX Item "origin"
947 Marks the object may contain \f(CW$ORIGIN\fR.
948 .IP "\fBrelro\fR" 4
949 .IX Item "relro"
950 Create an \s-1ELF\s0 \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object.
951 .IP "\fBmax\-page\-size=\fR\fIvalue\fR" 4
952 .IX Item "max-page-size=value"
953 Set the emulation maximum page size to \fIvalue\fR.
954 .IP "\fBcommon\-page\-size=\fR\fIvalue\fR" 4
955 .IX Item "common-page-size=value"
956 Set the emulation common page size to \fIvalue\fR.
957 .IP "\fBstack\-size=\fR\fIvalue\fR" 4
958 .IX Item "stack-size=value"
959 Specify a stack size for in an \s-1ELF\s0 \f(CW\*(C`PT_GNU_STACK\*(C'\fR segment.
960 Specifying zero will override any default non-zero sized
961 \&\f(CW\*(C`PT_GNU_STACK\*(C'\fR segment creation.
962 .RE
963 .RS 4
964 .Sp
965 Other keywords are ignored for Solaris compatibility.
966 .RE
967 .IP "\fB\-(\fR \fIarchives\fR \fB\-)\fR" 4
968 .IX Item "-( archives -)"
969 .PD 0
970 .IP "\fB\-\-start\-group\fR \fIarchives\fR \fB\-\-end\-group\fR" 4
971 .IX Item "--start-group archives --end-group"
972 .PD
973 The \fIarchives\fR should be a list of archive files.  They may be
974 either explicit file names, or \fB\-l\fR options.
975 .Sp
976 The specified archives are searched repeatedly until no new undefined
977 references are created.  Normally, an archive is searched only once in
978 the order that it is specified on the command line.  If a symbol in that
979 archive is needed to resolve an undefined symbol referred to by an
980 object in an archive that appears later on the command line, the linker
981 would not be able to resolve that reference.  By grouping the archives,
982 they all be searched repeatedly until all possible references are
983 resolved.
984 .Sp
985 Using this option has a significant performance cost.  It is best to use
986 it only when there are unavoidable circular references between two or
987 more archives.
988 .IP "\fB\-\-accept\-unknown\-input\-arch\fR" 4
989 .IX Item "--accept-unknown-input-arch"
990 .PD 0
991 .IP "\fB\-\-no\-accept\-unknown\-input\-arch\fR" 4
992 .IX Item "--no-accept-unknown-input-arch"
993 .PD
994 Tells the linker to accept input files whose architecture cannot be
995 recognised.  The assumption is that the user knows what they are doing
996 and deliberately wants to link in these unknown input files.  This was
997 the default behaviour of the linker, before release 2.14.  The default
998 behaviour from release 2.14 onwards is to reject such input files, and
999 so the \fB\-\-accept\-unknown\-input\-arch\fR option has been added to
1000 restore the old behaviour.
1001 .IP "\fB\-\-as\-needed\fR" 4
1002 .IX Item "--as-needed"
1003 .PD 0
1004 .IP "\fB\-\-no\-as\-needed\fR" 4
1005 .IX Item "--no-as-needed"
1006 .PD
1007 This option affects \s-1ELF\s0 \s-1DT_NEEDED\s0 tags for dynamic libraries mentioned
1008 on the command line after the \fB\-\-as\-needed\fR option.  Normally
1009 the linker will add a \s-1DT_NEEDED\s0 tag for each dynamic library mentioned
1010 on the command line, regardless of whether the library is actually
1011 needed or not.  \fB\-\-as\-needed\fR causes a \s-1DT_NEEDED\s0 tag to only be
1012 emitted for a library that \fIat that point in the link\fR satisfies a
1013 non-weak undefined symbol reference from a regular object file or, if
1014 the library is not found in the \s-1DT_NEEDED\s0 lists of other libraries, a
1015 non-weak undefined symbol reference from another dynamic library.
1016 Object files or libraries appearing on the command line \fIafter\fR
1017 the library in question do not affect whether the library is seen as
1018 needed.  This is similar to the rules for extraction of object files
1019 from archives.  \fB\-\-no\-as\-needed\fR restores the default behaviour.
1020 .IP "\fB\-\-add\-needed\fR" 4
1021 .IX Item "--add-needed"
1022 .PD 0
1023 .IP "\fB\-\-no\-add\-needed\fR" 4
1024 .IX Item "--no-add-needed"
1025 .PD
1026 These two options have been deprecated because of the similarity of
1027 their names to the \fB\-\-as\-needed\fR and \fB\-\-no\-as\-needed\fR
1028 options.  They have been replaced by \fB\-\-copy\-dt\-needed\-entries\fR
1029 and \fB\-\-no\-copy\-dt\-needed\-entries\fR.
1030 .IP "\fB\-assert\fR \fIkeyword\fR" 4
1031 .IX Item "-assert keyword"
1032 This option is ignored for SunOS compatibility.
1033 .IP "\fB\-Bdynamic\fR" 4
1034 .IX Item "-Bdynamic"
1035 .PD 0
1036 .IP "\fB\-dy\fR" 4
1037 .IX Item "-dy"
1038 .IP "\fB\-call_shared\fR" 4
1039 .IX Item "-call_shared"
1040 .PD
1041 Link against dynamic libraries.  This is only meaningful on platforms
1042 for which shared libraries are supported.  This option is normally the
1043 default on such platforms.  The different variants of this option are
1044 for compatibility with various systems.  You may use this option
1045 multiple times on the command line: it affects library searching for
1046 \&\fB\-l\fR options which follow it.
1047 .IP "\fB\-Bgroup\fR" 4
1048 .IX Item "-Bgroup"
1049 Set the \f(CW\*(C`DF_1_GROUP\*(C'\fR flag in the \f(CW\*(C`DT_FLAGS_1\*(C'\fR entry in the dynamic
1050 section.  This causes the runtime linker to handle lookups in this
1051 object and its dependencies to be performed only inside the group.
1052 \&\fB\-\-unresolved\-symbols=report\-all\fR is implied.  This option is
1053 only meaningful on \s-1ELF\s0 platforms which support shared libraries.
1054 .IP "\fB\-Bstatic\fR" 4
1055 .IX Item "-Bstatic"
1056 .PD 0
1057 .IP "\fB\-dn\fR" 4
1058 .IX Item "-dn"
1059 .IP "\fB\-non_shared\fR" 4
1060 .IX Item "-non_shared"
1061 .IP "\fB\-static\fR" 4
1062 .IX Item "-static"
1063 .PD
1064 Do not link against shared libraries.  This is only meaningful on
1065 platforms for which shared libraries are supported.  The different
1066 variants of this option are for compatibility with various systems.  You
1067 may use this option multiple times on the command line: it affects
1068 library searching for \fB\-l\fR options which follow it.  This
1069 option also implies \fB\-\-unresolved\-symbols=report\-all\fR.  This
1070 option can be used with \fB\-shared\fR.  Doing so means that a
1071 shared library is being created but that all of the library's external
1072 references must be resolved by pulling in entries from static
1073 libraries.
1074 .IP "\fB\-Bsymbolic\fR" 4
1075 .IX Item "-Bsymbolic"
1076 When creating a shared library, bind references to global symbols to the
1077 definition within the shared library, if any.  Normally, it is possible
1078 for a program linked against a shared library to override the definition
1079 within the shared library.  This option is only meaningful on \s-1ELF\s0
1080 platforms which support shared libraries.
1081 .IP "\fB\-Bsymbolic\-functions\fR" 4
1082 .IX Item "-Bsymbolic-functions"
1083 When creating a shared library, bind references to global function
1084 symbols to the definition within the shared library, if any.
1085 This option is only meaningful on \s-1ELF\s0 platforms which support shared
1086 libraries.
1087 .IP "\fB\-\-dynamic\-list=\fR\fIdynamic-list-file\fR" 4
1088 .IX Item "--dynamic-list=dynamic-list-file"
1089 Specify the name of a dynamic list file to the linker.  This is
1090 typically used when creating shared libraries to specify a list of
1091 global symbols whose references shouldn't be bound to the definition
1092 within the shared library, or creating dynamically linked executables
1093 to specify a list of symbols which should be added to the symbol table
1094 in the executable.  This option is only meaningful on \s-1ELF\s0 platforms
1095 which support shared libraries.
1096 .Sp
1097 The format of the dynamic list is the same as the version node without
1098 scope and node name.  See \fB\s-1VERSION\s0\fR for more information.
1099 .IP "\fB\-\-dynamic\-list\-data\fR" 4
1100 .IX Item "--dynamic-list-data"
1101 Include all global data symbols to the dynamic list.
1102 .IP "\fB\-\-dynamic\-list\-cpp\-new\fR" 4
1103 .IX Item "--dynamic-list-cpp-new"
1104 Provide the builtin dynamic list for \*(C+ operator new and delete.  It
1105 is mainly useful for building shared libstdc++.
1106 .IP "\fB\-\-dynamic\-list\-cpp\-typeinfo\fR" 4
1107 .IX Item "--dynamic-list-cpp-typeinfo"
1108 Provide the builtin dynamic list for \*(C+ runtime type identification.
1109 .IP "\fB\-\-check\-sections\fR" 4
1110 .IX Item "--check-sections"
1111 .PD 0
1112 .IP "\fB\-\-no\-check\-sections\fR" 4
1113 .IX Item "--no-check-sections"
1114 .PD
1115 Asks the linker \fInot\fR to check section addresses after they have
1116 been assigned to see if there are any overlaps.  Normally the linker will
1117 perform this check, and if it finds any overlaps it will produce
1118 suitable error messages.  The linker does know about, and does make
1119 allowances for sections in overlays.  The default behaviour can be
1120 restored by using the command line switch \fB\-\-check\-sections\fR.
1121 Section overlap is not usually checked for relocatable links.  You can
1122 force checking in that case by using the \fB\-\-check\-sections\fR
1123 option.
1124 .IP "\fB\-\-copy\-dt\-needed\-entries\fR" 4
1125 .IX Item "--copy-dt-needed-entries"
1126 .PD 0
1127 .IP "\fB\-\-no\-copy\-dt\-needed\-entries\fR" 4
1128 .IX Item "--no-copy-dt-needed-entries"
1129 .PD
1130 This option affects the treatment of dynamic libraries referred to
1131 by \s-1DT_NEEDED\s0 tags \fIinside\fR \s-1ELF\s0 dynamic libraries mentioned on the
1132 command line.  Normally the linker won't add a \s-1DT_NEEDED\s0 tag to the
1133 output binary for each library mentioned in a \s-1DT_NEEDED\s0 tag in an
1134 input dynamic library.  With \fB\-\-copy\-dt\-needed\-entries\fR
1135 specified on the command line however any dynamic libraries that
1136 follow it will have their \s-1DT_NEEDED\s0 entries added.  The default
1137 behaviour can be restored with \fB\-\-no\-copy\-dt\-needed\-entries\fR.
1138 .Sp
1139 This option also has an effect on the resolution of symbols in dynamic
1140 libraries.  With \fB\-\-copy\-dt\-needed\-entries\fR dynamic libraries
1141 mentioned on the command line will be recursively searched, following
1142 their \s-1DT_NEEDED\s0 tags to other libraries, in order to resolve symbols
1143 required by the output binary.  With the default setting however
1144 the searching of dynamic libraries that follow it will stop with the
1145 dynamic library itself.  No \s-1DT_NEEDED\s0 links will be traversed to resolve
1146 symbols.
1147 .IP "\fB\-\-cref\fR" 4
1148 .IX Item "--cref"
1149 Output a cross reference table.  If a linker map file is being
1150 generated, the cross reference table is printed to the map file.
1151 Otherwise, it is printed on the standard output.
1152 .Sp
1153 The format of the table is intentionally simple, so that it may be
1154 easily processed by a script if necessary.  The symbols are printed out,
1155 sorted by name.  For each symbol, a list of file names is given.  If the
1156 symbol is defined, the first file listed is the location of the
1157 definition.  If the symbol is defined as a common value then any files
1158 where this happens appear next.  Finally any files that reference the
1159 symbol are listed.
1160 .IP "\fB\-\-no\-define\-common\fR" 4
1161 .IX Item "--no-define-common"
1162 This option inhibits the assignment of addresses to common symbols.
1163 The script command \f(CW\*(C`INHIBIT_COMMON_ALLOCATION\*(C'\fR has the same effect.
1164 .Sp
1165 The \fB\-\-no\-define\-common\fR option allows decoupling
1166 the decision to assign addresses to Common symbols from the choice
1167 of the output file type; otherwise a non-Relocatable output type
1168 forces assigning addresses to Common symbols.
1169 Using \fB\-\-no\-define\-common\fR allows Common symbols that are referenced
1170 from a shared library to be assigned addresses only in the main program.
1171 This eliminates the unused duplicate space in the shared library,
1172 and also prevents any possible confusion over resolving to the wrong
1173 duplicate when there are many dynamic modules with specialized search
1174 paths for runtime symbol resolution.
1175 .IP "\fB\-\-defsym=\fR\fIsymbol\fR\fB=\fR\fIexpression\fR" 4
1176 .IX Item "--defsym=symbol=expression"
1177 Create a global symbol in the output file, containing the absolute
1178 address given by \fIexpression\fR.  You may use this option as many
1179 times as necessary to define multiple symbols in the command line.  A
1180 limited form of arithmetic is supported for the \fIexpression\fR in this
1181 context: you may give a hexadecimal constant or the name of an existing
1182 symbol, or use \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`\-\*(C'\fR to add or subtract hexadecimal
1183 constants or symbols.  If you need more elaborate expressions, consider
1184 using the linker command language from a script.  \fINote:\fR there should be no white
1185 space between \fIsymbol\fR, the equals sign ("\fB=\fR"), and
1186 \&\fIexpression\fR.
1187 .IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4
1188 .IX Item "--demangle[=style]"
1189 .PD 0
1190 .IP "\fB\-\-no\-demangle\fR" 4
1191 .IX Item "--no-demangle"
1192 .PD
1193 These options control whether to demangle symbol names in error messages
1194 and other output.  When the linker is told to demangle, it tries to
1195 present symbol names in a readable fashion: it strips leading
1196 underscores if they are used by the object file format, and converts \*(C+
1197 mangled symbol names into user readable names.  Different compilers have
1198 different mangling styles.  The optional demangling style argument can be used
1199 to choose an appropriate demangling style for your compiler.  The linker will
1200 demangle by default unless the environment variable \fB\s-1COLLECT_NO_DEMANGLE\s0\fR
1201 is set.  These options may be used to override the default.
1202 .IP "\fB\-I\fR\fIfile\fR" 4
1203 .IX Item "-Ifile"
1204 .PD 0
1205 .IP "\fB\-\-dynamic\-linker=\fR\fIfile\fR" 4
1206 .IX Item "--dynamic-linker=file"
1207 .PD
1208 Set the name of the dynamic linker.  This is only meaningful when
1209 generating dynamically linked \s-1ELF\s0 executables.  The default dynamic
1210 linker is normally correct; don't use this unless you know what you are
1211 doing.
1212 .IP "\fB\-\-fatal\-warnings\fR" 4
1213 .IX Item "--fatal-warnings"
1214 .PD 0
1215 .IP "\fB\-\-no\-fatal\-warnings\fR" 4
1216 .IX Item "--no-fatal-warnings"
1217 .PD
1218 Treat all warnings as errors.  The default behaviour can be restored
1219 with the option \fB\-\-no\-fatal\-warnings\fR.
1220 .IP "\fB\-\-force\-exe\-suffix\fR" 4
1221 .IX Item "--force-exe-suffix"
1222 Make sure that an output file has a .exe suffix.
1223 .Sp
1224 If a successfully built fully linked output file does not have a
1225 \&\f(CW\*(C`.exe\*(C'\fR or \f(CW\*(C`.dll\*(C'\fR suffix, this option forces the linker to copy
1226 the output file to one of the same name with a \f(CW\*(C`.exe\*(C'\fR suffix. This
1227 option is useful when using unmodified Unix makefiles on a Microsoft
1228 Windows host, since some versions of Windows won't run an image unless
1229 it ends in a \f(CW\*(C`.exe\*(C'\fR suffix.
1230 .IP "\fB\-\-gc\-sections\fR" 4
1231 .IX Item "--gc-sections"
1232 .PD 0
1233 .IP "\fB\-\-no\-gc\-sections\fR" 4
1234 .IX Item "--no-gc-sections"
1235 .PD
1236 Enable garbage collection of unused input sections.  It is ignored on
1237 targets that do not support this option.  The default behaviour (of not
1238 performing this garbage collection) can be restored by specifying
1239 \&\fB\-\-no\-gc\-sections\fR on the command line.
1240 .Sp
1241 \&\fB\-\-gc\-sections\fR decides which input sections are used by
1242 examining symbols and relocations.  The section containing the entry
1243 symbol and all sections containing symbols undefined on the
1244 command-line will be kept, as will sections containing symbols
1245 referenced by dynamic objects.  Note that when building shared
1246 libraries, the linker must assume that any visible symbol is
1247 referenced.  Once this initial set of sections has been determined,
1248 the linker recursively marks as used any section referenced by their
1249 relocations.  See \fB\-\-entry\fR and \fB\-\-undefined\fR.
1250 .Sp
1251 This option can be set when doing a partial link (enabled with option
1252 \&\fB\-r\fR).  In this case the root of symbols kept must be explicitly
1253 specified either by an \fB\-\-entry\fR or \fB\-\-undefined\fR option or by
1254 a \f(CW\*(C`ENTRY\*(C'\fR command in the linker script.
1255 .IP "\fB\-\-print\-gc\-sections\fR" 4
1256 .IX Item "--print-gc-sections"
1257 .PD 0
1258 .IP "\fB\-\-no\-print\-gc\-sections\fR" 4
1259 .IX Item "--no-print-gc-sections"
1260 .PD
1261 List all sections removed by garbage collection.  The listing is
1262 printed on stderr.  This option is only effective if garbage
1263 collection has been enabled via the \fB\-\-gc\-sections\fR) option.  The
1264 default behaviour (of not listing the sections that are removed) can
1265 be restored by specifying \fB\-\-no\-print\-gc\-sections\fR on the command
1266 line.
1267 .IP "\fB\-\-print\-output\-format\fR" 4
1268 .IX Item "--print-output-format"
1269 Print the name of the default output format (perhaps influenced by
1270 other command-line options).  This is the string that would appear
1271 in an \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR linker script command.
1272 .IP "\fB\-\-help\fR" 4
1273 .IX Item "--help"
1274 Print a summary of the command-line options on the standard output and exit.
1275 .IP "\fB\-\-target\-help\fR" 4
1276 .IX Item "--target-help"
1277 Print a summary of all target specific options on the standard output and exit.
1278 .IP "\fB\-Map=\fR\fImapfile\fR" 4
1279 .IX Item "-Map=mapfile"
1280 Print a link map to the file \fImapfile\fR.  See the description of the
1281 \&\fB\-M\fR option, above.
1282 .IP "\fB\-\-no\-keep\-memory\fR" 4
1283 .IX Item "--no-keep-memory"
1284 \&\fBld\fR normally optimizes for speed over memory usage by caching the
1285 symbol tables of input files in memory.  This option tells \fBld\fR to
1286 instead optimize for memory usage, by rereading the symbol tables as
1287 necessary.  This may be required if \fBld\fR runs out of memory space
1288 while linking a large executable.
1289 .IP "\fB\-\-no\-undefined\fR" 4
1290 .IX Item "--no-undefined"
1291 .PD 0
1292 .IP "\fB\-z defs\fR" 4
1293 .IX Item "-z defs"
1294 .PD
1295 Report unresolved symbol references from regular object files.  This
1296 is done even if the linker is creating a non-symbolic shared library.
1297 The switch \fB\-\-[no\-]allow\-shlib\-undefined\fR controls the
1298 behaviour for reporting unresolved references found in shared
1299 libraries being linked in.
1300 .IP "\fB\-\-allow\-multiple\-definition\fR" 4
1301 .IX Item "--allow-multiple-definition"
1302 .PD 0
1303 .IP "\fB\-z muldefs\fR" 4
1304 .IX Item "-z muldefs"
1305 .PD
1306 Normally when a symbol is defined multiple times, the linker will
1307 report a fatal error. These options allow multiple definitions and the
1308 first definition will be used.
1309 .IP "\fB\-\-allow\-shlib\-undefined\fR" 4
1310 .IX Item "--allow-shlib-undefined"
1311 .PD 0
1312 .IP "\fB\-\-no\-allow\-shlib\-undefined\fR" 4
1313 .IX Item "--no-allow-shlib-undefined"
1314 .PD
1315 Allows or disallows undefined symbols in shared libraries.
1316 This switch is similar to \fB\-\-no\-undefined\fR except that it
1317 determines the behaviour when the undefined symbols are in a
1318 shared library rather than a regular object file.  It does not affect
1319 how undefined symbols in regular object files are handled.
1320 .Sp
1321 The default behaviour is to report errors for any undefined symbols
1322 referenced in shared libraries if the linker is being used to create
1323 an executable, but to allow them if the linker is being used to create
1324 a shared library.
1325 .Sp
1326 The reasons for allowing undefined symbol references in shared
1327 libraries specified at link time are that:
1328 .RS 4
1329 .IP "\(bu" 4
1330 A shared library specified at link time may not be the same as the one
1331 that is available at load time, so the symbol might actually be
1332 resolvable at load time.
1333 .IP "\(bu" 4
1334 There are some operating systems, eg BeOS and \s-1HPPA\s0, where undefined
1335 symbols in shared libraries are normal.
1336 .Sp
1337 The BeOS kernel for example patches shared libraries at load time to
1338 select whichever function is most appropriate for the current
1339 architecture.  This is used, for example, to dynamically select an
1340 appropriate memset function.
1341 .RE
1342 .RS 4
1343 .RE
1344 .IP "\fB\-\-no\-undefined\-version\fR" 4
1345 .IX Item "--no-undefined-version"
1346 Normally when a symbol has an undefined version, the linker will ignore
1347 it. This option disallows symbols with undefined version and a fatal error
1348 will be issued instead.
1349 .IP "\fB\-\-default\-symver\fR" 4
1350 .IX Item "--default-symver"
1351 Create and use a default symbol version (the soname) for unversioned
1352 exported symbols.
1353 .IP "\fB\-\-default\-imported\-symver\fR" 4
1354 .IX Item "--default-imported-symver"
1355 Create and use a default symbol version (the soname) for unversioned
1356 imported symbols.
1357 .IP "\fB\-\-no\-warn\-mismatch\fR" 4
1358 .IX Item "--no-warn-mismatch"
1359 Normally \fBld\fR will give an error if you try to link together input
1360 files that are mismatched for some reason, perhaps because they have
1361 been compiled for different processors or for different endiannesses.
1362 This option tells \fBld\fR that it should silently permit such possible
1363 errors.  This option should only be used with care, in cases when you
1364 have taken some special action that ensures that the linker errors are
1365 inappropriate.
1366 .IP "\fB\-\-no\-warn\-search\-mismatch\fR" 4
1367 .IX Item "--no-warn-search-mismatch"
1368 Normally \fBld\fR will give a warning if it finds an incompatible
1369 library during a library search.  This option silences the warning.
1370 .IP "\fB\-\-no\-whole\-archive\fR" 4
1371 .IX Item "--no-whole-archive"
1372 Turn off the effect of the \fB\-\-whole\-archive\fR option for subsequent
1373 archive files.
1374 .IP "\fB\-\-noinhibit\-exec\fR" 4
1375 .IX Item "--noinhibit-exec"
1376 Retain the executable output file whenever it is still usable.
1377 Normally, the linker will not produce an output file if it encounters
1378 errors during the link process; it exits without writing an output file
1379 when it issues any error whatsoever.
1380 .IP "\fB\-nostdlib\fR" 4
1381 .IX Item "-nostdlib"
1382 Only search library directories explicitly specified on the
1383 command line.  Library directories specified in linker scripts
1384 (including linker scripts specified on the command line) are ignored.
1385 .IP "\fB\-\-oformat=\fR\fIoutput-format\fR" 4
1386 .IX Item "--oformat=output-format"
1387 \&\fBld\fR may be configured to support more than one kind of object
1388 file.  If your \fBld\fR is configured this way, you can use the
1389 \&\fB\-\-oformat\fR option to specify the binary format for the output
1390 object file.  Even when \fBld\fR is configured to support alternative
1391 object formats, you don't usually need to specify this, as \fBld\fR
1392 should be configured to produce as a default output format the most
1393 usual format on each machine.  \fIoutput-format\fR is a text string, the
1394 name of a particular format supported by the \s-1BFD\s0 libraries.  (You can
1395 list the available binary formats with \fBobjdump \-i\fR.)  The script
1396 command \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR can also specify the output format, but
1397 this option overrides it.
1398 .IP "\fB\-pie\fR" 4
1399 .IX Item "-pie"
1400 .PD 0
1401 .IP "\fB\-\-pic\-executable\fR" 4
1402 .IX Item "--pic-executable"
1403 .PD
1404 Create a position independent executable.  This is currently only supported on
1405 \&\s-1ELF\s0 platforms.  Position independent executables are similar to shared
1406 libraries in that they are relocated by the dynamic linker to the virtual
1407 address the \s-1OS\s0 chooses for them (which can vary between invocations).  Like
1408 normal dynamically linked executables they can be executed and symbols
1409 defined in the executable cannot be overridden by shared libraries.
1410 .IP "\fB\-qmagic\fR" 4
1411 .IX Item "-qmagic"
1412 This option is ignored for Linux compatibility.
1413 .IP "\fB\-Qy\fR" 4
1414 .IX Item "-Qy"
1415 This option is ignored for \s-1SVR4\s0 compatibility.
1416 .IP "\fB\-\-relax\fR" 4
1417 .IX Item "--relax"
1418 .PD 0
1419 .IP "\fB\-\-no\-relax\fR" 4
1420 .IX Item "--no-relax"
1421 .PD
1422 An option with machine dependent effects.
1423 This option is only supported on a few targets.
1424 .Sp
1425 On some platforms the \fB\-\-relax\fR option performs target specific,
1426 global optimizations that become possible when the linker resolves
1427 addressing in the program, such as relaxing address modes,
1428 synthesizing new instructions, selecting shorter version of current
1429 instructions, and combining constant values.
1430 .Sp
1431 On some platforms these link time global optimizations may make symbolic
1432 debugging of the resulting executable impossible.
1433 This is known to be the case for the Matsushita \s-1MN10200\s0 and \s-1MN10300\s0
1434 family of processors.
1435 .Sp
1436 On platforms where this is not supported, \fB\-\-relax\fR is accepted,
1437 but ignored.
1438 .Sp
1439 On platforms where \fB\-\-relax\fR is accepted the option
1440 \&\fB\-\-no\-relax\fR can be used to disable the feature.
1441 .IP "\fB\-\-retain\-symbols\-file=\fR\fIfilename\fR" 4
1442 .IX Item "--retain-symbols-file=filename"
1443 Retain \fIonly\fR the symbols listed in the file \fIfilename\fR,
1444 discarding all others.  \fIfilename\fR is simply a flat file, with one
1445 symbol name per line.  This option is especially useful in environments
1446 (such as VxWorks)
1447 where a large global symbol table is accumulated gradually, to conserve
1448 run-time memory.
1449 .Sp
1450 \&\fB\-\-retain\-symbols\-file\fR does \fInot\fR discard undefined symbols,
1451 or symbols needed for relocations.
1452 .Sp
1453 You may only specify \fB\-\-retain\-symbols\-file\fR once in the command
1454 line.  It overrides \fB\-s\fR and \fB\-S\fR.
1455 .IP "\fB\-rpath=\fR\fIdir\fR" 4
1456 .IX Item "-rpath=dir"
1457 Add a directory to the runtime library search path.  This is used when
1458 linking an \s-1ELF\s0 executable with shared objects.  All \fB\-rpath\fR
1459 arguments are concatenated and passed to the runtime linker, which uses
1460 them to locate shared objects at runtime.  The \fB\-rpath\fR option is
1461 also used when locating shared objects which are needed by shared
1462 objects explicitly included in the link; see the description of the
1463 \&\fB\-rpath\-link\fR option.  If \fB\-rpath\fR is not used when linking an
1464 \&\s-1ELF\s0 executable, the contents of the environment variable
1465 \&\f(CW\*(C`LD_RUN_PATH\*(C'\fR will be used if it is defined.
1466 .Sp
1467 The \fB\-rpath\fR option may also be used on SunOS.  By default, on
1468 SunOS, the linker will form a runtime search patch out of all the
1469 \&\fB\-L\fR options it is given.  If a \fB\-rpath\fR option is used, the
1470 runtime search path will be formed exclusively using the \fB\-rpath\fR
1471 options, ignoring the \fB\-L\fR options.  This can be useful when using
1472 gcc, which adds many \fB\-L\fR options which may be on \s-1NFS\s0 mounted
1473 file systems.
1474 .Sp
1475 For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is
1476 followed by a directory name, rather than a file name, it is treated as
1477 the \fB\-rpath\fR option.
1478 .IP "\fB\-rpath\-link=\fR\fIdir\fR" 4
1479 .IX Item "-rpath-link=dir"
1480 When using \s-1ELF\s0 or SunOS, one shared library may require another.  This
1481 happens when an \f(CW\*(C`ld \-shared\*(C'\fR link includes a shared library as one
1482 of the input files.
1483 .Sp
1484 When the linker encounters such a dependency when doing a non-shared,
1485 non-relocatable link, it will automatically try to locate the required
1486 shared library and include it in the link, if it is not included
1487 explicitly.  In such a case, the \fB\-rpath\-link\fR option
1488 specifies the first set of directories to search.  The
1489 \&\fB\-rpath\-link\fR option may specify a sequence of directory names
1490 either by specifying a list of names separated by colons, or by
1491 appearing multiple times.
1492 .Sp
1493 This option should be used with caution as it overrides the search path
1494 that may have been hard compiled into a shared library. In such a case it
1495 is possible to use unintentionally a different search path than the
1496 runtime linker would do.
1497 .Sp
1498 The linker uses the following search paths to locate required shared
1499 libraries:
1500 .RS 4
1501 .IP "1." 4
1502 Any directories specified by \fB\-rpath\-link\fR options.
1503 .IP "2." 4
1504 Any directories specified by \fB\-rpath\fR options.  The difference
1505 between \fB\-rpath\fR and \fB\-rpath\-link\fR is that directories
1506 specified by \fB\-rpath\fR options are included in the executable and
1507 used at runtime, whereas the \fB\-rpath\-link\fR option is only effective
1508 at link time. Searching \fB\-rpath\fR in this way is only supported
1509 by native linkers and cross linkers which have been configured with
1510 the \fB\-\-with\-sysroot\fR option.
1511 .IP "3." 4
1512 On an \s-1ELF\s0 system, for native linkers, if the \fB\-rpath\fR and
1513 \&\fB\-rpath\-link\fR options were not used, search the contents of the
1514 environment variable \f(CW\*(C`LD_RUN_PATH\*(C'\fR.
1515 .IP "4." 4
1516 On SunOS, if the \fB\-rpath\fR option was not used, search any
1517 directories specified using \fB\-L\fR options.
1518 .IP "5." 4
1519 For a native linker, search the contents of the environment
1520 variable \f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR.
1521 .IP "6." 4
1522 For a native \s-1ELF\s0 linker, the directories in \f(CW\*(C`DT_RUNPATH\*(C'\fR or
1523 \&\f(CW\*(C`DT_RPATH\*(C'\fR of a shared library are searched for shared
1524 libraries needed by it. The \f(CW\*(C`DT_RPATH\*(C'\fR entries are ignored if
1525 \&\f(CW\*(C`DT_RUNPATH\*(C'\fR entries exist.
1526 .IP "7." 4
1527 The default directories, normally \fI/lib\fR and \fI/usr/lib\fR.
1528 .IP "8." 4
1529 For a native linker on an \s-1ELF\s0 system, if the file \fI/etc/ld.so.conf\fR
1530 exists, the list of directories found in that file.
1531 .RE
1532 .RS 4
1533 .Sp
1534 If the required shared library is not found, the linker will issue a
1535 warning and continue with the link.
1536 .RE
1537 .IP "\fB\-shared\fR" 4
1538 .IX Item "-shared"
1539 .PD 0
1540 .IP "\fB\-Bshareable\fR" 4
1541 .IX Item "-Bshareable"
1542 .PD
1543 Create a shared library.  This is currently only supported on \s-1ELF\s0, \s-1XCOFF\s0
1544 and SunOS platforms.  On SunOS, the linker will automatically create a
1545 shared library if the \fB\-e\fR option is not used and there are
1546 undefined symbols in the link.
1547 .IP "\fB\-\-sort\-common\fR" 4
1548 .IX Item "--sort-common"
1549 .PD 0
1550 .IP "\fB\-\-sort\-common=ascending\fR" 4
1551 .IX Item "--sort-common=ascending"
1552 .IP "\fB\-\-sort\-common=descending\fR" 4
1553 .IX Item "--sort-common=descending"
1554 .PD
1555 This option tells \fBld\fR to sort the common symbols by alignment in
1556 ascending or descending order when it places them in the appropriate output
1557 sections.  The symbol alignments considered are sixteen-byte or larger,
1558 eight-byte, four-byte, two-byte, and one-byte. This is to prevent gaps
1559 between symbols due to alignment constraints.  If no sorting order is
1560 specified, then descending order is assumed.
1561 .IP "\fB\-\-sort\-section=name\fR" 4
1562 .IX Item "--sort-section=name"
1563 This option will apply \f(CW\*(C`SORT_BY_NAME\*(C'\fR to all wildcard section
1564 patterns in the linker script.
1565 .IP "\fB\-\-sort\-section=alignment\fR" 4
1566 .IX Item "--sort-section=alignment"
1567 This option will apply \f(CW\*(C`SORT_BY_ALIGNMENT\*(C'\fR to all wildcard section
1568 patterns in the linker script.
1569 .IP "\fB\-\-split\-by\-file[=\fR\fIsize\fR\fB]\fR" 4
1570 .IX Item "--split-by-file[=size]"
1571 Similar to \fB\-\-split\-by\-reloc\fR but creates a new output section for
1572 each input file when \fIsize\fR is reached.  \fIsize\fR defaults to a
1573 size of 1 if not given.
1574 .IP "\fB\-\-split\-by\-reloc[=\fR\fIcount\fR\fB]\fR" 4
1575 .IX Item "--split-by-reloc[=count]"
1576 Tries to creates extra sections in the output file so that no single
1577 output section in the file contains more than \fIcount\fR relocations.
1578 This is useful when generating huge relocatable files for downloading into
1579 certain real time kernels with the \s-1COFF\s0 object file format; since \s-1COFF\s0
1580 cannot represent more than 65535 relocations in a single section.  Note
1581 that this will fail to work with object file formats which do not
1582 support arbitrary sections.  The linker will not split up individual
1583 input sections for redistribution, so if a single input section contains
1584 more than \fIcount\fR relocations one output section will contain that
1585 many relocations.  \fIcount\fR defaults to a value of 32768.
1586 .IP "\fB\-\-stats\fR" 4
1587 .IX Item "--stats"
1588 Compute and display statistics about the operation of the linker, such
1589 as execution time and memory usage.
1590 .IP "\fB\-\-sysroot=\fR\fIdirectory\fR" 4
1591 .IX Item "--sysroot=directory"
1592 Use \fIdirectory\fR as the location of the sysroot, overriding the
1593 configure-time default.  This option is only supported by linkers
1594 that were configured using \fB\-\-with\-sysroot\fR.
1595 .IP "\fB\-\-traditional\-format\fR" 4
1596 .IX Item "--traditional-format"
1597 For some targets, the output of \fBld\fR is different in some ways from
1598 the output of some existing linker.  This switch requests \fBld\fR to
1599 use the traditional format instead.
1600 .Sp
1601 For example, on SunOS, \fBld\fR combines duplicate entries in the
1602 symbol string table.  This can reduce the size of an output file with
1603 full debugging information by over 30 percent.  Unfortunately, the SunOS
1604 \&\f(CW\*(C`dbx\*(C'\fR program can not read the resulting program (\f(CW\*(C`gdb\*(C'\fR has no
1605 trouble).  The \fB\-\-traditional\-format\fR switch tells \fBld\fR to not
1606 combine duplicate entries.
1607 .IP "\fB\-\-section\-start=\fR\fIsectionname\fR\fB=\fR\fIorg\fR" 4
1608 .IX Item "--section-start=sectionname=org"
1609 Locate a section in the output file at the absolute
1610 address given by \fIorg\fR.  You may use this option as many
1611 times as necessary to locate multiple sections in the command
1612 line.
1613 \&\fIorg\fR must be a single hexadecimal integer;
1614 for compatibility with other linkers, you may omit the leading
1615 \&\fB0x\fR usually associated with hexadecimal values.  \fINote:\fR there
1616 should be no white space between \fIsectionname\fR, the equals
1617 sign ("\fB=\fR"), and \fIorg\fR.
1618 .IP "\fB\-Tbss=\fR\fIorg\fR" 4
1619 .IX Item "-Tbss=org"
1620 .PD 0
1621 .IP "\fB\-Tdata=\fR\fIorg\fR" 4
1622 .IX Item "-Tdata=org"
1623 .IP "\fB\-Ttext=\fR\fIorg\fR" 4
1624 .IX Item "-Ttext=org"
1625 .PD
1626 Same as \fB\-\-section\-start\fR, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or
1627 \&\f(CW\*(C`.text\*(C'\fR as the \fIsectionname\fR.
1628 .IP "\fB\-Ttext\-segment=\fR\fIorg\fR" 4
1629 .IX Item "-Ttext-segment=org"
1630 When creating an \s-1ELF\s0 executable or shared object, it will set the address
1631 of the first byte of the text segment.
1632 .IP "\fB\-Trodata\-segment=\fR\fIorg\fR" 4
1633 .IX Item "-Trodata-segment=org"
1634 When creating an \s-1ELF\s0 executable or shared object for a target where
1635 the read-only data is in its own segment separate from the executable
1636 text, it will set the address of the first byte of the read-only data segment.
1637 .IP "\fB\-Tldata\-segment=\fR\fIorg\fR" 4
1638 .IX Item "-Tldata-segment=org"
1639 When creating an \s-1ELF\s0 executable or shared object for x86\-64 medium memory
1640 model, it will set the address of the first byte of the ldata segment.
1641 .IP "\fB\-\-unresolved\-symbols=\fR\fImethod\fR" 4
1642 .IX Item "--unresolved-symbols=method"
1643 Determine how to handle unresolved symbols.  There are four possible
1644 values for \fBmethod\fR:
1645 .RS 4
1646 .IP "\fBignore-all\fR" 4
1647 .IX Item "ignore-all"
1648 Do not report any unresolved symbols.
1649 .IP "\fBreport-all\fR" 4
1650 .IX Item "report-all"
1651 Report all unresolved symbols.  This is the default.
1652 .IP "\fBignore-in-object-files\fR" 4
1653 .IX Item "ignore-in-object-files"
1654 Report unresolved symbols that are contained in shared libraries, but
1655 ignore them if they come from regular object files.
1656 .IP "\fBignore-in-shared-libs\fR" 4
1657 .IX Item "ignore-in-shared-libs"
1658 Report unresolved symbols that come from regular object files, but
1659 ignore them if they come from shared libraries.  This can be useful
1660 when creating a dynamic binary and it is known that all the shared
1661 libraries that it should be referencing are included on the linker's
1662 command line.
1663 .RE
1664 .RS 4
1665 .Sp
1666 The behaviour for shared libraries on their own can also be controlled
1667 by the \fB\-\-[no\-]allow\-shlib\-undefined\fR option.
1668 .Sp
1669 Normally the linker will generate an error message for each reported
1670 unresolved symbol but the option \fB\-\-warn\-unresolved\-symbols\fR
1671 can change this to a warning.
1672 .RE
1673 .IP "\fB\-\-dll\-verbose\fR" 4
1674 .IX Item "--dll-verbose"
1675 .PD 0
1676 .IP "\fB\-\-verbose[=\fR\fI\s-1NUMBER\s0\fR\fB]\fR" 4
1677 .IX Item "--verbose[=NUMBER]"
1678 .PD
1679 Display the version number for \fBld\fR and list the linker emulations
1680 supported.  Display which input files can and cannot be opened.  Display
1681 the linker script being used by the linker. If the optional \fI\s-1NUMBER\s0\fR
1682 argument > 1, plugin symbol status will also be displayed.
1683 .IP "\fB\-\-version\-script=\fR\fIversion-scriptfile\fR" 4
1684 .IX Item "--version-script=version-scriptfile"
1685 Specify the name of a version script to the linker.  This is typically
1686 used when creating shared libraries to specify additional information
1687 about the version hierarchy for the library being created.  This option
1688 is only fully supported on \s-1ELF\s0 platforms which support shared libraries;
1689 see \fB\s-1VERSION\s0\fR.  It is partially supported on \s-1PE\s0 platforms, which can
1690 use version scripts to filter symbol visibility in auto-export mode: any
1691 symbols marked \fBlocal\fR in the version script will not be exported.
1692 .IP "\fB\-\-warn\-common\fR" 4
1693 .IX Item "--warn-common"
1694 Warn when a common symbol is combined with another common symbol or with
1695 a symbol definition.  Unix linkers allow this somewhat sloppy practice,
1696 but linkers on some other operating systems do not.  This option allows
1697 you to find potential problems from combining global symbols.
1698 Unfortunately, some C libraries use this practice, so you may get some
1699 warnings about symbols in the libraries as well as in your programs.
1700 .Sp
1701 There are three kinds of global symbols, illustrated here by C examples:
1702 .RS 4
1703 .IP "\fBint i = 1;\fR" 4
1704 .IX Item "int i = 1;"
1705 A definition, which goes in the initialized data section of the output
1706 file.
1707 .IP "\fBextern int i;\fR" 4
1708 .IX Item "extern int i;"
1709 An undefined reference, which does not allocate space.
1710 There must be either a definition or a common symbol for the
1711 variable somewhere.
1712 .IP "\fBint i;\fR" 4
1713 .IX Item "int i;"
1714 A common symbol.  If there are only (one or more) common symbols for a
1715 variable, it goes in the uninitialized data area of the output file.
1716 The linker merges multiple common symbols for the same variable into a
1717 single symbol.  If they are of different sizes, it picks the largest
1718 size.  The linker turns a common symbol into a declaration, if there is
1719 a definition of the same variable.
1720 .RE
1721 .RS 4
1722 .Sp
1723 The \fB\-\-warn\-common\fR option can produce five kinds of warnings.
1724 Each warning consists of a pair of lines: the first describes the symbol
1725 just encountered, and the second describes the previous symbol
1726 encountered with the same name.  One or both of the two symbols will be
1727 a common symbol.
1728 .IP "1." 4
1729 Turning a common symbol into a reference, because there is already a
1730 definition for the symbol.
1731 .Sp
1732 .Vb 3
1733 \&        <file>(<section>): warning: common of \`<symbol>\*(Aq
1734 \&           overridden by definition
1735 \&        <file>(<section>): warning: defined here
1736 .Ve
1737 .IP "2." 4
1738 Turning a common symbol into a reference, because a later definition for
1739 the symbol is encountered.  This is the same as the previous case,
1740 except that the symbols are encountered in a different order.
1741 .Sp
1742 .Vb 3
1743 \&        <file>(<section>): warning: definition of \`<symbol>\*(Aq
1744 \&           overriding common
1745 \&        <file>(<section>): warning: common is here
1746 .Ve
1747 .IP "3." 4
1748 Merging a common symbol with a previous same-sized common symbol.
1749 .Sp
1750 .Vb 3
1751 \&        <file>(<section>): warning: multiple common
1752 \&           of \`<symbol>\*(Aq
1753 \&        <file>(<section>): warning: previous common is here
1754 .Ve
1755 .IP "4." 4
1756 Merging a common symbol with a previous larger common symbol.
1757 .Sp
1758 .Vb 3
1759 \&        <file>(<section>): warning: common of \`<symbol>\*(Aq
1760 \&           overridden by larger common
1761 \&        <file>(<section>): warning: larger common is here
1762 .Ve
1763 .IP "5." 4
1764 Merging a common symbol with a previous smaller common symbol.  This is
1765 the same as the previous case, except that the symbols are
1766 encountered in a different order.
1767 .Sp
1768 .Vb 3
1769 \&        <file>(<section>): warning: common of \`<symbol>\*(Aq
1770 \&           overriding smaller common
1771 \&        <file>(<section>): warning: smaller common is here
1772 .Ve
1773 .RE
1774 .RS 4
1775 .RE
1776 .IP "\fB\-\-warn\-constructors\fR" 4
1777 .IX Item "--warn-constructors"
1778 Warn if any global constructors are used.  This is only useful for a few
1779 object file formats.  For formats like \s-1COFF\s0 or \s-1ELF\s0, the linker can not
1780 detect the use of global constructors.
1781 .IP "\fB\-\-warn\-multiple\-gp\fR" 4
1782 .IX Item "--warn-multiple-gp"
1783 Warn if multiple global pointer values are required in the output file.
1784 This is only meaningful for certain processors, such as the Alpha.
1785 Specifically, some processors put large-valued constants in a special
1786 section.  A special register (the global pointer) points into the middle
1787 of this section, so that constants can be loaded efficiently via a
1788 base-register relative addressing mode.  Since the offset in
1789 base-register relative mode is fixed and relatively small (e.g., 16
1790 bits), this limits the maximum size of the constant pool.  Thus, in
1791 large programs, it is often necessary to use multiple global pointer
1792 values in order to be able to address all possible constants.  This
1793 option causes a warning to be issued whenever this case occurs.
1794 .IP "\fB\-\-warn\-once\fR" 4
1795 .IX Item "--warn-once"
1796 Only warn once for each undefined symbol, rather than once per module
1797 which refers to it.
1798 .IP "\fB\-\-warn\-section\-align\fR" 4
1799 .IX Item "--warn-section-align"
1800 Warn if the address of an output section is changed because of
1801 alignment.  Typically, the alignment will be set by an input section.
1802 The address will only be changed if it not explicitly specified; that
1803 is, if the \f(CW\*(C`SECTIONS\*(C'\fR command does not specify a start address for
1804 the section.
1805 .IP "\fB\-\-warn\-shared\-textrel\fR" 4
1806 .IX Item "--warn-shared-textrel"
1807 Warn if the linker adds a \s-1DT_TEXTREL\s0 to a shared object.
1808 .IP "\fB\-\-warn\-alternate\-em\fR" 4
1809 .IX Item "--warn-alternate-em"
1810 Warn if an object has alternate \s-1ELF\s0 machine code.
1811 .IP "\fB\-\-warn\-unresolved\-symbols\fR" 4
1812 .IX Item "--warn-unresolved-symbols"
1813 If the linker is going to report an unresolved symbol (see the option
1814 \&\fB\-\-unresolved\-symbols\fR) it will normally generate an error.
1815 This option makes it generate a warning instead.
1816 .IP "\fB\-\-error\-unresolved\-symbols\fR" 4
1817 .IX Item "--error-unresolved-symbols"
1818 This restores the linker's default behaviour of generating errors when
1819 it is reporting unresolved symbols.
1820 .IP "\fB\-\-whole\-archive\fR" 4
1821 .IX Item "--whole-archive"
1822 For each archive mentioned on the command line after the
1823 \&\fB\-\-whole\-archive\fR option, include every object file in the archive
1824 in the link, rather than searching the archive for the required object
1825 files.  This is normally used to turn an archive file into a shared
1826 library, forcing every object to be included in the resulting shared
1827 library.  This option may be used more than once.
1828 .Sp
1829 Two notes when using this option from gcc: First, gcc doesn't know
1830 about this option, so you have to use \fB\-Wl,\-whole\-archive\fR.
1831 Second, don't forget to use \fB\-Wl,\-no\-whole\-archive\fR after your
1832 list of archives, because gcc will add its own list of archives to
1833 your link and you may not want this flag to affect those as well.
1834 .IP "\fB\-\-wrap=\fR\fIsymbol\fR" 4
1835 .IX Item "--wrap=symbol"
1836 Use a wrapper function for \fIsymbol\fR.  Any undefined reference to
1837 \&\fIsymbol\fR will be resolved to \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR.  Any
1838 undefined reference to \f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR will be resolved to
1839 \&\fIsymbol\fR.
1840 .Sp
1841 This can be used to provide a wrapper for a system function.  The
1842 wrapper function should be called \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR.  If it
1843 wishes to call the system function, it should call
1844 \&\f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR.
1845 .Sp
1846 Here is a trivial example:
1847 .Sp
1848 .Vb 6
1849 \&        void *
1850 \&        _\|_wrap_malloc (size_t c)
1851 \&        {
1852 \&          printf ("malloc called with %zu\en", c);
1853 \&          return _\|_real_malloc (c);
1854 \&        }
1855 .Ve
1856 .Sp
1857 If you link other code with this file using \fB\-\-wrap malloc\fR, then
1858 all calls to \f(CW\*(C`malloc\*(C'\fR will call the function \f(CW\*(C`_\|_wrap_malloc\*(C'\fR
1859 instead.  The call to \f(CW\*(C`_\|_real_malloc\*(C'\fR in \f(CW\*(C`_\|_wrap_malloc\*(C'\fR will
1860 call the real \f(CW\*(C`malloc\*(C'\fR function.
1861 .Sp
1862 You may wish to provide a \f(CW\*(C`_\|_real_malloc\*(C'\fR function as well, so that
1863 links without the \fB\-\-wrap\fR option will succeed.  If you do this,
1864 you should not put the definition of \f(CW\*(C`_\|_real_malloc\*(C'\fR in the same
1865 file as \f(CW\*(C`_\|_wrap_malloc\*(C'\fR; if you do, the assembler may resolve the
1866 call before the linker has a chance to wrap it to \f(CW\*(C`malloc\*(C'\fR.
1867 .IP "\fB\-\-eh\-frame\-hdr\fR" 4
1868 .IX Item "--eh-frame-hdr"
1869 Request creation of \f(CW\*(C`.eh_frame_hdr\*(C'\fR section and \s-1ELF\s0
1870 \&\f(CW\*(C`PT_GNU_EH_FRAME\*(C'\fR segment header.
1871 .IP "\fB\-\-no\-ld\-generated\-unwind\-info\fR" 4
1872 .IX Item "--no-ld-generated-unwind-info"
1873 Request creation of \f(CW\*(C`.eh_frame\*(C'\fR unwind info for linker
1874 generated code sections like \s-1PLT\s0.  This option is on by default
1875 if linker generated unwind info is supported.
1876 .IP "\fB\-\-enable\-new\-dtags\fR" 4
1877 .IX Item "--enable-new-dtags"
1878 .PD 0
1879 .IP "\fB\-\-disable\-new\-dtags\fR" 4
1880 .IX Item "--disable-new-dtags"
1881 .PD
1882 This linker can create the new dynamic tags in \s-1ELF\s0. But the older \s-1ELF\s0
1883 systems may not understand them. If you specify
1884 \&\fB\-\-enable\-new\-dtags\fR, the new dynamic tags will be created as needed
1885 and older dynamic tags will be omitted.
1886 If you specify \fB\-\-disable\-new\-dtags\fR, no new dynamic tags will be
1887 created. By default, the new dynamic tags are not created. Note that
1888 those options are only available for \s-1ELF\s0 systems.
1889 .IP "\fB\-\-hash\-size=\fR\fInumber\fR" 4
1890 .IX Item "--hash-size=number"
1891 Set the default size of the linker's hash tables to a prime number
1892 close to \fInumber\fR.  Increasing this value can reduce the length of
1893 time it takes the linker to perform its tasks, at the expense of
1894 increasing the linker's memory requirements.  Similarly reducing this
1895 value can reduce the memory requirements at the expense of speed.
1896 .IP "\fB\-\-hash\-style=\fR\fIstyle\fR" 4
1897 .IX Item "--hash-style=style"
1898 Set the type of linker's hash table(s).  \fIstyle\fR can be either
1899 \&\f(CW\*(C`sysv\*(C'\fR for classic \s-1ELF\s0 \f(CW\*(C`.hash\*(C'\fR section, \f(CW\*(C`gnu\*(C'\fR for
1900 new style \s-1GNU\s0 \f(CW\*(C`.gnu.hash\*(C'\fR section or \f(CW\*(C`both\*(C'\fR for both
1901 the classic \s-1ELF\s0 \f(CW\*(C`.hash\*(C'\fR and new style \s-1GNU\s0 \f(CW\*(C`.gnu.hash\*(C'\fR
1902 hash tables.  The default is \f(CW\*(C`sysv\*(C'\fR.
1903 .IP "\fB\-\-reduce\-memory\-overheads\fR" 4
1904 .IX Item "--reduce-memory-overheads"
1905 This option reduces memory requirements at ld runtime, at the expense of
1906 linking speed.  This was introduced to select the old O(n^2) algorithm
1907 for link map file generation, rather than the new O(n) algorithm which uses
1908 about 40% more memory for symbol storage.
1909 .Sp
1910 Another effect of the switch is to set the default hash table size to
1911 1021, which again saves memory at the cost of lengthening the linker's
1912 run time.  This is not done however if the \fB\-\-hash\-size\fR switch
1913 has been used.
1914 .Sp
1915 The \fB\-\-reduce\-memory\-overheads\fR switch may be also be used to
1916 enable other tradeoffs in future versions of the linker.
1917 .IP "\fB\-\-build\-id\fR" 4
1918 .IX Item "--build-id"
1919 .PD 0
1920 .IP "\fB\-\-build\-id=\fR\fIstyle\fR" 4
1921 .IX Item "--build-id=style"
1922 .PD
1923 Request creation of \f(CW\*(C`.note.gnu.build\-id\*(C'\fR \s-1ELF\s0 note section.
1924 The contents of the note are unique bits identifying this linked
1925 file.  \fIstyle\fR can be \f(CW\*(C`uuid\*(C'\fR to use 128 random bits,
1926 \&\f(CW\*(C`sha1\*(C'\fR to use a 160\-bit \s-1SHA1\s0 hash on the normative
1927 parts of the output contents, \f(CW\*(C`md5\*(C'\fR to use a 128\-bit
1928 \&\s-1MD5\s0 hash on the normative parts of the output contents, or
1929 \&\f(CW\*(C`0x\f(CIhexstring\f(CW\*(C'\fR to use a chosen bit string specified as
1930 an even number of hexadecimal digits (\f(CW\*(C`\-\*(C'\fR and \f(CW\*(C`:\*(C'\fR
1931 characters between digit pairs are ignored).  If \fIstyle\fR is
1932 omitted, \f(CW\*(C`sha1\*(C'\fR is used.
1933 .Sp
1934 The \f(CW\*(C`md5\*(C'\fR and \f(CW\*(C`sha1\*(C'\fR styles produces an identifier
1935 that is always the same in an identical output file, but will be
1936 unique among all nonidentical output files.  It is not intended
1937 to be compared as a checksum for the file's contents.  A linked
1938 file may be changed later by other tools, but the build \s-1ID\s0 bit
1939 string identifying the original linked file does not change.
1940 .Sp
1941 Passing \f(CW\*(C`none\*(C'\fR for \fIstyle\fR disables the setting from any
1942 \&\f(CW\*(C`\-\-build\-id\*(C'\fR options earlier on the command line.
1943 .PP
1944 The i386 \s-1PE\s0 linker supports the \fB\-shared\fR option, which causes
1945 the output to be a dynamically linked library (\s-1DLL\s0) instead of a
1946 normal executable.  You should name the output \f(CW\*(C`*.dll\*(C'\fR when you
1947 use this option.  In addition, the linker fully supports the standard
1948 \&\f(CW\*(C`*.def\*(C'\fR files, which may be specified on the linker command line
1949 like an object file (in fact, it should precede archives it exports
1950 symbols from, to ensure that they get linked in, just like a normal
1951 object file).
1952 .PP
1953 In addition to the options common to all targets, the i386 \s-1PE\s0 linker
1954 support additional command line options that are specific to the i386
1955 \&\s-1PE\s0 target.  Options that take values may be separated from their
1956 values by either a space or an equals sign.
1957 .IP "\fB\-\-add\-stdcall\-alias\fR" 4
1958 .IX Item "--add-stdcall-alias"
1959 If given, symbols with a stdcall suffix (@\fInn\fR) will be exported
1960 as-is and also with the suffix stripped.
1961 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
1962 .IP "\fB\-\-base\-file\fR \fIfile\fR" 4
1963 .IX Item "--base-file file"
1964 Use \fIfile\fR as the name of a file in which to save the base
1965 addresses of all the relocations needed for generating DLLs with
1966 \&\fIdlltool\fR.
1967 [This is an i386 \s-1PE\s0 specific option]
1968 .IP "\fB\-\-dll\fR" 4
1969 .IX Item "--dll"
1970 Create a \s-1DLL\s0 instead of a regular executable.  You may also use
1971 \&\fB\-shared\fR or specify a \f(CW\*(C`LIBRARY\*(C'\fR in a given \f(CW\*(C`.def\*(C'\fR
1972 file.
1973 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
1974 .IP "\fB\-\-enable\-long\-section\-names\fR" 4
1975 .IX Item "--enable-long-section-names"
1976 .PD 0
1977 .IP "\fB\-\-disable\-long\-section\-names\fR" 4
1978 .IX Item "--disable-long-section-names"
1979 .PD
1980 The \s-1PE\s0 variants of the Coff object format add an extension that permits
1981 the use of section names longer than eight characters, the normal limit
1982 for Coff.  By default, these names are only allowed in object files, as
1983 fully-linked executable images do not carry the Coff string table required
1984 to support the longer names.  As a \s-1GNU\s0 extension, it is possible to
1985 allow their use in executable images as well, or to (probably pointlessly!)
1986 disallow it in object files, by using these two options.  Executable images
1987 generated with these long section names are slightly non-standard, carrying
1988 as they do a string table, and may generate confusing output when examined
1989 with non-GNU PE-aware tools, such as file viewers and dumpers.  However,
1990 \&\s-1GDB\s0 relies on the use of \s-1PE\s0 long section names to find Dwarf\-2 debug
1991 information sections in an executable image at runtime, and so if neither
1992 option is specified on the command-line, \fBld\fR will enable long
1993 section names, overriding the default and technically correct behaviour,
1994 when it finds the presence of debug information while linking an executable
1995 image and not stripping symbols.
1996 [This option is valid for all \s-1PE\s0 targeted ports of the linker]
1997 .IP "\fB\-\-enable\-stdcall\-fixup\fR" 4
1998 .IX Item "--enable-stdcall-fixup"
1999 .PD 0
2000 .IP "\fB\-\-disable\-stdcall\-fixup\fR" 4
2001 .IX Item "--disable-stdcall-fixup"
2002 .PD
2003 If the link finds a symbol that it cannot resolve, it will attempt to
2004 do \*(L"fuzzy linking\*(R" by looking for another defined symbol that differs
2005 only in the format of the symbol name (cdecl vs stdcall) and will
2006 resolve that symbol by linking to the match.  For example, the
2007 undefined symbol \f(CW\*(C`_foo\*(C'\fR might be linked to the function
2008 \&\f(CW\*(C`_foo@12\*(C'\fR, or the undefined symbol \f(CW\*(C`_bar@16\*(C'\fR might be linked
2009 to the function \f(CW\*(C`_bar\*(C'\fR.  When the linker does this, it prints a
2010 warning, since it normally should have failed to link, but sometimes
2011 import libraries generated from third-party dlls may need this feature
2012 to be usable.  If you specify \fB\-\-enable\-stdcall\-fixup\fR, this
2013 feature is fully enabled and warnings are not printed.  If you specify
2014 \&\fB\-\-disable\-stdcall\-fixup\fR, this feature is disabled and such
2015 mismatches are considered to be errors.
2016 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2017 .IP "\fB\-\-leading\-underscore\fR" 4
2018 .IX Item "--leading-underscore"
2019 .PD 0
2020 .IP "\fB\-\-no\-leading\-underscore\fR" 4
2021 .IX Item "--no-leading-underscore"
2022 .PD
2023 For most targets default symbol-prefix is an underscore and is defined
2024 in target's description. By this option it is possible to
2025 disable/enable the default underscore symbol-prefix.
2026 .IP "\fB\-\-export\-all\-symbols\fR" 4
2027 .IX Item "--export-all-symbols"
2028 If given, all global symbols in the objects used to build a \s-1DLL\s0 will
2029 be exported by the \s-1DLL\s0.  Note that this is the default if there
2030 otherwise wouldn't be any exported symbols.  When symbols are
2031 explicitly exported via \s-1DEF\s0 files or implicitly exported via function
2032 attributes, the default is to not export anything else unless this
2033 option is given.  Note that the symbols \f(CW\*(C`DllMain@12\*(C'\fR,
2034 \&\f(CW\*(C`DllEntryPoint@0\*(C'\fR, \f(CW\*(C`DllMainCRTStartup@12\*(C'\fR, and
2035 \&\f(CW\*(C`impure_ptr\*(C'\fR will not be automatically
2036 exported.  Also, symbols imported from other DLLs will not be
2037 re-exported, nor will symbols specifying the \s-1DLL\s0's internal layout
2038 such as those beginning with \f(CW\*(C`_head_\*(C'\fR or ending with
2039 \&\f(CW\*(C`_iname\*(C'\fR.  In addition, no symbols from \f(CW\*(C`libgcc\*(C'\fR,
2040 \&\f(CW\*(C`libstd++\*(C'\fR, \f(CW\*(C`libmingw32\*(C'\fR, or \f(CW\*(C`crtX.o\*(C'\fR will be exported.
2041 Symbols whose names begin with \f(CW\*(C`_\|_rtti_\*(C'\fR or \f(CW\*(C`_\|_builtin_\*(C'\fR will
2042 not be exported, to help with \*(C+ DLLs.  Finally, there is an
2043 extensive list of cygwin-private symbols that are not exported
2044 (obviously, this applies on when building DLLs for cygwin targets).
2045 These cygwin-excludes are: \f(CW\*(C`_cygwin_dll_entry@12\*(C'\fR,
2046 \&\f(CW\*(C`_cygwin_crt0_common@8\*(C'\fR, \f(CW\*(C`_cygwin_noncygwin_dll_entry@12\*(C'\fR,
2047 \&\f(CW\*(C`_fmode\*(C'\fR, \f(CW\*(C`_impure_ptr\*(C'\fR, \f(CW\*(C`cygwin_attach_dll\*(C'\fR,
2048 \&\f(CW\*(C`cygwin_premain0\*(C'\fR, \f(CW\*(C`cygwin_premain1\*(C'\fR, \f(CW\*(C`cygwin_premain2\*(C'\fR,
2049 \&\f(CW\*(C`cygwin_premain3\*(C'\fR, and \f(CW\*(C`environ\*(C'\fR.
2050 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2051 .IP "\fB\-\-exclude\-symbols\fR \fIsymbol\fR\fB,\fR\fIsymbol\fR\fB,...\fR" 4
2052 .IX Item "--exclude-symbols symbol,symbol,..."
2053 Specifies a list of symbols which should not be automatically
2054 exported.  The symbol names may be delimited by commas or colons.
2055 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2056 .IP "\fB\-\-exclude\-all\-symbols\fR" 4
2057 .IX Item "--exclude-all-symbols"
2058 Specifies no symbols should be automatically exported.
2059 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2060 .IP "\fB\-\-file\-alignment\fR" 4
2061 .IX Item "--file-alignment"
2062 Specify the file alignment.  Sections in the file will always begin at
2063 file offsets which are multiples of this number.  This defaults to
2064 512.
2065 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2066 .IP "\fB\-\-heap\fR \fIreserve\fR" 4
2067 .IX Item "--heap reserve"
2068 .PD 0
2069 .IP "\fB\-\-heap\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4
2070 .IX Item "--heap reserve,commit"
2071 .PD
2072 Specify the number of bytes of memory to reserve (and optionally commit)
2073 to be used as heap for this program.  The default is 1MB reserved, 4K
2074 committed.
2075 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2076 .IP "\fB\-\-image\-base\fR \fIvalue\fR" 4
2077 .IX Item "--image-base value"
2078 Use \fIvalue\fR as the base address of your program or dll.  This is
2079 the lowest memory location that will be used when your program or dll
2080 is loaded.  To reduce the need to relocate and improve performance of
2081 your dlls, each should have a unique base address and not overlap any
2082 other dlls.  The default is 0x400000 for executables, and 0x10000000
2083 for dlls.
2084 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2085 .IP "\fB\-\-kill\-at\fR" 4
2086 .IX Item "--kill-at"
2087 If given, the stdcall suffixes (@\fInn\fR) will be stripped from
2088 symbols before they are exported.
2089 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2090 .IP "\fB\-\-large\-address\-aware\fR" 4
2091 .IX Item "--large-address-aware"
2092 If given, the appropriate bit in the \*(L"Characteristics\*(R" field of the \s-1COFF\s0
2093 header is set to indicate that this executable supports virtual addresses
2094 greater than 2 gigabytes.  This should be used in conjunction with the /3GB
2095 or /USERVA=\fIvalue\fR megabytes switch in the \*(L"[operating systems]\*(R"
2096 section of the \s-1BOOT\s0.INI.  Otherwise, this bit has no effect.
2097 [This option is specific to \s-1PE\s0 targeted ports of the linker]
2098 .IP "\fB\-\-disable\-large\-address\-aware\fR" 4
2099 .IX Item "--disable-large-address-aware"
2100 Reverts the effect of a previous \fB\-\-large\-address\-aware\fR option.
2101 This is useful if \fB\-\-large\-address\-aware\fR is always set by the compiler
2102 driver (e.g. Cygwin gcc) and the executable does not support virtual
2103 addresses greater than 2 gigabytes.
2104 [This option is specific to \s-1PE\s0 targeted ports of the linker]
2105 .IP "\fB\-\-major\-image\-version\fR \fIvalue\fR" 4
2106 .IX Item "--major-image-version value"
2107 Sets the major number of the \*(L"image version\*(R".  Defaults to 1.
2108 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2109 .IP "\fB\-\-major\-os\-version\fR \fIvalue\fR" 4
2110 .IX Item "--major-os-version value"
2111 Sets the major number of the \*(L"os version\*(R".  Defaults to 4.
2112 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2113 .IP "\fB\-\-major\-subsystem\-version\fR \fIvalue\fR" 4
2114 .IX Item "--major-subsystem-version value"
2115 Sets the major number of the \*(L"subsystem version\*(R".  Defaults to 4.
2116 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2117 .IP "\fB\-\-minor\-image\-version\fR \fIvalue\fR" 4
2118 .IX Item "--minor-image-version value"
2119 Sets the minor number of the \*(L"image version\*(R".  Defaults to 0.
2120 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2121 .IP "\fB\-\-minor\-os\-version\fR \fIvalue\fR" 4
2122 .IX Item "--minor-os-version value"
2123 Sets the minor number of the \*(L"os version\*(R".  Defaults to 0.
2124 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2125 .IP "\fB\-\-minor\-subsystem\-version\fR \fIvalue\fR" 4
2126 .IX Item "--minor-subsystem-version value"
2127 Sets the minor number of the \*(L"subsystem version\*(R".  Defaults to 0.
2128 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2129 .IP "\fB\-\-output\-def\fR \fIfile\fR" 4
2130 .IX Item "--output-def file"
2131 The linker will create the file \fIfile\fR which will contain a \s-1DEF\s0
2132 file corresponding to the \s-1DLL\s0 the linker is generating.  This \s-1DEF\s0 file
2133 (which should be called \f(CW\*(C`*.def\*(C'\fR) may be used to create an import
2134 library with \f(CW\*(C`dlltool\*(C'\fR or may be used as a reference to
2135 automatically or implicitly exported symbols.
2136 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2137 .IP "\fB\-\-out\-implib\fR \fIfile\fR" 4
2138 .IX Item "--out-implib file"
2139 The linker will create the file \fIfile\fR which will contain an
2140 import lib corresponding to the \s-1DLL\s0 the linker is generating. This
2141 import lib (which should be called \f(CW\*(C`*.dll.a\*(C'\fR or \f(CW\*(C`*.a\*(C'\fR
2142 may be used to link clients against the generated \s-1DLL\s0; this behaviour
2143 makes it possible to skip a separate \f(CW\*(C`dlltool\*(C'\fR import library
2144 creation step.
2145 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2146 .IP "\fB\-\-enable\-auto\-image\-base\fR" 4
2147 .IX Item "--enable-auto-image-base"
2148 Automatically choose the image base for DLLs, unless one is specified
2149 using the \f(CW\*(C`\-\-image\-base\*(C'\fR argument.  By using a hash generated
2150 from the dllname to create unique image bases for each \s-1DLL\s0, in-memory
2151 collisions and relocations which can delay program execution are
2152 avoided.
2153 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2154 .IP "\fB\-\-disable\-auto\-image\-base\fR" 4
2155 .IX Item "--disable-auto-image-base"
2156 Do not automatically generate a unique image base.  If there is no
2157 user-specified image base (\f(CW\*(C`\-\-image\-base\*(C'\fR) then use the platform
2158 default.
2159 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2160 .IP "\fB\-\-dll\-search\-prefix\fR \fIstring\fR" 4
2161 .IX Item "--dll-search-prefix string"
2162 When linking dynamically to a dll without an import library,
2163 search for \f(CW\*(C`<string><basename>.dll\*(C'\fR in preference to
2164 \&\f(CW\*(C`lib<basename>.dll\*(C'\fR. This behaviour allows easy distinction
2165 between DLLs built for the various \*(L"subplatforms\*(R": native, cygwin,
2166 uwin, pw, etc.  For instance, cygwin DLLs typically use
2167 \&\f(CW\*(C`\-\-dll\-search\-prefix=cyg\*(C'\fR.
2168 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2169 .IP "\fB\-\-enable\-auto\-import\fR" 4
2170 .IX Item "--enable-auto-import"
2171 Do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to \f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for
2172 \&\s-1DATA\s0 imports from DLLs, and create the necessary thunking symbols when
2173 building the import libraries with those \s-1DATA\s0 exports. Note: Use of the
2174 \&'auto\-import' extension will cause the text section of the image file
2175 to be made writable. This does not conform to the PE-COFF format
2176 specification published by Microsoft.
2177 .Sp
2178 Note \- use of the 'auto\-import' extension will also cause read only
2179 data which would normally be placed into the .rdata section to be
2180 placed into the .data section instead.  This is in order to work
2181 around a problem with consts that is described here:
2182 http://www.cygwin.com/ml/cygwin/2004\-09/msg01101.html
2183 .Sp
2184 Using 'auto\-import' generally will 'just work' \*(-- but sometimes you may
2185 see this message:
2186 .Sp
2187 "variable '<var>' can't be auto-imported. Please read the
2188 documentation for ld's \f(CW\*(C`\-\-enable\-auto\-import\*(C'\fR for details."
2189 .Sp
2190 This message occurs when some (sub)expression accesses an address
2191 ultimately given by the sum of two constants (Win32 import tables only
2192 allow one).  Instances where this may occur include accesses to member
2193 fields of struct variables imported from a \s-1DLL\s0, as well as using a
2194 constant index into an array variable imported from a \s-1DLL\s0.  Any
2195 multiword variable (arrays, structs, long long, etc) may trigger
2196 this error condition.  However, regardless of the exact data type
2197 of the offending exported variable, ld will always detect it, issue
2198 the warning, and exit.
2199 .Sp
2200 There are several ways to address this difficulty, regardless of the
2201 data type of the exported variable:
2202 .Sp
2203 One way is to use \-\-enable\-runtime\-pseudo\-reloc switch. This leaves the task
2204 of adjusting references in your client code for runtime environment, so
2205 this method works only when runtime environment supports this feature.
2206 .Sp
2207 A second solution is to force one of the 'constants' to be a variable \*(--
2208 that is, unknown and un-optimizable at compile time.  For arrays,
2209 there are two possibilities: a) make the indexee (the array's address)
2210 a variable, or b) make the 'constant' index a variable.  Thus:
2211 .Sp
2212 .Vb 3
2213 \&        extern type extern_array[];
2214 \&        extern_array[1] \-\->
2215 \&           { volatile type *t=extern_array; t[1] }
2216 .Ve
2217 .Sp
2218 or
2219 .Sp
2220 .Vb 3
2221 \&        extern type extern_array[];
2222 \&        extern_array[1] \-\->
2223 \&           { volatile int t=1; extern_array[t] }
2224 .Ve
2225 .Sp
2226 For structs (and most other multiword data types) the only option
2227 is to make the struct itself (or the long long, or the ...) variable:
2228 .Sp
2229 .Vb 3
2230 \&        extern struct s extern_struct;
2231 \&        extern_struct.field \-\->
2232 \&           { volatile struct s *t=&extern_struct; t\->field }
2233 .Ve
2234 .Sp
2235 or
2236 .Sp
2237 .Vb 3
2238 \&        extern long long extern_ll;
2239 \&        extern_ll \-\->
2240 \&          { volatile long long * local_ll=&extern_ll; *local_ll }
2241 .Ve
2242 .Sp
2243 A third method of dealing with this difficulty is to abandon
2244 \&'auto\-import' for the offending symbol and mark it with
2245 \&\f(CW\*(C`_\|_declspec(dllimport)\*(C'\fR.  However, in practice that
2246 requires using compile-time #defines to indicate whether you are
2247 building a \s-1DLL\s0, building client code that will link to the \s-1DLL\s0, or
2248 merely building/linking to a static library.   In making the choice
2249 between the various methods of resolving the 'direct address with
2250 constant offset' problem, you should consider typical real-world usage:
2251 .Sp
2252 Original:
2253 .Sp
2254 .Vb 7
2255 \&        \-\-foo.h
2256 \&        extern int arr[];
2257 \&        \-\-foo.c
2258 \&        #include "foo.h"
2259 \&        void main(int argc, char **argv){
2260 \&          printf("%d\en",arr[1]);
2261 \&        }
2262 .Ve
2263 .Sp
2264 Solution 1:
2265 .Sp
2266 .Vb 9
2267 \&        \-\-foo.h
2268 \&        extern int arr[];
2269 \&        \-\-foo.c
2270 \&        #include "foo.h"
2271 \&        void main(int argc, char **argv){
2272 \&          /* This workaround is for win32 and cygwin; do not "optimize" */
2273 \&          volatile int *parr = arr;
2274 \&          printf("%d\en",parr[1]);
2275 \&        }
2276 .Ve
2277 .Sp
2278 Solution 2:
2279 .Sp
2280 .Vb 10
2281 \&        \-\-foo.h
2282 \&        /* Note: auto\-export is assumed (no _\|_declspec(dllexport)) */
2283 \&        #if (defined(_WIN32) || defined(_\|_CYGWIN_\|_)) && \e
2284 \&          !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
2285 \&        #define FOO_IMPORT _\|_declspec(dllimport)
2286 \&        #else
2287 \&        #define FOO_IMPORT
2288 \&        #endif
2289 \&        extern FOO_IMPORT int arr[];
2290 \&        \-\-foo.c
2291 \&        #include "foo.h"
2292 \&        void main(int argc, char **argv){
2293 \&          printf("%d\en",arr[1]);
2294 \&        }
2295 .Ve
2296 .Sp
2297 A fourth way to avoid this problem is to re-code your
2298 library to use a functional interface rather than a data interface
2299 for the offending variables (e.g. \fIset_foo()\fR and \fIget_foo()\fR accessor
2300 functions).
2301 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2302 .IP "\fB\-\-disable\-auto\-import\fR" 4
2303 .IX Item "--disable-auto-import"
2304 Do not attempt to do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to
2305 \&\f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for \s-1DATA\s0 imports from DLLs.
2306 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2307 .IP "\fB\-\-enable\-runtime\-pseudo\-reloc\fR" 4
2308 .IX Item "--enable-runtime-pseudo-reloc"
2309 If your code contains expressions described in \-\-enable\-auto\-import section,
2310 that is, \s-1DATA\s0 imports from \s-1DLL\s0 with non-zero offset, this switch will create
2311 a vector of 'runtime pseudo relocations' which can be used by runtime
2312 environment to adjust references to such data in your client code.
2313 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2314 .IP "\fB\-\-disable\-runtime\-pseudo\-reloc\fR" 4
2315 .IX Item "--disable-runtime-pseudo-reloc"
2316 Do not create pseudo relocations for non-zero offset \s-1DATA\s0 imports from
2317 DLLs.
2318 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2319 .IP "\fB\-\-enable\-extra\-pe\-debug\fR" 4
2320 .IX Item "--enable-extra-pe-debug"
2321 Show additional debug info related to auto-import symbol thunking.
2322 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2323 .IP "\fB\-\-section\-alignment\fR" 4
2324 .IX Item "--section-alignment"
2325 Sets the section alignment.  Sections in memory will always begin at
2326 addresses which are a multiple of this number.  Defaults to 0x1000.
2327 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2328 .IP "\fB\-\-stack\fR \fIreserve\fR" 4
2329 .IX Item "--stack reserve"
2330 .PD 0
2331 .IP "\fB\-\-stack\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4
2332 .IX Item "--stack reserve,commit"
2333 .PD
2334 Specify the number of bytes of memory to reserve (and optionally commit)
2335 to be used as stack for this program.  The default is 2MB reserved, 4K
2336 committed.
2337 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2338 .IP "\fB\-\-subsystem\fR \fIwhich\fR" 4
2339 .IX Item "--subsystem which"
2340 .PD 0
2341 .IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR" 4
2342 .IX Item "--subsystem which:major"
2343 .IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR\fB.\fR\fIminor\fR" 4
2344 .IX Item "--subsystem which:major.minor"
2345 .PD
2346 Specifies the subsystem under which your program will execute.  The
2347 legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C'\fR,
2348 \&\f(CW\*(C`console\*(C'\fR, \f(CW\*(C`posix\*(C'\fR, and \f(CW\*(C`xbox\*(C'\fR.  You may optionally set
2349 the subsystem version also.  Numeric values are also accepted for
2350 \&\fIwhich\fR.
2351 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]
2352 .Sp
2353 The following options set flags in the \f(CW\*(C`DllCharacteristics\*(C'\fR field
2354 of the \s-1PE\s0 file header:
2355 [These options are specific to \s-1PE\s0 targeted ports of the linker]
2356 .IP "\fB\-\-dynamicbase\fR" 4
2357 .IX Item "--dynamicbase"
2358 The image base address may be relocated using address space layout
2359 randomization (\s-1ASLR\s0).  This feature was introduced with \s-1MS\s0 Windows
2360 Vista for i386 \s-1PE\s0 targets.
2361 .IP "\fB\-\-forceinteg\fR" 4
2362 .IX Item "--forceinteg"
2363 Code integrity checks are enforced.
2364 .IP "\fB\-\-nxcompat\fR" 4
2365 .IX Item "--nxcompat"
2366 The image is compatible with the Data Execution Prevention.
2367 This feature was introduced with \s-1MS\s0 Windows \s-1XP\s0 \s-1SP2\s0 for i386 \s-1PE\s0 targets.
2368 .IP "\fB\-\-no\-isolation\fR" 4
2369 .IX Item "--no-isolation"
2370 Although the image understands isolation, do not isolate the image.
2371 .IP "\fB\-\-no\-seh\fR" 4
2372 .IX Item "--no-seh"
2373 The image does not use \s-1SEH\s0. No \s-1SE\s0 handler may be called from
2374 this image.
2375 .IP "\fB\-\-no\-bind\fR" 4
2376 .IX Item "--no-bind"
2377 Do not bind this image.
2378 .IP "\fB\-\-wdmdriver\fR" 4
2379 .IX Item "--wdmdriver"
2380 The driver uses the \s-1MS\s0 Windows Driver Model.
2381 .IP "\fB\-\-tsaware\fR" 4
2382 .IX Item "--tsaware"
2383 The image is Terminal Server aware.
2384 .IP "\fB\-\-insert\-timestamp\fR" 4
2385 .IX Item "--insert-timestamp"
2386 Insert a real timestamp into the image, rather than the default value
2387 of zero.  This will result in a slightly different results with each
2388 invocation, which could be helpful for distributing unique images.
2389 .PP
2390 The C6X uClinux target uses a binary format called \s-1DSBT\s0 to support shared
2391 libraries.  Each shared library in the system needs to have a unique index;
2392 all executables use an index of 0.
2393 .IP "\fB\-\-dsbt\-size\fR \fIsize\fR" 4
2394 .IX Item "--dsbt-size size"
2395 This option sets the number of entires in the \s-1DSBT\s0 of the current executable
2396 or shared library to \fIsize\fR.  The default is to create a table with 64
2397 entries.
2398 .IP "\fB\-\-dsbt\-index\fR \fIindex\fR" 4
2399 .IX Item "--dsbt-index index"
2400 This option sets the \s-1DSBT\s0 index of the current executable or shared library
2401 to \fIindex\fR.  The default is 0, which is appropriate for generating
2402 executables.  If a shared library is generated with a \s-1DSBT\s0 index of 0, the
2403 \&\f(CW\*(C`R_C6000_DSBT_INDEX\*(C'\fR relocs are copied into the output file.
2404 .Sp
2405 The \fB\-\-no\-merge\-exidx\-entries\fR switch disables the merging of adjacent
2406 exidx entries in frame unwind info.
2407 .PP
2408 The 68HC11 and 68HC12 linkers support specific options to control the
2409 memory bank switching mapping and trampoline code generation.
2410 .IP "\fB\-\-no\-trampoline\fR" 4
2411 .IX Item "--no-trampoline"
2412 This option disables the generation of trampoline. By default a trampoline
2413 is generated for each far function which is called using a \f(CW\*(C`jsr\*(C'\fR
2414 instruction (this happens when a pointer to a far function is taken).
2415 .IP "\fB\-\-bank\-window\fR \fIname\fR" 4
2416 .IX Item "--bank-window name"
2417 This option indicates to the linker the name of the memory region in
2418 the \fB\s-1MEMORY\s0\fR specification that describes the memory bank window.
2419 The definition of such region is then used by the linker to compute
2420 paging and addresses within the memory window.
2421 .PP
2422 The following options are supported to control handling of \s-1GOT\s0 generation
2423 when linking for 68K targets.
2424 .IP "\fB\-\-got=\fR\fItype\fR" 4
2425 .IX Item "--got=type"
2426 This option tells the linker which \s-1GOT\s0 generation scheme to use.
2427 \&\fItype\fR should be one of \fBsingle\fR, \fBnegative\fR,
2428 \&\fBmultigot\fR or \fBtarget\fR.  For more information refer to the
2429 Info entry for \fIld\fR.
2430 .PP
2431 The following options are supported to control microMIPS instruction
2432 generation when linking for \s-1MIPS\s0 targets.
2433 .IP "\fB\-\-insn32\fR" 4
2434 .IX Item "--insn32"
2435 .PD 0
2436 .IP "\fB\-\-no\-insn32\fR" 4
2437 .IX Item "--no-insn32"
2438 .PD
2439 These options control the choice of microMIPS instructions used in code
2440 generated by the linker, such as that in the \s-1PLT\s0 or lazy binding stubs,
2441 or in relaxation.  If \fB\-\-insn32\fR is used, then the linker only uses
2442 32\-bit instruction encodings.  By default or if \fB\-\-no\-insn32\fR is
2443 used, all instruction encodings are used, including 16\-bit ones where
2444 possible.
2445 .SH "ENVIRONMENT"
2446 .IX Header "ENVIRONMENT"
2447 You can change the behaviour of \fBld\fR with the environment variables
2448 \&\f(CW\*(C`GNUTARGET\*(C'\fR,
2449 \&\f(CW\*(C`LDEMULATION\*(C'\fR and \f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR.
2450 .PP
2451 \&\f(CW\*(C`GNUTARGET\*(C'\fR determines the input-file object format if you don't
2452 use \fB\-b\fR (or its synonym \fB\-\-format\fR).  Its value should be one
2453 of the \s-1BFD\s0 names for an input format.  If there is no
2454 \&\f(CW\*(C`GNUTARGET\*(C'\fR in the environment, \fBld\fR uses the natural format
2455 of the target. If \f(CW\*(C`GNUTARGET\*(C'\fR is set to \f(CW\*(C`default\*(C'\fR then \s-1BFD\s0
2456 attempts to discover the input format by examining binary input files;
2457 this method often succeeds, but there are potential ambiguities, since
2458 there is no method of ensuring that the magic number used to specify
2459 object-file formats is unique.  However, the configuration procedure for
2460 \&\s-1BFD\s0 on each system places the conventional format for that system first
2461 in the search-list, so ambiguities are resolved in favor of convention.
2462 .PP
2463 \&\f(CW\*(C`LDEMULATION\*(C'\fR determines the default emulation if you don't use the
2464 \&\fB\-m\fR option.  The emulation can affect various aspects of linker
2465 behaviour, particularly the default linker script.  You can list the
2466 available emulations with the \fB\-\-verbose\fR or \fB\-V\fR options.  If
2467 the \fB\-m\fR option is not used, and the \f(CW\*(C`LDEMULATION\*(C'\fR environment
2468 variable is not defined, the default emulation depends upon how the
2469 linker was configured.
2470 .PP
2471 Normally, the linker will default to demangling symbols.  However, if
2472 \&\f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR is set in the environment, then it will
2473 default to not demangling symbols.  This environment variable is used in
2474 a similar fashion by the \f(CW\*(C`gcc\*(C'\fR linker wrapper program.  The default
2475 may be overridden by the \fB\-\-demangle\fR and \fB\-\-no\-demangle\fR
2476 options.
2477 .SH "SEE ALSO"
2478 .IX Header "SEE ALSO"
2479 \&\fIar\fR\|(1), \fInm\fR\|(1), \fIobjcopy\fR\|(1), \fIobjdump\fR\|(1), \fIreadelf\fR\|(1) and
2480 the Info entries for \fIbinutils\fR and
2481 \&\fIld\fR.
2482 .SH "COPYRIGHT"
2483 .IX Header "COPYRIGHT"
2484 Copyright (c) 1991\-2013 Free Software Foundation, Inc.
2485 .PP
2486 Permission is granted to copy, distribute and/or modify this document
2487 under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3
2488 or any later version published by the Free Software Foundation;
2489 with no Invariant Sections, with no Front-Cover Texts, and with no
2490 Back-Cover Texts.  A copy of the license is included in the
2491 section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".