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