1 This is ld.info, produced by makeinfo version 4.6 from ./ld.texinfo.
4 * Ld: (ld). The GNU linker.
7 This file documents the GNU linker LD version 2.15.
9 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001,
10 2002, 2003, 2004 Free Software Foundation, Inc.
13 File: ld.info, Node: Top, Next: Overview, Up: (dir)
18 This file documents the GNU linker ld version 2.15.
20 This document is distributed under the terms of the GNU Free
21 Documentation License. A copy of the license is included in the
22 section entitled "GNU Free Documentation License".
27 * Invocation:: Invocation
28 * Scripts:: Linker Scripts
30 * Machine Dependent:: Machine Dependent Features
34 * Reporting Bugs:: Reporting Bugs
35 * MRI:: MRI Compatible Script Files
36 * GNU Free Documentation License:: GNU Free Documentation License
40 File: ld.info, Node: Overview, Next: Invocation, Prev: Top, Up: Top
45 `ld' combines a number of object and archive files, relocates their
46 data and ties up symbol references. Usually the last step in compiling
47 a program is to run `ld'.
49 `ld' accepts Linker Command Language files written in a superset of
50 AT&T's Link Editor Command Language syntax, to provide explicit and
51 total control over the linking process.
53 This version of `ld' uses the general purpose BFD libraries to
54 operate on object files. This allows `ld' to read, combine, and write
55 object files in many different formats--for example, COFF or `a.out'.
56 Different formats may be linked together to produce any available kind
57 of object file. *Note BFD::, for more information.
59 Aside from its flexibility, the GNU linker is more helpful than other
60 linkers in providing diagnostic information. Many linkers abandon
61 execution immediately upon encountering an error; whenever possible,
62 `ld' continues executing, allowing you to identify other errors (or, in
63 some cases, to get an output file in spite of the error).
66 File: ld.info, Node: Invocation, Next: Scripts, Prev: Overview, Up: Top
71 The GNU linker `ld' is meant to cover a broad range of situations, and
72 to be as compatible as possible with other linkers. As a result, you
73 have many choices to control its behavior.
77 * Options:: Command Line Options
78 * Environment:: Environment Variables
81 File: ld.info, Node: Options, Next: Environment, Up: Invocation
86 The linker supports a plethora of command-line options, but in actual
87 practice few of them are used in any particular context. For instance,
88 a frequent use of `ld' is to link standard Unix object files on a
89 standard, supported Unix system. On such a system, to link a file
92 ld -o OUTPUT /lib/crt0.o hello.o -lc
94 This tells `ld' to produce a file called OUTPUT as the result of
95 linking the file `/lib/crt0.o' with `hello.o' and the library `libc.a',
96 which will come from the standard search directories. (See the
97 discussion of the `-l' option below.)
99 Some of the command-line options to `ld' may be specified at any
100 point in the command line. However, options which refer to files, such
101 as `-l' or `-T', cause the file to be read at the point at which the
102 option appears in the command line, relative to the object files and
103 other file options. Repeating non-file options with a different
104 argument will either have no further effect, or override prior
105 occurrences (those further to the left on the command line) of that
106 option. Options which may be meaningfully specified more than once are
107 noted in the descriptions below.
109 Non-option arguments are object files or archives which are to be
110 linked together. They may follow, precede, or be mixed in with
111 command-line options, except that an object file argument may not be
112 placed between an option and its argument.
114 Usually the linker is invoked with at least one object file, but you
115 can specify other forms of binary input files using `-l', `-R', and the
116 script command language. If _no_ binary input files at all are
117 specified, the linker does not produce any output, and issues the
118 message `No input files'.
120 If the linker cannot recognize the format of an object file, it will
121 assume that it is a linker script. A script specified in this way
122 augments the main linker script used for the link (either the default
123 linker script or the one specified by using `-T'). This feature
124 permits the linker to link against a file which appears to be an object
125 or an archive, but actually merely defines some symbol values, or uses
126 `INPUT' or `GROUP' to load other objects. Note that specifying a
127 script in this way merely augments the main linker script; use the `-T'
128 option to replace the default linker script entirely. *Note Scripts::.
130 For options whose names are a single letter, option arguments must
131 either follow the option letter without intervening whitespace, or be
132 given as separate arguments immediately following the option that
135 For options whose names are multiple letters, either one dash or two
136 can precede the option name; for example, `-trace-symbol' and
137 `--trace-symbol' are equivalent. Note--there is one exception to this
138 rule. Multiple letter options that start with a lower case 'o' can
139 only be preceeded by two dashes. This is to reduce confusion with the
140 `-o' option. So for example `-omagic' sets the output file name to
141 `magic' whereas `--omagic' sets the NMAGIC flag on the output.
143 Arguments to multiple-letter options must either be separated from
144 the option name by an equals sign, or be given as separate arguments
145 immediately following the option that requires them. For example,
146 `--trace-symbol foo' and `--trace-symbol=foo' are equivalent. Unique
147 abbreviations of the names of multiple-letter options are accepted.
149 Note--if the linker is being invoked indirectly, via a compiler
150 driver (e.g. `gcc') then all the linker command line options should be
151 prefixed by `-Wl,' (or whatever is appropriate for the particular
152 compiler driver) like this:
154 gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup
156 This is important, because otherwise the compiler driver program may
157 silently drop the linker options, resulting in a bad link.
159 Here is a table of the generic command line switches accepted by the
163 This option is supported for HP/UX compatibility. The KEYWORD
164 argument must be one of the strings `archive', `shared', or
165 `default'. `-aarchive' is functionally equivalent to `-Bstatic',
166 and the other two keywords are functionally equivalent to
167 `-Bdynamic'. This option may be used any number of times.
170 `--architecture=ARCHITECTURE'
171 In the current release of `ld', this option is useful only for the
172 Intel 960 family of architectures. In that `ld' configuration, the
173 ARCHITECTURE argument identifies the particular architecture in
174 the 960 family, enabling some safeguards and modifying the
175 archive-library search path. *Note `ld' and the Intel 960 family:
178 Future releases of `ld' may support similar functionality for
179 other architecture families.
182 `--format=INPUT-FORMAT'
183 `ld' may be configured to support more than one kind of object
184 file. If your `ld' is configured this way, you can use the `-b'
185 option to specify the binary format for input object files that
186 follow this option on the command line. Even when `ld' is
187 configured to support alternative object formats, you don't
188 usually need to specify this, as `ld' should be configured to
189 expect as a default input format the most usual format on each
190 machine. INPUT-FORMAT is a text string, the name of a particular
191 format supported by the BFD libraries. (You can list the
192 available binary formats with `objdump -i'.) *Note BFD::.
194 You may want to use this option if you are linking files with an
195 unusual binary format. You can also use `-b' to switch formats
196 explicitly (when linking object files of different formats), by
197 including `-b INPUT-FORMAT' before each group of object files in a
200 The default format is taken from the environment variable
201 `GNUTARGET'. *Note Environment::. You can also define the input
202 format from a script, using the command `TARGET'; see *Note Format
206 `--mri-script=MRI-COMMANDFILE'
207 For compatibility with linkers produced by MRI, `ld' accepts script
208 files written in an alternate, restricted command language,
209 described in *Note MRI Compatible Script Files: MRI. Introduce
210 MRI script files with the option `-c'; use the `-T' option to run
211 linker scripts written in the general-purpose `ld' scripting
212 language. If MRI-CMDFILE does not exist, `ld' looks for it in the
213 directories specified by any `-L' options.
218 These three options are equivalent; multiple forms are supported
219 for compatibility with other linkers. They assign space to common
220 symbols even if a relocatable output file is specified (with
221 `-r'). The script command `FORCE_COMMON_ALLOCATION' has the same
222 effect. *Note Miscellaneous Commands::.
226 Use ENTRY as the explicit symbol for beginning execution of your
227 program, rather than the default entry point. If there is no
228 symbol named ENTRY, the linker will try to parse ENTRY as a number,
229 and use that as the entry address (the number will be interpreted
230 in base 10; you may use a leading `0x' for base 16, or a leading
231 `0' for base 8). *Note Entry Point::, for a discussion of defaults
232 and other ways of specifying the entry point.
236 When creating a dynamically linked executable, add all symbols to
237 the dynamic symbol table. The dynamic symbol table is the set of
238 symbols which are visible from dynamic objects at run time.
240 If you do not use this option, the dynamic symbol table will
241 normally contain only those symbols which are referenced by some
242 dynamic object mentioned in the link.
244 If you use `dlopen' to load a dynamic object which needs to refer
245 back to the symbols defined by the program, rather than some other
246 dynamic object, then you will probably need to use this option when
247 linking the program itself.
249 You can also use the version script to control what symbols should
250 be added to the dynamic symbol table if the output format supports
251 it. See the description of `--version-script' in *Note VERSION::.
254 Link big-endian objects. This affects the default output format.
257 Link little-endian objects. This affects the default output
262 When creating an ELF shared object, set the internal DT_AUXILIARY
263 field to the specified name. This tells the dynamic linker that
264 the symbol table of the shared object should be used as an
265 auxiliary filter on the symbol table of the shared object NAME.
267 If you later link a program against this filter object, then, when
268 you run the program, the dynamic linker will see the DT_AUXILIARY
269 field. If the dynamic linker resolves any symbols from the filter
270 object, it will first check whether there is a definition in the
271 shared object NAME. If there is one, it will be used instead of
272 the definition in the filter object. The shared object NAME need
273 not exist. Thus the shared object NAME may be used to provide an
274 alternative implementation of certain functions, perhaps for
275 debugging or for machine specific performance.
277 This option may be specified more than once. The DT_AUXILIARY
278 entries will be created in the order in which they appear on the
283 When creating an ELF shared object, set the internal DT_FILTER
284 field to the specified name. This tells the dynamic linker that
285 the symbol table of the shared object which is being created
286 should be used as a filter on the symbol table of the shared
289 If you later link a program against this filter object, then, when
290 you run the program, the dynamic linker will see the DT_FILTER
291 field. The dynamic linker will resolve symbols according to the
292 symbol table of the filter object as usual, but it will actually
293 link to the definitions found in the shared object NAME. Thus the
294 filter object can be used to select a subset of the symbols
295 provided by the object NAME.
297 Some older linkers used the `-F' option throughout a compilation
298 toolchain for specifying object-file format for both input and
299 output object files. The GNU linker uses other mechanisms for
300 this purpose: the `-b', `--format', `--oformat' options, the
301 `TARGET' command in linker scripts, and the `GNUTARGET'
302 environment variable. The GNU linker will ignore the `-F' option
303 when not creating an ELF shared object.
306 When creating an ELF executable or shared object, call NAME when
307 the executable or shared object is unloaded, by setting DT_FINI to
308 the address of the function. By default, the linker uses `_fini'
309 as the function to call.
312 Ignored. Provided for compatibility with other tools.
316 Set the maximum size of objects to be optimized using the GP
317 register to SIZE. This is only meaningful for object file formats
318 such as MIPS ECOFF which supports putting large and small objects
319 into different sections. This is ignored for other object file
324 When creating an ELF shared object, set the internal DT_SONAME
325 field to the specified name. When an executable is linked with a
326 shared object which has a DT_SONAME field, then when the
327 executable is run the dynamic linker will attempt to load the
328 shared object specified by the DT_SONAME field rather than the
329 using the file name given to the linker.
332 Perform an incremental link (same as option `-r').
335 When creating an ELF executable or shared object, call NAME when
336 the executable or shared object is loaded, by setting DT_INIT to
337 the address of the function. By default, the linker uses `_init'
338 as the function to call.
342 Add archive file ARCHIVE to the list of files to link. This
343 option may be used any number of times. `ld' will search its
344 path-list for occurrences of `libARCHIVE.a' for every ARCHIVE
347 On systems which support shared libraries, `ld' may also search for
348 libraries with extensions other than `.a'. Specifically, on ELF
349 and SunOS systems, `ld' will search a directory for a library with
350 an extension of `.so' before searching for one with an extension of
351 `.a'. By convention, a `.so' extension indicates a shared library.
353 The linker will search an archive only once, at the location where
354 it is specified on the command line. If the archive defines a
355 symbol which was undefined in some object which appeared before
356 the archive on the command line, the linker will include the
357 appropriate file(s) from the archive. However, an undefined
358 symbol in an object appearing later on the command line will not
359 cause the linker to search the archive again.
361 See the `-(' option for a way to force the linker to search
362 archives multiple times.
364 You may list the same archive multiple times on the command line.
366 This type of archive searching is standard for Unix linkers.
367 However, if you are using `ld' on AIX, note that it is different
368 from the behaviour of the AIX linker.
371 `--library-path=SEARCHDIR'
372 Add path SEARCHDIR to the list of paths that `ld' will search for
373 archive libraries and `ld' control scripts. You may use this
374 option any number of times. The directories are searched in the
375 order in which they are specified on the command line.
376 Directories specified on the command line are searched before the
377 default directories. All `-L' options apply to all `-l' options,
378 regardless of the order in which the options appear.
380 If SEARCHDIR begins with `=', then the `=' will be replaced by the
381 "sysroot prefix", a path specified when the linker is configured.
383 The default set of paths searched (without being specified with
384 `-L') depends on which emulation mode `ld' is using, and in some
385 cases also on how it was configured. *Note Environment::.
387 The paths can also be specified in a link script with the
388 `SEARCH_DIR' command. Directories specified this way are searched
389 at the point in which the linker script appears in the command
393 Emulate the EMULATION linker. You can list the available
394 emulations with the `--verbose' or `-V' options.
396 If the `-m' option is not used, the emulation is taken from the
397 `LDEMULATION' environment variable, if that is defined.
399 Otherwise, the default emulation depends upon how the linker was
404 Print a link map to the standard output. A link map provides
405 information about the link, including the following:
407 * Where object files and symbols are mapped into memory.
409 * How common symbols are allocated.
411 * All archive members included in the link, with a mention of
412 the symbol which caused the archive member to be brought in.
416 Turn off page alignment of sections, and mark the output as
417 `NMAGIC' if possible.
421 Set the text and data sections to be readable and writable. Also,
422 do not page-align the data segment, and disable linking against
423 shared libraries. If the output format supports Unix style magic
424 numbers, mark the output as `OMAGIC'. Note: Although a writable
425 text section is allowed for PE-COFF targets, it does not conform
426 to the format specification published by Microsoft.
429 This option negates most of the effects of the `-N' option. It
430 sets the text section to be read-only, and forces the data segment
431 to be page-aligned. Note - this option does not enable linking
432 against shared libraries. Use `-Bdynamic' for this.
436 Use OUTPUT as the name for the program produced by `ld'; if this
437 option is not specified, the name `a.out' is used by default. The
438 script command `OUTPUT' can also specify the output file name.
441 If LEVEL is a numeric values greater than zero `ld' optimizes the
442 output. This might take significantly longer and therefore
443 probably should only be enabled for the final binary.
447 Leave relocation sections and contents in fully linked
448 exececutables. Post link analysis and optimization tools may need
449 this information in order to perform correct modifications of
450 executables. This results in larger executables.
452 This option is currently only supported on ELF platforms.
456 Generate relocatable output--i.e., generate an output file that
457 can in turn serve as input to `ld'. This is often called "partial
458 linking". As a side effect, in environments that support standard
459 Unix magic numbers, this option also sets the output file's magic
460 number to `OMAGIC'. If this option is not specified, an absolute
461 file is produced. When linking C++ programs, this option _will
462 not_ resolve references to constructors; to do that, use `-Ur'.
464 When an input file does not have the same format as the output
465 file, partial linking is only supported if that input file does
466 not contain any relocations. Different output formats can have
467 further restrictions; for example some `a.out'-based formats do
468 not support partial linking with input files in other formats at
471 This option does the same thing as `-i'.
474 `--just-symbols=FILENAME'
475 Read symbol names and their addresses from FILENAME, but do not
476 relocate it or include it in the output. This allows your output
477 file to refer symbolically to absolute locations of memory defined
478 in other programs. You may use this option more than once.
480 For compatibility with other ELF linkers, if the `-R' option is
481 followed by a directory name, rather than a file name, it is
482 treated as the `-rpath' option.
486 Omit all symbol information from the output file.
490 Omit debugger symbol information (but not all symbols) from the
495 Print the names of the input files as `ld' processes them.
498 `--script=SCRIPTFILE'
499 Use SCRIPTFILE as the linker script. This script replaces `ld''s
500 default linker script (rather than adding to it), so COMMANDFILE
501 must specify everything necessary to describe the output file.
502 *Note Scripts::. If SCRIPTFILE does not exist in the current
503 directory, `ld' looks for it in the directories specified by any
504 preceding `-L' options. Multiple `-T' options accumulate.
508 Force SYMBOL to be entered in the output file as an undefined
509 symbol. Doing this may, for example, trigger linking of additional
510 modules from standard libraries. `-u' may be repeated with
511 different option arguments to enter additional undefined symbols.
512 This option is equivalent to the `EXTERN' linker script command.
515 For anything other than C++ programs, this option is equivalent to
516 `-r': it generates relocatable output--i.e., an output file that
517 can in turn serve as input to `ld'. When linking C++ programs,
518 `-Ur' _does_ resolve references to constructors, unlike `-r'. It
519 does not work to use `-Ur' on files that were themselves linked
520 with `-Ur'; once the constructor table has been built, it cannot
521 be added to. Use `-Ur' only for the last partial link, and `-r'
525 Creates a separate output section for every input section matching
526 SECTION, or if the optional wildcard SECTION argument is missing,
527 for every orphan input section. An orphan section is one not
528 specifically mentioned in a linker script. You may use this option
529 multiple times on the command line; It prevents the normal
530 merging of input sections with the same name, overriding output
531 section assignments in a linker script.
536 Display the version number for `ld'. The `-V' option also lists
537 the supported emulations.
541 Delete all local symbols.
545 Delete all temporary local symbols. For most targets, this is all
546 local symbols whose names begin with `L'.
549 `--trace-symbol=SYMBOL'
550 Print the name of each linked file in which SYMBOL appears. This
551 option may be given any number of times. On many systems it is
552 necessary to prepend an underscore.
554 This option is useful when you have an undefined symbol in your
555 link but don't know where the reference is coming from.
558 Add PATH to the default library search path. This option exists
559 for Solaris compatibility.
562 The recognized keywords are:
564 Combines multiple reloc sections and sorts them to make
565 dynamic symbol lookup caching possible.
568 Disallows undefined symbols in object files. Undefined
569 symbols in shared libraries are still allowed.
572 This option is only meaningful when building a shared object.
573 It marks the object so that its runtime initialization will
574 occur before the runtime initialization of any other objects
575 brought into the process at the same time. Similarly the
576 runtime finalization of the object will occur after the
577 runtime finalization of any other objects.
580 Marks the object that its symbol table interposes before all
581 symbols but the primary executable.
584 Marks the object that its filters be processed immediately at
588 Allows multiple definitions.
591 Disables multiple reloc sections combining.
594 Disables production of copy relocs.
597 Marks the object that the search for dependencies of this
598 object will ignore any default library search paths.
601 Marks the object shouldn't be unloaded at runtime.
604 Marks the object not available to `dlopen'.
607 Marks the object can not be dumped by `dldump'.
610 When generating an executable or shared library, mark it to
611 tell the dynamic linker to resolve all symbols when the
612 program is started, or when the shared library is linked to
613 using dlopen, instead of deferring function call resolution
614 to the point when the function is first called.
617 Marks the object may contain $ORIGIN.
620 Other keywords are ignored for Solaris compatibility.
623 `--start-group ARCHIVES --end-group'
624 The ARCHIVES should be a list of archive files. They may be
625 either explicit file names, or `-l' options.
627 The specified archives are searched repeatedly until no new
628 undefined references are created. Normally, an archive is
629 searched only once in the order that it is specified on the
630 command line. If a symbol in that archive is needed to resolve an
631 undefined symbol referred to by an object in an archive that
632 appears later on the command line, the linker would not be able to
633 resolve that reference. By grouping the archives, they all be
634 searched repeatedly until all possible references are resolved.
636 Using this option has a significant performance cost. It is best
637 to use it only when there are unavoidable circular references
638 between two or more archives.
640 `--accept-unknown-input-arch'
641 `--no-accept-unknown-input-arch'
642 Tells the linker to accept input files whose architecture cannot be
643 recognised. The assumption is that the user knows what they are
644 doing and deliberately wants to link in these unknown input files.
645 This was the default behaviour of the linker, before release
646 2.14. The default behaviour from release 2.14 onwards is to
647 reject such input files, and so the `--accept-unknown-input-arch'
648 option has been added to restore the old behaviour.
652 This option affects ELF DT_NEEDED tags for dynamic libraries
653 mentioned on the command line after the `--as-needed' option.
654 Normally, the linker will add a DT_NEEDED tag for each dynamic
655 library mentioned on the command line, regardless of whether the
656 library is actually needed. `--as-needed' causes DT_NEEDED tags to
657 only be emitted for libraries that satisfy some reference from
658 regular objects. `--no-as-needed' restores the default behaviour.
661 This option is ignored for SunOS compatibility.
666 Link against dynamic libraries. This is only meaningful on
667 platforms for which shared libraries are supported. This option
668 is normally the default on such platforms. The different variants
669 of this option are for compatibility with various systems. You
670 may use this option multiple times on the command line: it affects
671 library searching for `-l' options which follow it.
674 Set the `DF_1_GROUP' flag in the `DT_FLAGS_1' entry in the dynamic
675 section. This causes the runtime linker to handle lookups in this
676 object and its dependencies to be performed only inside the group.
677 `--unresolved-symbols=report-all' is implied. This option is only
678 meaningful on ELF platforms which support shared libraries.
684 Do not link against shared libraries. This is only meaningful on
685 platforms for which shared libraries are supported. The different
686 variants of this option are for compatibility with various
687 systems. You may use this option multiple times on the command
688 line: it affects library searching for `-l' options which follow
689 it. This option also implies `--unresolved-symbols=report-all'.
692 When creating a shared library, bind references to global symbols
693 to the definition within the shared library, if any. Normally, it
694 is possible for a program linked against a shared library to
695 override the definition within the shared library. This option is
696 only meaningful on ELF platforms which support shared libraries.
699 `--no-check-sections'
700 Asks the linker _not_ to check section addresses after they have
701 been assigned to see if there any overlaps. Normally the linker
702 will perform this check, and if it finds any overlaps it will
703 produce suitable error messages. The linker does know about, and
704 does make allowances for sections in overlays. The default
705 behaviour can be restored by using the command line switch
709 Output a cross reference table. If a linker map file is being
710 generated, the cross reference table is printed to the map file.
711 Otherwise, it is printed on the standard output.
713 The format of the table is intentionally simple, so that it may be
714 easily processed by a script if necessary. The symbols are
715 printed out, sorted by name. For each symbol, a list of file
716 names is given. If the symbol is defined, the first file listed
717 is the location of the definition. The remaining files contain
718 references to the symbol.
721 This option inhibits the assignment of addresses to common symbols.
722 The script command `INHIBIT_COMMON_ALLOCATION' has the same effect.
723 *Note Miscellaneous Commands::.
725 The `--no-define-common' option allows decoupling the decision to
726 assign addresses to Common symbols from the choice of the output
727 file type; otherwise a non-Relocatable output type forces
728 assigning addresses to Common symbols. Using `--no-define-common'
729 allows Common symbols that are referenced from a shared library to
730 be assigned addresses only in the main program. This eliminates
731 the unused duplicate space in the shared library, and also
732 prevents any possible confusion over resolving to the wrong
733 duplicate when there are many dynamic modules with specialized
734 search paths for runtime symbol resolution.
736 `--defsym SYMBOL=EXPRESSION'
737 Create a global symbol in the output file, containing the absolute
738 address given by EXPRESSION. You may use this option as many
739 times as necessary to define multiple symbols in the command line.
740 A limited form of arithmetic is supported for the EXPRESSION in
741 this context: you may give a hexadecimal constant or the name of
742 an existing symbol, or use `+' and `-' to add or subtract
743 hexadecimal constants or symbols. If you need more elaborate
744 expressions, consider using the linker command language from a
745 script (*note Assignment: Symbol Definitions: Assignments.).
746 _Note:_ there should be no white space between SYMBOL, the equals
747 sign ("<=>"), and EXPRESSION.
751 These options control whether to demangle symbol names in error
752 messages and other output. When the linker is told to demangle,
753 it tries to present symbol names in a readable fashion: it strips
754 leading underscores if they are used by the object file format,
755 and converts C++ mangled symbol names into user readable names.
756 Different compilers have different mangling styles. The optional
757 demangling style argument can be used to choose an appropriate
758 demangling style for your compiler. The linker will demangle by
759 default unless the environment variable `COLLECT_NO_DEMANGLE' is
760 set. These options may be used to override the default.
762 `--dynamic-linker FILE'
763 Set the name of the dynamic linker. This is only meaningful when
764 generating dynamically linked ELF executables. The default dynamic
765 linker is normally correct; don't use this unless you know what
769 This option is only meaningful when linking MIPS embedded PIC code,
770 generated by the -membedded-pic option to the GNU compiler and
771 assembler. It causes the linker to create a table which may be
772 used at runtime to relocate any data which was statically
773 initialized to pointer values. See the code in testsuite/ld-empic
777 Treat all warnings as errors.
780 Make sure that an output file has a .exe suffix.
782 If a successfully built fully linked output file does not have a
783 `.exe' or `.dll' suffix, this option forces the linker to copy the
784 output file to one of the same name with a `.exe' suffix. This
785 option is useful when using unmodified Unix makefiles on a
786 Microsoft Windows host, since some versions of Windows won't run
787 an image unless it ends in a `.exe' suffix.
791 Enable garbage collection of unused input sections. It is ignored
792 on targets that do not support this option. This option is not
793 compatible with `-r', nor should it be used with dynamic linking.
794 The default behaviour (of not performing this garbage collection)
795 can be restored by specifying `--no-gc-sections' on the command
799 Print a summary of the command-line options on the standard output
803 Print a summary of all target specific options on the standard
807 Print a link map to the file MAPFILE. See the description of the
811 `ld' normally optimizes for speed over memory usage by caching the
812 symbol tables of input files in memory. This option tells `ld' to
813 instead optimize for memory usage, by rereading the symbol tables
814 as necessary. This may be required if `ld' runs out of memory
815 space while linking a large executable.
819 Report unresolved symbol references from regular object files.
820 This is done even if the linker is creating a non-symbolic shared
821 library. The switch `--[no-]allow-shlib-undefined' controls the
822 behaviour for reporting unresolved references found in shared
823 libraries being linked in.
825 `--allow-multiple-definition'
827 Normally when a symbol is defined multiple times, the linker will
828 report a fatal error. These options allow multiple definitions and
829 the first definition will be used.
831 `--allow-shlib-undefined'
832 `--no-allow-shlib-undefined'
833 Allows (the default) or disallows undefined symbols in shared
834 libraries. This switch is similar to `--no-undefined' except that
835 it determines the behaviour when the undefined symbols are in a
836 shared library rather than a regular object file. It does not
837 affect how undefined symbols in regular object files are handled.
839 The reason that `--allow-shlib-undefined' is the default is that
840 the shared library being specified at link time may not be the
841 same as the one that is available at load time, so the symbols
842 might actually be resolvable at load time. Plus there are some
843 systems, (eg BeOS) where undefined symbols in shared libraries is
844 normal. (The kernel patches them at load time to select which
845 function is most appropriate for the current architecture. This
846 is used for example to dynamically select an appropriate memset
847 function). Apparently it is also normal for HPPA shared libraries
848 to have undefined symbols.
850 `--no-undefined-version'
851 Normally when a symbol has an undefined version, the linker will
852 ignore it. This option disallows symbols with undefined version
853 and a fatal error will be issued instead.
856 Normally `ld' will give an error if you try to link together input
857 files that are mismatched for some reason, perhaps because they
858 have been compiled for different processors or for different
859 endiannesses. This option tells `ld' that it should silently
860 permit such possible errors. This option should only be used with
861 care, in cases when you have taken some special action that
862 ensures that the linker errors are inappropriate.
865 Turn off the effect of the `--whole-archive' option for subsequent
869 Retain the executable output file whenever it is still usable.
870 Normally, the linker will not produce an output file if it
871 encounters errors during the link process; it exits without
872 writing an output file when it issues any error whatsoever.
875 Only search library directories explicitly specified on the
876 command line. Library directories specified in linker scripts
877 (including linker scripts specified on the command line) are
880 `--oformat OUTPUT-FORMAT'
881 `ld' may be configured to support more than one kind of object
882 file. If your `ld' is configured this way, you can use the
883 `--oformat' option to specify the binary format for the output
884 object file. Even when `ld' is configured to support alternative
885 object formats, you don't usually need to specify this, as `ld'
886 should be configured to produce as a default output format the most
887 usual format on each machine. OUTPUT-FORMAT is a text string, the
888 name of a particular format supported by the BFD libraries. (You
889 can list the available binary formats with `objdump -i'.) The
890 script command `OUTPUT_FORMAT' can also specify the output format,
891 but this option overrides it. *Note BFD::.
895 Create a position independent executable. This is currently only
896 supported on ELF platforms. Position independent executables are
897 similar to shared libraries in that they are relocated by the
898 dynamic linker to the virtual address the OS chooses for them
899 (which can vary between invocations). Like normal dynamically
900 linked executables they can be executed and symbols defined in the
901 executable cannot be overridden by shared libraries.
904 This option is ignored for Linux compatibility.
907 This option is ignored for SVR4 compatibility.
910 An option with machine dependent effects. This option is only
911 supported on a few targets. *Note `ld' and the H8/300: H8/300.
912 *Note `ld' and the Intel 960 family: i960. *Note `ld' and Xtensa
915 On some platforms, the `--relax' option performs global
916 optimizations that become possible when the linker resolves
917 addressing in the program, such as relaxing address modes and
918 synthesizing new instructions in the output object file.
920 On some platforms these link time global optimizations may make
921 symbolic debugging of the resulting executable impossible. This
922 is known to be the case for the Matsushita MN10200 and MN10300
923 family of processors.
925 On platforms where this is not supported, `--relax' is accepted,
928 `--retain-symbols-file FILENAME'
929 Retain _only_ the symbols listed in the file FILENAME, discarding
930 all others. FILENAME is simply a flat file, with one symbol name
931 per line. This option is especially useful in environments (such
932 as VxWorks) where a large global symbol table is accumulated
933 gradually, to conserve run-time memory.
935 `--retain-symbols-file' does _not_ discard undefined symbols, or
936 symbols needed for relocations.
938 You may only specify `--retain-symbols-file' once in the command
939 line. It overrides `-s' and `-S'.
942 Add a directory to the runtime library search path. This is used
943 when linking an ELF executable with shared objects. All `-rpath'
944 arguments are concatenated and passed to the runtime linker, which
945 uses them to locate shared objects at runtime. The `-rpath'
946 option is also used when locating shared objects which are needed
947 by shared objects explicitly included in the link; see the
948 description of the `-rpath-link' option. If `-rpath' is not used
949 when linking an ELF executable, the contents of the environment
950 variable `LD_RUN_PATH' will be used if it is defined.
952 The `-rpath' option may also be used on SunOS. By default, on
953 SunOS, the linker will form a runtime search patch out of all the
954 `-L' options it is given. If a `-rpath' option is used, the
955 runtime search path will be formed exclusively using the `-rpath'
956 options, ignoring the `-L' options. This can be useful when using
957 gcc, which adds many `-L' options which may be on NFS mounted
960 For compatibility with other ELF linkers, if the `-R' option is
961 followed by a directory name, rather than a file name, it is
962 treated as the `-rpath' option.
965 When using ELF or SunOS, one shared library may require another.
966 This happens when an `ld -shared' link includes a shared library
967 as one of the input files.
969 When the linker encounters such a dependency when doing a
970 non-shared, non-relocatable link, it will automatically try to
971 locate the required shared library and include it in the link, if
972 it is not included explicitly. In such a case, the `-rpath-link'
973 option specifies the first set of directories to search. The
974 `-rpath-link' option may specify a sequence of directory names
975 either by specifying a list of names separated by colons, or by
976 appearing multiple times.
978 This option should be used with caution as it overrides the search
979 path that may have been hard compiled into a shared library. In
980 such a case it is possible to use unintentionally a different
981 search path than the runtime linker would do.
983 The linker uses the following search paths to locate required
985 1. Any directories specified by `-rpath-link' options.
987 2. Any directories specified by `-rpath' options. The difference
988 between `-rpath' and `-rpath-link' is that directories
989 specified by `-rpath' options are included in the executable
990 and used at runtime, whereas the `-rpath-link' option is only
991 effective at link time. It is for the native linker only.
993 3. On an ELF system, if the `-rpath' and `rpath-link' options
994 were not used, search the contents of the environment variable
995 `LD_RUN_PATH'. It is for the native linker only.
997 4. On SunOS, if the `-rpath' option was not used, search any
998 directories specified using `-L' options.
1000 5. For a native linker, the contents of the environment variable
1003 6. For a native ELF linker, the directories in `DT_RUNPATH' or
1004 `DT_RPATH' of a shared library are searched for shared
1005 libraries needed by it. The `DT_RPATH' entries are ignored if
1006 `DT_RUNPATH' entries exist.
1008 7. The default directories, normally `/lib' and `/usr/lib'.
1010 8. For a native linker on an ELF system, if the file
1011 `/etc/ld.so.conf' exists, the list of directories found in
1014 If the required shared library is not found, the linker will issue
1015 a warning and continue with the link.
1019 Create a shared library. This is currently only supported on ELF,
1020 XCOFF and SunOS platforms. On SunOS, the linker will
1021 automatically create a shared library if the `-e' option is not
1022 used and there are undefined symbols in the link.
1025 This option tells `ld' to sort the common symbols by size when it
1026 places them in the appropriate output sections. First come all
1027 the one byte symbols, then all the two byte, then all the four
1028 byte, and then everything else. This is to prevent gaps between
1029 symbols due to alignment constraints.
1031 `--split-by-file [SIZE]'
1032 Similar to `--split-by-reloc' but creates a new output section for
1033 each input file when SIZE is reached. SIZE defaults to a size of
1036 `--split-by-reloc [COUNT]'
1037 Tries to creates extra sections in the output file so that no
1038 single output section in the file contains more than COUNT
1039 relocations. This is useful when generating huge relocatable
1040 files for downloading into certain real time kernels with the COFF
1041 object file format; since COFF cannot represent more than 65535
1042 relocations in a single section. Note that this will fail to work
1043 with object file formats which do not support arbitrary sections.
1044 The linker will not split up individual input sections for
1045 redistribution, so if a single input section contains more than
1046 COUNT relocations one output section will contain that many
1047 relocations. COUNT defaults to a value of 32768.
1050 Compute and display statistics about the operation of the linker,
1051 such as execution time and memory usage.
1053 `--traditional-format'
1054 For some targets, the output of `ld' is different in some ways from
1055 the output of some existing linker. This switch requests `ld' to
1056 use the traditional format instead.
1058 For example, on SunOS, `ld' combines duplicate entries in the
1059 symbol string table. This can reduce the size of an output file
1060 with full debugging information by over 30 percent.
1061 Unfortunately, the SunOS `dbx' program can not read the resulting
1062 program (`gdb' has no trouble). The `--traditional-format' switch
1063 tells `ld' to not combine duplicate entries.
1065 `--section-start SECTIONNAME=ORG'
1066 Locate a section in the output file at the absolute address given
1067 by ORG. You may use this option as many times as necessary to
1068 locate multiple sections in the command line. ORG must be a
1069 single hexadecimal integer; for compatibility with other linkers,
1070 you may omit the leading `0x' usually associated with hexadecimal
1071 values. _Note:_ there should be no white space between
1072 SECTIONNAME, the equals sign ("<=>"), and ORG.
1077 Same as -section-start, with `.bss', `.data' or `.text' as the
1080 `--unresolved-symbols=METHOD'
1081 Determine how to handle unresolved symbols. There are four
1082 possible values for `method':
1085 Do not report any unresolved symbols.
1088 Report all unresolved symbols. This is the default.
1090 `ignore-in-object-files'
1091 Report unresolved symbols that are contained in shared
1092 libraries, but ignore them if they come from regular object
1095 `ignore-in-shared-libs'
1096 Report unresolved symbols that come from regular object
1097 files, but ignore them if they come from shared libraries.
1098 This can be useful when creating a dynamic binary and it is
1099 known that all the shared libraries that it should be
1100 referencing are included on the linker's command line.
1102 The behaviour for shared libraries on their own can also be
1103 controlled by the `--[no-]allow-shlib-undefined' option.
1105 Normally the linker will generate an error message for each
1106 reported unresolved symbol but the option
1107 `--warn-unresolved-symbols' can change this to a warning.
1111 Display the version number for `ld' and list the linker emulations
1112 supported. Display which input files can and cannot be opened.
1113 Display the linker script being used by the linker.
1115 `--version-script=VERSION-SCRIPTFILE'
1116 Specify the name of a version script to the linker. This is
1117 typically used when creating shared libraries to specify
1118 additional information about the version hierarchy for the library
1119 being created. This option is only meaningful on ELF platforms
1120 which support shared libraries. *Note VERSION::.
1123 Warn when a common symbol is combined with another common symbol
1124 or with a symbol definition. Unix linkers allow this somewhat
1125 sloppy practise, but linkers on some other operating systems do
1126 not. This option allows you to find potential problems from
1127 combining global symbols. Unfortunately, some C libraries use
1128 this practise, so you may get some warnings about symbols in the
1129 libraries as well as in your programs.
1131 There are three kinds of global symbols, illustrated here by C
1135 A definition, which goes in the initialized data section of
1139 An undefined reference, which does not allocate space. There
1140 must be either a definition or a common symbol for the
1144 A common symbol. If there are only (one or more) common
1145 symbols for a variable, it goes in the uninitialized data
1146 area of the output file. The linker merges multiple common
1147 symbols for the same variable into a single symbol. If they
1148 are of different sizes, it picks the largest size. The
1149 linker turns a common symbol into a declaration, if there is
1150 a definition of the same variable.
1152 The `--warn-common' option can produce five kinds of warnings.
1153 Each warning consists of a pair of lines: the first describes the
1154 symbol just encountered, and the second describes the previous
1155 symbol encountered with the same name. One or both of the two
1156 symbols will be a common symbol.
1158 1. Turning a common symbol into a reference, because there is
1159 already a definition for the symbol.
1160 FILE(SECTION): warning: common of `SYMBOL'
1161 overridden by definition
1162 FILE(SECTION): warning: defined here
1164 2. Turning a common symbol into a reference, because a later
1165 definition for the symbol is encountered. This is the same
1166 as the previous case, except that the symbols are encountered
1167 in a different order.
1168 FILE(SECTION): warning: definition of `SYMBOL'
1170 FILE(SECTION): warning: common is here
1172 3. Merging a common symbol with a previous same-sized common
1174 FILE(SECTION): warning: multiple common
1176 FILE(SECTION): warning: previous common is here
1178 4. Merging a common symbol with a previous larger common symbol.
1179 FILE(SECTION): warning: common of `SYMBOL'
1180 overridden by larger common
1181 FILE(SECTION): warning: larger common is here
1183 5. Merging a common symbol with a previous smaller common
1184 symbol. This is the same as the previous case, except that
1185 the symbols are encountered in a different order.
1186 FILE(SECTION): warning: common of `SYMBOL'
1187 overriding smaller common
1188 FILE(SECTION): warning: smaller common is here
1190 `--warn-constructors'
1191 Warn if any global constructors are used. This is only useful for
1192 a few object file formats. For formats like COFF or ELF, the
1193 linker can not detect the use of global constructors.
1195 `--warn-multiple-gp'
1196 Warn if multiple global pointer values are required in the output
1197 file. This is only meaningful for certain processors, such as the
1198 Alpha. Specifically, some processors put large-valued constants
1199 in a special section. A special register (the global pointer)
1200 points into the middle of this section, so that constants can be
1201 loaded efficiently via a base-register relative addressing mode.
1202 Since the offset in base-register relative mode is fixed and
1203 relatively small (e.g., 16 bits), this limits the maximum size of
1204 the constant pool. Thus, in large programs, it is often necessary
1205 to use multiple global pointer values in order to be able to
1206 address all possible constants. This option causes a warning to
1207 be issued whenever this case occurs.
1210 Only warn once for each undefined symbol, rather than once per
1211 module which refers to it.
1213 `--warn-section-align'
1214 Warn if the address of an output section is changed because of
1215 alignment. Typically, the alignment will be set by an input
1216 section. The address will only be changed if it not explicitly
1217 specified; that is, if the `SECTIONS' command does not specify a
1218 start address for the section (*note SECTIONS::).
1220 `--warn-unresolved-symbols'
1221 If the linker is going to report an unresolved symbol (see the
1222 option `--unresolved-symbols') it will normally generate an error.
1223 This option makes it generate a warning instead.
1225 `--error-unresolved-symbols'
1226 This restores the linker's default behaviour of generating errors
1227 when it is reporting unresolved symbols.
1230 For each archive mentioned on the command line after the
1231 `--whole-archive' option, include every object file in the archive
1232 in the link, rather than searching the archive for the required
1233 object files. This is normally used to turn an archive file into
1234 a shared library, forcing every object to be included in the
1235 resulting shared library. This option may be used more than once.
1237 Two notes when using this option from gcc: First, gcc doesn't know
1238 about this option, so you have to use `-Wl,-whole-archive'.
1239 Second, don't forget to use `-Wl,-no-whole-archive' after your
1240 list of archives, because gcc will add its own list of archives to
1241 your link and you may not want this flag to affect those as well.
1244 Use a wrapper function for SYMBOL. Any undefined reference to
1245 SYMBOL will be resolved to `__wrap_SYMBOL'. Any undefined
1246 reference to `__real_SYMBOL' will be resolved to SYMBOL.
1248 This can be used to provide a wrapper for a system function. The
1249 wrapper function should be called `__wrap_SYMBOL'. If it wishes
1250 to call the system function, it should call `__real_SYMBOL'.
1252 Here is a trivial example:
1255 __wrap_malloc (size_t c)
1257 printf ("malloc called with %zu\n", c);
1258 return __real_malloc (c);
1261 If you link other code with this file using `--wrap malloc', then
1262 all calls to `malloc' will call the function `__wrap_malloc'
1263 instead. The call to `__real_malloc' in `__wrap_malloc' will call
1264 the real `malloc' function.
1266 You may wish to provide a `__real_malloc' function as well, so that
1267 links without the `--wrap' option will succeed. If you do this,
1268 you should not put the definition of `__real_malloc' in the same
1269 file as `__wrap_malloc'; if you do, the assembler may resolve the
1270 call before the linker has a chance to wrap it to `malloc'.
1272 `--enable-new-dtags'
1273 `--disable-new-dtags'
1274 This linker can create the new dynamic tags in ELF. But the older
1275 ELF systems may not understand them. If you specify
1276 `--enable-new-dtags', the dynamic tags will be created as needed.
1277 If you specify `--disable-new-dtags', no new dynamic tags will be
1278 created. By default, the new dynamic tags are not created. Note
1279 that those options are only available for ELF systems.
1282 Options Specific to i386 PE Targets
1283 -----------------------------------
1285 The i386 PE linker supports the `-shared' option, which causes the
1286 output to be a dynamically linked library (DLL) instead of a normal
1287 executable. You should name the output `*.dll' when you use this
1288 option. In addition, the linker fully supports the standard `*.def'
1289 files, which may be specified on the linker command line like an object
1290 file (in fact, it should precede archives it exports symbols from, to
1291 ensure that they get linked in, just like a normal object file).
1293 In addition to the options common to all targets, the i386 PE linker
1294 support additional command line options that are specific to the i386
1295 PE target. Options that take values may be separated from their values
1296 by either a space or an equals sign.
1298 `--add-stdcall-alias'
1299 If given, symbols with a stdcall suffix (@NN) will be exported
1300 as-is and also with the suffix stripped. [This option is specific
1301 to the i386 PE targeted port of the linker]
1304 Use FILE as the name of a file in which to save the base addresses
1305 of all the relocations needed for generating DLLs with `dlltool'.
1306 [This is an i386 PE specific option]
1309 Create a DLL instead of a regular executable. You may also use
1310 `-shared' or specify a `LIBRARY' in a given `.def' file. [This
1311 option is specific to the i386 PE targeted port of the linker]
1313 `--enable-stdcall-fixup'
1314 `--disable-stdcall-fixup'
1315 If the link finds a symbol that it cannot resolve, it will attempt
1316 to do "fuzzy linking" by looking for another defined symbol that
1317 differs only in the format of the symbol name (cdecl vs stdcall)
1318 and will resolve that symbol by linking to the match. For
1319 example, the undefined symbol `_foo' might be linked to the
1320 function `_foo@12', or the undefined symbol `_bar@16' might be
1321 linked to the function `_bar'. When the linker does this, it
1322 prints a warning, since it normally should have failed to link,
1323 but sometimes import libraries generated from third-party dlls may
1324 need this feature to be usable. If you specify
1325 `--enable-stdcall-fixup', this feature is fully enabled and
1326 warnings are not printed. If you specify
1327 `--disable-stdcall-fixup', this feature is disabled and such
1328 mismatches are considered to be errors. [This option is specific
1329 to the i386 PE targeted port of the linker]
1331 `--export-all-symbols'
1332 If given, all global symbols in the objects used to build a DLL
1333 will be exported by the DLL. Note that this is the default if
1334 there otherwise wouldn't be any exported symbols. When symbols are
1335 explicitly exported via DEF files or implicitly exported via
1336 function attributes, the default is to not export anything else
1337 unless this option is given. Note that the symbols `DllMain@12',
1338 `DllEntryPoint@0', `DllMainCRTStartup@12', and `impure_ptr' will
1339 not be automatically exported. Also, symbols imported from other
1340 DLLs will not be re-exported, nor will symbols specifying the
1341 DLL's internal layout such as those beginning with `_head_' or
1342 ending with `_iname'. In addition, no symbols from `libgcc',
1343 `libstd++', `libmingw32', or `crtX.o' will be exported. Symbols
1344 whose names begin with `__rtti_' or `__builtin_' will not be
1345 exported, to help with C++ DLLs. Finally, there is an extensive
1346 list of cygwin-private symbols that are not exported (obviously,
1347 this applies on when building DLLs for cygwin targets). These
1348 cygwin-excludes are: `_cygwin_dll_entry@12',
1349 `_cygwin_crt0_common@8', `_cygwin_noncygwin_dll_entry@12',
1350 `_fmode', `_impure_ptr', `cygwin_attach_dll', `cygwin_premain0',
1351 `cygwin_premain1', `cygwin_premain2', `cygwin_premain3', and
1352 `environ'. [This option is specific to the i386 PE targeted port
1355 `--exclude-symbols SYMBOL,SYMBOL,...'
1356 Specifies a list of symbols which should not be automatically
1357 exported. The symbol names may be delimited by commas or colons.
1358 [This option is specific to the i386 PE targeted port of the
1361 `--exclude-libs LIB,LIB,...'
1362 Specifies a list of archive libraries from which symbols should
1363 not be automatically exported. The library names may be delimited
1364 by commas or colons. Specifying `--exclude-libs ALL' excludes
1365 symbols in all archive libraries from automatic export. Symbols
1366 explicitly listed in a .def file are still exported, regardless of
1367 this option. [This option is specific to the i386 PE targeted
1371 Specify the file alignment. Sections in the file will always
1372 begin at file offsets which are multiples of this number. This
1373 defaults to 512. [This option is specific to the i386 PE targeted
1377 `--heap RESERVE,COMMIT'
1378 Specify the amount of memory to reserve (and optionally commit) to
1379 be used as heap for this program. The default is 1Mb reserved, 4K
1380 committed. [This option is specific to the i386 PE targeted port
1383 `--image-base VALUE'
1384 Use VALUE as the base address of your program or dll. This is the
1385 lowest memory location that will be used when your program or dll
1386 is loaded. To reduce the need to relocate and improve performance
1387 of your dlls, each should have a unique base address and not
1388 overlap any other dlls. The default is 0x400000 for executables,
1389 and 0x10000000 for dlls. [This option is specific to the i386 PE
1390 targeted port of the linker]
1393 If given, the stdcall suffixes (@NN) will be stripped from symbols
1394 before they are exported. [This option is specific to the i386 PE
1395 targeted port of the linker]
1397 `--major-image-version VALUE'
1398 Sets the major number of the "image version". Defaults to 1.
1399 [This option is specific to the i386 PE targeted port of the
1402 `--major-os-version VALUE'
1403 Sets the major number of the "os version". Defaults to 4. [This
1404 option is specific to the i386 PE targeted port of the linker]
1406 `--major-subsystem-version VALUE'
1407 Sets the major number of the "subsystem version". Defaults to 4.
1408 [This option is specific to the i386 PE targeted port of the
1411 `--minor-image-version VALUE'
1412 Sets the minor number of the "image version". Defaults to 0.
1413 [This option is specific to the i386 PE targeted port of the
1416 `--minor-os-version VALUE'
1417 Sets the minor number of the "os version". Defaults to 0. [This
1418 option is specific to the i386 PE targeted port of the linker]
1420 `--minor-subsystem-version VALUE'
1421 Sets the minor number of the "subsystem version". Defaults to 0.
1422 [This option is specific to the i386 PE targeted port of the
1426 The linker will create the file FILE which will contain a DEF file
1427 corresponding to the DLL the linker is generating. This DEF file
1428 (which should be called `*.def') may be used to create an import
1429 library with `dlltool' or may be used as a reference to
1430 automatically or implicitly exported symbols. [This option is
1431 specific to the i386 PE targeted port of the linker]
1434 The linker will create the file FILE which will contain an import
1435 lib corresponding to the DLL the linker is generating. This import
1436 lib (which should be called `*.dll.a' or `*.a' may be used to link
1437 clients against the generated DLL; this behaviour makes it
1438 possible to skip a separate `dlltool' import library creation step.
1439 [This option is specific to the i386 PE targeted port of the
1442 `--enable-auto-image-base'
1443 Automatically choose the image base for DLLs, unless one is
1444 specified using the `--image-base' argument. By using a hash
1445 generated from the dllname to create unique image bases for each
1446 DLL, in-memory collisions and relocations which can delay program
1447 execution are avoided. [This option is specific to the i386 PE
1448 targeted port of the linker]
1450 `--disable-auto-image-base'
1451 Do not automatically generate a unique image base. If there is no
1452 user-specified image base (`--image-base') then use the platform
1453 default. [This option is specific to the i386 PE targeted port of
1456 `--dll-search-prefix STRING'
1457 When linking dynamically to a dll without an import library,
1458 search for `<string><basename>.dll' in preference to
1459 `lib<basename>.dll'. This behaviour allows easy distinction
1460 between DLLs built for the various "subplatforms": native, cygwin,
1461 uwin, pw, etc. For instance, cygwin DLLs typically use
1462 `--dll-search-prefix=cyg'. [This option is specific to the i386
1463 PE targeted port of the linker]
1465 `--enable-auto-import'
1466 Do sophisticated linking of `_symbol' to `__imp__symbol' for DATA
1467 imports from DLLs, and create the necessary thunking symbols when
1468 building the import libraries with those DATA exports. Note: Use
1469 of the 'auto-import' extension will cause the text section of the
1470 image file to be made writable. This does not conform to the
1471 PE-COFF format specification published by Microsoft.
1473 Using 'auto-import' generally will 'just work' - but sometimes you
1474 may see this message:
1476 "variable '<var>' can't be auto-imported. Please read the
1477 documentation for ld's `--enable-auto-import' for details."
1479 This message occurs when some (sub)expression accesses an address
1480 ultimately given by the sum of two constants (Win32 import tables
1481 only allow one). Instances where this may occur include accesses
1482 to member fields of struct variables imported from a DLL, as well
1483 as using a constant index into an array variable imported from a
1484 DLL. Any multiword variable (arrays, structs, long long, etc) may
1485 trigger this error condition. However, regardless of the exact
1486 data type of the offending exported variable, ld will always
1487 detect it, issue the warning, and exit.
1489 There are several ways to address this difficulty, regardless of
1490 the data type of the exported variable:
1492 One way is to use -enable-runtime-pseudo-reloc switch. This leaves
1493 the task of adjusting references in your client code for runtime
1494 environment, so this method works only when runtime environment
1495 supports this feature.
1497 A second solution is to force one of the 'constants' to be a
1498 variable - that is, unknown and un-optimizable at compile time.
1499 For arrays, there are two possibilities: a) make the indexee (the
1500 array's address) a variable, or b) make the 'constant' index a
1503 extern type extern_array[];
1505 { volatile type *t=extern_array; t[1] }
1509 extern type extern_array[];
1511 { volatile int t=1; extern_array[t] }
1513 For structs (and most other multiword data types) the only option
1514 is to make the struct itself (or the long long, or the ...)
1517 extern struct s extern_struct;
1518 extern_struct.field -->
1519 { volatile struct s *t=&extern_struct; t->field }
1523 extern long long extern_ll;
1525 { volatile long long * local_ll=&extern_ll; *local_ll }
1527 A third method of dealing with this difficulty is to abandon
1528 'auto-import' for the offending symbol and mark it with
1529 `__declspec(dllimport)'. However, in practise that requires using
1530 compile-time #defines to indicate whether you are building a DLL,
1531 building client code that will link to the DLL, or merely
1532 building/linking to a static library. In making the choice
1533 between the various methods of resolving the 'direct address with
1534 constant offset' problem, you should consider typical real-world
1542 void main(int argc, char **argv){
1543 printf("%d\n",arr[1]);
1551 void main(int argc, char **argv){
1552 /* This workaround is for win32 and cygwin; do not "optimize" */
1553 volatile int *parr = arr;
1554 printf("%d\n",parr[1]);
1559 /* Note: auto-export is assumed (no __declspec(dllexport)) */
1560 #if (defined(_WIN32) || defined(__CYGWIN__)) && \
1561 !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
1562 #define FOO_IMPORT __declspec(dllimport)
1566 extern FOO_IMPORT int arr[];
1569 void main(int argc, char **argv){
1570 printf("%d\n",arr[1]);
1573 A fourth way to avoid this problem is to re-code your library to
1574 use a functional interface rather than a data interface for the
1575 offending variables (e.g. set_foo() and get_foo() accessor
1576 functions). [This option is specific to the i386 PE targeted port
1579 `--disable-auto-import'
1580 Do not attempt to do sophisticated linking of `_symbol' to
1581 `__imp__symbol' for DATA imports from DLLs. [This option is
1582 specific to the i386 PE targeted port of the linker]
1584 `--enable-runtime-pseudo-reloc'
1585 If your code contains expressions described in -enable-auto-import
1586 section, that is, DATA imports from DLL with non-zero offset, this
1587 switch will create a vector of 'runtime pseudo relocations' which
1588 can be used by runtime environment to adjust references to such
1589 data in your client code. [This option is specific to the i386 PE
1590 targeted port of the linker]
1592 `--disable-runtime-pseudo-reloc'
1593 Do not create pseudo relocations for non-zero offset DATA imports
1594 from DLLs. This is the default. [This option is specific to the
1595 i386 PE targeted port of the linker]
1597 `--enable-extra-pe-debug'
1598 Show additional debug info related to auto-import symbol thunking.
1599 [This option is specific to the i386 PE targeted port of the
1602 `--section-alignment'
1603 Sets the section alignment. Sections in memory will always begin
1604 at addresses which are a multiple of this number. Defaults to
1605 0x1000. [This option is specific to the i386 PE targeted port of
1609 `--stack RESERVE,COMMIT'
1610 Specify the amount of memory to reserve (and optionally commit) to
1611 be used as stack for this program. The default is 2Mb reserved, 4K
1612 committed. [This option is specific to the i386 PE targeted port
1616 `--subsystem WHICH:MAJOR'
1617 `--subsystem WHICH:MAJOR.MINOR'
1618 Specifies the subsystem under which your program will execute. The
1619 legal values for WHICH are `native', `windows', `console', and
1620 `posix'. You may optionally set the subsystem version also.
1621 [This option is specific to the i386 PE targeted port of the
1626 File: ld.info, Node: Environment, Prev: Options, Up: Invocation
1628 Environment Variables
1629 =====================
1631 You can change the behaviour of `ld' with the environment variables
1632 `GNUTARGET', `LDEMULATION' and `COLLECT_NO_DEMANGLE'.
1634 `GNUTARGET' determines the input-file object format if you don't use
1635 `-b' (or its synonym `--format'). Its value should be one of the BFD
1636 names for an input format (*note BFD::). If there is no `GNUTARGET' in
1637 the environment, `ld' uses the natural format of the target. If
1638 `GNUTARGET' is set to `default' then BFD attempts to discover the input
1639 format by examining binary input files; this method often succeeds, but
1640 there are potential ambiguities, since there is no method of ensuring
1641 that the magic number used to specify object-file formats is unique.
1642 However, the configuration procedure for BFD on each system places the
1643 conventional format for that system first in the search-list, so
1644 ambiguities are resolved in favor of convention.
1646 `LDEMULATION' determines the default emulation if you don't use the
1647 `-m' option. The emulation can affect various aspects of linker
1648 behaviour, particularly the default linker script. You can list the
1649 available emulations with the `--verbose' or `-V' options. If the `-m'
1650 option is not used, and the `LDEMULATION' environment variable is not
1651 defined, the default emulation depends upon how the linker was
1654 Normally, the linker will default to demangling symbols. However, if
1655 `COLLECT_NO_DEMANGLE' is set in the environment, then it will default
1656 to not demangling symbols. This environment variable is used in a
1657 similar fashion by the `gcc' linker wrapper program. The default may
1658 be overridden by the `--demangle' and `--no-demangle' options.
1661 File: ld.info, Node: Scripts, Next: Machine Dependent, Prev: Invocation, Up: Top
1666 Every link is controlled by a "linker script". This script is written
1667 in the linker command language.
1669 The main purpose of the linker script is to describe how the
1670 sections in the input files should be mapped into the output file, and
1671 to control the memory layout of the output file. Most linker scripts
1672 do nothing more than this. However, when necessary, the linker script
1673 can also direct the linker to perform many other operations, using the
1674 commands described below.
1676 The linker always uses a linker script. If you do not supply one
1677 yourself, the linker will use a default script that is compiled into the
1678 linker executable. You can use the `--verbose' command line option to
1679 display the default linker script. Certain command line options, such
1680 as `-r' or `-N', will affect the default linker script.
1682 You may supply your own linker script by using the `-T' command line
1683 option. When you do this, your linker script will replace the default
1686 You may also use linker scripts implicitly by naming them as input
1687 files to the linker, as though they were files to be linked. *Note
1688 Implicit Linker Scripts::.
1692 * Basic Script Concepts:: Basic Linker Script Concepts
1693 * Script Format:: Linker Script Format
1694 * Simple Example:: Simple Linker Script Example
1695 * Simple Commands:: Simple Linker Script Commands
1696 * Assignments:: Assigning Values to Symbols
1697 * SECTIONS:: SECTIONS Command
1698 * MEMORY:: MEMORY Command
1699 * PHDRS:: PHDRS Command
1700 * VERSION:: VERSION Command
1701 * Expressions:: Expressions in Linker Scripts
1702 * Implicit Linker Scripts:: Implicit Linker Scripts
1705 File: ld.info, Node: Basic Script Concepts, Next: Script Format, Up: Scripts
1707 Basic Linker Script Concepts
1708 ============================
1710 We need to define some basic concepts and vocabulary in order to
1711 describe the linker script language.
1713 The linker combines input files into a single output file. The
1714 output file and each input file are in a special data format known as an
1715 "object file format". Each file is called an "object file". The
1716 output file is often called an "executable", but for our purposes we
1717 will also call it an object file. Each object file has, among other
1718 things, a list of "sections". We sometimes refer to a section in an
1719 input file as an "input section"; similarly, a section in the output
1720 file is an "output section".
1722 Each section in an object file has a name and a size. Most sections
1723 also have an associated block of data, known as the "section contents".
1724 A section may be marked as "loadable", which mean that the contents
1725 should be loaded into memory when the output file is run. A section
1726 with no contents may be "allocatable", which means that an area in
1727 memory should be set aside, but nothing in particular should be loaded
1728 there (in some cases this memory must be zeroed out). A section which
1729 is neither loadable nor allocatable typically contains some sort of
1730 debugging information.
1732 Every loadable or allocatable output section has two addresses. The
1733 first is the "VMA", or virtual memory address. This is the address the
1734 section will have when the output file is run. The second is the
1735 "LMA", or load memory address. This is the address at which the
1736 section will be loaded. In most cases the two addresses will be the
1737 same. An example of when they might be different is when a data section
1738 is loaded into ROM, and then copied into RAM when the program starts up
1739 (this technique is often used to initialize global variables in a ROM
1740 based system). In this case the ROM address would be the LMA, and the
1741 RAM address would be the VMA.
1743 You can see the sections in an object file by using the `objdump'
1744 program with the `-h' option.
1746 Every object file also has a list of "symbols", known as the "symbol
1747 table". A symbol may be defined or undefined. Each symbol has a name,
1748 and each defined symbol has an address, among other information. If
1749 you compile a C or C++ program into an object file, you will get a
1750 defined symbol for every defined function and global or static
1751 variable. Every undefined function or global variable which is
1752 referenced in the input file will become an undefined symbol.
1754 You can see the symbols in an object file by using the `nm' program,
1755 or by using the `objdump' program with the `-t' option.
1758 File: ld.info, Node: Script Format, Next: Simple Example, Prev: Basic Script Concepts, Up: Scripts
1760 Linker Script Format
1761 ====================
1763 Linker scripts are text files.
1765 You write a linker script as a series of commands. Each command is
1766 either a keyword, possibly followed by arguments, or an assignment to a
1767 symbol. You may separate commands using semicolons. Whitespace is
1770 Strings such as file or format names can normally be entered
1771 directly. If the file name contains a character such as a comma which
1772 would otherwise serve to separate file names, you may put the file name
1773 in double quotes. There is no way to use a double quote character in a
1776 You may include comments in linker scripts just as in C, delimited by
1777 `/*' and `*/'. As in C, comments are syntactically equivalent to
1781 File: ld.info, Node: Simple Example, Next: Simple Commands, Prev: Script Format, Up: Scripts
1783 Simple Linker Script Example
1784 ============================
1786 Many linker scripts are fairly simple.
1788 The simplest possible linker script has just one command:
1789 `SECTIONS'. You use the `SECTIONS' command to describe the memory
1790 layout of the output file.
1792 The `SECTIONS' command is a powerful command. Here we will describe
1793 a simple use of it. Let's assume your program consists only of code,
1794 initialized data, and uninitialized data. These will be in the
1795 `.text', `.data', and `.bss' sections, respectively. Let's assume
1796 further that these are the only sections which appear in your input
1799 For this example, let's say that the code should be loaded at address
1800 0x10000, and that the data should start at address 0x8000000. Here is a
1801 linker script which will do that:
1805 .text : { *(.text) }
1807 .data : { *(.data) }
1811 You write the `SECTIONS' command as the keyword `SECTIONS', followed
1812 by a series of symbol assignments and output section descriptions
1813 enclosed in curly braces.
1815 The first line inside the `SECTIONS' command of the above example
1816 sets the value of the special symbol `.', which is the location
1817 counter. If you do not specify the address of an output section in some
1818 other way (other ways are described later), the address is set from the
1819 current value of the location counter. The location counter is then
1820 incremented by the size of the output section. At the start of the
1821 `SECTIONS' command, the location counter has the value `0'.
1823 The second line defines an output section, `.text'. The colon is
1824 required syntax which may be ignored for now. Within the curly braces
1825 after the output section name, you list the names of the input sections
1826 which should be placed into this output section. The `*' is a wildcard
1827 which matches any file name. The expression `*(.text)' means all
1828 `.text' input sections in all input files.
1830 Since the location counter is `0x10000' when the output section
1831 `.text' is defined, the linker will set the address of the `.text'
1832 section in the output file to be `0x10000'.
1834 The remaining lines define the `.data' and `.bss' sections in the
1835 output file. The linker will place the `.data' output section at
1836 address `0x8000000'. After the linker places the `.data' output
1837 section, the value of the location counter will be `0x8000000' plus the
1838 size of the `.data' output section. The effect is that the linker will
1839 place the `.bss' output section immediately after the `.data' output
1842 The linker will ensure that each output section has the required
1843 alignment, by increasing the location counter if necessary. In this
1844 example, the specified addresses for the `.text' and `.data' sections
1845 will probably satisfy any alignment constraints, but the linker may
1846 have to create a small gap between the `.data' and `.bss' sections.
1848 That's it! That's a simple and complete linker script.
1851 File: ld.info, Node: Simple Commands, Next: Assignments, Prev: Simple Example, Up: Scripts
1853 Simple Linker Script Commands
1854 =============================
1856 In this section we describe the simple linker script commands.
1860 * Entry Point:: Setting the entry point
1861 * File Commands:: Commands dealing with files
1863 * Format Commands:: Commands dealing with object file formats
1865 * Miscellaneous Commands:: Other linker script commands
1868 File: ld.info, Node: Entry Point, Next: File Commands, Up: Simple Commands
1870 Setting the Entry Point
1871 -----------------------
1873 The first instruction to execute in a program is called the "entry
1874 point". You can use the `ENTRY' linker script command to set the entry
1875 point. The argument is a symbol name:
1878 There are several ways to set the entry point. The linker will set
1879 the entry point by trying each of the following methods in order, and
1880 stopping when one of them succeeds:
1881 * the `-e' ENTRY command-line option;
1883 * the `ENTRY(SYMBOL)' command in a linker script;
1885 * the value of the symbol `start', if defined;
1887 * the address of the first byte of the `.text' section, if present;
1892 File: ld.info, Node: File Commands, Next: Format Commands, Prev: Entry Point, Up: Simple Commands
1894 Commands Dealing with Files
1895 ---------------------------
1897 Several linker script commands deal with files.
1900 Include the linker script FILENAME at this point. The file will
1901 be searched for in the current directory, and in any directory
1902 specified with the `-L' option. You can nest calls to `INCLUDE'
1903 up to 10 levels deep.
1905 `INPUT(FILE, FILE, ...)'
1906 `INPUT(FILE FILE ...)'
1907 The `INPUT' command directs the linker to include the named files
1908 in the link, as though they were named on the command line.
1910 For example, if you always want to include `subr.o' any time you do
1911 a link, but you can't be bothered to put it on every link command
1912 line, then you can put `INPUT (subr.o)' in your linker script.
1914 In fact, if you like, you can list all of your input files in the
1915 linker script, and then invoke the linker with nothing but a `-T'
1918 In case a "sysroot prefix" is configured, and the filename starts
1919 with the `/' character, and the script being processed was located
1920 inside the "sysroot prefix", the filename will be looked for in
1921 the "sysroot prefix". Otherwise, the linker will try to open the
1922 file in the current directory. If it is not found, the linker
1923 will search through the archive library search path. See the
1924 description of `-L' in *Note Command Line Options: Options.
1926 If you use `INPUT (-lFILE)', `ld' will transform the name to
1927 `libFILE.a', as with the command line argument `-l'.
1929 When you use the `INPUT' command in an implicit linker script, the
1930 files will be included in the link at the point at which the linker
1931 script file is included. This can affect archive searching.
1933 `GROUP(FILE, FILE, ...)'
1934 `GROUP(FILE FILE ...)'
1935 The `GROUP' command is like `INPUT', except that the named files
1936 should all be archives, and they are searched repeatedly until no
1937 new undefined references are created. See the description of `-('
1938 in *Note Command Line Options: Options.
1941 The `OUTPUT' command names the output file. Using
1942 `OUTPUT(FILENAME)' in the linker script is exactly like using `-o
1943 FILENAME' on the command line (*note Command Line Options:
1944 Options.). If both are used, the command line option takes
1947 You can use the `OUTPUT' command to define a default name for the
1948 output file other than the usual default of `a.out'.
1951 The `SEARCH_DIR' command adds PATH to the list of paths where `ld'
1952 looks for archive libraries. Using `SEARCH_DIR(PATH)' is exactly
1953 like using `-L PATH' on the command line (*note Command Line
1954 Options: Options.). If both are used, then the linker will search
1955 both paths. Paths specified using the command line option are
1959 The `STARTUP' command is just like the `INPUT' command, except
1960 that FILENAME will become the first input file to be linked, as
1961 though it were specified first on the command line. This may be
1962 useful when using a system in which the entry point is always the
1963 start of the first file.
1966 File: ld.info, Node: Format Commands, Next: Miscellaneous Commands, Prev: File Commands, Up: Simple Commands
1968 Commands Dealing with Object File Formats
1969 -----------------------------------------
1971 A couple of linker script commands deal with object file formats.
1973 `OUTPUT_FORMAT(BFDNAME)'
1974 `OUTPUT_FORMAT(DEFAULT, BIG, LITTLE)'
1975 The `OUTPUT_FORMAT' command names the BFD format to use for the
1976 output file (*note BFD::). Using `OUTPUT_FORMAT(BFDNAME)' is
1977 exactly like using `--oformat BFDNAME' on the command line (*note
1978 Command Line Options: Options.). If both are used, the command
1979 line option takes precedence.
1981 You can use `OUTPUT_FORMAT' with three arguments to use different
1982 formats based on the `-EB' and `-EL' command line options. This
1983 permits the linker script to set the output format based on the
1986 If neither `-EB' nor `-EL' are used, then the output format will
1987 be the first argument, DEFAULT. If `-EB' is used, the output
1988 format will be the second argument, BIG. If `-EL' is used, the
1989 output format will be the third argument, LITTLE.
1991 For example, the default linker script for the MIPS ELF target
1993 OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)
1994 This says that the default format for the output file is
1995 `elf32-bigmips', but if the user uses the `-EL' command line
1996 option, the output file will be created in the `elf32-littlemips'
2000 The `TARGET' command names the BFD format to use when reading input
2001 files. It affects subsequent `INPUT' and `GROUP' commands. This
2002 command is like using `-b BFDNAME' on the command line (*note
2003 Command Line Options: Options.). If the `TARGET' command is used
2004 but `OUTPUT_FORMAT' is not, then the last `TARGET' command is also
2005 used to set the format for the output file. *Note BFD::.
2008 File: ld.info, Node: Miscellaneous Commands, Prev: Format Commands, Up: Simple Commands
2010 Other Linker Script Commands
2011 ----------------------------
2013 There are a few other linker scripts commands.
2015 `ASSERT(EXP, MESSAGE)'
2016 Ensure that EXP is non-zero. If it is zero, then exit the linker
2017 with an error code, and print MESSAGE.
2019 `EXTERN(SYMBOL SYMBOL ...)'
2020 Force SYMBOL to be entered in the output file as an undefined
2021 symbol. Doing this may, for example, trigger linking of additional
2022 modules from standard libraries. You may list several SYMBOLs for
2023 each `EXTERN', and you may use `EXTERN' multiple times. This
2024 command has the same effect as the `-u' command-line option.
2026 `FORCE_COMMON_ALLOCATION'
2027 This command has the same effect as the `-d' command-line option:
2028 to make `ld' assign space to common symbols even if a relocatable
2029 output file is specified (`-r').
2031 `INHIBIT_COMMON_ALLOCATION'
2032 This command has the same effect as the `--no-define-common'
2033 command-line option: to make `ld' omit the assignment of addresses
2034 to common symbols even for a non-relocatable output file.
2036 `NOCROSSREFS(SECTION SECTION ...)'
2037 This command may be used to tell `ld' to issue an error about any
2038 references among certain output sections.
2040 In certain types of programs, particularly on embedded systems when
2041 using overlays, when one section is loaded into memory, another
2042 section will not be. Any direct references between the two
2043 sections would be errors. For example, it would be an error if
2044 code in one section called a function defined in the other section.
2046 The `NOCROSSREFS' command takes a list of output section names. If
2047 `ld' detects any cross references between the sections, it reports
2048 an error and returns a non-zero exit status. Note that the
2049 `NOCROSSREFS' command uses output section names, not input section
2052 `OUTPUT_ARCH(BFDARCH)'
2053 Specify a particular output machine architecture. The argument is
2054 one of the names used by the BFD library (*note BFD::). You can
2055 see the architecture of an object file by using the `objdump'
2056 program with the `-f' option.
2059 File: ld.info, Node: Assignments, Next: SECTIONS, Prev: Simple Commands, Up: Scripts
2061 Assigning Values to Symbols
2062 ===========================
2064 You may assign a value to a symbol in a linker script. This will define
2065 the symbol as a global symbol.
2069 * Simple Assignments:: Simple Assignments
2073 File: ld.info, Node: Simple Assignments, Next: PROVIDE, Up: Assignments
2078 You may assign to a symbol using any of the C assignment operators:
2080 `SYMBOL = EXPRESSION ;'
2081 `SYMBOL += EXPRESSION ;'
2082 `SYMBOL -= EXPRESSION ;'
2083 `SYMBOL *= EXPRESSION ;'
2084 `SYMBOL /= EXPRESSION ;'
2085 `SYMBOL <<= EXPRESSION ;'
2086 `SYMBOL >>= EXPRESSION ;'
2087 `SYMBOL &= EXPRESSION ;'
2088 `SYMBOL |= EXPRESSION ;'
2090 The first case will define SYMBOL to the value of EXPRESSION. In
2091 the other cases, SYMBOL must already be defined, and the value will be
2092 adjusted accordingly.
2094 The special symbol name `.' indicates the location counter. You may
2095 only use this within a `SECTIONS' command.
2097 The semicolon after EXPRESSION is required.
2099 Expressions are defined below; see *Note Expressions::.
2101 You may write symbol assignments as commands in their own right, or
2102 as statements within a `SECTIONS' command, or as part of an output
2103 section description in a `SECTIONS' command.
2105 The section of the symbol will be set from the section of the
2106 expression; for more information, see *Note Expression Section::.
2108 Here is an example showing the three different places that symbol
2109 assignments may be used:
2119 _bdata = (. + 3) & ~ 3;
2120 .data : { *(.data) }
2123 In this example, the symbol `floating_point' will be defined as zero.
2124 The symbol `_etext' will be defined as the address following the last
2125 `.text' input section. The symbol `_bdata' will be defined as the
2126 address following the `.text' output section aligned upward to a 4 byte
2130 File: ld.info, Node: PROVIDE, Prev: Simple Assignments, Up: Assignments
2135 In some cases, it is desirable for a linker script to define a symbol
2136 only if it is referenced and is not defined by any object included in
2137 the link. For example, traditional linkers defined the symbol `etext'.
2138 However, ANSI C requires that the user be able to use `etext' as a
2139 function name without encountering an error. The `PROVIDE' keyword may
2140 be used to define a symbol, such as `etext', only if it is referenced
2141 but not defined. The syntax is `PROVIDE(SYMBOL = EXPRESSION)'.
2143 Here is an example of using `PROVIDE' to define `etext':
2154 In this example, if the program defines `_etext' (with a leading
2155 underscore), the linker will give a multiple definition error. If, on
2156 the other hand, the program defines `etext' (with no leading
2157 underscore), the linker will silently use the definition in the program.
2158 If the program references `etext' but does not define it, the linker
2159 will use the definition in the linker script.
2162 File: ld.info, Node: SECTIONS, Next: MEMORY, Prev: Assignments, Up: Scripts
2167 The `SECTIONS' command tells the linker how to map input sections into
2168 output sections, and how to place the output sections in memory.
2170 The format of the `SECTIONS' command is:
2178 Each SECTIONS-COMMAND may of be one of the following:
2180 * an `ENTRY' command (*note Entry command: Entry Point.)
2182 * a symbol assignment (*note Assignments::)
2184 * an output section description
2186 * an overlay description
2188 The `ENTRY' command and symbol assignments are permitted inside the
2189 `SECTIONS' command for convenience in using the location counter in
2190 those commands. This can also make the linker script easier to
2191 understand because you can use those commands at meaningful points in
2192 the layout of the output file.
2194 Output section descriptions and overlay descriptions are described
2197 If you do not use a `SECTIONS' command in your linker script, the
2198 linker will place each input section into an identically named output
2199 section in the order that the sections are first encountered in the
2200 input files. If all input sections are present in the first file, for
2201 example, the order of sections in the output file will match the order
2202 in the first input file. The first section will be at address zero.
2206 * Output Section Description:: Output section description
2207 * Output Section Name:: Output section name
2208 * Output Section Address:: Output section address
2209 * Input Section:: Input section description
2210 * Output Section Data:: Output section data
2211 * Output Section Keywords:: Output section keywords
2212 * Output Section Discarding:: Output section discarding
2213 * Output Section Attributes:: Output section attributes
2214 * Overlay Description:: Overlay description
2217 File: ld.info, Node: Output Section Description, Next: Output Section Name, Up: SECTIONS
2219 Output Section Description
2220 --------------------------
2222 The full description of an output section looks like this:
2223 SECTION [ADDRESS] [(TYPE)] :
2224 [AT(LMA)] [SUBALIGN(SUBSECTION_ALIGN)]
2226 OUTPUT-SECTION-COMMAND
2227 OUTPUT-SECTION-COMMAND
2229 } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
2231 Most output sections do not use most of the optional section
2234 The whitespace around SECTION is required, so that the section name
2235 is unambiguous. The colon and the curly braces are also required. The
2236 line breaks and other white space are optional.
2238 Each OUTPUT-SECTION-COMMAND may be one of the following:
2240 * a symbol assignment (*note Assignments::)
2242 * an input section description (*note Input Section::)
2244 * data values to include directly (*note Output Section Data::)
2246 * a special output section keyword (*note Output Section Keywords::)
2249 File: ld.info, Node: Output Section Name, Next: Output Section Address, Prev: Output Section Description, Up: SECTIONS
2254 The name of the output section is SECTION. SECTION must meet the
2255 constraints of your output format. In formats which only support a
2256 limited number of sections, such as `a.out', the name must be one of
2257 the names supported by the format (`a.out', for example, allows only
2258 `.text', `.data' or `.bss'). If the output format supports any number
2259 of sections, but with numbers and not names (as is the case for Oasys),
2260 the name should be supplied as a quoted numeric string. A section name
2261 may consist of any sequence of characters, but a name which contains
2262 any unusual characters such as commas must be quoted.
2264 The output section name `/DISCARD/' is special; *Note Output Section
2268 File: ld.info, Node: Output Section Address, Next: Input Section, Prev: Output Section Name, Up: SECTIONS
2270 Output Section Description
2271 --------------------------
2273 The ADDRESS is an expression for the VMA (the virtual memory address)
2274 of the output section. If you do not provide ADDRESS, the linker will
2275 set it based on REGION if present, or otherwise based on the current
2276 value of the location counter.
2278 If you provide ADDRESS, the address of the output section will be
2279 set to precisely that. If you provide neither ADDRESS nor REGION, then
2280 the address of the output section will be set to the current value of
2281 the location counter aligned to the alignment requirements of the
2282 output section. The alignment requirement of the output section is the
2283 strictest alignment of any input section contained within the output
2287 .text . : { *(.text) }
2290 .text : { *(.text) }
2292 are subtly different. The first will set the address of the `.text'
2293 output section to the current value of the location counter. The
2294 second will set it to the current value of the location counter aligned
2295 to the strictest alignment of a `.text' input section.
2297 The ADDRESS may be an arbitrary expression; *Note Expressions::.
2298 For example, if you want to align the section on a 0x10 byte boundary,
2299 so that the lowest four bits of the section address are zero, you could
2300 do something like this:
2301 .text ALIGN(0x10) : { *(.text) }
2303 This works because `ALIGN' returns the current location counter aligned
2304 upward to the specified value.
2306 Specifying ADDRESS for a section will change the value of the
2310 File: ld.info, Node: Input Section, Next: Output Section Data, Prev: Output Section Address, Up: SECTIONS
2312 Input Section Description
2313 -------------------------
2315 The most common output section command is an input section description.
2317 The input section description is the most basic linker script
2318 operation. You use output sections to tell the linker how to lay out
2319 your program in memory. You use input section descriptions to tell the
2320 linker how to map the input files into your memory layout.
2324 * Input Section Basics:: Input section basics
2325 * Input Section Wildcards:: Input section wildcard patterns
2326 * Input Section Common:: Input section for common symbols
2327 * Input Section Keep:: Input section and garbage collection
2328 * Input Section Example:: Input section example
2331 File: ld.info, Node: Input Section Basics, Next: Input Section Wildcards, Up: Input Section
2333 Input Section Basics
2334 ....................
2336 An input section description consists of a file name optionally followed
2337 by a list of section names in parentheses.
2339 The file name and the section name may be wildcard patterns, which we
2340 describe further below (*note Input Section Wildcards::).
2342 The most common input section description is to include all input
2343 sections with a particular name in the output section. For example, to
2344 include all input `.text' sections, you would write:
2347 Here the `*' is a wildcard which matches any file name. To exclude a
2348 list of files from matching the file name wildcard, EXCLUDE_FILE may be
2349 used to match all files except the ones specified in the EXCLUDE_FILE
2351 (*(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors))
2352 will cause all .ctors sections from all files except `crtend.o' and
2353 `otherfile.o' to be included.
2355 There are two ways to include more than one section:
2359 The difference between these is the order in which the `.text' and
2360 `.rdata' input sections will appear in the output section. In the
2361 first example, they will be intermingled, appearing in the same order as
2362 they are found in the linker input. In the second example, all `.text'
2363 input sections will appear first, followed by all `.rdata' input
2366 You can specify a file name to include sections from a particular
2367 file. You would do this if one or more of your files contain special
2368 data that needs to be at a particular location in memory. For example:
2371 If you use a file name without a list of sections, then all sections
2372 in the input file will be included in the output section. This is not
2373 commonly done, but it may by useful on occasion. For example:
2376 When you use a file name which does not contain any wild card
2377 characters, the linker will first see if you also specified the file
2378 name on the linker command line or in an `INPUT' command. If you did
2379 not, the linker will attempt to open the file as an input file, as
2380 though it appeared on the command line. Note that this differs from an
2381 `INPUT' command, because the linker will not search for the file in the
2382 archive search path.
2385 File: ld.info, Node: Input Section Wildcards, Next: Input Section Common, Prev: Input Section Basics, Up: Input Section
2387 Input Section Wildcard Patterns
2388 ...............................
2390 In an input section description, either the file name or the section
2391 name or both may be wildcard patterns.
2393 The file name of `*' seen in many examples is a simple wildcard
2394 pattern for the file name.
2396 The wildcard patterns are like those used by the Unix shell.
2399 matches any number of characters
2402 matches any single character
2405 matches a single instance of any of the CHARS; the `-' character
2406 may be used to specify a range of characters, as in `[a-z]' to
2407 match any lower case letter
2410 quotes the following character
2412 When a file name is matched with a wildcard, the wildcard characters
2413 will not match a `/' character (used to separate directory names on
2414 Unix). A pattern consisting of a single `*' character is an exception;
2415 it will always match any file name, whether it contains a `/' or not.
2416 In a section name, the wildcard characters will match a `/' character.
2418 File name wildcard patterns only match files which are explicitly
2419 specified on the command line or in an `INPUT' command. The linker
2420 does not search directories to expand wildcards.
2422 If a file name matches more than one wildcard pattern, or if a file
2423 name appears explicitly and is also matched by a wildcard pattern, the
2424 linker will use the first match in the linker script. For example, this
2425 sequence of input section descriptions is probably in error, because the
2426 `data.o' rule will not be used:
2427 .data : { *(.data) }
2428 .data1 : { data.o(.data) }
2430 Normally, the linker will place files and sections matched by
2431 wildcards in the order in which they are seen during the link. You can
2432 change this by using the `SORT' keyword, which appears before a wildcard
2433 pattern in parentheses (e.g., `SORT(.text*)'). When the `SORT' keyword
2434 is used, the linker will sort the files or sections into ascending
2435 order by name before placing them in the output file.
2437 If you ever get confused about where input sections are going, use
2438 the `-M' linker option to generate a map file. The map file shows
2439 precisely how input sections are mapped to output sections.
2441 This example shows how wildcard patterns might be used to partition
2442 files. This linker script directs the linker to place all `.text'
2443 sections in `.text' and all `.bss' sections in `.bss'. The linker will
2444 place the `.data' section from all files beginning with an upper case
2445 character in `.DATA'; for all other files, the linker will place the
2446 `.data' section in `.data'.
2448 .text : { *(.text) }
2449 .DATA : { [A-Z]*(.data) }
2450 .data : { *(.data) }
2455 File: ld.info, Node: Input Section Common, Next: Input Section Keep, Prev: Input Section Wildcards, Up: Input Section
2457 Input Section for Common Symbols
2458 ................................
2460 A special notation is needed for common symbols, because in many object
2461 file formats common symbols do not have a particular input section. The
2462 linker treats common symbols as though they are in an input section
2465 You may use file names with the `COMMON' section just as with any
2466 other input sections. You can use this to place common symbols from a
2467 particular input file in one section while common symbols from other
2468 input files are placed in another section.
2470 In most cases, common symbols in input files will be placed in the
2471 `.bss' section in the output file. For example:
2472 .bss { *(.bss) *(COMMON) }
2474 Some object file formats have more than one type of common symbol.
2475 For example, the MIPS ELF object file format distinguishes standard
2476 common symbols and small common symbols. In this case, the linker will
2477 use a different special section name for other types of common symbols.
2478 In the case of MIPS ELF, the linker uses `COMMON' for standard common
2479 symbols and `.scommon' for small common symbols. This permits you to
2480 map the different types of common symbols into memory at different
2483 You will sometimes see `[COMMON]' in old linker scripts. This
2484 notation is now considered obsolete. It is equivalent to `*(COMMON)'.
2487 File: ld.info, Node: Input Section Keep, Next: Input Section Example, Prev: Input Section Common, Up: Input Section
2489 Input Section and Garbage Collection
2490 ....................................
2492 When link-time garbage collection is in use (`--gc-sections'), it is
2493 often useful to mark sections that should not be eliminated. This is
2494 accomplished by surrounding an input section's wildcard entry with
2495 `KEEP()', as in `KEEP(*(.init))' or `KEEP(SORT(*)(.ctors))'.
2498 File: ld.info, Node: Input Section Example, Prev: Input Section Keep, Up: Input Section
2500 Input Section Example
2501 .....................
2503 The following example is a complete linker script. It tells the linker
2504 to read all of the sections from file `all.o' and place them at the
2505 start of output section `outputa' which starts at location `0x10000'.
2506 All of section `.input1' from file `foo.o' follows immediately, in the
2507 same output section. All of section `.input2' from `foo.o' goes into
2508 output section `outputb', followed by section `.input1' from `foo1.o'.
2509 All of the remaining `.input1' and `.input2' sections from any files
2510 are written to output section `outputc'.
2531 File: ld.info, Node: Output Section Data, Next: Output Section Keywords, Prev: Input Section, Up: SECTIONS
2536 You can include explicit bytes of data in an output section by using
2537 `BYTE', `SHORT', `LONG', `QUAD', or `SQUAD' as an output section
2538 command. Each keyword is followed by an expression in parentheses
2539 providing the value to store (*note Expressions::). The value of the
2540 expression is stored at the current value of the location counter.
2542 The `BYTE', `SHORT', `LONG', and `QUAD' commands store one, two,
2543 four, and eight bytes (respectively). After storing the bytes, the
2544 location counter is incremented by the number of bytes stored.
2546 For example, this will store the byte 1 followed by the four byte
2547 value of the symbol `addr':
2551 When using a 64 bit host or target, `QUAD' and `SQUAD' are the same;
2552 they both store an 8 byte, or 64 bit, value. When both host and target
2553 are 32 bits, an expression is computed as 32 bits. In this case `QUAD'
2554 stores a 32 bit value zero extended to 64 bits, and `SQUAD' stores a 32
2555 bit value sign extended to 64 bits.
2557 If the object file format of the output file has an explicit
2558 endianness, which is the normal case, the value will be stored in that
2559 endianness. When the object file format does not have an explicit
2560 endianness, as is true of, for example, S-records, the value will be
2561 stored in the endianness of the first input object file.
2563 Note--these commands only work inside a section description and not
2564 between them, so the following will produce an error from the linker:
2565 SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }
2566 whereas this will work:
2567 SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }
2569 You may use the `FILL' command to set the fill pattern for the
2570 current section. It is followed by an expression in parentheses. Any
2571 otherwise unspecified regions of memory within the section (for example,
2572 gaps left due to the required alignment of input sections) are filled
2573 with the value of the expression, repeated as necessary. A `FILL'
2574 statement covers memory locations after the point at which it occurs in
2575 the section definition; by including more than one `FILL' statement,
2576 you can have different fill patterns in different parts of an output
2579 This example shows how to fill unspecified regions of memory with the
2583 The `FILL' command is similar to the `=FILLEXP' output section
2584 attribute, but it only affects the part of the section following the
2585 `FILL' command, rather than the entire section. If both are used, the
2586 `FILL' command takes precedence. *Note Output Section Fill::, for
2587 details on the fill expression.
2590 File: ld.info, Node: Output Section Keywords, Next: Output Section Discarding, Prev: Output Section Data, Up: SECTIONS
2592 Output Section Keywords
2593 -----------------------
2595 There are a couple of keywords which can appear as output section
2598 `CREATE_OBJECT_SYMBOLS'
2599 The command tells the linker to create a symbol for each input
2600 file. The name of each symbol will be the name of the
2601 corresponding input file. The section of each symbol will be the
2602 output section in which the `CREATE_OBJECT_SYMBOLS' command
2605 This is conventional for the a.out object file format. It is not
2606 normally used for any other object file format.
2609 When linking using the a.out object file format, the linker uses an
2610 unusual set construct to support C++ global constructors and
2611 destructors. When linking object file formats which do not support
2612 arbitrary sections, such as ECOFF and XCOFF, the linker will
2613 automatically recognize C++ global constructors and destructors by
2614 name. For these object file formats, the `CONSTRUCTORS' command
2615 tells the linker to place constructor information in the output
2616 section where the `CONSTRUCTORS' command appears. The
2617 `CONSTRUCTORS' command is ignored for other object file formats.
2619 The symbol `__CTOR_LIST__' marks the start of the global
2620 constructors, and the symbol `__DTOR_LIST' marks the end. The
2621 first word in the list is the number of entries, followed by the
2622 address of each constructor or destructor, followed by a zero
2623 word. The compiler must arrange to actually run the code. For
2624 these object file formats GNU C++ normally calls constructors from
2625 a subroutine `__main'; a call to `__main' is automatically
2626 inserted into the startup code for `main'. GNU C++ normally runs
2627 destructors either by using `atexit', or directly from the function
2630 For object file formats such as `COFF' or `ELF' which support
2631 arbitrary section names, GNU C++ will normally arrange to put the
2632 addresses of global constructors and destructors into the `.ctors'
2633 and `.dtors' sections. Placing the following sequence into your
2634 linker script will build the sort of table which the GNU C++
2635 runtime code expects to see.
2638 LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
2643 LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
2648 If you are using the GNU C++ support for initialization priority,
2649 which provides some control over the order in which global
2650 constructors are run, you must sort the constructors at link time
2651 to ensure that they are executed in the correct order. When using
2652 the `CONSTRUCTORS' command, use `SORT(CONSTRUCTORS)' instead.
2653 When using the `.ctors' and `.dtors' sections, use
2654 `*(SORT(.ctors))' and `*(SORT(.dtors))' instead of just
2655 `*(.ctors)' and `*(.dtors)'.
2657 Normally the compiler and linker will handle these issues
2658 automatically, and you will not need to concern yourself with
2659 them. However, you may need to consider this if you are using C++
2660 and writing your own linker scripts.
2664 File: ld.info, Node: Output Section Discarding, Next: Output Section Attributes, Prev: Output Section Keywords, Up: SECTIONS
2666 Output Section Discarding
2667 -------------------------
2669 The linker will not create output section which do not have any
2670 contents. This is for convenience when referring to input sections that
2671 may or may not be present in any of the input files. For example:
2674 will only create a `.foo' section in the output file if there is a
2675 `.foo' section in at least one input file.
2677 If you use anything other than an input section description as an
2678 output section command, such as a symbol assignment, then the output
2679 section will always be created, even if there are no matching input
2682 The special output section name `/DISCARD/' may be used to discard
2683 input sections. Any input sections which are assigned to an output
2684 section named `/DISCARD/' are not included in the output file.
2687 File: ld.info, Node: Output Section Attributes, Next: Overlay Description, Prev: Output Section Discarding, Up: SECTIONS
2689 Output Section Attributes
2690 -------------------------
2692 We showed above that the full description of an output section looked
2694 SECTION [ADDRESS] [(TYPE)] :
2695 [AT(LMA)] [SUBALIGN(SUBSECTION_ALIGN)]
2697 OUTPUT-SECTION-COMMAND
2698 OUTPUT-SECTION-COMMAND
2700 } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
2701 We've already described SECTION, ADDRESS, and
2702 OUTPUT-SECTION-COMMAND. In this section we will describe the remaining
2707 * Output Section Type:: Output section type
2708 * Output Section LMA:: Output section LMA
2709 * Forced Input Alignment:: Forced Input Alignment
2710 * Output Section Region:: Output section region
2711 * Output Section Phdr:: Output section phdr
2712 * Output Section Fill:: Output section fill
2715 File: ld.info, Node: Output Section Type, Next: Output Section LMA, Up: Output Section Attributes
2720 Each output section may have a type. The type is a keyword in
2721 parentheses. The following types are defined:
2724 The section should be marked as not loadable, so that it will not
2725 be loaded into memory when the program is run.
2731 These type names are supported for backward compatibility, and are
2732 rarely used. They all have the same effect: the section should be
2733 marked as not allocatable, so that no memory is allocated for the
2734 section when the program is run.
2736 The linker normally sets the attributes of an output section based on
2737 the input sections which map into it. You can override this by using
2738 the section type. For example, in the script sample below, the `ROM'
2739 section is addressed at memory location `0' and does not need to be
2740 loaded when the program is run. The contents of the `ROM' section will
2741 appear in the linker output file as usual.
2743 ROM 0 (NOLOAD) : { ... }
2748 File: ld.info, Node: Output Section LMA, Next: Forced Input Alignment, Prev: Output Section Type, Up: Output Section Attributes
2753 Every section has a virtual address (VMA) and a load address (LMA); see
2754 *Note Basic Script Concepts::. The address expression which may appear
2755 in an output section description sets the VMA (*note Output Section
2758 The linker will normally set the LMA equal to the VMA. You can
2759 change that by using the `AT' keyword. The expression LMA that follows
2760 the `AT' keyword specifies the load address of the section.
2762 Alternatively, with `AT>LMA_REGION' expression, you may specify a
2763 memory region for the section's load address. *Note MEMORY::. Note
2764 that if the section has not had a VMA assigned to it then the linker
2765 will use the LMA_REGION as the VMA region as well. *Note Output
2768 This feature is designed to make it easy to build a ROM image. For
2769 example, the following linker script creates three output sections: one
2770 called `.text', which starts at `0x1000', one called `.mdata', which is
2771 loaded at the end of the `.text' section even though its VMA is
2772 `0x2000', and one called `.bss' to hold uninitialized data at address
2773 `0x3000'. The symbol `_data' is defined with the value `0x2000', which
2774 shows that the location counter holds the VMA value, not the LMA value.
2778 .text 0x1000 : { *(.text) _etext = . ; }
2780 AT ( ADDR (.text) + SIZEOF (.text) )
2781 { _data = . ; *(.data); _edata = . ; }
2783 { _bstart = . ; *(.bss) *(COMMON) ; _bend = . ;}
2786 The run-time initialization code for use with a program generated
2787 with this linker script would include something like the following, to
2788 copy the initialized data from the ROM image to its runtime address.
2789 Notice how this code takes advantage of the symbols defined by the
2792 extern char _etext, _data, _edata, _bstart, _bend;
2793 char *src = &_etext;
2796 /* ROM has data at end of text; copy it. */
2797 while (dst < &_edata) {
2802 for (dst = &_bstart; dst< &_bend; dst++)
2806 File: ld.info, Node: Forced Input Alignment, Next: Output Section Region, Prev: Output Section LMA, Up: Output Section Attributes
2808 Forced Input Alignment
2809 ......................
2811 You can force input section alignment within an output section by using
2812 SUBALIGN. The value specified overrides any alignment given by input
2813 sections, whether larger or smaller.
2816 File: ld.info, Node: Output Section Region, Next: Output Section Phdr, Prev: Forced Input Alignment, Up: Output Section Attributes
2818 Output Section Region
2819 .....................
2821 You can assign a section to a previously defined region of memory by
2822 using `>REGION'. *Note MEMORY::.
2824 Here is a simple example:
2825 MEMORY { rom : ORIGIN = 0x1000, LENGTH = 0x1000 }
2826 SECTIONS { ROM : { *(.text) } >rom }
2829 File: ld.info, Node: Output Section Phdr, Next: Output Section Fill, Prev: Output Section Region, Up: Output Section Attributes
2834 You can assign a section to a previously defined program segment by
2835 using `:PHDR'. *Note PHDRS::. If a section is assigned to one or more
2836 segments, then all subsequent allocated sections will be assigned to
2837 those segments as well, unless they use an explicitly `:PHDR' modifier.
2838 You can use `:NONE' to tell the linker to not put the section in any
2841 Here is a simple example:
2842 PHDRS { text PT_LOAD ; }
2843 SECTIONS { .text : { *(.text) } :text }
2846 File: ld.info, Node: Output Section Fill, Prev: Output Section Phdr, Up: Output Section Attributes
2851 You can set the fill pattern for an entire section by using `=FILLEXP'.
2852 FILLEXP is an expression (*note Expressions::). Any otherwise
2853 unspecified regions of memory within the output section (for example,
2854 gaps left due to the required alignment of input sections) will be
2855 filled with the value, repeated as necessary. If the fill expression
2856 is a simple hex number, ie. a string of hex digit starting with `0x'
2857 and without a trailing `k' or `M', then an arbitrarily long sequence of
2858 hex digits can be used to specify the fill pattern; Leading zeros
2859 become part of the pattern too. For all other cases, including extra
2860 parentheses or a unary `+', the fill pattern is the four least
2861 significant bytes of the value of the expression. In all cases, the
2862 number is big-endian.
2864 You can also change the fill value with a `FILL' command in the
2865 output section commands; (*note Output Section Data::).
2867 Here is a simple example:
2868 SECTIONS { .text : { *(.text) } =0x90909090 }
2871 File: ld.info, Node: Overlay Description, Prev: Output Section Attributes, Up: SECTIONS
2876 An overlay description provides an easy way to describe sections which
2877 are to be loaded as part of a single memory image but are to be run at
2878 the same memory address. At run time, some sort of overlay manager will
2879 copy the overlaid sections in and out of the runtime memory address as
2880 required, perhaps by simply manipulating addressing bits. This approach
2881 can be useful, for example, when a certain region of memory is faster
2884 Overlays are described using the `OVERLAY' command. The `OVERLAY'
2885 command is used within a `SECTIONS' command, like an output section
2886 description. The full syntax of the `OVERLAY' command is as follows:
2887 OVERLAY [START] : [NOCROSSREFS] [AT ( LDADDR )]
2891 OUTPUT-SECTION-COMMAND
2892 OUTPUT-SECTION-COMMAND
2894 } [:PHDR...] [=FILL]
2897 OUTPUT-SECTION-COMMAND
2898 OUTPUT-SECTION-COMMAND
2900 } [:PHDR...] [=FILL]
2902 } [>REGION] [:PHDR...] [=FILL]
2904 Everything is optional except `OVERLAY' (a keyword), and each
2905 section must have a name (SECNAME1 and SECNAME2 above). The section
2906 definitions within the `OVERLAY' construct are identical to those
2907 within the general `SECTIONS' contruct (*note SECTIONS::), except that
2908 no addresses and no memory regions may be defined for sections within
2911 The sections are all defined with the same starting address. The
2912 load addresses of the sections are arranged such that they are
2913 consecutive in memory starting at the load address used for the
2914 `OVERLAY' as a whole (as with normal section definitions, the load
2915 address is optional, and defaults to the start address; the start
2916 address is also optional, and defaults to the current value of the
2919 If the `NOCROSSREFS' keyword is used, and there any references among
2920 the sections, the linker will report an error. Since the sections all
2921 run at the same address, it normally does not make sense for one
2922 section to refer directly to another. *Note NOCROSSREFS: Miscellaneous
2925 For each section within the `OVERLAY', the linker automatically
2926 defines two symbols. The symbol `__load_start_SECNAME' is defined as
2927 the starting load address of the section. The symbol
2928 `__load_stop_SECNAME' is defined as the final load address of the
2929 section. Any characters within SECNAME which are not legal within C
2930 identifiers are removed. C (or assembler) code may use these symbols
2931 to move the overlaid sections around as necessary.
2933 At the end of the overlay, the value of the location counter is set
2934 to the start address of the overlay plus the size of the largest
2937 Here is an example. Remember that this would appear inside a
2938 `SECTIONS' construct.
2939 OVERLAY 0x1000 : AT (0x4000)
2941 .text0 { o1/*.o(.text) }
2942 .text1 { o2/*.o(.text) }
2945 This will define both `.text0' and `.text1' to start at address 0x1000.
2946 `.text0' will be loaded at address 0x4000, and `.text1' will be loaded
2947 immediately after `.text0'. The following symbols will be defined:
2948 `__load_start_text0', `__load_stop_text0', `__load_start_text1',
2949 `__load_stop_text1'.
2951 C code to copy overlay `.text1' into the overlay area might look
2954 extern char __load_start_text1, __load_stop_text1;
2955 memcpy ((char *) 0x1000, &__load_start_text1,
2956 &__load_stop_text1 - &__load_start_text1);
2958 Note that the `OVERLAY' command is just syntactic sugar, since
2959 everything it does can be done using the more basic commands. The above
2960 example could have been written identically as follows.
2962 .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
2963 __load_start_text0 = LOADADDR (.text0);
2964 __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
2965 .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
2966 __load_start_text1 = LOADADDR (.text1);
2967 __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
2968 . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
2971 File: ld.info, Node: MEMORY, Next: PHDRS, Prev: SECTIONS, Up: Scripts
2976 The linker's default configuration permits allocation of all available
2977 memory. You can override this by using the `MEMORY' command.
2979 The `MEMORY' command describes the location and size of blocks of
2980 memory in the target. You can use it to describe which memory regions
2981 may be used by the linker, and which memory regions it must avoid. You
2982 can then assign sections to particular memory regions. The linker will
2983 set section addresses based on the memory regions, and will warn about
2984 regions that become too full. The linker will not shuffle sections
2985 around to fit into the available regions.
2987 A linker script may contain at most one use of the `MEMORY' command.
2988 However, you can define as many blocks of memory within it as you
2989 wish. The syntax is:
2992 NAME [(ATTR)] : ORIGIN = ORIGIN, LENGTH = LEN
2996 The NAME is a name used in the linker script to refer to the region.
2997 The region name has no meaning outside of the linker script. Region
2998 names are stored in a separate name space, and will not conflict with
2999 symbol names, file names, or section names. Each memory region must
3000 have a distinct name.
3002 The ATTR string is an optional list of attributes that specify
3003 whether to use a particular memory region for an input section which is
3004 not explicitly mapped in the linker script. As described in *Note
3005 SECTIONS::, if you do not specify an output section for some input
3006 section, the linker will create an output section with the same name as
3007 the input section. If you define region attributes, the linker will use
3008 them to select the memory region for the output section that it creates.
3010 The ATTR string must consist only of the following characters:
3030 Invert the sense of any of the preceding attributes
3032 If a unmapped section matches any of the listed attributes other than
3033 `!', it will be placed in the memory region. The `!' attribute
3034 reverses this test, so that an unmapped section will be placed in the
3035 memory region only if it does not match any of the listed attributes.
3037 The ORIGIN is an expression for the start address of the memory
3038 region. The expression must evaluate to a constant before memory
3039 allocation is performed, which means that you may not use any section
3040 relative symbols. The keyword `ORIGIN' may be abbreviated to `org' or
3041 `o' (but not, for example, `ORG').
3043 The LEN is an expression for the size in bytes of the memory region.
3044 As with the ORIGIN expression, the expression must evaluate to a
3045 constant before memory allocation is performed. The keyword `LENGTH'
3046 may be abbreviated to `len' or `l'.
3048 In the following example, we specify that there are two memory
3049 regions available for allocation: one starting at `0' for 256 kilobytes,
3050 and the other starting at `0x40000000' for four megabytes. The linker
3051 will place into the `rom' memory region every section which is not
3052 explicitly mapped into a memory region, and is either read-only or
3053 executable. The linker will place other sections which are not
3054 explicitly mapped into a memory region into the `ram' memory region.
3058 rom (rx) : ORIGIN = 0, LENGTH = 256K
3059 ram (!rx) : org = 0x40000000, l = 4M
3062 Once you define a memory region, you can direct the linker to place
3063 specific output sections into that memory region by using the `>REGION'
3064 output section attribute. For example, if you have a memory region
3065 named `mem', you would use `>mem' in the output section definition.
3066 *Note Output Section Region::. If no address was specified for the
3067 output section, the linker will set the address to the next available
3068 address within the memory region. If the combined output sections
3069 directed to a memory region are too large for the region, the linker
3070 will issue an error message.
3073 File: ld.info, Node: PHDRS, Next: VERSION, Prev: MEMORY, Up: Scripts
3078 The ELF object file format uses "program headers", also knows as
3079 "segments". The program headers describe how the program should be
3080 loaded into memory. You can print them out by using the `objdump'
3081 program with the `-p' option.
3083 When you run an ELF program on a native ELF system, the system loader
3084 reads the program headers in order to figure out how to load the
3085 program. This will only work if the program headers are set correctly.
3086 This manual does not describe the details of how the system loader
3087 interprets program headers; for more information, see the ELF ABI.
3089 The linker will create reasonable program headers by default.
3090 However, in some cases, you may need to specify the program headers more
3091 precisely. You may use the `PHDRS' command for this purpose. When the
3092 linker sees the `PHDRS' command in the linker script, it will not
3093 create any program headers other than the ones specified.
3095 The linker only pays attention to the `PHDRS' command when
3096 generating an ELF output file. In other cases, the linker will simply
3099 This is the syntax of the `PHDRS' command. The words `PHDRS',
3100 `FILEHDR', `AT', and `FLAGS' are keywords.
3104 NAME TYPE [ FILEHDR ] [ PHDRS ] [ AT ( ADDRESS ) ]
3105 [ FLAGS ( FLAGS ) ] ;
3108 The NAME is used only for reference in the `SECTIONS' command of the
3109 linker script. It is not put into the output file. Program header
3110 names are stored in a separate name space, and will not conflict with
3111 symbol names, file names, or section names. Each program header must
3112 have a distinct name.
3114 Certain program header types describe segments of memory which the
3115 system loader will load from the file. In the linker script, you
3116 specify the contents of these segments by placing allocatable output
3117 sections in the segments. You use the `:PHDR' output section attribute
3118 to place a section in a particular segment. *Note Output Section
3121 It is normal to put certain sections in more than one segment. This
3122 merely implies that one segment of memory contains another. You may
3123 repeat `:PHDR', using it once for each segment which should contain the
3126 If you place a section in one or more segments using `:PHDR', then
3127 the linker will place all subsequent allocatable sections which do not
3128 specify `:PHDR' in the same segments. This is for convenience, since
3129 generally a whole set of contiguous sections will be placed in a single
3130 segment. You can use `:NONE' to override the default segment and tell
3131 the linker to not put the section in any segment at all.
3133 You may use the `FILEHDR' and `PHDRS' keywords appear after the
3134 program header type to further describe the contents of the segment.
3135 The `FILEHDR' keyword means that the segment should include the ELF
3136 file header. The `PHDRS' keyword means that the segment should include
3137 the ELF program headers themselves.
3139 The TYPE may be one of the following. The numbers indicate the
3140 value of the keyword.
3143 Indicates an unused program header.
3146 Indicates that this program header describes a segment to be
3147 loaded from the file.
3150 Indicates a segment where dynamic linking information can be found.
3153 Indicates a segment where the name of the program interpreter may
3157 Indicates a segment holding note information.
3160 A reserved program header type, defined but not specified by the
3164 Indicates a segment where the program headers may be found.
3167 An expression giving the numeric type of the program header. This
3168 may be used for types not defined above.
3170 You can specify that a segment should be loaded at a particular
3171 address in memory by using an `AT' expression. This is identical to the
3172 `AT' command used as an output section attribute (*note Output Section
3173 LMA::). The `AT' command for a program header overrides the output
3176 The linker will normally set the segment flags based on the sections
3177 which comprise the segment. You may use the `FLAGS' keyword to
3178 explicitly specify the segment flags. The value of FLAGS must be an
3179 integer. It is used to set the `p_flags' field of the program header.
3181 Here is an example of `PHDRS'. This shows a typical set of program
3182 headers used on a native ELF system.
3186 headers PT_PHDR PHDRS ;
3188 text PT_LOAD FILEHDR PHDRS ;
3190 dynamic PT_DYNAMIC ;
3196 .interp : { *(.interp) } :text :interp
3197 .text : { *(.text) } :text
3198 .rodata : { *(.rodata) } /* defaults to :text */
3200 . = . + 0x1000; /* move to a new page in memory */
3201 .data : { *(.data) } :data
3202 .dynamic : { *(.dynamic) } :data :dynamic
3207 File: ld.info, Node: VERSION, Next: Expressions, Prev: PHDRS, Up: Scripts
3212 The linker supports symbol versions when using ELF. Symbol versions are
3213 only useful when using shared libraries. The dynamic linker can use
3214 symbol versions to select a specific version of a function when it runs
3215 a program that may have been linked against an earlier version of the
3218 You can include a version script directly in the main linker script,
3219 or you can supply the version script as an implicit linker script. You
3220 can also use the `--version-script' linker option.
3222 The syntax of the `VERSION' command is simply
3223 VERSION { version-script-commands }
3225 The format of the version script commands is identical to that used
3226 by Sun's linker in Solaris 2.5. The version script defines a tree of
3227 version nodes. You specify the node names and interdependencies in the
3228 version script. You can specify which symbols are bound to which
3229 version nodes, and you can reduce a specified set of symbols to local
3230 scope so that they are not globally visible outside of the shared
3233 The easiest way to demonstrate the version script language is with a
3253 This example version script defines three version nodes. The first
3254 version node defined is `VERS_1.1'; it has no other dependencies. The
3255 script binds the symbol `foo1' to `VERS_1.1'. It reduces a number of
3256 symbols to local scope so that they are not visible outside of the
3257 shared library; this is done using wildcard patterns, so that any
3258 symbol whose name begins with `old', `original', or `new' is matched.
3259 The wildcard patterns available are the same as those used in the shell
3260 when matching filenames (also known as "globbing").
3262 Next, the version script defines node `VERS_1.2'. This node depends
3263 upon `VERS_1.1'. The script binds the symbol `foo2' to the version
3266 Finally, the version script defines node `VERS_2.0'. This node
3267 depends upon `VERS_1.2'. The scripts binds the symbols `bar1' and
3268 `bar2' are bound to the version node `VERS_2.0'.
3270 When the linker finds a symbol defined in a library which is not
3271 specifically bound to a version node, it will effectively bind it to an
3272 unspecified base version of the library. You can bind all otherwise
3273 unspecified symbols to a given version node by using `global: *;'
3274 somewhere in the version script.
3276 The names of the version nodes have no specific meaning other than
3277 what they might suggest to the person reading them. The `2.0' version
3278 could just as well have appeared in between `1.1' and `1.2'. However,
3279 this would be a confusing way to write a version script.
3281 Node name can be omited, provided it is the only version node in the
3282 version script. Such version script doesn't assign any versions to
3283 symbols, only selects which symbols will be globally visible out and
3286 { global: foo; bar; local: *; };
3288 When you link an application against a shared library that has
3289 versioned symbols, the application itself knows which version of each
3290 symbol it requires, and it also knows which version nodes it needs from
3291 each shared library it is linked against. Thus at runtime, the dynamic
3292 loader can make a quick check to make sure that the libraries you have
3293 linked against do in fact supply all of the version nodes that the
3294 application will need to resolve all of the dynamic symbols. In this
3295 way it is possible for the dynamic linker to know with certainty that
3296 all external symbols that it needs will be resolvable without having to
3297 search for each symbol reference.
3299 The symbol versioning is in effect a much more sophisticated way of
3300 doing minor version checking that SunOS does. The fundamental problem
3301 that is being addressed here is that typically references to external
3302 functions are bound on an as-needed basis, and are not all bound when
3303 the application starts up. If a shared library is out of date, a
3304 required interface may be missing; when the application tries to use
3305 that interface, it may suddenly and unexpectedly fail. With symbol
3306 versioning, the user will get a warning when they start their program if
3307 the libraries being used with the application are too old.
3309 There are several GNU extensions to Sun's versioning approach. The
3310 first of these is the ability to bind a symbol to a version node in the
3311 source file where the symbol is defined instead of in the versioning
3312 script. This was done mainly to reduce the burden on the library
3313 maintainer. You can do this by putting something like:
3314 __asm__(".symver original_foo,foo@VERS_1.1");
3316 in the C source file. This renames the function `original_foo' to be
3317 an alias for `foo' bound to the version node `VERS_1.1'. The `local:'
3318 directive can be used to prevent the symbol `original_foo' from being
3319 exported. A `.symver' directive takes precedence over a version script.
3321 The second GNU extension is to allow multiple versions of the same
3322 function to appear in a given shared library. In this way you can make
3323 an incompatible change to an interface without increasing the major
3324 version number of the shared library, while still allowing applications
3325 linked against the old interface to continue to function.
3327 To do this, you must use multiple `.symver' directives in the source
3328 file. Here is an example:
3330 __asm__(".symver original_foo,foo@");
3331 __asm__(".symver old_foo,foo@VERS_1.1");
3332 __asm__(".symver old_foo1,foo@VERS_1.2");
3333 __asm__(".symver new_foo,foo@@VERS_2.0");
3335 In this example, `foo@' represents the symbol `foo' bound to the
3336 unspecified base version of the symbol. The source file that contains
3337 this example would define 4 C functions: `original_foo', `old_foo',
3338 `old_foo1', and `new_foo'.
3340 When you have multiple definitions of a given symbol, there needs to
3341 be some way to specify a default version to which external references to
3342 this symbol will be bound. You can do this with the `foo@@VERS_2.0'
3343 type of `.symver' directive. You can only declare one version of a
3344 symbol as the default in this manner; otherwise you would effectively
3345 have multiple definitions of the same symbol.
3347 If you wish to bind a reference to a specific version of the symbol
3348 within the shared library, you can use the aliases of convenience
3349 (i.e., `old_foo'), or you can use the `.symver' directive to
3350 specifically bind to an external version of the function in question.
3352 You can also specify the language in the version script:
3354 VERSION extern "lang" { version-script-commands }
3356 The supported `lang's are `C', `C++', and `Java'. The linker will
3357 iterate over the list of symbols at the link time and demangle them
3358 according to `lang' before matching them to the patterns specified in
3359 `version-script-commands'.
3362 File: ld.info, Node: Expressions, Next: Implicit Linker Scripts, Prev: VERSION, Up: Scripts
3364 Expressions in Linker Scripts
3365 =============================
3367 The syntax for expressions in the linker script language is identical to
3368 that of C expressions. All expressions are evaluated as integers. All
3369 expressions are evaluated in the same size, which is 32 bits if both the
3370 host and target are 32 bits, and is otherwise 64 bits.
3372 You can use and set symbol values in expressions.
3374 The linker defines several special purpose builtin functions for use
3379 * Constants:: Constants
3380 * Symbols:: Symbol Names
3381 * Location Counter:: The Location Counter
3382 * Operators:: Operators
3383 * Evaluation:: Evaluation
3384 * Expression Section:: The Section of an Expression
3385 * Builtin Functions:: Builtin Functions
3388 File: ld.info, Node: Constants, Next: Symbols, Up: Expressions
3393 All constants are integers.
3395 As in C, the linker considers an integer beginning with `0' to be
3396 octal, and an integer beginning with `0x' or `0X' to be hexadecimal.
3397 The linker considers other integers to be decimal.
3399 In addition, you can use the suffixes `K' and `M' to scale a
3400 constant by `1024' or `1024*1024' respectively. For example, the
3401 following all refer to the same quantity:
3407 File: ld.info, Node: Symbols, Next: Location Counter, Prev: Constants, Up: Expressions
3412 Unless quoted, symbol names start with a letter, underscore, or period
3413 and may include letters, digits, underscores, periods, and hyphens.
3414 Unquoted symbol names must not conflict with any keywords. You can
3415 specify a symbol which contains odd characters or has the same name as a
3416 keyword by surrounding the symbol name in double quotes:
3418 "with a space" = "also with a space" + 10;
3420 Since symbols can contain many non-alphabetic characters, it is
3421 safest to delimit symbols with spaces. For example, `A-B' is one
3422 symbol, whereas `A - B' is an expression involving subtraction.
3425 File: ld.info, Node: Location Counter, Next: Operators, Prev: Symbols, Up: Expressions
3427 The Location Counter
3428 --------------------
3430 The special linker variable "dot" `.' always contains the current
3431 output location counter. Since the `.' always refers to a location in
3432 an output section, it may only appear in an expression within a
3433 `SECTIONS' command. The `.' symbol may appear anywhere that an
3434 ordinary symbol is allowed in an expression.
3436 Assigning a value to `.' will cause the location counter to be
3437 moved. This may be used to create holes in the output section. The
3438 location counter may never be moved backwards.
3452 In the previous example, the `.text' section from `file1' is located at
3453 the beginning of the output section `output'. It is followed by a 1000
3454 byte gap. Then the `.text' section from `file2' appears, also with a
3455 1000 byte gap following before the `.text' section from `file3'. The
3456 notation `= 0x12345678' specifies what data to write in the gaps (*note
3457 Output Section Fill::).
3459 Note: `.' actually refers to the byte offset from the start of the
3460 current containing object. Normally this is the `SECTIONS' statement,
3461 whose start address is 0, hence `.' can be used as an absolute address.
3462 If `.' is used inside a section description however, it refers to the
3463 byte offset from the start of that section, not an absolute address.
3464 Thus in a script like this:
3480 The `.text' section will be assigned a starting address of 0x100 and
3481 a size of exactly 0x200 bytes, even if there is not enough data in the
3482 `.text' input sections to fill this area. (If there is too much data,
3483 an error will be produced because this would be an attempt to move `.'
3484 backwards). The `.data' section will start at 0x500 and it will have
3485 an extra 0x600 bytes worth of space after the end of the values from
3486 the `.data' input sections and before the end of the `.data' output
3490 File: ld.info, Node: Operators, Next: Evaluation, Prev: Location Counter, Up: Expressions
3495 The linker recognizes the standard C set of arithmetic operators, with
3496 the standard bindings and precedence levels:
3497 precedence associativity Operators Notes
3503 5 left == != > < <= >=
3509 11 right &= += -= *= /= (2)
3511 Notes: (1) Prefix operators (2) *Note Assignments::.
3514 File: ld.info, Node: Evaluation, Next: Expression Section, Prev: Operators, Up: Expressions
3519 The linker evaluates expressions lazily. It only computes the value of
3520 an expression when absolutely necessary.
3522 The linker needs some information, such as the value of the start
3523 address of the first section, and the origins and lengths of memory
3524 regions, in order to do any linking at all. These values are computed
3525 as soon as possible when the linker reads in the linker script.
3527 However, other values (such as symbol values) are not known or needed
3528 until after storage allocation. Such values are evaluated later, when
3529 other information (such as the sizes of output sections) is available
3530 for use in the symbol assignment expression.
3532 The sizes of sections cannot be known until after allocation, so
3533 assignments dependent upon these are not performed until after
3536 Some expressions, such as those depending upon the location counter
3537 `.', must be evaluated during section allocation.
3539 If the result of an expression is required, but the value is not
3540 available, then an error results. For example, a script like the
3544 .text 9+this_isnt_constant :
3548 will cause the error message `non constant expression for initial
3552 File: ld.info, Node: Expression Section, Next: Builtin Functions, Prev: Evaluation, Up: Expressions
3554 The Section of an Expression
3555 ----------------------------
3557 When the linker evaluates an expression, the result is either absolute
3558 or relative to some section. A relative expression is expressed as a
3559 fixed offset from the base of a section.
3561 The position of the expression within the linker script determines
3562 whether it is absolute or relative. An expression which appears within
3563 an output section definition is relative to the base of the output
3564 section. An expression which appears elsewhere will be absolute.
3566 A symbol set to a relative expression will be relocatable if you
3567 request relocatable output using the `-r' option. That means that a
3568 further link operation may change the value of the symbol. The symbol's
3569 section will be the section of the relative expression.
3571 A symbol set to an absolute expression will retain the same value
3572 through any further link operation. The symbol will be absolute, and
3573 will not have any particular associated section.
3575 You can use the builtin function `ABSOLUTE' to force an expression
3576 to be absolute when it would otherwise be relative. For example, to
3577 create an absolute symbol set to the address of the end of the output
3581 .data : { *(.data) _edata = ABSOLUTE(.); }
3584 If `ABSOLUTE' were not used, `_edata' would be relative to the `.data'
3588 File: ld.info, Node: Builtin Functions, Prev: Expression Section, Up: Expressions
3593 The linker script language includes a number of builtin functions for
3594 use in linker script expressions.
3597 Return the absolute (non-relocatable, as opposed to non-negative)
3598 value of the expression EXP. Primarily useful to assign an
3599 absolute value to a symbol within a section definition, where
3600 symbol values are normally section relative. *Note Expression
3604 Return the absolute address (the VMA) of the named SECTION. Your
3605 script must previously have defined the location of that section.
3606 In the following example, `symbol_1' and `symbol_2' are assigned
3611 start_of_output_1 = ABSOLUTE(.);
3616 symbol_1 = ADDR(.output1);
3617 symbol_2 = start_of_output_1;
3623 Return the location counter (`.') or arbitrary expression aligned
3624 to the next ALIGN boundary. The single operand `ALIGN' doesn't
3625 change the value of the location counter--it just does arithmetic
3626 on it. The two operand `ALIGN' allows an arbitrary expression to
3627 be aligned upwards (`ALIGN(ALIGN)' is equivalent to `ALIGN(.,
3630 Here is an example which aligns the output `.data' section to the
3631 next `0x2000' byte boundary after the preceding section and sets a
3632 variable within the section to the next `0x8000' boundary after the
3635 .data ALIGN(0x2000): {
3637 variable = ALIGN(0x8000);
3641 The first use of `ALIGN' in this example specifies the location of
3642 a section because it is used as the optional ADDRESS attribute of
3643 a section definition (*note Output Section Address::). The second
3644 use of `ALIGN' is used to defines the value of a symbol.
3646 The builtin function `NEXT' is closely related to `ALIGN'.
3649 This is a synonym for `ALIGN', for compatibility with older linker
3650 scripts. It is most often seen when setting the address of an
3653 `DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE)'
3654 This is equivalent to either
3655 (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - 1)))
3657 (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - COMMONPAGESIZE)))
3659 depending on whether the latter uses fewer COMMONPAGESIZE sized
3660 pages for the data segment (area between the result of this
3661 expression and `DATA_SEGMENT_END') than the former or not. If the
3662 latter form is used, it means COMMONPAGESIZE bytes of runtime
3663 memory will be saved at the expense of up to COMMONPAGESIZE wasted
3664 bytes in the on-disk file.
3666 This expression can only be used directly in `SECTIONS' commands,
3667 not in any output section descriptions and only once in the linker
3668 script. COMMONPAGESIZE should be less or equal to MAXPAGESIZE and
3669 should be the system page size the object wants to be optimized
3670 for (while still working on system page sizes up to MAXPAGESIZE).
3673 . = DATA_SEGMENT_ALIGN(0x10000, 0x2000);
3675 `DATA_SEGMENT_END(EXP)'
3676 This defines the end of data segment for `DATA_SEGMENT_ALIGN'
3677 evaluation purposes.
3679 . = DATA_SEGMENT_END(.);
3682 Return 1 if SYMBOL is in the linker global symbol table and is
3683 defined before the statement using DEFINED in the script, otherwise
3684 return 0. You can use this function to provide default values for
3685 symbols. For example, the following script fragment shows how to
3686 set a global symbol `begin' to the first location in the `.text'
3687 section--but if a symbol called `begin' already existed, its value
3692 begin = DEFINED(begin) ? begin : . ;
3699 Return the absolute LMA of the named SECTION. This is normally
3700 the same as `ADDR', but it may be different if the `AT' attribute
3701 is used in the output section definition (*note Output Section
3705 Returns the maximum of EXP1 and EXP2.
3708 Returns the minimum of EXP1 and EXP2.
3711 Return the next unallocated address that is a multiple of EXP.
3712 This function is closely related to `ALIGN(EXP)'; unless you use
3713 the `MEMORY' command to define discontinuous memory for the output
3714 file, the two functions are equivalent.
3717 Return the size in bytes of the named SECTION, if that section has
3718 been allocated. If the section has not been allocated when this is
3719 evaluated, the linker will report an error. In the following
3720 example, `symbol_1' and `symbol_2' are assigned identical values:
3727 symbol_1 = .end - .start ;
3728 symbol_2 = SIZEOF(.output);
3733 Return the size in bytes of the output file's headers. This is
3734 information which appears at the start of the output file. You
3735 can use this number when setting the start address of the first
3736 section, if you choose, to facilitate paging.
3738 When producing an ELF output file, if the linker script uses the
3739 `SIZEOF_HEADERS' builtin function, the linker must compute the
3740 number of program headers before it has determined all the section
3741 addresses and sizes. If the linker later discovers that it needs
3742 additional program headers, it will report an error `not enough
3743 room for program headers'. To avoid this error, you must avoid
3744 using the `SIZEOF_HEADERS' function, or you must rework your linker
3745 script to avoid forcing the linker to use additional program
3746 headers, or you must define the program headers yourself using the
3747 `PHDRS' command (*note PHDRS::).
3750 File: ld.info, Node: Implicit Linker Scripts, Prev: Expressions, Up: Scripts
3752 Implicit Linker Scripts
3753 =======================
3755 If you specify a linker input file which the linker can not recognize as
3756 an object file or an archive file, it will try to read the file as a
3757 linker script. If the file can not be parsed as a linker script, the
3758 linker will report an error.
3760 An implicit linker script will not replace the default linker script.
3762 Typically an implicit linker script would contain only symbol
3763 assignments, or the `INPUT', `GROUP', or `VERSION' commands.
3765 Any input files read because of an implicit linker script will be
3766 read at the position in the command line where the implicit linker
3767 script was read. This can affect archive searching.
3770 File: ld.info, Node: Machine Dependent, Next: BFD, Prev: Scripts, Up: Top
3772 Machine Dependent Features
3773 **************************
3775 `ld' has additional features on some platforms; the following sections
3776 describe them. Machines where `ld' has no additional functionality are
3782 * H8/300:: `ld' and the H8/300
3784 * i960:: `ld' and the Intel 960 family
3786 * ARM:: `ld' and the ARM family
3788 * HPPA ELF32:: `ld' and HPPA 32-bit ELF
3790 * MMIX:: `ld' and MMIX
3792 * MSP430:: `ld' and MSP430
3794 * TI COFF:: `ld' and TI COFF
3796 * WIN32:: `ld' and WIN32 (cygwin/mingw)
3798 * Xtensa:: `ld' and Xtensa Processors
3801 File: ld.info, Node: H8/300, Next: i960, Up: Machine Dependent
3806 For the H8/300, `ld' can perform these global optimizations when you
3807 specify the `--relax' command-line option.
3809 _relaxing address modes_
3810 `ld' finds all `jsr' and `jmp' instructions whose targets are
3811 within eight bits, and turns them into eight-bit program-counter
3812 relative `bsr' and `bra' instructions, respectively.
3814 _synthesizing instructions_
3815 `ld' finds all `mov.b' instructions which use the sixteen-bit
3816 absolute address form, but refer to the top page of memory, and
3817 changes them to use the eight-bit address form. (That is: the
3818 linker turns `mov.b `@'AA:16' into `mov.b `@'AA:8' whenever the
3819 address AA is in the top page of memory).
3822 File: ld.info, Node: i960, Next: ARM, Prev: H8/300, Up: Machine Dependent
3824 `ld' and the Intel 960 Family
3825 =============================
3827 You can use the `-AARCHITECTURE' command line option to specify one of
3828 the two-letter names identifying members of the 960 family; the option
3829 specifies the desired output target, and warns of any incompatible
3830 instructions in the input files. It also modifies the linker's search
3831 strategy for archive libraries, to support the use of libraries
3832 specific to each particular architecture, by including in the search
3833 loop names suffixed with the string identifying the architecture.
3835 For example, if your `ld' command line included `-ACA' as well as
3836 `-ltry', the linker would look (in its built-in search paths, and in
3837 any paths you specify with `-L') for a library with the names
3844 The first two possibilities would be considered in any event; the last
3845 two are due to the use of `-ACA'.
3847 You can meaningfully use `-A' more than once on a command line, since
3848 the 960 architecture family allows combination of target architectures;
3849 each use will add another pair of name variants to search for when `-l'
3850 specifies a library.
3852 `ld' supports the `--relax' option for the i960 family. If you
3853 specify `--relax', `ld' finds all `balx' and `calx' instructions whose
3854 targets are within 24 bits, and turns them into 24-bit program-counter
3855 relative `bal' and `cal' instructions, respectively. `ld' also turns
3856 `cal' instructions into `bal' instructions when it determines that the
3857 target subroutine is a leaf routine (that is, the target subroutine does
3858 not itself call any subroutines).
3861 File: ld.info, Node: ARM, Next: HPPA ELF32, Prev: i960, Up: Machine Dependent
3863 `ld''s Support for Interworking Between ARM and Thumb Code
3864 ==========================================================
3866 For the ARM, `ld' will generate code stubs to allow functions calls
3867 betweem ARM and Thumb code. These stubs only work with code that has
3868 been compiled and assembled with the `-mthumb-interwork' command line
3869 option. If it is necessary to link with old ARM object files or
3870 libraries, which have not been compiled with the -mthumb-interwork
3871 option then the `--support-old-code' command line switch should be
3872 given to the linker. This will make it generate larger stub functions
3873 which will work with non-interworking aware ARM code. Note, however,
3874 the linker does not support generating stubs for function calls to
3875 non-interworking aware Thumb code.
3877 The `--thumb-entry' switch is a duplicate of the generic `--entry'
3878 switch, in that it sets the program's starting address. But it also
3879 sets the bottom bit of the address, so that it can be branched to using
3880 a BX instruction, and the program will start executing in Thumb mode
3884 File: ld.info, Node: HPPA ELF32, Next: MMIX, Prev: ARM, Up: Machine Dependent
3886 `ld' and HPPA 32-bit ELF Support
3887 ================================
3889 When generating a shared library, `ld' will by default generate import
3890 stubs suitable for use with a single sub-space application. The
3891 `--multi-subspace' switch causes `ld' to generate export stubs, and
3892 different (larger) import stubs suitable for use with multiple
3895 Long branch stubs and import/export stubs are placed by `ld' in stub
3896 sections located between groups of input sections. `--stub-group-size'
3897 specifies the maximum size of a group of input sections handled by one
3898 stub section. Since branch offsets are signed, a stub section may
3899 serve two groups of input sections, one group before the stub section,
3900 and one group after it. However, when using conditional branches that
3901 require stubs, it may be better (for branch prediction) that stub
3902 sections only serve one group of input sections. A negative value for
3903 `N' chooses this scheme, ensuring that branches to stubs always use a
3904 negative offset. Two special values of `N' are recognized, `1' and
3905 `-1'. These both instruct `ld' to automatically size input section
3906 groups for the branch types detected, with the same behaviour regarding
3907 stub placement as other positive or negative values of `N' respectively.
3909 Note that `--stub-group-size' does not split input sections. A
3910 single input section larger than the group size specified will of course
3911 create a larger group (of one section). If input sections are too
3912 large, it may not be possible for a branch to reach its stub.
3915 File: ld.info, Node: MMIX, Next: MSP430, Prev: HPPA ELF32, Up: Machine Dependent
3920 For MMIX, there is a choice of generating `ELF' object files or `mmo'
3921 object files when linking. The simulator `mmix' understands the `mmo'
3922 format. The binutils `objcopy' utility can translate between the two
3925 There is one special section, the `.MMIX.reg_contents' section.
3926 Contents in this section is assumed to correspond to that of global
3927 registers, and symbols referring to it are translated to special
3928 symbols, equal to registers. In a final link, the start address of the
3929 `.MMIX.reg_contents' section corresponds to the first allocated global
3930 register multiplied by 8. Register `$255' is not included in this
3931 section; it is always set to the program entry, which is at the symbol
3932 `Main' for `mmo' files.
3934 Symbols with the prefix `__.MMIX.start.', for example
3935 `__.MMIX.start..text' and `__.MMIX.start..data' are special; there must
3936 be only one each, even if they are local. The default linker script
3937 uses these to set the default start address of a section.
3939 Initial and trailing multiples of zero-valued 32-bit words in a
3940 section, are left out from an mmo file.
3943 File: ld.info, Node: MSP430, Next: TI COFF, Prev: MMIX, Up: Machine Dependent
3948 For the MSP430 it is possible to select the MPU architecture. The flag
3949 `-m [mpu type]' will select an appropriate linker script for selected
3950 MPU type. (To get a list of known MPUs just pass `-m help' option to
3953 The linker will recognize some extra sections which are MSP430
3957 Defines a portion of ROM where interrupt vectors located.
3960 Defines the bootloader portion of the ROM (if applicable). Any
3961 code in this section will be uploaded to the MPU.
3964 Defines an information memory section (if applicable). Any code in
3965 this section will be uploaded to the MPU.
3968 This is the same as the `.infomem' section except that any code in
3969 this section will not be uploaded to the MPU.
3972 Denotes a portion of RAM located above `.bss' section.
3974 The last two sections are used by gcc.
3977 File: ld.info, Node: TI COFF, Next: WIN32, Prev: MSP430, Up: Machine Dependent
3979 `ld''s Support for Various TI COFF Versions
3980 ===========================================
3982 The `--format' switch allows selection of one of the various TI COFF
3983 versions. The latest of this writing is 2; versions 0 and 1 are also
3984 supported. The TI COFF versions also vary in header byte-order format;
3985 `ld' will read any version or byte order, but the output header format
3986 depends on the default specified by the specific target.
3989 File: ld.info, Node: WIN32, Next: Xtensa, Prev: TI COFF, Up: Machine Dependent
3991 `ld' and WIN32 (cygwin/mingw)
3992 =============================
3994 This section describes some of the win32 specific `ld' issues. See
3995 *Note Command Line Options: Options for detailed decription of the
3996 command line options mentioned here.
3999 The standard Windows linker creates and uses so-called import
4000 libraries, which contains information for linking to dll's. They
4001 are regular static archives and are handled as any other static
4002 archive. The cygwin and mingw ports of `ld' have specific support
4003 for creating such libraries provided with the `--out-implib'
4004 command line option.
4006 _exporting DLL symbols_
4007 The cygwin/mingw `ld' has several ways to export symbols for dll's.
4009 _using auto-export functionality_
4010 By default `ld' exports symbols with the auto-export
4011 functionality, which is controlled by the following command
4014 * -export-all-symbols [This is the default]
4020 If, however, `--export-all-symbols' is not given explicitly
4021 on the command line, then the default auto-export behavior
4022 will be _disabled_ if either of the following are true:
4024 * A DEF file is used.
4026 * Any symbol in any object file was marked with the
4027 __declspec(dllexport) attribute.
4030 Another way of exporting symbols is using a DEF file. A DEF
4031 file is an ASCII file containing definitions of symbols which
4032 should be exported when a dll is created. Usually it is
4033 named `<dll name>.def' and is added as any other object file
4034 to the linker's command line. The file's name must end in
4037 gcc -o <output> <objectfiles> <dll name>.def
4039 Using a DEF file turns off the normal auto-export behavior,
4040 unless the `--export-all-symbols' option is also used.
4042 Here is an example of a DEF file for a shared library called
4045 LIBRARY "xyz.dll" BASE=0x10000000
4052 This example defines a base address and three symbols. The
4053 third symbol is an alias for the second. For the complete
4054 format specification see ld/deffilep.y in the binutils
4057 While linking a shared dll, `ld' is able to create a DEF file
4058 with the `--output-def <file>' command line option.
4061 Another way of marking symbols for export is to modify the
4062 source code itself, so that when building the DLL each symbol
4063 to be exported is declared as:
4065 __declspec(dllexport) int a_variable
4066 __declspec(dllexport) void a_function(int with_args)
4068 All such symbols will be exported from the DLL. If, however,
4069 any of the object files in the DLL contain symbols decorated
4070 in this way, then the normal auto-export behavior is
4071 disabled, unless the `--export-all-symbols' option is also
4074 Note that object files that wish to access these symbols must
4075 _not_ decorate them with dllexport. Instead, they should use
4078 __declspec(dllimport) int a_variable
4079 __declspec(dllimport) void a_function(int with_args)
4081 This complicates the structure of library header files,
4082 because when included by the library itself the header must
4083 declare the variables and functions as dllexport, but when
4084 included by client code the header must declare them as
4085 dllimport. There are a number of idioms that are typically
4086 used to do this; often client code can omit the __declspec()
4087 declaration completely. See `--enable-auto-import' and
4088 `automatic data imports' for more imformation.
4090 _automatic data imports_
4091 The standard Windows dll format supports data imports from dlls
4092 only by adding special decorations (dllimport/dllexport), which
4093 let the compiler produce specific assembler instructions to deal
4094 with this issue. This increases the effort necessary to port
4095 existing Un*x code to these platforms, especially for large c++
4096 libraries and applications. The auto-import feature, which was
4097 initially provided by Paul Sokolovsky, allows one to omit the
4098 decorations to archieve a behavior that conforms to that on
4099 POSIX/Un*x platforms. This feature is enabled with the
4100 `--enable-auto-import' command-line option, although it is enabled
4101 by default on cygwin/mingw. The `--enable-auto-import' option
4102 itself now serves mainly to suppress any warnings that are
4103 ordinarily emitted when linked objects trigger the feature's use.
4105 auto-import of variables does not always work flawlessly without
4106 additional assistance. Sometimes, you will see this message
4108 "variable '<var>' can't be auto-imported. Please read the
4109 documentation for ld's `--enable-auto-import' for details."
4111 The `--enable-auto-import' documentation explains why this error
4112 occurs, and several methods that can be used to overcome this
4113 difficulty. One of these methods is the _runtime pseudo-relocs_
4114 feature, described below.
4116 For complex variables imported from DLLs (such as structs or
4117 classes), object files typically contain a base address for the
4118 variable and an offset (_addend_) within the variable-to specify a
4119 particular field or public member, for instance. Unfortunately,
4120 the runtime loader used in win32 environments is incapable of
4121 fixing these references at runtime without the additional
4122 information supplied by dllimport/dllexport decorations. The
4123 standard auto-import feature described above is unable to resolve
4126 The `--enable-runtime-pseudo-relocs' switch allows these
4127 references to be resolved without error, while leaving the task of
4128 adjusting the references themselves (with their non-zero addends)
4129 to specialized code provided by the runtime environment. Recent
4130 versions of the cygwin and mingw environments and compilers
4131 provide this runtime support; older versions do not. However, the
4132 support is only necessary on the developer's platform; the
4133 compiled result will run without error on an older system.
4135 `--enable-runtime-pseudo-relocs' is not the default; it must be
4136 explicitly enabled as needed.
4138 _direct linking to a dll_
4139 The cygwin/mingw ports of `ld' support the direct linking,
4140 including data symbols, to a dll without the usage of any import
4141 libraries. This is much faster and uses much less memory than
4142 does the traditional import library method, expecially when
4143 linking large libraries or applications. When `ld' creates an
4144 import lib, each function or variable exported from the dll is
4145 stored in its own bfd, even though a single bfd could contain many
4146 exports. The overhead involved in storing, loading, and
4147 processing so many bfd's is quite large, and explains the
4148 tremendous time, memory, and storage needed to link against
4149 particularly large or complex libraries when using import libs.
4151 Linking directly to a dll uses no extra command-line switches
4152 other than `-L' and `-l', because `ld' already searches for a
4153 number of names to match each library. All that is needed from
4154 the developer's perspective is an understanding of this search, in
4155 order to force ld to select the dll instead of an import library.
4157 For instance, when ld is called with the argument `-lxxx' it will
4158 attempt to find, in the first directory of its search path,
4167 before moving on to the next directory in the search path.
4169 (*) Actually, this is not `cygxxx.dll' but in fact is
4170 `<prefix>xxx.dll', where `<prefix>' is set by the `ld' option
4171 `--dll-search-prefix=<prefix>'. In the case of cygwin, the
4172 standard gcc spec file includes `--dll-search-prefix=cyg', so in
4173 effect we actually search for `cygxxx.dll'.
4175 Other win32-based unix environments, such as mingw or pw32, may
4176 use other `<prefix>'es, although at present only cygwin makes use
4177 of this feature. It was originally intended to help avoid name
4178 conflicts among dll's built for the various win32/un*x
4179 environments, so that (for example) two versions of a zlib dll
4180 could coexist on the same machine.
4182 The generic cygwin/mingw path layout uses a `bin' directory for
4183 applications and dll's and a `lib' directory for the import
4184 libraries (using cygwin nomenclature):
4189 libxxx.dll.a (in case of dll's)
4190 libxxx.a (in case of static archive)
4192 Linking directly to a dll without using the import library can be
4195 1. Use the dll directly by adding the `bin' path to the link line
4196 gcc -Wl,-verbose -o a.exe -L../bin/ -lxxx
4198 However, as the dll's often have version numbers appended to their
4199 names (`cygncurses-5.dll') this will often fail, unless one
4200 specifies `-L../bin -lncurses-5' to include the version. Import
4201 libs are generally not versioned, and do not have this difficulty.
4203 2. Create a symbolic link from the dll to a file in the `lib'
4204 directory according to the above mentioned search pattern. This
4205 should be used to avoid unwanted changes in the tools needed for
4208 ln -s bin/cygxxx.dll lib/[cyg|lib|]xxx.dll[.a]
4210 Then you can link without any make environment changes.
4212 gcc -Wl,-verbose -o a.exe -L../lib/ -lxxx
4214 This technique also avoids the version number problems, because
4215 the following is perfectly legal
4220 libxxx.dll.a -> ../bin/cygxxx-5.dll
4222 Linking directly to a dll without using an import lib will work
4223 even when auto-import features are exercised, and even when
4224 `--enable-runtime-pseudo-relocs' is used.
4226 Given the improvements in speed and memory usage, one might
4227 justifiably wonder why import libraries are used at all. There
4230 1. Until recently, the link-directly-to-dll functionality did _not_
4231 work with auto-imported data.
4233 2. Sometimes it is necessary to include pure static objects within
4234 the import library (which otherwise contains only bfd's for
4235 indirection symbols that point to the exports of a dll). Again,
4236 the import lib for the cygwin kernel makes use of this ability,
4237 and it is not possible to do this without an import lib.
4239 So, import libs are not going away. But the ability to replace
4240 true import libs with a simple symbolic link to (or a copy of) a
4241 dll, in most cases, is a useful addition to the suite of tools
4242 binutils makes available to the win32 developer. Given the
4243 massive improvements in memory requirements during linking, storage
4244 requirements, and linking speed, we expect that many developers
4245 will soon begin to use this feature whenever possible.
4249 _adding additional names_
4250 Sometimes, it is useful to export symbols with additional
4251 names. A symbol `foo' will be exported as `foo', but it can
4252 also be exported as `_foo' by using special directives in the
4253 DEF file when creating the dll. This will affect also the
4254 optional created import library. Consider the following DEF
4257 LIBRARY "xyz.dll" BASE=0x61000000
4263 The line `_foo = foo' maps the symbol `foo' to `_foo'.
4265 Another method for creating a symbol alias is to create it in
4266 the source code using the "weak" attribute:
4268 void foo () { /* Do something. */; }
4269 void _foo () __attribute__ ((weak, alias ("foo")));
4271 See the gcc manual for more information about attributes and
4275 Sometimes it is useful to rename exports. For instance, the
4276 cygwin kernel does this regularly. A symbol `_foo' can be
4277 exported as `foo' but not as `_foo' by using special
4278 directives in the DEF file. (This will also affect the import
4279 library, if it is created). In the following example:
4281 LIBRARY "xyz.dll" BASE=0x61000000
4286 The line `_foo = foo' maps the exported symbol `foo' to
4289 Note: using a DEF file disables the default auto-export behavior,
4290 unless the `--export-all-symbols' command line option is used.
4291 If, however, you are trying to rename symbols, then you should list
4292 _all_ desired exports in the DEF file, including the symbols that
4293 are not being renamed, and do _not_ use the `--export-all-symbols'
4294 option. If you list only the renamed symbols in the DEF file, and
4295 use `--export-all-symbols' to handle the other symbols, then the
4296 both the new names _and_ the original names for the renamed
4297 symbols will be exported. In effect, you'd be aliasing those
4298 symbols, not renaming them, which is probably not what you wanted.
4301 File: ld.info, Node: Xtensa, Prev: WIN32, Up: Machine Dependent
4303 `ld' and Xtensa Processors
4304 ==========================
4306 The default `ld' behavior for Xtensa processors is to interpret
4307 `SECTIONS' commands so that lists of explicitly named sections in a
4308 specification with a wildcard file will be interleaved when necessary to
4309 keep literal pools within the range of PC-relative load offsets. For
4310 example, with the command:
4319 `ld' may interleave some of the `.literal' and `.text' sections from
4320 different object files to ensure that the literal pools are within the
4321 range of PC-relative load offsets. A valid interleaving might place
4322 the `.literal' sections from an initial group of files followed by the
4323 `.text' sections of that group of files. Then, the `.literal' sections
4324 from the rest of the files and the `.text' sections from the rest of
4325 the files would follow. The non-interleaved order can still be
4331 *(.literal) *(.text)
4335 The Xtensa version of `ld' enables the `--relax' option by default
4336 to attempt to reduce space in the output image by combining literals
4337 with identical values. It also provides the `--no-relax' option to
4338 disable this optimization. When enabled, the relaxation algorithm
4339 ensures that a literal will only be merged with another literal when
4340 the new merged literal location is within the offset range of all of
4343 The relaxation mechanism will also attempt to optimize
4344 assembler-generated "longcall" sequences of `L32R'/`CALLXN' when the
4345 target is known to fit into a `CALLN' instruction encoding. The
4346 current optimization converts the sequence into `NOP'/`CALLN' and
4347 removes the literal referenced by the `L32R' instruction.
4350 File: ld.info, Node: BFD, Next: Reporting Bugs, Prev: Machine Dependent, Up: Top
4355 The linker accesses object and archive files using the BFD libraries.
4356 These libraries allow the linker to use the same routines to operate on
4357 object files whatever the object file format. A different object file
4358 format can be supported simply by creating a new BFD back end and adding
4359 it to the library. To conserve runtime memory, however, the linker and
4360 associated tools are usually configured to support only a subset of the
4361 object file formats available. You can use `objdump -i' (*note
4362 objdump: (binutils.info)objdump.) to list all the formats available for
4365 As with most implementations, BFD is a compromise between several
4366 conflicting requirements. The major factor influencing BFD design was
4367 efficiency: any time used converting between formats is time which
4368 would not have been spent had BFD not been involved. This is partly
4369 offset by abstraction payback; since BFD simplifies applications and
4370 back ends, more time and care may be spent optimizing algorithms for a
4373 One minor artifact of the BFD solution which you should bear in mind
4374 is the potential for information loss. There are two places where
4375 useful information can be lost using the BFD mechanism: during
4376 conversion and during output. *Note BFD information loss::.
4380 * BFD outline:: How it works: an outline of BFD
4383 File: ld.info, Node: BFD outline, Up: BFD
4385 How It Works: An Outline of BFD
4386 ===============================
4388 When an object file is opened, BFD subroutines automatically determine
4389 the format of the input object file. They then build a descriptor in
4390 memory with pointers to routines that will be used to access elements of
4391 the object file's data structures.
4393 As different information from the object files is required, BFD
4394 reads from different sections of the file and processes them. For
4395 example, a very common operation for the linker is processing symbol
4396 tables. Each BFD back end provides a routine for converting between
4397 the object file's representation of symbols and an internal canonical
4398 format. When the linker asks for the symbol table of an object file, it
4399 calls through a memory pointer to the routine from the relevant BFD
4400 back end which reads and converts the table into a canonical form. The
4401 linker then operates upon the canonical form. When the link is finished
4402 and the linker writes the output file's symbol table, another BFD back
4403 end routine is called to take the newly created symbol table and
4404 convert it into the chosen output format.
4408 * BFD information loss:: Information Loss
4409 * Canonical format:: The BFD canonical object-file format
4412 File: ld.info, Node: BFD information loss, Next: Canonical format, Up: BFD outline
4417 _Information can be lost during output._ The output formats supported
4418 by BFD do not provide identical facilities, and information which can
4419 be described in one form has nowhere to go in another format. One
4420 example of this is alignment information in `b.out'. There is nowhere
4421 in an `a.out' format file to store alignment information on the
4422 contained data, so when a file is linked from `b.out' and an `a.out'
4423 image is produced, alignment information will not propagate to the
4424 output file. (The linker will still use the alignment information
4425 internally, so the link is performed correctly).
4427 Another example is COFF section names. COFF files may contain an
4428 unlimited number of sections, each one with a textual section name. If
4429 the target of the link is a format which does not have many sections
4430 (e.g., `a.out') or has sections without names (e.g., the Oasys format),
4431 the link cannot be done simply. You can circumvent this problem by
4432 describing the desired input-to-output section mapping with the linker
4435 _Information can be lost during canonicalization._ The BFD internal
4436 canonical form of the external formats is not exhaustive; there are
4437 structures in input formats for which there is no direct representation
4438 internally. This means that the BFD back ends cannot maintain all
4439 possible data richness through the transformation between external to
4440 internal and back to external formats.
4442 This limitation is only a problem when an application reads one
4443 format and writes another. Each BFD back end is responsible for
4444 maintaining as much data as possible, and the internal BFD canonical
4445 form has structures which are opaque to the BFD core, and exported only
4446 to the back ends. When a file is read in one format, the canonical form
4447 is generated for BFD and the application. At the same time, the back
4448 end saves away any information which may otherwise be lost. If the data
4449 is then written back in the same format, the back end routine will be
4450 able to use the canonical form provided by the BFD core as well as the
4451 information it prepared earlier. Since there is a great deal of
4452 commonality between back ends, there is no information lost when
4453 linking or copying big endian COFF to little endian COFF, or `a.out' to
4454 `b.out'. When a mixture of formats is linked, the information is only
4455 lost from the files whose format differs from the destination.
4458 File: ld.info, Node: Canonical format, Prev: BFD information loss, Up: BFD outline
4460 The BFD canonical object-file format
4461 ------------------------------------
4463 The greatest potential for loss of information occurs when there is the
4464 least overlap between the information provided by the source format,
4465 that stored by the canonical format, and that needed by the destination
4466 format. A brief description of the canonical form may help you
4467 understand which kinds of data you can count on preserving across
4471 Information stored on a per-file basis includes target machine
4472 architecture, particular implementation format type, a demand
4473 pageable bit, and a write protected bit. Information like Unix
4474 magic numbers is not stored here--only the magic numbers' meaning,
4475 so a `ZMAGIC' file would have both the demand pageable bit and the
4476 write protected text bit set. The byte order of the target is
4477 stored on a per-file basis, so that big- and little-endian object
4478 files may be used with one another.
4481 Each section in the input file contains the name of the section,
4482 the section's original address in the object file, size and
4483 alignment information, various flags, and pointers into other BFD
4487 Each symbol contains a pointer to the information for the object
4488 file which originally defined it, its name, its value, and various
4489 flag bits. When a BFD back end reads in a symbol table, it
4490 relocates all symbols to make them relative to the base of the
4491 section where they were defined. Doing this ensures that each
4492 symbol points to its containing section. Each symbol also has a
4493 varying amount of hidden private data for the BFD back end. Since
4494 the symbol points to the original file, the private data format
4495 for that symbol is accessible. `ld' can operate on a collection
4496 of symbols of wildly different formats without problems.
4498 Normal global and simple local symbols are maintained on output,
4499 so an output file (no matter its format) will retain symbols
4500 pointing to functions and to global, static, and common variables.
4501 Some symbol information is not worth retaining; in `a.out', type
4502 information is stored in the symbol table as long symbol names.
4503 This information would be useless to most COFF debuggers; the
4504 linker has command line switches to allow users to throw it away.
4506 There is one word of type information within the symbol, so if the
4507 format supports symbol type information within symbols (for
4508 example, COFF, IEEE, Oasys) and the type is simple enough to fit
4509 within one word (nearly everything but aggregates), the
4510 information will be preserved.
4513 Each canonical BFD relocation record contains a pointer to the
4514 symbol to relocate to, the offset of the data to relocate, the
4515 section the data is in, and a pointer to a relocation type
4516 descriptor. Relocation is performed by passing messages through
4517 the relocation type descriptor and the symbol pointer. Therefore,
4518 relocations can be performed on output data using a relocation
4519 method that is only available in one of the input formats. For
4520 instance, Oasys provides a byte relocation format. A relocation
4521 record requesting this relocation type would point indirectly to a
4522 routine to perform this, so the relocation may be performed on a
4523 byte being written to a 68k COFF file, even though 68k COFF has no
4524 such relocation type.
4527 Object formats can contain, for debugging purposes, some form of
4528 mapping between symbols, source line numbers, and addresses in the
4529 output file. These addresses have to be relocated along with the
4530 symbol information. Each symbol with an associated list of line
4531 number records points to the first record of the list. The head
4532 of a line number list consists of a pointer to the symbol, which
4533 allows finding out the address of the function whose line number
4534 is being described. The rest of the list is made up of pairs:
4535 offsets into the section and line numbers. Any format which can
4536 simply derive this information can pass it successfully between
4537 formats (COFF, IEEE and Oasys).
4540 File: ld.info, Node: Reporting Bugs, Next: MRI, Prev: BFD, Up: Top
4545 Your bug reports play an essential role in making `ld' reliable.
4547 Reporting a bug may help you by bringing a solution to your problem,
4548 or it may not. But in any case the principal function of a bug report
4549 is to help the entire community by making the next version of `ld' work
4550 better. Bug reports are your contribution to the maintenance of `ld'.
4552 In order for a bug report to serve its purpose, you must include the
4553 information that enables us to fix the bug.
4557 * Bug Criteria:: Have you found a bug?
4558 * Bug Reporting:: How to report bugs
4561 File: ld.info, Node: Bug Criteria, Next: Bug Reporting, Up: Reporting Bugs
4563 Have You Found a Bug?
4564 =====================
4566 If you are not sure whether you have found a bug, here are some
4569 * If the linker gets a fatal signal, for any input whatever, that is
4570 a `ld' bug. Reliable linkers never crash.
4572 * If `ld' produces an error message for valid input, that is a bug.
4574 * If `ld' does not produce an error message for invalid input, that
4575 may be a bug. In the general case, the linker can not verify that
4576 object files are correct.
4578 * If you are an experienced user of linkers, your suggestions for
4579 improvement of `ld' are welcome in any case.
4582 File: ld.info, Node: Bug Reporting, Prev: Bug Criteria, Up: Reporting Bugs
4587 A number of companies and individuals offer support for GNU products.
4588 If you obtained `ld' from a support organization, we recommend you
4589 contact that organization first.
4591 You can find contact information for many support companies and
4592 individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
4594 Otherwise, send bug reports for `ld' to `bug-binutils@gnu.org'.
4596 The fundamental principle of reporting bugs usefully is this:
4597 *report all the facts*. If you are not sure whether to state a fact or
4598 leave it out, state it!
4600 Often people omit facts because they think they know what causes the
4601 problem and assume that some details do not matter. Thus, you might
4602 assume that the name of a symbol you use in an example does not matter.
4603 Well, probably it does not, but one cannot be sure. Perhaps the bug
4604 is a stray memory reference which happens to fetch from the location
4605 where that name is stored in memory; perhaps, if the name were
4606 different, the contents of that location would fool the linker into
4607 doing the right thing despite the bug. Play it safe and give a
4608 specific, complete example. That is the easiest thing for you to do,
4609 and the most helpful.
4611 Keep in mind that the purpose of a bug report is to enable us to fix
4612 the bug if it is new to us. Therefore, always write your bug reports
4613 on the assumption that the bug has not been reported previously.
4615 Sometimes people give a few sketchy facts and ask, "Does this ring a
4616 bell?" This cannot help us fix a bug, so it is basically useless. We
4617 respond by asking for enough details to enable us to investigate. You
4618 might as well expedite matters by sending them to begin with.
4620 To enable us to fix the bug, you should include all these things:
4622 * The version of `ld'. `ld' announces it if you start it with the
4623 `--version' argument.
4625 Without this, we will not know whether there is any point in
4626 looking for the bug in the current version of `ld'.
4628 * Any patches you may have applied to the `ld' source, including any
4629 patches made to the `BFD' library.
4631 * The type of machine you are using, and the operating system name
4634 * What compiler (and its version) was used to compile `ld'--e.g.
4637 * The command arguments you gave the linker to link your example and
4638 observe the bug. To guarantee you will not omit something
4639 important, list them all. A copy of the Makefile (or the output
4640 from make) is sufficient.
4642 If we were to try to guess the arguments, we would probably guess
4643 wrong and then we might not encounter the bug.
4645 * A complete input file, or set of input files, that will reproduce
4646 the bug. It is generally most helpful to send the actual object
4647 files provided that they are reasonably small. Say no more than
4648 10K. For bigger files you can either make them available by FTP
4649 or HTTP or else state that you are willing to send the object
4650 file(s) to whomever requests them. (Note - your email will be
4651 going to a mailing list, so we do not want to clog it up with
4652 large attachments). But small attachments are best.
4654 If the source files were assembled using `gas' or compiled using
4655 `gcc', then it may be OK to send the source files rather than the
4656 object files. In this case, be sure to say exactly what version of
4657 `gas' or `gcc' was used to produce the object files. Also say how
4658 `gas' or `gcc' were configured.
4660 * A description of what behavior you observe that you believe is
4661 incorrect. For example, "It gets a fatal signal."
4663 Of course, if the bug is that `ld' gets a fatal signal, then we
4664 will certainly notice it. But if the bug is incorrect output, we
4665 might not notice unless it is glaringly wrong. You might as well
4666 not give us a chance to make a mistake.
4668 Even if the problem you experience is a fatal signal, you should
4669 still say so explicitly. Suppose something strange is going on,
4670 such as, your copy of `ld' is out of synch, or you have
4671 encountered a bug in the C library on your system. (This has
4672 happened!) Your copy might crash and ours would not. If you told
4673 us to expect a crash, then when ours fails to crash, we would know
4674 that the bug was not happening for us. If you had not told us to
4675 expect a crash, then we would not be able to draw any conclusion
4676 from our observations.
4678 * If you wish to suggest changes to the `ld' source, send us context
4679 diffs, as generated by `diff' with the `-u', `-c', or `-p' option.
4680 Always send diffs from the old file to the new file. If you even
4681 discuss something in the `ld' source, refer to it by context, not
4684 The line numbers in our development sources will not match those
4685 in your sources. Your line numbers would convey no useful
4688 Here are some things that are not necessary:
4690 * A description of the envelope of the bug.
4692 Often people who encounter a bug spend a lot of time investigating
4693 which changes to the input file will make the bug go away and which
4694 changes will not affect it.
4696 This is often time consuming and not very useful, because the way
4697 we will find the bug is by running a single example under the
4698 debugger with breakpoints, not by pure deduction from a series of
4699 examples. We recommend that you save your time for something else.
4701 Of course, if you can find a simpler example to report _instead_
4702 of the original one, that is a convenience for us. Errors in the
4703 output will be easier to spot, running under the debugger will take
4704 less time, and so on.
4706 However, simplification is not vital; if you do not want to do
4707 this, report the bug anyway and send us the entire test case you
4710 * A patch for the bug.
4712 A patch for the bug does help us if it is a good one. But do not
4713 omit the necessary information, such as the test case, on the
4714 assumption that a patch is all we need. We might see problems
4715 with your patch and decide to fix the problem another way, or we
4716 might not understand it at all.
4718 Sometimes with a program as complicated as `ld' it is very hard to
4719 construct an example that will make the program follow a certain
4720 path through the code. If you do not send us the example, we will
4721 not be able to construct one, so we will not be able to verify
4722 that the bug is fixed.
4724 And if we cannot understand what bug you are trying to fix, or why
4725 your patch should be an improvement, we will not install it. A
4726 test case will help us to understand.
4728 * A guess about what the bug is or what it depends on.
4730 Such guesses are usually wrong. Even we cannot guess right about
4731 such things without first using the debugger to find the facts.
4734 File: ld.info, Node: MRI, Next: GNU Free Documentation License, Prev: Reporting Bugs, Up: Top
4736 MRI Compatible Script Files
4737 ***************************
4739 To aid users making the transition to GNU `ld' from the MRI linker,
4740 `ld' can use MRI compatible linker scripts as an alternative to the
4741 more general-purpose linker scripting language described in *Note
4742 Scripts::. MRI compatible linker scripts have a much simpler command
4743 set than the scripting language otherwise used with `ld'. GNU `ld'
4744 supports the most commonly used MRI linker commands; these commands are
4747 In general, MRI scripts aren't of much use with the `a.out' object
4748 file format, since it only has three sections and MRI scripts lack some
4749 features to make use of them.
4751 You can specify a file containing an MRI-compatible script using the
4752 `-c' command-line option.
4754 Each command in an MRI-compatible script occupies its own line; each
4755 command line starts with the keyword that identifies the command (though
4756 blank lines are also allowed for punctuation). If a line of an
4757 MRI-compatible script begins with an unrecognized keyword, `ld' issues
4758 a warning message, but continues processing the script.
4760 Lines beginning with `*' are comments.
4762 You can write these commands using all upper-case letters, or all
4763 lower case; for example, `chip' is the same as `CHIP'. The following
4764 list shows only the upper-case form of each command.
4767 `ABSOLUTE SECNAME, SECNAME, ... SECNAME'
4768 Normally, `ld' includes in the output file all sections from all
4769 the input files. However, in an MRI-compatible script, you can
4770 use the `ABSOLUTE' command to restrict the sections that will be
4771 present in your output program. If the `ABSOLUTE' command is used
4772 at all in a script, then only the sections named explicitly in
4773 `ABSOLUTE' commands will appear in the linker output. You can
4774 still use other input sections (whatever you select on the command
4775 line, or using `LOAD') to resolve addresses in the output file.
4777 `ALIAS OUT-SECNAME, IN-SECNAME'
4778 Use this command to place the data from input section IN-SECNAME
4779 in a section called OUT-SECNAME in the linker output file.
4781 IN-SECNAME may be an integer.
4783 `ALIGN SECNAME = EXPRESSION'
4784 Align the section called SECNAME to EXPRESSION. The EXPRESSION
4785 should be a power of two.
4788 Use the value of EXPRESSION as the lowest address (other than
4789 absolute addresses) in the output file.
4792 `CHIP EXPRESSION, EXPRESSION'
4793 This command does nothing; it is accepted only for compatibility.
4796 This command does nothing whatever; it's only accepted for
4799 `FORMAT OUTPUT-FORMAT'
4800 Similar to the `OUTPUT_FORMAT' command in the more general linker
4801 language, but restricted to one of these output formats:
4803 1. S-records, if OUTPUT-FORMAT is `S'
4805 2. IEEE, if OUTPUT-FORMAT is `IEEE'
4807 3. COFF (the `coff-m68k' variant in BFD), if OUTPUT-FORMAT is
4811 Print (to the standard output file) a link map, as produced by the
4812 `ld' command-line option `-M'.
4814 The keyword `LIST' may be followed by anything on the same line,
4815 with no change in its effect.
4818 `LOAD FILENAME, FILENAME, ... FILENAME'
4819 Include one or more object file FILENAME in the link; this has the
4820 same effect as specifying FILENAME directly on the `ld' command
4824 OUTPUT-NAME is the name for the program produced by `ld'; the
4825 MRI-compatible command `NAME' is equivalent to the command-line
4826 option `-o' or the general script language command `OUTPUT'.
4828 `ORDER SECNAME, SECNAME, ... SECNAME'
4829 `ORDER SECNAME SECNAME SECNAME'
4830 Normally, `ld' orders the sections in its output file in the order
4831 in which they first appear in the input files. In an
4832 MRI-compatible script, you can override this ordering with the
4833 `ORDER' command. The sections you list with `ORDER' will appear
4834 first in your output file, in the order specified.
4836 `PUBLIC NAME=EXPRESSION'
4837 `PUBLIC NAME,EXPRESSION'
4838 `PUBLIC NAME EXPRESSION'
4839 Supply a value (EXPRESSION) for external symbol NAME used in the
4842 `SECT SECNAME, EXPRESSION'
4843 `SECT SECNAME=EXPRESSION'
4844 `SECT SECNAME EXPRESSION'
4845 You can use any of these three forms of the `SECT' command to
4846 specify the start address (EXPRESSION) for section SECNAME. If
4847 you have more than one `SECT' statement for the same SECNAME, only
4848 the _first_ sets the start address.
4851 File: ld.info, Node: GNU Free Documentation License, Next: Index, Prev: MRI, Up: Top
4853 GNU Free Documentation License
4854 ******************************
4856 Version 1.1, March 2000
4857 Copyright (C) 2000, Free Software Foundation, Inc.
4858 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4860 Everyone is permitted to copy and distribute verbatim copies
4861 of this license document, but changing it is not allowed.
4866 The purpose of this License is to make a manual, textbook, or other
4867 written document "free" in the sense of freedom: to assure everyone
4868 the effective freedom to copy and redistribute it, with or without
4869 modifying it, either commercially or noncommercially. Secondarily,
4870 this License preserves for the author and publisher a way to get
4871 credit for their work, while not being considered responsible for
4872 modifications made by others.
4874 This License is a kind of "copyleft", which means that derivative
4875 works of the document must themselves be free in the same sense.
4876 It complements the GNU General Public License, which is a copyleft
4877 license designed for free software.
4879 We have designed this License in order to use it for manuals for
4880 free software, because free software needs free documentation: a
4881 free program should come with manuals providing the same freedoms
4882 that the software does. But this License is not limited to
4883 software manuals; it can be used for any textual work, regardless
4884 of subject matter or whether it is published as a printed book.
4885 We recommend this License principally for works whose purpose is
4886 instruction or reference.
4889 1. APPLICABILITY AND DEFINITIONS
4891 This License applies to any manual or other work that contains a
4892 notice placed by the copyright holder saying it can be distributed
4893 under the terms of this License. The "Document", below, refers to
4894 any such manual or work. Any member of the public is a licensee,
4895 and is addressed as "you."
4897 A "Modified Version" of the Document means any work containing the
4898 Document or a portion of it, either copied verbatim, or with
4899 modifications and/or translated into another language.
4901 A "Secondary Section" is a named appendix or a front-matter
4902 section of the Document that deals exclusively with the
4903 relationship of the publishers or authors of the Document to the
4904 Document's overall subject (or to related matters) and contains
4905 nothing that could fall directly within that overall subject.
4906 (For example, if the Document is in part a textbook of
4907 mathematics, a Secondary Section may not explain any mathematics.)
4908 The relationship could be a matter of historical connection with
4909 the subject or with related matters, or of legal, commercial,
4910 philosophical, ethical or political position regarding them.
4912 The "Invariant Sections" are certain Secondary Sections whose
4913 titles are designated, as being those of Invariant Sections, in
4914 the notice that says that the Document is released under this
4917 The "Cover Texts" are certain short passages of text that are
4918 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4919 that says that the Document is released under this License.
4921 A "Transparent" copy of the Document means a machine-readable copy,
4922 represented in a format whose specification is available to the
4923 general public, whose contents can be viewed and edited directly
4924 and straightforwardly with generic text editors or (for images
4925 composed of pixels) generic paint programs or (for drawings) some
4926 widely available drawing editor, and that is suitable for input to
4927 text formatters or for automatic translation to a variety of
4928 formats suitable for input to text formatters. A copy made in an
4929 otherwise Transparent file format whose markup has been designed
4930 to thwart or discourage subsequent modification by readers is not
4931 Transparent. A copy that is not "Transparent" is called "Opaque."
4933 Examples of suitable formats for Transparent copies include plain
4934 ASCII without markup, Texinfo input format, LaTeX input format,
4935 SGML or XML using a publicly available DTD, and
4936 standard-conforming simple HTML designed for human modification.
4937 Opaque formats include PostScript, PDF, proprietary formats that
4938 can be read and edited only by proprietary word processors, SGML
4939 or XML for which the DTD and/or processing tools are not generally
4940 available, and the machine-generated HTML produced by some word
4941 processors for output purposes only.
4943 The "Title Page" means, for a printed book, the title page itself,
4944 plus such following pages as are needed to hold, legibly, the
4945 material this License requires to appear in the title page. For
4946 works in formats which do not have any title page as such, "Title
4947 Page" means the text near the most prominent appearance of the
4948 work's title, preceding the beginning of the body of the text.
4952 You may copy and distribute the Document in any medium, either
4953 commercially or noncommercially, provided that this License, the
4954 copyright notices, and the license notice saying this License
4955 applies to the Document are reproduced in all copies, and that you
4956 add no other conditions whatsoever to those of this License. You
4957 may not use technical measures to obstruct or control the reading
4958 or further copying of the copies you make or distribute. However,
4959 you may accept compensation in exchange for copies. If you
4960 distribute a large enough number of copies you must also follow
4961 the conditions in section 3.
4963 You may also lend copies, under the same conditions stated above,
4964 and you may publicly display copies.
4966 3. COPYING IN QUANTITY
4968 If you publish printed copies of the Document numbering more than
4969 100, and the Document's license notice requires Cover Texts, you
4970 must enclose the copies in covers that carry, clearly and legibly,
4971 all these Cover Texts: Front-Cover Texts on the front cover, and
4972 Back-Cover Texts on the back cover. Both covers must also clearly
4973 and legibly identify you as the publisher of these copies. The
4974 front cover must present the full title with all words of the
4975 title equally prominent and visible. You may add other material
4976 on the covers in addition. Copying with changes limited to the
4977 covers, as long as they preserve the title of the Document and
4978 satisfy these conditions, can be treated as verbatim copying in
4981 If the required texts for either cover are too voluminous to fit
4982 legibly, you should put the first ones listed (as many as fit
4983 reasonably) on the actual cover, and continue the rest onto
4986 If you publish or distribute Opaque copies of the Document
4987 numbering more than 100, you must either include a
4988 machine-readable Transparent copy along with each Opaque copy, or
4989 state in or with each Opaque copy a publicly-accessible
4990 computer-network location containing a complete Transparent copy
4991 of the Document, free of added material, which the general
4992 network-using public has access to download anonymously at no
4993 charge using public-standard network protocols. If you use the
4994 latter option, you must take reasonably prudent steps, when you
4995 begin distribution of Opaque copies in quantity, to ensure that
4996 this Transparent copy will remain thus accessible at the stated
4997 location until at least one year after the last time you
4998 distribute an Opaque copy (directly or through your agents or
4999 retailers) of that edition to the public.
5001 It is requested, but not required, that you contact the authors of
5002 the Document well before redistributing any large number of
5003 copies, to give them a chance to provide you with an updated
5004 version of the Document.
5008 You may copy and distribute a Modified Version of the Document
5009 under the conditions of sections 2 and 3 above, provided that you
5010 release the Modified Version under precisely this License, with
5011 the Modified Version filling the role of the Document, thus
5012 licensing distribution and modification of the Modified Version to
5013 whoever possesses a copy of it. In addition, you must do these
5014 things in the Modified Version:
5016 A. Use in the Title Page (and on the covers, if any) a title
5017 distinct from that of the Document, and from those of previous
5018 versions (which should, if there were any, be listed in the
5019 History section of the Document). You may use the same title
5020 as a previous version if the original publisher of that version
5022 B. List on the Title Page, as authors, one or more persons or
5023 entities responsible for authorship of the modifications in the
5024 Modified Version, together with at least five of the principal
5025 authors of the Document (all of its principal authors, if it
5026 has less than five).
5027 C. State on the Title page the name of the publisher of the
5028 Modified Version, as the publisher.
5029 D. Preserve all the copyright notices of the Document.
5030 E. Add an appropriate copyright notice for your modifications
5031 adjacent to the other copyright notices.
5032 F. Include, immediately after the copyright notices, a license
5033 notice giving the public permission to use the Modified Version
5034 under the terms of this License, in the form shown in the
5036 G. Preserve in that license notice the full lists of Invariant
5037 Sections and required Cover Texts given in the Document's
5039 H. Include an unaltered copy of this License.
5040 I. Preserve the section entitled "History", and its title, and add
5041 to it an item stating at least the title, year, new authors, and
5042 publisher of the Modified Version as given on the Title Page.
5043 If there is no section entitled "History" in the Document,
5044 create one stating the title, year, authors, and publisher of
5045 the Document as given on its Title Page, then add an item
5046 describing the Modified Version as stated in the previous
5048 J. Preserve the network location, if any, given in the Document for
5049 public access to a Transparent copy of the Document, and
5050 likewise the network locations given in the Document for
5051 previous versions it was based on. These may be placed in the
5052 "History" section. You may omit a network location for a work
5053 that was published at least four years before the Document
5054 itself, or if the original publisher of the version it refers
5055 to gives permission.
5056 K. In any section entitled "Acknowledgements" or "Dedications",
5057 preserve the section's title, and preserve in the section all the
5058 substance and tone of each of the contributor acknowledgements
5059 and/or dedications given therein.
5060 L. Preserve all the Invariant Sections of the Document,
5061 unaltered in their text and in their titles. Section numbers
5062 or the equivalent are not considered part of the section titles.
5063 M. Delete any section entitled "Endorsements." Such a section
5064 may not be included in the Modified Version.
5065 N. Do not retitle any existing section as "Endorsements" or to
5066 conflict in title with any Invariant Section.
5068 If the Modified Version includes new front-matter sections or
5069 appendices that qualify as Secondary Sections and contain no
5070 material copied from the Document, you may at your option
5071 designate some or all of these sections as invariant. To do this,
5072 add their titles to the list of Invariant Sections in the Modified
5073 Version's license notice. These titles must be distinct from any
5074 other section titles.
5076 You may add a section entitled "Endorsements", provided it contains
5077 nothing but endorsements of your Modified Version by various
5078 parties-for example, statements of peer review or that the text has
5079 been approved by an organization as the authoritative definition
5082 You may add a passage of up to five words as a Front-Cover Text,
5083 and a passage of up to 25 words as a Back-Cover Text, to the end
5084 of the list of Cover Texts in the Modified Version. Only one
5085 passage of Front-Cover Text and one of Back-Cover Text may be
5086 added by (or through arrangements made by) any one entity. If the
5087 Document already includes a cover text for the same cover,
5088 previously added by you or by arrangement made by the same entity
5089 you are acting on behalf of, you may not add another; but you may
5090 replace the old one, on explicit permission from the previous
5091 publisher that added the old one.
5093 The author(s) and publisher(s) of the Document do not by this
5094 License give permission to use their names for publicity for or to
5095 assert or imply endorsement of any Modified Version.
5097 5. COMBINING DOCUMENTS
5099 You may combine the Document with other documents released under
5100 this License, under the terms defined in section 4 above for
5101 modified versions, provided that you include in the combination
5102 all of the Invariant Sections of all of the original documents,
5103 unmodified, and list them all as Invariant Sections of your
5104 combined work in its license notice.
5106 The combined work need only contain one copy of this License, and
5107 multiple identical Invariant Sections may be replaced with a single
5108 copy. If there are multiple Invariant Sections with the same name
5109 but different contents, make the title of each such section unique
5110 by adding at the end of it, in parentheses, the name of the
5111 original author or publisher of that section if known, or else a
5112 unique number. Make the same adjustment to the section titles in
5113 the list of Invariant Sections in the license notice of the
5116 In the combination, you must combine any sections entitled
5117 "History" in the various original documents, forming one section
5118 entitled "History"; likewise combine any sections entitled
5119 "Acknowledgements", and any sections entitled "Dedications." You
5120 must delete all sections entitled "Endorsements."
5122 6. COLLECTIONS OF DOCUMENTS
5124 You may make a collection consisting of the Document and other
5125 documents released under this License, and replace the individual
5126 copies of this License in the various documents with a single copy
5127 that is included in the collection, provided that you follow the
5128 rules of this License for verbatim copying of each of the
5129 documents in all other respects.
5131 You may extract a single document from such a collection, and
5132 distribute it individually under this License, provided you insert
5133 a copy of this License into the extracted document, and follow
5134 this License in all other respects regarding verbatim copying of
5137 7. AGGREGATION WITH INDEPENDENT WORKS
5139 A compilation of the Document or its derivatives with other
5140 separate and independent documents or works, in or on a volume of
5141 a storage or distribution medium, does not as a whole count as a
5142 Modified Version of the Document, provided no compilation
5143 copyright is claimed for the compilation. Such a compilation is
5144 called an "aggregate", and this License does not apply to the
5145 other self-contained works thus compiled with the Document, on
5146 account of their being thus compiled, if they are not themselves
5147 derivative works of the Document.
5149 If the Cover Text requirement of section 3 is applicable to these
5150 copies of the Document, then if the Document is less than one
5151 quarter of the entire aggregate, the Document's Cover Texts may be
5152 placed on covers that surround only the Document within the
5153 aggregate. Otherwise they must appear on covers around the whole
5158 Translation is considered a kind of modification, so you may
5159 distribute translations of the Document under the terms of section
5160 4. Replacing Invariant Sections with translations requires special
5161 permission from their copyright holders, but you may include
5162 translations of some or all Invariant Sections in addition to the
5163 original versions of these Invariant Sections. You may include a
5164 translation of this License provided that you also include the
5165 original English version of this License. In case of a
5166 disagreement between the translation and the original English
5167 version of this License, the original English version will prevail.
5171 You may not copy, modify, sublicense, or distribute the Document
5172 except as expressly provided for under this License. Any other
5173 attempt to copy, modify, sublicense or distribute the Document is
5174 void, and will automatically terminate your rights under this
5175 License. However, parties who have received copies, or rights,
5176 from you under this License will not have their licenses
5177 terminated so long as such parties remain in full compliance.
5179 10. FUTURE REVISIONS OF THIS LICENSE
5181 The Free Software Foundation may publish new, revised versions of
5182 the GNU Free Documentation License from time to time. Such new
5183 versions will be similar in spirit to the present version, but may
5184 differ in detail to address new problems or concerns. See
5185 http://www.gnu.org/copyleft/.
5187 Each version of the License is given a distinguishing version
5188 number. If the Document specifies that a particular numbered
5189 version of this License "or any later version" applies to it, you
5190 have the option of following the terms and conditions either of
5191 that specified version or of any later version that has been
5192 published (not as a draft) by the Free Software Foundation. If
5193 the Document does not specify a version number of this License,
5194 you may choose any version ever published (not as a draft) by the
5195 Free Software Foundation.
5198 ADDENDUM: How to use this License for your documents
5199 ====================================================
5201 To use this License in a document you have written, include a copy of
5202 the License in the document and put the following copyright and license
5203 notices just after the title page:
5205 Copyright (C) YEAR YOUR NAME.
5206 Permission is granted to copy, distribute and/or modify this document
5207 under the terms of the GNU Free Documentation License, Version 1.1
5208 or any later version published by the Free Software Foundation;
5209 with the Invariant Sections being LIST THEIR TITLES, with the
5210 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
5211 A copy of the license is included in the section entitled "GNU
5212 Free Documentation License."
5214 If you have no Invariant Sections, write "with no Invariant Sections"
5215 instead of saying which ones are invariant. If you have no Front-Cover
5216 Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
5217 LIST"; likewise for Back-Cover Texts.
5219 If your document contains nontrivial examples of program code, we
5220 recommend releasing these examples in parallel under your choice of
5221 free software license, such as the GNU General Public License, to
5222 permit their use in free software.
5225 File: ld.info, Node: Index, Prev: GNU Free Documentation License, Up: Top
5234 * --accept-unknown-input-arch: Options.
5235 * --add-stdcall-alias: Options.
5236 * --allow-multiple-definition: Options.
5237 * --allow-shlib-undefined: Options.
5238 * --architecture=ARCH: Options.
5239 * --as-needed: Options.
5240 * --auxiliary: Options.
5241 * --base-file: Options.
5242 * --check-sections: Options.
5244 * --defsym SYMBOL=EXP: Options.
5245 * --demangle[=STYLE]: Options.
5246 * --disable-auto-image-base: Options.
5247 * --disable-auto-import: Options.
5248 * --disable-new-dtags: Options.
5249 * --disable-runtime-pseudo-reloc: Options.
5250 * --disable-stdcall-fixup: Options.
5251 * --discard-all: Options.
5252 * --discard-locals: Options.
5254 * --dll-search-prefix: Options.
5255 * --dynamic-linker FILE: Options.
5256 * --embedded-relocs: Options.
5257 * --emit-relocs: Options.
5258 * --enable-auto-image-base: Options.
5259 * --enable-auto-import: Options.
5260 * --enable-extra-pe-debug: Options.
5261 * --enable-new-dtags: Options.
5262 * --enable-runtime-pseudo-reloc: Options.
5263 * --enable-stdcall-fixup: Options.
5264 * --entry=ENTRY: Options.
5265 * --error-unresolved-symbols: Options.
5266 * --exclude-libs: Options.
5267 * --exclude-symbols: Options.
5268 * --export-all-symbols: Options.
5269 * --export-dynamic: Options.
5270 * --fatal-warnings: Options.
5271 * --file-alignment: Options.
5272 * --filter: Options.
5273 * --force-exe-suffix: Options.
5274 * --format=FORMAT: Options.
5275 * --format=VERSION: TI COFF.
5276 * --gc-sections: Options.
5277 * --gpsize: Options.
5280 * --image-base: Options.
5281 * --just-symbols=FILE: Options.
5282 * --kill-at: Options.
5283 * --library-path=DIR: Options.
5284 * --library=ARCHIVE: Options.
5285 * --major-image-version: Options.
5286 * --major-os-version: Options.
5287 * --major-subsystem-version: Options.
5288 * --minor-image-version: Options.
5289 * --minor-os-version: Options.
5290 * --minor-subsystem-version: Options.
5291 * --mri-script=MRI-CMDFILE: Options.
5292 * --multi-subspace: HPPA ELF32.
5293 * --nmagic: Options.
5294 * --no-accept-unknown-input-arch: Options.
5295 * --no-allow-shlib-undefined: Options.
5296 * --no-as-needed: Options.
5297 * --no-check-sections: Options.
5298 * --no-define-common: Options.
5299 * --no-demangle: Options.
5300 * --no-gc-sections: Options.
5301 * --no-keep-memory: Options.
5302 * --no-omagic: Options.
5303 * --no-relax: Xtensa.
5304 * --no-undefined: Options.
5305 * --no-undefined-version: Options.
5306 * --no-warn-mismatch: Options.
5307 * --no-whole-archive: Options.
5308 * --noinhibit-exec: Options.
5309 * --oformat: Options.
5310 * --omagic: Options.
5311 * --out-implib: Options.
5312 * --output-def: Options.
5313 * --output=OUTPUT: Options.
5314 * --pic-executable: Options.
5315 * --print-map: Options.
5317 * --relax on i960: i960.
5318 * --relax on Xtensa: Xtensa.
5319 * --relocatable: Options.
5320 * --script=SCRIPT: Options.
5321 * --section-alignment: Options.
5322 * --section-start SECTIONNAME=ORG: Options.
5323 * --sort-common: Options.
5324 * --split-by-file: Options.
5325 * --split-by-reloc: Options.
5328 * --strip-all: Options.
5329 * --strip-debug: Options.
5330 * --stub-group-size=N: HPPA ELF32.
5331 * --subsystem: Options.
5332 * --support-old-code: ARM.
5333 * --target-help: Options.
5334 * --thumb-entry=ENTRY: ARM.
5336 * --trace-symbol=SYMBOL: Options.
5337 * --traditional-format: Options.
5338 * --undefined=SYMBOL: Options.
5339 * --unique[=SECTION]: Options.
5340 * --unresolved-symbols: Options.
5341 * --verbose: Options.
5342 * --version: Options.
5343 * --version-script=VERSION-SCRIPTFILE: Options.
5344 * --warn-common: Options.
5345 * --warn-constructors: Options.
5346 * --warn-multiple-gp: Options.
5347 * --warn-once: Options.
5348 * --warn-section-align: Options.
5349 * --warn-unresolved-symbols: Options.
5350 * --whole-archive: Options.
5353 * -aKEYWORD: Options.
5354 * -assert KEYWORD: Options.
5355 * -b FORMAT: Options.
5356 * -Bdynamic: Options.
5358 * -Bshareable: Options.
5359 * -Bstatic: Options.
5360 * -Bsymbolic: Options.
5361 * -c MRI-CMDFILE: Options.
5362 * -call_shared: Options.
5369 * -e ENTRY: Options.
5381 * -lARCHIVE: Options.
5384 * -m EMULATION: Options.
5388 * -non_shared: Options.
5389 * -nostdlib: Options.
5390 * -O LEVEL: Options.
5391 * -o OUTPUT: Options.
5399 * -rpath-link: Options.
5403 * -soname=NAME: Options.
5406 * -T SCRIPT: Options.
5407 * -Tbss ORG: Options.
5408 * -Tdata ORG: Options.
5409 * -Ttext ORG: Options.
5410 * -u SYMBOL: Options.
5417 * -y SYMBOL: Options.
5419 * -z KEYWORD: Options.
5420 * -z muldefs: Options.
5421 * .: Location Counter.
5422 * /DISCARD/: Output Section Discarding.
5423 * :PHDR: Output Section Phdr.
5424 * =FILLEXP: Output Section Fill.
5425 * >REGION: Output Section Region.
5426 * [COMMON]: Input Section Common.
5427 * ABSOLUTE (MRI): MRI.
5428 * absolute and relocatable symbols: Expression Section.
5429 * absolute expressions: Expression Section.
5430 * ABSOLUTE(EXP): Builtin Functions.
5431 * ADDR(SECTION): Builtin Functions.
5432 * address, section: Output Section Address.
5435 * align expression: Builtin Functions.
5436 * align location counter: Builtin Functions.
5437 * ALIGN(ALIGN): Builtin Functions.
5438 * ALIGN(EXP,ALIGN): Builtin Functions.
5439 * allocating memory: MEMORY.
5440 * architecture: Miscellaneous Commands.
5441 * architectures: Options.
5442 * archive files, from cmd line: Options.
5443 * archive search path in linker script: File Commands.
5444 * arithmetic: Expressions.
5445 * arithmetic operators: Operators.
5446 * ARM interworking support: ARM.
5447 * ASSERT: Miscellaneous Commands.
5448 * assertion in linker script: Miscellaneous Commands.
5449 * assignment in scripts: Assignments.
5450 * AT(LMA): Output Section LMA.
5451 * AT>LMA_REGION: Output Section LMA.
5452 * automatic data imports: WIN32.
5455 * BFD canonical format: Canonical format.
5456 * BFD requirements: BFD.
5457 * big-endian objects: Options.
5458 * binary input format: Options.
5459 * BLOCK(EXP): Builtin Functions.
5460 * bug criteria: Bug Criteria.
5461 * bug reports: Bug Reporting.
5462 * bugs in ld: Reporting Bugs.
5463 * BYTE(EXPRESSION): Output Section Data.
5464 * C++ constructors, arranging in link: Output Section Keywords.
5466 * COLLECT_NO_DEMANGLE: Environment.
5467 * combining symbols, warnings on: Options.
5468 * command files: Scripts.
5469 * command line: Options.
5470 * common allocation: Options.
5471 * common allocation in linker script: Miscellaneous Commands.
5472 * common symbol placement: Input Section Common.
5473 * compatibility, MRI: Options.
5474 * constants in linker scripts: Constants.
5475 * CONSTRUCTORS: Output Section Keywords.
5476 * constructors: Options.
5477 * constructors, arranging in link: Output Section Keywords.
5478 * crash of linker: Bug Criteria.
5479 * CREATE_OBJECT_SYMBOLS: Output Section Keywords.
5480 * creating a DEF file: WIN32.
5481 * cross reference table: Options.
5482 * cross references: Miscellaneous Commands.
5483 * current output location: Location Counter.
5484 * data: Output Section Data.
5485 * DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE): Builtin Functions.
5486 * DATA_SEGMENT_END(EXP): Builtin Functions.
5488 * DEF files, creating: Options.
5489 * default emulation: Environment.
5490 * default input format: Environment.
5491 * DEFINED(SYMBOL): Builtin Functions.
5492 * deleting local symbols: Options.
5493 * demangling, default: Environment.
5494 * demangling, from command line: Options.
5495 * direct linking to a dll: WIN32.
5496 * discarding sections: Output Section Discarding.
5497 * discontinuous memory: MEMORY.
5498 * DLLs, creating: Options.
5499 * DLLs, linking to: Options.
5500 * dot: Location Counter.
5501 * dot inside sections: Location Counter.
5502 * dynamic linker, from command line: Options.
5503 * dynamic symbol table: Options.
5504 * ELF program headers: PHDRS.
5505 * emulation: Options.
5506 * emulation, default: Environment.
5508 * endianness: Options.
5509 * entry point: Entry Point.
5510 * entry point, from command line: Options.
5511 * entry point, thumb: ARM.
5512 * ENTRY(SYMBOL): Entry Point.
5513 * error on valid input: Bug Criteria.
5514 * example of linker script: Simple Example.
5515 * exporting DLL symbols: WIN32.
5516 * expression evaluation order: Evaluation.
5517 * expression sections: Expression Section.
5518 * expression, absolute: Builtin Functions.
5519 * expressions: Expressions.
5520 * EXTERN: Miscellaneous Commands.
5521 * fatal signal: Bug Criteria.
5522 * file name wildcard patterns: Input Section Wildcards.
5524 * filename symbols: Output Section Keywords.
5525 * fill pattern, entire section: Output Section Fill.
5526 * FILL(EXPRESSION): Output Section Data.
5527 * finalization function: Options.
5528 * first input file: File Commands.
5529 * first instruction: Entry Point.
5530 * FORCE_COMMON_ALLOCATION: Miscellaneous Commands.
5531 * forcing input section alignment: Forced Input Alignment.
5532 * FORMAT (MRI): MRI.
5533 * functions in expressions: Builtin Functions.
5534 * garbage collection <1>: Input Section Keep.
5535 * garbage collection: Options.
5536 * generating optimized output: Options.
5537 * GNU linker: Overview.
5538 * GNUTARGET: Environment.
5539 * GROUP(FILES): File Commands.
5540 * grouping input files: File Commands.
5541 * groups of archives: Options.
5542 * H8/300 support: H8/300.
5543 * header size: Builtin Functions.
5544 * heap size: Options.
5546 * holes: Location Counter.
5547 * holes, filling: Output Section Data.
5548 * HPPA multiple sub-space stubs: HPPA ELF32.
5549 * HPPA stub grouping: HPPA ELF32.
5550 * i960 support: i960.
5551 * image base: Options.
5552 * implicit linker scripts: Implicit Linker Scripts.
5553 * import libraries: WIN32.
5554 * INCLUDE FILENAME: File Commands.
5555 * including a linker script: File Commands.
5556 * including an entire archive: Options.
5557 * incremental link: Options.
5558 * INHIBIT_COMMON_ALLOCATION: Miscellaneous Commands.
5559 * initialization function: Options.
5560 * initialized data in ROM: Output Section LMA.
5561 * input file format in linker script: Format Commands.
5562 * input filename symbols: Output Section Keywords.
5563 * input files in linker scripts: File Commands.
5564 * input files, displaying: Options.
5565 * input format: Options.
5566 * input object files in linker scripts: File Commands.
5567 * input section alignment: Forced Input Alignment.
5568 * input section basics: Input Section Basics.
5569 * input section wildcards: Input Section Wildcards.
5570 * input sections: Input Section.
5571 * INPUT(FILES): File Commands.
5572 * integer notation: Constants.
5573 * integer suffixes: Constants.
5574 * internal object-file format: Canonical format.
5575 * invalid input: Bug Criteria.
5576 * K and M integer suffixes: Constants.
5577 * KEEP: Input Section Keep.
5579 * L, deleting symbols beginning: Options.
5580 * lazy evaluation: Evaluation.
5581 * ld bugs, reporting: Bug Reporting.
5582 * LDEMULATION: Environment.
5585 * library search path in linker script: File Commands.
5586 * link map: Options.
5587 * link-time runtime library search path: Options.
5588 * linker crash: Bug Criteria.
5589 * linker script concepts: Basic Script Concepts.
5590 * linker script example: Simple Example.
5591 * linker script file commands: File Commands.
5592 * linker script format: Script Format.
5593 * linker script input object files: File Commands.
5594 * linker script simple commands: Simple Commands.
5595 * linker scripts: Scripts.
5597 * little-endian objects: Options.
5599 * load address: Output Section LMA.
5600 * LOADADDR(SECTION): Builtin Functions.
5601 * loading, preventing: Output Section Type.
5602 * local symbols, deleting: Options.
5603 * location counter: Location Counter.
5604 * LONG(EXPRESSION): Output Section Data.
5605 * M and K integer suffixes: Constants.
5606 * machine architecture: Miscellaneous Commands.
5607 * machine dependencies: Machine Dependent.
5608 * mapping input sections to output sections: Input Section.
5609 * MAX: Builtin Functions.
5611 * memory region attributes: MEMORY.
5612 * memory regions: MEMORY.
5613 * memory regions and sections: Output Section Region.
5614 * memory usage: Options.
5615 * MIN: Builtin Functions.
5616 * MIPS embedded PIC code: Options.
5617 * MRI compatibility: MRI.
5618 * MSP430 extra sections: MSP430.
5620 * name, section: Output Section Name.
5622 * naming the output file: Options.
5623 * NEXT(EXP): Builtin Functions.
5625 * NOCROSSREFS(SECTIONS): Miscellaneous Commands.
5626 * NOLOAD: Output Section Type.
5627 * not enough room for program headers: Builtin Functions.
5630 * object file management: BFD.
5631 * object files: Options.
5632 * object formats available: BFD.
5633 * object size: Options.
5635 * opening object files: BFD outline.
5636 * operators for arithmetic: Operators.
5641 * output file after errors: Options.
5642 * output file format in linker script: Format Commands.
5643 * output file name in linker scripot: File Commands.
5644 * output section attributes: Output Section Attributes.
5645 * output section data: Output Section Data.
5646 * OUTPUT(FILENAME): File Commands.
5647 * OUTPUT_ARCH(BFDARCH): Miscellaneous Commands.
5648 * OUTPUT_FORMAT(BFDNAME): Format Commands.
5649 * OVERLAY: Overlay Description.
5650 * overlays: Overlay Description.
5651 * partial link: Options.
5653 * position independent executables: Options.
5654 * precedence in expressions: Operators.
5655 * prevent unnecessary loading: Output Section Type.
5656 * program headers: PHDRS.
5657 * program headers and sections: Output Section Phdr.
5658 * program headers, not enough room: Builtin Functions.
5659 * program segments: PHDRS.
5661 * PUBLIC (MRI): MRI.
5662 * QUAD(EXPRESSION): Output Section Data.
5663 * quoted symbol names: Symbols.
5664 * read-only text: Options.
5665 * read/write from cmd line: Options.
5666 * regions of memory: MEMORY.
5667 * relative expressions: Expression Section.
5668 * relaxing addressing modes: Options.
5669 * relaxing on H8/300: H8/300.
5670 * relaxing on i960: i960.
5671 * relaxing on Xtensa: Xtensa.
5672 * relocatable and absolute symbols: Expression Section.
5673 * relocatable output: Options.
5674 * removing sections: Output Section Discarding.
5675 * reporting bugs in ld: Reporting Bugs.
5676 * requirements for BFD: BFD.
5677 * retain relocations in final executable: Options.
5678 * retaining specified symbols: Options.
5679 * ROM initialized data: Output Section LMA.
5680 * round up expression: Builtin Functions.
5681 * round up location counter: Builtin Functions.
5682 * runtime library name: Options.
5683 * runtime library search path: Options.
5684 * runtime pseudo-relocation: WIN32.
5685 * scaled integers: Constants.
5686 * scommon section: Input Section Common.
5687 * script files: Options.
5689 * search directory, from cmd line: Options.
5690 * search path in linker script: File Commands.
5691 * SEARCH_DIR(PATH): File Commands.
5693 * section address: Output Section Address.
5694 * section address in expression: Builtin Functions.
5695 * section alignment, warnings on: Options.
5696 * section data: Output Section Data.
5697 * section fill pattern: Output Section Fill.
5698 * section load address: Output Section LMA.
5699 * section load address in expression: Builtin Functions.
5700 * section name: Output Section Name.
5701 * section name wildcard patterns: Input Section Wildcards.
5702 * section size: Builtin Functions.
5703 * section, assigning to memory region: Output Section Region.
5704 * section, assigning to program header: Output Section Phdr.
5705 * SECTIONS: SECTIONS.
5706 * sections, discarding: Output Section Discarding.
5707 * segment origins, cmd line: Options.
5708 * segments, ELF: PHDRS.
5709 * shared libraries: Options.
5710 * SHORT(EXPRESSION): Output Section Data.
5711 * SIZEOF(SECTION): Builtin Functions.
5712 * SIZEOF_HEADERS: Builtin Functions.
5713 * small common symbols: Input Section Common.
5714 * SORT: Input Section Wildcards.
5715 * SQUAD(EXPRESSION): Output Section Data.
5716 * stack size: Options.
5717 * standard Unix system: Options.
5718 * start of execution: Entry Point.
5719 * STARTUP(FILENAME): File Commands.
5720 * strip all symbols: Options.
5721 * strip debugger symbols: Options.
5722 * stripping all but some symbols: Options.
5723 * SUBALIGN(SUBSECTION_ALIGN): Forced Input Alignment.
5724 * suffixes for integers: Constants.
5725 * symbol defaults: Builtin Functions.
5726 * symbol definition, scripts: Assignments.
5727 * symbol names: Symbols.
5728 * symbol tracing: Options.
5729 * symbol versions: VERSION.
5730 * symbol-only input: Options.
5731 * symbols, from command line: Options.
5732 * symbols, relocatable and absolute: Expression Section.
5733 * symbols, retaining selectively: Options.
5734 * synthesizing linker: Options.
5735 * synthesizing on H8/300: H8/300.
5736 * TARGET(BFDNAME): Format Commands.
5737 * thumb entry point: ARM.
5738 * TI COFF versions: TI COFF.
5739 * traditional format: Options.
5740 * unallocated address, next: Builtin Functions.
5741 * undefined symbol: Options.
5742 * undefined symbol in linker script: Miscellaneous Commands.
5743 * undefined symbols, warnings on: Options.
5744 * uninitialized data placement: Input Section Common.
5745 * unspecified memory: Output Section Data.
5747 * using a DEF file: WIN32.
5748 * using auto-export functionality: WIN32.
5749 * Using decorations: WIN32.
5750 * variables, defining: Assignments.
5753 * version script: VERSION.
5754 * version script, symbol versions: Options.
5755 * VERSION {script text}: VERSION.
5756 * versions of symbols: VERSION.
5757 * warnings, on combining symbols: Options.
5758 * warnings, on section alignment: Options.
5759 * warnings, on undefined symbols: Options.
5760 * what is this?: Overview.
5761 * wildcard file name patterns: Input Section Wildcards.
5762 * Xtensa processors: Xtensa.
5768 Node: Overview
\x7f1095
5769 Node: Invocation
\x7f2205
5770 Node: Options
\x7f2609
5771 Node: Environment
\x7f72045
5772 Node: Scripts
\x7f73797
5773 Node: Basic Script Concepts
\x7f75527
5774 Node: Script Format
\x7f78226
5775 Node: Simple Example
\x7f79081
5776 Node: Simple Commands
\x7f82168
5777 Node: Entry Point
\x7f82611
5778 Node: File Commands
\x7f83358
5779 Node: Format Commands
\x7f86648
5780 Node: Miscellaneous Commands
\x7f88602
5781 Node: Assignments
\x7f90820
5782 Node: Simple Assignments
\x7f91149
5783 Node: PROVIDE
\x7f92843
5784 Node: SECTIONS
\x7f94013
5785 Node: Output Section Description
\x7f95896
5786 Node: Output Section Name
\x7f96914
5787 Node: Output Section Address
\x7f97778
5788 Node: Input Section
\x7f99417
5789 Node: Input Section Basics
\x7f100206
5790 Node: Input Section Wildcards
\x7f102538
5791 Node: Input Section Common
\x7f105342
5792 Node: Input Section Keep
\x7f106808
5793 Node: Input Section Example
\x7f107274
5794 Node: Output Section Data
\x7f108226
5795 Node: Output Section Keywords
\x7f110991
5796 Node: Output Section Discarding
\x7f114421
5797 Node: Output Section Attributes
\x7f115363
5798 Node: Output Section Type
\x7f116280
5799 Node: Output Section LMA
\x7f117418
5800 Node: Forced Input Alignment
\x7f119682
5801 Node: Output Section Region
\x7f120046
5802 Node: Output Section Phdr
\x7f120460
5803 Node: Output Section Fill
\x7f121108
5804 Node: Overlay Description
\x7f122234
5805 Node: MEMORY
\x7f126470
5806 Node: PHDRS
\x7f130544
5807 Node: VERSION
\x7f135580
5808 Node: Expressions
\x7f142578
5809 Node: Constants
\x7f143409
5810 Node: Symbols
\x7f143956
5811 Node: Location Counter
\x7f144681
5812 Node: Operators
\x7f146991
5813 Node: Evaluation
\x7f147899
5814 Node: Expression Section
\x7f149250
5815 Node: Builtin Functions
\x7f150723
5816 Node: Implicit Linker Scripts
\x7f157043
5817 Node: Machine Dependent
\x7f157808
5818 Node: H8/300
\x7f158549
5819 Node: i960
\x7f159342
5821 Node: HPPA ELF32
\x7f162170
5822 Node: MMIX
\x7f163785
5823 Node: MSP430
\x7f164994
5824 Node: TI COFF
\x7f166028
5825 Node: WIN32
\x7f166543
5826 Node: Xtensa
\x7f180368
5828 Node: BFD outline
\x7f183654
5829 Node: BFD information loss
\x7f184932
5830 Node: Canonical format
\x7f187437
5831 Node: Reporting Bugs
\x7f191780
5832 Node: Bug Criteria
\x7f192470
5833 Node: Bug Reporting
\x7f193161
5835 Node: GNU Free Documentation License
\x7f204799
5836 Node: Index
\x7f224485