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