Debian Codegraph @

upstream/fedora-44/man1/ld.1

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