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 ECOFF which supports putting large and small objects
338 into different sections. This is ignored for other object file
339 formats.
340
341 -h name
342 -soname=name
343 When creating an ELF shared object, set the internal DT_SONAME
344 field to the specified name. When an executable is linked with a
345 shared object which has a DT_SONAME field, then when the executable
346 is run the dynamic linker will attempt to load the shared object
347 specified by the DT_SONAME field rather than the using the file
348 name given to the linker.
349
350 -i Perform an incremental link (same as option -r).
351
352 -init=name
353 When creating an ELF executable or shared object, call NAME when
354 the executable or shared object is loaded, by setting DT_INIT to
355 the address of the function. By default, the linker uses "_init"
356 as the function to call.
357
358 -l namespec
359 --library=namespec
360 Add the archive or object file specified by namespec to the list of
361 files to link. This option may be used any number of times. If
362 namespec is of the form :filename, ld will search the library path
363 for a file called filename, otherwise it will search the library
364 path for a file called libnamespec.a.
365
366 On systems which support shared libraries, ld may also search for
367 files other than libnamespec.a. Specifically, on ELF and SunOS
368 systems, ld will search a directory for a library called
369 libnamespec.so before searching for one called libnamespec.a. (By
370 convention, a ".so" extension indicates a shared library.) Note
371 that this behavior does not apply to :filename, which always
372 specifies a file called filename.
373
374 The linker will search an archive only once, at the location where
375 it is specified on the command line. If the archive defines a
376 symbol which was undefined in some object which appeared before the
377 archive on the command line, the linker will include the
378 appropriate file(s) from the archive. However, an undefined symbol
379 in an object appearing later on the command line will not cause the
380 linker to search the archive again.
381
382 See the -( option for a way to force the linker to search archives
383 multiple times.
384
385 You may list the same archive multiple times on the command line.
386
387 This type of archive searching is standard for Unix linkers.
388 However, if you are using ld on AIX, note that it is different from
389 the behaviour of the AIX linker.
390
391 -L searchdir
392 --library-path=searchdir
393 Add path searchdir to the list of paths that ld will search for
394 archive libraries and ld control scripts. You may use this option
395 any number of times. The directories are searched in the order in
396 which they are specified on the command line. Directories
397 specified on the command line are searched before the default
398 directories. All -L options apply to all -l options, regardless of
399 the order in which the options appear. -L options do not affect
400 how ld searches for a linker script unless -T option is specified.
401
402 If searchdir begins with "=", then the "=" will be replaced by the
403 sysroot prefix, a path specified 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 -q
499 --emit-relocs
500 Leave relocation sections and contents in fully linked executables.
501 Post link analysis and optimization tools may need this information
502 in order to perform correct modifications of executables. This
503 results in larger executables.
504
505 This option is currently only supported on ELF platforms.
506
507 --force-dynamic
508 Force the output file to have dynamic sections. This option is
509 specific to VxWorks targets.
510
511 -r
512 --relocatable
513 Generate relocatable output---i.e., generate an output file that
514 can in turn serve as input to ld. This is often called partial
515 linking. As a side effect, in environments that support standard
516 Unix magic numbers, this option also sets the output file's magic
517 number to "OMAGIC". If this option is not specified, an absolute
518 file is produced. When linking C++ programs, this option will not
519 resolve references to constructors; to do that, use -Ur.
520
521 When an input file does not have the same format as the output
522 file, partial linking is only supported if that input file does not
523 contain any relocations. Different output formats can have further
524 restrictions; for example some "a.out"-based formats do not support
525 partial linking with input files in other formats at all.
526
527 This option does the same thing as -i.
528
529 -R filename
530 --just-symbols=filename
531 Read symbol names and their addresses from filename, but do not
532 relocate it or include it in the output. This allows your output
533 file to refer symbolically to absolute locations of memory defined
534 in other programs. You may use this option more than once.
535
536 For compatibility with other ELF linkers, if the -R option is
537 followed by a directory name, rather than a file name, it is
538 treated as the -rpath option.
539
540 -s
541 --strip-all
542 Omit all symbol information from the output file.
543
544 -S
545 --strip-debug
546 Omit debugger symbol information (but not all symbols) from the
547 output file.
548
549 -t
550 --trace
551 Print the names of the input files as ld processes them.
552
553 -T scriptfile
554 --script=scriptfile
555 Use scriptfile as the linker script. This script replaces ld's
556 default linker script (rather than adding to it), so commandfile
557 must specify everything necessary to describe the output file.
558 If scriptfile does not exist in the current directory, "ld" looks
559 for it in the directories specified by any preceding -L options.
560 Multiple -T options accumulate.
561
562 -dT scriptfile
563 --default-script=scriptfile
564 Use scriptfile as the default linker script.
565
566 This option is similar to the --script option except that
567 processing of the script is delayed until after the rest of the
568 command line has been processed. This allows options placed after
569 the --default-script option on the command line to affect the
570 behaviour of the linker script, which can be important when the
571 linker command line cannot be directly controlled by the user. (eg
572 because the command line is being constructed by another tool, such
573 as gcc).
574
575 -u symbol
576 --undefined=symbol
577 Force symbol to be entered in the output file as an undefined
578 symbol. Doing this may, for example, trigger linking of additional
579 modules from standard libraries. -u may be repeated with different
580 option arguments to enter additional undefined symbols. This
581 option is equivalent to the "EXTERN" linker script command.
582
583 -Ur For anything other than C++ programs, this option is equivalent to
584 -r: it generates relocatable output---i.e., an output file that can
585 in turn serve as input to ld. When linking C++ programs, -Ur does
586 resolve references to constructors, unlike -r. It does not work to
587 use -Ur on files that were themselves linked with -Ur; once the
588 constructor table has been built, it cannot be added to. Use -Ur
589 only for the last partial link, and -r for the others.
590
591 --unique[=SECTION]
592 Creates a separate output section for every input section matching
593 SECTION, or if the optional wildcard SECTION argument is missing,
594 for every orphan input section. An orphan section is one not
595 specifically mentioned in a linker script. You may use this option
596 multiple times on the command line; It prevents the normal merging
597 of input sections with the same name, overriding output section
598 assignments in a linker script.
599
600 -v
601 --version
602 -V Display the version number for ld. The -V option also lists the
603 supported emulations.
604
605 -x
606 --discard-all
607 Delete all local symbols.
608
609 -X
610 --discard-locals
611 Delete all temporary local symbols. (These symbols start with
612 system-specific local label prefixes, typically .L for ELF systems
613 or L for traditional a.out systems.)
614
615 -y symbol
616 --trace-symbol=symbol
617 Print the name of each linked file in which symbol appears. This
618 option may be given any number of times. On many systems it is
619 necessary to prepend an underscore.
620
621 This option is useful when you have an undefined symbol in your
622 link but don't know where the reference is coming from.
623
624 -Y path
625 Add path to the default library search path. This option exists
626 for Solaris compatibility.
627
628 -z keyword
629 The recognized keywords are:
630
631 combreloc
632 Combines multiple reloc sections and sorts them to make dynamic
633 symbol lookup caching possible.
634
635 defs
636 Disallows undefined symbols in object files. Undefined symbols
637 in shared libraries are still allowed.
638
639 execstack
640 Marks the object as requiring executable stack.
641
642 initfirst
643 This option is only meaningful when building a shared object.
644 It marks the object so that its runtime initialization will
645 occur before the runtime initialization of any other objects
646 brought into the process at the same time. Similarly the
647 runtime finalization of the object will occur after the runtime
648 finalization of any other objects.
649
650 interpose
651 Marks the object that its symbol table interposes before all
652 symbols but the primary executable.
653
654 lazy
655 When generating an executable or shared library, mark it to
656 tell the dynamic linker to defer function call resolution to
657 the point when the function is called (lazy binding), rather
658 than at load time. Lazy binding is the default.
659
660 loadfltr
661 Marks the object that its filters be processed immediately at
662 runtime.
663
664 muldefs
665 Allows multiple definitions.
666
667 nocombreloc
668 Disables multiple reloc sections combining.
669
670 nocopyreloc
671 Disables production of copy relocs.
672
673 nodefaultlib
674 Marks the object that the search for dependencies of this
675 object will ignore any default library search paths.
676
677 nodelete
678 Marks the object shouldn't be unloaded at runtime.
679
680 nodlopen
681 Marks the object not available to "dlopen".
682
683 nodump
684 Marks the object can not be dumped by "dldump".
685
686 noexecstack
687 Marks the object as not requiring executable stack.
688
689 norelro
690 Don't create an ELF "PT_GNU_RELRO" segment header in the
691 object.
692
693 now When generating an executable or shared library, mark it to
694 tell the dynamic linker to resolve all symbols when the program
695 is started, or when the shared library is linked to using
696 dlopen, instead of deferring function call resolution to the
697 point when the function is first called.
698
699 origin
700 Marks the object may contain $ORIGIN.
701
702 relro
703 Create an ELF "PT_GNU_RELRO" segment header in the object.
704
705 max-page-size=value
706 Set the emulation maximum page size to value.
707
708 common-page-size=value
709 Set the emulation common page size to value.
710
711 Other keywords are ignored for Solaris compatibility.
712
713 -( archives -)
714 --start-group archives --end-group
715 The archives should be a list of archive files. They may be either
716 explicit file names, or -l options.
717
718 The specified archives are searched repeatedly until no new
719 undefined references are created. Normally, an archive is searched
720 only once in the order that it is specified on the command line.
721 If a symbol in that archive is needed to resolve an undefined
722 symbol referred to by an object in an archive that appears later on
723 the command line, the linker would not be able to resolve that
724 reference. By grouping the archives, they all be searched
725 repeatedly until all possible references are resolved.
726
727 Using this option has a significant performance cost. It is best
728 to use it only when there are unavoidable circular references
729 between two or more archives.
730
731 --accept-unknown-input-arch
732 --no-accept-unknown-input-arch
733 Tells the linker to accept input files whose architecture cannot be
734 recognised. The assumption is that the user knows what they are
735 doing and deliberately wants to link in these unknown input files.
736 This was the default behaviour of the linker, before release 2.14.
737 The default behaviour from release 2.14 onwards is to reject such
738 input files, and so the --accept-unknown-input-arch option has been
739 added to restore the old behaviour.
740
741 --as-needed
742 --no-as-needed
743 This option affects ELF DT_NEEDED tags for dynamic libraries
744 mentioned on the command line after the --as-needed option.
745 Normally the linker will add a DT_NEEDED tag for each dynamic
746 library mentioned on the command line, regardless of whether the
747 library is actually needed or not. --as-needed causes a DT_NEEDED
748 tag to only be emitted for a library that satisfies an undefined
749 symbol reference from a regular object file or, if the library is
750 not found in the DT_NEEDED lists of other libraries linked up to
751 that point, an undefined symbol reference from another dynamic
752 library. --no-as-needed restores the default behaviour.
753
754 --add-needed
755 --no-add-needed
756 These two options have been deprecated because of the similarity of
757 their names to the --as-needed and --no-as-needed options. They
758 have been replaced by --copy-dt-needed-entries and
759 --no-copy-dt-needed-entries.
760
761 -assert keyword
762 This option is ignored for SunOS compatibility.
763
764 -Bdynamic
765 -dy
766 -call_shared
767 Link against dynamic libraries. This is only meaningful on
768 platforms for which shared libraries are supported. This option is
769 normally the default on such platforms. The different variants of
770 this option are for compatibility with various systems. You may
771 use this option multiple times on the command line: it affects
772 library searching for -l options which follow it.
773
774 -Bgroup
775 Set the "DF_1_GROUP" flag in the "DT_FLAGS_1" entry in the dynamic
776 section. This causes the runtime linker to handle lookups in this
777 object and its dependencies to be performed only inside the group.
778 --unresolved-symbols=report-all is implied. This option is only
779 meaningful on ELF platforms which support shared libraries.
780
781 -Bstatic
782 -dn
783 -non_shared
784 -static
785 Do not link against shared libraries. This is only meaningful on
786 platforms for which shared libraries are supported. The different
787 variants of this option are for compatibility with various systems.
788 You may use this option multiple times on the command line: it
789 affects library searching for -l options which follow it. This
790 option also implies --unresolved-symbols=report-all. This option
791 can be used with -shared. Doing so means that a shared library is
792 being created but that all of the library's external references
793 must be resolved by pulling in entries from static libraries.
794
795 -Bsymbolic
796 When creating a shared library, bind references to global symbols
797 to the definition within the shared library, if any. Normally, it
798 is possible for a program linked against a shared library to
799 override the definition within the shared library. This option is
800 only meaningful on ELF platforms which support shared libraries.
801
802 -Bsymbolic-functions
803 When creating a shared library, bind references to global function
804 symbols to the definition within the shared library, if any. This
805 option is only meaningful on ELF platforms which support shared
806 libraries.
807
808 --dynamic-list=dynamic-list-file
809 Specify the name of a dynamic list file to the linker. This is
810 typically used when creating shared libraries to specify a list of
811 global symbols whose references shouldn't be bound to the
812 definition within the shared library, or creating dynamically
813 linked executables to specify a list of symbols which should be
814 added to the symbol table in the executable. This option is only
815 meaningful on ELF platforms which support shared libraries.
816
817 The format of the dynamic list is the same as the version node
818 without scope and node name. See VERSION for more information.
819
820 --dynamic-list-data
821 Include all global data symbols to the dynamic list.
822
823 --dynamic-list-cpp-new
824 Provide the builtin dynamic list for C++ operator new and delete.
825 It is mainly useful for building shared libstdc++.
826
827 --dynamic-list-cpp-typeinfo
828 Provide the builtin dynamic list for C++ runtime type
829 identification.
830
831 --check-sections
832 --no-check-sections
833 Asks the linker not to check section addresses after they have been
834 assigned to see if there are any overlaps. Normally the linker
835 will perform this check, and if it finds any overlaps it will
836 produce suitable error messages. The linker does know about, and
837 does make allowances for sections in overlays. The default
838 behaviour can be restored by using the command line switch
839 --check-sections. Section overlap is not usually checked for
840 relocatable links. You can force checking in that case by using
841 the --check-sections option.
842
843 --copy-dt-needed-entries
844 --no-copy-dt-needed-entries
845 This option affects the treatment of dynamic libraries referred to
846 by DT_NEEDED tags inside ELF dynamic libraries mentioned on the
847 command line. Normally the linker will add a DT_NEEDED tag to the
848 output binary for each library mentioned in a DT_NEEDED tag in an
849 input dynamic library. With --no-copy-dt-needed-entries specified
850 on the command line however any dynamic libraries that follow it
851 will have their DT_NEEDED entries ignored. The default behaviour
852 can be restored with --copy-dt-needed-entries.
853
854 This option also has an effect on the resolution of symbols in
855 dynamic libraries. With the default setting dynamic libraries
856 mentioned on the command line will be recursively searched,
857 following their DT_NEEDED tags to other libraries, in order to
858 resolve symbols required by the output binary. With
859 --no-copy-dt-needed-entries specified however the searching of
860 dynamic libraries that follow it will stop with the dynamic library
861 itself. No DT_NEEDED links will be traversed to resolve symbols.
862
863 --cref
864 Output a cross reference table. If a linker map file is being
865 generated, the cross reference table is printed to the map file.
866 Otherwise, it is printed on the standard output.
867
868 The format of the table is intentionally simple, so that it may be
869 easily processed by a script if necessary. The symbols are printed
870 out, sorted by name. For each symbol, a list of file names is
871 given. If the symbol is defined, the first file listed is the
872 location of the definition. The remaining files contain references
873 to the symbol.
874
875 --no-define-common
876 This option inhibits the assignment of addresses to common symbols.
877 The script command "INHIBIT_COMMON_ALLOCATION" has the same effect.
878
879 The --no-define-common option allows decoupling the decision to
880 assign addresses to Common symbols from the choice of the output
881 file type; otherwise a non-Relocatable output type forces assigning
882 addresses to Common symbols. Using --no-define-common allows
883 Common symbols that are referenced from a shared library to be
884 assigned addresses only in the main program. This eliminates the
885 unused duplicate space in the shared library, and also prevents any
886 possible confusion over resolving to the wrong duplicate when there
887 are many dynamic modules with specialized search paths for runtime
888 symbol resolution.
889
890 --defsym=symbol=expression
891 Create a global symbol in the output file, containing the absolute
892 address given by expression. You may use this option as many times
893 as necessary to define multiple symbols in the command line. A
894 limited form of arithmetic is supported for the expression in this
895 context: you may give a hexadecimal constant or the name of an
896 existing symbol, or use "+" and "-" to add or subtract hexadecimal
897 constants or symbols. If you need more elaborate expressions,
898 consider using the linker command language from a script. Note:
899 there should be no white space between symbol, the equals sign
900 ("="), and expression.
901
902 --demangle[=style]
903 --no-demangle
904 These options control whether to demangle symbol names in error
905 messages and other output. When the linker is told to demangle, it
906 tries to present symbol names in a readable fashion: it strips
907 leading underscores if they are used by the object file format, and
908 converts C++ mangled symbol names into user readable names.
909 Different compilers have different mangling styles. The optional
910 demangling style argument can be used to choose an appropriate
911 demangling style for your compiler. The linker will demangle by
912 default unless the environment variable COLLECT_NO_DEMANGLE is set.
913 These options may be used to override the default.
914
915 -Ifile
916 --dynamic-linker=file
917 Set the name of the dynamic linker. This is only meaningful when
918 generating dynamically linked ELF executables. The default dynamic
919 linker is normally correct; don't use this unless you know what you
920 are doing.
921
922 --fatal-warnings
923 --no-fatal-warnings
924 Treat all warnings as errors. The default behaviour can be
925 restored with the option --no-fatal-warnings.
926
927 --force-exe-suffix
928 Make sure that an output file has a .exe suffix.
929
930 If a successfully built fully linked output file does not have a
931 ".exe" or ".dll" suffix, this option forces the linker to copy the
932 output file to one of the same name with a ".exe" suffix. This
933 option is useful when using unmodified Unix makefiles on a
934 Microsoft Windows host, since some versions of Windows won't run an
935 image unless it ends in a ".exe" suffix.
936
937 --gc-sections
938 --no-gc-sections
939 Enable garbage collection of unused input sections. It is ignored
940 on targets that do not support this option. The default behaviour
941 (of not performing this garbage collection) can be restored by
942 specifying --no-gc-sections on the command line.
943
944 --gc-sections decides which input sections are used by examining
945 symbols and relocations. The section containing the entry symbol
946 and all sections containing symbols undefined on the command-line
947 will be kept, as will sections containing symbols referenced by
948 dynamic objects. Note that when building shared libraries, the
949 linker must assume that any visible symbol is referenced. Once
950 this initial set of sections has been determined, the linker
951 recursively marks as used any section referenced by their
952 relocations. See --entry and --undefined.
953
954 This option can be set when doing a partial link (enabled with
955 option -r). In this case the root of symbols kept must be
956 explicitly specified either by an --entry or --undefined option or
957 by a "ENTRY" command in the linker script.
958
959 --print-gc-sections
960 --no-print-gc-sections
961 List all sections removed by garbage collection. The listing is
962 printed on stderr. This option is only effective if garbage
963 collection has been enabled via the --gc-sections) option. The
964 default behaviour (of not listing the sections that are removed)
965 can be restored by specifying --no-print-gc-sections on the command
966 line.
967
968 --help
969 Print a summary of the command-line options on the standard output
970 and exit.
971
972 --target-help
973 Print a summary of all target specific options on the standard
974 output and exit.
975
976 -Map=mapfile
977 Print a link map to the file mapfile. See the description of the
978 -M option, above.
979
980 --no-keep-memory
981 ld normally optimizes for speed over memory usage by caching the
982 symbol tables of input files in memory. This option tells ld to
983 instead optimize for memory usage, by rereading the symbol tables
984 as necessary. This may be required if ld runs out of memory space
985 while linking a large executable.
986
987 --no-undefined
988 -z defs
989 Report unresolved symbol references from regular object files.
990 This is done even if the linker is creating a non-symbolic shared
991 library. The switch --[no-]allow-shlib-undefined controls the
992 behaviour for reporting unresolved references found in shared
993 libraries being linked in.
994
995 --allow-multiple-definition
996 -z muldefs
997 Normally when a symbol is defined multiple times, the linker will
998 report a fatal error. These options allow multiple definitions and
999 the first definition will be used.
1000
1001 --allow-shlib-undefined
1002 --no-allow-shlib-undefined
1003 Allows or disallows undefined symbols in shared libraries. This
1004 switch is similar to --no-undefined except that it determines the
1005 behaviour when the undefined symbols are in a shared library rather
1006 than a regular object file. It does not affect how undefined
1007 symbols in regular object files are handled.
1008
1009 The default behaviour is to report errors for any undefined symbols
1010 referenced in shared libraries if the linker is being used to
1011 create an executable, but to allow them if the linker is being used
1012 to create a shared library.
1013
1014 The reasons for allowing undefined symbol references in shared
1015 libraries specified at link time are that:
1016
1017 · A shared library specified at link time may not be the same as
1018 the one that is available at load time, so the symbol might
1019 actually be resolvable at load time.
1020
1021 · There are some operating systems, eg BeOS and HPPA, where
1022 undefined symbols in shared libraries are normal.
1023
1024 The BeOS kernel for example patches shared libraries at load
1025 time to select whichever function is most appropriate for the
1026 current architecture. This is used, for example, to
1027 dynamically select an appropriate memset function.
1028
1029 --no-undefined-version
1030 Normally when a symbol has an undefined version, the linker will
1031 ignore it. This option disallows symbols with undefined version and
1032 a fatal error will be issued instead.
1033
1034 --default-symver
1035 Create and use a default symbol version (the soname) for
1036 unversioned exported symbols.
1037
1038 --default-imported-symver
1039 Create and use a default symbol version (the soname) for
1040 unversioned imported symbols.
1041
1042 --no-warn-mismatch
1043 Normally ld will give an error if you try to link together input
1044 files that are mismatched for some reason, perhaps because they
1045 have been compiled for different processors or for different
1046 endiannesses. This option tells ld that it should silently permit
1047 such possible errors. This option should only be used with care,
1048 in cases when you have taken some special action that ensures that
1049 the linker errors are inappropriate.
1050
1051 --no-warn-search-mismatch
1052 Normally ld will give a warning if it finds an incompatible library
1053 during a library search. This option silences the warning.
1054
1055 --no-whole-archive
1056 Turn off the effect of the --whole-archive option for subsequent
1057 archive files.
1058
1059 --noinhibit-exec
1060 Retain the executable output file whenever it is still usable.
1061 Normally, the linker will not produce an output file if it
1062 encounters errors during the link process; it exits without writing
1063 an output file when it issues any error whatsoever.
1064
1065 -nostdlib
1066 Only search library directories explicitly specified on the command
1067 line. Library directories specified in linker scripts (including
1068 linker scripts specified on the command line) are ignored.
1069
1070 --oformat=output-format
1071 ld may be configured to support more than one kind of object file.
1072 If your ld is configured this way, you can use the --oformat option
1073 to specify the binary format for the output object file. Even when
1074 ld is configured to support alternative object formats, you don't
1075 usually need to specify this, as ld should be configured to produce
1076 as a default output format the most usual format on each machine.
1077 output-format is a text string, the name of a particular format
1078 supported by the BFD libraries. (You can list the available binary
1079 formats with objdump -i.) The script command "OUTPUT_FORMAT" can
1080 also specify the output format, but this option overrides it.
1081
1082 -pie
1083 --pic-executable
1084 Create a position independent executable. This is currently only
1085 supported on ELF platforms. Position independent executables are
1086 similar to shared libraries in that they are relocated by the
1087 dynamic linker to the virtual address the OS chooses for them
1088 (which can vary between invocations). Like normal dynamically
1089 linked executables they can be executed and symbols defined in the
1090 executable cannot be overridden by shared libraries.
1091
1092 -qmagic
1093 This option is ignored for Linux compatibility.
1094
1095 -Qy This option is ignored for SVR4 compatibility.
1096
1097 --relax
1098 --no-relax
1099 An option with machine dependent effects. This option is only
1100 supported on a few targets.
1101
1102 On some platforms the --relax option performs target specific,
1103 global optimizations that become possible when the linker resolves
1104 addressing in the program, such as relaxing address modes,
1105 synthesizing new instructions, selecting shorter version of current
1106 instructions, and combinig constant values.
1107
1108 On some platforms these link time global optimizations may make
1109 symbolic debugging of the resulting executable impossible. This is
1110 known to be the case for the Matsushita MN10200 and MN10300 family
1111 of processors.
1112
1113 On platforms where this is not supported, --relax is accepted, but
1114 ignored.
1115
1116 On platforms where --relax is accepted the option --no-relax can be
1117 used to disable the feature.
1118
1119 --retain-symbols-file=filename
1120 Retain only the symbols listed in the file filename, discarding all
1121 others. filename is simply a flat file, with one symbol name per
1122 line. This option is especially useful in environments (such as
1123 VxWorks) where a large global symbol table is accumulated
1124 gradually, to conserve run-time memory.
1125
1126 --retain-symbols-file does not discard undefined symbols, or
1127 symbols needed for relocations.
1128
1129 You may only specify --retain-symbols-file once in the command
1130 line. It overrides -s and -S.
1131
1132 -rpath=dir
1133 Add a directory to the runtime library search path. This is used
1134 when linking an ELF executable with shared objects. All -rpath
1135 arguments are concatenated and passed to the runtime linker, which
1136 uses them to locate shared objects at runtime. The -rpath option
1137 is also used when locating shared objects which are needed by
1138 shared objects explicitly included in the link; see the description
1139 of the -rpath-link option. If -rpath is not used when linking an
1140 ELF executable, the contents of the environment variable
1141 "LD_RUN_PATH" will be used if it is defined.
1142
1143 The -rpath option may also be used on SunOS. By default, on SunOS,
1144 the linker will form a runtime search patch out of all the -L
1145 options it is given. If a -rpath option is used, the runtime
1146 search path will be formed exclusively using the -rpath options,
1147 ignoring the -L options. This can be useful when using gcc, which
1148 adds many -L options which may be on NFS mounted file systems.
1149
1150 For compatibility with other ELF linkers, if the -R option is
1151 followed by a directory name, rather than a file name, it is
1152 treated as the -rpath option.
1153
1154 -rpath-link=dir
1155 When using ELF or SunOS, one shared library may require another.
1156 This happens when an "ld -shared" link includes a shared library as
1157 one of the input files.
1158
1159 When the linker encounters such a dependency when doing a non-
1160 shared, non-relocatable link, it will automatically try to locate
1161 the required shared library and include it in the link, if it is
1162 not included explicitly. In such a case, the -rpath-link option
1163 specifies the first set of directories to search. The -rpath-link
1164 option may specify a sequence of directory names either by
1165 specifying a list of names separated by colons, or by appearing
1166 multiple times.
1167
1168 This option should be used with caution as it overrides the search
1169 path that may have been hard compiled into a shared library. In
1170 such a case it is possible to use unintentionally a different
1171 search path than the runtime linker would do.
1172
1173 The linker uses the following search paths to locate required
1174 shared libraries:
1175
1176 1. Any directories specified by -rpath-link options.
1177
1178 2. Any directories specified by -rpath options. The difference
1179 between -rpath and -rpath-link is that directories specified by
1180 -rpath options are included in the executable and used at
1181 runtime, whereas the -rpath-link option is only effective at
1182 link time. Searching -rpath in this way is only supported by
1183 native linkers and cross linkers which have been configured
1184 with the --with-sysroot option.
1185
1186 3. On an ELF system, for native linkers, if the -rpath and
1187 -rpath-link options were not used, search the contents of the
1188 environment variable "LD_RUN_PATH".
1189
1190 4. On SunOS, if the -rpath option was not used, search any
1191 directories specified using -L options.
1192
1193 5. For a native linker, the search the contents of the environment
1194 variable "LD_LIBRARY_PATH".
1195
1196 6. For a native ELF linker, the directories in "DT_RUNPATH" or
1197 "DT_RPATH" of a shared library are searched for shared
1198 libraries needed by it. The "DT_RPATH" entries are ignored if
1199 "DT_RUNPATH" entries exist.
1200
1201 7. The default directories, normally /lib and /usr/lib.
1202
1203 8. For a native linker on an ELF system, if the file
1204 /etc/ld.so.conf exists, the list of directories found in that
1205 file.
1206
1207 If the required shared library is not found, the linker will issue
1208 a warning and continue with the link.
1209
1210 -shared
1211 -Bshareable
1212 Create a shared library. This is currently only supported on ELF,
1213 XCOFF and SunOS platforms. On SunOS, the linker will automatically
1214 create a shared library if the -e option is not used and there are
1215 undefined symbols in the link.
1216
1217 --sort-common
1218 --sort-common=ascending
1219 --sort-common=descending
1220 This option tells ld to sort the common symbols by alignment in
1221 ascending or descending order when it places them in the
1222 appropriate output sections. The symbol alignments considered are
1223 sixteen-byte or larger, eight-byte, four-byte, two-byte, and one-
1224 byte. This is to prevent gaps between symbols due to alignment
1225 constraints. If no sorting order is specified, then descending
1226 order is assumed.
1227
1228 --sort-section=name
1229 This option will apply "SORT_BY_NAME" to all wildcard section
1230 patterns in the linker script.
1231
1232 --sort-section=alignment
1233 This option will apply "SORT_BY_ALIGNMENT" to all wildcard section
1234 patterns in the linker script.
1235
1236 --split-by-file[=size]
1237 Similar to --split-by-reloc but creates a new output section for
1238 each input file when size is reached. size defaults to a size of 1
1239 if not given.
1240
1241 --split-by-reloc[=count]
1242 Tries to creates extra sections in the output file so that no
1243 single output section in the file contains more than count
1244 relocations. This is useful when generating huge relocatable files
1245 for downloading into certain real time kernels with the COFF object
1246 file format; since COFF cannot represent more than 65535
1247 relocations in a single section. Note that this will fail to work
1248 with object file formats which do not support arbitrary sections.
1249 The linker will not split up individual input sections for
1250 redistribution, so if a single input section contains more than
1251 count relocations one output section will contain that many
1252 relocations. count defaults to a value of 32768.
1253
1254 --stats
1255 Compute and display statistics about the operation of the linker,
1256 such as execution time and memory usage.
1257
1258 --sysroot=directory
1259 Use directory as the location of the sysroot, overriding the
1260 configure-time default. This option is only supported by linkers
1261 that were configured using --with-sysroot.
1262
1263 --traditional-format
1264 For some targets, the output of ld is different in some ways from
1265 the output of some existing linker. This switch requests ld to use
1266 the traditional format instead.
1267
1268 For example, on SunOS, ld combines duplicate entries in the symbol
1269 string table. This can reduce the size of an output file with full
1270 debugging information by over 30 percent. Unfortunately, the SunOS
1271 "dbx" program can not read the resulting program ("gdb" has no
1272 trouble). The --traditional-format switch tells ld to not combine
1273 duplicate entries.
1274
1275 --section-start=sectionname=org
1276 Locate a section in the output file at the absolute address given
1277 by org. You may use this option as many times as necessary to
1278 locate multiple sections in the command line. org must be a single
1279 hexadecimal integer; for compatibility with other linkers, you may
1280 omit the leading 0x usually associated with hexadecimal values.
1281 Note: there should be no white space between sectionname, the
1282 equals sign ("="), and org.
1283
1284 -Tbss=org
1285 -Tdata=org
1286 -Ttext=org
1287 Same as --section-start, with ".bss", ".data" or ".text" as the
1288 sectionname.
1289
1290 -Ttext-segment=org
1291 When creating an ELF executable or shared object, it will set the
1292 address of the first byte of the text segment.
1293
1294 --unresolved-symbols=method
1295 Determine how to handle unresolved symbols. There are four
1296 possible values for method:
1297
1298 ignore-all
1299 Do not report any unresolved symbols.
1300
1301 report-all
1302 Report all unresolved symbols. This is the default.
1303
1304 ignore-in-object-files
1305 Report unresolved symbols that are contained in shared
1306 libraries, but ignore them if they come from regular object
1307 files.
1308
1309 ignore-in-shared-libs
1310 Report unresolved symbols that come from regular object files,
1311 but ignore them if they come from shared libraries. This can
1312 be useful when creating a dynamic binary and it is known that
1313 all the shared libraries that it should be referencing are
1314 included on the linker's command line.
1315
1316 The behaviour for shared libraries on their own can also be
1317 controlled by the --[no-]allow-shlib-undefined option.
1318
1319 Normally the linker will generate an error message for each
1320 reported unresolved symbol but the option --warn-unresolved-symbols
1321 can change this to a warning.
1322
1323 --dll-verbose
1324 --verbose
1325 Display the version number for ld and list the linker emulations
1326 supported. Display which input files can and cannot be opened.
1327 Display the linker script being used by the linker.
1328
1329 --version-script=version-scriptfile
1330 Specify the name of a version script to the linker. This is
1331 typically used when creating shared libraries to specify additional
1332 information about the version hierarchy for the library being
1333 created. This option is only fully supported on ELF platforms
1334 which support shared libraries; see VERSION. It is partially
1335 supported on PE platforms, which can use version scripts to filter
1336 symbol visibility in auto-export mode: any symbols marked local in
1337 the version script will not be exported.
1338
1339 --warn-common
1340 Warn when a common symbol is combined with another common symbol or
1341 with a symbol definition. Unix linkers allow this somewhat sloppy
1342 practise, but linkers on some other operating systems do not. This
1343 option allows you to find potential problems from combining global
1344 symbols. Unfortunately, some C libraries use this practise, so you
1345 may get some warnings about symbols in the libraries as well as in
1346 your programs.
1347
1348 There are three kinds of global symbols, illustrated here by C
1349 examples:
1350
1351 int i = 1;
1352 A definition, which goes in the initialized data section of the
1353 output file.
1354
1355 extern int i;
1356 An undefined reference, which does not allocate space. There
1357 must be either a definition or a common symbol for the variable
1358 somewhere.
1359
1360 int i;
1361 A common symbol. If there are only (one or more) common
1362 symbols for a variable, it goes in the uninitialized data area
1363 of the output file. The linker merges multiple common symbols
1364 for the same variable into a single symbol. If they are of
1365 different sizes, it picks the largest size. The linker turns a
1366 common symbol into a declaration, if there is a definition of
1367 the same variable.
1368
1369 The --warn-common option can produce five kinds of warnings. Each
1370 warning consists of a pair of lines: the first describes the symbol
1371 just encountered, and the second describes the previous symbol
1372 encountered with the same name. One or both of the two symbols
1373 will be a common symbol.
1374
1375 1. Turning a common symbol into a reference, because there is
1376 already a definition for the symbol.
1377
1378 <file>(<section>): warning: common of `<symbol>'
1379 overridden by definition
1380 <file>(<section>): warning: defined here
1381
1382 2. Turning a common symbol into a reference, because a later
1383 definition for the symbol is encountered. This is the same as
1384 the previous case, except that the symbols are encountered in a
1385 different order.
1386
1387 <file>(<section>): warning: definition of `<symbol>'
1388 overriding common
1389 <file>(<section>): warning: common is here
1390
1391 3. Merging a common symbol with a previous same-sized common
1392 symbol.
1393
1394 <file>(<section>): warning: multiple common
1395 of `<symbol>'
1396 <file>(<section>): warning: previous common is here
1397
1398 4. Merging a common symbol with a previous larger common symbol.
1399
1400 <file>(<section>): warning: common of `<symbol>'
1401 overridden by larger common
1402 <file>(<section>): warning: larger common is here
1403
1404 5. Merging a common symbol with a previous smaller common symbol.
1405 This is the same as the previous case, except that the symbols
1406 are encountered in a different order.
1407
1408 <file>(<section>): warning: common of `<symbol>'
1409 overriding smaller common
1410 <file>(<section>): warning: smaller common is here
1411
1412 --warn-constructors
1413 Warn if any global constructors are used. This is only useful for
1414 a few object file formats. For formats like COFF or ELF, the
1415 linker can not detect the use of global constructors.
1416
1417 --warn-multiple-gp
1418 Warn if multiple global pointer values are required in the output
1419 file. This is only meaningful for certain processors, such as the
1420 Alpha. Specifically, some processors put large-valued constants in
1421 a special section. A special register (the global pointer) points
1422 into the middle of this section, so that constants can be loaded
1423 efficiently via a base-register relative addressing mode. Since
1424 the offset in base-register relative mode is fixed and relatively
1425 small (e.g., 16 bits), this limits the maximum size of the constant
1426 pool. Thus, in large programs, it is often necessary to use
1427 multiple global pointer values in order to be able to address all
1428 possible constants. This option causes a warning to be issued
1429 whenever this case occurs.
1430
1431 --warn-once
1432 Only warn once for each undefined symbol, rather than once per
1433 module which refers to it.
1434
1435 --warn-section-align
1436 Warn if the address of an output section is changed because of
1437 alignment. Typically, the alignment will be set by an input
1438 section. The address will only be changed if it not explicitly
1439 specified; that is, if the "SECTIONS" command does not specify a
1440 start address for the section.
1441
1442 --warn-shared-textrel
1443 Warn if the linker adds a DT_TEXTREL to a shared object.
1444
1445 --warn-alternate-em
1446 Warn if an object has alternate ELF machine code.
1447
1448 --warn-unresolved-symbols
1449 If the linker is going to report an unresolved symbol (see the
1450 option --unresolved-symbols) it will normally generate an error.
1451 This option makes it generate a warning instead.
1452
1453 --error-unresolved-symbols
1454 This restores the linker's default behaviour of generating errors
1455 when it is reporting unresolved symbols.
1456
1457 --whole-archive
1458 For each archive mentioned on the command line after the
1459 --whole-archive option, include every object file in the archive in
1460 the link, rather than searching the archive for the required object
1461 files. This is normally used to turn an archive file into a shared
1462 library, forcing every object to be included in the resulting
1463 shared library. This option may be used more than once.
1464
1465 Two notes when using this option from gcc: First, gcc doesn't know
1466 about this option, so you have to use -Wl,-whole-archive. Second,
1467 don't forget to use -Wl,-no-whole-archive after your list of
1468 archives, because gcc will add its own list of archives to your
1469 link and you may not want this flag to affect those as well.
1470
1471 --wrap=symbol
1472 Use a wrapper function for symbol. Any undefined reference to
1473 symbol will be resolved to "__wrap_symbol". Any undefined
1474 reference to "__real_symbol" will be resolved to symbol.
1475
1476 This can be used to provide a wrapper for a system function. The
1477 wrapper function should be called "__wrap_symbol". If it wishes to
1478 call the system function, it should call "__real_symbol".
1479
1480 Here is a trivial example:
1481
1482 void *
1483 __wrap_malloc (size_t c)
1484 {
1485 printf ("malloc called with %zu\n", c);
1486 return __real_malloc (c);
1487 }
1488
1489 If you link other code with this file using --wrap malloc, then all
1490 calls to "malloc" will call the function "__wrap_malloc" instead.
1491 The call to "__real_malloc" in "__wrap_malloc" will call the real
1492 "malloc" function.
1493
1494 You may wish to provide a "__real_malloc" function as well, so that
1495 links without the --wrap option will succeed. If you do this, you
1496 should not put the definition of "__real_malloc" in the same file
1497 as "__wrap_malloc"; if you do, the assembler may resolve the call
1498 before the linker has a chance to wrap it to "malloc".
1499
1500 --eh-frame-hdr
1501 Request creation of ".eh_frame_hdr" section and ELF
1502 "PT_GNU_EH_FRAME" segment header.
1503
1504 --enable-new-dtags
1505 --disable-new-dtags
1506 This linker can create the new dynamic tags in ELF. But the older
1507 ELF systems may not understand them. If you specify
1508 --enable-new-dtags, the dynamic tags will be created as needed. If
1509 you specify --disable-new-dtags, no new dynamic tags will be
1510 created. By default, the new dynamic tags are not created. Note
1511 that those options are only available for ELF systems.
1512
1513 --hash-size=number
1514 Set the default size of the linker's hash tables to a prime number
1515 close to number. Increasing this value can reduce the length of
1516 time it takes the linker to perform its tasks, at the expense of
1517 increasing the linker's memory requirements. Similarly reducing
1518 this value can reduce the memory requirements at the expense of
1519 speed.
1520
1521 --hash-style=style
1522 Set the type of linker's hash table(s). style can be either "sysv"
1523 for classic ELF ".hash" section, "gnu" for new style GNU
1524 ".gnu.hash" section or "both" for both the classic ELF ".hash" and
1525 new style GNU ".gnu.hash" hash tables. The default is "sysv".
1526
1527 --reduce-memory-overheads
1528 This option reduces memory requirements at ld runtime, at the
1529 expense of linking speed. This was introduced to select the old
1530 O(n^2) algorithm for link map file generation, rather than the new
1531 O(n) algorithm which uses about 40% more memory for symbol storage.
1532
1533 Another effect of the switch is to set the default hash table size
1534 to 1021, which again saves memory at the cost of lengthening the
1535 linker's run time. This is not done however if the --hash-size
1536 switch has been used.
1537
1538 The --reduce-memory-overheads switch may be also be used to enable
1539 other tradeoffs in future versions of the linker.
1540
1541 --build-id
1542 --build-id=style
1543 Request creation of ".note.gnu.build-id" ELF note section. The
1544 contents of the note are unique bits identifying this linked file.
1545 style can be "uuid" to use 128 random bits, "sha1" to use a 160-bit
1546 SHA1 hash on the normative parts of the output contents, "md5" to
1547 use a 128-bit MD5 hash on the normative parts of the output
1548 contents, or "0xhexstring" to use a chosen bit string specified as
1549 an even number of hexadecimal digits ("-" and ":" characters
1550 between digit pairs are ignored). If style is omitted, "sha1" is
1551 used.
1552
1553 The "md5" and "sha1" styles produces an identifier that is always
1554 the same in an identical output file, but will be unique among all
1555 nonidentical output files. It is not intended to be compared as a
1556 checksum for the file's contents. A linked file may be changed
1557 later by other tools, but the build ID bit string identifying the
1558 original linked file does not change.
1559
1560 Passing "none" for style disables the setting from any "--build-id"
1561 options earlier on the command line.
1562
1563 The i386 PE linker supports the -shared option, which causes the output
1564 to be a dynamically linked library (DLL) instead of a normal
1565 executable. You should name the output "*.dll" when you use this
1566 option. In addition, the linker fully supports the standard "*.def"
1567 files, which may be specified on the linker command line like an object
1568 file (in fact, it should precede archives it exports symbols from, to
1569 ensure that they get linked in, just like a normal object file).
1570
1571 In addition to the options common to all targets, the i386 PE linker
1572 support additional command line options that are specific to the i386
1573 PE target. Options that take values may be separated from their values
1574 by either a space or an equals sign.
1575
1576 --add-stdcall-alias
1577 If given, symbols with a stdcall suffix (@nn) will be exported as-
1578 is and also with the suffix stripped. [This option is specific to
1579 the i386 PE targeted port of the linker]
1580
1581 --base-file file
1582 Use file as the name of a file in which to save the base addresses
1583 of all the relocations needed for generating DLLs with dlltool.
1584 [This is an i386 PE specific option]
1585
1586 --dll
1587 Create a DLL instead of a regular executable. You may also use
1588 -shared or specify a "LIBRARY" in a given ".def" file. [This
1589 option is specific to the i386 PE targeted port of the linker]
1590
1591 --enable-long-section-names
1592 --disable-long-section-names
1593 The PE variants of the Coff object format add an extension that
1594 permits the use of section names longer than eight characters, the
1595 normal limit for Coff. By default, these names are only allowed in
1596 object files, as fully-linked executable images do not carry the
1597 Coff string table required to support the longer names. As a GNU
1598 extension, it is possible to allow their use in executable images
1599 as well, or to (probably pointlessly!) disallow it in object
1600 files, by using these two options. Executable images generated
1601 with these long section names are slightly non-standard, carrying
1602 as they do a string table, and may generate confusing output when
1603 examined with non-GNU PE-aware tools, such as file viewers and
1604 dumpers. However, GDB relies on the use of PE long section names
1605 to find Dwarf-2 debug information sections in an executable image
1606 at runtime, and so if neither option is specified on the command-
1607 line, ld will enable long section names, overriding the default and
1608 technically correct behaviour, when it finds the presence of debug
1609 information while linking an executable image and not stripping
1610 symbols. [This option is valid for all PE targeted ports of the
1611 linker]
1612
1613 --enable-stdcall-fixup
1614 --disable-stdcall-fixup
1615 If the link finds a symbol that it cannot resolve, it will attempt
1616 to do "fuzzy linking" by looking for another defined symbol that
1617 differs only in the format of the symbol name (cdecl vs stdcall)
1618 and will resolve that symbol by linking to the match. For example,
1619 the undefined symbol "_foo" might be linked to the function
1620 "_foo@12", or the undefined symbol "_bar@16" might be linked to the
1621 function "_bar". When the linker does this, it prints a warning,
1622 since it normally should have failed to link, but sometimes import
1623 libraries generated from third-party dlls may need this feature to
1624 be usable. If you specify --enable-stdcall-fixup, this feature is
1625 fully enabled and warnings are not printed. If you specify
1626 --disable-stdcall-fixup, this feature is disabled and such
1627 mismatches are considered to be errors. [This option is specific
1628 to the i386 PE targeted port of the linker]
1629
1630 --export-all-symbols
1631 If given, all global symbols in the objects used to build a DLL
1632 will be exported by the DLL. Note that this is the default if
1633 there otherwise wouldn't be any exported symbols. When symbols are
1634 explicitly exported via DEF files or implicitly exported via
1635 function attributes, the default is to not export anything else
1636 unless this option is given. Note that the symbols "DllMain@12",
1637 "DllEntryPoint@0", "DllMainCRTStartup@12", and "impure_ptr" will
1638 not be automatically exported. Also, symbols imported from other
1639 DLLs will not be re-exported, nor will symbols specifying the DLL's
1640 internal layout such as those beginning with "_head_" or ending
1641 with "_iname". In addition, no symbols from "libgcc", "libstd++",
1642 "libmingw32", or "crtX.o" will be exported. Symbols whose names
1643 begin with "__rtti_" or "__builtin_" will not be exported, to help
1644 with C++ DLLs. Finally, there is an extensive list of cygwin-
1645 private symbols that are not exported (obviously, this applies on
1646 when building DLLs for cygwin targets). These cygwin-excludes are:
1647 "_cygwin_dll_entry@12", "_cygwin_crt0_common@8",
1648 "_cygwin_noncygwin_dll_entry@12", "_fmode", "_impure_ptr",
1649 "cygwin_attach_dll", "cygwin_premain0", "cygwin_premain1",
1650 "cygwin_premain2", "cygwin_premain3", and "environ". [This option
1651 is specific to the i386 PE targeted port of the linker]
1652
1653 --exclude-symbols symbol,symbol,...
1654 Specifies a list of symbols which should not be automatically
1655 exported. The symbol names may be delimited by commas or colons.
1656 [This option is specific to the i386 PE targeted port of the
1657 linker]
1658
1659 --exclude-all-symbols
1660 Specifies no symbols should be automatically exported. [This
1661 option is specific to the i386 PE targeted port of the linker]
1662
1663 --file-alignment
1664 Specify the file alignment. Sections in the file will always begin
1665 at file offsets which are multiples of this number. This defaults
1666 to 512. [This option is specific to the i386 PE targeted port of
1667 the linker]
1668
1669 --heap reserve
1670 --heap reserve,commit
1671 Specify the number of bytes of memory to reserve (and optionally
1672 commit) to be used as heap for this program. The default is 1Mb
1673 reserved, 4K committed. [This option is specific to the i386 PE
1674 targeted port of the linker]
1675
1676 --image-base value
1677 Use value as the base address of your program or dll. This is the
1678 lowest memory location that will be used when your program or dll
1679 is loaded. To reduce the need to relocate and improve performance
1680 of your dlls, each should have a unique base address and not
1681 overlap any other dlls. The default is 0x400000 for executables,
1682 and 0x10000000 for dlls. [This option is specific to the i386 PE
1683 targeted port of the linker]
1684
1685 --kill-at
1686 If given, the stdcall suffixes (@nn) will be stripped from symbols
1687 before they are exported. [This option is specific to the i386 PE
1688 targeted port of the linker]
1689
1690 --large-address-aware
1691 If given, the appropriate bit in the "Characteristics" field of the
1692 COFF header is set to indicate that this executable supports
1693 virtual addresses greater than 2 gigabytes. This should be used in
1694 conjunction with the /3GB or /USERVA=value megabytes switch in the
1695 "[operating systems]" section of the BOOT.INI. Otherwise, this bit
1696 has no effect. [This option is specific to PE targeted ports of
1697 the linker]
1698
1699 --major-image-version value
1700 Sets the major number of the "image version". Defaults to 1.
1701 [This option is specific to the i386 PE targeted port of the
1702 linker]
1703
1704 --major-os-version value
1705 Sets the major number of the "os version". Defaults to 4. [This
1706 option is specific to the i386 PE targeted port of the linker]
1707
1708 --major-subsystem-version value
1709 Sets the major number of the "subsystem version". Defaults to 4.
1710 [This option is specific to the i386 PE targeted port of the
1711 linker]
1712
1713 --minor-image-version value
1714 Sets the minor number of the "image version". Defaults to 0.
1715 [This option is specific to the i386 PE targeted port of the
1716 linker]
1717
1718 --minor-os-version value
1719 Sets the minor number of the "os version". Defaults to 0. [This
1720 option is specific to the i386 PE targeted port of the linker]
1721
1722 --minor-subsystem-version value
1723 Sets the minor number of the "subsystem version". Defaults to 0.
1724 [This option is specific to the i386 PE targeted port of the
1725 linker]
1726
1727 --output-def file
1728 The linker will create the file file which will contain a DEF file
1729 corresponding to the DLL the linker is generating. This DEF file
1730 (which should be called "*.def") may be used to create an import
1731 library with "dlltool" or may be used as a reference to
1732 automatically or implicitly exported symbols. [This option is
1733 specific to the i386 PE targeted port of the linker]
1734
1735 --out-implib file
1736 The linker will create the file file which will contain an import
1737 lib corresponding to the DLL the linker is generating. This import
1738 lib (which should be called "*.dll.a" or "*.a" may be used to link
1739 clients against the generated DLL; this behaviour makes it possible
1740 to skip a separate "dlltool" import library creation step. [This
1741 option is specific to the i386 PE targeted port of the linker]
1742
1743 --enable-auto-image-base
1744 Automatically choose the image base for DLLs, unless one is
1745 specified using the "--image-base" argument. By using a hash
1746 generated from the dllname to create unique image bases for each
1747 DLL, in-memory collisions and relocations which can delay program
1748 execution are avoided. [This option is specific to the i386 PE
1749 targeted port of the linker]
1750
1751 --disable-auto-image-base
1752 Do not automatically generate a unique image base. If there is no
1753 user-specified image base ("--image-base") then use the platform
1754 default. [This option is specific to the i386 PE targeted port of
1755 the linker]
1756
1757 --dll-search-prefix string
1758 When linking dynamically to a dll without an import library, search
1759 for "<string><basename>.dll" in preference to "lib<basename>.dll".
1760 This behaviour allows easy distinction between DLLs built for the
1761 various "subplatforms": native, cygwin, uwin, pw, etc. For
1762 instance, cygwin DLLs typically use "--dll-search-prefix=cyg".
1763 [This option is specific to the i386 PE targeted port of the
1764 linker]
1765
1766 --enable-auto-import
1767 Do sophisticated linking of "_symbol" to "__imp__symbol" for DATA
1768 imports from DLLs, and create the necessary thunking symbols when
1769 building the import libraries with those DATA exports. Note: Use of
1770 the 'auto-import' extension will cause the text section of the
1771 image file to be made writable. This does not conform to the PE-
1772 COFF format specification published by Microsoft.
1773
1774 Note - use of the 'auto-import' extension will also cause read only
1775 data which would normally be placed into the .rdata section to be
1776 placed into the .data section instead. This is in order to work
1777 around a problem with consts that is described here:
1778 http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
1779
1780 Using 'auto-import' generally will 'just work' -- but sometimes you
1781 may see this message:
1782
1783 "variable '<var>' can't be auto-imported. Please read the
1784 documentation for ld's "--enable-auto-import" for details."
1785
1786 This message occurs when some (sub)expression accesses an address
1787 ultimately given by the sum of two constants (Win32 import tables
1788 only allow one). Instances where this may occur include accesses
1789 to member fields of struct variables imported from a DLL, as well
1790 as using a constant index into an array variable imported from a
1791 DLL. Any multiword variable (arrays, structs, long long, etc) may
1792 trigger this error condition. However, regardless of the exact
1793 data type of the offending exported variable, ld will always detect
1794 it, issue the warning, and exit.
1795
1796 There are several ways to address this difficulty, regardless of
1797 the data type of the exported variable:
1798
1799 One way is to use --enable-runtime-pseudo-reloc switch. This leaves
1800 the task of adjusting references in your client code for runtime
1801 environment, so this method works only when runtime environment
1802 supports this feature.
1803
1804 A second solution is to force one of the 'constants' to be a
1805 variable -- that is, unknown and un-optimizable at compile time.
1806 For arrays, there are two possibilities: a) make the indexee (the
1807 array's address) a variable, or b) make the 'constant' index a
1808 variable. Thus:
1809
1810 extern type extern_array[];
1811 extern_array[1] -->
1812 { volatile type *t=extern_array; t[1] }
1813
1814 or
1815
1816 extern type extern_array[];
1817 extern_array[1] -->
1818 { volatile int t=1; extern_array[t] }
1819
1820 For structs (and most other multiword data types) the only option
1821 is to make the struct itself (or the long long, or the ...)
1822 variable:
1823
1824 extern struct s extern_struct;
1825 extern_struct.field -->
1826 { volatile struct s *t=&extern_struct; t->field }
1827
1828 or
1829
1830 extern long long extern_ll;
1831 extern_ll -->
1832 { volatile long long * local_ll=&extern_ll; *local_ll }
1833
1834 A third method of dealing with this difficulty is to abandon
1835 'auto-import' for the offending symbol and mark it with
1836 "__declspec(dllimport)". However, in practise that requires using
1837 compile-time #defines to indicate whether you are building a DLL,
1838 building client code that will link to the DLL, or merely
1839 building/linking to a static library. In making the choice
1840 between the various methods of resolving the 'direct address with
1841 constant offset' problem, you should consider typical real-world
1842 usage:
1843
1844 Original:
1845
1846 --foo.h
1847 extern int arr[];
1848 --foo.c
1849 #include "foo.h"
1850 void main(int argc, char **argv){
1851 printf("%d\n",arr[1]);
1852 }
1853
1854 Solution 1:
1855
1856 --foo.h
1857 extern int arr[];
1858 --foo.c
1859 #include "foo.h"
1860 void main(int argc, char **argv){
1861 /* This workaround is for win32 and cygwin; do not "optimize" */
1862 volatile int *parr = arr;
1863 printf("%d\n",parr[1]);
1864 }
1865
1866 Solution 2:
1867
1868 --foo.h
1869 /* Note: auto-export is assumed (no __declspec(dllexport)) */
1870 #if (defined(_WIN32) || defined(__CYGWIN__)) && \
1871 !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
1872 #define FOO_IMPORT __declspec(dllimport)
1873 #else
1874 #define FOO_IMPORT
1875 #endif
1876 extern FOO_IMPORT int arr[];
1877 --foo.c
1878 #include "foo.h"
1879 void main(int argc, char **argv){
1880 printf("%d\n",arr[1]);
1881 }
1882
1883 A fourth way to avoid this problem is to re-code your library to
1884 use a functional interface rather than a data interface for the
1885 offending variables (e.g. set_foo() and get_foo() accessor
1886 functions). [This option is specific to the i386 PE targeted port
1887 of the linker]
1888
1889 --disable-auto-import
1890 Do not attempt to do sophisticated linking of "_symbol" to
1891 "__imp__symbol" for DATA imports from DLLs. [This option is
1892 specific to the i386 PE targeted port of the linker]
1893
1894 --enable-runtime-pseudo-reloc
1895 If your code contains expressions described in --enable-auto-import
1896 section, that is, DATA imports from DLL with non-zero offset, this
1897 switch will create a vector of 'runtime pseudo relocations' which
1898 can be used by runtime environment to adjust references to such
1899 data in your client code. [This option is specific to the i386 PE
1900 targeted port of the linker]
1901
1902 --disable-runtime-pseudo-reloc
1903 Do not create pseudo relocations for non-zero offset DATA imports
1904 from DLLs. This is the default. [This option is specific to the
1905 i386 PE targeted port of the linker]
1906
1907 --enable-extra-pe-debug
1908 Show additional debug info related to auto-import symbol thunking.
1909 [This option is specific to the i386 PE targeted port of the
1910 linker]
1911
1912 --section-alignment
1913 Sets the section alignment. Sections in memory will always begin
1914 at addresses which are a multiple of this number. Defaults to
1915 0x1000. [This option is specific to the i386 PE targeted port of
1916 the linker]
1917
1918 --stack reserve
1919 --stack reserve,commit
1920 Specify the number of bytes of memory to reserve (and optionally
1921 commit) to be used as stack for this program. The default is 2Mb
1922 reserved, 4K committed. [This option is specific to the i386 PE
1923 targeted port of the linker]
1924
1925 --subsystem which
1926 --subsystem which:major
1927 --subsystem which:major.minor
1928 Specifies the subsystem under which your program will execute. The
1929 legal values for which are "native", "windows", "console", "posix",
1930 and "xbox". You may optionally set the subsystem version also.
1931 Numeric values are also accepted for which. [This option is
1932 specific to the i386 PE targeted port of the linker]
1933
1934 The following options set flags in the "DllCharacteristics" field
1935 of the PE file header: [These options are specific to PE targeted
1936 ports of the linker]
1937
1938 --dynamicbase
1939 The image base address may be relocated using address space layout
1940 randomization (ASLR). This feature was introduced with MS Windows
1941 Vista for i386 PE targets.
1942
1943 --forceinteg
1944 Code integrity checks are enforced.
1945
1946 --nxcompat
1947 The image is compatible with the Data Execution Prevention. This
1948 feature was introduced with MS Windows XP SP2 for i386 PE targets.
1949
1950 --no-isolation
1951 Although the image understands isolation, do not isolate the image.
1952
1953 --no-seh
1954 The image does not use SEH. No SE handler may be called from this
1955 image.
1956
1957 --no-bind
1958 Do not bind this image.
1959
1960 --wdmdriver
1961 The driver uses the MS Windows Driver Model.
1962
1963 --tsaware
1964 The image is Terminal Server aware.
1965
1966 The 68HC11 and 68HC12 linkers support specific options to control the
1967 memory bank switching mapping and trampoline code generation.
1968
1969 --no-trampoline
1970 This option disables the generation of trampoline. By default a
1971 trampoline is generated for each far function which is called using
1972 a "jsr" instruction (this happens when a pointer to a far function
1973 is taken).
1974
1975 --bank-window name
1976 This option indicates to the linker the name of the memory region
1977 in the MEMORY specification that describes the memory bank window.
1978 The definition of such region is then used by the linker to compute
1979 paging and addresses within the memory window.
1980
1981 The following options are supported to control handling of GOT
1982 generation when linking for 68K targets.
1983
1984 --got=type
1985 This option tells the linker which GOT generation scheme to use.
1986 type should be one of single, negative, multigot or target. For
1987 more information refer to the Info entry for ld.
1988
1990 You can change the behaviour of ld with the environment variables
1991 "GNUTARGET", "LDEMULATION" and "COLLECT_NO_DEMANGLE".
1992
1993 "GNUTARGET" determines the input-file object format if you don't use -b
1994 (or its synonym --format). Its value should be one of the BFD names
1995 for an input format. If there is no "GNUTARGET" in the environment, ld
1996 uses the natural format of the target. If "GNUTARGET" is set to
1997 "default" then BFD attempts to discover the input format by examining
1998 binary input files; this method often succeeds, but there are potential
1999 ambiguities, since there is no method of ensuring that the magic number
2000 used to specify object-file formats is unique. However, the
2001 configuration procedure for BFD on each system places the conventional
2002 format for that system first in the search-list, so ambiguities are
2003 resolved in favor of convention.
2004
2005 "LDEMULATION" determines the default emulation if you don't use the -m
2006 option. The emulation can affect various aspects of linker behaviour,
2007 particularly the default linker script. You can list the available
2008 emulations with the --verbose or -V options. If the -m option is not
2009 used, and the "LDEMULATION" environment variable is not defined, the
2010 default emulation depends upon how the linker was configured.
2011
2012 Normally, the linker will default to demangling symbols. However, if
2013 "COLLECT_NO_DEMANGLE" is set in the environment, then it will default
2014 to not demangling symbols. This environment variable is used in a
2015 similar fashion by the "gcc" linker wrapper program. The default may
2016 be overridden by the --demangle and --no-demangle options.
2017
2019 ar(1), nm(1), objcopy(1), objdump(1), readelf(1) and the Info entries
2020 for binutils and ld.
2021
2023 Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002,
2024 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
2025
2026 Permission is granted to copy, distribute and/or modify this document
2027 under the terms of the GNU Free Documentation License, Version 1.3 or
2028 any later version published by the Free Software Foundation; with no
2029 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
2030 Texts. A copy of the license is included in the section entitled "GNU
2031 Free Documentation License".
2032
2033
2034
2035binutils-2.20.51.0.7 2011-05-02 LD(1)