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