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