Debian Codegraph @

upstream/fedora-rawhide/man1/ld.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.48)
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 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "LD 1"
61 .TH LD 1 2026-05-14 binutils-2.46.50 "GNU Development Tools"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 ld \- The GNU linker
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 ld [\fBoptions\fR] \fIobjfile\fR ...
71 .SH DESCRIPTION
72 .IX Header "DESCRIPTION"
73 \&\fBld\fR combines a number of object and archive files, relocates
74 their data and ties up symbol references. Usually the last step in
75 compiling a program is to run \fBld\fR.
76 .PP
77 \&\fBld\fR accepts Linker Command Language files written in
78 a superset of AT&T\*(Aqs Link Editor Command Language syntax,
79 to provide explicit and total control over the linking process.
80 .PP
81 This man page does not describe the command language; see the
82 \&\fBld\fR entry in \f(CW\*(C`info\*(C'\fR for full details on the command
83 language and on other aspects of the GNU linker.
84 .PP
85 This version of \fBld\fR uses the general purpose BFD libraries
86 to operate on object files. This allows \fBld\fR to read, combine, and
87 write object files in many different formats\-\-\-for example, COFF or
88 \&\f(CW\*(C`a.out\*(C'\fR. Different formats may be linked together to produce any
89 available kind of object file.
90 .PP
91 Aside from its flexibility, the GNU linker is more helpful than other
92 linkers in providing diagnostic information. Many linkers abandon
93 execution immediately upon encountering an error; whenever possible,
94 \&\fBld\fR continues executing, allowing you to identify other errors
95 (or, in some cases, to get an output file in spite of the error).
96 .PP
97 The GNU linker \fBld\fR is meant to cover a broad range of situations,
98 and to be as compatible as possible with other linkers. As a result,
99 you have many choices to control its behavior.
100 .SH OPTIONS
101 .IX Header "OPTIONS"
102 The linker supports a plethora of command\-line options, but in actual
103 practice few of them are used in any particular context.
104 For instance, a frequent use of \fBld\fR is to link standard Unix
105 object files on a standard, supported Unix system. On such a system, to
106 link a file \f(CW\*(C`hello.o\*(C'\fR:
107 .PP
108 .Vb 1
109 \& ld \-o <output> /lib/crt0.o hello.o \-lc
110 .Ve
111 .PP
112 This tells \fBld\fR to produce a file called \fIoutput\fR as the
113 result of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR and
114 the library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard search
115 directories. (See the discussion of the \fB\-l\fR option below.)
116 .PP
117 Some of the command\-line options to \fBld\fR may be specified at any
118 point in the command line. However, options which refer to files, such
119 as \fB\-l\fR or \fB\-T\fR, cause the file to be read at the point at
120 which the option appears in the command line, relative to the object
121 files and other file options. Repeating non\-file options with a
122 different argument will either have no further effect, or override prior
123 occurrences (those further to the left on the command line) of that
124 option. Options which may be meaningfully specified more than once are
125 noted in the descriptions below.
126 .PP
127 Non\-option arguments are object files or archives which are to be linked
128 together. They may follow, precede, or be mixed in with command\-line
129 options, except that an object file argument may not be placed between
130 an option and its argument.
131 .PP
132 Usually the linker is invoked with at least one object file, but you can
133 specify other forms of binary input files using \fB\-l\fR, \fB\-R\fR,
134 and the script command language. If \fIno\fR binary input files at all
135 are specified, the linker does not produce any output, and issues the
136 message \fBNo input files\fR.
137 .PP
138 If the linker cannot recognize the format of an object file, it will
139 assume that it is a linker script. A script specified in this way
140 augments the main linker script used for the link (either the default
141 linker script or the one specified by using \fB\-T\fR). This feature
142 permits the linker to link against a file which appears to be an object
143 or an archive, but actually merely defines some symbol values, or uses
144 \&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Specifying a
145 script in this way merely augments the main linker script, with the
146 extra commands placed after the main script; use the \fB\-T\fR option
147 to replace the default linker script entirely, but note the effect of
148 the \f(CW\*(C`INSERT\*(C'\fR command.
149 .PP
150 For options whose names are a single letter,
151 option arguments must either follow the option letter without intervening
152 whitespace, or be given as separate arguments immediately following the
153 option that requires them.
154 .PP
155 For options whose names are multiple letters, either one dash or two can
156 precede the option name; for example, \fB\-trace\-symbol\fR and
157 \&\fB\-\-trace\-symbol\fR are equivalent. Note\-\-\-there is one exception to
158 this rule. Multiple letter options that start with a lower case \*(Aqo\*(Aq can
159 only be preceded by two dashes. This is to reduce confusion with the
160 \&\fB\-o\fR option. So for example \fB\-omagic\fR sets the output file
161 name to \fBmagic\fR whereas \fB\-\-omagic\fR sets the NMAGIC flag on the
162 output.
163 .PP
164 Arguments to multiple\-letter options must either be separated from the
165 option name by an equals sign, or be given as separate arguments
166 immediately following the option that requires them. For example,
167 \&\fB\-\-trace\-symbol foo\fR and \fB\-\-trace\-symbol=foo\fR are equivalent.
168 Unique abbreviations of the names of multiple\-letter options are
169 accepted.
170 .PP
171 Note\-\-\-if the linker is being invoked indirectly, via a compiler driver
172 (e.g. \fBgcc\fR) then all the linker command\-line options should be
173 prefixed by \fB\-Wl,\fR (or whatever is appropriate for the particular
174 compiler driver) like this:
175 .PP
176 .Vb 1
177 \& gcc \-Wl,\-\-start\-group foo.o bar.o \-Wl,\-\-end\-group
178 .Ve
179 .PP
180 This is important, because otherwise the compiler driver program may
181 silently drop the linker options, resulting in a bad link. Confusion
182 may also arise when passing options that require values through a
183 driver, as the use of a space between option and argument acts as
184 a separator, and causes the driver to pass only the option to the linker
185 and the argument to the compiler. In this case, it is simplest to use
186 the joined forms of both single\- and multiple\-letter options, such as:
187 .PP
188 .Vb 1
189 \& gcc foo.o bar.o \-Wl,\-eENTRY \-Wl,\-Map=a.map
190 .Ve
191 .PP
192 Here is a table of the generic command\-line switches accepted by the GNU
193 linker:
194 .IP \fB@\fR\fIfile\fR 4
195 .IX Item "@file"
196 Read command\-line options from \fIfile\fR. The options read are
197 inserted in place of the original @\fIfile\fR option. If \fIfile\fR
198 does not exist, or cannot be read, then the option will be treated
199 literally, and not removed.
200 .Sp
201 Options in \fIfile\fR are separated by whitespace. A whitespace
202 character may be included in an option by surrounding the entire
203 option in either single or double quotes. Any character (including a
204 backslash) may be included by prefixing the character to be included
205 with a backslash. The \fIfile\fR may itself contain additional
206 @\fIfile\fR options; any such options will be processed recursively.
207 .IP "\fB\-a\fR \fIkeyword\fR" 4
208 .IX Item "-a keyword"
209 This option is supported for HP/UX compatibility. The \fIkeyword\fR
210 argument must be one of the strings \fBarchive\fR, \fBshared\fR, or
211 \&\fBdefault\fR. \fB\-aarchive\fR is functionally equivalent to
212 \&\fB\-Bstatic\fR, and the other two keywords are functionally equivalent
213 to \fB\-Bdynamic\fR. This option may be used any number of times.
214 .IP "\fB\-\-audit\fR \fIAUDITLIB\fR" 4
215 .IX Item "--audit AUDITLIB"
216 Adds \fIAUDITLIB\fR to the \f(CW\*(C`DT_AUDIT\*(C'\fR entry of the dynamic section.
217 \&\fIAUDITLIB\fR is not checked for existence, nor will it use the DT_SONAME
218 specified in the library. If specified multiple times \f(CW\*(C`DT_AUDIT\*(C'\fR
219 will contain a colon separated list of audit interfaces to use. If the linker
220 finds an object with an audit entry while searching for shared libraries,
221 it will add a corresponding \f(CW\*(C`DT_DEPAUDIT\*(C'\fR entry in the output file.
222 This option is only meaningful on ELF platforms supporting the rtld\-audit
223 interface.
224 .IP "\fB\-b\fR \fIinput\-format\fR" 4
225 .IX Item "-b input-format"
226 .PD 0
227 .IP \fB\-\-format=\fR\fIinput\-format\fR 4
228 .IX Item "--format=input-format"
229 .PD
230 \&\fBld\fR may be configured to support more than one kind of object
231 file. If your \fBld\fR is configured this way, you can use the
232 \&\fB\-b\fR option to specify the binary format for input object files
233 that follow this option on the command line. Even when \fBld\fR is
234 configured to support alternative object formats, you don\*(Aqt usually need
235 to specify this, as \fBld\fR should be configured to expect as a
236 default input format the most usual format on each machine.
237 \&\fIinput\-format\fR is a text string, the name of a particular format
238 supported by the BFD libraries. (You can list the available binary
239 formats with \fBobjdump \-i\fR.)
240 .Sp
241 You may want to use this option if you are linking files with an unusual
242 binary format. You can also use \fB\-b\fR to switch formats explicitly (when
243 linking object files of different formats), by including
244 \&\fB\-b\fR \fIinput\-format\fR before each group of object files in a
245 particular format.
246 .Sp
247 The default format is taken from the environment variable
248 \&\f(CW\*(C`GNUTARGET\*(C'\fR.
249 .Sp
250 You can also define the input format from a script, using the command
251 \&\f(CW\*(C`TARGET\*(C'\fR;
252 .IP "\fB\-c\fR \fIMRI\-commandfile\fR" 4
253 .IX Item "-c MRI-commandfile"
254 .PD 0
255 .IP \fB\-\-mri\-script=\fR\fIMRI\-commandfile\fR 4
256 .IX Item "--mri-script=MRI-commandfile"
257 .PD
258 For compatibility with linkers produced by MRI, \fBld\fR accepts script
259 files written in an alternate, restricted command language, described in
260 the MRI Compatible Script Files section of GNU ld documentation.
261 Introduce MRI script files with
262 the option \fB\-c\fR; use the \fB\-T\fR option to run linker
263 scripts written in the general\-purpose \fBld\fR scripting language.
264 If \fIMRI\-cmdfile\fR does not exist, \fBld\fR looks for it in the directories
265 specified by any \fB\-L\fR options.
266 .IP \fB\-d\fR 4
267 .IX Item "-d"
268 .PD 0
269 .IP \fB\-dc\fR 4
270 .IX Item "-dc"
271 .IP \fB\-dp\fR 4
272 .IX Item "-dp"
273 .PD
274 These three options are equivalent; multiple forms are supported for
275 compatibility with other linkers. They assign space to common symbols
276 even if a relocatable output file is specified (with \fB\-r\fR). The
277 script command \f(CW\*(C`FORCE_COMMON_ALLOCATION\*(C'\fR has the same effect.
278 .IP "\fB\-\-depaudit\fR \fIAUDITLIB\fR" 4
279 .IX Item "--depaudit AUDITLIB"
280 .PD 0
281 .IP "\fB\-P\fR \fIAUDITLIB\fR" 4
282 .IX Item "-P AUDITLIB"
283 .PD
284 Adds \fIAUDITLIB\fR to the \f(CW\*(C`DT_DEPAUDIT\*(C'\fR entry of the dynamic section.
285 \&\fIAUDITLIB\fR is not checked for existence, nor will it use the DT_SONAME
286 specified in the library. If specified multiple times \f(CW\*(C`DT_DEPAUDIT\*(C'\fR
287 will contain a colon separated list of audit interfaces to use. This
288 option is only meaningful on ELF platforms supporting the rtld\-audit interface.
289 The \-P option is provided for Solaris compatibility.
290 .IP \fB\-\-enable\-linker\-version\fR 4
291 .IX Item "--enable-linker-version"
292 Enables the \f(CW\*(C`LINKER_VERSION\*(C'\fR linker script directive, described
293 in \fBOutput Section Data\fR. If this directive is used in a linker
294 script and this option has been enabled then a string containing the
295 linker version will be inserted at the current point.
296 .Sp
297 Note \- this location of this option on the linker command line is
298 significant. It will only affect linker scripts that come after it on
299 the command line, or which are built into the linker.
300 .IP \fB\-\-disable\-linker\-version\fR 4
301 .IX Item "--disable-linker-version"
302 Disables the \f(CW\*(C`LINKER_VERSION\*(C'\fR linker script directive, so that it
303 does not insert a version string. This is the default.
304 .IP \fB\-\-enable\-non\-contiguous\-regions\fR 4
305 .IX Item "--enable-non-contiguous-regions"
306 This option avoids generating an error if an input section does not
307 fit a matching output section. The linker tries to allocate the input
308 section to subsequent matching output sections, and generates an
309 error only if no output section is large enough. This is useful when
310 several non\-contiguous memory regions are available and the input
311 section does not require a particular one. The order in which input
312 sections are evaluated does not change, for instance:
313 .Sp
314 .Vb 10
315 \& MEMORY {
316 \& MEM1 (rwx) : ORIGIN = 0x1000, LENGTH = 0x14
317 \& MEM2 (rwx) : ORIGIN = 0x1000, LENGTH = 0x40
318 \& MEM3 (rwx) : ORIGIN = 0x2000, LENGTH = 0x40
319 \& }
320 \& SECTIONS {
321 \& mem1 : { *(.data.*); } > MEM1
322 \& mem2 : { *(.data.*); } > MEM2
323 \& mem3 : { *(.data.*); } > MEM3
324 \& }
325 \&
326 \& with input sections:
327 \& .data.1: size 8
328 \& .data.2: size 0x10
329 \& .data.3: size 4
330 \&
331 \& results in .data.1 affected to mem1, and .data.2 and .data.3
332 \& affected to mem2, even though .data.3 would fit in mem3.
333 .Ve
334 .Sp
335 This option is incompatible with INSERT statements because it changes
336 the way input sections are mapped to output sections.
337 .IP \fB\-\-enable\-non\-contiguous\-regions\-warnings\fR 4
338 .IX Item "--enable-non-contiguous-regions-warnings"
339 This option enables warnings when
340 \&\f(CW\*(C`\-\-enable\-non\-contiguous\-regions\*(C'\fR allows possibly unexpected
341 matches in sections mapping, potentially leading to silently
342 discarding a section instead of failing because it does not fit any
343 output region.
344 .IP "\fB\-e\fR \fIentry\fR" 4
345 .IX Item "-e entry"
346 .PD 0
347 .IP \fB\-\-entry=\fR\fIentry\fR 4
348 .IX Item "--entry=entry"
349 .PD
350 Use \fIentry\fR as the explicit symbol for beginning execution of your
351 program, rather than the default entry point. If there is no symbol
352 named \fIentry\fR, the linker will try to parse \fIentry\fR as a number,
353 and use that as the entry address (the number will be interpreted in
354 base 10; you may use a leading \fB0x\fR for base 16, or a leading
355 \&\fB0\fR for base 8). For i386 PE, \fIentry\fR
356 can be also the original function name (without the leading underscore
357 and/or the trailing stdcall \fR\f(CB@number\fR\fB\fR when applicable).
358 .IP "\fB\-\-exclude\-libs\fR \fIlib\fR\fB,\fR\fIlib\fR\fB,...\fR" 4
359 .IX Item "--exclude-libs lib,lib,..."
360 Specifies a list of archive libraries from which symbols should not be automatically
361 exported. The library names may be delimited by commas or colons. Specifying
362 \&\f(CW\*(C`\-\-exclude\-libs ALL\*(C'\fR excludes symbols in all archive libraries from
363 automatic export. This option is available only for the i386 PE targeted
364 port of the linker and for ELF targeted ports. For i386 PE, symbols
365 explicitly listed in a .def file are still exported, regardless of this
366 option. For ELF targeted ports, symbols affected by this option will
367 be treated as hidden.
368 .IP "\fB\-\-exclude\-modules\-for\-implib\fR \fImodule\fR\fB,\fR\fImodule\fR\fB,...\fR" 4
369 .IX Item "--exclude-modules-for-implib module,module,..."
370 Specifies a list of object files or archive members, from which symbols
371 should not be automatically exported, but which should be copied wholesale
372 into the import library being generated during the link. The module names
373 may be delimited by commas or colons, and must match exactly the filenames
374 used by \fBld\fR to open the files; for archive members, this is simply
375 the member name, but for object files the name listed must include and
376 match precisely any path used to specify the input file on the linker\*(Aqs
377 command\-line. This option is available only for the i386 PE targeted port
378 of the linker. Symbols explicitly listed in a .def file are still exported,
379 regardless of this option.
380 .IP \fB\-E\fR 4
381 .IX Item "-E"
382 .PD 0
383 .IP \fB\-\-export\-dynamic\fR 4
384 .IX Item "--export-dynamic"
385 .IP \fB\-\-no\-export\-dynamic\fR 4
386 .IX Item "--no-export-dynamic"
387 .PD
388 When creating a dynamically linked executable, using the \fB\-E\fR
389 option or the \fB\-\-export\-dynamic\fR option causes the linker to add
390 all symbols to the dynamic symbol table. The dynamic symbol table is the
391 set of symbols which are visible from dynamic objects at run time.
392 .Sp
393 If you do not use either of these options (or use the
394 \&\fB\-\-no\-export\-dynamic\fR option to restore the default behavior), the
395 dynamic symbol table will normally contain only those symbols which are
396 referenced by some dynamic object mentioned in the link.
397 .Sp
398 If you use \f(CW\*(C`dlopen\*(C'\fR to load a dynamic object which needs to refer
399 back to the symbols defined by the program, rather than some other
400 dynamic object, then you will probably need to use this option when
401 linking the program itself.
402 .Sp
403 You can also use the dynamic list to control what symbols should
404 be added to the dynamic symbol table if the output format supports it.
405 See the description of \fB\-\-dynamic\-list\fR.
406 .Sp
407 Note that this option is specific to ELF targeted ports. PE targets
408 support a similar function to export all symbols from a DLL or EXE; see
409 the description of \fB\-\-export\-all\-symbols\fR below.
410 .IP \fB\-\-export\-dynamic\-symbol=\fR\fIglob\fR 4
411 .IX Item "--export-dynamic-symbol=glob"
412 When creating a dynamically linked executable, symbols matching
413 \&\fIglob\fR will be added to the dynamic symbol table. When creating a
414 shared library, references to symbols matching \fIglob\fR will not be
415 bound to the definitions within the shared library. This option is a
416 no\-op when creating a shared library and \fB\-Bsymbolic\fR or
417 \&\fB\-\-dynamic\-list\fR are not specified. This option is only meaningful
418 on ELF platforms which support shared libraries.
419 .IP \fB\-\-export\-dynamic\-symbol\-list=\fR\fIfile\fR 4
420 .IX Item "--export-dynamic-symbol-list=file"
421 Specify a \fB\-\-export\-dynamic\-symbol\fR for each pattern in the file.
422 The format of the file is the same as the version node without
423 scope and node name. See \fBVERSION\fR for more information.
424 .IP \fB\-EB\fR 4
425 .IX Item "-EB"
426 Link big\-endian objects. This affects the default output format.
427 .IP \fB\-EL\fR 4
428 .IX Item "-EL"
429 Link little\-endian objects. This affects the default output format.
430 .IP "\fB\-f\fR \fIname\fR" 4
431 .IX Item "-f name"
432 .PD 0
433 .IP \fB\-\-auxiliary=\fR\fIname\fR 4
434 .IX Item "--auxiliary=name"
435 .PD
436 When creating an ELF shared object, set the internal DT_AUXILIARY field
437 to the specified name. This tells the dynamic linker that the symbol
438 table of the shared object should be used as an auxiliary filter on the
439 symbol table of the shared object \fIname\fR.
440 .Sp
441 If you later link a program against this filter object, then, when you
442 run the program, the dynamic linker will see the DT_AUXILIARY field. If
443 the dynamic linker resolves any symbols from the filter object, it will
444 first check whether there is a definition in the shared object
445 \&\fIname\fR. If there is one, it will be used instead of the definition
446 in the filter object. The shared object \fIname\fR need not exist.
447 Thus the shared object \fIname\fR may be used to provide an alternative
448 implementation of certain functions, perhaps for debugging or for
449 machine\-specific performance.
450 .Sp
451 This option may be specified more than once. The DT_AUXILIARY entries
452 will be created in the order in which they appear on the command line.
453 .IP "\fB\-F\fR \fIname\fR" 4
454 .IX Item "-F name"
455 .PD 0
456 .IP \fB\-\-filter=\fR\fIname\fR 4
457 .IX Item "--filter=name"
458 .PD
459 When creating an ELF shared object, set the internal DT_FILTER field to
460 the specified name. This tells the dynamic linker that the symbol table
461 of the shared object which is being created should be used as a filter
462 on the symbol table of the shared object \fIname\fR.
463 .Sp
464 If you later link a program against this filter object, then, when you
465 run the program, the dynamic linker will see the DT_FILTER field. The
466 dynamic linker will resolve symbols according to the symbol table of the
467 filter object as usual, but it will actually link to the definitions
468 found in the shared object \fIname\fR. Thus the filter object can be
469 used to select a subset of the symbols provided by the object
470 \&\fIname\fR.
471 .Sp
472 Some older linkers used the \fB\-F\fR option throughout a compilation
473 toolchain for specifying object\-file format for both input and output
474 object files.
475 The GNU linker uses other mechanisms for this purpose: the
476 \&\fB\-b\fR, \fB\-\-format\fR, \fB\-\-oformat\fR options, the
477 \&\f(CW\*(C`TARGET\*(C'\fR command in linker scripts, and the \f(CW\*(C`GNUTARGET\*(C'\fR
478 environment variable.
479 The GNU linker will ignore the \fB\-F\fR option when not
480 creating an ELF shared object.
481 .IP \fB\-fini=\fR\fIname\fR 4
482 .IX Item "-fini=name"
483 When creating an ELF executable or shared object, call NAME when the
484 executable or shared object is unloaded, by setting DT_FINI to the
485 address of the function. By default, the linker uses \f(CW\*(C`_fini\*(C'\fR as
486 the function to call.
487 .IP \fB\-g\fR 4
488 .IX Item "-g"
489 Ignored. Provided for compatibility with other tools.
490 .IP "\fB\-G\fR \fIvalue\fR" 4
491 .IX Item "-G value"
492 .PD 0
493 .IP \fB\-\-gpsize=\fR\fIvalue\fR 4
494 .IX Item "--gpsize=value"
495 .PD
496 Set the maximum size of objects to be optimized using the GP register to
497 \&\fIsize\fR. This is only meaningful for object file formats such as
498 MIPS ELF that support putting large and small objects into different
499 sections. This is ignored for other object file formats.
500 .IP "\fB\-h\fR \fIname\fR" 4
501 .IX Item "-h name"
502 .PD 0
503 .IP \fB\-soname=\fR\fIname\fR 4
504 .IX Item "-soname=name"
505 .PD
506 When creating an ELF shared object, set the internal DT_SONAME field to
507 the specified name. When an executable is linked with a shared object
508 which has a DT_SONAME field, then when the executable is run the dynamic
509 linker will attempt to load the shared object specified by the DT_SONAME
510 field rather than using the file name given to the linker.
511 .IP \fB\-i\fR 4
512 .IX Item "-i"
513 Perform an incremental link (same as option \fB\-r\fR).
514 .IP \fB\-init=\fR\fIname\fR 4
515 .IX Item "-init=name"
516 When creating an ELF executable or shared object, call NAME when the
517 executable or shared object is loaded, by setting DT_INIT to the address
518 of the function. By default, the linker uses \f(CW\*(C`_init\*(C'\fR as the
519 function to call.
520 .IP "\fB\-l\fR \fInamespec\fR" 4
521 .IX Item "-l namespec"
522 .PD 0
523 .IP \fB\-\-library=\fR\fInamespec\fR 4
524 .IX Item "--library=namespec"
525 .PD
526 Add the archive or object file specified by \fInamespec\fR to the
527 list of files to link. This option may be used any number of times.
528 If \fInamespec\fR is of the form \fI:filename\fR, \fBld\fR
529 will search the library path for a file called \fIfilename\fR, otherwise it
530 will search the library path for a file called \fIlibnamespec.a\fR.
531 .Sp
532 On systems which support shared libraries, \fBld\fR may also search for
533 files other than \fIlibnamespec.a\fR. Specifically, on ELF
534 and SunOS systems, \fBld\fR will search a directory for a library
535 called \fIlibnamespec.so\fR before searching for one called
536 \&\fIlibnamespec.a\fR. (By convention, a \f(CW\*(C`.so\*(C'\fR extension
537 indicates a shared library.) Note that this behavior does not apply
538 to \fI:filename\fR, which always specifies a file called
539 \&\fIfilename\fR.
540 .Sp
541 The linker will search an archive only once, at the location where it is
542 specified on the command line. If the archive defines a symbol which
543 was undefined in some object which appeared before the archive on the
544 command line, the linker will include the appropriate file(s) from the
545 archive. However, an undefined symbol in an object appearing later on
546 the command line will not cause the linker to search the archive again.
547 .Sp
548 See the \fB\-(\fR option for a way to force the linker to search
549 archives multiple times.
550 .Sp
551 You may list the same archive multiple times on the command line.
552 .Sp
553 This type of archive searching is standard for Unix linkers. However,
554 if you are using \fBld\fR on AIX, note that it is different from the
555 behaviour of the AIX linker.
556 .IP "\fB\-L\fR \fIsearchdir\fR" 4
557 .IX Item "-L searchdir"
558 .PD 0
559 .IP \fB\-\-library\-path=\fR\fIsearchdir\fR 4
560 .IX Item "--library-path=searchdir"
561 .PD
562 Add path \fIsearchdir\fR to the list of paths that \fBld\fR will search
563 for archive libraries and \fBld\fR control scripts. You may use this
564 option any number of times. The directories are searched in the order
565 in which they are specified on the command line. Directories specified
566 on the command line are searched before the default directories. All
567 \&\fB\-L\fR options apply to all \fB\-l\fR options, regardless of the
568 order in which the options appear. \fB\-L\fR options do not affect
569 how \fBld\fR searches for a linker script unless \fB\-T\fR
570 option is specified.
571 .Sp
572 If \fIsearchdir\fR begins with \f(CW\*(C`=\*(C'\fR or \f(CW$SYSROOT\fR, then this
573 prefix will be replaced by the \fIsysroot prefix\fR, controlled by the
574 \&\fB\-\-sysroot\fR option, or specified when the linker is configured.
575 .Sp
576 The default set of paths searched (without being specified with
577 \&\fB\-L\fR) depends on which emulation mode \fBld\fR is using, and in
578 some cases also on how it was configured.
579 .Sp
580 The paths can also be specified in a link script with the
581 \&\f(CW\*(C`SEARCH_DIR\*(C'\fR command. Directories specified this way are searched
582 at the point in which the linker script appears in the command line.
583 .IP "\fB\-m\fR \fIemulation\fR" 4
584 .IX Item "-m emulation"
585 Emulate the \fIemulation\fR linker. You can list the available
586 emulations with the \fB\-\-verbose\fR or \fB\-V\fR options.
587 .Sp
588 If the \fB\-m\fR option is not used, the emulation is taken from the
589 \&\f(CW\*(C`LDEMULATION\*(C'\fR environment variable, if that is defined.
590 .Sp
591 Otherwise, the default emulation depends upon how the linker was
592 configured.
593 .IP \fB\-\-remap\-inputs=\fR\f(BIpattern\fR\fB=\fR\f(BIfilename\fR 4
594 .IX Item "--remap-inputs=pattern=filename"
595 .PD 0
596 .IP \fB\-\-remap\-inputs\-file=\fR\f(BIfile\fR 4
597 .IX Item "--remap-inputs-file=file"
598 .PD
599 These options allow the names of input files to be changed before the
600 linker attempts to open them. The option
601 \&\fB\-\-remap\-inputs=foo.o=bar.o\fR will cause any attempt to load a
602 file called \fIfoo.o\fR to instead try to load a file called
603 \&\fIbar.o\fR. Wildcard patterns are permitted in the first filename,
604 so \fB\-\-remap\-inputs=foo*.o=bar.o\fR will rename any input file that
605 matches \fIfoo*.o\fR to \fIbar.o\fR.
606 .Sp
607 An alternative form of the option
608 \&\fB\-\-remap\-inputs\-file=filename\fR allows the remappings to be read
609 from a file. Each line in the file can contain a single remapping.
610 Blank lines are ignored. Anything from a hash character (\fB#\fR) to
611 the end of a line is considered to be a comment and is also ignored.
612 The mapping pattern can be separated from the filename by whitespace
613 or an equals (\fB=\fR) character.
614 .Sp
615 The options can be specified multiple times. Their contents
616 accumulate. The remappings will be processed in the order in which
617 they occur on the command line, and if they come from a file, in the
618 order in which they occur in the file. If a match is made, no further
619 checking for that filename will be performed.
620 .Sp
621 If the replacement filename is \fI/dev/null\fR or just \fINUL\fR
622 then the remapping will actually cause the input file to be ignored.
623 This can be a convenient way to experiment with removing input files
624 from a complicated build environment.
625 .Sp
626 Note that this option is position dependent and only affects filenames
627 that come after it on the command line. Thus:
628 .Sp
629 .Vb 1
630 \& ld foo.o \-\-remap\-inputs=foo.o=bar.o
631 .Ve
632 .Sp
633 Will have no effect, whereas:
634 .Sp
635 .Vb 1
636 \& ld \-\-remap\-inputs=foo.o=bar.o foo.o
637 .Ve
638 .Sp
639 Will rename the input file \fIfoo.o\fR to \fIbar.o\fR.
640 .Sp
641 Note \- these options also affect files referenced by \fIINPUT\fR
642 statements in linker scripts. But since linker scripts are processed
643 after the entire command line is read, the position of the remap
644 options on the command line is not significant.
645 .Sp
646 If the \fBverbose\fR option is enabled then any mappings that match
647 will be reported, although again the \fBverbose\fR option needs to
648 be enabled on the command line \fIbefore\fR the remaped filenames
649 appear.
650 .Sp
651 If the \fB\-Map\fR or \fB\-\-print\-map\fR options are enabled then
652 the remapping list will be included in the map output.
653 .IP \fB\-M\fR 4
654 .IX Item "-M"
655 .PD 0
656 .IP \fB\-\-print\-map\fR 4
657 .IX Item "--print-map"
658 .PD
659 Print a link map to the standard output. A link map provides
660 information about the link, including the following:
661 .RS 4
662 .IP \(bu 4
663 Where object files are mapped into memory.
664 .IP \(bu 4
665 How common symbols are allocated.
666 .IP \(bu 4
667 All archive members included in the link, with a mention of the symbol
668 which caused the archive member to be brought in.
669 .IP \(bu 4
670 The values assigned to symbols.
671 .Sp
672 Note \- symbols whose values are computed by an expression which
673 involves a reference to a previous value of the same symbol may not
674 have correct result displayed in the link map. This is because the
675 linker discards intermediate results and only retains the final value
676 of an expression. Under such circumstances the linker will display
677 the final value enclosed by square brackets. Thus for example a
678 linker script containing:
679 .Sp
680 .Vb 3
681 \& foo = 1
682 \& foo = foo * 4
683 \& foo = foo + 8
684 .Ve
685 .Sp
686 will produce the following output in the link map if the \fB\-M\fR
687 option is used:
688 .Sp
689 .Vb 3
690 \& 0x00000001 foo = 0x1
691 \& [0x0000000c] foo = (foo * 0x4)
692 \& [0x0000000c] foo = (foo + 0x8)
693 .Ve
694 .Sp
695 See \fBExpressions\fR for more information about expressions in linker
696 scripts.
697 .IP \(bu 4
698 How GNU properties are merged.
699 .Sp
700 When the linker merges input .note.gnu.property sections into one output
701 \&.note.gnu.property section, some properties are removed or updated.
702 These actions are reported in the link map. For example:
703 .Sp
704 .Vb 1
705 \& Removed property 0xc0000002 to merge foo.o (0x1) and bar.o (not found)
706 .Ve
707 .Sp
708 This indicates that property 0xc0000002 is removed from output when
709 merging properties in \fIfoo.o\fR, whose property 0xc0000002 value
710 is 0x1, and \fIbar.o\fR, which doesn\*(Aqt have property 0xc0000002.
711 .Sp
712 .Vb 1
713 \& Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1)
714 .Ve
715 .Sp
716 This indicates that property 0xc0010001 value is updated to 0x1 in output
717 when merging properties in \fIfoo.o\fR, whose 0xc0010001 property value
718 is 0x1, and \fIbar.o\fR, whose 0xc0010001 property value is 0x1.
719 .IP \(bu 4
720 On some ELF targets, a list of fixups inserted by \fB\-\-relax\fR
721 .Sp
722 .Vb 1
723 \& foo.o: Adjusting branch at 0x00000008 towards "far" in section .text
724 .Ve
725 .Sp
726 This indicates that the branch at 0x00000008 in foo.o, targeting
727 the symbol "far" in section .text, has been replaced by a trampoline.
728 .RE
729 .RS 4
730 .RE
731 .IP \fB\-\-print\-map\-discarded\fR 4
732 .IX Item "--print-map-discarded"
733 .PD 0
734 .IP \fB\-\-no\-print\-map\-discarded\fR 4
735 .IX Item "--no-print-map-discarded"
736 .PD
737 Print (or do not print) the list of discarded and garbage collected sections
738 in the link map. Enabled by default.
739 .IP \fB\-\-print\-map\-locals\fR 4
740 .IX Item "--print-map-locals"
741 .PD 0
742 .IP \fB\-\-no\-print\-map\-locals\fR 4
743 .IX Item "--no-print-map-locals"
744 .PD
745 Print (or do not print) local symbols in the link map. Local symbols
746 will have the text \fB(local)\fR printed before their name, and will
747 be listed after all of the global symbols in a given section.
748 Temporary local symbols (typically those that start with \fB.L\fR)
749 will not be included in the output. Disabled by default.
750 .IP \fB\-n\fR 4
751 .IX Item "-n"
752 .PD 0
753 .IP \fB\-\-nmagic\fR 4
754 .IX Item "--nmagic"
755 .PD
756 Turn off page alignment of sections, and disable linking against shared
757 libraries. If the output format supports Unix style magic numbers,
758 mark the output as \f(CW\*(C`NMAGIC\*(C'\fR.
759 .IP \fB\-N\fR 4
760 .IX Item "-N"
761 .PD 0
762 .IP \fB\-\-omagic\fR 4
763 .IX Item "--omagic"
764 .PD
765 Set the text and data sections to be readable and writable. Also, do
766 not page\-align the data segment, and disable linking against shared
767 libraries. If the output format supports Unix style magic numbers,
768 mark the output as \f(CW\*(C`OMAGIC\*(C'\fR. Note: Although a writable text section
769 is allowed for PE\-COFF targets, it does not conform to the format
770 specification published by Microsoft.
771 .IP \fB\-\-no\-omagic\fR 4
772 .IX Item "--no-omagic"
773 This option negates most of the effects of the \fB\-N\fR option. It
774 sets the text section to be read\-only, and forces the data segment to
775 be page\-aligned. Note \- this option does not enable linking against
776 shared libraries. Use \fB\-Bdynamic\fR for this.
777 .IP "\fB\-o\fR \fIoutput\fR" 4
778 .IX Item "-o output"
779 .PD 0
780 .IP \fB\-\-output=\fR\fIoutput\fR 4
781 .IX Item "--output=output"
782 .PD
783 Use \fIoutput\fR as the name for the program produced by \fBld\fR; if this
784 option is not specified, the name \fIa.out\fR is used by default. The
785 script command \f(CW\*(C`OUTPUT\*(C'\fR can also specify the output file name.
786 .Sp
787 Note \- the linker will delete the output file before it starts to
788 write to it. It will do this even if it turns out that the link
789 cannot be completed due to errors.
790 .Sp
791 Note \- the linker will check to make sure that the output file name
792 does not match the name of any of the input files, but that is all.
793 In particular it will not complain if the output file might overwrite
794 a source file or some other important file. Therefore in build
795 systems it is recommended to use the \fB\-o\fR option as the last
796 option on the linker command line. For example consider:
797 .Sp
798 .Vb 2
799 \& ld \-o $(EXE) $(OBJS)
800 \& ld $(OBJS) \-o $(EXE)
801 .Ve
802 .Sp
803 If the \fBEXE\fR variable is not defined for some reason, the first
804 version of the linker command could end up deleting one of the object
805 files (the first one in the \fBOBJS\fR list) whereas the second
806 version of the linker command will generate an error message and not
807 delete anything.
808 .IP \fB\-\-dependency\-file=\fR\fIdepfile\fR 4
809 .IX Item "--dependency-file=depfile"
810 Write a \fIdependency file\fR to \fIdepfile\fR. This file contains a rule
811 suitable for \f(CW\*(C`make\*(C'\fR describing the output file and all the input files
812 that were read to produce it. The output is similar to the compiler\*(Aqs
813 output with \fB\-M \-MP\fR. Note that there is no option like the compiler\*(Aqs \fB\-MM\fR,
814 to exclude "system files" (which is not a well\-specified concept in the
815 linker, unlike "system headers" in the compiler). So the output from
816 \&\fB\-\-dependency\-file\fR is always specific to the exact state of the
817 installation where it was produced, and should not be copied into
818 distributed makefiles without careful editing.
819 .IP "\fB\-O\fR \fIlevel\fR" 4
820 .IX Item "-O level"
821 If \fIlevel\fR is a numeric values greater than zero \fBld\fR optimizes
822 the output. This might take significantly longer and therefore probably
823 should only be enabled for the final binary. At the moment this
824 option only affects ELF shared library generation. Future releases of
825 the linker may make more use of this option. Also currently there is
826 no difference in the linker\*(Aqs behaviour for different non\-zero values
827 of this option. Again this may change with future releases.
828 .Sp
829 If \fIlevel\fR is zero or the string \fBfast\fR then \fBld\fR
830 instead skips operations that are optional, resulting in a faster link
831 but producing slower, larger binaries. Currently the only operation
832 that is skipped is the combining of mergeable sections, but this may
833 change in the future.
834 .Sp
835 If \fIlevel\fR is the string \fBdefault\fR or just the \fB\-\fR
836 character then the linker\*(Aqs default behaviour of neither optimizing
837 nor skipping operations is selected.
838 .IP "\fB\-plugin\fR \fIname\fR" 4
839 .IX Item "-plugin name"
840 Involve a plugin in the linking process. The \fIname\fR parameter is
841 the absolute filename of the plugin. Usually this parameter is
842 automatically added by the complier, when using link time
843 optimization, but users can also add their own plugins if they so
844 wish.
845 .Sp
846 Note that the location of the compiler originated plugins is different
847 from the place where the \fBar\fR, \fBnm\fR and
848 \&\fBranlib\fR programs search for their plugins. In order for
849 those commands to make use of a compiler based plugin it must first be
850 copied into the \fI${libdir}/bfd\-plugins\fR directory. All gcc
851 based linker plugins are backward compatible, so it is sufficient to
852 just copy in the newest one.
853 .IP \fB\-\-push\-state\fR 4
854 .IX Item "--push-state"
855 The \fB\-\-push\-state\fR allows one to preserve the current state of the
856 flags which govern the input file handling so that they can all be
857 restored with one corresponding \fB\-\-pop\-state\fR option.
858 .Sp
859 The option which are covered are: \fB\-Bdynamic\fR, \fB\-Bstatic\fR,
860 \&\fB\-dn\fR, \fB\-dy\fR, \fB\-call_shared\fR, \fB\-non_shared\fR,
861 \&\fB\-static\fR, \fB\-N\fR, \fB\-n\fR, \fB\-\-whole\-archive\fR,
862 \&\fB\-\-no\-whole\-archive\fR, \fB\-\-link\-mapless\fR,
863 \&\fB\-\-no\-link\-mapless\fR, \fB\-r\fR, \fB\-Ur\fR,
864 \&\fB\-\-copy\-dt\-needed\-entries\fR, \fB\-\-no\-copy\-dt\-needed\-entries\fR,
865 \&\fB\-\-as\-needed\fR, \fB\-\-no\-as\-needed\fR, and \fB\-a\fR.
866 .Sp
867 One target for this option are specifications for \fIpkg\-config\fR. When
868 used with the \fB\-\-libs\fR option all possibly needed libraries are
869 listed and then possibly linked with all the time. It is better to return
870 something as follows:
871 .Sp
872 .Vb 1
873 \& \-Wl,\-\-push\-state,\-\-as\-needed \-libone \-libtwo \-Wl,\-\-pop\-state
874 .Ve
875 .IP \fB\-\-pop\-state\fR 4
876 .IX Item "--pop-state"
877 Undoes the effect of \fB\-\-push\-state\fR, restores the previous values
878 of the flags governing input file handling.
879 .IP \fB\-q\fR 4
880 .IX Item "-q"
881 .PD 0
882 .IP \fB\-\-emit\-relocs\fR 4
883 .IX Item "--emit-relocs"
884 .PD
885 Leave relocation sections and contents in fully linked executables.
886 Post link analysis and optimization tools may need this information in
887 order to perform correct modifications of executables. This results
888 in larger executables.
889 .Sp
890 This option is currently only supported on ELF platforms.
891 .IP \fB\-\-force\-dynamic\fR 4
892 .IX Item "--force-dynamic"
893 Force the output file to have dynamic sections. This option is specific
894 to VxWorks targets.
895 .IP \fB\-r\fR 4
896 .IX Item "-r"
897 .PD 0
898 .IP \fB\-\-relocatable\fR 4
899 .IX Item "--relocatable"
900 .PD
901 Generate relocatable output\-\-\-i.e., generate an output file that can in
902 turn serve as input to \fBld\fR. This is often called \fIpartial
903 linking\fR. As a side effect, in environments that support standard Unix
904 magic numbers, this option also sets the output file\*(Aqs magic number to
905 \&\f(CW\*(C`OMAGIC\*(C'\fR.
906 If this option is not specified, an absolute file is produced. When
907 linking C++ programs, this option \fIwill not\fR resolve references to
908 constructors; to do that, use \fB\-Ur\fR.
909 .Sp
910 When an input file does not have the same format as the output file,
911 partial linking is only supported if that input file does not contain any
912 relocations. Different output formats can have further restrictions; for
913 example some \f(CW\*(C`a.out\*(C'\fR\-based formats do not support partial linking
914 with input files in other formats at all.
915 .Sp
916 When the relocatable output contains both contents which require
917 link\-time optimization (LTO) and contents which don\*(Aqt require LTO,
918 a .gnu_object_only section will be created to contain a relocatable
919 object file, as if \fB\-r\fR is applied to all relocatable inputs
920 which don\*(Aqt require LTO. When processing a relocatable input with
921 a .gnu_object_only section, the linker will extract the .gnu_object_only
922 section as a separate input.
923 .Sp
924 Note that since \fB\-r\fR groups some sections from different input files
925 together, there may be negative impacts on code size and locality in
926 final executable or shared library.
927 .Sp
928 This option does the same thing as \fB\-i\fR.
929 .IP "\fB\-R\fR \fIfilename\fR" 4
930 .IX Item "-R filename"
931 .PD 0
932 .IP \fB\-\-just\-symbols=\fR\fIfilename\fR 4
933 .IX Item "--just-symbols=filename"
934 .PD
935 Read symbol names and their addresses from \fIfilename\fR, but do not
936 relocate it or include it in the output. This allows your output file
937 to refer symbolically to absolute locations of memory defined in other
938 programs. You may use this option more than once.
939 .Sp
940 For compatibility with other ELF linkers, if the \fB\-R\fR option is
941 followed by a directory name, rather than a file name, it is treated as
942 the \fB\-rpath\fR option.
943 .IP \fB\-\-rosegment\fR 4
944 .IX Item "--rosegment"
945 .PD 0
946 .IP \fB\-\-no\-rosegment\fR 4
947 .IX Item "--no-rosegment"
948 .PD
949 Attempt to ensure that only a single read\-only, non\-code segment is
950 created. Only useful when used in conjunction with the \fB\-z
951 separate\-code\fR option. The resulting binaries should be smaller than
952 if \fB\-z separate\-code\fR is used on its own. Without this option,
953 or if \fB\-\-no\-rosegment\fR is specified, the \fB\-z separate\-code\fR
954 option will create two read\-only segments, one before the code segment
955 and one after it.
956 .Sp
957 The name of the options are misleading, but they have been chosen in
958 order for the linker to be compatible with the LLD and GOLD linkers.
959 .Sp
960 Thse options are only supported by ELF targets.
961 .IP \fB\-s\fR 4
962 .IX Item "-s"
963 .PD 0
964 .IP \fB\-\-strip\-all\fR 4
965 .IX Item "--strip-all"
966 .PD
967 Omit all symbol information from the output file.
968 .IP \fB\-S\fR 4
969 .IX Item "-S"
970 .PD 0
971 .IP \fB\-\-strip\-debug\fR 4
972 .IX Item "--strip-debug"
973 .PD
974 Omit debugger symbol information (but not all symbols) from the output file.
975 .IP \fB\-\-strip\-discarded\fR 4
976 .IX Item "--strip-discarded"
977 .PD 0
978 .IP \fB\-\-no\-strip\-discarded\fR 4
979 .IX Item "--no-strip-discarded"
980 .PD
981 Omit (or do not omit) global symbols defined in discarded sections.
982 Enabled by default.
983 .IP \fB\-plugin\-save\-temps\fR 4
984 .IX Item "-plugin-save-temps"
985 Store the plugin "temporary" intermediate files permanently.
986 .IP \fB\-t\fR 4
987 .IX Item "-t"
988 .PD 0
989 .IP \fB\-\-trace\fR 4
990 .IX Item "--trace"
991 .PD
992 Print the names of the input files as \fBld\fR processes them. If
993 \&\fB\-t\fR is given twice then members within archives are also printed.
994 \&\fB\-t\fR output is useful to generate a list of all the object files
995 and scripts involved in linking, for example, when packaging files for
996 a linker bug report.
997 .IP "\fB\-T\fR \fIscriptfile\fR" 4
998 .IX Item "-T scriptfile"
999 .PD 0
1000 .IP \fB\-\-script=\fR\fIscriptfile\fR 4
1001 .IX Item "--script=scriptfile"
1002 .PD
1003 Use \fIscriptfile\fR as the linker script. This script replaces
1004 \&\fBld\fR\*(Aqs default linker script (rather than adding to it),
1005 unless the script contains \f(CW\*(C`INSERT\*(C'\fR, so \fIcommandfile\fR must
1006 specify everything necessary to describe the output file.
1007 .Sp
1008 If \fIscriptfile\fR does not exist in the current directory, \f(CW\*(C`ld\*(C'\fR
1009 looks for it in the directories specified by any preceding \fB\-L\fR
1010 options.
1011 .Sp
1012 Command line options that appear before the \fB\-T\fR option can
1013 affect the script, but command line options that appear after it do
1014 not.
1015 .Sp
1016 Multiple \fB\-T\fR options will accumulate if they are augmenting the
1017 current script, otherwise the last, non\-augmenting, \fB\-T\fR option
1018 will be used.
1019 .Sp
1020 There are other ways of specifying linker scripts. See
1021 .IP "\fB\-dT\fR \fIscriptfile\fR" 4
1022 .IX Item "-dT scriptfile"
1023 .PD 0
1024 .IP \fB\-\-default\-script=\fR\fIscriptfile\fR 4
1025 .IX Item "--default-script=scriptfile"
1026 .PD
1027 Use \fIscriptfile\fR as the default linker script.
1028 .Sp
1029 This option is similar to the \fB\-\-script\fR option except that
1030 processing of the script is delayed until after the rest of the
1031 command line has been processed. This allows options placed after the
1032 \&\fB\-\-default\-script\fR option on the command line to affect the
1033 behaviour of the linker script, which can be important when the linker
1034 command line cannot be directly controlled by the user. (eg because
1035 the command line is being constructed by another tool, such as
1036 \&\fBgcc\fR).
1037 .IP "\fB\-u\fR \fIsymbol\fR" 4
1038 .IX Item "-u symbol"
1039 .PD 0
1040 .IP \fB\-\-undefined=\fR\fIsymbol\fR 4
1041 .IX Item "--undefined=symbol"
1042 .PD
1043 Force \fIsymbol\fR to be entered in the output file as an undefined
1044 symbol. Doing this may, for example, trigger linking of additional
1045 modules from standard libraries. \fB\-u\fR may be repeated with
1046 different option arguments to enter additional undefined symbols. This
1047 option is equivalent to the \f(CW\*(C`EXTERN\*(C'\fR linker script command.
1048 .Sp
1049 If this option is being used to force additional modules to be pulled
1050 into the link, and if it is an error for the symbol to remain
1051 undefined, then the option \fB\-\-require\-defined\fR should be used
1052 instead.
1053 .IP \fB\-\-require\-defined=\fR\fIsymbol\fR 4
1054 .IX Item "--require-defined=symbol"
1055 Require that \fIsymbol\fR is defined in the output file. This option
1056 is the same as option \fB\-\-undefined\fR except that if \fIsymbol\fR
1057 is not defined in the output file then the linker will issue an error
1058 and exit. The same effect can be achieved in a linker script by using
1059 \&\f(CW\*(C`EXTERN\*(C'\fR, \f(CW\*(C`ASSERT\*(C'\fR and \f(CW\*(C`DEFINED\*(C'\fR together. This option
1060 can be used multiple times to require additional symbols.
1061 .IP \fB\-Ur\fR 4
1062 .IX Item "-Ur"
1063 For programs that do not use constructors or destructors, or for ELF
1064 based systems this option is equivalent to \fB\-r\fR: it generates
1065 relocatable output\-\-\-i.e., an output file that can in turn serve as
1066 input to \fBld\fR. For other binaries however the \fB\-Ur\fR
1067 option is similar to \fB\-r\fR but it also resolves references to
1068 constructors and destructors.
1069 .Sp
1070 For those systems where \fB\-r\fR and \fB\-Ur\fR behave
1071 differently, it does not work to use \fB\-Ur\fR on files that were
1072 themselves linked with \fB\-Ur\fR; once the constructor table has
1073 been built, it cannot be added to. Use \fB\-Ur\fR only for the last
1074 partial link, and \fB\-r\fR for the others.
1075 .IP \fB\-\-orphan\-handling=\fR\fIMODE\fR 4
1076 .IX Item "--orphan-handling=MODE"
1077 Control how orphan sections are handled. An orphan section is one not
1078 specifically mentioned in a linker script.
1079 .Sp
1080 \&\fIMODE\fR can have any of the following values:
1081 .RS 4
1082 .ie n .IP """place""" 4
1083 .el .IP \f(CWplace\fR 4
1084 .IX Item "place"
1085 Orphan sections are placed into a suitable output section following
1086 the strategy described in \fBOrphan Sections\fR. The option
1087 \&\fB\-\-unique\fR also affects how sections are placed.
1088 .ie n .IP """discard""" 4
1089 .el .IP \f(CWdiscard\fR 4
1090 .IX Item "discard"
1091 All orphan sections are discarded, by placing them in the
1092 \&\fB/DISCARD/\fR section.
1093 .ie n .IP """warn""" 4
1094 .el .IP \f(CWwarn\fR 4
1095 .IX Item "warn"
1096 The linker will place the orphan section as for \f(CW\*(C`place\*(C'\fR and also
1097 issue a warning.
1098 .ie n .IP """error""" 4
1099 .el .IP \f(CWerror\fR 4
1100 .IX Item "error"
1101 The linker will exit with an error if any orphan section is found.
1102 .RE
1103 .RS 4
1104 .Sp
1105 The default if \fB\-\-orphan\-handling\fR is not given is \f(CW\*(C`place\*(C'\fR.
1106 .RE
1107 .IP \fB\-\-unique[=\fR\fISECTION\fR\fB]\fR 4
1108 .IX Item "--unique[=SECTION]"
1109 Creates a separate output section for every input section matching
1110 \&\fISECTION\fR, or if the optional wildcard \fISECTION\fR argument is
1111 missing, for every orphan input section. An orphan section is one not
1112 specifically mentioned in a linker script. You may use this option
1113 multiple times on the command line; It prevents the normal merging of
1114 input sections with the same name, overriding output section assignments
1115 in a linker script.
1116 .IP \fB\-v\fR 4
1117 .IX Item "-v"
1118 .PD 0
1119 .IP \fB\-\-version\fR 4
1120 .IX Item "--version"
1121 .IP \fB\-V\fR 4
1122 .IX Item "-V"
1123 .PD
1124 Display the version number for \fBld\fR. The \fB\-V\fR option also
1125 lists the supported emulations. See also the description of the
1126 \&\fB\-\-enable\-linker\-version\fR in \fBOptions,,Command\-line Options\fR
1127 which can be used to insert the linker version string into a binary.
1128 .IP \fB\-x\fR 4
1129 .IX Item "-x"
1130 .PD 0
1131 .IP \fB\-\-discard\-all\fR 4
1132 .IX Item "--discard-all"
1133 .PD
1134 Delete all local symbols.
1135 .IP \fB\-X\fR 4
1136 .IX Item "-X"
1137 .PD 0
1138 .IP \fB\-\-discard\-locals\fR 4
1139 .IX Item "--discard-locals"
1140 .PD
1141 Delete all temporary local symbols. (These symbols start with
1142 system\-specific local label prefixes, typically \fB.L\fR for ELF systems
1143 or \fBL\fR for traditional a.out systems.)
1144 .IP "\fB\-y\fR \fIsymbol\fR" 4
1145 .IX Item "-y symbol"
1146 .PD 0
1147 .IP \fB\-\-trace\-symbol=\fR\fIsymbol\fR 4
1148 .IX Item "--trace-symbol=symbol"
1149 .PD
1150 Print the name of each linked file in which \fIsymbol\fR appears. This
1151 option may be given any number of times. On many systems it is necessary
1152 to prepend an underscore.
1153 .Sp
1154 This option is useful when you have an undefined symbol in your link but
1155 don\*(Aqt know where the reference is coming from.
1156 .IP "\fB\-Y\fR \fIpath\fR" 4
1157 .IX Item "-Y path"
1158 Add \fIpath\fR to the default library search path. This option exists
1159 for Solaris compatibility.
1160 .IP "\fB\-z\fR \fIkeyword\fR" 4
1161 .IX Item "-z keyword"
1162 The recognized keywords are:
1163 .RS 4
1164 .IP \fBcall\-nop=prefix\-addr\fR 4
1165 .IX Item "call-nop=prefix-addr"
1166 .PD 0
1167 .IP \fBcall\-nop=suffix\-nop\fR 4
1168 .IX Item "call-nop=suffix-nop"
1169 .IP \fBcall\-nop=prefix\-\fR\fIbyte\fR 4
1170 .IX Item "call-nop=prefix-byte"
1171 .IP \fBcall\-nop=suffix\-\fR\fIbyte\fR 4
1172 .IX Item "call-nop=suffix-byte"
1173 .PD
1174 Specify the 1\-byte \f(CW\*(C`NOP\*(C'\fR padding when transforming indirect call
1175 to a locally defined function, foo, via its GOT slot.
1176 \&\fBcall\-nop=prefix\-addr\fR generates \f(CW\*(C`0x67 call foo\*(C'\fR.
1177 \&\fBcall\-nop=suffix\-nop\fR generates \f(CW\*(C`call foo 0x90\*(C'\fR.
1178 \&\fBcall\-nop=prefix\-\fR\fIbyte\fR generates \f(CW\*(C`\fR\f(CIbyte\fR\f(CW call foo\*(C'\fR.
1179 \&\fBcall\-nop=suffix\-\fR\fIbyte\fR generates \f(CW\*(C`call foo \fR\f(CIbyte\fR\f(CW\*(C'\fR.
1180 Supported for i386 and x86_64.
1181 .IP \fBcet\-report=none\fR 4
1182 .IX Item "cet-report=none"
1183 .PD 0
1184 .IP \fBcet\-report=warning\fR 4
1185 .IX Item "cet-report=warning"
1186 .IP \fBcet\-report=error\fR 4
1187 .IX Item "cet-report=error"
1188 .PD
1189 Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_IBT and
1190 GNU_PROPERTY_X86_FEATURE_1_SHSTK properties in input .note.gnu.property
1191 section. \fBcet\-report=none\fR, which is the default, will make the
1192 linker not report missing properties in input files.
1193 \&\fBcet\-report=warning\fR will make the linker issue a warning for
1194 missing properties in input files. \fBcet\-report=error\fR will make
1195 the linker issue an error for missing properties in input files.
1196 Note that \fBibt\fR will turn off the missing
1197 GNU_PROPERTY_X86_FEATURE_1_IBT property report and \fBshstk\fR will
1198 turn off the missing GNU_PROPERTY_X86_FEATURE_1_SHSTK property report.
1199 Supported for Linux/i386 and Linux/x86_64.
1200 .IP \fBcombreloc\fR 4
1201 .IX Item "combreloc"
1202 .PD 0
1203 .IP \fBnocombreloc\fR 4
1204 .IX Item "nocombreloc"
1205 .PD
1206 Combine multiple dynamic relocation sections and sort to improve
1207 dynamic symbol lookup caching. Do not do this if \fBnocombreloc\fR.
1208 .IP \fBcommon\fR 4
1209 .IX Item "common"
1210 .PD 0
1211 .IP \fBnocommon\fR 4
1212 .IX Item "nocommon"
1213 .PD
1214 Generate common symbols with STT_COMMON type during a relocatable
1215 link. Use STT_OBJECT type if \fBnocommon\fR.
1216 .IP \fBcommon\-page\-size=\fR\fIvalue\fR 4
1217 .IX Item "common-page-size=value"
1218 Set the page size most commonly used to \fIvalue\fR. Memory image
1219 layout will be optimized to minimize memory pages if the system is
1220 using pages of this size.
1221 .IP \fBdefs\fR 4
1222 .IX Item "defs"
1223 Report unresolved symbol references from regular object files. This
1224 is done even if the linker is creating a non\-symbolic shared library.
1225 This option is the inverse of \fB\-z undefs\fR.
1226 .IP \fBdynamic\-undefined\-weak\fR 4
1227 .IX Item "dynamic-undefined-weak"
1228 .PD 0
1229 .IP \fBnodynamic\-undefined\-weak\fR 4
1230 .IX Item "nodynamic-undefined-weak"
1231 .PD
1232 Make undefined weak symbols dynamic when building a dynamic object,
1233 if they are referenced from a regular object file and not forced local
1234 by symbol visibility or versioning. Do not make them dynamic if
1235 \&\fBnodynamic\-undefined\-weak\fR. If neither option is given, a target
1236 may default to either option being in force, or make some other
1237 selection of undefined weak symbols dynamic. Not all targets support
1238 these options.
1239 .IP \fBexecstack\fR 4
1240 .IX Item "execstack"
1241 Marks the object as requiring executable stack.
1242 .IP \fBglobal\fR 4
1243 .IX Item "global"
1244 This option is only meaningful when building a shared object. It makes
1245 the symbols defined by this shared object available for symbol resolution
1246 of subsequently loaded libraries.
1247 .IP \fBglobalaudit\fR 4
1248 .IX Item "globalaudit"
1249 This option is only meaningful when building a dynamic executable.
1250 This option marks the executable as requiring global auditing by
1251 setting the \f(CW\*(C`DF_1_GLOBAUDIT\*(C'\fR bit in the \f(CW\*(C`DT_FLAGS_1\*(C'\fR dynamic
1252 tag. Global auditing requires that any auditing library defined via
1253 the \fB\-\-depaudit\fR or \fB\-P\fR command\-line options be run for
1254 all dynamic objects loaded by the application.
1255 .IP \fBibtplt\fR 4
1256 .IX Item "ibtplt"
1257 Generate Intel Indirect Branch Tracking (IBT) enabled PLT entries.
1258 Supported for Linux/i386 and Linux/x86_64.
1259 .IP \fBibt\fR 4
1260 .IX Item "ibt"
1261 Generate GNU_PROPERTY_X86_FEATURE_1_IBT in .note.gnu.property section
1262 to indicate compatibility with IBT. This also implies \fBibtplt\fR.
1263 Supported for Linux/i386 and Linux/x86_64.
1264 .IP \fBindirect\-extern\-access\fR 4
1265 .IX Item "indirect-extern-access"
1266 .PD 0
1267 .IP \fBnoindirect\-extern\-access\fR 4
1268 .IX Item "noindirect-extern-access"
1269 .PD
1270 Generate GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS in
1271 \&.note.gnu.property section to indicate that object file requires
1272 canonical function pointers and cannot be used with copy relocation.
1273 This option also implies \fBnoextern\-protected\-data\fR and
1274 \&\fBnocopyreloc\fR. Supported for i386 and x86\-64.
1275 .Sp
1276 \&\fBnoindirect\-extern\-access\fR removes
1277 GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS from .note.gnu.property
1278 section.
1279 .IP \fBinitfirst\fR 4
1280 .IX Item "initfirst"
1281 This option is only meaningful when building a shared object.
1282 It marks the object so that its runtime initialization will occur
1283 before the runtime initialization of any other objects brought into
1284 the process at the same time. Similarly the runtime finalization of
1285 the object will occur after the runtime finalization of any other
1286 objects.
1287 .IP \fBinterpose\fR 4
1288 .IX Item "interpose"
1289 Specify that the dynamic loader should modify its symbol search order
1290 so that symbols in this shared library interpose all other shared
1291 libraries not so marked.
1292 .IP \fBunique\fR 4
1293 .IX Item "unique"
1294 .PD 0
1295 .IP \fBnounique\fR 4
1296 .IX Item "nounique"
1297 .PD
1298 When generating a shared library or other dynamically loadable ELF
1299 object mark it as one that should (by default) only ever be loaded once,
1300 and only in the main namespace (when using \f(CW\*(C`dlmopen\*(C'\fR). This is
1301 primarily used to mark fundamental libraries such as libc, libpthread et
1302 al which do not usually function correctly unless they are the sole instances
1303 of themselves. This behaviour can be overridden by the \f(CW\*(C`dlmopen\*(C'\fR caller
1304 and does not apply to certain loading mechanisms (such as audit libraries).
1305 .IP \fBlam\-u48\fR 4
1306 .IX Item "lam-u48"
1307 Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U48 in .note.gnu.property section
1308 to indicate compatibility with Intel LAM_U48. Supported for Linux/x86_64.
1309 .IP \fBlam\-u57\fR 4
1310 .IX Item "lam-u57"
1311 Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U57 in .note.gnu.property section
1312 to indicate compatibility with Intel LAM_U57. Supported for Linux/x86_64.
1313 .IP \fBlam\-u48\-report=none\fR 4
1314 .IX Item "lam-u48-report=none"
1315 .PD 0
1316 .IP \fBlam\-u48\-report=warning\fR 4
1317 .IX Item "lam-u48-report=warning"
1318 .IP \fBlam\-u48\-report=error\fR 4
1319 .IX Item "lam-u48-report=error"
1320 .PD
1321 Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U48
1322 property in input .note.gnu.property section.
1323 \&\fBlam\-u48\-report=none\fR, which is the default, will make the
1324 linker not report missing properties in input files.
1325 \&\fBlam\-u48\-report=warning\fR will make the linker issue a warning for
1326 missing properties in input files. \fBlam\-u48\-report=error\fR will
1327 make the linker issue an error for missing properties in input files.
1328 Supported for Linux/x86_64.
1329 .IP \fBlam\-u57\-report=none\fR 4
1330 .IX Item "lam-u57-report=none"
1331 .PD 0
1332 .IP \fBlam\-u57\-report=warning\fR 4
1333 .IX Item "lam-u57-report=warning"
1334 .IP \fBlam\-u57\-report=error\fR 4
1335 .IX Item "lam-u57-report=error"
1336 .PD
1337 Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U57
1338 property in input .note.gnu.property section.
1339 \&\fBlam\-u57\-report=none\fR, which is the default, will make the
1340 linker not report missing properties in input files.
1341 \&\fBlam\-u57\-report=warning\fR will make the linker issue a warning for
1342 missing properties in input files. \fBlam\-u57\-report=error\fR will
1343 make the linker issue an error for missing properties in input files.
1344 Supported for Linux/x86_64.
1345 .IP \fBlam\-report=none\fR 4
1346 .IX Item "lam-report=none"
1347 .PD 0
1348 .IP \fBlam\-report=warning\fR 4
1349 .IX Item "lam-report=warning"
1350 .IP \fBlam\-report=error\fR 4
1351 .IX Item "lam-report=error"
1352 .PD
1353 Specify how to report the missing GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and
1354 GNU_PROPERTY_X86_FEATURE_1_LAM_U57 properties in input .note.gnu.property
1355 section. \fBlam\-report=none\fR, which is the default, will make the
1356 linker not report missing properties in input files.
1357 \&\fBlam\-report=warning\fR will make the linker issue a warning for
1358 missing properties in input files. \fBlam\-report=error\fR will make
1359 the linker issue an error for missing properties in input files.
1360 Supported for Linux/x86_64.
1361 .IP \fBlazy\fR 4
1362 .IX Item "lazy"
1363 When generating an executable or shared library, mark it to tell the
1364 dynamic linker to defer function call resolution to the point when
1365 the function is called (lazy binding), rather than at load time.
1366 Lazy binding is the default.
1367 .IP \fBloadfltr\fR 4
1368 .IX Item "loadfltr"
1369 Specify that the object\*(Aqs filters be processed immediately at runtime.
1370 .IP \fBmax\-page\-size=\fR\fIvalue\fR 4
1371 .IX Item "max-page-size=value"
1372 Set the maximum memory page size supported to \fIvalue\fR.
1373 .IP \fBmark\-plt\fR 4
1374 .IX Item "mark-plt"
1375 .PD 0
1376 .IP \fBnomark\-plt\fR 4
1377 .IX Item "nomark-plt"
1378 .PD
1379 Mark PLT entries with dynamic tags, DT_X86_64_PLT, DT_X86_64_PLTSZ and
1380 DT_X86_64_PLTENT. Since this option stores a non\-zero value in the
1381 r_addend field of R_X86_64_JUMP_SLOT relocations, the resulting
1382 executables and shared libraries are incompatible with dynamic linkers,
1383 such as those in older versions of glibc without the change to ignore
1384 r_addend in R_X86_64_GLOB_DAT and R_X86_64_JUMP_SLOT relocations, which
1385 don\*(Aqt ignore the r_addend field of R_X86_64_JUMP_SLOT relocations.
1386 Supported for x86_64.
1387 .IP \fBmuldefs\fR 4
1388 .IX Item "muldefs"
1389 Allow multiple definitions.
1390 .IP \fBnocopyreloc\fR 4
1391 .IX Item "nocopyreloc"
1392 Disable linker generated .dynbss variables used in place of variables
1393 defined in shared libraries. May result in dynamic text relocations.
1394 .IP \fBnodefaultlib\fR 4
1395 .IX Item "nodefaultlib"
1396 Specify that the dynamic loader search for dependencies of this object
1397 should ignore any default library search paths.
1398 .IP \fBnodelete\fR 4
1399 .IX Item "nodelete"
1400 Specify that the object shouldn\*(Aqt be unloaded at runtime.
1401 .IP \fBnodlopen\fR 4
1402 .IX Item "nodlopen"
1403 Specify that the object is not available to \f(CW\*(C`dlopen\*(C'\fR.
1404 .IP \fBnodump\fR 4
1405 .IX Item "nodump"
1406 Specify that the object can not be dumped by \f(CW\*(C`dldump\*(C'\fR.
1407 .IP \fBnoexecstack\fR 4
1408 .IX Item "noexecstack"
1409 Marks the object as not requiring executable stack.
1410 .IP \fBnoextern\-protected\-data\fR 4
1411 .IX Item "noextern-protected-data"
1412 Don\*(Aqt treat protected data symbols as external when building a shared
1413 library. This option overrides the linker backend default. It can be
1414 used to work around incorrect relocations against protected data symbols
1415 generated by compiler. Updates on protected data symbols by another
1416 module aren\*(Aqt visible to the resulting shared library. Supported for
1417 i386 and x86\-64.
1418 .IP \fBnoreloc\-overflow\fR 4
1419 .IX Item "noreloc-overflow"
1420 Disable relocation overflow check. This can be used to disable
1421 relocation overflow check if there will be no dynamic relocation
1422 overflow at run\-time. Supported for x86_64.
1423 .IP \fBmemory\-seal\fR 4
1424 .IX Item "memory-seal"
1425 .PD 0
1426 .IP \fBnomemory\-seal\fR 4
1427 .IX Item "nomemory-seal"
1428 .PD
1429 Instruct the executable or shared library that the all PT_LOAD segments
1430 should be sealed to avoid further manipulation (such as changing the
1431 protection flags, the segment size, or remove the mapping).
1432 This is a security hardening that requires system support. This
1433 generates GNU_PROPERTY_MEMORY_SEAL in .note.gnu.property section
1434 .IP \fBnow\fR 4
1435 .IX Item "now"
1436 When generating an executable or shared library, mark it to tell the
1437 dynamic linker to resolve all symbols when the program is started, or
1438 when the shared library is loaded by dlopen, instead of deferring
1439 function call resolution to the point when the function is first
1440 called.
1441 .IP \fBorigin\fR 4
1442 .IX Item "origin"
1443 Specify that the object requires \fR\f(CB$ORIGIN\fR\fB\fR handling in paths.
1444 .IP \fBpack\-relative\-relocs\fR 4
1445 .IX Item "pack-relative-relocs"
1446 .PD 0
1447 .IP \fBnopack\-relative\-relocs\fR 4
1448 .IX Item "nopack-relative-relocs"
1449 .PD
1450 Generate compact relative relocation in position\-independent executable
1451 and shared library. It adds \f(CW\*(C`DT_RELR\*(C'\fR, \f(CW\*(C`DT_RELRSZ\*(C'\fR and
1452 \&\f(CW\*(C`DT_RELRENT\*(C'\fR entries to the dynamic section. It is ignored when
1453 building position\-dependent executable and relocatable output.
1454 \&\fBnopack\-relative\-relocs\fR is the default, which disables compact
1455 relative relocation. When linked against the GNU C Library, a
1456 GLIBC_ABI_DT_RELR symbol version dependency on the shared C Library is
1457 added to the output. Supported for i386 and x86\-64.
1458 .IP \fBrelro\fR 4
1459 .IX Item "relro"
1460 .PD 0
1461 .IP \fBnorelro\fR 4
1462 .IX Item "norelro"
1463 .PD
1464 Create an ELF \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object. This
1465 specifies a memory segment that should be made read\-only after
1466 relocation, if supported. Specifying \fBcommon\-page\-size\fR smaller
1467 than the system page size will render this protection ineffective.
1468 Don\*(Aqt create an ELF \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment if \fBnorelro\fR.
1469 .IP \fBreport\-relative\-reloc\fR 4
1470 .IX Item "report-relative-reloc"
1471 Report dynamic relative relocations generated by linker. Supported for
1472 Linux/i386 and Linux/x86_64.
1473 .IP \fBsectionheader\fR 4
1474 .IX Item "sectionheader"
1475 .PD 0
1476 .IP \fBnosectionheader\fR 4
1477 .IX Item "nosectionheader"
1478 .PD
1479 Generate section header. Don\*(Aqt generate section header if
1480 \&\fBnosectionheader\fR is used. \fBsectionheader\fR is the default.
1481 .IP \fBseparate\-code\fR 4
1482 .IX Item "separate-code"
1483 .PD 0
1484 .IP \fBnoseparate\-code\fR 4
1485 .IX Item "noseparate-code"
1486 .PD
1487 Create separate code \f(CW\*(C`PT_LOAD\*(C'\fR segment header in the object. This
1488 specifies a memory segment that should contain only instructions and must
1489 be in wholly disjoint pages from any other data. Don\*(Aqt create separate
1490 code \f(CW\*(C`PT_LOAD\*(C'\fR segment if \fBnoseparate\-code\fR is used.
1491 .IP \fBshstk\fR 4
1492 .IX Item "shstk"
1493 Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in .note.gnu.property section
1494 to indicate compatibility with Intel Shadow Stack. Supported for
1495 Linux/i386 and Linux/x86_64.
1496 .IP \fBstack\-size=\fR\fIvalue\fR 4
1497 .IX Item "stack-size=value"
1498 Specify a stack size for an ELF \f(CW\*(C`PT_GNU_STACK\*(C'\fR segment.
1499 Specifying zero will override any default non\-zero sized
1500 \&\f(CW\*(C`PT_GNU_STACK\*(C'\fR segment creation.
1501 .IP \fBstart\-stop\-gc\fR 4
1502 .IX Item "start-stop-gc"
1503 .PD 0
1504 .IP \fBnostart\-stop\-gc\fR 4
1505 .IX Item "nostart-stop-gc"
1506 .PD
1507 When \fB\-\-gc\-sections\fR is in effect, a reference from a retained
1508 section to \f(CW\*(C`_\|_start_SECNAME\*(C'\fR or \f(CW\*(C`_\|_stop_SECNAME\*(C'\fR causes all
1509 input sections named \f(CW\*(C`SECNAME\*(C'\fR to also be retained, if
1510 \&\f(CW\*(C`SECNAME\*(C'\fR is representable as a C identifier and either
1511 \&\f(CW\*(C`_\|_start_SECNAME\*(C'\fR or \f(CW\*(C`_\|_stop_SECNAME\*(C'\fR is synthesized by the
1512 linker. \fB\-z start\-stop\-gc\fR disables this effect, allowing
1513 sections to be garbage collected as if the special synthesized symbols
1514 were not defined. \fB\-z start\-stop\-gc\fR has no effect on a
1515 definition of \f(CW\*(C`_\|_start_SECNAME\*(C'\fR or \f(CW\*(C`_\|_stop_SECNAME\*(C'\fR in an
1516 object file or linker script. Such a definition will prevent the
1517 linker providing a synthesized \f(CW\*(C`_\|_start_SECNAME\*(C'\fR or
1518 \&\f(CW\*(C`_\|_stop_SECNAME\*(C'\fR respectively, and therefore the special
1519 treatment by garbage collection for those references.
1520 .IP \fBstart\-stop\-visibility=\fR\fIvalue\fR 4
1521 .IX Item "start-stop-visibility=value"
1522 Specify the ELF symbol visibility for synthesized
1523 \&\f(CW\*(C`_\|_start_SECNAME\*(C'\fR and \f(CW\*(C`_\|_stop_SECNAME\*(C'\fR symbols. \fIvalue\fR must be exactly \fBdefault\fR,
1524 \&\fBinternal\fR, \fBhidden\fR, or \fBprotected\fR. If no \fB\-z
1525 start\-stop\-visibility\fR option is given, \fBprotected\fR is used for
1526 compatibility with historical practice. However, it\*(Aqs highly
1527 recommended to use \fB\-z start\-stop\-visibility=hidden\fR in new
1528 programs and shared libraries so that these symbols are not exported
1529 between shared objects, which is not usually what\*(Aqs intended.
1530 .IP \fBtext\fR 4
1531 .IX Item "text"
1532 .PD 0
1533 .IP \fBnotext\fR 4
1534 .IX Item "notext"
1535 .IP \fBtextoff\fR 4
1536 .IX Item "textoff"
1537 .PD
1538 Report an error if DT_TEXTREL is set, i.e., if the position\-independent
1539 or shared object has dynamic relocations in read\-only sections. Don\*(Aqt
1540 report an error if \fBnotext\fR or \fBtextoff\fR.
1541 .IP \fBundefs\fR 4
1542 .IX Item "undefs"
1543 Do not report unresolved symbol references from regular object files,
1544 either when creating an executable, or when creating a shared library.
1545 This option is the inverse of \fB\-z defs\fR.
1546 .IP \fBunique\-symbol\fR 4
1547 .IX Item "unique-symbol"
1548 .PD 0
1549 .IP \fBnounique\-symbol\fR 4
1550 .IX Item "nounique-symbol"
1551 .PD
1552 Avoid duplicated local symbol names in the symbol string table. Append
1553 ".\f(CW\*(C`number\*(C'\fR" to duplicated local symbol names if \fBunique\-symbol\fR
1554 is used. \fBnounique\-symbol\fR is the default.
1555 .IP \fBx86\-64\-baseline\fR 4
1556 .IX Item "x86-64-baseline"
1557 .PD 0
1558 .IP \fBx86\-64\-v2\fR 4
1559 .IX Item "x86-64-v2"
1560 .IP \fBx86\-64\-v3\fR 4
1561 .IX Item "x86-64-v3"
1562 .IP \fBx86\-64\-v4\fR 4
1563 .IX Item "x86-64-v4"
1564 .PD
1565 Specify the x86\-64 ISA level needed in .note.gnu.property section.
1566 \&\fBx86\-64\-baseline\fR generates \f(CW\*(C`GNU_PROPERTY_X86_ISA_1_BASELINE\*(C'\fR.
1567 \&\fBx86\-64\-v2\fR generates \f(CW\*(C`GNU_PROPERTY_X86_ISA_1_V2\*(C'\fR.
1568 \&\fBx86\-64\-v3\fR generates \f(CW\*(C`GNU_PROPERTY_X86_ISA_1_V3\*(C'\fR.
1569 \&\fBx86\-64\-v4\fR generates \f(CW\*(C`GNU_PROPERTY_X86_ISA_1_V4\*(C'\fR.
1570 Supported for Linux/i386 and Linux/x86_64.
1571 .IP \fBisa\-level\-report=none\fR 4
1572 .IX Item "isa-level-report=none"
1573 .PD 0
1574 .IP \fBisa\-level\-report=all\fR 4
1575 .IX Item "isa-level-report=all"
1576 .IP \fBisa\-level\-report=needed\fR 4
1577 .IX Item "isa-level-report=needed"
1578 .IP \fBisa\-level\-report=used\fR 4
1579 .IX Item "isa-level-report=used"
1580 .PD
1581 Specify how to report x86\-64 ISA levels in input relocatable files.
1582 \&\fBisa\-level\-report=none\fR, which is the default, will make the
1583 linker not report x86\-64 ISA levels in input files.
1584 \&\fBisa\-level\-report=all\fR will make the linker report needed and
1585 used x86\-64 ISA levels in input files.
1586 \&\fBisa\-level\-report=needed\fR will make the linker report needed
1587 x86\-64 ISA levels in input files.
1588 \&\fBisa\-level\-report=used\fR will make the linker report used
1589 x86\-64 ISA levels in input files.
1590 Supported for Linux/i386 and Linux/x86_64.
1591 .RE
1592 .RS 4
1593 .Sp
1594 Other keywords are ignored for Solaris compatibility.
1595 .RE
1596 .IP \fB\-\-gnu\-tls\-tag\fR 4
1597 .IX Item "--gnu-tls-tag"
1598 .PD 0
1599 .IP \fB\-\-no\-gnu\-tls\-tag\fR 4
1600 .IX Item "--no-gnu-tls-tag"
1601 .PD
1602 Add \f(CW\*(C`GLIBC_ABI_GNU_TLS\*(C'\fR version tag dependency in output programs
1603 and shared libraries when linking against glibc if input relocatable
1604 object files call \f(CW\*(C`_\|_\|_tls_get_addr\*(C'\fR. The output will fail to load
1605 and run at run\-time against glibc which doesn\*(Aqt define the
1606 \&\f(CW\*(C`GLIBC_ABI_GNU_TLS\*(C'\fR version tag. Unless disabled by the
1607 \&\fB\-\-disable\-gnu\-tls\-tag\fR configure option at the linker build
1608 time, when no options are specified, linker will add the
1609 \&\f(CW\*(C`GLIBC_ABI_GNU_TLS\*(C'\fR version tag dependency if inputs have
1610 \&\f(CW\*(C`_\|_\|_tls_get_addr\*(C'\fR call and libc.so defines the
1611 \&\f(CW\*(C`GLIBC_ABI_GNU_TLS\*(C'\fR version tag. Supported for Linux/i386.
1612 .IP \fB\-\-gnu2\-tls\-tag\fR 4
1613 .IX Item "--gnu2-tls-tag"
1614 .PD 0
1615 .IP \fB\-\-no\-gnu2\-tls\-tag\fR 4
1616 .IX Item "--no-gnu2-tls-tag"
1617 .PD
1618 Add \f(CW\*(C`GLIBC_ABI_GNU2_TLS\*(C'\fR version tag dependency in output programs
1619 and shared libraries when linking against glibc if input relocatable
1620 object files have \f(CW\*(C`R_386_TLS_DESC_CALL\*(C'\fR or
1621 \&\f(CW\*(C`R_X86_64_TLSDESC_CALL\*(C'\fR relocation. The output will fail to load
1622 and run at run\-time against glibc which doesn\*(Aqt define the
1623 \&\f(CW\*(C`GLIBC_ABI_GNU2_TLS\*(C'\fR version tag. Unless disabled by the
1624 \&\fB\-\-disable\-gnu2\-tls\-tag\fR configure option at the linker build
1625 time, when no options are specified, linker will add the
1626 \&\f(CW\*(C`GLIBC_ABI_GNU2_TLS\*(C'\fR version tag dependency if inputs have
1627 \&\f(CW\*(C`R_386_TLS_DESC_CALL\*(C'\fR or \f(CW\*(C`R_X86_64_TLSDESC_CALL\*(C'\fR relocation
1628 and libc.so defines the \f(CW\*(C`GLIBC_ABI_GNU2_TLS\*(C'\fR version tag.
1629 Supported for Linux/i386 and Linux/x86_64.
1630 .IP "\fB\-(\fR \fIarchives\fR \fB\-)\fR" 4
1631 .IX Item "-( archives -)"
1632 .PD 0
1633 .IP "\fB\-\-start\-group\fR \fIarchives\fR \fB\-\-end\-group\fR" 4
1634 .IX Item "--start-group archives --end-group"
1635 .PD
1636 The \fIarchives\fR should be a list of archive files. They may be
1637 either explicit file names, or \fB\-l\fR options.
1638 .Sp
1639 The specified archives are searched repeatedly until no new undefined
1640 references are created. Normally, an archive is searched only once in
1641 the order that it is specified on the command line. If a symbol in that
1642 archive is needed to resolve an undefined symbol referred to by an
1643 object in an archive that appears later on the command line, the linker
1644 would not be able to resolve that reference. By grouping the archives,
1645 they will all be searched repeatedly until all possible references are
1646 resolved.
1647 .Sp
1648 This option is not allowed within a \fB\-\-start\-lib\fR/\fB\-\-end\-lib\fR
1649 option pair.
1650 .Sp
1651 Using this option has a significant performance cost. It is best to use
1652 it only when there are unavoidable circular references between two or
1653 more archives.
1654 .IP "\fB\-\-start\-lib\fR \fIobjects\fR \fB\-\-end\-lib\fR" 4
1655 .IX Item "--start-lib objects --end-lib"
1656 The \fIobjects\fR should be a list of object files.
1657 .Sp
1658 The specified objects are treated as if they were members of an archive
1659 the name of which has been placed at the location of \fB\-\-start\-lib\fR
1660 on the command line. All the usual linker archive handling properties
1661 and command line options apply to such an artificial archive.
1662 .Sp
1663 This option may be used multiple times, in which case each set of the
1664 objects specified will be treated as an individual archive. Nesting this
1665 option is not allowed though.
1666 .Sp
1667 Options that affect archive processing are not allowed between
1668 \&\fB\-\-start\-lib\fR and \fB\-\-end\-lib\fR as it would make no sense
1669 to apply them midway through handling an archive. These options include:
1670 \&\fB\-(\fR/\fB\-\-start\-group\fR, \fB\-)\fR/\fB\-\-end\-group\fR,
1671 \&\fB\-\-whole\-archive\fR, and \fB\-\-no\-whole\-archive\fR, as well as
1672 \&\fB\-\-pop\-state\fR where it would change the state of
1673 \&\fB\-\-whole\-archive\fR setting.
1674 .IP \fB\-\-accept\-unknown\-input\-arch\fR 4
1675 .IX Item "--accept-unknown-input-arch"
1676 .PD 0
1677 .IP \fB\-\-no\-accept\-unknown\-input\-arch\fR 4
1678 .IX Item "--no-accept-unknown-input-arch"
1679 .PD
1680 Tells the linker to accept input files whose architecture cannot be
1681 recognised. The assumption is that the user knows what they are doing
1682 and deliberately wants to link in these unknown input files. This was
1683 the default behaviour of the linker, before release 2.14. The default
1684 behaviour from release 2.14 onwards is to reject such input files, and
1685 so the \fB\-\-accept\-unknown\-input\-arch\fR option has been added to
1686 restore the old behaviour.
1687 .IP \fB\-\-as\-needed\fR 4
1688 .IX Item "--as-needed"
1689 .PD 0
1690 .IP \fB\-\-no\-as\-needed\fR 4
1691 .IX Item "--no-as-needed"
1692 .PD
1693 This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
1694 on the command line after the \fB\-\-as\-needed\fR option. Normally
1695 the linker will add a DT_NEEDED tag for each dynamic library mentioned
1696 on the command line, regardless of whether the library is actually
1697 needed or not. \fB\-\-as\-needed\fR causes a DT_NEEDED tag to only be
1698 emitted for a library that \fIat that point in the link\fR satisfies a
1699 non\-weak undefined symbol reference from a regular object file or, if
1700 the library is not found in the DT_NEEDED lists of other needed libraries, a
1701 non\-weak undefined symbol reference from another needed dynamic library.
1702 Object files or libraries appearing on the command line \fIafter\fR
1703 the library in question do not affect whether the library is seen as
1704 needed. This is similar to the rules for extraction of object files
1705 from archives. \fB\-\-no\-as\-needed\fR restores the default behaviour.
1706 .Sp
1707 Note: On Linux based systems the \fB\-\-as\-needed\fR option also has
1708 an affect on the behaviour of the \fB\-\-rpath\fR and
1709 \&\fB\-\-rpath\-link\fR options. See the description of
1710 \&\fB\-\-rpath\-link\fR for more details.
1711 .IP \fB\-\-add\-needed\fR 4
1712 .IX Item "--add-needed"
1713 .PD 0
1714 .IP \fB\-\-no\-add\-needed\fR 4
1715 .IX Item "--no-add-needed"
1716 .PD
1717 These two options have been deprecated because of the similarity of
1718 their names to the \fB\-\-as\-needed\fR and \fB\-\-no\-as\-needed\fR
1719 options. They have been replaced by \fB\-\-copy\-dt\-needed\-entries\fR
1720 and \fB\-\-no\-copy\-dt\-needed\-entries\fR.
1721 .IP "\fB\-assert\fR \fIkeyword\fR" 4
1722 .IX Item "-assert keyword"
1723 This option is ignored for SunOS compatibility.
1724 .IP \fB\-Bdynamic\fR 4
1725 .IX Item "-Bdynamic"
1726 .PD 0
1727 .IP \fB\-dy\fR 4
1728 .IX Item "-dy"
1729 .IP \fB\-call_shared\fR 4
1730 .IX Item "-call_shared"
1731 .PD
1732 Link against dynamic libraries. This is only meaningful on platforms
1733 for which shared libraries are supported. This option is normally the
1734 default on such platforms. The different variants of this option are
1735 for compatibility with various systems. You may use this option
1736 multiple times on the command line: it affects library searching for
1737 \&\fB\-l\fR options which follow it.
1738 .IP \fB\-Bgroup\fR 4
1739 .IX Item "-Bgroup"
1740 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
1741 section. This causes the runtime linker to handle lookups in this
1742 object and its dependencies to be performed only inside the group.
1743 \&\fB\-\-unresolved\-symbols=report\-all\fR is implied. This option is
1744 only meaningful on ELF platforms which support shared libraries.
1745 .IP \fB\-Bstatic\fR 4
1746 .IX Item "-Bstatic"
1747 .PD 0
1748 .IP \fB\-dn\fR 4
1749 .IX Item "-dn"
1750 .IP \fB\-non_shared\fR 4
1751 .IX Item "-non_shared"
1752 .IP \fB\-static\fR 4
1753 .IX Item "-static"
1754 .PD
1755 Do not link against shared libraries. This is only meaningful on
1756 platforms for which shared libraries are supported. The different
1757 variants of this option are for compatibility with various systems. You
1758 may use this option multiple times on the command line: it affects
1759 library searching for \fB\-l\fR options which follow it. This
1760 option also implies \fB\-\-unresolved\-symbols=report\-all\fR. This
1761 option can be used with \fB\-shared\fR. Doing so means that a
1762 shared library is being created but that all of the library\*(Aqs external
1763 references must be resolved by pulling in entries from static
1764 libraries.
1765 .IP \fB\-Bsymbolic\fR 4
1766 .IX Item "-Bsymbolic"
1767 When creating a shared library, bind references to global symbols to the
1768 definition within the shared library, if any. Normally, it is possible
1769 for a program linked against a shared library to override the definition
1770 within the shared library. This option is only meaningful on ELF
1771 platforms which support shared libraries.
1772 .IP \fB\-Bsymbolic\-functions\fR 4
1773 .IX Item "-Bsymbolic-functions"
1774 When creating a shared library, bind references to global function
1775 symbols to the definition within the shared library, if any.
1776 This option is only meaningful on ELF platforms which support shared
1777 libraries.
1778 .IP \fB\-Bno\-symbolic\fR 4
1779 .IX Item "-Bno-symbolic"
1780 This option can cancel previously specified \fB\-Bsymbolic\fR and
1781 \&\fB\-Bsymbolic\-functions\fR.
1782 .IP \fB\-\-dynamic\-list=\fR\fIdynamic\-list\-file\fR 4
1783 .IX Item "--dynamic-list=dynamic-list-file"
1784 Specify the name of a dynamic list file to the linker. This is
1785 typically used when creating shared libraries to specify a list of
1786 global symbols whose references shouldn\*(Aqt be bound to the definition
1787 within the shared library, or creating dynamically linked executables
1788 to specify a list of symbols which should be added to the symbol table
1789 in the executable. This option is only meaningful on ELF platforms
1790 which support shared libraries.
1791 .Sp
1792 The format of the dynamic list is the same as the version node without
1793 scope and node name. See \fBVERSION\fR for more information.
1794 .IP \fB\-\-dynamic\-list\-data\fR 4
1795 .IX Item "--dynamic-list-data"
1796 Include all global data symbols to the dynamic list.
1797 .IP \fB\-\-dynamic\-list\-cpp\-new\fR 4
1798 .IX Item "--dynamic-list-cpp-new"
1799 Provide the builtin dynamic list for C++ operator new and delete. It
1800 is mainly useful for building shared libstdc++.
1801 .IP \fB\-\-dynamic\-list\-cpp\-typeinfo\fR 4
1802 .IX Item "--dynamic-list-cpp-typeinfo"
1803 Provide the builtin dynamic list for C++ runtime type identification.
1804 .IP \fB\-\-check\-sections\fR 4
1805 .IX Item "--check-sections"
1806 .PD 0
1807 .IP \fB\-\-no\-check\-sections\fR 4
1808 .IX Item "--no-check-sections"
1809 .PD
1810 Asks the linker \fInot\fR to check section addresses after they have
1811 been assigned to see if there are any overlaps. Normally the linker will
1812 perform this check, and if it finds any overlaps it will produce
1813 suitable error messages. The linker does know about, and does make
1814 allowances for sections in overlays. The default behaviour can be
1815 restored by using the command\-line switch \fB\-\-check\-sections\fR.
1816 Section overlap is not usually checked for relocatable links. You can
1817 force checking in that case by using the \fB\-\-check\-sections\fR
1818 option.
1819 .IP \fB\-\-copy\-dt\-needed\-entries\fR 4
1820 .IX Item "--copy-dt-needed-entries"
1821 .PD 0
1822 .IP \fB\-\-no\-copy\-dt\-needed\-entries\fR 4
1823 .IX Item "--no-copy-dt-needed-entries"
1824 .PD
1825 This option affects the treatment of dynamic libraries referred to
1826 by DT_NEEDED tags \fIinside\fR ELF dynamic libraries mentioned on the
1827 command line. Normally the linker won\*(Aqt add a DT_NEEDED tag to the
1828 output binary for each library mentioned in a DT_NEEDED tag in an
1829 input dynamic library. With \fB\-\-copy\-dt\-needed\-entries\fR
1830 specified on the command line however any dynamic libraries that
1831 follow it will have their DT_NEEDED entries added. The default
1832 behaviour can be restored with \fB\-\-no\-copy\-dt\-needed\-entries\fR.
1833 .Sp
1834 This option also has an effect on the resolution of symbols in dynamic
1835 libraries. With \fB\-\-copy\-dt\-needed\-entries\fR dynamic libraries
1836 mentioned on the command line will be recursively searched, following
1837 their DT_NEEDED tags to other libraries, in order to resolve symbols
1838 required by the output binary. With the default setting however
1839 the searching of dynamic libraries that follow it will stop with the
1840 dynamic library itself. No DT_NEEDED links will be traversed to resolve
1841 symbols.
1842 .IP \fB\-\-cref\fR 4
1843 .IX Item "--cref"
1844 Output a cross reference table. If a linker map file is being
1845 generated, the cross reference table is printed to the map file.
1846 Otherwise, it is printed on the standard output.
1847 .Sp
1848 The format of the table is intentionally simple, so that it may be
1849 easily processed by a script if necessary. The symbols are printed out,
1850 sorted by name. For each symbol, a list of file names is given. If the
1851 symbol is defined, the first file listed is the location of the
1852 definition. If the symbol is defined as a common value then any files
1853 where this happens appear next. Finally any files that reference the
1854 symbol are listed.
1855 .IP \fB\-\-ctf\-variables\fR 4
1856 .IX Item "--ctf-variables"
1857 .PD 0
1858 .IP \fB\-\-no\-ctf\-variables\fR 4
1859 .IX Item "--no-ctf-variables"
1860 .PD
1861 The CTF debuginfo format supports a section which encodes the names and
1862 types of variables found in the program which do not appear in any symbol
1863 table. These variables clearly cannot be looked up by address by
1864 conventional debuggers, so the space used for their types and names is
1865 usually wasted: the types are usually small but the names are often not.
1866 \&\fB\-\-ctf\-variables\fR causes the generation of such a section.
1867 The default behaviour can be restored with \fB\-\-no\-ctf\-variables\fR.
1868 .IP \fB\-\-ctf\-share\-types=\fR\fImethod\fR 4
1869 .IX Item "--ctf-share-types=method"
1870 Adjust the method used to share types between translation units in CTF.
1871 .RS 4
1872 .IP \fBshare\-unconflicted\fR 4
1873 .IX Item "share-unconflicted"
1874 Put all types that do not have ambiguous definitions into the shared dictionary,
1875 where debuggers can easily access them, even if they only occur in one
1876 translation unit. This is the default.
1877 .IP \fBshare\-duplicated\fR 4
1878 .IX Item "share-duplicated"
1879 Put only types that occur in multiple translation units into the shared
1880 dictionary: types with only one definition go into per\-translation\-unit
1881 dictionaries. Types with ambiguous definitions in multiple translation units
1882 always go into per\-translation\-unit dictionaries. This tends to make the CTF
1883 larger, but may reduce the amount of CTF in the shared dictionary. For very
1884 large projects this may speed up opening the CTF and save memory in the CTF
1885 consumer at runtime.
1886 .RE
1887 .RS 4
1888 .RE
1889 .IP \fB\-\-no\-define\-common\fR 4
1890 .IX Item "--no-define-common"
1891 This option inhibits the assignment of addresses to common symbols.
1892 The script command \f(CW\*(C`INHIBIT_COMMON_ALLOCATION\*(C'\fR has the same effect.
1893 .Sp
1894 The \fB\-\-no\-define\-common\fR option allows decoupling
1895 the decision to assign addresses to Common symbols from the choice
1896 of the output file type; otherwise a non\-Relocatable output type
1897 forces assigning addresses to Common symbols.
1898 Using \fB\-\-no\-define\-common\fR allows Common symbols that are referenced
1899 from a shared library to be assigned addresses only in the main program.
1900 This eliminates the unused duplicate space in the shared library,
1901 and also prevents any possible confusion over resolving to the wrong
1902 duplicate when there are many dynamic modules with specialized search
1903 paths for runtime symbol resolution.
1904 .IP \fB\-\-force\-group\-allocation\fR 4
1905 .IX Item "--force-group-allocation"
1906 This option causes the linker to place section group members like
1907 normal input sections, and to delete the section groups. This is the
1908 default behaviour for a final link but this option can be used to
1909 change the behaviour of a relocatable link (\fB\-r\fR). The script
1910 command \f(CW\*(C`FORCE_GROUP_ALLOCATION\*(C'\fR has the same
1911 effect.
1912 .IP \fB\-\-defsym=\fR\fIsymbol\fR\fB=\fR\fIexpression\fR 4
1913 .IX Item "--defsym=symbol=expression"
1914 Create a global symbol in the output file, containing the absolute
1915 address given by \fIexpression\fR. You may use this option as many
1916 times as necessary to define multiple symbols in the command line. A
1917 limited form of arithmetic is supported for the \fIexpression\fR in this
1918 context: you may give a hexadecimal constant or the name of an existing
1919 symbol, or use \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`\-\*(C'\fR to add or subtract hexadecimal
1920 constants or symbols. If you need more elaborate expressions, consider
1921 using the linker command language from a script.
1922 \&\fINote:\fR there should be no white space between \fIsymbol\fR, the
1923 equals sign ("\fB=\fR"), and \fIexpression\fR.
1924 .Sp
1925 The linker processes \fB\-\-defsym\fR arguments and \fB\-T\fR arguments
1926 in order, placing \fB\-\-defsym\fR before \fB\-T\fR will define the
1927 symbol before the linker script from \fB\-T\fR is processed, while
1928 placing \fB\-\-defsym\fR after \fB\-T\fR will define the symbol after
1929 the linker script has been processed. This difference has
1930 consequences for expressions within the linker script that use the
1931 \&\fB\-\-defsym\fR symbols, which order is correct will depend on what
1932 you are trying to achieve.
1933 .IP \fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR 4
1934 .IX Item "--demangle[=style]"
1935 .PD 0
1936 .IP \fB\-\-no\-demangle\fR 4
1937 .IX Item "--no-demangle"
1938 .PD
1939 These options control whether to demangle symbol names in error messages
1940 and other output. When the linker is told to demangle, it tries to
1941 present symbol names in a readable fashion: it strips leading
1942 underscores if they are used by the object file format, and converts C++
1943 mangled symbol names into user readable names. Different compilers have
1944 different mangling styles. The optional demangling style argument can be used
1945 to choose an appropriate demangling style for your compiler. The linker will
1946 demangle by default unless the environment variable \fBCOLLECT_NO_DEMANGLE\fR
1947 is set. These options may be used to override the default.
1948 .IP \fB\-I\fR\fIfile\fR 4
1949 .IX Item "-Ifile"
1950 .PD 0
1951 .IP \fB\-\-dynamic\-linker=\fR\fIfile\fR 4
1952 .IX Item "--dynamic-linker=file"
1953 .PD
1954 Set the name of the dynamic linker. This is only meaningful when
1955 generating dynamically linked ELF executables. The default dynamic
1956 linker is normally correct; don\*(Aqt use this unless you know what you are
1957 doing.
1958 .IP \fB\-\-no\-dynamic\-linker\fR 4
1959 .IX Item "--no-dynamic-linker"
1960 When producing an executable file, omit the request for a dynamic
1961 linker to be used at load\-time. This is only meaningful for ELF
1962 executables that contain dynamic relocations, and usually requires
1963 entry point code that is capable of processing these relocations.
1964 .IP \fB\-\-embedded\-relocs\fR 4
1965 .IX Item "--embedded-relocs"
1966 This option is similar to the \fB\-\-emit\-relocs\fR option except
1967 that the relocs are stored in a target\-specific section. This option
1968 is only supported by the \fBBFIN\fR, \fBCR16\fR and \fIM68K\fR
1969 targets.
1970 .IP \fB\-\-disable\-multiple\-abs\-defs\fR 4
1971 .IX Item "--disable-multiple-abs-defs"
1972 Do not allow multiple definitions with symbols included
1973 in filename invoked by \-R or \-\-just\-symbols
1974 .IP \fB\-\-fatal\-warnings\fR 4
1975 .IX Item "--fatal-warnings"
1976 .PD 0
1977 .IP \fB\-\-no\-fatal\-warnings\fR 4
1978 .IX Item "--no-fatal-warnings"
1979 .PD
1980 Treat all warnings as errors. The default behaviour can be restored
1981 with the option \fB\-\-no\-fatal\-warnings\fR.
1982 .IP \fB\-w\fR 4
1983 .IX Item "-w"
1984 .PD 0
1985 .IP \fB\-\-no\-warnings\fR 4
1986 .IX Item "--no-warnings"
1987 .PD
1988 Do not display any warning or error messages. This overrides
1989 \&\fB\-\-fatal\-warnings\fR if it has been enabled. This option can be
1990 used when it is known that the output binary will not work, but there
1991 is still a need to create it.
1992 .IP \fB\-\-force\-exe\-suffix\fR 4
1993 .IX Item "--force-exe-suffix"
1994 Make sure that an output file has a .exe suffix.
1995 .Sp
1996 If a successfully built fully linked output file does not have a
1997 \&\f(CW\*(C`.exe\*(C'\fR or \f(CW\*(C`.dll\*(C'\fR suffix, this option forces the linker to copy
1998 the output file to one of the same name with a \f(CW\*(C`.exe\*(C'\fR suffix. This
1999 option is useful when using unmodified Unix makefiles on a Microsoft
2000 Windows host, since some versions of Windows won\*(Aqt run an image unless
2001 it ends in a \f(CW\*(C`.exe\*(C'\fR suffix.
2002 .IP \fB\-\-gc\-sections\fR 4
2003 .IX Item "--gc-sections"
2004 .PD 0
2005 .IP \fB\-\-no\-gc\-sections\fR 4
2006 .IX Item "--no-gc-sections"
2007 .PD
2008 Enable garbage collection of unused input sections. It is ignored on
2009 targets that do not support this option. The default behaviour (of not
2010 performing this garbage collection) can be restored by specifying
2011 \&\fB\-\-no\-gc\-sections\fR on the command line. Note that garbage
2012 collection for COFF and PE format targets is supported, but the
2013 implementation is currently considered to be experimental.
2014 .Sp
2015 \&\fB\-\-gc\-sections\fR decides which input sections are used by
2016 examining symbols and relocations. The section containing the entry
2017 symbol and all sections containing symbols undefined on the
2018 command\-line will be kept, as will sections containing symbols
2019 referenced by dynamic objects. Note that when building shared
2020 libraries, the linker must assume that any visible symbol is
2021 referenced. Once this initial set of sections has been determined,
2022 the linker recursively marks as used any section referenced by their
2023 relocations. See \fB\-\-entry\fR, \fB\-\-undefined\fR, and
2024 \&\fB\-\-gc\-keep\-exported\fR.
2025 .Sp
2026 This option can be set when doing a partial link (enabled with option
2027 \&\fB\-r\fR). In this case the root of symbols kept must be explicitly
2028 specified either by one of the options \fB\-\-entry\fR,
2029 \&\fB\-\-undefined\fR, or \fB\-\-gc\-keep\-exported\fR or by a \f(CW\*(C`ENTRY\*(C'\fR
2030 command in the linker script.
2031 .Sp
2032 As a GNU extension, ELF input sections marked with the
2033 \&\f(CW\*(C`SHF_GNU_RETAIN\*(C'\fR flag will not be garbage collected.
2034 .IP \fB\-\-print\-gc\-sections\fR 4
2035 .IX Item "--print-gc-sections"
2036 .PD 0
2037 .IP \fB\-\-no\-print\-gc\-sections\fR 4
2038 .IX Item "--no-print-gc-sections"
2039 .PD
2040 List all sections removed by garbage collection. The listing is
2041 printed on stderr. This option is only effective if garbage
2042 collection has been enabled via the \fB\-\-gc\-sections\fR) option. The
2043 default behaviour (of not listing the sections that are removed) can
2044 be restored by specifying \fB\-\-no\-print\-gc\-sections\fR on the command
2045 line.
2046 .IP \fB\-\-gc\-keep\-exported\fR 4
2047 .IX Item "--gc-keep-exported"
2048 When \fB\-\-gc\-sections\fR is enabled, this option prevents garbage
2049 collection of unused input sections that contain global symbols having
2050 default or protected visibility. This option is intended to be used for
2051 executables where unreferenced sections would otherwise be garbage
2052 collected regardless of the external visibility of contained symbols.
2053 Note that this option has no effect when linking shared objects since
2054 it is already the default behaviour. This option is only supported for
2055 ELF format targets.
2056 .IP \fB\-\-print\-output\-format\fR 4
2057 .IX Item "--print-output-format"
2058 Print the name of the default output format (perhaps influenced by
2059 other command\-line options). This is the string that would appear
2060 in an \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR linker script command.
2061 .IP \fB\-\-print\-memory\-usage\fR 4
2062 .IX Item "--print-memory-usage"
2063 Print used size, total size and used size of memory regions created with
2064 the \fBMEMORY\fR command. This is useful on embedded targets to have a
2065 quick view of amount of free memory. The format of the output has one
2066 headline and one line per region. It is both human readable and easily
2067 parsable by tools. Here is an example of an output:
2068 .Sp
2069 .Vb 3
2070 \& Memory region Used Size Region Size %age Used
2071 \& ROM: 256 KB 1 MB 25.00%
2072 \& RAM: 32 B 2 GB 0.00%
2073 .Ve
2074 .Sp
2075 Note: if you want to find out about the memory usage of the linker
2076 itself, then the \fB\-\-stats\fR option will do this.
2077 .IP \fB\-\-help\fR 4
2078 .IX Item "--help"
2079 Print a summary of the command\-line options on the standard output and exit.
2080 .IP \fB\-\-target\-help\fR 4
2081 .IX Item "--target-help"
2082 Print a summary of all target\-specific options on the standard output and exit.
2083 .IP \fB\-Map=\fR\fImapfile\fR 4
2084 .IX Item "-Map=mapfile"
2085 Print a link map to the file \fImapfile\fR. See the description of the
2086 \&\fB\-M\fR option, above. If \fImapfile\fR is just the character
2087 \&\f(CW\*(C`\-\*(C'\fR then the map will be written to stdout.
2088 .Sp
2089 Specifying a directory as \fImapfile\fR causes the linker map to be
2090 written as a file inside the directory. Normally name of the file
2091 inside the directory is computed as the basename of the \fIoutput\fR
2092 file with \f(CW\*(C`.map\*(C'\fR appended. If however the special character
2093 \&\f(CW\*(C`%\*(C'\fR is used then this will be replaced by the full path of the
2094 output file. Additionally if there are any characters after the
2095 \&\fI%\fR symbol then \f(CW\*(C`.map\*(C'\fR will no longer be appended.
2096 .Sp
2097 .Vb 10
2098 \& \-o foo.exe \-Map=bar [Creates ./bar]
2099 \& \-o ../dir/foo.exe \-Map=bar [Creates ./bar]
2100 \& \-o foo.exe \-Map=../dir [Creates ../dir/foo.exe.map]
2101 \& \-o ../dir2/foo.exe \-Map=../dir [Creates ../dir/foo.exe.map]
2102 \& \-o foo.exe \-Map=% [Creates ./foo.exe.map]
2103 \& \-o ../dir/foo.exe \-Map=% [Creates ../dir/foo.exe.map]
2104 \& \-o foo.exe \-Map=%.bar [Creates ./foo.exe.bar]
2105 \& \-o ../dir/foo.exe \-Map=%.bar [Creates ../dir/foo.exe.bar]
2106 \& \-o ../dir2/foo.exe \-Map=../dir/% [Creates ../dir/../dir2/foo.exe.map]
2107 \& \-o ../dir2/foo.exe \-Map=../dir/%.bar [Creates ../dir/../dir2/foo.exe.bar]
2108 .Ve
2109 .Sp
2110 It is an error to specify more than one \f(CW\*(C`%\*(C'\fR character.
2111 .Sp
2112 If the map file already exists then it will be overwritten by this
2113 operation.
2114 .IP \fB\-\-no\-keep\-memory\fR 4
2115 .IX Item "--no-keep-memory"
2116 \&\fBld\fR normally optimizes for speed over memory usage by caching the
2117 symbol tables of input files in memory. This option tells \fBld\fR to
2118 instead optimize for memory usage, by rereading the symbol tables as
2119 necessary. This may be required if \fBld\fR runs out of memory space
2120 while linking a large executable.
2121 .IP \fB\-\-no\-undefined\fR 4
2122 .IX Item "--no-undefined"
2123 .PD 0
2124 .IP "\fB\-z defs\fR" 4
2125 .IX Item "-z defs"
2126 .PD
2127 Report unresolved symbol references from regular object files. This
2128 is done even if the linker is creating a non\-symbolic shared library.
2129 The switch \fB\-\-[no\-]allow\-shlib\-undefined\fR controls the
2130 behaviour for reporting unresolved references found in shared
2131 libraries being linked in.
2132 .Sp
2133 The effects of this option can be reverted by using \f(CW\*(C`\-z undefs\*(C'\fR.
2134 .IP \fB\-\-allow\-multiple\-definition\fR 4
2135 .IX Item "--allow-multiple-definition"
2136 .PD 0
2137 .IP "\fB\-z muldefs\fR" 4
2138 .IX Item "-z muldefs"
2139 .PD
2140 Normally when a symbol is defined multiple times, the linker will
2141 report a fatal error. These options allow multiple definitions and the
2142 first definition will be used.
2143 .IP \fB\-\-allow\-shlib\-undefined\fR 4
2144 .IX Item "--allow-shlib-undefined"
2145 .PD 0
2146 .IP \fB\-\-no\-allow\-shlib\-undefined\fR 4
2147 .IX Item "--no-allow-shlib-undefined"
2148 .PD
2149 Allows or disallows undefined symbols in shared libraries.
2150 This switch is similar to \fB\-\-no\-undefined\fR except that it
2151 determines the behaviour when the undefined symbols are in a
2152 shared library rather than a regular object file. It does not affect
2153 how undefined symbols in regular object files are handled.
2154 .Sp
2155 The default behaviour is to report errors for any undefined symbols
2156 referenced in shared libraries if the linker is being used to create
2157 an executable, but to allow them if the linker is being used to create
2158 a shared library.
2159 .Sp
2160 The reasons for allowing undefined symbol references in shared
2161 libraries specified at link time are that:
2162 .RS 4
2163 .IP \(bu 4
2164 A shared library specified at link time may not be the same as the one
2165 that is available at load time, so the symbol might actually be
2166 resolvable at load time.
2167 .IP \(bu 4
2168 There are some operating systems, eg BeOS and HPPA, where undefined
2169 symbols in shared libraries are normal.
2170 .Sp
2171 The BeOS kernel for example patches shared libraries at load time to
2172 select whichever function is most appropriate for the current
2173 architecture. This is used, for example, to dynamically select an
2174 appropriate memset function.
2175 .RE
2176 .RS 4
2177 .RE
2178 .IP \fB\-\-error\-handling\-script=\fR\fIscriptname\fR 4
2179 .IX Item "--error-handling-script=scriptname"
2180 If this option is provided then the linker will invoke
2181 \&\fIscriptname\fR whenever an error is encountered. Currently however
2182 only two kinds of error are supported: missing symbols and missing
2183 libraries. Two arguments will be passed to script: the keyword
2184 "undefined\-symbol" or \`missing\-lib" and the \fIname\fR of the
2185 undefined symbol or missing library. The intention is that the script
2186 will provide suggestions to the user as to where the symbol or library
2187 might be found. After the script has finished then the normal linker
2188 error message will be displayed.
2189 .Sp
2190 The availability of this option is controlled by a configure time
2191 switch, so it may not be present in specific implementations.
2192 .IP \fB\-\-no\-undefined\-version\fR 4
2193 .IX Item "--no-undefined-version"
2194 Normally when a symbol has an undefined version, the linker will ignore
2195 it. This option disallows symbols with undefined version and a fatal error
2196 will be issued instead.
2197 .IP \fB\-\-default\-symver\fR 4
2198 .IX Item "--default-symver"
2199 Create and use a default symbol version (the soname) for unversioned
2200 exported symbols.
2201 .IP \fB\-\-default\-imported\-symver\fR 4
2202 .IX Item "--default-imported-symver"
2203 Create and use a default symbol version (the soname) for unversioned
2204 imported symbols.
2205 .IP \fB\-\-no\-warn\-mismatch\fR 4
2206 .IX Item "--no-warn-mismatch"
2207 Normally \fBld\fR will give an error if you try to link together input
2208 files that are mismatched for some reason, perhaps because they have
2209 been compiled for different processors or for different endiannesses.
2210 This option tells \fBld\fR that it should silently permit such possible
2211 errors. This option should only be used with care, in cases when you
2212 have taken some special action that ensures that the linker errors are
2213 inappropriate.
2214 .IP \fB\-\-no\-warn\-search\-mismatch\fR 4
2215 .IX Item "--no-warn-search-mismatch"
2216 Normally \fBld\fR will give a warning if it finds an incompatible
2217 library during a library search. This option silences the warning.
2218 .IP \fB\-\-no\-whole\-archive\fR 4
2219 .IX Item "--no-whole-archive"
2220 Turn off the effect of the \fB\-\-whole\-archive\fR option for subsequent
2221 archive files. Not allowed within a \fB\-\-start\-lib\fR/\fB\-\-end\-lib\fR
2222 option pair.
2223 .IP \fB\-\-no\-link\-mapless\fR 4
2224 .IX Item "--no-link-mapless"
2225 Reject archives that lack an index aka symbol map for all the subsequent
2226 archives referred on the command line. If such a file is encountered,
2227 a link error occurs. This is the traditional behavior.
2228 .IP \fB\-\-noinhibit\-exec\fR 4
2229 .IX Item "--noinhibit-exec"
2230 Retain the executable output file whenever it is still usable.
2231 Normally, the linker will not produce an output file if it encounters
2232 errors during the link process; it exits without writing an output file
2233 when it issues any error whatsoever.
2234 .IP \fB\-nostdlib\fR 4
2235 .IX Item "-nostdlib"
2236 Only search library directories explicitly specified on the
2237 command line. Library directories specified in linker scripts
2238 (including linker scripts specified on the command line) are ignored.
2239 .IP \fB\-\-oformat=\fR\fIoutput\-format\fR 4
2240 .IX Item "--oformat=output-format"
2241 \&\fBld\fR may be configured to support more than one kind of object
2242 file. If your \fBld\fR is configured this way, you can use the
2243 \&\fB\-\-oformat\fR option to specify the binary format for the output
2244 object file. Even when \fBld\fR is configured to support alternative
2245 object formats, you don\*(Aqt usually need to specify this, as \fBld\fR
2246 should be configured to produce as a default output format the most
2247 usual format on each machine. \fIoutput\-format\fR is a text string, the
2248 name of a particular format supported by the BFD libraries. (You can
2249 list the available binary formats with \fBobjdump \-i\fR.) The script
2250 command \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR can also specify the output format, but
2251 this option overrides it.
2252 .IP "\fB\-\-out\-implib\fR \fIfile\fR" 4
2253 .IX Item "--out-implib file"
2254 Create an import library in \fIfile\fR corresponding to the executable
2255 the linker is generating (eg. a DLL or ELF program). This import
2256 library (which should be called \f(CW\*(C`*.dll.a\*(C'\fR or \f(CW\*(C`*.a\*(C'\fR for DLLs)
2257 may be used to link clients against the generated executable; this
2258 behaviour makes it possible to skip a separate import library creation
2259 step (eg. \f(CW\*(C`dlltool\*(C'\fR for DLLs). This option is only available for
2260 the i386 PE and ELF targetted ports of the linker.
2261 .IP \fB\-pie\fR 4
2262 .IX Item "-pie"
2263 .PD 0
2264 .IP \fB\-\-pic\-executable\fR 4
2265 .IX Item "--pic-executable"
2266 .PD
2267 Create a position independent executable. This is currently only
2268 supported on ELF platforms. Position independent executables are
2269 relocated by the dynamic linker to the virtual address the OS chooses
2270 for them, which can vary between invocations. They are marked ET_DYN
2271 in the ELF file header, but differ from shared libraries in a number
2272 of ways. In particular, defined symbols in a PIE by default can not
2273 be overridden by another object as they can be in a shared library.
2274 .IP \fB\-no\-pie\fR 4
2275 .IX Item "-no-pie"
2276 Create a position dependent executable. This is the default.
2277 .IP \fB\-qmagic\fR 4
2278 .IX Item "-qmagic"
2279 This option is ignored for Linux compatibility.
2280 .IP \fB\-Qy\fR 4
2281 .IX Item "-Qy"
2282 This option is ignored for SVR4 compatibility.
2283 .IP \fB\-\-relax\fR 4
2284 .IX Item "--relax"
2285 .PD 0
2286 .IP \fB\-\-no\-relax\fR 4
2287 .IX Item "--no-relax"
2288 .PD
2289 An option with machine dependent effects.
2290 This option is only supported on a few targets.
2291 .Sp
2292 On some platforms the \fB\-\-relax\fR option performs target specific,
2293 global optimizations that become possible when the linker resolves
2294 addressing in the program, such as relaxing address modes,
2295 synthesizing new instructions, selecting shorter version of current
2296 instructions, and combining constant values.
2297 .Sp
2298 On some platforms these link time global optimizations may make symbolic
2299 debugging of the resulting executable impossible.
2300 This is known to be the case for the Matsushita MN10200 and MN10300
2301 family of processors.
2302 .Sp
2303 On platforms where the feature is supported, the option
2304 \&\fB\-\-no\-relax\fR will disable it.
2305 .Sp
2306 On platforms where the feature is not supported, both \fB\-\-relax\fR
2307 and \fB\-\-no\-relax\fR are accepted, but ignored.
2308 .IP \fB\-\-retain\-symbols\-file=\fR\fIfilename\fR 4
2309 .IX Item "--retain-symbols-file=filename"
2310 Retain \fIonly\fR the symbols listed in the file \fIfilename\fR,
2311 discarding all others. \fIfilename\fR is simply a flat file, with one
2312 symbol name per line. This option is especially useful in environments
2313 (such as VxWorks)
2314 where a large global symbol table is accumulated gradually, to conserve
2315 run\-time memory.
2316 .Sp
2317 \&\fB\-\-retain\-symbols\-file\fR does \fInot\fR discard undefined symbols,
2318 or symbols needed for relocations.
2319 .Sp
2320 You may only specify \fB\-\-retain\-symbols\-file\fR once in the command
2321 line. It overrides \fB\-s\fR and \fB\-S\fR.
2322 .IP \fB\-rpath=\fR\fIdir\fR 4
2323 .IX Item "-rpath=dir"
2324 Add a directory to the runtime library search path. This is used when
2325 linking an ELF executable with shared objects. All \fB\-rpath\fR
2326 arguments are concatenated and passed to the runtime linker, which uses
2327 them to locate shared objects at runtime.
2328 .Sp
2329 The \fB\-rpath\fR option is also used when locating shared objects which
2330 are needed by shared objects explicitly included in the link; see the
2331 description of the \fB\-rpath\-link\fR option. Searching \fB\-rpath\fR
2332 in this way is only supported by native linkers and cross linkers which
2333 have been configured with the \fB\-\-with\-sysroot\fR option.
2334 .Sp
2335 If \fB\-rpath\fR is not used when linking an ELF executable, the
2336 contents of the environment variable \f(CW\*(C`LD_RUN_PATH\*(C'\fR will be used if it
2337 is defined.
2338 .Sp
2339 The \fB\-rpath\fR option may also be used on SunOS. By default, on
2340 SunOS, the linker will form a runtime search path out of all the
2341 \&\fB\-L\fR options it is given. If a \fB\-rpath\fR option is used, the
2342 runtime search path will be formed exclusively using the \fB\-rpath\fR
2343 options, ignoring the \fB\-L\fR options. This can be useful when using
2344 gcc, which adds many \fB\-L\fR options which may be on NFS mounted
2345 file systems.
2346 .Sp
2347 For compatibility with other ELF linkers, if the \fB\-R\fR option is
2348 followed by a directory name, rather than a file name, it is treated as
2349 the \fB\-rpath\fR option.
2350 .IP \fB\-rpath\-link=\fR\fIdir\fR 4
2351 .IX Item "-rpath-link=dir"
2352 When using ELF or SunOS, one shared library may require another. This
2353 happens when an \f(CW\*(C`ld \-shared\*(C'\fR link includes a shared library as one
2354 of the input files.
2355 .Sp
2356 When the linker encounters such a dependency when doing a non\-shared,
2357 non\-relocatable link, it will automatically try to locate the required
2358 shared library and include it in the link, if it is not included
2359 explicitly. In such a case, several directories are searched as
2360 described below. The \fB\-rpath\-link\fR option specifies the first
2361 set of directories to search. This option may specify a sequence of
2362 directory names either by providing a list of names separated by
2363 colons, or by appearing multiple times.
2364 .Sp
2365 The tokens \fR\f(CI$ORIGIN\fR\fI\fR and \fI\fR\f(CI$LIB\fR\fI\fR can appear in these search
2366 directories. They will be replaced by the full path to the directory
2367 containing the program or shared object in the case of \fI\fR\f(CI$ORIGIN\fR\fI\fR
2368 and either \fBlib\fR \- for 32\-bit binaries \- or \fBlib64\fR \- for
2369 64\-bit binaries \- in the case of \fI\fR\f(CI$LIB\fR\fI\fR.
2370 .Sp
2371 The alternative form of these tokens \- \fI${ORIGIN}\fR and
2372 \&\fI${LIB}\fR can also be used. The token \fR\f(CI$PLATFORM\fR\fI\fR is not
2373 supported.
2374 .Sp
2375 The \fB\-\-rpath\-link\fR option should be used with caution as it
2376 overrides the search path that may have been hard compiled into a
2377 shared library. In such a case it is possible to unintentionally use
2378 a different search path than the runtime linker would have used.
2379 .Sp
2380 When additional shared libraries are required, the linker will search
2381 directories in the order listed below in order to find them. Note
2382 however that this only applies to additional libraries needed to
2383 satisfy already included shared libraries. It does \fInot\fR
2384 apply to libraries that are included via the \fB\-l\fR command line
2385 option. Searches for \fB\-l\fR libraries are only conducted in
2386 directories specified by the \fB\-L\fR option.
2387 .RS 4
2388 .IP 1. 4
2389 Any directories specified by \fB\-rpath\-link\fR options.
2390 .IP 2. 4
2391 Any directories specified by \fB\-rpath\fR options. The difference
2392 between \fB\-rpath\fR and \fB\-rpath\-link\fR is that directories
2393 specified by \fB\-rpath\fR options are included in the executable and
2394 used at runtime, whereas the \fB\-rpath\-link\fR option is only effective
2395 at link time. Searching \fB\-rpath\fR in this way is only supported
2396 by native linkers and cross linkers which have been configured with
2397 the \fB\-\-with\-sysroot\fR option.
2398 .IP 3. 4
2399 On an ELF system, for native linkers, if the \fB\-rpath\fR and
2400 \&\fB\-rpath\-link\fR options were not used, search the contents of the
2401 environment variable \f(CW\*(C`LD_RUN_PATH\*(C'\fR.
2402 .IP 4. 4
2403 On SunOS, if the \fB\-rpath\fR option was not used, search any
2404 directories specified using \fB\-L\fR options.
2405 .IP 5. 4
2406 For a native linker, search the contents of the environment
2407 variable \f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR.
2408 .IP 6. 4
2409 For a native ELF linker, the directories in \f(CW\*(C`DT_RUNPATH\*(C'\fR or
2410 \&\f(CW\*(C`DT_RPATH\*(C'\fR of a shared library are searched for shared
2411 libraries needed by it. The \f(CW\*(C`DT_RPATH\*(C'\fR entries are ignored if
2412 \&\f(CW\*(C`DT_RUNPATH\*(C'\fR entries exist.
2413 .IP 7. 4
2414 For a linker for a Linux system, if the file \fI/etc/ld.so.conf\fR
2415 exists, the list of directories found in that file. Note: the path
2416 to this file is prefixed with the \f(CW\*(C`sysroot\*(C'\fR value, if that is
2417 defined, and then any \f(CW\*(C`prefix\*(C'\fR string if the linker was
2418 configured with the \fB\-\-prefix=<path>\fR option.
2419 .IP 8. 4
2420 For a native linker on a FreeBSD system, any directories specified by
2421 the \f(CW\*(C`_PATH_ELF_HINTS\*(C'\fR macro defined in the \fIelf\-hints.h\fR
2422 header file.
2423 .IP 9. 4
2424 Any directories specified by a \f(CW\*(C`SEARCH_DIR\*(C'\fR command in a
2425 linker script given on the command line, including scripts specified
2426 by \fB\-T\fR (but not \fB\-dT\fR).
2427 .IP 10. 4
2428 The default directories, normally \fI/lib\fR and \fI/usr/lib\fR.
2429 .IP 11. 4
2430 Any directories specified by a plugin LDPT_SET_EXTRA_LIBRARY_PATH.
2431 .IP 12. 4
2432 Any directories specified by a \f(CW\*(C`SEARCH_DIR\*(C'\fR command in a default
2433 linker script.
2434 .RE
2435 .RS 4
2436 .Sp
2437 Note however on Linux based systems there is an additional caveat: If
2438 the \fB\-\-as\-needed\fR option is active \fIand\fR a shared library
2439 is located which would normally satisfy the search \fIand\fR this
2440 library does not have DT_NEEDED tag for \fIlibc.so\fR
2441 \&\fIand\fR there is a shared library later on in the set of search
2442 directories which also satisfies the search \fIand\fR
2443 this second shared library does have a DT_NEEDED tag for
2444 \&\fIlibc.so\fR \fIthen\fR the second library will be selected instead
2445 of the first.
2446 .Sp
2447 If the required shared library is not found, the linker will issue a
2448 warning and continue with the link.
2449 .RE
2450 .IP \fB\-\-section\-ordering\-file=\fR\fIscript\fR 4
2451 .IX Item "--section-ordering-file=script"
2452 This option is used to augment the current linker script with
2453 additional mapping of input sections to output sections. This file
2454 must use the same syntax for \f(CW\*(C`SECTIONS\*(C'\fR as is used in normal
2455 linker scripts, but it should not do anything other than place input
2456 sections into output sections. \f(CW@pxref\fR{SECTIONS}
2457 .Sp
2458 A second constraint on the section ordering script is that it can only
2459 reference output sections that are already defined by whichever linker
2460 script is currently in use. (Ie the default linker script or a script
2461 specified on the command line). The benefit of the section ordering
2462 script however is that the input sections are mapped to the start of
2463 the output sections, so that they can ensure the ordering of sections
2464 in the output section. For example, imagine that the default linker
2465 script looks like this:
2466 .Sp
2467 .Vb 4
2468 \& SECTIONS {
2469 \& .text : { *(.text.hot) ; *(.text .text.*) }
2470 \& .data : { *(.data.big) ; *(.data .data.*) }
2471 \& }
2472 .Ve
2473 .Sp
2474 Then if a section ordering file like this is used:
2475 .Sp
2476 .Vb 2
2477 \& .text : { *(.text.first) ; *(.text.z*) }
2478 \& .data : { foo.o(.data.first) ; *(.data.small) }
2479 .Ve
2480 .Sp
2481 This would be equivalent to a linker script like this:
2482 .Sp
2483 .Vb 4
2484 \& SECTIONS {
2485 \& .text : { *(.text.first) ; *(.text.z*) ; *(.text.hot) ; *(.text .text.*) }
2486 \& .data : { foo.o(.data.first) ; *(.data.small) ; *(.data.big) ; *(.data .data.*) }
2487 \& }
2488 .Ve
2489 .Sp
2490 The advantage of the section ordering file is that it can be used to
2491 order those sections that matter to the user without having to worry
2492 about any other sections, or memory regions, or anything else.
2493 .IP \fB\-shared\fR 4
2494 .IX Item "-shared"
2495 .PD 0
2496 .IP \fB\-Bshareable\fR 4
2497 .IX Item "-Bshareable"
2498 .PD
2499 Create a shared library. This is currently only supported on ELF, XCOFF
2500 and SunOS platforms. On SunOS, the linker will automatically create a
2501 shared library if the \fB\-e\fR option is not used and there are
2502 undefined symbols in the link.
2503 .IP \fB\-\-sort\-common\fR 4
2504 .IX Item "--sort-common"
2505 .PD 0
2506 .IP \fB\-\-sort\-common=ascending\fR 4
2507 .IX Item "--sort-common=ascending"
2508 .IP \fB\-\-sort\-common=descending\fR 4
2509 .IX Item "--sort-common=descending"
2510 .PD
2511 This option tells \fBld\fR to sort the common symbols by alignment in
2512 ascending or descending order when it places them in the appropriate output
2513 sections. The symbol alignments considered are sixteen\-byte or larger,
2514 eight\-byte, four\-byte, two\-byte, and one\-byte. This is to prevent gaps
2515 between symbols due to alignment constraints. If no sorting order is
2516 specified, then descending order is assumed.
2517 .IP \fB\-\-sort\-section=name\fR 4
2518 .IX Item "--sort-section=name"
2519 This option will apply \f(CW\*(C`SORT_BY_NAME\*(C'\fR to all wildcard section
2520 patterns in the linker script.
2521 .IP \fB\-\-sort\-section=alignment\fR 4
2522 .IX Item "--sort-section=alignment"
2523 This option will apply \f(CW\*(C`SORT_BY_ALIGNMENT\*(C'\fR to all wildcard section
2524 patterns in the linker script.
2525 .IP \fB\-\-spare\-dynamic\-tags=\fR\fIcount\fR 4
2526 .IX Item "--spare-dynamic-tags=count"
2527 This option specifies the number of empty slots to leave in the
2528 \&.dynamic section of ELF shared objects. Empty slots may be needed by
2529 post processing tools, such as the prelinker. The default is 5.
2530 .IP \fB\-\-split\-by\-file[=\fR\fIsize\fR\fB]\fR 4
2531 .IX Item "--split-by-file[=size]"
2532 Similar to \fB\-\-split\-by\-reloc\fR but creates a new output section for
2533 each input file when \fIsize\fR is reached. \fIsize\fR defaults to a
2534 size of 1 if not given.
2535 .IP \fB\-\-split\-by\-reloc[=\fR\fIcount\fR\fB]\fR 4
2536 .IX Item "--split-by-reloc[=count]"
2537 Tries to creates extra sections in the output file so that no single
2538 output section in the file contains more than \fIcount\fR relocations.
2539 This is useful when generating huge relocatable files for downloading into
2540 certain real time kernels with the COFF object file format; since COFF
2541 cannot represent more than 65535 relocations in a single section. Note
2542 that this will fail to work with object file formats which do not
2543 support arbitrary sections. The linker will not split up individual
2544 input sections for redistribution, so if a single input section contains
2545 more than \fIcount\fR relocations one output section will contain that
2546 many relocations. \fIcount\fR defaults to a value of 32768.
2547 .IP \fB\-\-stats[=\fR\fIfilename\fR\fB]\fR 4
2548 .IX Item "--stats[=filename]"
2549 Compute and display statistics about the operation of the linker, such
2550 as execution time and memory usage.
2551 .Sp
2552 If the optional \fIfilename\fR argument is not supplied then only
2553 basic information is reported, and it is sent to the standard error
2554 output stream. If the \fIfilename\fR argument is supplied then
2555 extended information is written to the named file. If \fIfilename\fR
2556 is set to just the \fI\-\fR symbol, then the extended information is
2557 sent to the standard output stream. If the \fIfilename\fR starts with
2558 \&\fI+\fR then the file is opened in append mode rather than overwrite
2559 mode.
2560 .Sp
2561 If the \fB\-Map\fR option has been enabled then the information is
2562 also recorded in the map file as well. Note: if both the
2563 \&\fB\-\-stats\fR option and the \fB\-Map\fR options have been given
2564 \&\fIfilename\fR arguments and they match, then the information will
2565 only be written out once not twice.
2566 .Sp
2567 If the \f(CW\*(C`LD_STATS\*(C'\fR environment variable is defined then this
2568 behaves likes the \fB\-\-stats\fR option. If the variable\*(Aqs value is
2569 a string then this will used as the name of a file into which the
2570 information should be recorded. Otherwise the information
2571 will be sent to the standard output stream. Using the environment
2572 variable allows stats to be recorded without having to alter the
2573 linker\*(Aqs command line. Note: if both the environment variable and the
2574 \&\fB\-\-stats\fR option are used then the \fB\-\-stats\fR option
2575 takes precedence.
2576 .Sp
2577 The extended information reported includes the cpu time used and, if
2578 the \fR\f(BIgetrusage()\fR\fI\fR system library call is available then maximum
2579 set size and the user and system run times as well. In addition if
2580 the \fImallinfo\fR or \fImallinfo2\fR system library calls are
2581 available then the total memory usage is reported,
2582 .Sp
2583 The information is displayed for individual parts of the linking
2584 process which are referred to as \fIphases\fR. Note that
2585 individual phases can contain or overlap with each other so it should
2586 not be assumed that the overall resources used by the linker is the
2587 sum of the resources used by the individual phases.
2588 .Sp
2589 In addition the information is also reported for a special phase
2590 called \fIALL\fR which covers the entire linking process.
2591 .Sp
2592 When extended information is being reported the linker version,
2593 command line arguments and linker start time are also included. This
2594 makes it easier to handle the situation where multiple links are being
2595 invoked by a build system and to indentify exactly which arguments
2596 were responsible for producing the statistics that are reported.
2597 .Sp
2598 The extended output looks something like this:
2599 .Sp
2600 .Vb 3
2601 \& Stats: linker version: (GNU Binutils) 2.44.50.20250401
2602 \& Stats: linker started: Wed Apr 2 09:36:41 2025
2603 \& Stats: args: ld \-z norelro \-z nomemory\-seal \-z no\-separate\-code \-o a.out [...]
2604 \&
2605 \& Stats: phase cpu time rss user time system time memory
2606 \& Stats: name (microsec) (KiB) (seconds) (seconds) (KiB)
2607 \& Stats: ALL 390082 217740 0 0 25219440
2608 \& Stats: ctf processing 12 0 0 0 0
2609 \& Stats: string merge 1324 0 0 0 406544
2610 \& Stats: parsing 349 288 0 0 119792
2611 \& Stats: plugins 1 0 0 0 0
2612 \& Stats: processing files 259616 214524 0 0 31569120
2613 \& Stats: write 116493 0 0 0 48096
2614 .Ve
2615 .IP \fB\-\-no\-stats\fR 4
2616 .IX Item "--no-stats"
2617 Disables the reporting of usage statistics, should it have been
2618 enabled via the \fB\-\-stats\fR command line option or the
2619 \&\fILD_STATS\fR environment variable.
2620 .IP \fB\-\-sysroot=\fR\fIdirectory\fR 4
2621 .IX Item "--sysroot=directory"
2622 Use \fIdirectory\fR as the location of the sysroot, overriding the
2623 configure\-time default. This option is only supported by linkers
2624 that were configured using \fB\-\-with\-sysroot\fR.
2625 .IP \fB\-\-task\-link\fR 4
2626 .IX Item "--task-link"
2627 This is used by COFF/PE based targets to create a task\-linked object
2628 file where all of the global symbols have been converted to statics.
2629 .IP \fB\-\-traditional\-format\fR 4
2630 .IX Item "--traditional-format"
2631 For some targets, the output of \fBld\fR is different in some ways from
2632 the output of some existing linker. This switch requests \fBld\fR to
2633 use the traditional format instead.
2634 .Sp
2635 For example, on SunOS, \fBld\fR combines duplicate entries in the
2636 symbol string table. This can reduce the size of an output file with
2637 full debugging information by over 30 percent. Unfortunately, the SunOS
2638 \&\f(CW\*(C`dbx\*(C'\fR program can not read the resulting program (\f(CW\*(C`gdb\*(C'\fR has no
2639 trouble). The \fB\-\-traditional\-format\fR switch tells \fBld\fR to not
2640 combine duplicate entries.
2641 .IP \fB\-\-section\-start=\fR\fIsectionname\fR\fB=\fR\fIorg\fR 4
2642 .IX Item "--section-start=sectionname=org"
2643 Locate a section in the output file at the absolute
2644 address given by \fIorg\fR. You may use this option as many
2645 times as necessary to locate multiple sections in the command
2646 line.
2647 \&\fIorg\fR must be a single hexadecimal integer;
2648 for compatibility with other linkers, you may omit the leading
2649 \&\fB0x\fR usually associated with hexadecimal values. \fINote:\fR there
2650 should be no white space between \fIsectionname\fR, the equals
2651 sign ("\fB=\fR"), and \fIorg\fR.
2652 .IP \fB\-\-image\-base=\fR\fIorg\fR 4
2653 .IX Item "--image-base=org"
2654 When using ELF, same as \fB\-Ttext\-segment\fR, with both options effectively
2655 setting the base address of the ELF executable.
2656 .Sp
2657 When using PE, use \fIvalue\fR as the base address of your program or dll.
2658 This is the lowest memory location that will be used when your program or
2659 dll is loaded. To reduce the need to relocate and improve performance of
2660 your dlls, each should have a unique base address and not overlap any
2661 other dlls. The default is 0x400000 for executables, and 0x10000000
2662 for dlls.
2663 .IP \fB\-Tbss=\fR\fIorg\fR 4
2664 .IX Item "-Tbss=org"
2665 .PD 0
2666 .IP \fB\-Tdata=\fR\fIorg\fR 4
2667 .IX Item "-Tdata=org"
2668 .IP \fB\-Ttext=\fR\fIorg\fR 4
2669 .IX Item "-Ttext=org"
2670 .PD
2671 Same as \fB\-\-section\-start\fR, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or
2672 \&\f(CW\*(C`.text\*(C'\fR as the \fIsectionname\fR.
2673 .IP \fB\-Ttext\-segment=\fR\fIorg\fR 4
2674 .IX Item "-Ttext-segment=org"
2675 When creating an ELF executable, it will set the address of the first
2676 byte of the first segment. Note that when \fB\-pie\fR is used with
2677 \&\fB\-Ttext\-segment=\fR\fIorg\fR, the output executable is marked
2678 ET_EXEC so that the address of the first byte of the text segment will
2679 be guaranteed to be \fIorg\fR at run time.
2680 .IP \fB\-Trodata\-segment=\fR\fIorg\fR 4
2681 .IX Item "-Trodata-segment=org"
2682 When creating an ELF executable or shared object for a target where
2683 the read\-only data is in its own segment separate from the executable
2684 text, it will set the address of the first byte of the read\-only data segment.
2685 .IP \fB\-Tldata\-segment=\fR\fIorg\fR 4
2686 .IX Item "-Tldata-segment=org"
2687 When creating an ELF executable or shared object for x86\-64 medium memory
2688 model, it will set the address of the first byte of the ldata segment.
2689 .IP \fB\-\-unresolved\-symbols=\fR\fImethod\fR 4
2690 .IX Item "--unresolved-symbols=method"
2691 Determine how to handle unresolved symbols. There are four possible
2692 values for \fBmethod\fR:
2693 .RS 4
2694 .IP \fBignore\-all\fR 4
2695 .IX Item "ignore-all"
2696 Do not report any unresolved symbols.
2697 .IP \fBreport\-all\fR 4
2698 .IX Item "report-all"
2699 Report all unresolved symbols. This is the default.
2700 .IP \fBignore\-in\-object\-files\fR 4
2701 .IX Item "ignore-in-object-files"
2702 Report unresolved symbols that are contained in shared libraries, but
2703 ignore them if they come from regular object files.
2704 .IP \fBignore\-in\-shared\-libs\fR 4
2705 .IX Item "ignore-in-shared-libs"
2706 Report unresolved symbols that come from regular object files, but
2707 ignore them if they come from shared libraries. This can be useful
2708 when creating a dynamic binary and it is known that all the shared
2709 libraries that it should be referencing are included on the linker\*(Aqs
2710 command line.
2711 .RE
2712 .RS 4
2713 .Sp
2714 The behaviour for shared libraries on their own can also be controlled
2715 by the \fB\-\-[no\-]allow\-shlib\-undefined\fR option.
2716 .Sp
2717 Normally the linker will generate an error message for each reported
2718 unresolved symbol but the option \fB\-\-warn\-unresolved\-symbols\fR
2719 can change this to a warning.
2720 .RE
2721 .IP \fB\-\-dll\-verbose\fR 4
2722 .IX Item "--dll-verbose"
2723 .PD 0
2724 .IP \fB\-\-verbose[=\fR\fINUMBER\fR\fB]\fR 4
2725 .IX Item "--verbose[=NUMBER]"
2726 .PD
2727 Display the version number for \fBld\fR and list the linker emulations
2728 supported. Display which input files can and cannot be opened. Display
2729 the linker script being used by the linker. If the optional \fINUMBER\fR
2730 argument > 1, plugin symbol status will also be displayed.
2731 .IP \fB\-\-version\-script=\fR\fIversion\-scriptfile\fR 4
2732 .IX Item "--version-script=version-scriptfile"
2733 Specify the name of a version script to the linker. This is typically
2734 used when creating shared libraries to specify additional information
2735 about the version hierarchy for the library being created. This option
2736 is only fully supported on ELF platforms which support shared libraries;
2737 see \fBVERSION\fR. It is partially supported on PE platforms, which can
2738 use version scripts to filter symbol visibility in auto\-export mode: any
2739 symbols marked \fBlocal\fR in the version script will not be exported.
2740 .IP \fB\-\-warn\-common\fR 4
2741 .IX Item "--warn-common"
2742 Warn when a common symbol is combined with another common symbol or with
2743 a symbol definition. Unix linkers allow this somewhat sloppy practice,
2744 but linkers on some other operating systems do not. This option allows
2745 you to find potential problems from combining global symbols.
2746 Unfortunately, some C libraries use this practice, so you may get some
2747 warnings about symbols in the libraries as well as in your programs.
2748 .Sp
2749 There are three kinds of global symbols, illustrated here by C examples:
2750 .RS 4
2751 .IP "\fBint i = 1;\fR" 4
2752 .IX Item "int i = 1;"
2753 A definition, which goes in the initialized data section of the output
2754 file.
2755 .IP "\fBextern int i;\fR" 4
2756 .IX Item "extern int i;"
2757 An undefined reference, which does not allocate space.
2758 There must be either a definition or a common symbol for the
2759 variable somewhere.
2760 .IP "\fBint i;\fR" 4
2761 .IX Item "int i;"
2762 A common symbol. If there are only (one or more) common symbols for a
2763 variable, it goes in the uninitialized data area of the output file.
2764 The linker merges multiple common symbols for the same variable into a
2765 single symbol. If they are of different sizes, it picks the largest
2766 size. The linker turns a common symbol into a declaration, if there is
2767 a definition of the same variable.
2768 .RE
2769 .RS 4
2770 .Sp
2771 The \fB\-\-warn\-common\fR option can produce five kinds of warnings.
2772 Each warning consists of a pair of lines: the first describes the symbol
2773 just encountered, and the second describes the previous symbol
2774 encountered with the same name. One or both of the two symbols will be
2775 a common symbol.
2776 .IP 1. 4
2777 Turning a common symbol into a reference, because there is already a
2778 definition for the symbol.
2779 .Sp
2780 .Vb 3
2781 \& <file>(<section>): warning: common of \`<symbol>\*(Aq
2782 \& overridden by definition
2783 \& <file>(<section>): warning: defined here
2784 .Ve
2785 .IP 2. 4
2786 Turning a common symbol into a reference, because a later definition for
2787 the symbol is encountered. This is the same as the previous case,
2788 except that the symbols are encountered in a different order.
2789 .Sp
2790 .Vb 3
2791 \& <file>(<section>): warning: definition of \`<symbol>\*(Aq
2792 \& overriding common
2793 \& <file>(<section>): warning: common is here
2794 .Ve
2795 .IP 3. 4
2796 Merging a common symbol with a previous same\-sized common symbol.
2797 .Sp
2798 .Vb 3
2799 \& <file>(<section>): warning: multiple common
2800 \& of \`<symbol>\*(Aq
2801 \& <file>(<section>): warning: previous common is here
2802 .Ve
2803 .IP 4. 4
2804 Merging a common symbol with a previous larger common symbol.
2805 .Sp
2806 .Vb 3
2807 \& <file>(<section>): warning: common of \`<symbol>\*(Aq
2808 \& overridden by larger common
2809 \& <file>(<section>): warning: larger common is here
2810 .Ve
2811 .IP 5. 4
2812 Merging a common symbol with a previous smaller common symbol. This is
2813 the same as the previous case, except that the symbols are
2814 encountered in a different order.
2815 .Sp
2816 .Vb 3
2817 \& <file>(<section>): warning: common of \`<symbol>\*(Aq
2818 \& overriding smaller common
2819 \& <file>(<section>): warning: smaller common is here
2820 .Ve
2821 .RE
2822 .RS 4
2823 .RE
2824 .IP \fB\-\-warn\-constructors\fR 4
2825 .IX Item "--warn-constructors"
2826 Warn if any global constructors are used. This is only useful for a few
2827 object file formats. For formats like COFF or ELF, the linker can not
2828 detect the use of global constructors.
2829 .IP \fB\-\-warn\-execstack\fR 4
2830 .IX Item "--warn-execstack"
2831 .PD 0
2832 .IP \fB\-\-warn\-execstack\-objects\fR 4
2833 .IX Item "--warn-execstack-objects"
2834 .IP \fB\-\-no\-warn\-execstack\fR 4
2835 .IX Item "--no-warn-execstack"
2836 .PD
2837 On ELF platforms the linker may generate warning messages if it is
2838 asked to create an output file that contains an executable stack.
2839 There are three possible states:
2840 .RS 4
2841 .IP 1. 4
2842 Do not generate any warnings.
2843 .IP 2. 4
2844 Always generate warnings, even if the executable stack is requested
2845 via the \fB\-z execstack\fR command line option.
2846 .IP 3. 4
2847 Only generate a warning if an object file requests an executable
2848 stack, but not if the \fB\-z execstack\fR option is used.
2849 .RE
2850 .RS 4
2851 .Sp
2852 The default state depends upon how the linker was configured when it
2853 was built. The \fB\-\-no\-warn\-execstack\fR option always puts the
2854 linker into the no\-warnings state. The \fB\-\-warn\-execstack\fR
2855 option puts the linker into the warn\-always state. The
2856 \&\fB\-\-warn\-execstack\-objects\fR option puts the linker into the
2857 warn\-for\-object\-files\-only state.
2858 .Sp
2859 Note: ELF format input files can specify that they need an executable
2860 stack by having a \fI.note.GNU\-stack\fR section with the executable
2861 bit set in its section flags. They can specify that they do not need
2862 an executable stack by having the same section, but without the
2863 executable flag bit set. If an input file does not have a
2864 \&\fI.note.GNU\-stack\fR section then the default behaviour is target
2865 specific. For some targets, then absence of such a section implies
2866 that an executable stack \fIis\fR required. This is often a problem
2867 for hand crafted assembler files.
2868 .RE
2869 .IP \fB\-\-error\-execstack\fR 4
2870 .IX Item "--error-execstack"
2871 .PD 0
2872 .IP \fB\-\-no\-error\-execstack\fR 4
2873 .IX Item "--no-error-execstack"
2874 .PD
2875 If the linker is going to generate a warning message about an
2876 executable stack then the \fB\-\-error\-execstack\fR option will
2877 instead change that warning into an error. Note \- this option does
2878 not change the linker\*(Aqs execstack warning generation state. Use
2879 \&\fB\-\-warn\-execstack\fR or \fB\-\-warn\-execstack\-objects\fR to set
2880 a specific warning state.
2881 .Sp
2882 The \fB\-\-no\-error\-execstack\fR option will restore the default
2883 behaviour of generating warning messages.
2884 .IP \fB\-\-warn\-multiple\-gp\fR 4
2885 .IX Item "--warn-multiple-gp"
2886 Warn if multiple global pointer values are required in the output file.
2887 This is only meaningful for certain processors, such as the Alpha.
2888 Specifically, some processors put large\-valued constants in a special
2889 section. A special register (the global pointer) points into the middle
2890 of this section, so that constants can be loaded efficiently via a
2891 base\-register relative addressing mode. Since the offset in
2892 base\-register relative mode is fixed and relatively small (e.g., 16
2893 bits), this limits the maximum size of the constant pool. Thus, in
2894 large programs, it is often necessary to use multiple global pointer
2895 values in order to be able to address all possible constants. This
2896 option causes a warning to be issued whenever this case occurs.
2897 .IP \fB\-\-warn\-once\fR 4
2898 .IX Item "--warn-once"
2899 Only warn once for each undefined symbol, rather than once per module
2900 which refers to it.
2901 .IP \fB\-\-warn\-rwx\-segments\fR 4
2902 .IX Item "--warn-rwx-segments"
2903 .PD 0
2904 .IP \fB\-\-no\-warn\-rwx\-segments\fR 4
2905 .IX Item "--no-warn-rwx-segments"
2906 .PD
2907 Warn if the linker creates a loadable, non\-zero sized segment that has
2908 all three of the read, write and execute permission flags set. Such a
2909 segment represents a potential security vulnerability. In addition
2910 warnings will be generated if a thread local storage segment is
2911 created with the execute permission flag set, regardless of whether or
2912 not it has the read and/or write flags set.
2913 .Sp
2914 These warnings are enabled by default. They can be disabled via the
2915 \&\fB\-\-no\-warn\-rwx\-segments\fR option and re\-enabled via the
2916 \&\fB\-\-warn\-rwx\-segments\fR option.
2917 .IP \fB\-\-error\-rwx\-segments\fR 4
2918 .IX Item "--error-rwx-segments"
2919 .PD 0
2920 .IP \fB\-\-no\-error\-rwx\-segments\fR 4
2921 .IX Item "--no-error-rwx-segments"
2922 .PD
2923 If the linker is going to generate a warning message about an
2924 executable, writeable segment, or an executable TLS segment, then the
2925 \&\fB\-\-error\-rwx\-segments\fR option will turn this warning into an
2926 error instead. The \fB\-\-no\-error\-rwx\-segments\fR option will
2927 restore the default behaviour of just generating a warning message.
2928 .Sp
2929 Note \- the \fB\-\-error\-rwx\-segments\fR option does not by itself
2930 turn on warnings about these segments. These warnings are either
2931 enabled by default, if the linker was configured that way, or via the
2932 \&\fB\-\-warn\-rwx\-segments\fR command line option.
2933 .IP \fB\-\-warn\-section\-align\fR 4
2934 .IX Item "--warn-section-align"
2935 Warn if the address of an output section is changed because of
2936 alignment. Typically, the alignment will be set by an input section.
2937 The address will only be changed if it not explicitly specified; that
2938 is, if the \f(CW\*(C`SECTIONS\*(C'\fR command does not specify a start address for
2939 the section.
2940 .IP \fB\-\-warn\-textrel\fR 4
2941 .IX Item "--warn-textrel"
2942 Warn if the linker adds DT_TEXTREL to a position\-independent executable
2943 or shared object.
2944 .IP \fB\-\-warn\-alternate\-em\fR 4
2945 .IX Item "--warn-alternate-em"
2946 Warn if an object has alternate ELF machine code.
2947 .IP \fB\-\-warn\-unresolved\-symbols\fR 4
2948 .IX Item "--warn-unresolved-symbols"
2949 If the linker is going to report an unresolved symbol (see the option
2950 \&\fB\-\-unresolved\-symbols\fR) it will normally generate an error.
2951 This option makes it generate a warning instead.
2952 .IP \fB\-\-error\-unresolved\-symbols\fR 4
2953 .IX Item "--error-unresolved-symbols"
2954 This restores the linker\*(Aqs default behaviour of generating errors when
2955 it is reporting unresolved symbols.
2956 .IP \fB\-\-whole\-archive\fR 4
2957 .IX Item "--whole-archive"
2958 For each archive mentioned on the command line after the
2959 \&\fB\-\-whole\-archive\fR option, include every object file in the archive
2960 in the link, rather than searching the archive for the required object
2961 files. This is normally used to turn an archive file into a shared
2962 library, forcing every object to be included in the resulting shared
2963 library. This option may be used more than once.
2964 .Sp
2965 This option is not allowed within a \fB\-\-start\-lib\fR/\fB\-\-end\-lib\fR
2966 option pair.
2967 .Sp
2968 Two notes when using this option from gcc: First, gcc doesn\*(Aqt know
2969 about this option, so you have to use \fB\-Wl,\-whole\-archive\fR.
2970 Second, don\*(Aqt forget to use \fB\-Wl,\-no\-whole\-archive\fR after your
2971 list of archives, because gcc will add its own list of archives to
2972 your link and you may not want this flag to affect those as well.
2973 .IP \fB\-\-link\-mapless\fR 4
2974 .IX Item "--link-mapless"
2975 Accept archives that lack an index aka symbol map for all the subsequent
2976 archives referred on the command line. If missing, such an index is made
2977 internally on the fly at performance cost. This is the default.
2978 .IP \fB\-\-wrap=\fR\fIsymbol\fR 4
2979 .IX Item "--wrap=symbol"
2980 Use a wrapper function for \fIsymbol\fR. Any undefined reference to
2981 \&\fIsymbol\fR will be resolved to \f(CW\*(C`_\|_wrap_\fR\f(CIsymbol\fR\f(CW\*(C'\fR. Any
2982 undefined reference to \f(CW\*(C`_\|_real_\fR\f(CIsymbol\fR\f(CW\*(C'\fR will be resolved to
2983 \&\fIsymbol\fR.
2984 .Sp
2985 This can be used to provide a wrapper for a system function. The
2986 wrapper function should be called \f(CW\*(C`_\|_wrap_\fR\f(CIsymbol\fR\f(CW\*(C'\fR. If it
2987 wishes to call the system function, it should call
2988 \&\f(CW\*(C`_\|_real_\fR\f(CIsymbol\fR\f(CW\*(C'\fR.
2989 .Sp
2990 Here is a trivial example:
2991 .Sp
2992 .Vb 6
2993 \& void *
2994 \& _\|_wrap_malloc (size_t c)
2995 \& {
2996 \& printf ("malloc called with %zu\en", c);
2997 \& return _\|_real_malloc (c);
2998 \& }
2999 .Ve
3000 .Sp
3001 If you link other code with this file using \fB\-\-wrap malloc\fR, then
3002 all calls to \f(CW\*(C`malloc\*(C'\fR will call the function \f(CW\*(C`_\|_wrap_malloc\*(C'\fR
3003 instead. The call to \f(CW\*(C`_\|_real_malloc\*(C'\fR in \f(CW\*(C`_\|_wrap_malloc\*(C'\fR will
3004 call the real \f(CW\*(C`malloc\*(C'\fR function.
3005 .Sp
3006 You may wish to provide a \f(CW\*(C`_\|_real_malloc\*(C'\fR function as well, so that
3007 links without the \fB\-\-wrap\fR option will succeed. If you do this,
3008 you should not put the definition of \f(CW\*(C`_\|_real_malloc\*(C'\fR in the same
3009 file as \f(CW\*(C`_\|_wrap_malloc\*(C'\fR; if you do, the assembler may resolve the
3010 call before the linker has a chance to wrap it to \f(CW\*(C`malloc\*(C'\fR.
3011 .Sp
3012 Only undefined references are replaced by the linker. So, translation unit
3013 internal references to \fIsymbol\fR are not resolved to
3014 \&\f(CW\*(C`_\|_wrap_\fR\f(CIsymbol\fR\f(CW\*(C'\fR. In the next example, the call to \f(CW\*(C`f\*(C'\fR in
3015 \&\f(CW\*(C`g\*(C'\fR is not resolved to \f(CW\*(C`_\|_wrap_f\*(C'\fR.
3016 .Sp
3017 .Vb 5
3018 \& int
3019 \& f (void)
3020 \& {
3021 \& return 123;
3022 \& }
3023 \&
3024 \& int
3025 \& g (void)
3026 \& {
3027 \& return f();
3028 \& }
3029 .Ve
3030 .IP \fB\-\-eh\-frame\-hdr\fR 4
3031 .IX Item "--eh-frame-hdr"
3032 .PD 0
3033 .IP \fB\-\-no\-eh\-frame\-hdr\fR 4
3034 .IX Item "--no-eh-frame-hdr"
3035 .PD
3036 Request (\fB\-\-eh\-frame\-hdr\fR) or suppress
3037 (\fB\-\-no\-eh\-frame\-hdr\fR) the creation of \f(CW\*(C`.eh_frame_hdr\*(C'\fR
3038 section and ELF \f(CW\*(C`PT_GNU_EH_FRAME\*(C'\fR segment header.
3039 .IP \fB\-\-no\-ld\-generated\-unwind\-info\fR 4
3040 .IX Item "--no-ld-generated-unwind-info"
3041 Request creation of \f(CW\*(C`.eh_frame\*(C'\fR unwind info for linker
3042 generated code sections like PLT. This option is on by default
3043 if linker generated unwind info is supported.
3044 .IP \fB\-\-discard\-sframe\fR 4
3045 .IX Item "--discard-sframe"
3046 Discard \f(CW\*(C`.sframe\*(C'\fR stack trace info from the output. This option also
3047 prohibits the creation of SFrame stack trace data for linker generated code
3048 sections like PLT. This option is off by default.
3049 .IP \fB\-\-enable\-new\-dtags\fR 4
3050 .IX Item "--enable-new-dtags"
3051 .PD 0
3052 .IP \fB\-\-disable\-new\-dtags\fR 4
3053 .IX Item "--disable-new-dtags"
3054 .PD
3055 This linker can create the new dynamic tags in ELF. But the older ELF
3056 systems may not understand them. If you specify
3057 \&\fB\-\-enable\-new\-dtags\fR, the new dynamic tags will be created as needed
3058 and older dynamic tags will be omitted.
3059 If you specify \fB\-\-disable\-new\-dtags\fR, no new dynamic tags will be
3060 created. By default, the new dynamic tags are not created. Note that
3061 those options are only available for ELF systems.
3062 .IP \fB\-\-hash\-size=\fR\fInumber\fR 4
3063 .IX Item "--hash-size=number"
3064 Set the default size of the linker\*(Aqs hash tables to a prime number
3065 close to \fInumber\fR. Increasing this value can reduce the length of
3066 time it takes the linker to perform its tasks, at the expense of
3067 increasing the linker\*(Aqs memory requirements. Similarly reducing this
3068 value can reduce the memory requirements at the expense of speed.
3069 The default value is 4051 under normal circumstances and 1021 if the
3070 \&\fB\-\-reduce\-memory\-overheads\fR command line option is used.
3071 .IP \fB\-\-hash\-style=\fR\fIstyle\fR 4
3072 .IX Item "--hash-style=style"
3073 Set the type of linker\*(Aqs hash table(s). \fIstyle\fR can be either
3074 \&\f(CW\*(C`sysv\*(C'\fR for classic ELF \f(CW\*(C`.hash\*(C'\fR section, \f(CW\*(C`gnu\*(C'\fR for
3075 new style GNU \f(CW\*(C`.gnu.hash\*(C'\fR section or \f(CW\*(C`both\*(C'\fR for both
3076 the classic ELF \f(CW\*(C`.hash\*(C'\fR and new style GNU \f(CW\*(C`.gnu.hash\*(C'\fR
3077 hash tables. The default depends upon how the linker was configured,
3078 but for most Linux based systems it will be \f(CW\*(C`both\*(C'\fR.
3079 .IP \fB\-\-compress\-debug\-sections=none\fR 4
3080 .IX Item "--compress-debug-sections=none"
3081 .PD 0
3082 .IP \fB\-\-compress\-debug\-sections=zlib\fR 4
3083 .IX Item "--compress-debug-sections=zlib"
3084 .IP \fB\-\-compress\-debug\-sections=zlib\-gnu\fR 4
3085 .IX Item "--compress-debug-sections=zlib-gnu"
3086 .IP \fB\-\-compress\-debug\-sections=zlib\-gabi\fR 4
3087 .IX Item "--compress-debug-sections=zlib-gabi"
3088 .IP \fB\-\-compress\-debug\-sections=zstd\fR 4
3089 .IX Item "--compress-debug-sections=zstd"
3090 .PD
3091 On ELF platforms, these options control how DWARF debug sections are
3092 compressed using zlib.
3093 .Sp
3094 \&\fB\-\-compress\-debug\-sections=none\fR doesn\*(Aqt compress DWARF debug
3095 sections. \fB\-\-compress\-debug\-sections=zlib\-gnu\fR compresses
3096 DWARF debug sections and renames them to begin with \fB.zdebug\fR
3097 instead of \fB.debug\fR. \fB\-\-compress\-debug\-sections=zlib\-gabi\fR
3098 also compresses DWARF debug sections, but rather than renaming them it
3099 sets the SHF_COMPRESSED flag in the sections\*(Aq headers.
3100 .Sp
3101 The \fB\-\-compress\-debug\-sections=zlib\fR option is an alias for
3102 \&\fB\-\-compress\-debug\-sections=zlib\-gabi\fR.
3103 .Sp
3104 \&\fB\-\-compress\-debug\-sections=zstd\fR compresses DWARF debug sections using
3105 zstd.
3106 .Sp
3107 Note that this option overrides any compression in input debug
3108 sections, so if a binary is linked with \fB\-\-compress\-debug\-sections=none\fR
3109 for example, then any compressed debug sections in input files will be
3110 uncompressed before they are copied into the output binary.
3111 .Sp
3112 The default compression behaviour varies depending upon the target
3113 involved and the configure options used to build the toolchain. The
3114 default can be determined by examining the output from the linker\*(Aqs
3115 \&\fB\-\-help\fR option.
3116 .IP \fB\-\-reduce\-memory\-overheads\fR 4
3117 .IX Item "--reduce-memory-overheads"
3118 This option reduces memory requirements at ld runtime, at the expense of
3119 linking speed. This was introduced to select the old O(n^2) algorithm
3120 for link map file generation, rather than the new O(n) algorithm which uses
3121 about 40% more memory for symbol storage.
3122 .Sp
3123 Another effect of the switch is to set the default hash table size to
3124 1021, which again saves memory at the cost of lengthening the linker\*(Aqs
3125 run time. This is not done however if the \fB\-\-hash\-size\fR switch
3126 has been used.
3127 .Sp
3128 The \fB\-\-reduce\-memory\-overheads\fR switch may be also be used to
3129 enable other tradeoffs in future versions of the linker.
3130 .IP \fB\-\-max\-cache\-size=\fR\fIsize\fR 4
3131 .IX Item "--max-cache-size=size"
3132 \&\fBld\fR normally caches the relocation information and symbol tables
3133 of input files in memory with the unlimited size. This option sets the
3134 maximum cache size to \fIsize\fR. Note \- if the
3135 \&\fB\-\-no\-keep\-memory\fR command line option has been used then the
3136 linker acts as if the maximum cache size has been set to 0 \- ie
3137 nothing is retained.
3138 .IP \fB\-\-build\-id\fR 4
3139 .IX Item "--build-id"
3140 .PD 0
3141 .IP \fB\-\-build\-id=\fR\fIstyle\fR 4
3142 .IX Item "--build-id=style"
3143 .PD
3144 Request the creation of a \f(CW\*(C`.note.gnu.build\-id\*(C'\fR ELF note section
3145 or a \f(CW\*(C`.buildid\*(C'\fR COFF section. The contents of the note are
3146 unique bits identifying this linked file. \fIstyle\fR can be
3147 \&\f(CW\*(C`uuid\*(C'\fR to use 128 random bits; \f(CW\*(C`sha1\*(C'\fR to use a 160\-bit
3148 SHA1 hash, \f(CW\*(C`md5\*(C'\fR to use a 128\-bit MD5 hash, or \f(CW\*(C`xx\*(C'\fR
3149 to use a 128\-bit XXHASH on the normative parts of the output
3150 contents; or \f(CW\*(C`0x\fR\f(CIhexstring\fR\f(CW\*(C'\fR to use a chosen bit string
3151 specified as an even number of hexadecimal digits (\f(CW\*(C`\-\*(C'\fR and
3152 \&\f(CW\*(C`:\*(C'\fR characters between digit pairs are ignored). If \fIstyle\fR
3153 is omitted, \f(CW\*(C`sha1\*(C'\fR is used.
3154 .Sp
3155 The \f(CW\*(C`md5\*(C'\fR, \f(CW\*(C`sha1\*(C'\fR, and \f(CW\*(C`xx\*(C'\fR styles produces an
3156 identifier that is always the same in an identical output file, but
3157 are almost certainly unique among all nonidentical output files. It
3158 is not intended to be compared as a checksum for the file\*(Aqs contents.
3159 A linked file may be changed later by other tools, but the build ID
3160 bit string identifying the original linked file does not change.
3161 .Sp
3162 Passing \f(CW\*(C`none\*(C'\fR for \fIstyle\fR disables the setting from any
3163 \&\f(CW\*(C`\-\-build\-id\*(C'\fR options earlier on the command line.
3164 .IP \fB\-\-package\-metadata=\fR\fIJSON\fR 4
3165 .IX Item "--package-metadata=JSON"
3166 Request the creation of a \f(CW\*(C`.note.package\*(C'\fR ELF note section. The
3167 contents of the note are in JSON format, as per the package metadata
3168 specification. For more information see:
3169 https://systemd.io/ELF_PACKAGE_METADATA/
3170 The JSON argument support percent\-encoding and following %[string]
3171 (where string refers to the name in HTML\*(Aqs Named Character References)
3172 encoding: \fB%[comma]\fR for \fB,\fR, \fB%[lbrace]\fR for \fB{\fR,
3173 \&\fB%[quot]\fR for \fB"\fR, \fB%[rbrace]\fR for \fB}\fR, and
3174 \&\fB%[space]\fR for space character.
3175 If the JSON argument is missing/empty then this will disable the
3176 creation of the metadata note, if one had been enabled by an earlier
3177 occurrence of the \-\-package\-metadata option.
3178 If the linker has been built with libjansson, then the JSON string
3179 will be validated.
3180 .PP
3181 The i386 PE linker supports the \fB\-shared\fR option, which causes
3182 the output to be a dynamically linked library (DLL) instead of a
3183 normal executable. You should name the output \f(CW\*(C`*.dll\*(C'\fR when you
3184 use this option. In addition, the linker fully supports the standard
3185 \&\f(CW\*(C`*.def\*(C'\fR files, which may be specified on the linker command line
3186 like an object file (in fact, it should precede archives it exports
3187 symbols from, to ensure that they get linked in, just like a normal
3188 object file).
3189 .PP
3190 In addition to the options common to all targets, the i386 PE linker
3191 support additional command\-line options that are specific to the i386
3192 PE target. Options that take values may be separated from their
3193 values by either a space or an equals sign.
3194 .IP \fB\-\-add\-stdcall\-alias\fR 4
3195 .IX Item "--add-stdcall-alias"
3196 If given, symbols with a stdcall suffix (@\fInn\fR) will be exported
3197 as\-is and also with the suffix stripped.
3198 [This option is specific to the i386 PE targeted port of the linker]
3199 .IP "\fB\-\-base\-file\fR \fIfile\fR" 4
3200 .IX Item "--base-file file"
3201 Use \fIfile\fR as the name of a file in which to save the base
3202 addresses of all the relocations needed for generating DLLs with
3203 \&\fIdlltool\fR.
3204 [This is an i386 PE specific option]
3205 .IP \fB\-\-dll\fR 4
3206 .IX Item "--dll"
3207 Create a DLL instead of a regular executable. You may also use
3208 \&\fB\-shared\fR or specify a \f(CW\*(C`LIBRARY\*(C'\fR in a given \f(CW\*(C`.def\*(C'\fR
3209 file.
3210 [This option is specific to the i386 PE targeted port of the linker]
3211 .IP \fB\-\-enable\-long\-section\-names\fR 4
3212 .IX Item "--enable-long-section-names"
3213 .PD 0
3214 .IP \fB\-\-disable\-long\-section\-names\fR 4
3215 .IX Item "--disable-long-section-names"
3216 .PD
3217 The PE variants of the COFF object format add an extension that permits
3218 the use of section names longer than eight characters, the normal limit
3219 for COFF. By default, these names are only allowed in object files, as
3220 fully\-linked executable images do not carry the COFF string table required
3221 to support the longer names. As a GNU extension, it is possible to
3222 allow their use in executable images as well, or to (probably pointlessly!)
3223 disallow it in object files, by using these two options. Executable images
3224 generated with these long section names are slightly non\-standard, carrying
3225 as they do a string table, and may generate confusing output when examined
3226 with non\-GNU PE\-aware tools, such as file viewers and dumpers. However,
3227 GDB relies on the use of PE long section names to find Dwarf\-2 debug
3228 information sections in an executable image at runtime, and so if neither
3229 option is specified on the command\-line, \fBld\fR will enable long
3230 section names, overriding the default and technically correct behaviour,
3231 when it finds the presence of debug information while linking an executable
3232 image and not stripping symbols.
3233 [This option is valid for all PE targeted ports of the linker]
3234 .IP \fB\-\-enable\-stdcall\-fixup\fR 4
3235 .IX Item "--enable-stdcall-fixup"
3236 .PD 0
3237 .IP \fB\-\-disable\-stdcall\-fixup\fR 4
3238 .IX Item "--disable-stdcall-fixup"
3239 .PD
3240 If the link finds a symbol that it cannot resolve, it will attempt to
3241 do "fuzzy linking" by looking for another defined symbol that differs
3242 only in the format of the symbol name (cdecl vs stdcall) and will
3243 resolve that symbol by linking to the match. For example, the
3244 undefined symbol \f(CW\*(C`_foo\*(C'\fR might be linked to the function
3245 \&\f(CW\*(C`_foo@12\*(C'\fR, or the undefined symbol \f(CW\*(C`_bar@16\*(C'\fR might be linked
3246 to the function \f(CW\*(C`_bar\*(C'\fR. When the linker does this, it prints a
3247 warning, since it normally should have failed to link, but sometimes
3248 import libraries generated from third\-party dlls may need this feature
3249 to be usable. If you specify \fB\-\-enable\-stdcall\-fixup\fR, this
3250 feature is fully enabled and warnings are not printed. If you specify
3251 \&\fB\-\-disable\-stdcall\-fixup\fR, this feature is disabled and such
3252 mismatches are considered to be errors.
3253 [This option is specific to the i386 PE targeted port of the linker]
3254 .IP \fB\-\-leading\-underscore\fR 4
3255 .IX Item "--leading-underscore"
3256 .PD 0
3257 .IP \fB\-\-no\-leading\-underscore\fR 4
3258 .IX Item "--no-leading-underscore"
3259 .PD
3260 For most targets default symbol\-prefix is an underscore and is defined
3261 in target\*(Aqs description. By this option it is possible to
3262 disable/enable the default underscore symbol\-prefix.
3263 .IP \fB\-\-export\-all\-symbols\fR 4
3264 .IX Item "--export-all-symbols"
3265 If given, all global symbols in the objects used to build a DLL will
3266 be exported by the DLL. Note that this is the default if there
3267 otherwise wouldn\*(Aqt be any exported symbols. When symbols are
3268 explicitly exported via DEF files or implicitly exported via function
3269 attributes, the default is to not export anything else unless this
3270 option is given. Note that the symbols \f(CW\*(C`DllMain@12\*(C'\fR,
3271 \&\f(CW\*(C`DllEntryPoint@0\*(C'\fR, \f(CW\*(C`DllMainCRTStartup@12\*(C'\fR, and
3272 \&\f(CW\*(C`impure_ptr\*(C'\fR will not be automatically
3273 exported. Also, symbols imported from other DLLs will not be
3274 re\-exported, nor will symbols specifying the DLL\*(Aqs internal layout
3275 such as those beginning with \f(CW\*(C`_head_\*(C'\fR or ending with
3276 \&\f(CW\*(C`_iname\*(C'\fR. In addition, no symbols from \f(CW\*(C`libgcc\*(C'\fR,
3277 \&\f(CW\*(C`libstd++\*(C'\fR, \f(CW\*(C`libmingw32\*(C'\fR, or \f(CW\*(C`crtX.o\*(C'\fR will be exported.
3278 Symbols whose names begin with \f(CW\*(C`_\|_rtti_\*(C'\fR or \f(CW\*(C`_\|_builtin_\*(C'\fR will
3279 not be exported, to help with C++ DLLs. Finally, there is an
3280 extensive list of cygwin\-private symbols that are not exported
3281 (obviously, this applies on when building DLLs for cygwin targets).
3282 These cygwin\-excludes are: \f(CW\*(C`_cygwin_dll_entry@12\*(C'\fR,
3283 \&\f(CW\*(C`_cygwin_crt0_common@8\*(C'\fR, \f(CW\*(C`_cygwin_noncygwin_dll_entry@12\*(C'\fR,
3284 \&\f(CW\*(C`_fmode\*(C'\fR, \f(CW\*(C`_impure_ptr\*(C'\fR, \f(CW\*(C`cygwin_attach_dll\*(C'\fR,
3285 \&\f(CW\*(C`cygwin_premain0\*(C'\fR, \f(CW\*(C`cygwin_premain1\*(C'\fR, \f(CW\*(C`cygwin_premain2\*(C'\fR,
3286 \&\f(CW\*(C`cygwin_premain3\*(C'\fR, and \f(CW\*(C`environ\*(C'\fR.
3287 [This option is specific to the i386 PE targeted port of the linker]
3288 .IP "\fB\-\-exclude\-symbols\fR \fIsymbol\fR\fB,\fR\fIsymbol\fR\fB,...\fR" 4
3289 .IX Item "--exclude-symbols symbol,symbol,..."
3290 Specifies a list of symbols which should not be automatically
3291 exported. The symbol names may be delimited by commas or colons.
3292 [This option is specific to the i386 PE targeted port of the linker]
3293 .IP \fB\-\-exclude\-all\-symbols\fR 4
3294 .IX Item "--exclude-all-symbols"
3295 Specifies no symbols should be automatically exported.
3296 [This option is specific to the i386 PE targeted port of the linker]
3297 .IP \fB\-\-file\-alignment\fR 4
3298 .IX Item "--file-alignment"
3299 Specify the file alignment. Sections in the file will always begin at
3300 file offsets which are multiples of this number. This defaults to
3301 512.
3302 [This option is specific to the i386 PE targeted port of the linker]
3303 .IP "\fB\-\-heap\fR \fIreserve\fR" 4
3304 .IX Item "--heap reserve"
3305 .PD 0
3306 .IP "\fB\-\-heap\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4
3307 .IX Item "--heap reserve,commit"
3308 .PD
3309 Specify the number of bytes of memory to reserve (and optionally commit)
3310 to be used as heap for this program. The default is 1MB reserved, 4K
3311 committed.
3312 [This option is specific to the i386 PE targeted port of the linker]
3313 .IP \fB\-\-kill\-at\fR 4
3314 .IX Item "--kill-at"
3315 If given, the stdcall suffixes (@\fInn\fR) will be stripped from
3316 symbols before they are exported.
3317 [This option is specific to the i386 PE targeted port of the linker]
3318 .IP \fB\-\-large\-address\-aware\fR 4
3319 .IX Item "--large-address-aware"
3320 If given, the appropriate bit in the "Characteristics" field of the COFF
3321 header is set to indicate that this executable supports virtual addresses
3322 greater than 2 gigabytes. This should be used in conjunction with the /3GB
3323 or /USERVA=\fIvalue\fR megabytes switch in the "[operating systems]"
3324 section of the BOOT.INI. Otherwise, this bit has no effect.
3325 [This option is specific to PE targeted ports of the linker]
3326 .IP \fB\-\-disable\-large\-address\-aware\fR 4
3327 .IX Item "--disable-large-address-aware"
3328 Reverts the effect of a previous \fB\-\-large\-address\-aware\fR option.
3329 This is useful if \fB\-\-large\-address\-aware\fR is always set by the compiler
3330 driver (e.g. Cygwin gcc) and the executable does not support virtual
3331 addresses greater than 2 gigabytes.
3332 [This option is specific to PE targeted ports of the linker]
3333 .IP "\fB\-\-major\-image\-version\fR \fIvalue\fR" 4
3334 .IX Item "--major-image-version value"
3335 Sets the major number of the "image version". Defaults to 1.
3336 [This option is specific to the i386 PE targeted port of the linker]
3337 .IP "\fB\-\-major\-os\-version\fR \fIvalue\fR" 4
3338 .IX Item "--major-os-version value"
3339 Sets the major number of the "os version". Defaults to 4.
3340 [This option is specific to the i386 PE targeted port of the linker]
3341 .IP "\fB\-\-major\-subsystem\-version\fR \fIvalue\fR" 4
3342 .IX Item "--major-subsystem-version value"
3343 Sets the major number of the "subsystem version". Defaults to 4.
3344 [This option is specific to the i386 PE targeted port of the linker]
3345 .IP "\fB\-\-minor\-image\-version\fR \fIvalue\fR" 4
3346 .IX Item "--minor-image-version value"
3347 Sets the minor number of the "image version". Defaults to 0.
3348 [This option is specific to the i386 PE targeted port of the linker]
3349 .IP "\fB\-\-minor\-os\-version\fR \fIvalue\fR" 4
3350 .IX Item "--minor-os-version value"
3351 Sets the minor number of the "os version". Defaults to 0.
3352 [This option is specific to the i386 PE targeted port of the linker]
3353 .IP "\fB\-\-minor\-subsystem\-version\fR \fIvalue\fR" 4
3354 .IX Item "--minor-subsystem-version value"
3355 Sets the minor number of the "subsystem version". Defaults to 0.
3356 [This option is specific to the i386 PE targeted port of the linker]
3357 .IP "\fB\-\-output\-def\fR \fIfile\fR" 4
3358 .IX Item "--output-def file"
3359 The linker will create the file \fIfile\fR which will contain a DEF
3360 file corresponding to the DLL the linker is generating. This DEF file
3361 (which should be called \f(CW\*(C`*.def\*(C'\fR) may be used to create an import
3362 library with \f(CW\*(C`dlltool\*(C'\fR or may be used as a reference to
3363 automatically or implicitly exported symbols.
3364 [This option is specific to the i386 PE targeted port of the linker]
3365 .IP \fB\-\-enable\-auto\-image\-base\fR 4
3366 .IX Item "--enable-auto-image-base"
3367 .PD 0
3368 .IP \fB\-\-enable\-auto\-image\-base=\fR\fIvalue\fR 4
3369 .IX Item "--enable-auto-image-base=value"
3370 .PD
3371 Automatically choose the image base for DLLs, optionally starting with base
3372 \&\fIvalue\fR, unless one is specified using the \f(CW\*(C`\-\-image\-base\*(C'\fR argument.
3373 By using a hash generated from the dllname to create unique image bases
3374 for each DLL, in\-memory collisions and relocations which can delay program
3375 execution are avoided.
3376 [This option is specific to the i386 PE targeted port of the linker]
3377 .IP \fB\-\-disable\-auto\-image\-base\fR 4
3378 .IX Item "--disable-auto-image-base"
3379 Do not automatically generate a unique image base. If there is no
3380 user\-specified image base (\f(CW\*(C`\-\-image\-base\*(C'\fR) then use the platform
3381 default.
3382 [This option is specific to the i386 PE targeted port of the linker]
3383 .IP "\fB\-\-dll\-search\-prefix\fR \fIstring\fR" 4
3384 .IX Item "--dll-search-prefix string"
3385 When linking dynamically to a dll without an import library,
3386 search for \f(CW\*(C`<string><basename>.dll\*(C'\fR in preference to
3387 \&\f(CW\*(C`lib<basename>.dll\*(C'\fR. This behaviour allows easy distinction
3388 between DLLs built for the various "subplatforms": native, cygwin,
3389 uwin, pw, etc. For instance, cygwin DLLs typically use
3390 \&\f(CW\*(C`\-\-dll\-search\-prefix=cyg\*(C'\fR.
3391 [This option is specific to the i386 PE targeted port of the linker]
3392 .IP \fB\-\-enable\-auto\-import\fR 4
3393 .IX Item "--enable-auto-import"
3394 Do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to \f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for
3395 DATA imports from DLLs, thus making it possible to bypass the dllimport
3396 mechanism on the user side and to reference unmangled symbol names.
3397 [This option is specific to the i386 PE targeted port of the linker]
3398 .Sp
3399 The following remarks pertain to the original implementation of the
3400 feature and are obsolete nowadays for Cygwin and MinGW targets.
3401 .Sp
3402 Note: Use of the \*(Aqauto\-import\*(Aq extension will cause the text section
3403 of the image file to be made writable. This does not conform to the
3404 PE\-COFF format specification published by Microsoft.
3405 .Sp
3406 Note \- use of the \*(Aqauto\-import\*(Aq extension will also cause read only
3407 data which would normally be placed into the .rdata section to be
3408 placed into the .data section instead. This is in order to work
3409 around a problem with consts that is described here:
3410 http://www.cygwin.com/ml/cygwin/2004\-09/msg01101.html
3411 .Sp
3412 Using \*(Aqauto\-import\*(Aq generally will \*(Aqjust work\*(Aq \-\- but sometimes you may
3413 see this message:
3414 .Sp
3415 "variable \*(Aq<var>\*(Aq can\*(Aqt be auto\-imported. Please read the
3416 documentation for ld\*(Aqs \f(CW\*(C`\-\-enable\-auto\-import\*(C'\fR for details."
3417 .Sp
3418 This message occurs when some (sub)expression accesses an address
3419 ultimately given by the sum of two constants (Win32 import tables only
3420 allow one). Instances where this may occur include accesses to member
3421 fields of struct variables imported from a DLL, as well as using a
3422 constant index into an array variable imported from a DLL. Any
3423 multiword variable (arrays, structs, long long, etc) may trigger
3424 this error condition. However, regardless of the exact data type
3425 of the offending exported variable, ld will always detect it, issue
3426 the warning, and exit.
3427 .Sp
3428 There are several ways to address this difficulty, regardless of the
3429 data type of the exported variable:
3430 .Sp
3431 One way is to use \-\-enable\-runtime\-pseudo\-reloc switch. This leaves the task
3432 of adjusting references in your client code for runtime environment, so
3433 this method works only when runtime environment supports this feature.
3434 .Sp
3435 A second solution is to force one of the \*(Aqconstants\*(Aq to be a variable \-\-
3436 that is, unknown and un\-optimizable at compile time. For arrays,
3437 there are two possibilities: a) make the indexee (the array\*(Aqs address)
3438 a variable, or b) make the \*(Aqconstant\*(Aq index a variable. Thus:
3439 .Sp
3440 .Vb 3
3441 \& extern type extern_array[];
3442 \& extern_array[1] \-\->
3443 \& { volatile type *t=extern_array; t[1] }
3444 .Ve
3445 .Sp
3446 or
3447 .Sp
3448 .Vb 3
3449 \& extern type extern_array[];
3450 \& extern_array[1] \-\->
3451 \& { volatile int t=1; extern_array[t] }
3452 .Ve
3453 .Sp
3454 For structs (and most other multiword data types) the only option
3455 is to make the struct itself (or the long long, or the ...) variable:
3456 .Sp
3457 .Vb 3
3458 \& extern struct s extern_struct;
3459 \& extern_struct.field \-\->
3460 \& { volatile struct s *t=&extern_struct; t\->field }
3461 .Ve
3462 .Sp
3463 or
3464 .Sp
3465 .Vb 3
3466 \& extern long long extern_ll;
3467 \& extern_ll \-\->
3468 \& { volatile long long * local_ll=&extern_ll; *local_ll }
3469 .Ve
3470 .Sp
3471 A third method of dealing with this difficulty is to abandon
3472 \&\*(Aqauto\-import\*(Aq for the offending symbol and mark it with
3473 \&\f(CW\*(C`_\|_declspec(dllimport)\*(C'\fR. However, in practice that
3474 requires using compile\-time #defines to indicate whether you are
3475 building a DLL, building client code that will link to the DLL, or
3476 merely building/linking to a static library. In making the choice
3477 between the various methods of resolving the \*(Aqdirect address with
3478 constant offset\*(Aq problem, you should consider typical real\-world usage:
3479 .Sp
3480 Original:
3481 .Sp
3482 .Vb 7
3483 \& \-\-foo.h
3484 \& extern int arr[];
3485 \& \-\-foo.c
3486 \& #include "foo.h"
3487 \& void main(int argc, char **argv){
3488 \& printf("%d\en",arr[1]);
3489 \& }
3490 .Ve
3491 .Sp
3492 Solution 1:
3493 .Sp
3494 .Vb 9
3495 \& \-\-foo.h
3496 \& extern int arr[];
3497 \& \-\-foo.c
3498 \& #include "foo.h"
3499 \& void main(int argc, char **argv){
3500 \& /* This workaround is for win32 and cygwin; do not "optimize" */
3501 \& volatile int *parr = arr;
3502 \& printf("%d\en",parr[1]);
3503 \& }
3504 .Ve
3505 .Sp
3506 Solution 2:
3507 .Sp
3508 .Vb 10
3509 \& \-\-foo.h
3510 \& /* Note: auto\-export is assumed (no _\|_declspec(dllexport)) */
3511 \& #if (defined(_WIN32) || defined(_\|_CYGWIN_\|_)) && \e
3512 \& !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
3513 \& #define FOO_IMPORT _\|_declspec(dllimport)
3514 \& #else
3515 \& #define FOO_IMPORT
3516 \& #endif
3517 \& extern FOO_IMPORT int arr[];
3518 \& \-\-foo.c
3519 \& #include "foo.h"
3520 \& void main(int argc, char **argv){
3521 \& printf("%d\en",arr[1]);
3522 \& }
3523 .Ve
3524 .Sp
3525 A fourth way to avoid this problem is to re\-code your
3526 library to use a functional interface rather than a data interface
3527 for the offending variables (e.g. \fBset_foo()\fR and \fBget_foo()\fR accessor
3528 functions).
3529 .IP \fB\-\-disable\-auto\-import\fR 4
3530 .IX Item "--disable-auto-import"
3531 Do not attempt to do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to
3532 \&\f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for DATA imports from DLLs.
3533 [This option is specific to the i386 PE targeted port of the linker]
3534 .IP \fB\-\-enable\-runtime\-pseudo\-reloc\fR 4
3535 .IX Item "--enable-runtime-pseudo-reloc"
3536 If your code contains expressions described in \-\-enable\-auto\-import section,
3537 that is, DATA imports from DLL with non\-zero offset, this switch will create
3538 a vector of \*(Aqruntime pseudo relocations\*(Aq which can be used by runtime
3539 environment to adjust references to such data in your client code.
3540 [This option is specific to the i386 PE targeted port of the linker]
3541 .IP \fB\-\-disable\-runtime\-pseudo\-reloc\fR 4
3542 .IX Item "--disable-runtime-pseudo-reloc"
3543 Do not create pseudo relocations for non\-zero offset DATA imports from DLLs.
3544 [This option is specific to the i386 PE targeted port of the linker]
3545 .IP \fB\-\-enable\-extra\-pe\-debug\fR 4
3546 .IX Item "--enable-extra-pe-debug"
3547 Show additional debug info related to auto\-import symbol thunking.
3548 [This option is specific to the i386 PE targeted port of the linker]
3549 .IP \fB\-\-section\-alignment\fR 4
3550 .IX Item "--section-alignment"
3551 Sets the section alignment. Sections in memory will always begin at
3552 addresses which are a multiple of this number. Defaults to 0x1000.
3553 [This option is specific to the i386 PE targeted port of the linker]
3554 .IP "\fB\-\-stack\fR \fIreserve\fR" 4
3555 .IX Item "--stack reserve"
3556 .PD 0
3557 .IP "\fB\-\-stack\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4
3558 .IX Item "--stack reserve,commit"
3559 .PD
3560 Specify the number of bytes of memory to reserve (and optionally commit)
3561 to be used as stack for this program. The default is 2MB reserved, 4K
3562 committed.
3563 [This option is specific to the i386 PE targeted port of the linker]
3564 .IP "\fB\-\-subsystem\fR \fIwhich\fR" 4
3565 .IX Item "--subsystem which"
3566 .PD 0
3567 .IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR" 4
3568 .IX Item "--subsystem which:major"
3569 .IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR\fB.\fR\fIminor\fR" 4
3570 .IX Item "--subsystem which:major.minor"
3571 .PD
3572 Specifies the subsystem under which your program will execute. The
3573 legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C'\fR,
3574 \&\f(CW\*(C`console\*(C'\fR, \f(CW\*(C`posix\*(C'\fR, and \f(CW\*(C`xbox\*(C'\fR. You may optionally set
3575 the subsystem version also. Numeric values are also accepted for
3576 \&\fIwhich\fR.
3577 [This option is specific to the i386 PE targeted port of the linker]
3578 .Sp
3579 The following options set flags in the \f(CW\*(C`DllCharacteristics\*(C'\fR field
3580 of the PE file header:
3581 [These options are specific to PE targeted ports of the linker]
3582 .IP \fB\-\-high\-entropy\-va\fR 4
3583 .IX Item "--high-entropy-va"
3584 .PD 0
3585 .IP \fB\-\-disable\-high\-entropy\-va\fR 4
3586 .IX Item "--disable-high-entropy-va"
3587 .PD
3588 Image is compatible with 64\-bit address space layout randomization
3589 (ASLR). This option is enabled by default for 64\-bit PE images in
3590 MinGW targets.
3591 .Sp
3592 This option also implies \fB\-\-dynamicbase\fR and
3593 \&\fB\-\-enable\-reloc\-section\fR.
3594 .IP \fB\-\-dynamicbase\fR 4
3595 .IX Item "--dynamicbase"
3596 .PD 0
3597 .IP \fB\-\-disable\-dynamicbase\fR 4
3598 .IX Item "--disable-dynamicbase"
3599 .PD
3600 The image base address may be relocated using address space layout
3601 randomization (ASLR). This feature was introduced with MS Windows
3602 Vista for i386 PE targets. This option is enabled by default for MinGW
3603 targets but can be disabled via the \fB\-\-disable\-dynamicbase\fR
3604 option. This option also implies \fB\-\-enable\-reloc\-section\fR.
3605 .IP \fB\-\-forceinteg\fR 4
3606 .IX Item "--forceinteg"
3607 .PD 0
3608 .IP \fB\-\-disable\-forceinteg\fR 4
3609 .IX Item "--disable-forceinteg"
3610 .PD
3611 Code integrity checks are enforced. This option is disabled by
3612 default.
3613 .IP \fB\-\-nxcompat\fR 4
3614 .IX Item "--nxcompat"
3615 .PD 0
3616 .IP \fB\-\-disable\-nxcompat\fR 4
3617 .IX Item "--disable-nxcompat"
3618 .PD
3619 The image is compatible with the Data Execution Prevention.
3620 This feature was introduced with MS Windows XP SP2 for i386 PE
3621 targets. The option is enabled by default for MinGW targets.
3622 .IP \fB\-\-no\-isolation\fR 4
3623 .IX Item "--no-isolation"
3624 .PD 0
3625 .IP \fB\-\-disable\-no\-isolation\fR 4
3626 .IX Item "--disable-no-isolation"
3627 .PD
3628 Although the image understands isolation, do not isolate the image.
3629 This option is disabled by default.
3630 .IP \fB\-\-no\-seh\fR 4
3631 .IX Item "--no-seh"
3632 .PD 0
3633 .IP \fB\-\-disable\-no\-seh\fR 4
3634 .IX Item "--disable-no-seh"
3635 .PD
3636 The image does not use SEH. No SE handler may be called from
3637 this image. This option is disabled by default.
3638 .IP \fB\-\-no\-bind\fR 4
3639 .IX Item "--no-bind"
3640 .PD 0
3641 .IP \fB\-\-disable\-no\-bind\fR 4
3642 .IX Item "--disable-no-bind"
3643 .PD
3644 Do not bind this image. This option is disabled by default.
3645 .IP \fB\-\-wdmdriver\fR 4
3646 .IX Item "--wdmdriver"
3647 .PD 0
3648 .IP \fB\-\-disable\-wdmdriver\fR 4
3649 .IX Item "--disable-wdmdriver"
3650 .PD
3651 The driver uses the MS Windows Driver Model. This option is disabled
3652 by default.
3653 .IP \fB\-\-tsaware\fR 4
3654 .IX Item "--tsaware"
3655 .PD 0
3656 .IP \fB\-\-disable\-tsaware\fR 4
3657 .IX Item "--disable-tsaware"
3658 .PD
3659 The image is Terminal Server aware. This option is disabled by
3660 default.
3661 .IP \fB\-\-insert\-timestamp\fR 4
3662 .IX Item "--insert-timestamp"
3663 .PD 0
3664 .IP \fB\-\-no\-insert\-timestamp\fR 4
3665 .IX Item "--no-insert-timestamp"
3666 .PD
3667 Insert a real timestamp into the image. This is the default behaviour
3668 as it matches legacy code and it means that the image will work with
3669 other, proprietary tools. The problem with this default is that it
3670 will result in slightly different images being produced each time the
3671 same sources are linked. The option \fB\-\-no\-insert\-timestamp\fR
3672 can be used to insert a zero value for the timestamp, this ensuring
3673 that binaries produced from identical sources will compare
3674 identically.
3675 .Sp
3676 If \fB\-\-insert\-timestamp\fR is active then the time inserted is
3677 either the time that the linking takes place or, if the
3678 \&\f(CW\*(C`SOURCE_DATE_EPOCH\*(C'\fR environment variable is defined, the number
3679 of seconds since Unix epoch as specified by that variable.
3680 .IP \fB\-\-enable\-reloc\-section\fR 4
3681 .IX Item "--enable-reloc-section"
3682 .PD 0
3683 .IP \fB\-\-disable\-reloc\-section\fR 4
3684 .IX Item "--disable-reloc-section"
3685 .PD
3686 Create the base relocation table, which is necessary if the image
3687 is loaded at a different image base than specified in the PE header.
3688 This option is enabled by default.
3689 .PP
3690 The C6X uClinux target uses a binary format called DSBT to support shared
3691 libraries. Each shared library in the system needs to have a unique index;
3692 all executables use an index of 0.
3693 .IP "\fB\-\-dsbt\-size\fR \fIsize\fR" 4
3694 .IX Item "--dsbt-size size"
3695 This option sets the number of entries in the DSBT of the current executable
3696 or shared library to \fIsize\fR. The default is to create a table with 64
3697 entries.
3698 .IP "\fB\-\-dsbt\-index\fR \fIindex\fR" 4
3699 .IX Item "--dsbt-index index"
3700 This option sets the DSBT index of the current executable or shared library
3701 to \fIindex\fR. The default is 0, which is appropriate for generating
3702 executables. If a shared library is generated with a DSBT index of 0, the
3703 \&\f(CW\*(C`R_C6000_DSBT_INDEX\*(C'\fR relocs are copied into the output file.
3704 .Sp
3705 The \fB\-\-no\-merge\-exidx\-entries\fR switch disables the merging of adjacent
3706 exidx entries in frame unwind info.
3707 .IP \fB\-\-branch\-stub\fR 4
3708 .IX Item "--branch-stub"
3709 This option enables linker branch relaxation by inserting branch stub
3710 sections when needed to extend the range of branches. This option is
3711 usually not required since C\-SKY supports branch and call instructions that
3712 can access the full memory range and branch relaxation is normally handled by
3713 the compiler or assembler.
3714 .IP \fB\-\-stub\-group\-size=\fR\fIN\fR 4
3715 .IX Item "--stub-group-size=N"
3716 This option allows finer control of linker branch stub creation.
3717 It sets the maximum size of a group of input sections that can
3718 be handled by one stub section. A negative value of \fIN\fR locates
3719 stub sections after their branches, while a positive value allows stub
3720 sections to appear either before or after the branches. Values of
3721 \&\fB1\fR or \fB\-1\fR indicate that the
3722 linker should choose suitable defaults.
3723 .PP
3724 The 68HC11 and 68HC12 linkers support specific options to control the
3725 memory bank switching mapping and trampoline code generation.
3726 .IP \fB\-\-no\-trampoline\fR 4
3727 .IX Item "--no-trampoline"
3728 This option disables the generation of trampoline. By default a trampoline
3729 is generated for each far function which is called using a \f(CW\*(C`jsr\*(C'\fR
3730 instruction (this happens when a pointer to a far function is taken).
3731 .IP "\fB\-\-bank\-window\fR \fIname\fR" 4
3732 .IX Item "--bank-window name"
3733 This option indicates to the linker the name of the memory region in
3734 the \fBMEMORY\fR specification that describes the memory bank window.
3735 The definition of such region is then used by the linker to compute
3736 paging and addresses within the memory window.
3737 .PP
3738 The following options are supported to control handling of GOT generation
3739 when linking for 68K targets.
3740 .IP \fB\-\-got=\fR\fItype\fR 4
3741 .IX Item "--got=type"
3742 This option tells the linker which GOT generation scheme to use.
3743 \&\fItype\fR should be one of \fBsingle\fR, \fBnegative\fR,
3744 \&\fBmultigot\fR or \fBtarget\fR. For more information refer to the
3745 Info entry for \fIld\fR.
3746 .PP
3747 The following options are supported to control microMIPS instruction
3748 generation and branch relocation checks for ISA mode transitions when
3749 linking for MIPS targets.
3750 .IP \fB\-\-insn32\fR 4
3751 .IX Item "--insn32"
3752 .PD 0
3753 .IP \fB\-\-no\-insn32\fR 4
3754 .IX Item "--no-insn32"
3755 .PD
3756 These options control the choice of microMIPS instructions used in code
3757 generated by the linker, such as that in the PLT or lazy binding stubs,
3758 or in relaxation. If \fB\-\-insn32\fR is used, then the linker only uses
3759 32\-bit instruction encodings. By default or if \fB\-\-no\-insn32\fR is
3760 used, all instruction encodings are used, including 16\-bit ones where
3761 possible.
3762 .IP \fB\-\-ignore\-branch\-isa\fR 4
3763 .IX Item "--ignore-branch-isa"
3764 .PD 0
3765 .IP \fB\-\-no\-ignore\-branch\-isa\fR 4
3766 .IX Item "--no-ignore-branch-isa"
3767 .PD
3768 These options control branch relocation checks for invalid ISA mode
3769 transitions. If \fB\-\-ignore\-branch\-isa\fR is used, then the linker
3770 accepts any branch relocations and any ISA mode transition required
3771 is lost in relocation calculation, except for some cases of \f(CW\*(C`BAL\*(C'\fR
3772 instructions which meet relaxation conditions and are converted to
3773 equivalent \f(CW\*(C`JALX\*(C'\fR instructions as the associated relocation is
3774 calculated. By default or if \fB\-\-no\-ignore\-branch\-isa\fR is used
3775 a check is made causing the loss of an ISA mode transition to produce
3776 an error.
3777 .IP \fB\-\-compact\-branches\fR 4
3778 .IX Item "--compact-branches"
3779 .PD 0
3780 .IP \fB\-\-no\-compact\-branches\fR 4
3781 .IX Item "--no-compact-branches"
3782 .PD
3783 These options control the generation of compact instructions by the linker
3784 in the PLT entries for MIPS R6.
3785 .PP
3786 For the pdp11\-aout target, three variants of the output format can be
3787 produced as selected by the following options. The default variant
3788 for pdp11\-aout is the \fB\-\-omagic\fR option, whereas for other
3789 targets \fB\-\-nmagic\fR is the default. The \fB\-\-imagic\fR option is
3790 defined only for the pdp11\-aout target, while the others are described
3791 here as they apply to the pdp11\-aout target.
3792 .IP \fB\-N\fR 4
3793 .IX Item "-N"
3794 .PD 0
3795 .IP \fB\-\-omagic\fR 4
3796 .IX Item "--omagic"
3797 .PD
3798 Mark the output as \f(CW\*(C`OMAGIC\*(C'\fR (0407) in the \fIa.out\fR header to
3799 indicate that the text segment is not to be write\-protected and
3800 shared. Since the text and data sections are both readable and
3801 writable, the data section is allocated immediately contiguous after
3802 the text segment. This is the oldest format for PDP11 executable
3803 programs and is the default for \fBld\fR on PDP11 Unix systems
3804 from the beginning through 2.11BSD.
3805 .IP \fB\-n\fR 4
3806 .IX Item "-n"
3807 .PD 0
3808 .IP \fB\-\-nmagic\fR 4
3809 .IX Item "--nmagic"
3810 .PD
3811 Mark the output as \f(CW\*(C`NMAGIC\*(C'\fR (0410) in the \fIa.out\fR header to
3812 indicate that when the output file is executed, the text portion will
3813 be read\-only and shareable among all processes executing the same
3814 file. This involves moving the data areas up to the first possible 8K
3815 byte page boundary following the end of the text. This option creates
3816 a \fIpure executable\fR format.
3817 .IP \fB\-z\fR 4
3818 .IX Item "-z"
3819 .PD 0
3820 .IP \fB\-\-imagic\fR 4
3821 .IX Item "--imagic"
3822 .PD
3823 Mark the output as \f(CW\*(C`IMAGIC\*(C'\fR (0411) in the \fIa.out\fR header to
3824 indicate that when the output file is executed, the program text and
3825 data areas will be loaded into separate address spaces using the split
3826 instruction and data space feature of the memory management unit in
3827 larger models of the PDP11. This doubles the address space available
3828 to the program. The text segment is again pure, write\-protected, and
3829 shareable. The only difference in the output format between this
3830 option and the others, besides the magic number, is that both the text
3831 and data sections start at location 0. The \fB\-z\fR option selected
3832 this format in 2.11BSD. This option creates a \fIseparate
3833 executable\fR format.
3834 .IP \fB\-\-no\-omagic\fR 4
3835 .IX Item "--no-omagic"
3836 Equivalent to \fB\-\-nmagic\fR for pdp11\-aout.
3837 .SH ENVIRONMENT
3838 .IX Header "ENVIRONMENT"
3839 You can change the behaviour of \fBld\fR with the environment variables
3840 \&\f(CW\*(C`GNUTARGET\*(C'\fR,
3841 \&\f(CW\*(C`LDEMULATION\*(C'\fR and \f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR.
3842 .PP
3843 \&\f(CW\*(C`GNUTARGET\*(C'\fR determines the input\-file object format if you don\*(Aqt
3844 use \fB\-b\fR (or its synonym \fB\-\-format\fR). Its value should be one
3845 of the BFD names for an input format. If there is no
3846 \&\f(CW\*(C`GNUTARGET\*(C'\fR in the environment, \fBld\fR uses the natural format
3847 of the target. If \f(CW\*(C`GNUTARGET\*(C'\fR is set to \f(CW\*(C`default\*(C'\fR then BFD
3848 attempts to discover the input format by examining binary input files;
3849 this method often succeeds, but there are potential ambiguities, since
3850 there is no method of ensuring that the magic number used to specify
3851 object\-file formats is unique. However, the configuration procedure for
3852 BFD on each system places the conventional format for that system first
3853 in the search\-list, so ambiguities are resolved in favor of convention.
3854 .PP
3855 \&\f(CW\*(C`LDEMULATION\*(C'\fR determines the default emulation if you don\*(Aqt use the
3856 \&\fB\-m\fR option. The emulation can affect various aspects of linker
3857 behaviour, particularly the default linker script. You can list the
3858 available emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. If
3859 the \fB\-m\fR option is not used, and the \f(CW\*(C`LDEMULATION\*(C'\fR environment
3860 variable is not defined, the default emulation depends upon how the
3861 linker was configured.
3862 .PP
3863 Normally, the linker will default to demangling symbols. However, if
3864 \&\f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR is set in the environment, then it will
3865 default to not demangling symbols. This environment variable is used in
3866 a similar fashion by the \f(CW\*(C`gcc\*(C'\fR linker wrapper program. The default
3867 may be overridden by the \fB\-\-demangle\fR and \fB\-\-no\-demangle\fR
3868 options.
3869 .PP
3870 If the PE/COFF specific \fB\-\-insert\-timestamp\fR is active and the
3871 \&\fBSOURCE_DATE_EPOCH\fR environment variable is defined, then the
3872 timestamp value in this variable will be inserted into the COFF header
3873 instead of the current time.
3874 .PP
3875 If the \f(CW\*(C`LD_STATS\*(C'\fR environment variable is defined then linker
3876 resource use information will be recorded, just as if the
3877 \&\fB\-\-stats\fR option had been used. If the \f(CW\*(C`LD_STATS\*(C'\fR
3878 variable has a string value then this will used as the name of a file
3879 into which the information should be stored. Otherwise the information
3880 will be sent to the standard output stream.
3881 .SH "SEE ALSO"
3882 .IX Header "SEE ALSO"
3883 \&\fBar\fR\|(1), \fBnm\fR\|(1), \fBobjcopy\fR\|(1), \fBobjdump\fR\|(1), \fBreadelf\fR\|(1) and
3884 the Info entries for \fIbinutils\fR and
3885 \&\fIld\fR.
3886 .SH COPYRIGHT
3887 .IX Header "COPYRIGHT"
3888 Copyright (c) 1991\-2026 Free Software Foundation, Inc.
3889 .PP
3890 Permission is granted to copy, distribute and/or modify this document
3891 under the terms of the GNU Free Documentation License, Version 1.3
3892 or any later version published by the Free Software Foundation;
3893 with no Invariant Sections, with no Front\-Cover Texts, and with no
3894 Back\-Cover Texts. A copy of the license is included in the
3895 section entitled "GNU Free Documentation License".