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