xref: /netbsd-src/external/gpl3/binutils/dist/ld/ld.info (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1This is ld.info, produced by makeinfo version 7.0.2 from ld.texi.
2
3This file documents the GNU linker LD (GNU Binutils) version 2.42.
4
5   Copyright © 1991-2024 Free Software Foundation, Inc.
6
7   Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3 or
9any later version published by the Free Software Foundation; with no
10Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
11Texts.  A copy of the license is included in the section entitled “GNU
12Free Documentation License”.
13INFO-DIR-SECTION Software development
14START-INFO-DIR-ENTRY
15* Ld: (ld).                       The GNU linker.
16END-INFO-DIR-ENTRY
17
18
19File: ld.info,  Node: Top,  Next: Overview,  Up: (dir)
20
21LD
22**
23
24This file documents the GNU linker ld (GNU Binutils) version 2.42.
25
26   This document is distributed under the terms of the GNU Free
27Documentation License version 1.3.  A copy of the license is included in
28the section entitled “GNU Free Documentation License”.
29
30* Menu:
31
32* Overview::                    Overview
33* Invocation::                  Invocation
34* Scripts::                     Linker Scripts
35* Plugins::                     Linker Plugins
36* Special Sections::            Special Sections
37* Machine Dependent::           Machine Dependent Features
38* BFD::                         BFD
39
40* Reporting Bugs::              Reporting Bugs
41* MRI::                         MRI Compatible Script Files
42* GNU Free Documentation License::  GNU Free Documentation License
43* LD Index::                       LD Index
44
45
46File: ld.info,  Node: Overview,  Next: Invocation,  Prev: Top,  Up: Top
47
481 Overview
49**********
50
51‘ld’ combines a number of object and archive files, relocates their data
52and ties up symbol references.  Usually the last step in compiling a
53program is to run ‘ld’.
54
55   ‘ld’ accepts Linker Command Language files written in a superset of
56AT&T’s Link Editor Command Language syntax, to provide explicit and
57total control over the linking process.
58
59   This version of ‘ld’ uses the general purpose BFD libraries to
60operate on object files.  This allows ‘ld’ to read, combine, and write
61object files in many different formats—for example, COFF or ‘a.out’.
62Different formats may be linked together to produce any available kind
63of object file.  *Note BFD::, for more information.
64
65   Aside from its flexibility, the GNU linker is more helpful than other
66linkers in providing diagnostic information.  Many linkers abandon
67execution immediately upon encountering an error; whenever possible,
68‘ld’ continues executing, allowing you to identify other errors (or, in
69some cases, to get an output file in spite of the error).
70
71
72File: ld.info,  Node: Invocation,  Next: Scripts,  Prev: Overview,  Up: Top
73
742 Invocation
75************
76
77The GNU linker ‘ld’ is meant to cover a broad range of situations, and
78to be as compatible as possible with other linkers.  As a result, you
79have many choices to control its behavior.
80
81* Menu:
82
83* Options::                     Command-line Options
84* Environment::                 Environment Variables
85
86
87File: ld.info,  Node: Options,  Next: Environment,  Up: Invocation
88
892.1 Command-line Options
90========================
91
92The linker supports a plethora of command-line options, but in actual
93practice few of them are used in any particular context.  For instance,
94a frequent use of ‘ld’ is to link standard Unix object files on a
95standard, supported Unix system.  On such a system, to link a file
96hello.o’:
97
98     ld -o OUTPUT /lib/crt0.o hello.o -lc
99
100   This tells ‘ld’ to produce a file called OUTPUT as the result of
101linking the file ‘/lib/crt0.o’ with ‘hello.o’ and the library ‘libc.a’,
102which will come from the standard search directories.  (See the
103discussion of the ‘-l’ option below.)
104
105   Some of the command-line options to ‘ld’ may be specified at any
106point in the command line.  However, options which refer to files, such
107as ‘-l’ or ‘-T’, cause the file to be read at the point at which the
108option appears in the command line, relative to the object files and
109other file options.  Repeating non-file options with a different
110argument will either have no further effect, or override prior
111occurrences (those further to the left on the command line) of that
112option.  Options which may be meaningfully specified more than once are
113noted in the descriptions below.
114
115   Non-option arguments are object files or archives which are to be
116linked together.  They may follow, precede, or be mixed in with
117command-line options, except that an object file argument may not be
118placed between an option and its argument.
119
120   Usually the linker is invoked with at least one object file, but you
121can specify other forms of binary input files using ‘-l’, ‘-R’, and the
122script command language.  If _no_ binary input files at all are
123specified, the linker does not produce any output, and issues the
124message ‘No input files’.
125
126   If the linker cannot recognize the format of an object file, it will
127assume that it is a linker script.  A script specified in this way
128augments the main linker script used for the link (either the default
129linker script or the one specified by using ‘-T’).  This feature permits
130the linker to link against a file which appears to be an object or an
131archive, but actually merely defines some symbol values, or uses ‘INPUT’
132or ‘GROUP’ to load other objects.  Specifying a script in this way
133merely augments the main linker script, with the extra commands placed
134after the main script; use the ‘-T’ option to replace the default linker
135script entirely, but note the effect of the ‘INSERT’ command.  *Note
136Scripts::.
137
138   For options whose names are a single letter, option arguments must
139either follow the option letter without intervening whitespace, or be
140given as separate arguments immediately following the option that
141requires them.
142
143   For options whose names are multiple letters, either one dash or two
144can precede the option name; for example, ‘-trace-symbol’ and
145‘--trace-symbol’ are equivalent.  Note—there is one exception to this
146rule.  Multiple letter options that start with a lower case ’o’ can only
147be preceded by two dashes.  This is to reduce confusion with the ‘-o’
148option.  So for example ‘-omagic’ sets the output file name to ‘magic’
149whereas ‘--omagic’ sets the NMAGIC flag on the output.
150
151   Arguments to multiple-letter options must either be separated from
152the option name by an equals sign, or be given as separate arguments
153immediately following the option that requires them.  For example,
154‘--trace-symbol foo’ and ‘--trace-symbol=foo’ are equivalent.  Unique
155abbreviations of the names of multiple-letter options are accepted.
156
157   Note—if the linker is being invoked indirectly, via a compiler driver
158(e.g.  ‘gcc’) then all the linker command-line options should be
159prefixed by ‘-Wl,’ (or whatever is appropriate for the particular
160compiler driver) like this:
161
162       gcc -Wl,--start-group foo.o bar.o -Wl,--end-group
163
164   This is important, because otherwise the compiler driver program may
165silently drop the linker options, resulting in a bad link.  Confusion
166may also arise when passing options that require values through a
167driver, as the use of a space between option and argument acts as a
168separator, and causes the driver to pass only the option to the linker
169and the argument to the compiler.  In this case, it is simplest to use
170the joined forms of both single- and multiple-letter options, such as:
171
172       gcc foo.o bar.o -Wl,-eENTRY -Wl,-Map=a.map
173
174   Here is a table of the generic command-line switches accepted by the
175GNU linker:
176
177‘@FILE’
178     Read command-line options from FILE.  The options read are inserted
179     in place of the original @FILE option.  If FILE does not exist, or
180     cannot be read, then the option will be treated literally, and not
181     removed.
182
183     Options in FILE are separated by whitespace.  A whitespace
184     character may be included in an option by surrounding the entire
185     option in either single or double quotes.  Any character (including
186     a backslash) may be included by prefixing the character to be
187     included with a backslash.  The FILE may itself contain additional
188     @FILE options; any such options will be processed recursively.
189
190‘-a KEYWORD’
191     This option is supported for HP/UX compatibility.  The KEYWORD
192     argument must be one of the strings ‘archive’, ‘shared’, or
193     ‘default’.  ‘-aarchive’ is functionally equivalent to ‘-Bstatic’,
194     and the other two keywords are functionally equivalent to
195     ‘-Bdynamic’.  This option may be used any number of times.
196
197‘--audit AUDITLIB’
198     Adds AUDITLIB to the ‘DT_AUDIT’ entry of the dynamic section.
199     AUDITLIB is not checked for existence, nor will it use the
200     DT_SONAME specified in the library.  If specified multiple times
201     ‘DT_AUDIT’ will contain a colon separated list of audit interfaces
202     to use.  If the linker finds an object with an audit entry while
203     searching for shared libraries, it will add a corresponding
204     ‘DT_DEPAUDIT’ entry in the output file.  This option is only
205     meaningful on ELF platforms supporting the rtld-audit interface.
206
207‘-b INPUT-FORMAT’
208‘--format=INPUT-FORMAT’
209     ‘ld’ may be configured to support more than one kind of object
210     file.  If your ‘ld’ is configured this way, you can use the ‘-b’
211     option to specify the binary format for input object files that
212     follow this option on the command line.  Even when ‘ld’ is
213     configured to support alternative object formats, you don’t usually
214     need to specify this, as ‘ld’ should be configured to expect as a
215     default input format the most usual format on each machine.
216     INPUT-FORMAT is a text string, the name of a particular format
217     supported by the BFD libraries.  (You can list the available binary
218     formats with ‘objdump -i’.)  *Note BFD::.
219
220     You may want to use this option if you are linking files with an
221     unusual binary format.  You can also use ‘-b’ to switch formats
222     explicitly (when linking object files of different formats), by
223     including ‘-b INPUT-FORMAT’ before each group of object files in a
224     particular format.
225
226     The default format is taken from the environment variable
227     ‘GNUTARGET’.  *Note Environment::.  You can also define the input
228     format from a script, using the command ‘TARGET’; see *note Format
229     Commands::.
230
231‘-c MRI-COMMANDFILE’
232‘--mri-script=MRI-COMMANDFILE’
233     For compatibility with linkers produced by MRI, ‘ld’ accepts script
234     files written in an alternate, restricted command language,
235     described in *note MRI Compatible Script Files: MRI. Introduce MRI
236     script files with the option ‘-c’; use the ‘-T’ option to run
237     linker scripts written in the general-purpose ‘ld’ scripting
238     language.  If MRI-CMDFILE does not exist, ‘ld’ looks for it in the
239     directories specified by any ‘-L’ options.
240
241‘-d’
242‘-dc’
243‘-dp’
244     These three options are equivalent; multiple forms are supported
245     for compatibility with other linkers.  They assign space to common
246     symbols even if a relocatable output file is specified (with ‘-r’).
247     The script command ‘FORCE_COMMON_ALLOCATION’ has the same effect.
248     *Note Miscellaneous Commands::.
249
250‘--depaudit AUDITLIB’
251‘-P AUDITLIB’
252     Adds AUDITLIB to the ‘DT_DEPAUDIT’ entry of the dynamic section.
253     AUDITLIB is not checked for existence, nor will it use the
254     DT_SONAME specified in the library.  If specified multiple times
255     ‘DT_DEPAUDIT’ will contain a colon separated list of audit
256     interfaces to use.  This option is only meaningful on ELF platforms
257     supporting the rtld-audit interface.  The -P option is provided for
258     Solaris compatibility.
259
260‘--enable-linker-version’
261     Enables the ‘LINKER_VERSION’ linker script directive, described in
262     *note Output Section Data::.  If this directive is used in a linker
263     script and this option has been enabled then a string containing
264     the linker version will be inserted at the current point.
265
266     Note - this location of this option on the linker command line is
267     significant.  It will only affect linker scripts that come after it
268     on the command line, or which are built into the linker.
269
270‘--disable-linker-version’
271     Disables the ‘LINKER_VERSION’ linker script directive, so that it
272     does not insert a version string.  This is the default.
273
274‘--enable-non-contiguous-regions’
275     This option avoids generating an error if an input section does not
276     fit a matching output section.  The linker tries to allocate the
277     input section to subseque nt matching output sections, and
278     generates an error only if no output section is large enough.  This
279     is useful when several non-contiguous memory regions are available
280     and the input section does not require a particular one.  The order
281     in which input sections are evaluated does not change, for
282     instance:
283
284            MEMORY {
285              MEM1 (rwx) : ORIGIN = 0x1000, LENGTH = 0x14
286              MEM2 (rwx) : ORIGIN = 0x1000, LENGTH = 0x40
287              MEM3 (rwx) : ORIGIN = 0x2000, LENGTH = 0x40
288            }
289            SECTIONS {
290              mem1 : { *(.data.*); } > MEM1
291              mem2 : { *(.data.*); } > MEM2
292              mem3 : { *(.data.*); } > MEM3
293            }
294
295            with input sections:
296            .data.1: size 8
297            .data.2: size 0x10
298            .data.3: size 4
299
300            results in .data.1 affected to mem1, and .data.2 and .data.3
301            affected to mem2, even though .data.3 would fit in mem3.
302
303     This option is incompatible with INSERT statements because it
304     changes the way input sections are mapped to output sections.
305
306‘--enable-non-contiguous-regions-warnings’
307     This option enables warnings when ‘--enable-non-contiguous-regions’
308     allows possibly unexpected matches in sections mapping, potentially
309     leading to silently discarding a section instead of failing because
310     it does not fit any output region.
311
312‘-e ENTRY’
313‘--entry=ENTRY’
314     Use ENTRY as the explicit symbol for beginning execution of your
315     program, rather than the default entry point.  If there is no
316     symbol named ENTRY, the linker will try to parse ENTRY as a number,
317     and use that as the entry address (the number will be interpreted
318     in base 10; you may use a leading ‘0x’ for base 16, or a leading
319     ‘0’ for base 8).  *Note Entry Point::, for a discussion of defaults
320     and other ways of specifying the entry point.
321
322‘--exclude-libs LIB,LIB,...’
323     Specifies a list of archive libraries from which symbols should not
324     be automatically exported.  The library names may be delimited by
325     commas or colons.  Specifying ‘--exclude-libs ALL’ excludes symbols
326     in all archive libraries from automatic export.  This option is
327     available only for the i386 PE targeted port of the linker and for
328     ELF targeted ports.  For i386 PE, symbols explicitly listed in a
329     .def file are still exported, regardless of this option.  For ELF
330     targeted ports, symbols affected by this option will be treated as
331     hidden.
332
333‘--exclude-modules-for-implib MODULE,MODULE,...’
334     Specifies a list of object files or archive members, from which
335     symbols should not be automatically exported, but which should be
336     copied wholesale into the import library being generated during the
337     link.  The module names may be delimited by commas or colons, and
338     must match exactly the filenames used by ‘ld’ to open the files;
339     for archive members, this is simply the member name, but for object
340     files the name listed must include and match precisely any path
341     used to specify the input file on the linker’s command-line.  This
342     option is available only for the i386 PE targeted port of the
343     linker.  Symbols explicitly listed in a .def file are still
344     exported, regardless of this option.
345
346‘-E’
347‘--export-dynamic’
348‘--no-export-dynamic’
349     When creating a dynamically linked executable, using the ‘-E’
350     option or the ‘--export-dynamic’ option causes the linker to add
351     all symbols to the dynamic symbol table.  The dynamic symbol table
352     is the set of symbols which are visible from dynamic objects at run
353     time.
354
355     If you do not use either of these options (or use the
356     ‘--no-export-dynamic’ option to restore the default behavior), the
357     dynamic symbol table will normally contain only those symbols which
358     are referenced by some dynamic object mentioned in the link.
359
360     If you use ‘dlopen’ to load a dynamic object which needs to refer
361     back to the symbols defined by the program, rather than some other
362     dynamic object, then you will probably need to use this option when
363     linking the program itself.
364
365     You can also use the dynamic list to control what symbols should be
366     added to the dynamic symbol table if the output format supports it.
367     See the description of ‘--dynamic-list’.
368
369     Note that this option is specific to ELF targeted ports.  PE
370     targets support a similar function to export all symbols from a DLL
371     or EXE; see the description of ‘--export-all-symbols’ below.
372
373‘--export-dynamic-symbol=GLOB’
374     When creating a dynamically linked executable, symbols matching
375     GLOB will be added to the dynamic symbol table.  When creating a
376     shared library, references to symbols matching GLOB will not be
377     bound to the definitions within the shared library.  This option is
378     a no-op when creating a shared library and ‘-Bsymbolic’ or
379     ‘--dynamic-list’ are not specified.  This option is only meaningful
380     on ELF platforms which support shared libraries.
381
382‘--export-dynamic-symbol-list=FILE’
383     Specify a ‘--export-dynamic-symbol’ for each pattern in the file.
384     The format of the file is the same as the version node without
385     scope and node name.  See *note VERSION:: for more information.
386
387‘-EB’
388     Link big-endian objects.  This affects the default output format.
389
390‘-EL’
391     Link little-endian objects.  This affects the default output
392     format.
393
394‘-f NAME’
395‘--auxiliary=NAME’
396     When creating an ELF shared object, set the internal DT_AUXILIARY
397     field to the specified name.  This tells the dynamic linker that
398     the symbol table of the shared object should be used as an
399     auxiliary filter on the symbol table of the shared object NAME.
400
401     If you later link a program against this filter object, then, when
402     you run the program, the dynamic linker will see the DT_AUXILIARY
403     field.  If the dynamic linker resolves any symbols from the filter
404     object, it will first check whether there is a definition in the
405     shared object NAME.  If there is one, it will be used instead of
406     the definition in the filter object.  The shared object NAME need
407     not exist.  Thus the shared object NAME may be used to provide an
408     alternative implementation of certain functions, perhaps for
409     debugging or for machine-specific performance.
410
411     This option may be specified more than once.  The DT_AUXILIARY
412     entries will be created in the order in which they appear on the
413     command line.
414
415‘-F NAME’
416‘--filter=NAME’
417     When creating an ELF shared object, set the internal DT_FILTER
418     field to the specified name.  This tells the dynamic linker that
419     the symbol table of the shared object which is being created should
420     be used as a filter on the symbol table of the shared object NAME.
421
422     If you later link a program against this filter object, then, when
423     you run the program, the dynamic linker will see the DT_FILTER
424     field.  The dynamic linker will resolve symbols according to the
425     symbol table of the filter object as usual, but it will actually
426     link to the definitions found in the shared object NAME.  Thus the
427     filter object can be used to select a subset of the symbols
428     provided by the object NAME.
429
430     Some older linkers used the ‘-F’ option throughout a compilation
431     toolchain for specifying object-file format for both input and
432     output object files.  The GNU linker uses other mechanisms for this
433     purpose: the ‘-b’, ‘--format’, ‘--oformat’ options, the ‘TARGET’
434     command in linker scripts, and the ‘GNUTARGET’ environment
435     variable.  The GNU linker will ignore the ‘-F’ option when not
436     creating an ELF shared object.
437
438‘-fini=NAME’
439     When creating an ELF executable or shared object, call NAME when
440     the executable or shared object is unloaded, by setting DT_FINI to
441     the address of the function.  By default, the linker uses ‘_fini’
442     as the function to call.
443
444‘-g’
445     Ignored.  Provided for compatibility with other tools.
446
447‘-G VALUE’
448‘--gpsize=VALUE’
449     Set the maximum size of objects to be optimized using the GP
450     register to SIZE.  This is only meaningful for object file formats
451     such as MIPS ELF that support putting large and small objects into
452     different sections.  This is ignored for other object file formats.
453
454‘-h NAME’
455‘-soname=NAME’
456     When creating an ELF shared object, set the internal DT_SONAME
457     field to the specified name.  When an executable is linked with a
458     shared object which has a DT_SONAME field, then when the executable
459     is run the dynamic linker will attempt to load the shared object
460     specified by the DT_SONAME field rather than using the file name
461     given to the linker.
462
463‘-i’
464     Perform an incremental link (same as option ‘-r’).
465
466‘-init=NAME’
467     When creating an ELF executable or shared object, call NAME when
468     the executable or shared object is loaded, by setting DT_INIT to
469     the address of the function.  By default, the linker uses ‘_init’
470     as the function to call.
471
472‘-l NAMESPEC’
473‘--library=NAMESPEC’
474     Add the archive or object file specified by NAMESPEC to the list of
475     files to link.  This option may be used any number of times.  If
476     NAMESPEC is of the form ‘:FILENAME’, ‘ld’ will search the library
477     path for a file called FILENAME, otherwise it will search the
478     library path for a file called ‘libNAMESPEC.a’.
479
480     On systems which support shared libraries, ‘ld’ may also search for
481     files other than ‘libNAMESPEC.a’.  Specifically, on ELF and SunOS
482     systems, ‘ld’ will search a directory for a library called
483libNAMESPEC.so’ before searching for one called ‘libNAMESPEC.a’.
484     (By convention, a ‘.so’ extension indicates a shared library.)
485     Note that this behavior does not apply to ‘:FILENAME’, which always
486     specifies a file called FILENAME.
487
488     The linker will search an archive only once, at the location where
489     it is specified on the command line.  If the archive defines a
490     symbol which was undefined in some object which appeared before the
491     archive on the command line, the linker will include the
492     appropriate file(s) from the archive.  However, an undefined symbol
493     in an object appearing later on the command line will not cause the
494     linker to search the archive again.
495
496     See the ‘-(’ option for a way to force the linker to search
497     archives multiple times.
498
499     You may list the same archive multiple times on the command line.
500
501     This type of archive searching is standard for Unix linkers.
502     However, if you are using ‘ld’ on AIX, note that it is different
503     from the behaviour of the AIX linker.
504
505‘-L SEARCHDIR’
506‘--library-path=SEARCHDIR’
507     Add path SEARCHDIR to the list of paths that ‘ld’ will search for
508     archive libraries and ‘ld’ control scripts.  You may use this
509     option any number of times.  The directories are searched in the
510     order in which they are specified on the command line.  Directories
511     specified on the command line are searched before the default
512     directories.  All ‘-L’ options apply to all ‘-l’ options,
513     regardless of the order in which the options appear.  ‘-L’ options
514     do not affect how ‘ld’ searches for a linker script unless ‘-T’
515     option is specified.
516
517     If SEARCHDIR begins with ‘=’ or ‘$SYSROOT’, then this prefix will
518     be replaced by the “sysroot prefix”, controlled by the ‘--sysroot’
519     option, or specified when the linker is configured.
520
521     The default set of paths searched (without being specified with
522     ‘-L’) depends on which emulation mode ‘ld’ is using, and in some
523     cases also on how it was configured.  *Note Environment::.
524
525     The paths can also be specified in a link script with the
526     ‘SEARCH_DIR’ command.  Directories specified this way are searched
527     at the point in which the linker script appears in the command
528     line.
529
530‘-m EMULATION’
531     Emulate the EMULATION linker.  You can list the available
532     emulations with the ‘--verbose’ or ‘-V’ options.
533
534     If the ‘-m’ option is not used, the emulation is taken from the
535     ‘LDEMULATION’ environment variable, if that is defined.
536
537     Otherwise, the default emulation depends upon how the linker was
538     configured.
539
540‘--remap-inputs=pattern=filename’
541‘--remap-inputs-file=file’
542     These options allow the names of input files to be changed before
543     the linker attempts to open them.  The option
544     ‘--remap-inputs=foo.o=bar.o’ will cause any attempt to load a file
545     called ‘foo.o’ to instead try to load a file called ‘bar.o’.
546     Wildcard patterns are permitted in the first filename, so
547     ‘--remap-inputs=foo*.o=bar.o’ will rename any input file that
548     matches ‘foo*.o’ to ‘bar.o’.
549
550     An alternative form of the option ‘--remap-inputs-file=filename’
551     allows the remappings to be read from a file.  Each line in the
552     file can contain a single remapping.  Blank lines are ignored.
553     Anything from a hash character (‘#’) to the end of a line is
554     considered to be a comment and is also ignored.  The mapping
555     pattern can be separated from the filename by whitespace or an
556     equals (‘=’) character.
557
558     The options can be specified multiple times.  Their contents
559     accumulate.  The remappings will be processed in the order in which
560     they occur on the command line, and if they come from a file, in
561     the order in which they occur in the file.  If a match is made, no
562     further checking for that filename will be performed.
563
564     If the replacement filename is ‘/dev/null’ or just ‘NUL’ then the
565     remapping will actually cause the input file to be ignored.  This
566     can be a convenient way to experiment with removing input files
567     from a complicated build environment.
568
569     Note that this option is position dependent and only affects
570     filenames that come after it on the command line.  Thus:
571
572            ld foo.o --remap-inputs=foo.o=bar.o
573
574     Will have no effect, whereas:
575
576            ld --remap-inputs=foo.o=bar.o foo.o
577
578     Will rename the input file ‘foo.o’ to ‘bar.o’.
579
580     Note - these options also affect files referenced by _INPUT_
581     statements in linker scripts.  But since linker scripts are
582     processed after the entire command line is read, the position of
583     the remap options on the command line is not significant.
584
585     If the ‘verbose’ option is enabled then any mappings that match
586     will be reported, although again the ‘verbose’ option needs to be
587     enabled on the command line _before_ the remaped filenames appear.
588
589     If the ‘-Map’ or ‘--print-map’ options are enabled then the
590     remapping list will be included in the map output.
591
592‘-M’
593‘--print-map’
594     Print a link map to the standard output.  A link map provides
595     information about the link, including the following:
596
597        • Where object files are mapped into memory.
598        • How common symbols are allocated.
599        • All archive members included in the link, with a mention of
600          the symbol which caused the archive member to be brought in.
601        • The values assigned to symbols.
602
603          Note - symbols whose values are computed by an expression
604          which involves a reference to a previous value of the same
605          symbol may not have correct result displayed in the link map.
606          This is because the linker discards intermediate results and
607          only retains the final value of an expression.  Under such
608          circumstances the linker will display the final value enclosed
609          by square brackets.  Thus for example a linker script
610          containing:
611
612                  foo = 1
613                  foo = foo * 4
614                  foo = foo + 8
615
616          will produce the following output in the link map if the ‘-M’
617          option is used:
618
619                  0x00000001                foo = 0x1
620                  [0x0000000c]                foo = (foo * 0x4)
621                  [0x0000000c]                foo = (foo + 0x8)
622
623          See *note Expressions:: for more information about expressions
624          in linker scripts.
625
626        • How GNU properties are merged.
627
628          When the linker merges input .note.gnu.property sections into
629          one output .note.gnu.property section, some properties are
630          removed or updated.  These actions are reported in the link
631          map.  For example:
632
633               Removed property 0xc0000002 to merge foo.o (0x1) and bar.o (not found)
634
635          This indicates that property 0xc0000002 is removed from output
636          when merging properties in ‘foo.o’, whose property 0xc0000002
637          value is 0x1, and ‘bar.o’, which doesn’t have property
638          0xc0000002.
639
640               Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1)
641
642          This indicates that property 0xc0010001 value is updated to
643          0x1 in output when merging properties in ‘foo.o’, whose
644          0xc0010001 property value is 0x1, and ‘bar.o’, whose
645          0xc0010001 property value is 0x1.
646
647        • On some ELF targets, a list of fixups inserted by ‘--relax’
648
649               foo.o: Adjusting branch at 0x00000008 towards "far" in section .text
650
651          This indicates that the branch at 0x00000008 in foo.o,
652          targeting the symbol "far" in section .text, has been replaced
653          by a trampoline.
654
655‘--print-map-discarded’
656‘--no-print-map-discarded’
657     Print (or do not print) the list of discarded and garbage collected
658     sections in the link map.  Enabled by default.
659
660‘--print-map-locals’
661‘--no-print-map-locals’
662     Print (or do not print) local symbols in the link map.  Local
663     symbols will have the text ‘(local)’ printed before their name, and
664     will be listed after all of the global symbols in a given section.
665     Temporary local symbols (typically those that start with ‘.L’) will
666     not be included in the output.  Disabled by default.
667
668‘-n’
669‘--nmagic’
670     Turn off page alignment of sections, and disable linking against
671     shared libraries.  If the output format supports Unix style magic
672     numbers, mark the output as ‘NMAGIC’.
673
674‘-N’
675‘--omagic’
676     Set the text and data sections to be readable and writable.  Also,
677     do not page-align the data segment, and disable linking against
678     shared libraries.  If the output format supports Unix style magic
679     numbers, mark the output as ‘OMAGIC’.  Note: Although a writable
680     text section is allowed for PE-COFF targets, it does not conform to
681     the format specification published by Microsoft.
682
683‘--no-omagic’
684     This option negates most of the effects of the ‘-N’ option.  It
685     sets the text section to be read-only, and forces the data segment
686     to be page-aligned.  Note - this option does not enable linking
687     against shared libraries.  Use ‘-Bdynamic’ for this.
688
689‘-o OUTPUT’
690‘--output=OUTPUT’
691     Use OUTPUT as the name for the program produced by ‘ld’; if this
692     option is not specified, the name ‘a.out’ is used by default.  The
693     script command ‘OUTPUT’ can also specify the output file name.
694
695‘--dependency-file=DEPFILE’
696     Write a “dependency file” to DEPFILE.  This file contains a rule
697     suitable for ‘make’ describing the output file and all the input
698     files that were read to produce it.  The output is similar to the
699     compiler’s output with ‘-M -MP’ (*note Options Controlling the
700     Preprocessor: (gcc.info)Preprocessor Options.).  Note that there is
701     no option like the compiler’s ‘-MM’, to exclude “system files”
702     (which is not a well-specified concept in the linker, unlike
703     “system headers” in the compiler).  So the output from
704     ‘--dependency-file’ is always specific to the exact state of the
705     installation where it was produced, and should not be copied into
706     distributed makefiles without careful editing.
707
708‘-O LEVEL’
709     If LEVEL is a numeric values greater than zero ‘ld’ optimizes the
710     output.  This might take significantly longer and therefore
711     probably should only be enabled for the final binary.  At the
712     moment this option only affects ELF shared library generation.
713     Future releases of the linker may make more use of this option.
714     Also currently there is no difference in the linker’s behaviour for
715     different non-zero values of this option.  Again this may change
716     with future releases.
717
718‘-plugin NAME’
719     Involve a plugin in the linking process.  The NAME parameter is the
720     absolute filename of the plugin.  Usually this parameter is
721     automatically added by the complier, when using link time
722     optimization, but users can also add their own plugins if they so
723     wish.
724
725     Note that the location of the compiler originated plugins is
726     different from the place where the ‘ar’, ‘nm’ and ‘ranlib’ programs
727     search for their plugins.  In order for those commands to make use
728     of a compiler based plugin it must first be copied into the
729     ‘${libdir}/bfd-plugins’ directory.  All gcc based linker plugins
730     are backward compatible, so it is sufficient to just copy in the
731     newest one.
732
733‘--push-state’
734     The ‘--push-state’ allows one to preserve the current state of the
735     flags which govern the input file handling so that they can all be
736     restored with one corresponding ‘--pop-state’ option.
737
738     The option which are covered are: ‘-Bdynamic’, ‘-Bstatic’, ‘-dn’,
739     ‘-dy’, ‘-call_shared’, ‘-non_shared’, ‘-static’, ‘-N’, ‘-n’,
740     ‘--whole-archive’, ‘--no-whole-archive’, ‘-r’, ‘-Ur’,
741     ‘--copy-dt-needed-entries’, ‘--no-copy-dt-needed-entries’,
742     ‘--as-needed’, ‘--no-as-needed’, and ‘-a’.
743
744     One target for this option are specifications for ‘pkg-config’.
745     When used with the ‘--libs’ option all possibly needed libraries
746     are listed and then possibly linked with all the time.  It is
747     better to return something as follows:
748
749          -Wl,--push-state,--as-needed -libone -libtwo -Wl,--pop-state
750
751‘--pop-state’
752     Undoes the effect of –push-state, restores the previous values of
753     the flags governing input file handling.
754
755‘-q’
756‘--emit-relocs’
757     Leave relocation sections and contents in fully linked executables.
758     Post link analysis and optimization tools may need this information
759     in order to perform correct modifications of executables.  This
760     results in larger executables.
761
762     This option is currently only supported on ELF platforms.
763
764‘--force-dynamic’
765     Force the output file to have dynamic sections.  This option is
766     specific to VxWorks targets.
767
768‘-r’
769‘--relocatable’
770     Generate relocatable output—i.e., generate an output file that can
771     in turn serve as input to ‘ld’.  This is often called “partial
772     linking”.  As a side effect, in environments that support standard
773     Unix magic numbers, this option also sets the output file’s magic
774     number to ‘OMAGIC’.  If this option is not specified, an absolute
775     file is produced.  When linking C++ programs, this option _will
776     not_ resolve references to constructors; to do that, use ‘-Ur’.
777
778     When an input file does not have the same format as the output
779     file, partial linking is only supported if that input file does not
780     contain any relocations.  Different output formats can have further
781     restrictions; for example some ‘a.out’-based formats do not support
782     partial linking with input files in other formats at all.
783
784     This option does the same thing as ‘-i’.
785
786‘-R FILENAME’
787‘--just-symbols=FILENAME’
788     Read symbol names and their addresses from FILENAME, but do not
789     relocate it or include it in the output.  This allows your output
790     file to refer symbolically to absolute locations of memory defined
791     in other programs.  You may use this option more than once.
792
793     For compatibility with other ELF linkers, if the ‘-R’ option is
794     followed by a directory name, rather than a file name, it is
795     treated as the ‘-rpath’ option.
796
797‘-s’
798‘--strip-all’
799     Omit all symbol information from the output file.
800
801‘-S’
802‘--strip-debug’
803     Omit debugger symbol information (but not all symbols) from the
804     output file.
805
806‘--strip-discarded’
807‘--no-strip-discarded’
808     Omit (or do not omit) global symbols defined in discarded sections.
809     Enabled by default.
810
811‘-t’
812‘--trace’
813     Print the names of the input files as ‘ld’ processes them.  If ‘-t’
814     is given twice then members within archives are also printed.  ‘-t’
815     output is useful to generate a list of all the object files and
816     scripts involved in linking, for example, when packaging files for
817     a linker bug report.
818
819‘-T SCRIPTFILE’
820‘--script=SCRIPTFILE’
821     Use SCRIPTFILE as the linker script.  This script replaces ‘ld’’s
822     default linker script (rather than adding to it), unless the script
823     contains ‘INSERT’, so COMMANDFILE must specify everything necessary
824     to describe the output file.  *Note Scripts::.  If SCRIPTFILE does
825     not exist in the current directory, ‘ld’ looks for it in the
826     directories specified by any preceding ‘-L’ options.  Multiple ‘-T’
827     options accumulate.
828
829‘-dT SCRIPTFILE’
830‘--default-script=SCRIPTFILE’
831     Use SCRIPTFILE as the default linker script.  *Note Scripts::.
832
833     This option is similar to the ‘--script’ option except that
834     processing of the script is delayed until after the rest of the
835     command line has been processed.  This allows options placed after
836     the ‘--default-script’ option on the command line to affect the
837     behaviour of the linker script, which can be important when the
838     linker command line cannot be directly controlled by the user.  (eg
839     because the command line is being constructed by another tool, such
840     as ‘gcc’).
841
842‘-u SYMBOL’
843‘--undefined=SYMBOL’
844     Force SYMBOL to be entered in the output file as an undefined
845     symbol.  Doing this may, for example, trigger linking of additional
846     modules from standard libraries.  ‘-u’ may be repeated with
847     different option arguments to enter additional undefined symbols.
848     This option is equivalent to the ‘EXTERN’ linker script command.
849
850     If this option is being used to force additional modules to be
851     pulled into the link, and if it is an error for the symbol to
852     remain undefined, then the option ‘--require-defined’ should be
853     used instead.
854
855‘--require-defined=SYMBOL’
856     Require that SYMBOL is defined in the output file.  This option is
857     the same as option ‘--undefined’ except that if SYMBOL is not
858     defined in the output file then the linker will issue an error and
859     exit.  The same effect can be achieved in a linker script by using
860     ‘EXTERN’, ‘ASSERT’ and ‘DEFINED’ together.  This option can be used
861     multiple times to require additional symbols.
862
863‘-Ur’
864
865     For programs that do not use constructors or destructors, or for
866     ELF based systems this option is equivalent to ‘-r’: it generates
867     relocatable output—i.e., an output file that can in turn serve as
868     input to ‘ld’.  For other binaries however the ‘-Ur’ option is
869     similar to ‘-r’ but it also resolves references to constructors and
870     destructors.
871
872     For those systems where ‘-r’ and ‘-Ur’ behave differently, it does
873     not work to use ‘-Ur’ on files that were themselves linked with
874     ‘-Ur’; once the constructor table has been built, it cannot be
875     added to.  Use ‘-Ur’ only for the last partial link, and ‘-r’ for
876     the others.
877
878‘--orphan-handling=MODE’
879     Control how orphan sections are handled.  An orphan section is one
880     not specifically mentioned in a linker script.  *Note Orphan
881     Sections::.
882
883     MODE can have any of the following values:
884
885     ‘place’
886          Orphan sections are placed into a suitable output section
887          following the strategy described in *note Orphan Sections::.
888          The option ‘--unique’ also affects how sections are placed.
889
890     ‘discard’
891          All orphan sections are discarded, by placing them in the
892          ‘/DISCARD/’ section (*note Output Section Discarding::).
893
894     ‘warn’
895          The linker will place the orphan section as for ‘place’ and
896          also issue a warning.
897
898     ‘error’
899          The linker will exit with an error if any orphan section is
900          found.
901
902     The default if ‘--orphan-handling’ is not given is ‘place’.
903
904‘--unique[=SECTION]’
905     Creates a separate output section for every input section matching
906     SECTION, or if the optional wildcard SECTION argument is missing,
907     for every orphan input section.  An orphan section is one not
908     specifically mentioned in a linker script.  You may use this option
909     multiple times on the command line; It prevents the normal merging
910     of input sections with the same name, overriding output section
911     assignments in a linker script.
912
913‘-v’
914‘--version’
915‘-V’
916     Display the version number for ‘ld’.  The ‘-V’ option also lists
917     the supported emulations.  See also the description of the
918     ‘--enable-linker-version’ in *note Command-line Options: Options.
919     which can be used to insert the linker version string into a
920     binary.
921
922‘-x’
923‘--discard-all’
924     Delete all local symbols.
925
926‘-X’
927‘--discard-locals’
928     Delete all temporary local symbols.  (These symbols start with
929     system-specific local label prefixes, typically ‘.L’ for ELF
930     systems or ‘L’ for traditional a.out systems.)
931
932‘-y SYMBOL’
933‘--trace-symbol=SYMBOL’
934     Print the name of each linked file in which SYMBOL appears.  This
935     option may be given any number of times.  On many systems it is
936     necessary to prepend an underscore.
937
938     This option is useful when you have an undefined symbol in your
939     link but don’t know where the reference is coming from.
940
941‘-Y PATH’
942     Add PATH to the default library search path.  This option exists
943     for Solaris compatibility.
944
945‘-z KEYWORD’
946     The recognized keywords are:
947
948     ‘call-nop=prefix-addr’
949     ‘call-nop=suffix-nop’
950     ‘call-nop=prefix-BYTE’
951     ‘call-nop=suffix-BYTE’
952          Specify the 1-byte ‘NOP’ padding when transforming indirect
953          call to a locally defined function, foo, via its GOT slot.
954          ‘call-nop=prefix-addr’ generates ‘0x67 call foo’.
955          ‘call-nop=suffix-nop’ generates ‘call foo 0x90’.
956          ‘call-nop=prefix-BYTE’ generates ‘BYTE call foo’.
957          ‘call-nop=suffix-BYTE’ generates ‘call foo BYTE’.  Supported
958          for i386 and x86_64.
959
960     ‘cet-report=none’
961     ‘cet-report=warning’
962     ‘cet-report=error’
963          Specify how to report the missing
964          GNU_PROPERTY_X86_FEATURE_1_IBT and
965          GNU_PROPERTY_X86_FEATURE_1_SHSTK properties in input
966          .note.gnu.property section.  ‘cet-report=none’, which is the
967          default, will make the linker not report missing properties in
968          input files.  ‘cet-report=warning’ will make the linker issue
969          a warning for missing properties in input files.
970          ‘cet-report=error’ will make the linker issue an error for
971          missing properties in input files.  Note that ‘ibt’ will turn
972          off the missing GNU_PROPERTY_X86_FEATURE_1_IBT property report
973          and ‘shstk’ will turn off the missing
974          GNU_PROPERTY_X86_FEATURE_1_SHSTK property report.  Supported
975          for Linux/i386 and Linux/x86_64.
976
977     ‘combreloc’
978     ‘nocombreloc’
979          Combine multiple dynamic relocation sections and sort to
980          improve dynamic symbol lookup caching.  Do not do this if
981          ‘nocombreloc’.
982
983     ‘common’
984     ‘nocommon’
985          Generate common symbols with STT_COMMON type during a
986          relocatable link.  Use STT_OBJECT type if ‘nocommon’.
987
988     ‘common-page-size=VALUE’
989          Set the page size most commonly used to VALUE.  Memory image
990          layout will be optimized to minimize memory pages if the
991          system is using pages of this size.
992
993     ‘defs’
994          Report unresolved symbol references from regular object files.
995          This is done even if the linker is creating a non-symbolic
996          shared library.  This option is the inverse of ‘-z undefs’.
997
998     ‘dynamic-undefined-weak’
999     ‘nodynamic-undefined-weak’
1000          Make undefined weak symbols dynamic when building a dynamic
1001          object, if they are referenced from a regular object file and
1002          not forced local by symbol visibility or versioning.  Do not
1003          make them dynamic if ‘nodynamic-undefined-weak’.  If neither
1004          option is given, a target may default to either option being
1005          in force, or make some other selection of undefined weak
1006          symbols dynamic.  Not all targets support these options.
1007
1008     ‘execstack’
1009          Marks the object as requiring executable stack.
1010
1011     ‘global’
1012          This option is only meaningful when building a shared object.
1013          It makes the symbols defined by this shared object available
1014          for symbol resolution of subsequently loaded libraries.
1015
1016     ‘globalaudit’
1017          This option is only meaningful when building a dynamic
1018          executable.  This option marks the executable as requiring
1019          global auditing by setting the ‘DF_1_GLOBAUDIT’ bit in the
1020          ‘DT_FLAGS_1’ dynamic tag.  Global auditing requires that any
1021          auditing library defined via the ‘--depaudit’ or ‘-P’
1022          command-line options be run for all dynamic objects loaded by
1023          the application.
1024
1025     ‘ibtplt’
1026          Generate Intel Indirect Branch Tracking (IBT) enabled PLT
1027          entries.  Supported for Linux/i386 and Linux/x86_64.
1028
1029     ‘ibt’
1030          Generate GNU_PROPERTY_X86_FEATURE_1_IBT in .note.gnu.property
1031          section to indicate compatibility with IBT. This also implies
1032          ‘ibtplt’.  Supported for Linux/i386 and Linux/x86_64.
1033
1034     ‘indirect-extern-access’
1035     ‘noindirect-extern-access’
1036          Generate GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS in
1037          .note.gnu.property section to indicate that object file
1038          requires canonical function pointers and cannot be used with
1039          copy relocation.  This option also implies
1040          ‘noextern-protected-data’ and ‘nocopyreloc’.  Supported for
1041          i386 and x86-64.
1042
1043          ‘noindirect-extern-access’ removes
1044          GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS from
1045          .note.gnu.property section.
1046
1047     ‘initfirst’
1048          This option is only meaningful when building a shared object.
1049          It marks the object so that its runtime initialization will
1050          occur before the runtime initialization of any other objects
1051          brought into the process at the same time.  Similarly the
1052          runtime finalization of the object will occur after the
1053          runtime finalization of any other objects.
1054
1055     ‘interpose’
1056          Specify that the dynamic loader should modify its symbol
1057          search order so that symbols in this shared library interpose
1058          all other shared libraries not so marked.
1059
1060     ‘unique’
1061     ‘nounique’
1062          When generating a shared library or other dynamically loadable
1063          ELF object mark it as one that should (by default) only ever
1064          be loaded once, and only in the main namespace (when using
1065          ‘dlmopen’).  This is primarily used to mark fundamental
1066          libraries such as libc, libpthread et al which do not usually
1067          function correctly unless they are the sole instances of
1068          themselves.  This behaviour can be overridden by the ‘dlmopen’
1069          caller and does not apply to certain loading mechanisms (such
1070          as audit libraries).
1071
1072     ‘lam-u48’
1073          Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U48 in
1074          .note.gnu.property section to indicate compatibility with
1075          Intel LAM_U48.  Supported for Linux/x86_64.
1076
1077     ‘lam-u57’
1078          Generate GNU_PROPERTY_X86_FEATURE_1_LAM_U57 in
1079          .note.gnu.property section to indicate compatibility with
1080          Intel LAM_U57.  Supported for Linux/x86_64.
1081
1082     ‘lam-u48-report=none’
1083     ‘lam-u48-report=warning’
1084     ‘lam-u48-report=error’
1085          Specify how to report the missing
1086          GNU_PROPERTY_X86_FEATURE_1_LAM_U48 property in input
1087          .note.gnu.property section.  ‘lam-u48-report=none’, which is
1088          the default, will make the linker not report missing
1089          properties in input files.  ‘lam-u48-report=warning’ will make
1090          the linker issue a warning for missing properties in input
1091          files.  ‘lam-u48-report=error’ will make the linker issue an
1092          error for missing properties in input files.  Supported for
1093          Linux/x86_64.
1094
1095     ‘lam-u57-report=none’
1096     ‘lam-u57-report=warning’
1097     ‘lam-u57-report=error’
1098          Specify how to report the missing
1099          GNU_PROPERTY_X86_FEATURE_1_LAM_U57 property in input
1100          .note.gnu.property section.  ‘lam-u57-report=none’, which is
1101          the default, will make the linker not report missing
1102          properties in input files.  ‘lam-u57-report=warning’ will make
1103          the linker issue a warning for missing properties in input
1104          files.  ‘lam-u57-report=error’ will make the linker issue an
1105          error for missing properties in input files.  Supported for
1106          Linux/x86_64.
1107
1108     ‘lam-report=none’
1109     ‘lam-report=warning’
1110     ‘lam-report=error’
1111          Specify how to report the missing
1112          GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and
1113          GNU_PROPERTY_X86_FEATURE_1_LAM_U57 properties in input
1114          .note.gnu.property section.  ‘lam-report=none’, which is the
1115          default, will make the linker not report missing properties in
1116          input files.  ‘lam-report=warning’ will make the linker issue
1117          a warning for missing properties in input files.
1118          ‘lam-report=error’ will make the linker issue an error for
1119          missing properties in input files.  Supported for
1120          Linux/x86_64.
1121
1122     ‘lazy’
1123          When generating an executable or shared library, mark it to
1124          tell the dynamic linker to defer function call resolution to
1125          the point when the function is called (lazy binding), rather
1126          than at load time.  Lazy binding is the default.
1127
1128     ‘loadfltr’
1129          Specify that the object’s filters be processed immediately at
1130          runtime.
1131
1132     ‘max-page-size=VALUE’
1133          Set the maximum memory page size supported to VALUE.
1134
1135     ‘mark-plt’
1136     ‘nomark-plt’
1137          Mark PLT entries with dynamic tags, DT_X86_64_PLT,
1138          DT_X86_64_PLTSZ and DT_X86_64_PLTENT. Since this option stores
1139          a non-zero value in the r_addend field of R_X86_64_JUMP_SLOT
1140          relocations, the resulting executables and shared libraries
1141          are incompatible with dynamic linkers, such as those in older
1142          versions of glibc without the change to ignore r_addend in
1143          R_X86_64_GLOB_DAT and R_X86_64_JUMP_SLOT relocations, which
1144          don’t ignore the r_addend field of R_X86_64_JUMP_SLOT
1145          relocations.  Supported for x86_64.
1146
1147     ‘muldefs’
1148          Allow multiple definitions.
1149
1150     ‘nocopyreloc’
1151          Disable linker generated .dynbss variables used in place of
1152          variables defined in shared libraries.  May result in dynamic
1153          text relocations.
1154
1155     ‘nodefaultlib’
1156          Specify that the dynamic loader search for dependencies of
1157          this object should ignore any default library search paths.
1158
1159     ‘nodelete’
1160          Specify that the object shouldn’t be unloaded at runtime.
1161
1162     ‘nodlopen’
1163          Specify that the object is not available to ‘dlopen’.
1164
1165     ‘nodump’
1166          Specify that the object can not be dumped by ‘dldump’.
1167
1168     ‘noexecstack’
1169          Marks the object as not requiring executable stack.
1170
1171     ‘noextern-protected-data’
1172          Don’t treat protected data symbols as external when building a
1173          shared library.  This option overrides the linker backend
1174          default.  It can be used to work around incorrect relocations
1175          against protected data symbols generated by compiler.  Updates
1176          on protected data symbols by another module aren’t visible to
1177          the resulting shared library.  Supported for i386 and x86-64.
1178
1179     ‘noreloc-overflow’
1180          Disable relocation overflow check.  This can be used to
1181          disable relocation overflow check if there will be no dynamic
1182          relocation overflow at run-time.  Supported for x86_64.
1183
1184     ‘now’
1185          When generating an executable or shared library, mark it to
1186          tell the dynamic linker to resolve all symbols when the
1187          program is started, or when the shared library is loaded by
1188          dlopen, instead of deferring function call resolution to the
1189          point when the function is first called.
1190
1191     ‘origin’
1192          Specify that the object requires ‘$ORIGIN’ handling in paths.
1193
1194     ‘pack-relative-relocs’
1195     ‘nopack-relative-relocs’
1196          Generate compact relative relocation in position-independent
1197          executable and shared library.  It adds ‘DT_RELR’, ‘DT_RELRSZ’
1198          and ‘DT_RELRENT’ entries to the dynamic section.  It is
1199          ignored when building position-dependent executable and
1200          relocatable output.  ‘nopack-relative-relocs’ is the default,
1201          which disables compact relative relocation.  When linked
1202          against the GNU C Library, a GLIBC_ABI_DT_RELR symbol version
1203          dependency on the shared C Library is added to the output.
1204          Supported for i386 and x86-64.
1205
1206     ‘relro’
1207     ‘norelro’
1208          Create an ELF ‘PT_GNU_RELRO’ segment header in the object.
1209          This specifies a memory segment that should be made read-only
1210          after relocation, if supported.  Specifying ‘common-page-size’
1211          smaller than the system page size will render this protection
1212          ineffective.  Don’t create an ELF ‘PT_GNU_RELRO’ segment if
1213          ‘norelro’.
1214
1215     ‘report-relative-reloc’
1216          Report dynamic relative relocations generated by linker.
1217          Supported for Linux/i386 and Linux/x86_64.
1218
1219     ‘sectionheader’
1220     ‘nosectionheader’
1221          Generate section header.  Don’t generate section header if
1222          ‘nosectionheader’ is used.  ‘sectionheader’ is the default.
1223
1224     ‘separate-code’
1225     ‘noseparate-code’
1226          Create separate code ‘PT_LOAD’ segment header in the object.
1227          This specifies a memory segment that should contain only
1228          instructions and must be in wholly disjoint pages from any
1229          other data.  Don’t create separate code ‘PT_LOAD’ segment if
1230          ‘noseparate-code’ is used.
1231
1232     ‘shstk’
1233          Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in
1234          .note.gnu.property section to indicate compatibility with
1235          Intel Shadow Stack.  Supported for Linux/i386 and
1236          Linux/x86_64.
1237
1238     ‘stack-size=VALUE’
1239          Specify a stack size for an ELF ‘PT_GNU_STACK’ segment.
1240          Specifying zero will override any default non-zero sized
1241          ‘PT_GNU_STACK’ segment creation.
1242
1243     ‘start-stop-gc’
1244     ‘nostart-stop-gc’
1245          When ‘--gc-sections’ is in effect, a reference from a retained
1246          section to ‘__start_SECNAME’ or ‘__stop_SECNAME’ causes all
1247          input sections named ‘SECNAME’ to also be retained, if
1248          ‘SECNAME’ is representable as a C identifier and either
1249          ‘__start_SECNAME’ or ‘__stop_SECNAME’ is synthesized by the
1250          linker.  ‘-z start-stop-gc’ disables this effect, allowing
1251          sections to be garbage collected as if the special synthesized
1252          symbols were not defined.  ‘-z start-stop-gc’ has no effect on
1253          a definition of ‘__start_SECNAME’ or ‘__stop_SECNAME’ in an
1254          object file or linker script.  Such a definition will prevent
1255          the linker providing a synthesized ‘__start_SECNAME’ or
1256          ‘__stop_SECNAME’ respectively, and therefore the special
1257          treatment by garbage collection for those references.
1258
1259     ‘start-stop-visibility=VALUE’
1260          Specify the ELF symbol visibility for synthesized
1261          ‘__start_SECNAME’ and ‘__stop_SECNAME’ symbols (*note Input
1262          Section Example::).  VALUE must be exactly ‘default’,
1263          ‘internal’, ‘hidden’, or ‘protected’.  If no ‘-z
1264          start-stop-visibility’ option is given, ‘protected’ is used
1265          for compatibility with historical practice.  However, it’s
1266          highly recommended to use ‘-z start-stop-visibility=hidden’ in
1267          new programs and shared libraries so that these symbols are
1268          not exported between shared objects, which is not usually
1269          what’s intended.
1270
1271     ‘text’
1272     ‘notext’
1273     ‘textoff’
1274          Report an error if DT_TEXTREL is set, i.e., if the
1275          position-independent or shared object has dynamic relocations
1276          in read-only sections.  Don’t report an error if ‘notext’ or
1277          ‘textoff’.
1278
1279     ‘undefs’
1280          Do not report unresolved symbol references from regular object
1281          files, either when creating an executable, or when creating a
1282          shared library.  This option is the inverse of ‘-z defs’.
1283
1284     ‘unique-symbol’
1285     ‘nounique-symbol’
1286          Avoid duplicated local symbol names in the symbol string
1287          table.  Append ".‘number’" to duplicated local symbol names if
1288          ‘unique-symbol’ is used.  ‘nounique-symbol’ is the default.
1289
1290     ‘x86-64-baseline’
1291     ‘x86-64-v2’
1292     ‘x86-64-v3’
1293     ‘x86-64-v4’
1294          Specify the x86-64 ISA level needed in .note.gnu.property
1295          section.  ‘x86-64-baseline’ generates
1296          ‘GNU_PROPERTY_X86_ISA_1_BASELINE’.  ‘x86-64-v2’ generates
1297          ‘GNU_PROPERTY_X86_ISA_1_V2’.  ‘x86-64-v3’ generates
1298          ‘GNU_PROPERTY_X86_ISA_1_V3’.  ‘x86-64-v4’ generates
1299          ‘GNU_PROPERTY_X86_ISA_1_V4’.  Supported for Linux/i386 and
1300          Linux/x86_64.
1301
1302     Other keywords are ignored for Solaris compatibility.
1303
1304‘-( ARCHIVES -)’
1305‘--start-group ARCHIVES --end-group’
1306     The ARCHIVES should be a list of archive files.  They may be either
1307     explicit file names, or ‘-l’ options.
1308
1309     The specified archives are searched repeatedly until no new
1310     undefined references are created.  Normally, an archive is searched
1311     only once in the order that it is specified on the command line.
1312     If a symbol in that archive is needed to resolve an undefined
1313     symbol referred to by an object in an archive that appears later on
1314     the command line, the linker would not be able to resolve that
1315     reference.  By grouping the archives, they will all be searched
1316     repeatedly until all possible references are resolved.
1317
1318     Using this option has a significant performance cost.  It is best
1319     to use it only when there are unavoidable circular references
1320     between two or more archives.
1321
1322‘--accept-unknown-input-arch’
1323‘--no-accept-unknown-input-arch’
1324     Tells the linker to accept input files whose architecture cannot be
1325     recognised.  The assumption is that the user knows what they are
1326     doing and deliberately wants to link in these unknown input files.
1327     This was the default behaviour of the linker, before release 2.14.
1328     The default behaviour from release 2.14 onwards is to reject such
1329     input files, and so the ‘--accept-unknown-input-arch’ option has
1330     been added to restore the old behaviour.
1331
1332‘--as-needed’
1333‘--no-as-needed’
1334     This option affects ELF DT_NEEDED tags for dynamic libraries
1335     mentioned on the command line after the ‘--as-needed’ option.
1336     Normally the linker will add a DT_NEEDED tag for each dynamic
1337     library mentioned on the command line, regardless of whether the
1338     library is actually needed or not.  ‘--as-needed’ causes a
1339     DT_NEEDED tag to only be emitted for a library that _at that point
1340     in the link_ satisfies a non-weak undefined symbol reference from a
1341     regular object file or, if the library is not found in the
1342     DT_NEEDED lists of other needed libraries, a non-weak undefined
1343     symbol reference from another needed dynamic library.  Object files
1344     or libraries appearing on the command line _after_ the library in
1345     question do not affect whether the library is seen as needed.  This
1346     is similar to the rules for extraction of object files from
1347     archives.  ‘--no-as-needed’ restores the default behaviour.
1348
1349     Note: On Linux based systems the ‘--as-needed’ option also has an
1350     affect on the behaviour of the ‘--rpath’ and ‘--rpath-link’
1351     options.  See the description of ‘--rpath-link’ for more details.
1352
1353‘--add-needed’
1354‘--no-add-needed’
1355     These two options have been deprecated because of the similarity of
1356     their names to the ‘--as-needed’ and ‘--no-as-needed’ options.
1357     They have been replaced by ‘--copy-dt-needed-entries’ and
1358     ‘--no-copy-dt-needed-entries’.
1359
1360‘-assert KEYWORD’
1361     This option is ignored for SunOS compatibility.
1362
1363‘-Bdynamic’
1364‘-dy’
1365‘-call_shared’
1366     Link against dynamic libraries.  This is only meaningful on
1367     platforms for which shared libraries are supported.  This option is
1368     normally the default on such platforms.  The different variants of
1369     this option are for compatibility with various systems.  You may
1370     use this option multiple times on the command line: it affects
1371     library searching for ‘-l’ options which follow it.
1372
1373‘-Bgroup’
1374     Set the ‘DF_1_GROUP’ flag in the ‘DT_FLAGS_1’ entry in the dynamic
1375     section.  This causes the runtime linker to handle lookups in this
1376     object and its dependencies to be performed only inside the group.
1377     ‘--unresolved-symbols=report-all’ is implied.  This option is only
1378     meaningful on ELF platforms which support shared libraries.
1379
1380‘-Bstatic’
1381‘-dn’
1382‘-non_shared’
1383‘-static’
1384     Do not link against shared libraries.  This is only meaningful on
1385     platforms for which shared libraries are supported.  The different
1386     variants of this option are for compatibility with various systems.
1387     You may use this option multiple times on the command line: it
1388     affects library searching for ‘-l’ options which follow it.  This
1389     option also implies ‘--unresolved-symbols=report-all’.  This option
1390     can be used with ‘-shared’.  Doing so means that a shared library
1391     is being created but that all of the library’s external references
1392     must be resolved by pulling in entries from static libraries.
1393
1394‘-Bsymbolic’
1395     When creating a shared library, bind references to global symbols
1396     to the definition within the shared library, if any.  Normally, it
1397     is possible for a program linked against a shared library to
1398     override the definition within the shared library.  This option is
1399     only meaningful on ELF platforms which support shared libraries.
1400
1401‘-Bsymbolic-functions’
1402     When creating a shared library, bind references to global function
1403     symbols to the definition within the shared library, if any.  This
1404     option is only meaningful on ELF platforms which support shared
1405     libraries.
1406
1407‘-Bno-symbolic’
1408     This option can cancel previously specified ‘-Bsymbolic’ and
1409     ‘-Bsymbolic-functions’.
1410
1411‘--dynamic-list=DYNAMIC-LIST-FILE’
1412     Specify the name of a dynamic list file to the linker.  This is
1413     typically used when creating shared libraries to specify a list of
1414     global symbols whose references shouldn’t be bound to the
1415     definition within the shared library, or creating dynamically
1416     linked executables to specify a list of symbols which should be
1417     added to the symbol table in the executable.  This option is only
1418     meaningful on ELF platforms which support shared libraries.
1419
1420     The format of the dynamic list is the same as the version node
1421     without scope and node name.  See *note VERSION:: for more
1422     information.
1423
1424‘--dynamic-list-data’
1425     Include all global data symbols to the dynamic list.
1426
1427‘--dynamic-list-cpp-new’
1428     Provide the builtin dynamic list for C++ operator new and delete.
1429     It is mainly useful for building shared libstdc++.
1430
1431‘--dynamic-list-cpp-typeinfo’
1432     Provide the builtin dynamic list for C++ runtime type
1433     identification.
1434
1435‘--check-sections’
1436‘--no-check-sections’
1437     Asks the linker _not_ to check section addresses after they have
1438     been assigned to see if there are any overlaps.  Normally the
1439     linker will perform this check, and if it finds any overlaps it
1440     will produce suitable error messages.  The linker does know about,
1441     and does make allowances for sections in overlays.  The default
1442     behaviour can be restored by using the command-line switch
1443     ‘--check-sections’.  Section overlap is not usually checked for
1444     relocatable links.  You can force checking in that case by using
1445     the ‘--check-sections’ option.
1446
1447‘--copy-dt-needed-entries’
1448‘--no-copy-dt-needed-entries’
1449     This option affects the treatment of dynamic libraries referred to
1450     by DT_NEEDED tags _inside_ ELF dynamic libraries mentioned on the
1451     command line.  Normally the linker won’t add a DT_NEEDED tag to the
1452     output binary for each library mentioned in a DT_NEEDED tag in an
1453     input dynamic library.  With ‘--copy-dt-needed-entries’ specified
1454     on the command line however any dynamic libraries that follow it
1455     will have their DT_NEEDED entries added.  The default behaviour can
1456     be restored with ‘--no-copy-dt-needed-entries’.
1457
1458     This option also has an effect on the resolution of symbols in
1459     dynamic libraries.  With ‘--copy-dt-needed-entries’ dynamic
1460     libraries mentioned on the command line will be recursively
1461     searched, following their DT_NEEDED tags to other libraries, in
1462     order to resolve symbols required by the output binary.  With the
1463     default setting however the searching of dynamic libraries that
1464     follow it will stop with the dynamic library itself.  No DT_NEEDED
1465     links will be traversed to resolve symbols.
1466
1467‘--cref’
1468     Output a cross reference table.  If a linker map file is being
1469     generated, the cross reference table is printed to the map file.
1470     Otherwise, it is printed on the standard output.
1471
1472     The format of the table is intentionally simple, so that it may be
1473     easily processed by a script if necessary.  The symbols are printed
1474     out, sorted by name.  For each symbol, a list of file names is
1475     given.  If the symbol is defined, the first file listed is the
1476     location of the definition.  If the symbol is defined as a common
1477     value then any files where this happens appear next.  Finally any
1478     files that reference the symbol are listed.
1479
1480‘--ctf-variables’
1481‘--no-ctf-variables’
1482     The CTF debuginfo format supports a section which encodes the names
1483     and types of variables found in the program which do not appear in
1484     any symbol table.  These variables clearly cannot be looked up by
1485     address by conventional debuggers, so the space used for their
1486     types and names is usually wasted: the types are usually small but
1487     the names are often not.  ‘--ctf-variables’ causes the generation
1488     of such a section.  The default behaviour can be restored with
1489     ‘--no-ctf-variables’.
1490
1491‘--ctf-share-types=METHOD’
1492     Adjust the method used to share types between translation units in
1493     CTF.
1494
1495     ‘share-unconflicted’
1496          Put all types that do not have ambiguous definitions into the
1497          shared dictionary, where debuggers can easily access them,
1498          even if they only occur in one translation unit.  This is the
1499          default.
1500
1501     ‘share-duplicated’
1502          Put only types that occur in multiple translation units into
1503          the shared dictionary: types with only one definition go into
1504          per-translation-unit dictionaries.  Types with ambiguous
1505          definitions in multiple translation units always go into
1506          per-translation-unit dictionaries.  This tends to make the CTF
1507          larger, but may reduce the amount of CTF in the shared
1508          dictionary.  For very large projects this may speed up opening
1509          the CTF and save memory in the CTF consumer at runtime.
1510
1511‘--no-define-common’
1512     This option inhibits the assignment of addresses to common symbols.
1513     The script command ‘INHIBIT_COMMON_ALLOCATION’ has the same effect.
1514     *Note Miscellaneous Commands::.
1515
1516     The ‘--no-define-common’ option allows decoupling the decision to
1517     assign addresses to Common symbols from the choice of the output
1518     file type; otherwise a non-Relocatable output type forces assigning
1519     addresses to Common symbols.  Using ‘--no-define-common’ allows
1520     Common symbols that are referenced from a shared library to be
1521     assigned addresses only in the main program.  This eliminates the
1522     unused duplicate space in the shared library, and also prevents any
1523     possible confusion over resolving to the wrong duplicate when there
1524     are many dynamic modules with specialized search paths for runtime
1525     symbol resolution.
1526
1527‘--force-group-allocation’
1528     This option causes the linker to place section group members like
1529     normal input sections, and to delete the section groups.  This is
1530     the default behaviour for a final link but this option can be used
1531     to change the behaviour of a relocatable link (‘-r’).  The script
1532     command ‘FORCE_GROUP_ALLOCATION’ has the same effect.  *Note
1533     Miscellaneous Commands::.
1534
1535‘--defsym=SYMBOL=EXPRESSION’
1536     Create a global symbol in the output file, containing the absolute
1537     address given by EXPRESSION.  You may use this option as many times
1538     as necessary to define multiple symbols in the command line.  A
1539     limited form of arithmetic is supported for the EXPRESSION in this
1540     context: you may give a hexadecimal constant or the name of an
1541     existing symbol, or use ‘+’ and ‘-’ to add or subtract hexadecimal
1542     constants or symbols.  If you need more elaborate expressions,
1543     consider using the linker command language from a script (*note
1544     Assignments::).  _Note:_ there should be no white space between
1545     SYMBOL, the equals sign (“<=>”), and EXPRESSION.
1546
1547     The linker processes ‘--defsym’ arguments and ‘-T’ arguments in
1548     order, placing ‘--defsym’ before ‘-T’ will define the symbol before
1549     the linker script from ‘-T’ is processed, while placing ‘--defsym’
1550     after ‘-T’ will define the symbol after the linker script has been
1551     processed.  This difference has consequences for expressions within
1552     the linker script that use the ‘--defsym’ symbols, which order is
1553     correct will depend on what you are trying to achieve.
1554
1555‘--demangle[=STYLE]’
1556‘--no-demangle’
1557     These options control whether to demangle symbol names in error
1558     messages and other output.  When the linker is told to demangle, it
1559     tries to present symbol names in a readable fashion: it strips
1560     leading underscores if they are used by the object file format, and
1561     converts C++ mangled symbol names into user readable names.
1562     Different compilers have different mangling styles.  The optional
1563     demangling style argument can be used to choose an appropriate
1564     demangling style for your compiler.  The linker will demangle by
1565     default unless the environment variable ‘COLLECT_NO_DEMANGLE’ is
1566     set.  These options may be used to override the default.
1567
1568‘-IFILE’
1569‘--dynamic-linker=FILE’
1570     Set the name of the dynamic linker.  This is only meaningful when
1571     generating dynamically linked ELF executables.  The default dynamic
1572     linker is normally correct; don’t use this unless you know what you
1573     are doing.
1574
1575‘--no-dynamic-linker’
1576     When producing an executable file, omit the request for a dynamic
1577     linker to be used at load-time.  This is only meaningful for ELF
1578     executables that contain dynamic relocations, and usually requires
1579     entry point code that is capable of processing these relocations.
1580
1581‘--embedded-relocs’
1582     This option is similar to the ‘--emit-relocs’ option except that
1583     the relocs are stored in a target-specific section.  This option is
1584     only supported by the ‘BFIN’, ‘CR16’ and _M68K_ targets.
1585
1586‘--disable-multiple-abs-defs’
1587     Do not allow multiple definitions with symbols included in filename
1588     invoked by -R or –just-symbols
1589
1590‘--fatal-warnings’
1591‘--no-fatal-warnings’
1592     Treat all warnings as errors.  The default behaviour can be
1593     restored with the option ‘--no-fatal-warnings’.
1594
1595‘-w’
1596‘--no-warnings’
1597     Do not display any warning or error messages.  This overrides
1598     ‘--fatal-warnings’ if it has been enabled.  This option can be used
1599     when it is known that the output binary will not work, but there is
1600     still a need to create it.
1601
1602‘--force-exe-suffix’
1603     Make sure that an output file has a .exe suffix.
1604
1605     If a successfully built fully linked output file does not have a
1606     ‘.exe’ or ‘.dll’ suffix, this option forces the linker to copy the
1607     output file to one of the same name with a ‘.exe’ suffix.  This
1608     option is useful when using unmodified Unix makefiles on a
1609     Microsoft Windows host, since some versions of Windows won’t run an
1610     image unless it ends in a ‘.exe’ suffix.
1611
1612‘--gc-sections’
1613‘--no-gc-sections’
1614     Enable garbage collection of unused input sections.  It is ignored
1615     on targets that do not support this option.  The default behaviour
1616     (of not performing this garbage collection) can be restored by
1617     specifying ‘--no-gc-sections’ on the command line.  Note that
1618     garbage collection for COFF and PE format targets is supported, but
1619     the implementation is currently considered to be experimental.
1620
1621     ‘--gc-sections’ decides which input sections are used by examining
1622     symbols and relocations.  The section containing the entry symbol
1623     and all sections containing symbols undefined on the command-line
1624     will be kept, as will sections containing symbols referenced by
1625     dynamic objects.  Note that when building shared libraries, the
1626     linker must assume that any visible symbol is referenced.  Once
1627     this initial set of sections has been determined, the linker
1628     recursively marks as used any section referenced by their
1629     relocations.  See ‘--entry’, ‘--undefined’, and
1630     ‘--gc-keep-exported’.
1631
1632     This option can be set when doing a partial link (enabled with
1633     option ‘-r’).  In this case the root of symbols kept must be
1634     explicitly specified either by one of the options ‘--entry’,
1635     ‘--undefined’, or ‘--gc-keep-exported’ or by a ‘ENTRY’ command in
1636     the linker script.
1637
1638     As a GNU extension, ELF input sections marked with the
1639     ‘SHF_GNU_RETAIN’ flag will not be garbage collected.
1640
1641‘--print-gc-sections’
1642‘--no-print-gc-sections’
1643     List all sections removed by garbage collection.  The listing is
1644     printed on stderr.  This option is only effective if garbage
1645     collection has been enabled via the ‘--gc-sections’) option.  The
1646     default behaviour (of not listing the sections that are removed)
1647     can be restored by specifying ‘--no-print-gc-sections’ on the
1648     command line.
1649
1650‘--gc-keep-exported’
1651     When ‘--gc-sections’ is enabled, this option prevents garbage
1652     collection of unused input sections that contain global symbols
1653     having default or protected visibility.  This option is intended to
1654     be used for executables where unreferenced sections would otherwise
1655     be garbage collected regardless of the external visibility of
1656     contained symbols.  Note that this option has no effect when
1657     linking shared objects since it is already the default behaviour.
1658     This option is only supported for ELF format targets.
1659
1660‘--print-output-format’
1661     Print the name of the default output format (perhaps influenced by
1662     other command-line options).  This is the string that would appear
1663     in an ‘OUTPUT_FORMAT’ linker script command (*note File
1664     Commands::).
1665
1666‘--print-memory-usage’
1667     Print used size, total size and used size of memory regions created
1668     with the *note MEMORY:: command.  This is useful on embedded
1669     targets to have a quick view of amount of free memory.  The format
1670     of the output has one headline and one line per region.  It is both
1671     human readable and easily parsable by tools.  Here is an example of
1672     an output:
1673
1674          Memory region         Used Size  Region Size  %age Used
1675                       ROM:        256 KB         1 MB     25.00%
1676                       RAM:          32 B         2 GB      0.00%
1677
1678‘--help’
1679     Print a summary of the command-line options on the standard output
1680     and exit.
1681
1682‘--target-help’
1683     Print a summary of all target-specific options on the standard
1684     output and exit.
1685
1686‘-Map=MAPFILE’
1687     Print a link map to the file MAPFILE.  See the description of the
1688     ‘-M’ option, above.  If MAPFILE is just the character ‘-’ then the
1689     map will be written to stdout.
1690
1691     Specifying a directory as MAPFILE causes the linker map to be
1692     written as a file inside the directory.  Normally name of the file
1693     inside the directory is computed as the basename of the OUTPUT file
1694     with ‘.map’ appended.  If however the special character ‘%’ is used
1695     then this will be replaced by the full path of the output file.
1696     Additionally if there are any characters after the % symbol then
1697     ‘.map’ will no longer be appended.
1698
1699           -o foo.exe -Map=bar                  [Creates ./bar]
1700           -o ../dir/foo.exe -Map=bar           [Creates ./bar]
1701           -o foo.exe -Map=../dir               [Creates ../dir/foo.exe.map]
1702           -o ../dir2/foo.exe -Map=../dir       [Creates ../dir/foo.exe.map]
1703           -o foo.exe -Map=%                    [Creates ./foo.exe.map]
1704           -o ../dir/foo.exe -Map=%             [Creates ../dir/foo.exe.map]
1705           -o foo.exe -Map=%.bar                [Creates ./foo.exe.bar]
1706           -o ../dir/foo.exe -Map=%.bar         [Creates ../dir/foo.exe.bar]
1707           -o ../dir2/foo.exe -Map=../dir/%     [Creates ../dir/../dir2/foo.exe.map]
1708           -o ../dir2/foo.exe -Map=../dir/%.bar [Creates ../dir/../dir2/foo.exe.bar]
1709
1710     It is an error to specify more than one ‘%’ character.
1711
1712     If the map file already exists then it will be overwritten by this
1713     operation.
1714
1715‘--no-keep-memory’
1716     ‘ld’ normally optimizes for speed over memory usage by caching the
1717     symbol tables of input files in memory.  This option tells ‘ld’ to
1718     instead optimize for memory usage, by rereading the symbol tables
1719     as necessary.  This may be required if ‘ld’ runs out of memory
1720     space while linking a large executable.
1721
1722‘--no-undefined’
1723‘-z defs’
1724     Report unresolved symbol references from regular object files.
1725     This is done even if the linker is creating a non-symbolic shared
1726     library.  The switch ‘--[no-]allow-shlib-undefined’ controls the
1727     behaviour for reporting unresolved references found in shared
1728     libraries being linked in.
1729
1730     The effects of this option can be reverted by using ‘-z undefs’.
1731
1732‘--allow-multiple-definition’
1733‘-z muldefs’
1734     Normally when a symbol is defined multiple times, the linker will
1735     report a fatal error.  These options allow multiple definitions and
1736     the first definition will be used.
1737
1738‘--allow-shlib-undefined’
1739‘--no-allow-shlib-undefined’
1740     Allows or disallows undefined symbols in shared libraries.  This
1741     switch is similar to ‘--no-undefined’ except that it determines the
1742     behaviour when the undefined symbols are in a shared library rather
1743     than a regular object file.  It does not affect how undefined
1744     symbols in regular object files are handled.
1745
1746     The default behaviour is to report errors for any undefined symbols
1747     referenced in shared libraries if the linker is being used to
1748     create an executable, but to allow them if the linker is being used
1749     to create a shared library.
1750
1751     The reasons for allowing undefined symbol references in shared
1752     libraries specified at link time are that:
1753
1754        • A shared library specified at link time may not be the same as
1755          the one that is available at load time, so the symbol might
1756          actually be resolvable at load time.
1757        • There are some operating systems, eg BeOS and HPPA, where
1758          undefined symbols in shared libraries are normal.
1759
1760          The BeOS kernel for example patches shared libraries at load
1761          time to select whichever function is most appropriate for the
1762          current architecture.  This is used, for example, to
1763          dynamically select an appropriate memset function.
1764
1765‘--error-handling-script=SCRIPTNAME’
1766     If this option is provided then the linker will invoke SCRIPTNAME
1767     whenever an error is encountered.  Currently however only two kinds
1768     of error are supported: missing symbols and missing libraries.  Two
1769     arguments will be passed to script: the keyword “undefined-symbol”
1770     or ‘missing-lib” and the NAME of the undefined symbol or missing
1771     library.  The intention is that the script will provide suggestions
1772     to the user as to where the symbol or library might be found.
1773     After the script has finished then the normal linker error message
1774     will be displayed.
1775
1776     The availability of this option is controlled by a configure time
1777     switch, so it may not be present in specific implementations.
1778
1779‘--no-undefined-version’
1780     Normally when a symbol has an undefined version, the linker will
1781     ignore it.  This option disallows symbols with undefined version
1782     and a fatal error will be issued instead.
1783
1784‘--default-symver’
1785     Create and use a default symbol version (the soname) for
1786     unversioned exported symbols.
1787
1788‘--default-imported-symver’
1789     Create and use a default symbol version (the soname) for
1790     unversioned imported symbols.
1791
1792‘--no-warn-mismatch’
1793     Normally ‘ld’ will give an error if you try to link together input
1794     files that are mismatched for some reason, perhaps because they
1795     have been compiled for different processors or for different
1796     endiannesses.  This option tells ‘ld’ that it should silently
1797     permit such possible errors.  This option should only be used with
1798     care, in cases when you have taken some special action that ensures
1799     that the linker errors are inappropriate.
1800
1801‘--no-warn-search-mismatch’
1802     Normally ‘ld’ will give a warning if it finds an incompatible
1803     library during a library search.  This option silences the warning.
1804
1805‘--no-whole-archive’
1806     Turn off the effect of the ‘--whole-archive’ option for subsequent
1807     archive files.
1808
1809‘--noinhibit-exec’
1810     Retain the executable output file whenever it is still usable.
1811     Normally, the linker will not produce an output file if it
1812     encounters errors during the link process; it exits without writing
1813     an output file when it issues any error whatsoever.
1814
1815‘-nostdlib’
1816     Only search library directories explicitly specified on the command
1817     line.  Library directories specified in linker scripts (including
1818     linker scripts specified on the command line) are ignored.
1819
1820‘--oformat=OUTPUT-FORMAT’
1821     ‘ld’ may be configured to support more than one kind of object
1822     file.  If your ‘ld’ is configured this way, you can use the
1823     ‘--oformat’ option to specify the binary format for the output
1824     object file.  Even when ‘ld’ is configured to support alternative
1825     object formats, you don’t usually need to specify this, as ‘ld’
1826     should be configured to produce as a default output format the most
1827     usual format on each machine.  OUTPUT-FORMAT is a text string, the
1828     name of a particular format supported by the BFD libraries.  (You
1829     can list the available binary formats with ‘objdump -i’.)  The
1830     script command ‘OUTPUT_FORMAT’ can also specify the output format,
1831     but this option overrides it.  *Note BFD::.
1832
1833‘--out-implib FILE’
1834     Create an import library in FILE corresponding to the executable
1835     the linker is generating (eg.  a DLL or ELF program).  This import
1836     library (which should be called ‘*.dll.a’ or ‘*.a’ for DLLs) may be
1837     used to link clients against the generated executable; this
1838     behaviour makes it possible to skip a separate import library
1839     creation step (eg.  ‘dlltool’ for DLLs).  This option is only
1840     available for the i386 PE and ELF targetted ports of the linker.
1841
1842‘-pie’
1843‘--pic-executable’
1844     Create a position independent executable.  This is currently only
1845     supported on ELF platforms.  Position independent executables are
1846     similar to shared libraries in that they are relocated by the
1847     dynamic linker to the virtual address the OS chooses for them
1848     (which can vary between invocations).  Like normal dynamically
1849     linked executables they can be executed and symbols defined in the
1850     executable cannot be overridden by shared libraries.
1851
1852‘-no-pie’
1853     Create a position dependent executable.  This is the default.
1854
1855‘-qmagic’
1856     This option is ignored for Linux compatibility.
1857
1858‘-Qy’
1859     This option is ignored for SVR4 compatibility.
1860
1861‘--relax’
1862‘--no-relax’
1863     An option with machine dependent effects.  This option is only
1864     supported on a few targets.  *Note ‘ld’ and the H8/300: H8/300.
1865     *Note ‘ld’ and Xtensa Processors: Xtensa.  *Note ‘ld’ and the
1866     68HC11 and 68HC12: M68HC11/68HC12.  *Note ‘ld’ and the Altera Nios
1867     II: Nios II. *Note ‘ld’ and PowerPC 32-bit ELF Support: PowerPC
1868     ELF32.
1869
1870     On some platforms the ‘--relax’ option performs target specific,
1871     global optimizations that become possible when the linker resolves
1872     addressing in the program, such as relaxing address modes,
1873     synthesizing new instructions, selecting shorter version of current
1874     instructions, and combining constant values.
1875
1876     On some platforms these link time global optimizations may make
1877     symbolic debugging of the resulting executable impossible.  This is
1878     known to be the case for the Matsushita MN10200 and MN10300 family
1879     of processors.
1880
1881     On platforms where the feature is supported, the option
1882     ‘--no-relax’ will disable it.
1883
1884     On platforms where the feature is not supported, both ‘--relax’ and
1885     ‘--no-relax’ are accepted, but ignored.
1886
1887‘--retain-symbols-file=FILENAME’
1888     Retain _only_ the symbols listed in the file FILENAME, discarding
1889     all others.  FILENAME is simply a flat file, with one symbol name
1890     per line.  This option is especially useful in environments (such
1891     as VxWorks) where a large global symbol table is accumulated
1892     gradually, to conserve run-time memory.
1893
1894     ‘--retain-symbols-file’ does _not_ discard undefined symbols, or
1895     symbols needed for relocations.
1896
1897     You may only specify ‘--retain-symbols-file’ once in the command
1898     line.  It overrides ‘-s’ and ‘-S’.
1899
1900‘-rpath=DIR’
1901     Add a directory to the runtime library search path.  This is used
1902     when linking an ELF executable with shared objects.  All ‘-rpath’
1903     arguments are concatenated and passed to the runtime linker, which
1904     uses them to locate shared objects at runtime.
1905
1906     The ‘-rpath’ option is also used when locating shared objects which
1907     are needed by shared objects explicitly included in the link; see
1908     the description of the ‘-rpath-link’ option.  Searching ‘-rpath’ in
1909     this way is only supported by native linkers and cross linkers
1910     which have been configured with the ‘--with-sysroot’ option.
1911
1912     If ‘-rpath’ is not used when linking an ELF executable, the
1913     contents of the environment variable ‘LD_RUN_PATH’ will be used if
1914     it is defined.
1915
1916     The ‘-rpath’ option may also be used on SunOS. By default, on
1917     SunOS, the linker will form a runtime search path out of all the
1918     ‘-L’ options it is given.  If a ‘-rpath’ option is used, the
1919     runtime search path will be formed exclusively using the ‘-rpath’
1920     options, ignoring the ‘-L’ options.  This can be useful when using
1921     gcc, which adds many ‘-L’ options which may be on NFS mounted file
1922     systems.
1923
1924     For compatibility with other ELF linkers, if the ‘-R’ option is
1925     followed by a directory name, rather than a file name, it is
1926     treated as the ‘-rpath’ option.
1927
1928‘-rpath-link=DIR’
1929     When using ELF or SunOS, one shared library may require another.
1930     This happens when an ‘ld -shared’ link includes a shared library as
1931     one of the input files.
1932
1933     When the linker encounters such a dependency when doing a
1934     non-shared, non-relocatable link, it will automatically try to
1935     locate the required shared library and include it in the link, if
1936     it is not included explicitly.  In such a case, the ‘-rpath-link’
1937     option specifies the first set of directories to search.  The
1938     ‘-rpath-link’ option may specify a sequence of directory names
1939     either by specifying a list of names separated by colons, or by
1940     appearing multiple times.
1941
1942     The tokens $ORIGIN and $LIB can appear in these search directories.
1943     They will be replaced by the full path to the directory containing
1944     the program or shared object in the case of $ORIGIN and either
1945     ‘lib’ - for 32-bit binaries - or ‘lib64’ - for 64-bit binaries - in
1946     the case of $LIB.
1947
1948     The alternative form of these tokens - ${ORIGIN} and ${LIB} can
1949     also be used.  The token $PLATFORM is not supported.
1950
1951     This option should be used with caution as it overrides the search
1952     path that may have been hard compiled into a shared library.  In
1953     such a case it is possible to use unintentionally a different
1954     search path than the runtime linker would do.
1955
1956     The linker uses the following search paths to locate required
1957     shared libraries:
1958
1959       1. Any directories specified by ‘-rpath-link’ options.
1960       2. Any directories specified by ‘-rpath’ options.  The difference
1961          between ‘-rpath’ and ‘-rpath-link’ is that directories
1962          specified by ‘-rpath’ options are included in the executable
1963          and used at runtime, whereas the ‘-rpath-link’ option is only
1964          effective at link time.  Searching ‘-rpath’ in this way is
1965          only supported by native linkers and cross linkers which have
1966          been configured with the ‘--with-sysroot’ option.
1967       3. On an ELF system, for native linkers, if the ‘-rpath’ and
1968          ‘-rpath-link’ options were not used, search the contents of
1969          the environment variable ‘LD_RUN_PATH’.
1970       4. On SunOS, if the ‘-rpath’ option was not used, search any
1971          directories specified using ‘-L’ options.
1972       5. For a native linker, search the contents of the environment
1973          variable ‘LD_LIBRARY_PATH’.
1974       6. For a native ELF linker, the directories in ‘DT_RUNPATH’ or
1975          ‘DT_RPATH’ of a shared library are searched for shared
1976          libraries needed by it.  The ‘DT_RPATH’ entries are ignored if
1977          ‘DT_RUNPATH’ entries exist.
1978       7. For a linker for a Linux system, if the file ‘/etc/ld.so.conf1979          exists, the list of directories found in that file.  Note: the
1980          path to this file is prefixed with the ‘sysroot’ value, if
1981          that is defined, and then any ‘prefix’ string if the linker
1982          was configured with the ‘--prefix=<path>’ option.
1983       8. For a native linker on a FreeBSD system, any directories
1984          specified by the ‘_PATH_ELF_HINTS’ macro defined in the
1985elf-hints.h’ header file.
1986       9. Any directories specified by a ‘SEARCH_DIR’ command in a
1987          linker script given on the command line, including scripts
1988          specified by ‘-T’ (but not ‘-dT’).
1989       10. The default directories, normally ‘/lib’ and ‘/usr/lib’.
1990       11. Any directories specified by a plugin
1991          LDPT_SET_EXTRA_LIBRARY_PATH.
1992       12. Any directories specified by a ‘SEARCH_DIR’ command in a
1993          default linker script.
1994
1995     Note however on Linux based systems there is an additional caveat:
1996     If the ‘--as-needed’ option is active _and_ a shared library is
1997     located which would normally satisfy the search _and_ this library
1998     does not have DT_NEEDED tag for ‘libc.so’ _and_ there is a shared
1999     library later on in the set of search directories which also
2000     satisfies the search _and_ this second shared library does have a
2001     DT_NEEDED tag for ‘libc.so’ _then_ the second library will be
2002     selected instead of the first.
2003
2004     If the required shared library is not found, the linker will issue
2005     a warning and continue with the link.
2006
2007‘-shared’
2008‘-Bshareable’
2009     Create a shared library.  This is currently only supported on ELF,
2010     XCOFF and SunOS platforms.  On SunOS, the linker will automatically
2011     create a shared library if the ‘-e’ option is not used and there
2012     are undefined symbols in the link.
2013
2014‘--sort-common’
2015‘--sort-common=ascending’
2016‘--sort-common=descending’
2017     This option tells ‘ld’ to sort the common symbols by alignment in
2018     ascending or descending order when it places them in the
2019     appropriate output sections.  The symbol alignments considered are
2020     sixteen-byte or larger, eight-byte, four-byte, two-byte, and
2021     one-byte.  This is to prevent gaps between symbols due to alignment
2022     constraints.  If no sorting order is specified, then descending
2023     order is assumed.
2024
2025‘--sort-section=name’
2026     This option will apply ‘SORT_BY_NAME’ to all wildcard section
2027     patterns in the linker script.
2028
2029‘--sort-section=alignment’
2030     This option will apply ‘SORT_BY_ALIGNMENT’ to all wildcard section
2031     patterns in the linker script.
2032
2033‘--spare-dynamic-tags=COUNT’
2034     This option specifies the number of empty slots to leave in the
2035     .dynamic section of ELF shared objects.  Empty slots may be needed
2036     by post processing tools, such as the prelinker.  The default is 5.
2037
2038‘--split-by-file[=SIZE]’
2039     Similar to ‘--split-by-reloc’ but creates a new output section for
2040     each input file when SIZE is reached.  SIZE defaults to a size of 1
2041     if not given.
2042
2043‘--split-by-reloc[=COUNT]’
2044     Tries to creates extra sections in the output file so that no
2045     single output section in the file contains more than COUNT
2046     relocations.  This is useful when generating huge relocatable files
2047     for downloading into certain real time kernels with the COFF object
2048     file format; since COFF cannot represent more than 65535
2049     relocations in a single section.  Note that this will fail to work
2050     with object file formats which do not support arbitrary sections.
2051     The linker will not split up individual input sections for
2052     redistribution, so if a single input section contains more than
2053     COUNT relocations one output section will contain that many
2054     relocations.  COUNT defaults to a value of 32768.
2055
2056‘--stats’
2057     Compute and display statistics about the operation of the linker,
2058     such as execution time and memory usage.
2059
2060‘--sysroot=DIRECTORY’
2061     Use DIRECTORY as the location of the sysroot, overriding the
2062     configure-time default.  This option is only supported by linkers
2063     that were configured using ‘--with-sysroot’.
2064
2065‘--task-link’
2066     This is used by COFF/PE based targets to create a task-linked
2067     object file where all of the global symbols have been converted to
2068     statics.
2069
2070‘--traditional-format’
2071     For some targets, the output of ‘ld’ is different in some ways from
2072     the output of some existing linker.  This switch requests ‘ld’ to
2073     use the traditional format instead.
2074
2075     For example, on SunOS, ‘ld’ combines duplicate entries in the
2076     symbol string table.  This can reduce the size of an output file
2077     with full debugging information by over 30 percent.  Unfortunately,
2078     the SunOS ‘dbx’ program can not read the resulting program (‘gdb’
2079     has no trouble).  The ‘--traditional-format’ switch tells ‘ld’ to
2080     not combine duplicate entries.
2081
2082‘--section-start=SECTIONNAME=ORG’
2083     Locate a section in the output file at the absolute address given
2084     by ORG.  You may use this option as many times as necessary to
2085     locate multiple sections in the command line.  ORG must be a single
2086     hexadecimal integer; for compatibility with other linkers, you may
2087     omit the leading ‘0x’ usually associated with hexadecimal values.
2088     _Note:_ there should be no white space between SECTIONNAME, the
2089     equals sign (“<=>”), and ORG.
2090
2091‘-Tbss=ORG’
2092‘-Tdata=ORG’
2093‘-Ttext=ORG’
2094     Same as ‘--section-start’, with ‘.bss’, ‘.data’ or ‘.text’ as the
2095     SECTIONNAME.
2096
2097‘-Ttext-segment=ORG’
2098     When creating an ELF executable, it will set the address of the
2099     first byte of the text segment.
2100
2101‘-Trodata-segment=ORG’
2102     When creating an ELF executable or shared object for a target where
2103     the read-only data is in its own segment separate from the
2104     executable text, it will set the address of the first byte of the
2105     read-only data segment.
2106
2107‘-Tldata-segment=ORG’
2108     When creating an ELF executable or shared object for x86-64 medium
2109     memory model, it will set the address of the first byte of the
2110     ldata segment.
2111
2112‘--unresolved-symbols=METHOD’
2113     Determine how to handle unresolved symbols.  There are four
2114     possible values for ‘method’:
2115
2116     ‘ignore-all’
2117          Do not report any unresolved symbols.
2118
2119     ‘report-all’
2120          Report all unresolved symbols.  This is the default.
2121
2122     ‘ignore-in-object-files’
2123          Report unresolved symbols that are contained in shared
2124          libraries, but ignore them if they come from regular object
2125          files.
2126
2127     ‘ignore-in-shared-libs’
2128          Report unresolved symbols that come from regular object files,
2129          but ignore them if they come from shared libraries.  This can
2130          be useful when creating a dynamic binary and it is known that
2131          all the shared libraries that it should be referencing are
2132          included on the linker’s command line.
2133
2134     The behaviour for shared libraries on their own can also be
2135     controlled by the ‘--[no-]allow-shlib-undefined’ option.
2136
2137     Normally the linker will generate an error message for each
2138     reported unresolved symbol but the option
2139     ‘--warn-unresolved-symbols’ can change this to a warning.
2140
2141‘--dll-verbose’
2142‘--verbose[=NUMBER]’
2143     Display the version number for ‘ld’ and list the linker emulations
2144     supported.  Display which input files can and cannot be opened.
2145     Display the linker script being used by the linker.  If the
2146     optional NUMBER argument > 1, plugin symbol status will also be
2147     displayed.
2148
2149‘--version-script=VERSION-SCRIPTFILE’
2150     Specify the name of a version script to the linker.  This is
2151     typically used when creating shared libraries to specify additional
2152     information about the version hierarchy for the library being
2153     created.  This option is only fully supported on ELF platforms
2154     which support shared libraries; see *note VERSION::.  It is
2155     partially supported on PE platforms, which can use version scripts
2156     to filter symbol visibility in auto-export mode: any symbols marked
2157     ‘local’ in the version script will not be exported.  *Note WIN32::.
2158
2159‘--warn-common’
2160     Warn when a common symbol is combined with another common symbol or
2161     with a symbol definition.  Unix linkers allow this somewhat sloppy
2162     practice, but linkers on some other operating systems do not.  This
2163     option allows you to find potential problems from combining global
2164     symbols.  Unfortunately, some C libraries use this practice, so you
2165     may get some warnings about symbols in the libraries as well as in
2166     your programs.
2167
2168     There are three kinds of global symbols, illustrated here by C
2169     examples:
2170
2171     ‘int i = 1;’
2172          A definition, which goes in the initialized data section of
2173          the output file.
2174
2175     ‘extern int i;’
2176          An undefined reference, which does not allocate space.  There
2177          must be either a definition or a common symbol for the
2178          variable somewhere.
2179
2180     ‘int i;’
2181          A common symbol.  If there are only (one or more) common
2182          symbols for a variable, it goes in the uninitialized data area
2183          of the output file.  The linker merges multiple common symbols
2184          for the same variable into a single symbol.  If they are of
2185          different sizes, it picks the largest size.  The linker turns
2186          a common symbol into a declaration, if there is a definition
2187          of the same variable.
2188
2189     The ‘--warn-common’ option can produce five kinds of warnings.
2190     Each warning consists of a pair of lines: the first describes the
2191     symbol just encountered, and the second describes the previous
2192     symbol encountered with the same name.  One or both of the two
2193     symbols will be a common symbol.
2194
2195       1. Turning a common symbol into a reference, because there is
2196          already a definition for the symbol.
2197               FILE(SECTION): warning: common of `SYMBOL'
2198                  overridden by definition
2199               FILE(SECTION): warning: defined here
2200
2201       2. Turning a common symbol into a reference, because a later
2202          definition for the symbol is encountered.  This is the same as
2203          the previous case, except that the symbols are encountered in
2204          a different order.
2205               FILE(SECTION): warning: definition of `SYMBOL'
2206                  overriding common
2207               FILE(SECTION): warning: common is here
2208
2209       3. Merging a common symbol with a previous same-sized common
2210          symbol.
2211               FILE(SECTION): warning: multiple common
2212                  of `SYMBOL'
2213               FILE(SECTION): warning: previous common is here
2214
2215       4. Merging a common symbol with a previous larger common symbol.
2216               FILE(SECTION): warning: common of `SYMBOL'
2217                  overridden by larger common
2218               FILE(SECTION): warning: larger common is here
2219
2220       5. Merging a common symbol with a previous smaller common symbol.
2221          This is the same as the previous case, except that the symbols
2222          are encountered in a different order.
2223               FILE(SECTION): warning: common of `SYMBOL'
2224                  overriding smaller common
2225               FILE(SECTION): warning: smaller common is here
2226
2227‘--warn-constructors’
2228     Warn if any global constructors are used.  This is only useful for
2229     a few object file formats.  For formats like COFF or ELF, the
2230     linker can not detect the use of global constructors.
2231
2232‘--warn-execstack’
2233‘--warn-execstack-objects’
2234‘--no-warn-execstack’
2235     On ELF platforms the linker may generate warning messages if it is
2236     asked to create an output file that contains an executable stack.
2237     There are three possible states:
2238       1. Do not generate any warnings.
2239       2. Always generate warnings, even if the executable stack is
2240          requested via the ‘-z execstack’ command line option.
2241       3. Only generate a warning if an object file requests an
2242          executable stack, but not if the ‘-z execstack’ option is
2243          used.
2244
2245     The default state depends upon how the linker was configured when
2246     it was built.  The ‘--no-warn-execstack’ option always puts the
2247     linker into the no-warnings state.  The ‘--warn-execstack’ option
2248     puts the linker into the warn-always state.  The
2249     ‘--warn-execstack-objects’ option puts the linker into the
2250     warn-for-object-files-only state.
2251
2252     Note: ELF format input files can specify that they need an
2253     executable stack by having a .NOTE.GNU-STACK section with the
2254     executable bit set in its section flags.  They can specify that
2255     they do not need an executable stack by having the same section,
2256     but without the executable flag bit set.  If an input file does not
2257     have a .NOTE.GNU-STACK section then the default behaviour is target
2258     specific.  For some targets, then absence of such a section implies
2259     that an executable stack _is_ required.  This is often a problem
2260     for hand crafted assembler files.
2261
2262‘--error-execstack’
2263‘--no-error-execstack’
2264     If the linker is going to generate a warning message about an
2265     executable stack then the ‘--error-execstack’ option will instead
2266     change that warning into an error.  Note - this option does not
2267     change the linker’s execstack warning generation state.  Use
2268     ‘--warn-execstack’ or ‘--warn-execstack-objects’ to set a specific
2269     warning state.
2270
2271     The ‘--no-error-execstack’ option will restore the default
2272     behaviour of generating warning messages.
2273
2274‘--warn-multiple-gp’
2275     Warn if multiple global pointer values are required in the output
2276     file.  This is only meaningful for certain processors, such as the
2277     Alpha.  Specifically, some processors put large-valued constants in
2278     a special section.  A special register (the global pointer) points
2279     into the middle of this section, so that constants can be loaded
2280     efficiently via a base-register relative addressing mode.  Since
2281     the offset in base-register relative mode is fixed and relatively
2282     small (e.g., 16 bits), this limits the maximum size of the constant
2283     pool.  Thus, in large programs, it is often necessary to use
2284     multiple global pointer values in order to be able to address all
2285     possible constants.  This option causes a warning to be issued
2286     whenever this case occurs.
2287
2288‘--warn-once’
2289     Only warn once for each undefined symbol, rather than once per
2290     module which refers to it.
2291
2292‘--warn-rwx-segments’
2293‘--no-warn-rwx-segments’
2294     Warn if the linker creates a loadable, non-zero sized segment that
2295     has all three of the read, write and execute permission flags set.
2296     Such a segment represents a potential security vulnerability.  In
2297     addition warnings will be generated if a thread local storage
2298     segment is created with the execute permission flag set, regardless
2299     of whether or not it has the read and/or write flags set.
2300
2301     These warnings are enabled by default.  They can be disabled via
2302     the ‘--no-warn-rwx-segments’ option and re-enabled via the
2303     ‘--warn-rwx-segments’ option.
2304
2305‘--error-rwx-segments’
2306‘--no-error-rwx-segments’
2307     If the linker is going to generate a warning message about an
2308     executable, writeable segment, or an executable TLS segment, then
2309     the ‘--error-rwx-segments’ option will turn this warning into an
2310     error instead.  The ‘--no-error-rwx-segments’ option will restore
2311     the default behaviour of just generating a warning message.
2312
2313     Note - the ‘--error-rwx-segments’ option does not by itself turn on
2314     warnings about these segments.  These warnings are either enabled
2315     by default, if the linker was configured that way, or via the
2316     ‘--warn-rwx-segments’ command line option.
2317
2318‘--warn-section-align’
2319     Warn if the address of an output section is changed because of
2320     alignment.  Typically, the alignment will be set by an input
2321     section.  The address will only be changed if it not explicitly
2322     specified; that is, if the ‘SECTIONS’ command does not specify a
2323     start address for the section (*note SECTIONS::).
2324
2325‘--warn-textrel’
2326     Warn if the linker adds DT_TEXTREL to a position-independent
2327     executable or shared object.
2328
2329‘--warn-alternate-em’
2330     Warn if an object has alternate ELF machine code.
2331
2332‘--warn-unresolved-symbols’
2333     If the linker is going to report an unresolved symbol (see the
2334     option ‘--unresolved-symbols’) it will normally generate an error.
2335     This option makes it generate a warning instead.
2336
2337‘--error-unresolved-symbols’
2338     This restores the linker’s default behaviour of generating errors
2339     when it is reporting unresolved symbols.
2340
2341‘--whole-archive’
2342     For each archive mentioned on the command line after the
2343     ‘--whole-archive’ option, include every object file in the archive
2344     in the link, rather than searching the archive for the required
2345     object files.  This is normally used to turn an archive file into a
2346     shared library, forcing every object to be included in the
2347     resulting shared library.  This option may be used more than once.
2348
2349     Two notes when using this option from gcc: First, gcc doesn’t know
2350     about this option, so you have to use ‘-Wl,-whole-archive’.
2351     Second, don’t forget to use ‘-Wl,-no-whole-archive’ after your list
2352     of archives, because gcc will add its own list of archives to your
2353     link and you may not want this flag to affect those as well.
2354
2355‘--wrap=SYMBOL’
2356     Use a wrapper function for SYMBOL.  Any undefined reference to
2357     SYMBOL will be resolved to ‘__wrap_SYMBOL’.  Any undefined
2358     reference to ‘__real_SYMBOL’ will be resolved to SYMBOL.
2359
2360     This can be used to provide a wrapper for a system function.  The
2361     wrapper function should be called ‘__wrap_SYMBOL’.  If it wishes to
2362     call the system function, it should call ‘__real_SYMBOL’.
2363
2364     Here is a trivial example:
2365
2366          void *
2367          __wrap_malloc (size_t c)
2368          {
2369            printf ("malloc called with %zu\n", c);
2370            return __real_malloc (c);
2371          }
2372
2373     If you link other code with this file using ‘--wrap malloc’, then
2374     all calls to ‘malloc’ will call the function ‘__wrap_malloc’
2375     instead.  The call to ‘__real_malloc’ in ‘__wrap_malloc’ will call
2376     the real ‘malloc’ function.
2377
2378     You may wish to provide a ‘__real_malloc’ function as well, so that
2379     links without the ‘--wrap’ option will succeed.  If you do this,
2380     you should not put the definition of ‘__real_malloc’ in the same
2381     file as ‘__wrap_malloc’; if you do, the assembler may resolve the
2382     call before the linker has a chance to wrap it to ‘malloc’.
2383
2384     Only undefined references are replaced by the linker.  So,
2385     translation unit internal references to SYMBOL are not resolved to
2386     ‘__wrap_SYMBOL’.  In the next example, the call to ‘f’ in ‘g’ is
2387     not resolved to ‘__wrap_f’.
2388
2389          int
2390          f (void)
2391          {
2392            return 123;
2393          }
2394
2395          int
2396          g (void)
2397          {
2398            return f();
2399          }
2400
2401‘--eh-frame-hdr’
2402‘--no-eh-frame-hdr’
2403     Request (‘--eh-frame-hdr’) or suppress (‘--no-eh-frame-hdr’) the
2404     creation of ‘.eh_frame_hdr’ section and ELF ‘PT_GNU_EH_FRAME’
2405     segment header.
2406
2407‘--no-ld-generated-unwind-info’
2408     Request creation of ‘.eh_frame’ unwind info for linker generated
2409     code sections like PLT. This option is on by default if linker
2410     generated unwind info is supported.  This option also controls the
2411     generation of ‘.sframe’ stack trace info for linker generated code
2412     sections like PLT.
2413
2414‘--enable-new-dtags’
2415‘--disable-new-dtags’
2416     This linker can create the new dynamic tags in ELF. But the older
2417     ELF systems may not understand them.  If you specify
2418     ‘--enable-new-dtags’, the new dynamic tags will be created as
2419     needed and older dynamic tags will be omitted.  If you specify
2420     ‘--disable-new-dtags’, no new dynamic tags will be created.  By
2421     default, the new dynamic tags are not created.  Note that those
2422     options are only available for ELF systems.
2423
2424‘--hash-size=NUMBER’
2425     Set the default size of the linker’s hash tables to a prime number
2426     close to NUMBER.  Increasing this value can reduce the length of
2427     time it takes the linker to perform its tasks, at the expense of
2428     increasing the linker’s memory requirements.  Similarly reducing
2429     this value can reduce the memory requirements at the expense of
2430     speed.
2431
2432‘--hash-style=STYLE’
2433     Set the type of linker’s hash table(s).  STYLE can be either ‘sysv’
2434     for classic ELF ‘.hash’ section, ‘gnu’ for new style GNU
2435.gnu.hash’ section or ‘both’ for both the classic ELF ‘.hash’ and
2436     new style GNU ‘.gnu.hash’ hash tables.  The default depends upon
2437     how the linker was configured, but for most Linux based systems it
2438     will be ‘both’.
2439
2440‘--compress-debug-sections=none’
2441‘--compress-debug-sections=zlib’
2442‘--compress-debug-sections=zlib-gnu’
2443‘--compress-debug-sections=zlib-gabi’
2444‘--compress-debug-sections=zstd’
2445     On ELF platforms, these options control how DWARF debug sections
2446     are compressed using zlib.
2447
2448     ‘--compress-debug-sections=none’ doesn’t compress DWARF debug
2449     sections.  ‘--compress-debug-sections=zlib-gnu’ compresses DWARF
2450     debug sections and renames them to begin with ‘.zdebug’ instead of
2451     ‘.debug’.  ‘--compress-debug-sections=zlib-gabi’ also compresses
2452     DWARF debug sections, but rather than renaming them it sets the
2453     SHF_COMPRESSED flag in the sections’ headers.
2454
2455     The ‘--compress-debug-sections=zlib’ option is an alias for
2456     ‘--compress-debug-sections=zlib-gabi’.
2457
2458     ‘--compress-debug-sections=zstd’ compresses DWARF debug sections
2459     using zstd.
2460
2461     Note that this option overrides any compression in input debug
2462     sections, so if a binary is linked with
2463     ‘--compress-debug-sections=none’ for example, then any compressed
2464     debug sections in input files will be uncompressed before they are
2465     copied into the output binary.
2466
2467     The default compression behaviour varies depending upon the target
2468     involved and the configure options used to build the toolchain.
2469     The default can be determined by examining the output from the
2470     linker’s ‘--help’ option.
2471
2472‘--reduce-memory-overheads’
2473     This option reduces memory requirements at ld runtime, at the
2474     expense of linking speed.  This was introduced to select the old
2475     O(n^2) algorithm for link map file generation, rather than the new
2476     O(n) algorithm which uses about 40% more memory for symbol storage.
2477
2478     Another effect of the switch is to set the default hash table size
2479     to 1021, which again saves memory at the cost of lengthening the
2480     linker’s run time.  This is not done however if the ‘--hash-size’
2481     switch has been used.
2482
2483     The ‘--reduce-memory-overheads’ switch may be also be used to
2484     enable other tradeoffs in future versions of the linker.
2485
2486‘--max-cache-size=SIZE’
2487     ‘ld’ normally caches the relocation information and symbol tables
2488     of input files in memory with the unlimited size.  This option sets
2489     the maximum cache size to SIZE.
2490
2491‘--build-id’
2492‘--build-id=STYLE’
2493     Request the creation of a ‘.note.gnu.build-id’ ELF note section or
2494     a ‘.buildid’ COFF section.  The contents of the note are unique
2495     bits identifying this linked file.  STYLE can be ‘uuid’ to use 128
2496     random bits, ‘sha1’ to use a 160-bit SHA1 hash on the normative
2497     parts of the output contents, ‘md5’ to use a 128-bit MD5 hash on
2498     the normative parts of the output contents, or ‘0xHEXSTRING’ to use
2499     a chosen bit string specified as an even number of hexadecimal
2500     digits (‘-’ and ‘:’ characters between digit pairs are ignored).
2501     If STYLE is omitted, ‘sha1’ is used.
2502
2503     The ‘md5’ and ‘sha1’ styles produces an identifier that is always
2504     the same in an identical output file, but will be unique among all
2505     nonidentical output files.  It is not intended to be compared as a
2506     checksum for the file’s contents.  A linked file may be changed
2507     later by other tools, but the build ID bit string identifying the
2508     original linked file does not change.
2509
2510     Passing ‘none’ for STYLE disables the setting from any ‘--build-id’
2511     options earlier on the command line.
2512
2513‘--package-metadata=JSON’
2514     Request the creation of a ‘.note.package’ ELF note section.  The
2515     contents of the note are in JSON format, as per the package
2516     metadata specification.  For more information see:
2517     https://systemd.io/ELF_PACKAGE_METADATA/ If the JSON argument is
2518     missing/empty then this will disable the creation of the metadata
2519     note, if one had been enabled by an earlier occurrence of the
2520     –package-metadata option.  If the linker has been built with
2521     libjansson, then the JSON string will be validated.
2522
25232.1.1 Options Specific to i386 PE Targets
2524-----------------------------------------
2525
2526The i386 PE linker supports the ‘-shared’ option, which causes the
2527output to be a dynamically linked library (DLL) instead of a normal
2528executable.  You should name the output ‘*.dll’ when you use this
2529option.  In addition, the linker fully supports the standard ‘*.def’
2530files, which may be specified on the linker command line like an object
2531file (in fact, it should precede archives it exports symbols from, to
2532ensure that they get linked in, just like a normal object file).
2533
2534   In addition to the options common to all targets, the i386 PE linker
2535support additional command-line options that are specific to the i386 PE
2536target.  Options that take values may be separated from their values by
2537either a space or an equals sign.
2538
2539‘--add-stdcall-alias’
2540     If given, symbols with a stdcall suffix (@NN) will be exported
2541     as-is and also with the suffix stripped.  [This option is specific
2542     to the i386 PE targeted port of the linker]
2543
2544‘--base-file FILE’
2545     Use FILE as the name of a file in which to save the base addresses
2546     of all the relocations needed for generating DLLs with ‘dlltool’.
2547     [This is an i386 PE specific option]
2548
2549‘--dll’
2550     Create a DLL instead of a regular executable.  You may also use
2551     ‘-shared’ or specify a ‘LIBRARY’ in a given ‘.def’ file.  [This
2552     option is specific to the i386 PE targeted port of the linker]
2553
2554‘--enable-long-section-names’
2555‘--disable-long-section-names’
2556     The PE variants of the COFF object format add an extension that
2557     permits the use of section names longer than eight characters, the
2558     normal limit for COFF. By default, these names are only allowed in
2559     object files, as fully-linked executable images do not carry the
2560     COFF string table required to support the longer names.  As a GNU
2561     extension, it is possible to allow their use in executable images
2562     as well, or to (probably pointlessly!)  disallow it in object
2563     files, by using these two options.  Executable images generated
2564     with these long section names are slightly non-standard, carrying
2565     as they do a string table, and may generate confusing output when
2566     examined with non-GNU PE-aware tools, such as file viewers and
2567     dumpers.  However, GDB relies on the use of PE long section names
2568     to find Dwarf-2 debug information sections in an executable image
2569     at runtime, and so if neither option is specified on the
2570     command-line, ‘ld’ will enable long section names, overriding the
2571     default and technically correct behaviour, when it finds the
2572     presence of debug information while linking an executable image and
2573     not stripping symbols.  [This option is valid for all PE targeted
2574     ports of the linker]
2575
2576‘--enable-stdcall-fixup’
2577‘--disable-stdcall-fixup’
2578     If the link finds a symbol that it cannot resolve, it will attempt
2579     to do “fuzzy linking” by looking for another defined symbol that
2580     differs only in the format of the symbol name (cdecl vs stdcall)
2581     and will resolve that symbol by linking to the match.  For example,
2582     the undefined symbol ‘_foo’ might be linked to the function
2583     ‘_foo@12’, or the undefined symbol ‘_bar@16’ might be linked to the
2584     function ‘_bar’.  When the linker does this, it prints a warning,
2585     since it normally should have failed to link, but sometimes import
2586     libraries generated from third-party dlls may need this feature to
2587     be usable.  If you specify ‘--enable-stdcall-fixup’, this feature
2588     is fully enabled and warnings are not printed.  If you specify
2589     ‘--disable-stdcall-fixup’, this feature is disabled and such
2590     mismatches are considered to be errors.  [This option is specific
2591     to the i386 PE targeted port of the linker]
2592
2593‘--leading-underscore’
2594‘--no-leading-underscore’
2595     For most targets default symbol-prefix is an underscore and is
2596     defined in target’s description.  By this option it is possible to
2597     disable/enable the default underscore symbol-prefix.
2598
2599‘--export-all-symbols’
2600     If given, all global symbols in the objects used to build a DLL
2601     will be exported by the DLL. Note that this is the default if there
2602     otherwise wouldn’t be any exported symbols.  When symbols are
2603     explicitly exported via DEF files or implicitly exported via
2604     function attributes, the default is to not export anything else
2605     unless this option is given.  Note that the symbols ‘DllMain@12’,
2606     ‘DllEntryPoint@0’, ‘DllMainCRTStartup@12’, and ‘impure_ptr’ will
2607     not be automatically exported.  Also, symbols imported from other
2608     DLLs will not be re-exported, nor will symbols specifying the DLL’s
2609     internal layout such as those beginning with ‘_head_’ or ending
2610     with ‘_iname’.  In addition, no symbols from ‘libgcc’, ‘libstd++’,
2611     ‘libmingw32’, or ‘crtX.o’ will be exported.  Symbols whose names
2612     begin with ‘__rtti_’ or ‘__builtin_’ will not be exported, to help
2613     with C++ DLLs.  Finally, there is an extensive list of
2614     cygwin-private symbols that are not exported (obviously, this
2615     applies on when building DLLs for cygwin targets).  These
2616     cygwin-excludes are: ‘_cygwin_dll_entry@12’,
2617     ‘_cygwin_crt0_common@8’, ‘_cygwin_noncygwin_dll_entry@12’,
2618     ‘_fmode’, ‘_impure_ptr’, ‘cygwin_attach_dll’, ‘cygwin_premain0’,
2619     ‘cygwin_premain1’, ‘cygwin_premain2’, ‘cygwin_premain3’, and
2620     ‘environ’.  [This option is specific to the i386 PE targeted port
2621     of the linker]
2622
2623‘--exclude-symbols SYMBOL,SYMBOL,...’
2624     Specifies a list of symbols which should not be automatically
2625     exported.  The symbol names may be delimited by commas or colons.
2626     [This option is specific to the i386 PE targeted port of the
2627     linker]
2628
2629‘--exclude-all-symbols’
2630     Specifies no symbols should be automatically exported.  [This
2631     option is specific to the i386 PE targeted port of the linker]
2632
2633‘--file-alignment’
2634     Specify the file alignment.  Sections in the file will always begin
2635     at file offsets which are multiples of this number.  This defaults
2636     to 512.  [This option is specific to the i386 PE targeted port of
2637     the linker]
2638
2639‘--heap RESERVE’
2640‘--heap RESERVE,COMMIT’
2641     Specify the number of bytes of memory to reserve (and optionally
2642     commit) to be used as heap for this program.  The default is 1MB
2643     reserved, 4K committed.  [This option is specific to the i386 PE
2644     targeted port of the linker]
2645
2646‘--image-base VALUE’
2647     Use VALUE as the base address of your program or dll.  This is the
2648     lowest memory location that will be used when your program or dll
2649     is loaded.  To reduce the need to relocate and improve performance
2650     of your dlls, each should have a unique base address and not
2651     overlap any other dlls.  The default is 0x400000 for executables,
2652     and 0x10000000 for dlls.  [This option is specific to the i386 PE
2653     targeted port of the linker]
2654
2655‘--kill-at’
2656     If given, the stdcall suffixes (@NN) will be stripped from symbols
2657     before they are exported.  [This option is specific to the i386 PE
2658     targeted port of the linker]
2659
2660‘--large-address-aware’
2661     If given, the appropriate bit in the “Characteristics” field of the
2662     COFF header is set to indicate that this executable supports
2663     virtual addresses greater than 2 gigabytes.  This should be used in
2664     conjunction with the /3GB or /USERVA=VALUE megabytes switch in the
2665     “[operating systems]” section of the BOOT.INI. Otherwise, this bit
2666     has no effect.  [This option is specific to PE targeted ports of
2667     the linker]
2668
2669‘--disable-large-address-aware’
2670     Reverts the effect of a previous ‘--large-address-aware’ option.
2671     This is useful if ‘--large-address-aware’ is always set by the
2672     compiler driver (e.g.  Cygwin gcc) and the executable does not
2673     support virtual addresses greater than 2 gigabytes.  [This option
2674     is specific to PE targeted ports of the linker]
2675
2676‘--major-image-version VALUE’
2677     Sets the major number of the “image version”.  Defaults to 1.
2678     [This option is specific to the i386 PE targeted port of the
2679     linker]
2680
2681‘--major-os-version VALUE’
2682     Sets the major number of the “os version”.  Defaults to 4.  [This
2683     option is specific to the i386 PE targeted port of the linker]
2684
2685‘--major-subsystem-version VALUE’
2686     Sets the major number of the “subsystem version”.  Defaults to 4.
2687     [This option is specific to the i386 PE targeted port of the
2688     linker]
2689
2690‘--minor-image-version VALUE’
2691     Sets the minor number of the “image version”.  Defaults to 0.
2692     [This option is specific to the i386 PE targeted port of the
2693     linker]
2694
2695‘--minor-os-version VALUE’
2696     Sets the minor number of the “os version”.  Defaults to 0.  [This
2697     option is specific to the i386 PE targeted port of the linker]
2698
2699‘--minor-subsystem-version VALUE’
2700     Sets the minor number of the “subsystem version”.  Defaults to 0.
2701     [This option is specific to the i386 PE targeted port of the
2702     linker]
2703
2704‘--output-def FILE’
2705     The linker will create the file FILE which will contain a DEF file
2706     corresponding to the DLL the linker is generating.  This DEF file
2707     (which should be called ‘*.def’) may be used to create an import
2708     library with ‘dlltool’ or may be used as a reference to
2709     automatically or implicitly exported symbols.  [This option is
2710     specific to the i386 PE targeted port of the linker]
2711
2712‘--enable-auto-image-base’
2713‘--enable-auto-image-base=VALUE’
2714     Automatically choose the image base for DLLs, optionally starting
2715     with base VALUE, unless one is specified using the ‘--image-base’
2716     argument.  By using a hash generated from the dllname to create
2717     unique image bases for each DLL, in-memory collisions and
2718     relocations which can delay program execution are avoided.  [This
2719     option is specific to the i386 PE targeted port of the linker]
2720
2721‘--disable-auto-image-base’
2722     Do not automatically generate a unique image base.  If there is no
2723     user-specified image base (‘--image-base’) then use the platform
2724     default.  [This option is specific to the i386 PE targeted port of
2725     the linker]
2726
2727‘--dll-search-prefix STRING’
2728     When linking dynamically to a dll without an import library, search
2729     for ‘<string><basename>.dll’ in preference to ‘lib<basename>.dll’.
2730     This behaviour allows easy distinction between DLLs built for the
2731     various "subplatforms": native, cygwin, uwin, pw, etc.  For
2732     instance, cygwin DLLs typically use ‘--dll-search-prefix=cyg’.
2733     [This option is specific to the i386 PE targeted port of the
2734     linker]
2735
2736‘--enable-auto-import’
2737     Do sophisticated linking of ‘_symbol’ to ‘__imp__symbol’ for DATA
2738     imports from DLLs, thus making it possible to bypass the dllimport
2739     mechanism on the user side and to reference unmangled symbol names.
2740     [This option is specific to the i386 PE targeted port of the
2741     linker]
2742
2743     The following remarks pertain to the original implementation of the
2744     feature and are obsolete nowadays for Cygwin and MinGW targets.
2745
2746     Note: Use of the ’auto-import’ extension will cause the text
2747     section of the image file to be made writable.  This does not
2748     conform to the PE-COFF format specification published by Microsoft.
2749
2750     Note - use of the ’auto-import’ extension will also cause read only
2751     data which would normally be placed into the .rdata section to be
2752     placed into the .data section instead.  This is in order to work
2753     around a problem with consts that is described here:
2754     http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
2755
2756     Using ’auto-import’ generally will ’just work’ – but sometimes you
2757     may see this message:
2758
2759     "variable ’<var>’ can’t be auto-imported.  Please read the
2760     documentation for ld’s ‘--enable-auto-import’ for details."
2761
2762     This message occurs when some (sub)expression accesses an address
2763     ultimately given by the sum of two constants (Win32 import tables
2764     only allow one).  Instances where this may occur include accesses
2765     to member fields of struct variables imported from a DLL, as well
2766     as using a constant index into an array variable imported from a
2767     DLL. Any multiword variable (arrays, structs, long long, etc) may
2768     trigger this error condition.  However, regardless of the exact
2769     data type of the offending exported variable, ld will always detect
2770     it, issue the warning, and exit.
2771
2772     There are several ways to address this difficulty, regardless of
2773     the data type of the exported variable:
2774
2775     One way is to use –enable-runtime-pseudo-reloc switch.  This leaves
2776     the task of adjusting references in your client code for runtime
2777     environment, so this method works only when runtime environment
2778     supports this feature.
2779
2780     A second solution is to force one of the ’constants’ to be a
2781     variable – that is, unknown and un-optimizable at compile time.
2782     For arrays, there are two possibilities: a) make the indexee (the
2783     array’s address) a variable, or b) make the ’constant’ index a
2784     variable.  Thus:
2785
2786          extern type extern_array[];
2787          extern_array[1] -->
2788             { volatile type *t=extern_array; t[1] }
2789
2790     or
2791
2792          extern type extern_array[];
2793          extern_array[1] -->
2794             { volatile int t=1; extern_array[t] }
2795
2796     For structs (and most other multiword data types) the only option
2797     is to make the struct itself (or the long long, or the ...)
2798     variable:
2799
2800          extern struct s extern_struct;
2801          extern_struct.field -->
2802             { volatile struct s *t=&extern_struct; t->field }
2803
2804     or
2805
2806          extern long long extern_ll;
2807          extern_ll -->
2808            { volatile long long * local_ll=&extern_ll; *local_ll }
2809
2810     A third method of dealing with this difficulty is to abandon
2811     ’auto-import’ for the offending symbol and mark it with
2812     ‘__declspec(dllimport)’.  However, in practice that requires using
2813     compile-time #defines to indicate whether you are building a DLL,
2814     building client code that will link to the DLL, or merely
2815     building/linking to a static library.  In making the choice between
2816     the various methods of resolving the ’direct address with constant
2817     offset’ problem, you should consider typical real-world usage:
2818
2819     Original:
2820          --foo.h
2821          extern int arr[];
2822          --foo.c
2823          #include "foo.h"
2824          void main(int argc, char **argv){
2825            printf("%d\n",arr[1]);
2826          }
2827
2828     Solution 1:
2829          --foo.h
2830          extern int arr[];
2831          --foo.c
2832          #include "foo.h"
2833          void main(int argc, char **argv){
2834            /* This workaround is for win32 and cygwin; do not "optimize" */
2835            volatile int *parr = arr;
2836            printf("%d\n",parr[1]);
2837          }
2838
2839     Solution 2:
2840          --foo.h
2841          /* Note: auto-export is assumed (no __declspec(dllexport)) */
2842          #if (defined(_WIN32) || defined(__CYGWIN__)) && \
2843            !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
2844          #define FOO_IMPORT __declspec(dllimport)
2845          #else
2846          #define FOO_IMPORT
2847          #endif
2848          extern FOO_IMPORT int arr[];
2849          --foo.c
2850          #include "foo.h"
2851          void main(int argc, char **argv){
2852            printf("%d\n",arr[1]);
2853          }
2854
2855     A fourth way to avoid this problem is to re-code your library to
2856     use a functional interface rather than a data interface for the
2857     offending variables (e.g.  set_foo() and get_foo() accessor
2858     functions).
2859
2860‘--disable-auto-import’
2861     Do not attempt to do sophisticated linking of ‘_symbol’ to
2862     ‘__imp__symbol’ for DATA imports from DLLs.  [This option is
2863     specific to the i386 PE targeted port of the linker]
2864
2865‘--enable-runtime-pseudo-reloc’
2866     If your code contains expressions described in –enable-auto-import
2867     section, that is, DATA imports from DLL with non-zero offset, this
2868     switch will create a vector of ’runtime pseudo relocations’ which
2869     can be used by runtime environment to adjust references to such
2870     data in your client code.  [This option is specific to the i386 PE
2871     targeted port of the linker]
2872
2873‘--disable-runtime-pseudo-reloc’
2874     Do not create pseudo relocations for non-zero offset DATA imports
2875     from DLLs.  [This option is specific to the i386 PE targeted port
2876     of the linker]
2877
2878‘--enable-extra-pe-debug’
2879     Show additional debug info related to auto-import symbol thunking.
2880     [This option is specific to the i386 PE targeted port of the
2881     linker]
2882
2883‘--section-alignment’
2884     Sets the section alignment.  Sections in memory will always begin
2885     at addresses which are a multiple of this number.  Defaults to
2886     0x1000.  [This option is specific to the i386 PE targeted port of
2887     the linker]
2888
2889‘--stack RESERVE’
2890‘--stack RESERVE,COMMIT’
2891     Specify the number of bytes of memory to reserve (and optionally
2892     commit) to be used as stack for this program.  The default is 2MB
2893     reserved, 4K committed.  [This option is specific to the i386 PE
2894     targeted port of the linker]
2895
2896‘--subsystem WHICH’
2897‘--subsystem WHICH:MAJOR’
2898‘--subsystem WHICH:MAJOR.MINOR2899     Specifies the subsystem under which your program will execute.  The
2900     legal values for WHICH are ‘native’, ‘windows’, ‘console’, ‘posix’,
2901     and ‘xbox’.  You may optionally set the subsystem version also.
2902     Numeric values are also accepted for WHICH.  [This option is
2903     specific to the i386 PE targeted port of the linker]
2904
2905     The following options set flags in the ‘DllCharacteristics’ field
2906     of the PE file header: [These options are specific to PE targeted
2907     ports of the linker]
2908
2909‘--high-entropy-va’
2910‘--disable-high-entropy-va’
2911     Image is compatible with 64-bit address space layout randomization
2912     (ASLR). This option is enabled by default for 64-bit PE images.
2913
2914     This option also implies ‘--dynamicbase’ and
2915     ‘--enable-reloc-section’.
2916
2917‘--dynamicbase’
2918‘--disable-dynamicbase’
2919     The image base address may be relocated using address space layout
2920     randomization (ASLR). This feature was introduced with MS Windows
2921     Vista for i386 PE targets.  This option is enabled by default but
2922     can be disabled via the ‘--disable-dynamicbase’ option.  This
2923     option also implies ‘--enable-reloc-section’.
2924
2925‘--forceinteg’
2926‘--disable-forceinteg’
2927     Code integrity checks are enforced.  This option is disabled by
2928     default.
2929
2930‘--nxcompat’
2931‘--disable-nxcompat’
2932     The image is compatible with the Data Execution Prevention.  This
2933     feature was introduced with MS Windows XP SP2 for i386 PE targets.
2934     The option is enabled by default.
2935
2936‘--no-isolation’
2937‘--disable-no-isolation’
2938     Although the image understands isolation, do not isolate the image.
2939     This option is disabled by default.
2940
2941‘--no-seh’
2942‘--disable-no-seh’
2943     The image does not use SEH. No SE handler may be called from this
2944     image.  This option is disabled by default.
2945
2946‘--no-bind’
2947‘--disable-no-bind’
2948     Do not bind this image.  This option is disabled by default.
2949
2950‘--wdmdriver’
2951‘--disable-wdmdriver’
2952     The driver uses the MS Windows Driver Model.  This option is
2953     disabled by default.
2954
2955‘--tsaware’
2956‘--disable-tsaware’
2957     The image is Terminal Server aware.  This option is disabled by
2958     default.
2959
2960‘--insert-timestamp’
2961‘--no-insert-timestamp’
2962     Insert a real timestamp into the image.  This is the default
2963     behaviour as it matches legacy code and it means that the image
2964     will work with other, proprietary tools.  The problem with this
2965     default is that it will result in slightly different images being
2966     produced each time the same sources are linked.  The option
2967     ‘--no-insert-timestamp’ can be used to insert a zero value for the
2968     timestamp, this ensuring that binaries produced from identical
2969     sources will compare identically.
2970
2971     If ‘--insert-timestamp’ is active then the time inserted is either
2972     the time that the linking takes place or, if the
2973     ‘SOURCE_DATE_EPOCH’ environment variable is defined, the number of
2974     seconds since Unix epoch as specified by that variable.
2975
2976‘--enable-reloc-section’
2977‘--disable-reloc-section’
2978     Create the base relocation table, which is necessary if the image
2979     is loaded at a different image base than specified in the PE
2980     header.  This option is enabled by default.
2981
29822.1.2 Options specific to C6X uClinux targets
2983---------------------------------------------
2984
2985The C6X uClinux target uses a binary format called DSBT to support
2986shared libraries.  Each shared library in the system needs to have a
2987unique index; all executables use an index of 0.
2988
2989‘--dsbt-size SIZE’
2990     This option sets the number of entries in the DSBT of the current
2991     executable or shared library to SIZE.  The default is to create a
2992     table with 64 entries.
2993
2994‘--dsbt-index INDEX’
2995     This option sets the DSBT index of the current executable or shared
2996     library to INDEX.  The default is 0, which is appropriate for
2997     generating executables.  If a shared library is generated with a
2998     DSBT index of 0, the ‘R_C6000_DSBT_INDEX’ relocs are copied into
2999     the output file.
3000
3001     The ‘--no-merge-exidx-entries’ switch disables the merging of
3002     adjacent exidx entries in frame unwind info.
3003
30042.1.3 Options specific to C-SKY targets
3005---------------------------------------
3006
3007‘--branch-stub’
3008     This option enables linker branch relaxation by inserting branch
3009     stub sections when needed to extend the range of branches.  This
3010     option is usually not required since C-SKY supports branch and call
3011     instructions that can access the full memory range and branch
3012     relaxation is normally handled by the compiler or assembler.
3013
3014‘--stub-group-size=N’
3015     This option allows finer control of linker branch stub creation.
3016     It sets the maximum size of a group of input sections that can be
3017     handled by one stub section.  A negative value of N locates stub
3018     sections after their branches, while a positive value allows stub
3019     sections to appear either before or after the branches.  Values of
3020     ‘1’ or ‘-1’ indicate that the linker should choose suitable
3021     defaults.
3022
30232.1.4 Options specific to Motorola 68HC11 and 68HC12 targets
3024------------------------------------------------------------
3025
3026The 68HC11 and 68HC12 linkers support specific options to control the
3027memory bank switching mapping and trampoline code generation.
3028
3029‘--no-trampoline’
3030     This option disables the generation of trampoline.  By default a
3031     trampoline is generated for each far function which is called using
3032     a ‘jsr’ instruction (this happens when a pointer to a far function
3033     is taken).
3034
3035‘--bank-window NAME’
3036     This option indicates to the linker the name of the memory region
3037     in the ‘MEMORY’ specification that describes the memory bank
3038     window.  The definition of such region is then used by the linker
3039     to compute paging and addresses within the memory window.
3040
30412.1.5 Options specific to Motorola 68K target
3042---------------------------------------------
3043
3044The following options are supported to control handling of GOT
3045generation when linking for 68K targets.
3046
3047‘--got=TYPE’
3048     This option tells the linker which GOT generation scheme to use.
3049     TYPE should be one of ‘single’, ‘negative’, ‘multigot’ or ‘target’.
3050     For more information refer to the Info entry for ‘ld’.
3051
30522.1.6 Options specific to MIPS targets
3053--------------------------------------
3054
3055The following options are supported to control microMIPS instruction
3056generation and branch relocation checks for ISA mode transitions when
3057linking for MIPS targets.
3058
3059‘--insn32’
3060‘--no-insn32’
3061     These options control the choice of microMIPS instructions used in
3062     code generated by the linker, such as that in the PLT or lazy
3063     binding stubs, or in relaxation.  If ‘--insn32’ is used, then the
3064     linker only uses 32-bit instruction encodings.  By default or if
3065     ‘--no-insn32’ is used, all instruction encodings are used,
3066     including 16-bit ones where possible.
3067
3068‘--ignore-branch-isa’
3069‘--no-ignore-branch-isa’
3070     These options control branch relocation checks for invalid ISA mode
3071     transitions.  If ‘--ignore-branch-isa’ is used, then the linker
3072     accepts any branch relocations and any ISA mode transition required
3073     is lost in relocation calculation, except for some cases of ‘BAL’
3074     instructions which meet relaxation conditions and are converted to
3075     equivalent ‘JALX’ instructions as the associated relocation is
3076     calculated.  By default or if ‘--no-ignore-branch-isa’ is used a
3077     check is made causing the loss of an ISA mode transition to produce
3078     an error.
3079
3080‘--compact-branches’
3081‘--no-compact-branches’
3082     These options control the generation of compact instructions by the
3083     linker in the PLT entries for MIPS R6.
3084
30852.1.7 Options specific to PDP11 targets
3086---------------------------------------
3087
3088For the pdp11-aout target, three variants of the output format can be
3089produced as selected by the following options.  The default variant for
3090pdp11-aout is the ‘--omagic’ option, whereas for other targets
3091‘--nmagic’ is the default.  The ‘--imagic’ option is defined only for
3092the pdp11-aout target, while the others are described here as they apply
3093to the pdp11-aout target.
3094
3095‘-N’
3096‘--omagic’
3097
3098     Mark the output as ‘OMAGIC’ (0407) in the ‘a.out’ header to
3099     indicate that the text segment is not to be write-protected and
3100     shared.  Since the text and data sections are both readable and
3101     writable, the data section is allocated immediately contiguous
3102     after the text segment.  This is the oldest format for PDP11
3103     executable programs and is the default for ‘ld’ on PDP11 Unix
3104     systems from the beginning through 2.11BSD.
3105
3106‘-n’
3107‘--nmagic’
3108
3109     Mark the output as ‘NMAGIC’ (0410) in the ‘a.out’ header to
3110     indicate that when the output file is executed, the text portion
3111     will be read-only and shareable among all processes executing the
3112     same file.  This involves moving the data areas up to the first
3113     possible 8K byte page boundary following the end of the text.  This
3114     option creates a _pure executable_ format.
3115
3116‘-z’
3117‘--imagic’
3118
3119     Mark the output as ‘IMAGIC’ (0411) in the ‘a.out’ header to
3120     indicate that when the output file is executed, the program text
3121     and data areas will be loaded into separate address spaces using
3122     the split instruction and data space feature of the memory
3123     management unit in larger models of the PDP11.  This doubles the
3124     address space available to the program.  The text segment is again
3125     pure, write-protected, and shareable.  The only difference in the
3126     output format between this option and the others, besides the magic
3127     number, is that both the text and data sections start at location
3128     0.  The ‘-z’ option selected this format in 2.11BSD. This option
3129     creates a _separate executable_ format.
3130
3131‘--no-omagic’
3132
3133     Equivalent to ‘--nmagic’ for pdp11-aout.
3134
3135
3136File: ld.info,  Node: Environment,  Prev: Options,  Up: Invocation
3137
31382.2 Environment Variables
3139=========================
3140
3141You can change the behaviour of ‘ld’ with the environment variables
3142‘GNUTARGET’, ‘LDEMULATION’ and ‘COLLECT_NO_DEMANGLE’.
3143
3144   ‘GNUTARGET’ determines the input-file object format if you don’t use
3145‘-b’ (or its synonym ‘--format’).  Its value should be one of the BFD
3146names for an input format (*note BFD::).  If there is no ‘GNUTARGET’ in
3147the environment, ‘ld’ uses the natural format of the target.  If
3148‘GNUTARGET’ is set to ‘default’ then BFD attempts to discover the input
3149format by examining binary input files; this method often succeeds, but
3150there are potential ambiguities, since there is no method of ensuring
3151that the magic number used to specify object-file formats is unique.
3152However, the configuration procedure for BFD on each system places the
3153conventional format for that system first in the search-list, so
3154ambiguities are resolved in favor of convention.
3155
3156   ‘LDEMULATION’ determines the default emulation if you don’t use the
3157‘-m’ option.  The emulation can affect various aspects of linker
3158behaviour, particularly the default linker script.  You can list the
3159available emulations with the ‘--verbose’ or ‘-V’ options.  If the ‘-m’
3160option is not used, and the ‘LDEMULATION’ environment variable is not
3161defined, the default emulation depends upon how the linker was
3162configured.
3163
3164   Normally, the linker will default to demangling symbols.  However, if
3165‘COLLECT_NO_DEMANGLE’ is set in the environment, then it will default to
3166not demangling symbols.  This environment variable is used in a similar
3167fashion by the ‘gcc’ linker wrapper program.  The default may be
3168overridden by the ‘--demangle’ and ‘--no-demangle’ options.
3169
3170
3171File: ld.info,  Node: Scripts,  Next: Plugins,  Prev: Invocation,  Up: Top
3172
31733 Linker Scripts
3174****************
3175
3176Every link is controlled by a “linker script”.  This script is written
3177in the linker command language.
3178
3179   The main purpose of the linker script is to describe how the sections
3180in the input files should be mapped into the output file, and to control
3181the memory layout of the output file.  Most linker scripts do nothing
3182more than this.  However, when necessary, the linker script can also
3183direct the linker to perform many other operations, using the commands
3184described below.
3185
3186   The linker always uses a linker script.  If you do not supply one
3187yourself, the linker will use a default script that is compiled into the
3188linker executable.  You can use the ‘--verbose’ command-line option to
3189display the default linker script.  Certain command-line options, such
3190as ‘-r’ or ‘-N’, will affect the default linker script.
3191
3192   You may supply your own linker script by using the ‘-T’ command line
3193option.  When you do this, your linker script will replace the default
3194linker script.
3195
3196   You may also use linker scripts implicitly by naming them as input
3197files to the linker, as though they were files to be linked.  *Note
3198Implicit Linker Scripts::.
3199
3200* Menu:
3201
3202* Basic Script Concepts::	Basic Linker Script Concepts
3203* Script Format::		Linker Script Format
3204* Simple Example::		Simple Linker Script Example
3205* Simple Commands::		Simple Linker Script Commands
3206* Assignments::			Assigning Values to Symbols
3207* SECTIONS::			SECTIONS Command
3208* MEMORY::			MEMORY Command
3209* PHDRS::			PHDRS Command
3210* VERSION::			VERSION Command
3211* Expressions::			Expressions in Linker Scripts
3212* Implicit Linker Scripts::	Implicit Linker Scripts
3213
3214
3215File: ld.info,  Node: Basic Script Concepts,  Next: Script Format,  Up: Scripts
3216
32173.1 Basic Linker Script Concepts
3218================================
3219
3220We need to define some basic concepts and vocabulary in order to
3221describe the linker script language.
3222
3223   The linker combines input files into a single output file.  The
3224output file and each input file are in a special data format known as an
3225“object file format”.  Each file is called an “object file”.  The output
3226file is often called an “executable”, but for our purposes we will also
3227call it an object file.  Each object file has, among other things, a
3228list of “sections”.  We sometimes refer to a section in an input file as
3229an “input section”; similarly, a section in the output file is an
3230“output section”.
3231
3232   Each section in an object file has a name and a size.  Most sections
3233also have an associated block of data, known as the “section contents”.
3234A section may be marked as “loadable”, which means that the contents
3235should be loaded into memory when the output file is run.  A section
3236with no contents may be “allocatable”, which means that an area in
3237memory should be set aside, but nothing in particular should be loaded
3238there (in some cases this memory must be zeroed out).  A section which
3239is neither loadable nor allocatable typically contains some sort of
3240debugging information.
3241
3242   Every loadable or allocatable output section has two addresses.  The
3243first is the “VMA”, or virtual memory address.  This is the address the
3244section will have when the output file is run.  The second is the “LMA”,
3245or load memory address.  This is the address at which the section will
3246be loaded.  In most cases the two addresses will be the same.  An
3247example of when they might be different is when a data section is loaded
3248into ROM, and then copied into RAM when the program starts up (this
3249technique is often used to initialize global variables in a ROM based
3250system).  In this case the ROM address would be the LMA, and the RAM
3251address would be the VMA.
3252
3253   You can see the sections in an object file by using the ‘objdump’
3254program with the ‘-h’ option.
3255
3256   Every object file also has a list of “symbols”, known as the “symbol
3257table”.  A symbol may be defined or undefined.  Each symbol has a name,
3258and each defined symbol has an address, among other information.  If you
3259compile a C or C++ program into an object file, you will get a defined
3260symbol for every defined function and global or static variable.  Every
3261undefined function or global variable which is referenced in the input
3262file will become an undefined symbol.
3263
3264   You can see the symbols in an object file by using the ‘nm’ program,
3265or by using the ‘objdump’ program with the ‘-t’ option.
3266
3267
3268File: ld.info,  Node: Script Format,  Next: Simple Example,  Prev: Basic Script Concepts,  Up: Scripts
3269
32703.2 Linker Script Format
3271========================
3272
3273Linker scripts are text files.
3274
3275   You write a linker script as a series of commands.  Each command is
3276either a keyword, possibly followed by arguments, or an assignment to a
3277symbol.  You may separate commands using semicolons.  Whitespace is
3278generally ignored.
3279
3280   Strings such as file or format names can normally be entered
3281directly.  If the file name contains a character such as a comma which
3282would otherwise serve to separate file names, you may put the file name
3283in double quotes.  There is no way to use a double quote character in a
3284file name.
3285
3286   You may include comments in linker scripts just as in C, delimited by
3287‘/*’ and ‘*/’.  As in C, comments are syntactically equivalent to
3288whitespace.
3289
3290
3291File: ld.info,  Node: Simple Example,  Next: Simple Commands,  Prev: Script Format,  Up: Scripts
3292
32933.3 Simple Linker Script Example
3294================================
3295
3296Many linker scripts are fairly simple.
3297
3298   The simplest possible linker script has just one command: ‘SECTIONS’.
3299You use the ‘SECTIONS’ command to describe the memory layout of the
3300output file.
3301
3302   The ‘SECTIONS’ command is a powerful command.  Here we will describe
3303a simple use of it.  Let’s assume your program consists only of code,
3304initialized data, and uninitialized data.  These will be in the ‘.text’,
3305‘.data’, and ‘.bss’ sections, respectively.  Let’s assume further that
3306these are the only sections which appear in your input files.
3307
3308   For this example, let’s say that the code should be loaded at address
33090x10000, and that the data should start at address 0x8000000.  Here is a
3310linker script which will do that:
3311     SECTIONS
3312     {
3313       . = 0x10000;
3314       .text : { *(.text) }
3315       . = 0x8000000;
3316       .data : { *(.data) }
3317       .bss : { *(.bss) }
3318     }
3319
3320   You write the ‘SECTIONS’ command as the keyword ‘SECTIONS’, followed
3321by a series of symbol assignments and output section descriptions
3322enclosed in curly braces.
3323
3324   The first line inside the ‘SECTIONS’ command of the above example
3325sets the value of the special symbol ‘.’, which is the location counter.
3326If you do not specify the address of an output section in some other way
3327(other ways are described later), the address is set from the current
3328value of the location counter.  The location counter is then incremented
3329by the size of the output section.  At the start of the ‘SECTIONS’
3330command, the location counter has the value ‘0’.
3331
3332   The second line defines an output section, ‘.text’.  The colon is
3333required syntax which may be ignored for now.  Within the curly braces
3334after the output section name, you list the names of the input sections
3335which should be placed into this output section.  The ‘*’ is a wildcard
3336which matches any file name.  The expression ‘*(.text)’ means all
3337‘.text’ input sections in all input files.
3338
3339   Since the location counter is ‘0x10000’ when the output section
3340‘.text’ is defined, the linker will set the address of the ‘.text’
3341section in the output file to be ‘0x10000’.
3342
3343   The remaining lines define the ‘.data’ and ‘.bss’ sections in the
3344output file.  The linker will place the ‘.data’ output section at
3345address ‘0x8000000’.  After the linker places the ‘.data’ output
3346section, the value of the location counter will be ‘0x8000000’ plus the
3347size of the ‘.data’ output section.  The effect is that the linker will
3348place the ‘.bss’ output section immediately after the ‘.data’ output
3349section in memory.
3350
3351   The linker will ensure that each output section has the required
3352alignment, by increasing the location counter if necessary.  In this
3353example, the specified addresses for the ‘.text’ and ‘.data’ sections
3354will probably satisfy any alignment constraints, but the linker may have
3355to create a small gap between the ‘.data’ and ‘.bss’ sections.
3356
3357   That’s it!  That’s a simple and complete linker script.
3358
3359
3360File: ld.info,  Node: Simple Commands,  Next: Assignments,  Prev: Simple Example,  Up: Scripts
3361
33623.4 Simple Linker Script Commands
3363=================================
3364
3365In this section we describe the simple linker script commands.
3366
3367* Menu:
3368
3369* Entry Point::			Setting the entry point
3370* File Commands::		Commands dealing with files
3371* Format Commands::		Commands dealing with object file formats
3372
3373* REGION_ALIAS::		Assign alias names to memory regions
3374* Miscellaneous Commands::	Other linker script commands
3375
3376
3377File: ld.info,  Node: Entry Point,  Next: File Commands,  Up: Simple Commands
3378
33793.4.1 Setting the Entry Point
3380-----------------------------
3381
3382The first instruction to execute in a program is called the “entry
3383point”.  You can use the ‘ENTRY’ linker script command to set the entry
3384point.  The argument is a symbol name:
3385     ENTRY(SYMBOL)
3386
3387   There are several ways to set the entry point.  The linker will set
3388the entry point by trying each of the following methods in order, and
3389stopping when one of them succeeds:
3390   • the ‘-e’ ENTRY command-line option;
3391   • the ‘ENTRY(SYMBOL)’ command in a linker script;
3392   • the value of a target-specific symbol, if it is defined; For many
3393     targets this is ‘start’, but PE- and BeOS-based systems for example
3394     check a list of possible entry symbols, matching the first one
3395     found.
3396   • the address of the first byte of the code section, if present and
3397     an executable is being created - the code section is usually
3398     ‘.text’, but can be something else;
3399   • The address ‘0’.
3400
3401
3402File: ld.info,  Node: File Commands,  Next: Format Commands,  Prev: Entry Point,  Up: Simple Commands
3403
34043.4.2 Commands Dealing with Files
3405---------------------------------
3406
3407Several linker script commands deal with files.
3408
3409‘INCLUDE FILENAME’
3410     Include the linker script FILENAME at this point.  The file will be
3411     searched for in the current directory, and in any directory
3412     specified with the ‘-L’ option.  You can nest calls to ‘INCLUDE’ up
3413     to 10 levels deep.
3414
3415     You can place ‘INCLUDE’ directives at the top level, in ‘MEMORY’ or
3416     ‘SECTIONS’ commands, or in output section descriptions.
3417
3418‘INPUT(FILE, FILE, ...)’
3419‘INPUT(FILE FILE ...)’
3420     The ‘INPUT’ command directs the linker to include the named files
3421     in the link, as though they were named on the command line.
3422
3423     For example, if you always want to include ‘subr.o’ any time you do
3424     a link, but you can’t be bothered to put it on every link command
3425     line, then you can put ‘INPUT (subr.o)’ in your linker script.
3426
3427     In fact, if you like, you can list all of your input files in the
3428     linker script, and then invoke the linker with nothing but a ‘-T’
3429     option.
3430
3431     In case a “sysroot prefix” is configured, and the filename starts
3432     with the ‘/’ character, and the script being processed was located
3433     inside the “sysroot prefix”, the filename will be looked for in the
3434     “sysroot prefix”.  The “sysroot prefix” can also be forced by
3435     specifying ‘=’ as the first character in the filename path, or
3436     prefixing the filename path with ‘$SYSROOT’.  See also the
3437     description of ‘-L’ in *note Command-line Options: Options.
3438
3439     If a “sysroot prefix” is not used then the linker will try to open
3440     the file in the directory containing the linker script.  If it is
3441     not found the linker will then search the current directory.  If it
3442     is still not found the linker will search through the archive
3443     library search path.
3444
3445     If you use ‘INPUT (-lFILE)’, ‘ld’ will transform the name to
3446libFILE.a’, as with the command-line argument ‘-l’.
3447
3448     When you use the ‘INPUT’ command in an implicit linker script, the
3449     files will be included in the link at the point at which the linker
3450     script file is included.  This can affect archive searching.
3451
3452‘GROUP(FILE, FILE, ...)’
3453‘GROUP(FILE FILE ...)’
3454     The ‘GROUP’ command is like ‘INPUT’, except that the named files
3455     should all be archives, and they are searched repeatedly until no
3456     new undefined references are created.  See the description of ‘-(’
3457     in *note Command-line Options: Options.
3458
3459‘AS_NEEDED(FILE, FILE, ...)’
3460‘AS_NEEDED(FILE FILE ...)’
3461     This construct can appear only inside of the ‘INPUT’ or ‘GROUP’
3462     commands, among other filenames.  The files listed will be handled
3463     as if they appear directly in the ‘INPUT’ or ‘GROUP’ commands, with
3464     the exception of ELF shared libraries, that will be added only when
3465     they are actually needed.  This construct essentially enables
3466     ‘--as-needed’ option for all the files listed inside of it and
3467     restores previous ‘--as-needed’ resp.  ‘--no-as-needed’ setting
3468     afterwards.
3469
3470‘OUTPUT(FILENAME)’
3471     The ‘OUTPUT’ command names the output file.  Using
3472     ‘OUTPUT(FILENAME)’ in the linker script is exactly like using ‘-o
3473     FILENAME’ on the command line (*note Command Line Options:
3474     Options.).  If both are used, the command-line option takes
3475     precedence.
3476
3477     You can use the ‘OUTPUT’ command to define a default name for the
3478     output file other than the usual default of ‘a.out’.
3479
3480‘SEARCH_DIR(PATH)’
3481     The ‘SEARCH_DIR’ command adds PATH to the list of paths where ‘ld’
3482     looks for archive libraries.  Using ‘SEARCH_DIR(PATH)’ is exactly
3483     like using ‘-L PATH’ on the command line (*note Command-line
3484     Options: Options.).  If both are used, then the linker will search
3485     both paths.  Paths specified using the command-line option are
3486     searched first.
3487
3488‘STARTUP(FILENAME)’
3489     The ‘STARTUP’ command is just like the ‘INPUT’ command, except that
3490     FILENAME will become the first input file to be linked, as though
3491     it were specified first on the command line.  This may be useful
3492     when using a system in which the entry point is always the start of
3493     the first file.
3494
3495
3496File: ld.info,  Node: Format Commands,  Next: REGION_ALIAS,  Prev: File Commands,  Up: Simple Commands
3497
34983.4.3 Commands Dealing with Object File Formats
3499-----------------------------------------------
3500
3501A couple of linker script commands deal with object file formats.
3502
3503‘OUTPUT_FORMAT(BFDNAME)’
3504‘OUTPUT_FORMAT(DEFAULT, BIG, LITTLE)’
3505     The ‘OUTPUT_FORMAT’ command names the BFD format to use for the
3506     output file (*note BFD::).  Using ‘OUTPUT_FORMAT(BFDNAME)’ is
3507     exactly like using ‘--oformat BFDNAME’ on the command line (*note
3508     Command-line Options: Options.).  If both are used, the command
3509     line option takes precedence.
3510
3511     You can use ‘OUTPUT_FORMAT’ with three arguments to use different
3512     formats based on the ‘-EB’ and ‘-EL’ command-line options.  This
3513     permits the linker script to set the output format based on the
3514     desired endianness.
3515
3516     If neither ‘-EB’ nor ‘-EL’ are used, then the output format will be
3517     the first argument, DEFAULT.  If ‘-EB’ is used, the output format
3518     will be the second argument, BIG.  If ‘-EL’ is used, the output
3519     format will be the third argument, LITTLE.
3520
3521     For example, the default linker script for the MIPS ELF target uses
3522     this command:
3523          OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)
3524     This says that the default format for the output file is
3525     ‘elf32-bigmips’, but if the user uses the ‘-EL’ command-line
3526     option, the output file will be created in the ‘elf32-littlemips’
3527     format.
3528
3529‘TARGET(BFDNAME)’
3530     The ‘TARGET’ command names the BFD format to use when reading input
3531     files.  It affects subsequent ‘INPUT’ and ‘GROUP’ commands.  This
3532     command is like using ‘-b BFDNAME’ on the command line (*note
3533     Command-line Options: Options.).  If the ‘TARGET’ command is used
3534     but ‘OUTPUT_FORMAT’ is not, then the last ‘TARGET’ command is also
3535     used to set the format for the output file.  *Note BFD::.
3536
3537
3538File: ld.info,  Node: REGION_ALIAS,  Next: Miscellaneous Commands,  Prev: Format Commands,  Up: Simple Commands
3539
35403.4.4 Assign alias names to memory regions
3541------------------------------------------
3542
3543Alias names can be added to existing memory regions created with the
3544*note MEMORY:: command.  Each name corresponds to at most one memory
3545region.
3546
3547     REGION_ALIAS(ALIAS, REGION)
3548
3549   The ‘REGION_ALIAS’ function creates an alias name ALIAS for the
3550memory region REGION.  This allows a flexible mapping of output sections
3551to memory regions.  An example follows.
3552
3553   Suppose we have an application for embedded systems which come with
3554various memory storage devices.  All have a general purpose, volatile
3555memory ‘RAM’ that allows code execution or data storage.  Some may have
3556a read-only, non-volatile memory ‘ROM’ that allows code execution and
3557read-only data access.  The last variant is a read-only, non-volatile
3558memory ‘ROM2’ with read-only data access and no code execution
3559capability.  We have four output sections:
3560
3561   • ‘.text’ program code;
3562   • ‘.rodata’ read-only data;
3563   • ‘.data’ read-write initialized data;
3564   • ‘.bss’ read-write zero initialized data.
3565
3566   The goal is to provide a linker command file that contains a system
3567independent part defining the output sections and a system dependent
3568part mapping the output sections to the memory regions available on the
3569system.  Our embedded systems come with three different memory setups
3570‘A’, ‘B’ and ‘C’:
3571Section            Variant A          Variant B          Variant C
3572.text              RAM                ROM                ROM
3573.rodata            RAM                ROM                ROM2
3574.data              RAM                RAM/ROM            RAM/ROM2
3575.bss               RAM                RAM                RAM
3576   The notation ‘RAM/ROM’ or ‘RAM/ROM2’ means that this section is
3577loaded into region ‘ROM’ or ‘ROM2’ respectively.  Please note that the
3578load address of the ‘.data’ section starts in all three variants at the
3579end of the ‘.rodata’ section.
3580
3581   The base linker script that deals with the output sections follows.
3582It includes the system dependent ‘linkcmds.memory’ file that describes
3583the memory layout:
3584     INCLUDE linkcmds.memory
3585
3586     SECTIONS
3587       {
3588         .text :
3589           {
3590             *(.text)
3591           } > REGION_TEXT
3592         .rodata :
3593           {
3594             *(.rodata)
3595             rodata_end = .;
3596           } > REGION_RODATA
3597         .data : AT (rodata_end)
3598           {
3599             data_start = .;
3600             *(.data)
3601           } > REGION_DATA
3602         data_size = SIZEOF(.data);
3603         data_load_start = LOADADDR(.data);
3604         .bss :
3605           {
3606             *(.bss)
3607           } > REGION_BSS
3608       }
3609
3610   Now we need three different ‘linkcmds.memory’ files to define memory
3611regions and alias names.  The content of ‘linkcmds.memory’ for the three
3612variants ‘A’, ‘B’ and ‘C’:
3613‘A’
3614     Here everything goes into the ‘RAM’.
3615          MEMORY
3616            {
3617              RAM : ORIGIN = 0, LENGTH = 4M
3618            }
3619
3620          REGION_ALIAS("REGION_TEXT", RAM);
3621          REGION_ALIAS("REGION_RODATA", RAM);
3622          REGION_ALIAS("REGION_DATA", RAM);
3623          REGION_ALIAS("REGION_BSS", RAM);
3624‘B’
3625     Program code and read-only data go into the ‘ROM’.  Read-write data
3626     goes into the ‘RAM’.  An image of the initialized data is loaded
3627     into the ‘ROM’ and will be copied during system start into the
3628     ‘RAM’.
3629          MEMORY
3630            {
3631              ROM : ORIGIN = 0, LENGTH = 3M
3632              RAM : ORIGIN = 0x10000000, LENGTH = 1M
3633            }
3634
3635          REGION_ALIAS("REGION_TEXT", ROM);
3636          REGION_ALIAS("REGION_RODATA", ROM);
3637          REGION_ALIAS("REGION_DATA", RAM);
3638          REGION_ALIAS("REGION_BSS", RAM);
3639‘C’
3640     Program code goes into the ‘ROM’.  Read-only data goes into the
3641     ‘ROM2’.  Read-write data goes into the ‘RAM’.  An image of the
3642     initialized data is loaded into the ‘ROM2’ and will be copied
3643     during system start into the ‘RAM’.
3644          MEMORY
3645            {
3646              ROM : ORIGIN = 0, LENGTH = 2M
3647              ROM2 : ORIGIN = 0x10000000, LENGTH = 1M
3648              RAM : ORIGIN = 0x20000000, LENGTH = 1M
3649            }
3650
3651          REGION_ALIAS("REGION_TEXT", ROM);
3652          REGION_ALIAS("REGION_RODATA", ROM2);
3653          REGION_ALIAS("REGION_DATA", RAM);
3654          REGION_ALIAS("REGION_BSS", RAM);
3655
3656   It is possible to write a common system initialization routine to
3657copy the ‘.data’ section from ‘ROM’ or ‘ROM2’ into the ‘RAM’ if
3658necessary:
3659     #include <string.h>
3660
3661     extern char data_start [];
3662     extern char data_size [];
3663     extern char data_load_start [];
3664
3665     void copy_data(void)
3666     {
3667       if (data_start != data_load_start)
3668         {
3669           memcpy(data_start, data_load_start, (size_t) data_size);
3670         }
3671     }
3672
3673
3674File: ld.info,  Node: Miscellaneous Commands,  Prev: REGION_ALIAS,  Up: Simple Commands
3675
36763.4.5 Other Linker Script Commands
3677----------------------------------
3678
3679There are a few other linker scripts commands.
3680
3681‘ASSERT(EXP, MESSAGE)’
3682     Ensure that EXP is non-zero.  If it is zero, then exit the linker
3683     with an error code, and print MESSAGE.
3684
3685     Note that assertions are checked before the final stages of linking
3686     take place.  This means that expressions involving symbols PROVIDEd
3687     inside section definitions will fail if the user has not set values
3688     for those symbols.  The only exception to this rule is PROVIDEd
3689     symbols that just reference dot.  Thus an assertion like this:
3690
3691            .stack :
3692            {
3693              PROVIDE (__stack = .);
3694              PROVIDE (__stack_size = 0x100);
3695              ASSERT ((__stack > (_end + __stack_size)), "Error: No room left for the stack");
3696            }
3697
3698     will fail if ‘__stack_size’ is not defined elsewhere.  Symbols
3699     PROVIDEd outside of section definitions are evaluated earlier, so
3700     they can be used inside ASSERTions.  Thus:
3701
3702            PROVIDE (__stack_size = 0x100);
3703            .stack :
3704            {
3705              PROVIDE (__stack = .);
3706              ASSERT ((__stack > (_end + __stack_size)), "Error: No room left for the stack");
3707            }
3708
3709     will work.
3710
3711‘EXTERN(SYMBOL SYMBOL ...)’
3712     Force SYMBOL to be entered in the output file as an undefined
3713     symbol.  Doing this may, for example, trigger linking of additional
3714     modules from standard libraries.  You may list several SYMBOLs for
3715     each ‘EXTERN’, and you may use ‘EXTERN’ multiple times.  This
3716     command has the same effect as the ‘-u’ command-line option.
3717
3718‘FORCE_COMMON_ALLOCATION’
3719     This command has the same effect as the ‘-d’ command-line option:
3720     to make ‘ld’ assign space to common symbols even if a relocatable
3721     output file is specified (‘-r’).
3722
3723‘INHIBIT_COMMON_ALLOCATION’
3724     This command has the same effect as the ‘--no-define-common’
3725     command-line option: to make ‘ld’ omit the assignment of addresses
3726     to common symbols even for a non-relocatable output file.
3727
3728‘FORCE_GROUP_ALLOCATION’
3729     This command has the same effect as the ‘--force-group-allocation’
3730     command-line option: to make ‘ld’ place section group members like
3731     normal input sections, and to delete the section groups even if a
3732     relocatable output file is specified (‘-r’).
3733
3734‘INSERT [ AFTER | BEFORE ] OUTPUT_SECTION’
3735     This command is typically used in a script specified by ‘-T’ to
3736     augment the default ‘SECTIONS’ with, for example, overlays.  It
3737     inserts all prior linker script statements after (or before)
3738     OUTPUT_SECTION, and also causes ‘-T’ to not override the default
3739     linker script.  The exact insertion point is as for orphan
3740     sections.  *Note Location Counter::.  The insertion happens after
3741     the linker has mapped input sections to output sections.  Prior to
3742     the insertion, since ‘-T’ scripts are parsed before the default
3743     linker script, statements in the ‘-T’ script occur before the
3744     default linker script statements in the internal linker
3745     representation of the script.  In particular, input section
3746     assignments will be made to ‘-T’ output sections before those in
3747     the default script.  Here is an example of how a ‘-T’ script using
3748     ‘INSERT’ might look:
3749
3750          SECTIONS
3751          {
3752            OVERLAY :
3753            {
3754              .ov1 { ov1*(.text) }
3755              .ov2 { ov2*(.text) }
3756            }
3757          }
3758          INSERT AFTER .text;
3759
3760     Note that when ‘-T’ is used twice, once to override the default
3761     script and once to augment that script using ‘INSERT’ the order of
3762     parsing and section assignments apply as for the default script.
3763     The script with ‘INSERT’ should be specified _first_ on the command
3764     line.
3765
3766‘NOCROSSREFS(SECTION SECTION ...)’
3767     This command may be used to tell ‘ld’ to issue an error about any
3768     references among certain output sections.
3769
3770     In certain types of programs, particularly on embedded systems when
3771     using overlays, when one section is loaded into memory, another
3772     section will not be.  Any direct references between the two
3773     sections would be errors.  For example, it would be an error if
3774     code in one section called a function defined in the other section.
3775
3776     The ‘NOCROSSREFS’ command takes a list of output section names.  If
3777     ‘ld’ detects any cross references between the sections, it reports
3778     an error and returns a non-zero exit status.  Note that the
3779     ‘NOCROSSREFS’ command uses output section names, not input section
3780     names.
3781
3782‘NOCROSSREFS_TO(TOSECTION FROMSECTION ...)’
3783     This command may be used to tell ‘ld’ to issue an error about any
3784     references to one section from a list of other sections.
3785
3786     The ‘NOCROSSREFS’ command is useful when ensuring that two or more
3787     output sections are entirely independent but there are situations
3788     where a one-way dependency is needed.  For example, in a multi-core
3789     application there may be shared code that can be called from each
3790     core but for safety must never call back.
3791
3792     The ‘NOCROSSREFS_TO’ command takes a list of output section names.
3793     The first section can not be referenced from any of the other
3794     sections.  If ‘ld’ detects any references to the first section from
3795     any of the other sections, it reports an error and returns a
3796     non-zero exit status.  Note that the ‘NOCROSSREFS_TO’ command uses
3797     output section names, not input section names.
3798
3799‘OUTPUT_ARCH(BFDARCH)’
3800     Specify a particular output machine architecture.  The argument is
3801     one of the names used by the BFD library (*note BFD::).  You can
3802     see the architecture of an object file by using the ‘objdump’
3803     program with the ‘-f’ option.
3804
3805‘LD_FEATURE(STRING)’
3806     This command may be used to modify ‘ld’ behavior.  If STRING is
3807     ‘"SANE_EXPR"’ then absolute symbols and numbers in a script are
3808     simply treated as numbers everywhere.  *Note Expression Section::.
3809
3810
3811File: ld.info,  Node: Assignments,  Next: SECTIONS,  Prev: Simple Commands,  Up: Scripts
3812
38133.5 Assigning Values to Symbols
3814===============================
3815
3816You may assign a value to a symbol in a linker script.  This will define
3817the symbol and place it into the symbol table with a global scope.
3818
3819* Menu:
3820
3821* Simple Assignments::		Simple Assignments
3822* HIDDEN::			HIDDEN
3823* PROVIDE::			PROVIDE
3824* PROVIDE_HIDDEN::		PROVIDE_HIDDEN
3825* Source Code Reference::	How to use a linker script defined symbol in source code
3826
3827
3828File: ld.info,  Node: Simple Assignments,  Next: HIDDEN,  Up: Assignments
3829
38303.5.1 Simple Assignments
3831------------------------
3832
3833You may assign to a symbol using any of the C assignment operators:
3834
3835‘SYMBOL = EXPRESSION ;’
3836‘SYMBOL += EXPRESSION ;’
3837‘SYMBOL -= EXPRESSION ;’
3838‘SYMBOL *= EXPRESSION ;’
3839‘SYMBOL /= EXPRESSION ;’
3840‘SYMBOL <<= EXPRESSION ;’
3841‘SYMBOL >>= EXPRESSION ;’
3842‘SYMBOL &= EXPRESSION ;’
3843‘SYMBOL |= EXPRESSION ;’
3844
3845   The first case will define SYMBOL to the value of EXPRESSION.  In the
3846other cases, SYMBOL must already be defined, and the value will be
3847adjusted accordingly.
3848
3849   The special symbol name ‘.’ indicates the location counter.  You may
3850only use this within a ‘SECTIONS’ command.  *Note Location Counter::.
3851
3852   The semicolon after EXPRESSION is required.
3853
3854   Expressions are defined below; see *note Expressions::.
3855
3856   You may write symbol assignments as commands in their own right, or
3857as statements within a ‘SECTIONS’ command, or as part of an output
3858section description in a ‘SECTIONS’ command.
3859
3860   The section of the symbol will be set from the section of the
3861expression; for more information, see *note Expression Section::.
3862
3863   Here is an example showing the three different places that symbol
3864assignments may be used:
3865
3866     floating_point = 0;
3867     SECTIONS
3868     {
3869       .text :
3870         {
3871           *(.text)
3872           _etext = .;
3873         }
3874       _bdata = (. + 3) & ~ 3;
3875       .data : { *(.data) }
3876     }
3877In this example, the symbol ‘floating_point’ will be defined as zero.
3878The symbol ‘_etext’ will be defined as the address following the last
3879‘.text’ input section.  The symbol ‘_bdata’ will be defined as the
3880address following the ‘.text’ output section aligned upward to a 4 byte
3881boundary.
3882
3883
3884File: ld.info,  Node: HIDDEN,  Next: PROVIDE,  Prev: Simple Assignments,  Up: Assignments
3885
38863.5.2 HIDDEN
3887------------
3888
3889For ELF targeted ports, define a symbol that will be hidden and won’t be
3890exported.  The syntax is ‘HIDDEN(SYMBOL = EXPRESSION)’.
3891
3892   Here is the example from *note Simple Assignments::, rewritten to use
3893‘HIDDEN’:
3894
3895     HIDDEN(floating_point = 0);
3896     SECTIONS
3897     {
3898       .text :
3899         {
3900           *(.text)
3901           HIDDEN(_etext = .);
3902         }
3903       HIDDEN(_bdata = (. + 3) & ~ 3);
3904       .data : { *(.data) }
3905     }
3906In this case none of the three symbols will be visible outside this
3907module.
3908
3909
3910File: ld.info,  Node: PROVIDE,  Next: PROVIDE_HIDDEN,  Prev: HIDDEN,  Up: Assignments
3911
39123.5.3 PROVIDE
3913-------------
3914
3915In some cases, it is desirable for a linker script to define a symbol
3916only if it is referenced and is not defined by any object included in
3917the link.  For example, traditional linkers defined the symbol ‘etext’.
3918However, ANSI C requires that the user be able to use ‘etext’ as a
3919function name without encountering an error.  The ‘PROVIDE’ keyword may
3920be used to define a symbol, such as ‘etext’, only if it is referenced
3921but not defined.  The syntax is ‘PROVIDE(SYMBOL = EXPRESSION)’.
3922
3923   Here is an example of using ‘PROVIDE’ to define ‘etext’:
3924     SECTIONS
3925     {
3926       .text :
3927         {
3928           *(.text)
3929           _etext = .;
3930           PROVIDE(etext = .);
3931         }
3932     }
3933
3934   In this example, if the program defines ‘_etext’ (with a leading
3935underscore), the linker will give a multiple definition diagnostic.  If,
3936on the other hand, the program defines ‘etext’ (with no leading
3937underscore), the linker will silently use the definition in the program.
3938If the program references ‘etext’ but does not define it, the linker
3939will use the definition in the linker script.
3940
3941   Note - the ‘PROVIDE’ directive considers a common symbol to be
3942defined, even though such a symbol could be combined with the symbol
3943that the ‘PROVIDE’ would create.  This is particularly important when
3944considering constructor and destructor list symbols such as
3945‘__CTOR_LIST__’ as these are often defined as common symbols.
3946
3947
3948File: ld.info,  Node: PROVIDE_HIDDEN,  Next: Source Code Reference,  Prev: PROVIDE,  Up: Assignments
3949
39503.5.4 PROVIDE_HIDDEN
3951--------------------
3952
3953Similar to ‘PROVIDE’.  For ELF targeted ports, the symbol will be hidden
3954and won’t be exported.
3955
3956
3957File: ld.info,  Node: Source Code Reference,  Prev: PROVIDE_HIDDEN,  Up: Assignments
3958
39593.5.5 Source Code Reference
3960---------------------------
3961
3962Accessing a linker script defined variable from source code is not
3963intuitive.  In particular a linker script symbol is not equivalent to a
3964variable declaration in a high level language, it is instead a symbol
3965that does not have a value.
3966
3967   Before going further, it is important to note that compilers often
3968transform names in the source code into different names when they are
3969stored in the symbol table.  For example, Fortran compilers commonly
3970prepend or append an underscore, and C++ performs extensive ‘name
3971mangling’.  Therefore there might be a discrepancy between the name of a
3972variable as it is used in source code and the name of the same variable
3973as it is defined in a linker script.  For example in C a linker script
3974variable might be referred to as:
3975
3976       extern int foo;
3977
3978   But in the linker script it might be defined as:
3979
3980       _foo = 1000;
3981
3982   In the remaining examples however it is assumed that no name
3983transformation has taken place.
3984
3985   When a symbol is declared in a high level language such as C, two
3986things happen.  The first is that the compiler reserves enough space in
3987the program’s memory to hold the _value_ of the symbol.  The second is
3988that the compiler creates an entry in the program’s symbol table which
3989holds the symbol’s _address_.  ie the symbol table contains the address
3990of the block of memory holding the symbol’s value.  So for example the
3991following C declaration, at file scope:
3992
3993       int foo = 1000;
3994
3995   creates an entry called ‘foo’ in the symbol table.  This entry holds
3996the address of an ‘int’ sized block of memory where the number 1000 is
3997initially stored.
3998
3999   When a program references a symbol the compiler generates code that
4000first accesses the symbol table to find the address of the symbol’s
4001memory block and then code to read the value from that memory block.
4002So:
4003
4004       foo = 1;
4005
4006   looks up the symbol ‘foo’ in the symbol table, gets the address
4007associated with this symbol and then writes the value 1 into that
4008address.  Whereas:
4009
4010       int * a = & foo;
4011
4012   looks up the symbol ‘foo’ in the symbol table, gets its address and
4013then copies this address into the block of memory associated with the
4014variable ‘a’.
4015
4016   Linker scripts symbol declarations, by contrast, create an entry in
4017the symbol table but do not assign any memory to them.  Thus they are an
4018address without a value.  So for example the linker script definition:
4019
4020       foo = 1000;
4021
4022   creates an entry in the symbol table called ‘foo’ which holds the
4023address of memory location 1000, but nothing special is stored at
4024address 1000.  This means that you cannot access the _value_ of a linker
4025script defined symbol - it has no value - all you can do is access the
4026_address_ of a linker script defined symbol.
4027
4028   Hence when you are using a linker script defined symbol in source
4029code you should always take the address of the symbol, and never attempt
4030to use its value.  For example suppose you want to copy the contents of
4031a section of memory called .ROM into a section called .FLASH and the
4032linker script contains these declarations:
4033
4034       start_of_ROM   = .ROM;
4035       end_of_ROM     = .ROM + sizeof (.ROM);
4036       start_of_FLASH = .FLASH;
4037
4038   Then the C source code to perform the copy would be:
4039
4040       extern char start_of_ROM, end_of_ROM, start_of_FLASH;
4041
4042       memcpy (& start_of_FLASH, & start_of_ROM, & end_of_ROM - & start_of_ROM);
4043
4044   Note the use of the ‘&’ operators.  These are correct.  Alternatively
4045the symbols can be treated as the names of vectors or arrays and then
4046the code will again work as expected:
4047
4048       extern char start_of_ROM[], end_of_ROM[], start_of_FLASH[];
4049
4050       memcpy (start_of_FLASH, start_of_ROM, end_of_ROM - start_of_ROM);
4051
4052   Note how using this method does not require the use of ‘&’ operators.
4053
4054
4055File: ld.info,  Node: SECTIONS,  Next: MEMORY,  Prev: Assignments,  Up: Scripts
4056
40573.6 SECTIONS Command
4058====================
4059
4060The ‘SECTIONS’ command tells the linker how to map input sections into
4061output sections, and how to place the output sections in memory.
4062
4063   The format of the ‘SECTIONS’ command is:
4064     SECTIONS
4065     {
4066       SECTIONS-COMMAND
4067       SECTIONS-COMMAND
4068       ...
4069     }
4070
4071   Each SECTIONS-COMMAND may of be one of the following:
4072
4073   • an ‘ENTRY’ command (*note Entry command: Entry Point.)
4074   • a symbol assignment (*note Assignments::)
4075   • an output section description
4076   • an overlay description
4077
4078   The ‘ENTRY’ command and symbol assignments are permitted inside the
4079‘SECTIONS’ command for convenience in using the location counter in
4080those commands.  This can also make the linker script easier to
4081understand because you can use those commands at meaningful points in
4082the layout of the output file.
4083
4084   Output section descriptions and overlay descriptions are described
4085below.
4086
4087   If you do not use a ‘SECTIONS’ command in your linker script, the
4088linker will place each input section into an identically named output
4089section in the order that the sections are first encountered in the
4090input files.  If all input sections are present in the first file, for
4091example, the order of sections in the output file will match the order
4092in the first input file.  The first section will be at address zero.
4093
4094* Menu:
4095
4096* Output Section Description::	Output section description
4097* Output Section Name::		Output section name
4098* Output Section Address::	Output section address
4099* Input Section::		Input section description
4100* Output Section Data::		Output section data
4101* Output Section Keywords::	Output section keywords
4102* Output Section Discarding::	Output section discarding
4103* Output Section Attributes::	Output section attributes
4104* Overlay Description::		Overlay description
4105
4106
4107File: ld.info,  Node: Output Section Description,  Next: Output Section Name,  Up: SECTIONS
4108
41093.6.1 Output Section Description
4110--------------------------------
4111
4112The full description of an output section looks like this:
4113     SECTION [ADDRESS] [(TYPE)] :
4114       [AT(LMA)]
4115       [ALIGN(SECTION_ALIGN) | ALIGN_WITH_INPUT]
4116       [SUBALIGN(SUBSECTION_ALIGN)]
4117       [CONSTRAINT]
4118       {
4119         OUTPUT-SECTION-COMMAND
4120         OUTPUT-SECTION-COMMAND
4121         ...
4122       } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP] [,]
4123
4124   Most output sections do not use most of the optional section
4125attributes.
4126
4127   The whitespace around SECTION is required, so that the section name
4128is unambiguous.  The colon and the curly braces are also required.  The
4129comma at the end may be required if a FILLEXP is used and the next
4130SECTIONS-COMMAND looks like a continuation of the expression.  The line
4131breaks and other white space are optional.
4132
4133   Each OUTPUT-SECTION-COMMAND may be one of the following:
4134
4135   • a symbol assignment (*note Assignments::)
4136   • an input section description (*note Input Section::)
4137   • data values to include directly (*note Output Section Data::)
4138   • a special output section keyword (*note Output Section Keywords::)
4139
4140
4141File: ld.info,  Node: Output Section Name,  Next: Output Section Address,  Prev: Output Section Description,  Up: SECTIONS
4142
41433.6.2 Output Section Name
4144-------------------------
4145
4146The name of the output section is SECTION.  SECTION must meet the
4147constraints of your output format.  In formats which only support a
4148limited number of sections, such as ‘a.out’, the name must be one of the
4149names supported by the format (‘a.out’, for example, allows only
4150‘.text’, ‘.data’ or ‘.bss’).  If the output format supports any number
4151of sections, but with numbers and not names (as is the case for Oasys),
4152the name should be supplied as a quoted numeric string.  A section name
4153may consist of any sequence of characters, but a name which contains any
4154unusual characters such as commas must be quoted.
4155
4156   The output section name ‘/DISCARD/’ is special; *note Output Section
4157Discarding::.
4158
4159
4160File: ld.info,  Node: Output Section Address,  Next: Input Section,  Prev: Output Section Name,  Up: SECTIONS
4161
41623.6.3 Output Section Address
4163----------------------------
4164
4165The ADDRESS is an expression for the VMA (the virtual memory address) of
4166the output section.  This address is optional, but if it is provided
4167then the output address will be set exactly as specified.
4168
4169   If the output address is not specified then one will be chosen for
4170the section, based on the heuristic below.  This address will be
4171adjusted to fit the alignment requirement of the output section.  The
4172alignment requirement is the strictest alignment of any input section
4173contained within the output section.
4174
4175   The output section address heuristic is as follows:
4176
4177   • If an output memory REGION is set for the section then it is added
4178     to this region and its address will be the next free address in
4179     that region.
4180
4181   • If the MEMORY command has been used to create a list of memory
4182     regions then the first region which has attributes compatible with
4183     the section is selected to contain it.  The section’s output
4184     address will be the next free address in that region; *note
4185     MEMORY::.
4186
4187   • If no memory regions were specified, or none match the section then
4188     the output address will be based on the current value of the
4189     location counter.
4190
4191For example:
4192
4193     .text . : { *(.text) }
4194
4195and
4196
4197     .text : { *(.text) }
4198
4199are subtly different.  The first will set the address of the ‘.text’
4200output section to the current value of the location counter.  The second
4201will set it to the current value of the location counter aligned to the
4202strictest alignment of any of the ‘.text’ input sections.
4203
4204   The ADDRESS may be an arbitrary expression; *note Expressions::.  For
4205example, if you want to align the section on a 0x10 byte boundary, so
4206that the lowest four bits of the section address are zero, you could do
4207something like this:
4208     .text ALIGN(0x10) : { *(.text) }
4209This works because ‘ALIGN’ returns the current location counter aligned
4210upward to the specified value.
4211
4212   Specifying ADDRESS for a section will change the value of the
4213location counter, provided that the section is non-empty.  (Empty
4214sections are ignored).
4215
4216
4217File: ld.info,  Node: Input Section,  Next: Output Section Data,  Prev: Output Section Address,  Up: SECTIONS
4218
42193.6.4 Input Section Description
4220-------------------------------
4221
4222The most common output section command is an input section description.
4223
4224   The input section description is the most basic linker script
4225operation.  You use output sections to tell the linker how to lay out
4226your program in memory.  You use input section descriptions to tell the
4227linker how to map the input files into your memory layout.
4228
4229* Menu:
4230
4231* Input Section Basics::	Input section basics
4232* Input Section Wildcards::	Input section wildcard patterns
4233* Input Section Common::	Input section for common symbols
4234* Input Section Keep::		Input section and garbage collection
4235* Input Section Example::	Input section example
4236
4237
4238File: ld.info,  Node: Input Section Basics,  Next: Input Section Wildcards,  Up: Input Section
4239
42403.6.4.1 Input Section Basics
4241............................
4242
4243An input section description consists of a file name optionally followed
4244by a list of section names in parentheses.
4245
4246   The file name and the section name may be wildcard patterns, which we
4247describe further below (*note Input Section Wildcards::).
4248
4249   The most common input section description is to include all input
4250sections with a particular name in the output section.  For example, to
4251include all input ‘.text’ sections, you would write:
4252     *(.text)
4253Here the ‘*’ is a wildcard which matches any file name.  To exclude a
4254list of files from matching the file name wildcard, EXCLUDE_FILE may be
4255used to match all files except the ones specified in the EXCLUDE_FILE
4256list.  For example:
4257     EXCLUDE_FILE (*crtend.o *otherfile.o) *(.ctors)
4258will cause all .ctors sections from all files except ‘crtend.o’ and
4259otherfile.o’ to be included.  The EXCLUDE_FILE can also be placed
4260inside the section list, for example:
4261     *(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors)
4262The result of this is identically to the previous example.  Supporting
4263two syntaxes for EXCLUDE_FILE is useful if the section list contains
4264more than one section, as described below.
4265
4266   There are two ways to include more than one section:
4267     *(.text .rdata)
4268     *(.text) *(.rdata)
4269The difference between these is the order in which the ‘.text’ and
4270‘.rdata’ input sections will appear in the output section.  In the first
4271example, they will be intermingled, appearing in the same order as they
4272are found in the linker input.  In the second example, all ‘.text’ input
4273sections will appear first, followed by all ‘.rdata’ input sections.
4274
4275   When using EXCLUDE_FILE with more than one section, if the exclusion
4276is within the section list then the exclusion only applies to the
4277immediately following section, for example:
4278     *(EXCLUDE_FILE (*somefile.o) .text .rdata)
4279will cause all ‘.text’ sections from all files except ‘somefile.o’ to be
4280included, while all ‘.rdata’ sections from all files, including
4281somefile.o’, will be included.  To exclude the ‘.rdata’ sections from
4282somefile.o’ the example could be modified to:
4283     *(EXCLUDE_FILE (*somefile.o) .text EXCLUDE_FILE (*somefile.o) .rdata)
4284Alternatively, placing the EXCLUDE_FILE outside of the section list,
4285before the input file selection, will cause the exclusion to apply for
4286all sections.  Thus the previous example can be rewritten as:
4287     EXCLUDE_FILE (*somefile.o) *(.text .rdata)
4288
4289   You can specify a file name to include sections from a particular
4290file.  You would do this if one or more of your files contain special
4291data that needs to be at a particular location in memory.  For example:
4292     data.o(.data)
4293
4294   To refine the sections that are included based on the section flags
4295of an input section, INPUT_SECTION_FLAGS may be used.
4296
4297   Here is a simple example for using Section header flags for ELF
4298sections:
4299
4300     SECTIONS {
4301       .text : { INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS) *(.text) }
4302       .text2 :  { INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) }
4303     }
4304
4305   In this example, the output section ‘.text’ will be comprised of any
4306input section matching the name *(.text) whose section header flags
4307‘SHF_MERGE’ and ‘SHF_STRINGS’ are set.  The output section ‘.text2’ will
4308be comprised of any input section matching the name *(.text) whose
4309section header flag ‘SHF_WRITE’ is clear.
4310
4311   You can also specify files within archives by writing a pattern
4312matching the archive, a colon, then the pattern matching the file, with
4313no whitespace around the colon.
4314
4315‘archive:file’
4316     matches file within archive
4317‘archive:’
4318     matches the whole archive
4319‘:file’
4320     matches file but not one in an archive
4321
4322   Either one or both of ‘archive’ and ‘file’ can contain shell
4323wildcards.  On DOS based file systems, the linker will assume that a
4324single letter followed by a colon is a drive specifier, so ‘c:myfile.o4325is a simple file specification, not ‘myfile.o’ within an archive called
4326‘c’.  ‘archive:file’ filespecs may also be used within an ‘EXCLUDE_FILE’
4327list, but may not appear in other linker script contexts.  For instance,
4328you cannot extract a file from an archive by using ‘archive:file’ in an
4329‘INPUT’ command.
4330
4331   If you use a file name without a list of sections, then all sections
4332in the input file will be included in the output section.  This is not
4333commonly done, but it may by useful on occasion.  For example:
4334     data.o
4335
4336   When you use a file name which is not an ‘archive:file’ specifier and
4337does not contain any wild card characters, the linker will first see if
4338you also specified the file name on the linker command line or in an
4339‘INPUT’ command.  If you did not, the linker will attempt to open the
4340file as an input file, as though it appeared on the command line.  Note
4341that this differs from an ‘INPUT’ command, because the linker will not
4342search for the file in the archive search path.
4343
4344
4345File: ld.info,  Node: Input Section Wildcards,  Next: Input Section Common,  Prev: Input Section Basics,  Up: Input Section
4346
43473.6.4.2 Input Section Wildcard Patterns
4348.......................................
4349
4350In an input section description, either the file name or the section
4351name or both may be wildcard patterns.
4352
4353   The file name of ‘*’ seen in many examples is a simple wildcard
4354pattern for the file name.
4355
4356   The wildcard patterns are like those used by the Unix shell.
4357
4358‘*’
4359     matches any number of characters
4360‘?’
4361     matches any single character
4362‘[CHARS]’
4363     matches a single instance of any of the CHARS; the ‘-’ character
4364     may be used to specify a range of characters, as in ‘[a-z]’ to
4365     match any lower case letter
4366‘\’
4367     quotes the following character
4368
4369   File name wildcard patterns only match files which are explicitly
4370specified on the command line or in an ‘INPUT’ command.  The linker does
4371not search directories to expand wildcards.
4372
4373   If a file name matches more than one wildcard pattern, or if a file
4374name appears explicitly and is also matched by a wildcard pattern, the
4375linker will use the first match in the linker script.  For example, this
4376sequence of input section descriptions is probably in error, because the
4377data.o’ rule will not be used:
4378     .data : { *(.data) }
4379     .data1 : { data.o(.data) }
4380
4381   Normally, the linker will place files and sections matched by
4382wildcards in the order in which they are seen during the link.  You can
4383change this by using the ‘SORT_BY_NAME’ keyword, which appears before a
4384wildcard pattern in parentheses (e.g., ‘SORT_BY_NAME(.text*)’).  When
4385the ‘SORT_BY_NAME’ keyword is used, the linker will sort the files or
4386sections into ascending order by name before placing them in the output
4387file.
4388
4389   ‘SORT_BY_ALIGNMENT’ is similar to ‘SORT_BY_NAME’.
4390‘SORT_BY_ALIGNMENT’ will sort sections into descending order of
4391alignment before placing them in the output file.  Placing larger
4392alignments before smaller alignments can reduce the amount of padding
4393needed.
4394
4395   ‘SORT_BY_INIT_PRIORITY’ is also similar to ‘SORT_BY_NAME’.
4396‘SORT_BY_INIT_PRIORITY’ will sort sections into ascending numerical
4397order of the GCC init_priority attribute encoded in the section name
4398before placing them in the output file.  In ‘.init_array.NNNNN’ and
4399.fini_array.NNNNN’, ‘NNNNN’ is the init_priority.  In ‘.ctors.NNNNN4400and ‘.dtors.NNNNN’, ‘NNNNN’ is 65535 minus the init_priority.
4401
4402   ‘SORT’ is an alias for ‘SORT_BY_NAME’.
4403
4404   ‘REVERSE’ indicates that the sorting should be reversed.  If used on
4405its own then ‘REVERSE’ implies ‘SORT_BY_NAME’, otherwise it reverses the
4406enclosed ‘SORT..’ command.  Note - reverse sorting of alignment is not
4407currently supported.
4408
4409   Note - the sorting commands only accept a single wildcard pattern.
4410So for example the following will not work:
4411       *(REVERSE(.text* .init*))
4412   To resolve this problem list the patterns individually, like this:
4413       *(REVERSE(.text*))
4414       *(REVERSE(.init*))
4415
4416   Note - you can put the ‘EXCLUDE_FILE’ command inside a sorting
4417command, but not the other way around.  So for example:
4418       *(SORT_BY_NAME(EXCLUDE_FILE(foo) .text*))
4419   will work, but:
4420       *(EXCLUDE_FILE(foo) SORT_BY_NAME(.text*))
4421   will not.
4422
4423   When there are nested section sorting commands in linker script,
4424there can be at most 1 level of nesting for section sorting commands.
4425
4426  1. ‘SORT_BY_NAME’ (‘SORT_BY_ALIGNMENT’ (wildcard section pattern)).
4427     It will sort the input sections by name first, then by alignment if
4428     two sections have the same name.
4429  2. ‘SORT_BY_ALIGNMENT’ (‘SORT_BY_NAME’ (wildcard section pattern)).
4430     It will sort the input sections by alignment first, then by name if
4431     two sections have the same alignment.
4432  3. ‘SORT_BY_NAME’ (‘SORT_BY_NAME’ (wildcard section pattern)) is
4433     treated the same as ‘SORT_BY_NAME’ (wildcard section pattern).
4434  4. ‘SORT_BY_ALIGNMENT’ (‘SORT_BY_ALIGNMENT’ (wildcard section
4435     pattern)) is treated the same as ‘SORT_BY_ALIGNMENT’ (wildcard
4436     section pattern).
4437  5. ‘SORT_BY_NAME’ (‘REVERSE’ (wildcard section pattern)) reverse sorts
4438     by name.
4439  6. ‘REVERSE’ (‘SORT_BY_NAME’ (wildcard section pattern)) reverse sorts
4440     by name.
4441  7. ‘SORT_BY_INIT_PRIORITY’ (‘REVERSE’ (wildcard section pattern))
4442     reverse sorts by init priority.
4443  8. All other nested section sorting commands are invalid.
4444
4445   When both command-line section sorting option and linker script
4446section sorting command are used, section sorting command always takes
4447precedence over the command-line option.
4448
4449   If the section sorting command in linker script isn’t nested, the
4450command-line option will make the section sorting command to be treated
4451as nested sorting command.
4452
4453  1. ‘SORT_BY_NAME’ (wildcard section pattern ) with ‘--sort-sections
4454     alignment’ is equivalent to ‘SORT_BY_NAME’ (‘SORT_BY_ALIGNMENT’
4455     (wildcard section pattern)).
4456  2. ‘SORT_BY_ALIGNMENT’ (wildcard section pattern) with ‘--sort-section
4457     name’ is equivalent to ‘SORT_BY_ALIGNMENT’ (‘SORT_BY_NAME’
4458     (wildcard section pattern)).
4459
4460   If the section sorting command in linker script is nested, the
4461command-line option will be ignored.
4462
4463   ‘SORT_NONE’ disables section sorting by ignoring the command-line
4464section sorting option.
4465
4466   If you ever get confused about where input sections are going, use
4467the ‘-M’ linker option to generate a map file.  The map file shows
4468precisely how input sections are mapped to output sections.
4469
4470   This example shows how wildcard patterns might be used to partition
4471files.  This linker script directs the linker to place all ‘.text’
4472sections in ‘.text’ and all ‘.bss’ sections in ‘.bss’.  The linker will
4473place the ‘.data’ section from all files beginning with an upper case
4474character in ‘.DATA’; for all other files, the linker will place the
4475‘.data’ section in ‘.data’.
4476     SECTIONS {
4477       .text : { *(.text) }
4478       .DATA : { [A-Z]*(.data) }
4479       .data : { *(.data) }
4480       .bss : { *(.bss) }
4481     }
4482
4483
4484File: ld.info,  Node: Input Section Common,  Next: Input Section Keep,  Prev: Input Section Wildcards,  Up: Input Section
4485
44863.6.4.3 Input Section for Common Symbols
4487........................................
4488
4489A special notation is needed for common symbols, because in many object
4490file formats common symbols do not have a particular input section.  The
4491linker treats common symbols as though they are in an input section
4492named ‘COMMON’.
4493
4494   You may use file names with the ‘COMMON’ section just as with any
4495other input sections.  You can use this to place common symbols from a
4496particular input file in one section while common symbols from other
4497input files are placed in another section.
4498
4499   In most cases, common symbols in input files will be placed in the
4500‘.bss’ section in the output file.  For example:
4501     .bss { *(.bss) *(COMMON) }
4502
4503   Some object file formats have more than one type of common symbol.
4504For example, the MIPS ELF object file format distinguishes standard
4505common symbols and small common symbols.  In this case, the linker will
4506use a different special section name for other types of common symbols.
4507In the case of MIPS ELF, the linker uses ‘COMMON’ for standard common
4508symbols and ‘.scommon’ for small common symbols.  This permits you to
4509map the different types of common symbols into memory at different
4510locations.
4511
4512   You will sometimes see ‘[COMMON]’ in old linker scripts.  This
4513notation is now considered obsolete.  It is equivalent to ‘*(COMMON)’.
4514
4515
4516File: ld.info,  Node: Input Section Keep,  Next: Input Section Example,  Prev: Input Section Common,  Up: Input Section
4517
45183.6.4.4 Input Section and Garbage Collection
4519............................................
4520
4521When link-time garbage collection is in use (‘--gc-sections’), it is
4522often useful to mark sections that should not be eliminated.  This is
4523accomplished by surrounding an input section’s wildcard entry with
4524‘KEEP()’, as in ‘KEEP(*(.init))’ or ‘KEEP(SORT_BY_NAME(*)(.ctors))’.
4525
4526
4527File: ld.info,  Node: Input Section Example,  Prev: Input Section Keep,  Up: Input Section
4528
45293.6.4.5 Input Section Example
4530.............................
4531
4532The following example is a complete linker script.  It tells the linker
4533to read all of the sections from file ‘all.o’ and place them at the
4534start of output section ‘outputa’ which starts at location ‘0x10000’.
4535All of section ‘.input1’ from file ‘foo.o’ follows immediately, in the
4536same output section.  All of section ‘.input2’ from ‘foo.o’ goes into
4537output section ‘outputb’, followed by section ‘.input1’ from ‘foo1.o’.
4538All of the remaining ‘.input1’ and ‘.input2’ sections from any files are
4539written to output section ‘outputc’.
4540
4541     SECTIONS {
4542       outputa 0x10000 :
4543         {
4544         all.o
4545         foo.o (.input1)
4546         }
4547       outputb :
4548         {
4549         foo.o (.input2)
4550         foo1.o (.input1)
4551         }
4552       outputc :
4553         {
4554         *(.input1)
4555         *(.input2)
4556         }
4557     }
4558
4559   If an output section’s name is the same as the input section’s name
4560and is representable as a C identifier, then the linker will
4561automatically *note PROVIDE:: two symbols: __start_SECNAME and
4562__stop_SECNAME, where SECNAME is the name of the section.  These
4563indicate the start address and end address of the output section
4564respectively.  Note: most section names are not representable as C
4565identifiers because they contain a ‘.’ character.
4566
4567
4568File: ld.info,  Node: Output Section Data,  Next: Output Section Keywords,  Prev: Input Section,  Up: SECTIONS
4569
45703.6.5 Output Section Data
4571-------------------------
4572
4573You can include explicit bytes of data in an output section by using
4574‘BYTE’, ‘SHORT’, ‘LONG’, ‘QUAD’, or ‘SQUAD’ as an output section
4575command.  Each keyword is followed by an expression in parentheses
4576providing the value to store (*note Expressions::).  The value of the
4577expression is stored at the current value of the location counter.
4578
4579   The ‘BYTE’, ‘SHORT’, ‘LONG’, and ‘QUAD’ commands store one, two,
4580four, and eight bytes (respectively).  After storing the bytes, the
4581location counter is incremented by the number of bytes stored.
4582
4583   For example, this will store the byte 1 followed by the four byte
4584value of the symbol ‘addr’:
4585     BYTE(1)
4586     LONG(addr)
4587
4588   When using a 64 bit host or target, ‘QUAD’ and ‘SQUAD’ are the same;
4589they both store an 8 byte, or 64 bit, value.  When both host and target
4590are 32 bits, an expression is computed as 32 bits.  In this case ‘QUAD’
4591stores a 32 bit value zero extended to 64 bits, and ‘SQUAD’ stores a 32
4592bit value sign extended to 64 bits.
4593
4594   If the object file format of the output file has an explicit
4595endianness, which is the normal case, the value will be stored in that
4596endianness.  When the object file format does not have an explicit
4597endianness, as is true of, for example, S-records, the value will be
4598stored in the endianness of the first input object file.
4599
4600   You can include a zero-terminated string in an output section by
4601using ‘ASCIZ’.  The keyword is followed by a string which is stored at
4602the current value of the location counter adding a zero byte at the end.
4603If the string includes spaces it must be enclosed in double quotes.  The
4604string may contain ’\n’, ’\r’, ’\t’ and octal numbers.  Hex numbers are
4605not supported.
4606
4607   For example, this string of 16 characters will create a 17 byte area
4608       ASCIZ "This is 16 bytes"
4609
4610   Note—these commands only work inside a section description and not
4611between them, so the following will produce an error from the linker:
4612     SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }
4613   whereas this will work:
4614     SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }
4615
4616   You may use the ‘FILL’ command to set the fill pattern for the
4617current section.  It is followed by an expression in parentheses.  Any
4618otherwise unspecified regions of memory within the section (for example,
4619gaps left due to the required alignment of input sections) are filled
4620with the value of the expression, repeated as necessary.  A ‘FILL’
4621statement covers memory locations after the point at which it occurs in
4622the section definition; by including more than one ‘FILL’ statement, you
4623can have different fill patterns in different parts of an output
4624section.
4625
4626   This example shows how to fill unspecified regions of memory with the
4627value ‘0x90’:
4628     FILL(0x90909090)
4629
4630   The ‘FILL’ command is similar to the ‘=FILLEXP’ output section
4631attribute, but it only affects the part of the section following the
4632‘FILL’ command, rather than the entire section.  If both are used, the
4633‘FILL’ command takes precedence.  *Note Output Section Fill::, for
4634details on the fill expression.
4635
4636   Note - normally the value of ‘expression’ is zero extended to 4 bytes
4637when used to fill gaps.  Thus ‘FILL(144)’ will fill a region with
4638repeats of the pattern ‘0 0 0 144’.  The value is treated as a
4639big-endian number, so for example ‘FILL(22 * 256 + 23)’ will fill the
4640region with repeats of the pattern ‘0 0 22 23’.  If the expression
4641results in a value with more than 4 significant bytes only the least 4
4642bytes of the value will be used.
4643
4644   The above rules do not apply when the ‘expression’ is a simple
4645hexadecimal number.  In this case zero extension is not performed and
4646all bytes are significant.  So ‘FILL(0x90)’ will fill a region with
4647repeats of ‘0x90’ with no zero bytes, and ‘FILL(0x9192)’ will fill the
4648region with repeats of ‘0x91 0x92’.  Zero bytes in a hexadecimal
4649expression are significant even at the start, so ‘FILL(0x0090)’ will
4650fill a region with repeats of ‘0x00 0x90’.
4651
4652   Hexadecimal numbers can be longer than 4 bytes, and all of the bytes
4653are significant, so ‘FILL(0x123456789a)’ will fill a region with repeats
4654of the 5 byte sequence ‘0x12 0x34 0x56 0x78 0x9a’.  Excess bytes in a
4655hexadecimal value beyond the size of a region will be silently ignored.
4656
4657   The above only applies to hexadecimal numbers specified as
4658‘0x[0-9][a-f][A-F]’.  Hexadecimal numbers specified with a ‘$’ prefix,
4659or a ‘h’, ‘H’, ‘x’ or ‘X’ suffix will follow the normal fill value
4660rules.  This also applies to expressions that involve hexadecimal
4661numbers, and hexadecimal numbers that have a magnitude suffix.
4662
4663   The ‘LINKER_VERSION’ command inserts a string containing the version
4664of the linker at the current point.  Note - by default this directive is
4665disabled and will do nothing.  It only becomes active if the
4666‘--enable-linker-version’ command line option is used.
4667
4668   Built-in linker scripts for ELF based targets already include this
4669directive in their ‘.comment’ section.
4670
4671
4672File: ld.info,  Node: Output Section Keywords,  Next: Output Section Discarding,  Prev: Output Section Data,  Up: SECTIONS
4673
46743.6.6 Output Section Keywords
4675-----------------------------
4676
4677There are a couple of keywords which can appear as output section
4678commands.
4679
4680‘CREATE_OBJECT_SYMBOLS’
4681     The command tells the linker to create a symbol for each input
4682     file.  The name of each symbol will be the name of the
4683     corresponding input file.  The section of each symbol will be the
4684     output section in which the ‘CREATE_OBJECT_SYMBOLS’ command
4685     appears.
4686
4687     This is conventional for the a.out object file format.  It is not
4688     normally used for any other object file format.
4689
4690‘CONSTRUCTORS’
4691     When linking using the a.out object file format, the linker uses an
4692     unusual set construct to support C++ global constructors and
4693     destructors.  When linking object file formats which do not support
4694     arbitrary sections, such as ECOFF and XCOFF, the linker will
4695     automatically recognize C++ global constructors and destructors by
4696     name.  For these object file formats, the ‘CONSTRUCTORS’ command
4697     tells the linker to place constructor information in the output
4698     section where the ‘CONSTRUCTORS’ command appears.  The
4699     ‘CONSTRUCTORS’ command is ignored for other object file formats.
4700
4701     The symbol ‘__CTOR_LIST__’ marks the start of the global
4702     constructors, and the symbol ‘__CTOR_END__’ marks the end.
4703     Similarly, ‘__DTOR_LIST__’ and ‘__DTOR_END__’ mark the start and
4704     end of the global destructors.  The first word in the list is the
4705     number of entries, followed by the address of each constructor or
4706     destructor, followed by a zero word.  The compiler must arrange to
4707     actually run the code.  For these object file formats GNU C++
4708     normally calls constructors from a subroutine ‘__main’; a call to
4709     ‘__main’ is automatically inserted into the startup code for
4710     ‘main’.  GNU C++ normally runs destructors either by using
4711     ‘atexit’, or directly from the function ‘exit’.
4712
4713     For object file formats such as ‘COFF’ or ‘ELF’ which support
4714     arbitrary section names, GNU C++ will normally arrange to put the
4715     addresses of global constructors and destructors into the ‘.ctors’
4716     and ‘.dtors’ sections.  Placing the following sequence into your
4717     linker script will build the sort of table which the GNU C++
4718     runtime code expects to see.
4719
4720                __CTOR_LIST__ = .;
4721                LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
4722                *(.ctors)
4723                LONG(0)
4724                __CTOR_END__ = .;
4725                __DTOR_LIST__ = .;
4726                LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
4727                *(.dtors)
4728                LONG(0)
4729                __DTOR_END__ = .;
4730
4731     If you are using the GNU C++ support for initialization priority,
4732     which provides some control over the order in which global
4733     constructors are run, you must sort the constructors at link time
4734     to ensure that they are executed in the correct order.  When using
4735     the ‘CONSTRUCTORS’ command, use ‘SORT_BY_NAME(CONSTRUCTORS)’
4736     instead.  When using the ‘.ctors’ and ‘.dtors’ sections, use
4737     ‘*(SORT_BY_NAME(.ctors))’ and ‘*(SORT_BY_NAME(.dtors))’ instead of
4738     just ‘*(.ctors)’ and ‘*(.dtors)’.
4739
4740     Normally the compiler and linker will handle these issues
4741     automatically, and you will not need to concern yourself with them.
4742     However, you may need to consider this if you are using C++ and
4743     writing your own linker scripts.
4744
4745
4746File: ld.info,  Node: Output Section Discarding,  Next: Output Section Attributes,  Prev: Output Section Keywords,  Up: SECTIONS
4747
47483.6.7 Output Section Discarding
4749-------------------------------
4750
4751The linker will not normally create output sections with no contents.
4752This is for convenience when referring to input sections that may or may
4753not be present in any of the input files.  For example:
4754     .foo : { *(.foo) }
4755will only create a ‘.foo’ section in the output file if there is a
4756‘.foo’ section in at least one input file, and if the input sections are
4757not all empty.  Other link script directives that allocate space in an
4758output section will also create the output section.  So too will
4759assignments to dot even if the assignment does not create space, except
4760for ‘. = 0’, ‘. = . + 0’, ‘. = sym’, ‘. = . + sym’ and ‘. = ALIGN (. !=
47610, expr, 1)’ when ‘sym’ is an absolute symbol of value 0 defined in the
4762script.  This allows you to force output of an empty section with ‘. =
4763.’.
4764
4765   The linker will ignore address assignments (*note Output Section
4766Address::) on discarded output sections, except when the linker script
4767defines symbols in the output section.  In that case the linker will
4768obey the address assignments, possibly advancing dot even though the
4769section is discarded.
4770
4771   The special output section name ‘/DISCARD/’ may be used to discard
4772input sections.  Any input sections which are assigned to an output
4773section named ‘/DISCARD/’ are not included in the output file.
4774
4775   This can be used to discard input sections marked with the ELF flag
4776‘SHF_GNU_RETAIN’, which would otherwise have been saved from linker
4777garbage collection.
4778
4779   Note, sections that match the ‘/DISCARD/’ output section will be
4780discarded even if they are in an ELF section group which has other
4781members which are not being discarded.  This is deliberate.  Discarding
4782takes precedence over grouping.
4783
4784
4785File: ld.info,  Node: Output Section Attributes,  Next: Overlay Description,  Prev: Output Section Discarding,  Up: SECTIONS
4786
47873.6.8 Output Section Attributes
4788-------------------------------
4789
4790We showed above that the full description of an output section looked
4791like this:
4792
4793     SECTION [ADDRESS] [(TYPE)] :
4794       [AT(LMA)]
4795       [ALIGN(SECTION_ALIGN) | ALIGN_WITH_INPUT]
4796       [SUBALIGN(SUBSECTION_ALIGN)]
4797       [CONSTRAINT]
4798       {
4799         OUTPUT-SECTION-COMMAND
4800         OUTPUT-SECTION-COMMAND
4801         ...
4802       } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
4803
4804   We’ve already described SECTION, ADDRESS, and OUTPUT-SECTION-COMMAND.
4805In this section we will describe the remaining section attributes.
4806
4807* Menu:
4808
4809* Output Section Type::		Output section type
4810* Output Section LMA::		Output section LMA
4811* Forced Output Alignment::	Forced Output Alignment
4812* Forced Input Alignment::	Forced Input Alignment
4813* Output Section Constraint::   Output section constraint
4814* Output Section Region::	Output section region
4815* Output Section Phdr::		Output section phdr
4816* Output Section Fill::		Output section fill
4817
4818
4819File: ld.info,  Node: Output Section Type,  Next: Output Section LMA,  Up: Output Section Attributes
4820
48213.6.8.1 Output Section Type
4822...........................
4823
4824Each output section may have a type.  The type is a keyword in
4825parentheses.  The following types are defined:
4826
4827‘NOLOAD’
4828     The section should be marked as not loadable, so that it will not
4829     be loaded into memory when the program is run.
4830
4831‘READONLY’
4832     The section should be marked as read-only.
4833
4834‘DSECT’
4835‘COPY’
4836‘INFO’
4837‘OVERLAY’
4838     These type names are supported for backward compatibility, and are
4839     rarely used.  They all have the same effect: the section should be
4840     marked as not allocatable, so that no memory is allocated for the
4841     section when the program is run.
4842
4843‘TYPE = TYPE’
4844     Set the section type to the integer TYPE.  When generating an ELF
4845     output file, type names ‘SHT_PROGBITS’, ‘SHT_STRTAB’, ‘SHT_NOTE’,
4846     ‘SHT_NOBITS’, ‘SHT_INIT_ARRAY’, ‘SHT_FINI_ARRAY’, and
4847     ‘SHT_PREINIT_ARRAY’ are also allowed for TYPE.  It is the user’s
4848     responsibility to ensure that any special requirements of the
4849     section type are met.
4850
4851     Note - the TYPE only is used if some or all of the contents of the
4852     section do not have an implicit type of their own.  So for example:
4853            .foo . TYPE = SHT_PROGBITS { *(.bar) }
4854     will set the type of section ‘.foo’ to the type of the section
4855     ‘.bar’ in the input files, which may not be the SHT_PROGBITS type.
4856     Whereas:
4857            .foo . TYPE = SHT_PROGBITS { BYTE(1) }
4858     will set the type of ‘.foo’ to SHT_PROGBBITS. If it is necessary to
4859     override the type of incoming sections and force the output section
4860     type then an extra piece of untyped data will be needed:
4861            .foo . TYPE = SHT_PROGBITS { BYTE(1); *(.bar) }
4862
4863‘READONLY ( TYPE = TYPE )’
4864     This form of the syntax combines the READONLY type with the type
4865     specified by TYPE.
4866
4867   The linker normally sets the attributes of an output section based on
4868the input sections which map into it.  You can override this by using
4869the section type.  For example, in the script sample below, the ‘ROM’
4870section is addressed at memory location ‘0’ and does not need to be
4871loaded when the program is run.
4872     SECTIONS {
4873       ROM 0 (NOLOAD) : { ... }
4874       ...
4875     }
4876
4877
4878File: ld.info,  Node: Output Section LMA,  Next: Forced Output Alignment,  Prev: Output Section Type,  Up: Output Section Attributes
4879
48803.6.8.2 Output Section LMA
4881..........................
4882
4883Every section has a virtual address (VMA) and a load address (LMA); see
4884*note Basic Script Concepts::.  The virtual address is specified by the
4885*note Output Section Address:: described earlier.  The load address is
4886specified by the ‘AT’ or ‘AT>’ keywords.  Specifying a load address is
4887optional.
4888
4889   The ‘AT’ keyword takes an expression as an argument.  This specifies
4890the exact load address of the section.  The ‘AT>’ keyword takes the name
4891of a memory region as an argument.  *Note MEMORY::.  The load address of
4892the section is set to the next free address in the region, aligned to
4893the section’s alignment requirements.
4894
4895   If neither ‘AT’ nor ‘AT>’ is specified for an allocatable section,
4896the linker will use the following heuristic to determine the load
4897address:
4898
4899   • If the section has a specific VMA address, then this is used as the
4900     LMA address as well.
4901
4902   • If the section is not allocatable then its LMA is set to its VMA.
4903
4904   • Otherwise if a memory region can be found that is compatible with
4905     the current section, and this region contains at least one section,
4906     then the LMA is set so the difference between the VMA and LMA is
4907     the same as the difference between the VMA and LMA of the last
4908     section in the located region.
4909
4910   • If no memory regions have been declared then a default region that
4911     covers the entire address space is used in the previous step.
4912
4913   • If no suitable region could be found, or there was no previous
4914     section then the LMA is set equal to the VMA.
4915
4916   This feature is designed to make it easy to build a ROM image.  For
4917example, the following linker script creates three output sections: one
4918called ‘.text’, which starts at ‘0x1000’, one called ‘.mdata’, which is
4919loaded at the end of the ‘.text’ section even though its VMA is
4920‘0x2000’, and one called ‘.bss’ to hold uninitialized data at address
4921‘0x3000’.  The symbol ‘_data’ is defined with the value ‘0x2000’, which
4922shows that the location counter holds the VMA value, not the LMA value.
4923
4924     SECTIONS
4925       {
4926       .text 0x1000 : { *(.text) _etext = . ; }
4927       .mdata 0x2000 :
4928         AT ( ADDR (.text) + SIZEOF (.text) )
4929         { _data = . ; *(.data); _edata = . ;  }
4930       .bss 0x3000 :
4931         { _bstart = . ;  *(.bss) *(COMMON) ; _bend = . ;}
4932     }
4933
4934   The run-time initialization code for use with a program generated
4935with this linker script would include something like the following, to
4936copy the initialized data from the ROM image to its runtime address.
4937Notice how this code takes advantage of the symbols defined by the
4938linker script.
4939
4940     extern char _etext, _data, _edata, _bstart, _bend;
4941     char *src = &_etext;
4942     char *dst = &_data;
4943
4944     /* ROM has data at end of text; copy it.  */
4945     while (dst < &_edata)
4946       *dst++ = *src++;
4947
4948     /* Zero bss.  */
4949     for (dst = &_bstart; dst< &_bend; dst++)
4950       *dst = 0;
4951
4952
4953File: ld.info,  Node: Forced Output Alignment,  Next: Forced Input Alignment,  Prev: Output Section LMA,  Up: Output Section Attributes
4954
49553.6.8.3 Forced Output Alignment
4956...............................
4957
4958You can increase an output section’s alignment by using ALIGN. As an
4959alternative you can enforce that the difference between the VMA and LMA
4960remains intact throughout this output section with the ALIGN_WITH_INPUT
4961attribute.
4962
4963
4964File: ld.info,  Node: Forced Input Alignment,  Next: Output Section Constraint,  Prev: Forced Output Alignment,  Up: Output Section Attributes
4965
49663.6.8.4 Forced Input Alignment
4967..............................
4968
4969You can force input section alignment within an output section by using
4970SUBALIGN. The value specified overrides any alignment given by input
4971sections, whether larger or smaller.
4972
4973
4974File: ld.info,  Node: Output Section Constraint,  Next: Output Section Region,  Prev: Forced Input Alignment,  Up: Output Section Attributes
4975
49763.6.8.5 Output Section Constraint
4977.................................
4978
4979You can specify that an output section should only be created if all of
4980its input sections are read-only or all of its input sections are
4981read-write by using the keyword ‘ONLY_IF_RO’ and ‘ONLY_IF_RW’
4982respectively.
4983
4984
4985File: ld.info,  Node: Output Section Region,  Next: Output Section Phdr,  Prev: Output Section Constraint,  Up: Output Section Attributes
4986
49873.6.8.6 Output Section Region
4988.............................
4989
4990You can assign a section to a previously defined region of memory by
4991using ‘>REGION’.  *Note MEMORY::.
4992
4993   Here is a simple example:
4994     MEMORY { rom : ORIGIN = 0x1000, LENGTH = 0x1000 }
4995     SECTIONS { ROM : { *(.text) } >rom }
4996
4997
4998File: ld.info,  Node: Output Section Phdr,  Next: Output Section Fill,  Prev: Output Section Region,  Up: Output Section Attributes
4999
50003.6.8.7 Output Section Phdr
5001...........................
5002
5003You can assign a section to a previously defined program segment by
5004using ‘:PHDR’.  *Note PHDRS::.  If a section is assigned to one or more
5005segments, then all subsequent allocated sections will be assigned to
5006those segments as well, unless they use an explicitly ‘:PHDR’ modifier.
5007You can use ‘:NONE’ to tell the linker to not put the section in any
5008segment at all.
5009
5010   Here is a simple example:
5011     PHDRS { text PT_LOAD ; }
5012     SECTIONS { .text : { *(.text) } :text }
5013
5014
5015File: ld.info,  Node: Output Section Fill,  Prev: Output Section Phdr,  Up: Output Section Attributes
5016
50173.6.8.8 Output Section Fill
5018...........................
5019
5020You can set the fill pattern for an entire section by using ‘=FILLEXP’.
5021FILLEXP is an expression (*note Expressions::).  Any otherwise
5022unspecified regions of memory within the output section (for example,
5023gaps left due to the required alignment of input sections) will be
5024filled with the value, repeated as necessary.  If the fill expression is
5025a simple hex number, ie.  a string of hex digit starting with ‘0x’ and
5026without a trailing ‘k’ or ‘M’, then an arbitrarily long sequence of hex
5027digits can be used to specify the fill pattern; Leading zeros become
5028part of the pattern too.  For all other cases, including extra
5029parentheses or a unary ‘+’, the fill pattern is the four least
5030significant bytes of the value of the expression.  If the value is less
5031than four bytes in size then it will be zero extended to four bytes.  In
5032all cases, the number is big-endian.
5033
5034     Fill Value     Fill Pattern
5035     0x90           90 90 90 90
5036     0x0090         00 90 00 90
5037     144            00 00 00 90
5038
5039   You can also change the fill value with a ‘FILL’ command in the
5040output section commands; (*note Output Section Data::).
5041
5042   Here is a simple example:
5043     SECTIONS { .text : { *(.text) } =0x90909090 }
5044
5045
5046File: ld.info,  Node: Overlay Description,  Prev: Output Section Attributes,  Up: SECTIONS
5047
50483.6.9 Overlay Description
5049-------------------------
5050
5051An overlay description provides an easy way to describe sections which
5052are to be loaded as part of a single memory image but are to be run at
5053the same memory address.  At run time, some sort of overlay manager will
5054copy the overlaid sections in and out of the runtime memory address as
5055required, perhaps by simply manipulating addressing bits.  This approach
5056can be useful, for example, when a certain region of memory is faster
5057than another.
5058
5059   Overlays are described using the ‘OVERLAY’ command.  The ‘OVERLAY’
5060command is used within a ‘SECTIONS’ command, like an output section
5061description.  The full syntax of the ‘OVERLAY’ command is as follows:
5062     OVERLAY [START] : [NOCROSSREFS] [AT ( LDADDR )]
5063       {
5064         SECNAME1
5065           {
5066             OUTPUT-SECTION-COMMAND
5067             OUTPUT-SECTION-COMMAND
5068             ...
5069           } [:PHDR...] [=FILL]
5070         SECNAME2
5071           {
5072             OUTPUT-SECTION-COMMAND
5073             OUTPUT-SECTION-COMMAND
5074             ...
5075           } [:PHDR...] [=FILL]
5076         ...
5077       } [>REGION] [:PHDR...] [=FILL] [,]
5078
5079   Everything is optional except ‘OVERLAY’ (a keyword), and each section
5080must have a name (SECNAME1 and SECNAME2 above).  The section definitions
5081within the ‘OVERLAY’ construct are identical to those within the general
5082‘SECTIONS’ construct (*note SECTIONS::), except that no addresses and no
5083memory regions may be defined for sections within an ‘OVERLAY’.
5084
5085   The comma at the end may be required if a FILL is used and the next
5086SECTIONS-COMMAND looks like a continuation of the expression.
5087
5088   The sections are all defined with the same starting address.  The
5089load addresses of the sections are arranged such that they are
5090consecutive in memory starting at the load address used for the
5091‘OVERLAY’ as a whole (as with normal section definitions, the load
5092address is optional, and defaults to the start address; the start
5093address is also optional, and defaults to the current value of the
5094location counter).
5095
5096   If the ‘NOCROSSREFS’ keyword is used, and there are any references
5097among the sections, the linker will report an error.  Since the sections
5098all run at the same address, it normally does not make sense for one
5099section to refer directly to another.  *Note NOCROSSREFS: Miscellaneous
5100Commands.
5101
5102   For each section within the ‘OVERLAY’, the linker automatically
5103provides two symbols.  The symbol ‘__load_start_SECNAME’ is defined as
5104the starting load address of the section.  The symbol
5105‘__load_stop_SECNAME’ is defined as the final load address of the
5106section.  Any characters within SECNAME which are not legal within C
5107identifiers are removed.  C (or assembler) code may use these symbols to
5108move the overlaid sections around as necessary.
5109
5110   At the end of the overlay, the value of the location counter is set
5111to the start address of the overlay plus the size of the largest
5112section.
5113
5114   Here is an example.  Remember that this would appear inside a
5115‘SECTIONS’ construct.
5116       OVERLAY 0x1000 : AT (0x4000)
5117        {
5118          .text0 { o1/*.o(.text) }
5119          .text1 { o2/*.o(.text) }
5120        }
5121This will define both ‘.text0’ and ‘.text1’ to start at address 0x1000.
5122‘.text0’ will be loaded at address 0x4000, and ‘.text1’ will be loaded
5123immediately after ‘.text0’.  The following symbols will be defined if
5124referenced: ‘__load_start_text0’, ‘__load_stop_text0’,
5125‘__load_start_text1’, ‘__load_stop_text1’.
5126
5127   C code to copy overlay ‘.text1’ into the overlay area might look like
5128the following.
5129
5130       extern char __load_start_text1, __load_stop_text1;
5131       memcpy ((char *) 0x1000, &__load_start_text1,
5132               &__load_stop_text1 - &__load_start_text1);
5133
5134   Note that the ‘OVERLAY’ command is just syntactic sugar, since
5135everything it does can be done using the more basic commands.  The above
5136example could have been written identically as follows.
5137
5138       .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
5139       PROVIDE (__load_start_text0 = LOADADDR (.text0));
5140       PROVIDE (__load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0));
5141       .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
5142       PROVIDE (__load_start_text1 = LOADADDR (.text1));
5143       PROVIDE (__load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1));
5144       . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
5145
5146
5147File: ld.info,  Node: MEMORY,  Next: PHDRS,  Prev: SECTIONS,  Up: Scripts
5148
51493.7 MEMORY Command
5150==================
5151
5152The linker’s default configuration permits allocation of all available
5153memory.  You can override this by using the ‘MEMORY’ command.
5154
5155   The ‘MEMORY’ command describes the location and size of blocks of
5156memory in the target.  You can use it to describe which memory regions
5157may be used by the linker, and which memory regions it must avoid.  You
5158can then assign sections to particular memory regions.  The linker will
5159set section addresses based on the memory regions, and will warn about
5160regions that become too full.  The linker will not shuffle sections
5161around to fit into the available regions.
5162
5163   A linker script may contain many uses of the ‘MEMORY’ command,
5164however, all memory blocks defined are treated as if they were specified
5165inside a single ‘MEMORY’ command.  The syntax for ‘MEMORY’ is:
5166     MEMORY
5167       {
5168         NAME [(ATTR)] : ORIGIN = ORIGIN, LENGTH = LEN
5169         ...
5170       }
5171
5172   The NAME is a name used in the linker script to refer to the region.
5173The region name has no meaning outside of the linker script.  Region
5174names are stored in a separate name space, and will not conflict with
5175symbol names, file names, or section names.  Each memory region must
5176have a distinct name within the ‘MEMORY’ command.  However you can add
5177later alias names to existing memory regions with the *note
5178REGION_ALIAS:: command.
5179
5180   The ATTR string is an optional list of attributes that specify
5181whether to use a particular memory region for an input section which is
5182not explicitly mapped in the linker script.  As described in *note
5183SECTIONS::, if you do not specify an output section for some input
5184section, the linker will create an output section with the same name as
5185the input section.  If you define region attributes, the linker will use
5186them to select the memory region for the output section that it creates.
5187
5188   The ATTR string must consist only of the following characters:
5189‘R’
5190     Read-only section
5191‘W’
5192     Read/write section
5193‘X’
5194     Executable section
5195‘A’
5196     Allocatable section
5197‘I’
5198     Initialized section
5199‘L’
5200     Same as ‘I’
5201‘!’
5202     Invert the sense of any of the attributes that follow
5203
5204   If an unmapped section matches any of the listed attributes other
5205than ‘!’, it will be placed in the memory region.  The ‘!’ attribute
5206reverses the test for the characters that follow, so that an unmapped
5207section will be placed in the memory region only if it does not match
5208any of the attributes listed afterwards.  Thus an attribute string of
5209‘RW!X’ will match any unmapped section that has either or both of the
5210‘R’ and ‘W’ attributes, but only as long as the section does not also
5211have the ‘X’ attribute.
5212
5213   The ORIGIN is an numerical expression for the start address of the
5214memory region.  The expression must evaluate to a constant and it cannot
5215involve any symbols.  The keyword ‘ORIGIN’ may be abbreviated to ‘org’
5216or ‘o’ (but not, for example, ‘ORG’).
5217
5218   The LEN is an expression for the size in bytes of the memory region.
5219As with the ORIGIN expression, the expression must be numerical only and
5220must evaluate to a constant.  The keyword ‘LENGTH’ may be abbreviated to
5221‘len’ or ‘l’.
5222
5223   In the following example, we specify that there are two memory
5224regions available for allocation: one starting at ‘0’ for 256 kilobytes,
5225and the other starting at ‘0x40000000’ for four megabytes.  The linker
5226will place into the ‘rom’ memory region every section which is not
5227explicitly mapped into a memory region, and is either read-only or
5228executable.  The linker will place other sections which are not
5229explicitly mapped into a memory region into the ‘ram’ memory region.
5230
5231     MEMORY
5232       {
5233         rom (rx)  : ORIGIN = 0, LENGTH = 256K
5234         ram (!rx) : org = 0x40000000, l = 4M
5235       }
5236
5237   Once you define a memory region, you can direct the linker to place
5238specific output sections into that memory region by using the ‘>REGION’
5239output section attribute.  For example, if you have a memory region
5240named ‘mem’, you would use ‘>mem’ in the output section definition.
5241*Note Output Section Region::.  If no address was specified for the
5242output section, the linker will set the address to the next available
5243address within the memory region.  If the combined output sections
5244directed to a memory region are too large for the region, the linker
5245will issue an error message.
5246
5247   It is possible to access the origin and length of a memory in an
5248expression via the ‘ORIGIN(MEMORY)’ and ‘LENGTH(MEMORY)’ functions:
5249
5250       _fstack = ORIGIN(ram) + LENGTH(ram) - 4;
5251
5252
5253File: ld.info,  Node: PHDRS,  Next: VERSION,  Prev: MEMORY,  Up: Scripts
5254
52553.8 PHDRS Command
5256=================
5257
5258The ELF object file format uses “program headers”, also knows as
5259“segments”.  The program headers describe how the program should be
5260loaded into memory.  You can print them out by using the ‘objdump’
5261program with the ‘-p’ option.
5262
5263   When you run an ELF program on a native ELF system, the system loader
5264reads the program headers in order to figure out how to load the
5265program.  This will only work if the program headers are set correctly.
5266This manual does not describe the details of how the system loader
5267interprets program headers; for more information, see the ELF ABI.
5268
5269   The linker will create reasonable program headers by default.
5270However, in some cases, you may need to specify the program headers more
5271precisely.  You may use the ‘PHDRS’ command for this purpose.  When the
5272linker sees the ‘PHDRS’ command in the linker script, it will not create
5273any program headers other than the ones specified.
5274
5275   The linker only pays attention to the ‘PHDRS’ command when generating
5276an ELF output file.  In other cases, the linker will simply ignore
5277‘PHDRS’.
5278
5279   This is the syntax of the ‘PHDRS’ command.  The words ‘PHDRS’,
5280‘FILEHDR’, ‘AT’, and ‘FLAGS’ are keywords.
5281
5282     PHDRS
5283     {
5284       NAME TYPE [ FILEHDR ] [ PHDRS ] [ AT ( ADDRESS ) ]
5285             [ FLAGS ( FLAGS ) ] ;
5286     }
5287
5288   The NAME is used only for reference in the ‘SECTIONS’ command of the
5289linker script.  It is not put into the output file.  Program header
5290names are stored in a separate name space, and will not conflict with
5291symbol names, file names, or section names.  Each program header must
5292have a distinct name.  The headers are processed in order and it is
5293usual for them to map to sections in ascending load address order.
5294
5295   Certain program header types describe segments of memory which the
5296system loader will load from the file.  In the linker script, you
5297specify the contents of these segments by placing allocatable output
5298sections in the segments.  You use the ‘:PHDR’ output section attribute
5299to place a section in a particular segment.  *Note Output Section
5300Phdr::.
5301
5302   It is normal to put certain sections in more than one segment.  This
5303merely implies that one segment of memory contains another.  You may
5304repeat ‘:PHDR’, using it once for each segment which should contain the
5305section.
5306
5307   If you place a section in one or more segments using ‘:PHDR’, then
5308the linker will place all subsequent allocatable sections which do not
5309specify ‘:PHDR’ in the same segments.  This is for convenience, since
5310generally a whole set of contiguous sections will be placed in a single
5311segment.  You can use ‘:NONE’ to override the default segment and tell
5312the linker to not put the section in any segment at all.
5313
5314   You may use the ‘FILEHDR’ and ‘PHDRS’ keywords after the program
5315header type to further describe the contents of the segment.  The
5316‘FILEHDR’ keyword means that the segment should include the ELF file
5317header.  The ‘PHDRS’ keyword means that the segment should include the
5318ELF program headers themselves.  If applied to a loadable segment
5319(‘PT_LOAD’), all prior loadable segments must have one of these
5320keywords.
5321
5322   The TYPE may be one of the following.  The numbers indicate the value
5323of the keyword.
5324
5325‘PT_NULL’ (0)
5326     Indicates an unused program header.
5327
5328‘PT_LOAD’ (1)
5329     Indicates that this program header describes a segment to be loaded
5330     from the file.
5331
5332‘PT_DYNAMIC’ (2)
5333     Indicates a segment where dynamic linking information can be found.
5334
5335‘PT_INTERP’ (3)
5336     Indicates a segment where the name of the program interpreter may
5337     be found.
5338
5339‘PT_NOTE’ (4)
5340     Indicates a segment holding note information.
5341
5342‘PT_SHLIB’ (5)
5343     A reserved program header type, defined but not specified by the
5344     ELF ABI.
5345
5346‘PT_PHDR’ (6)
5347     Indicates a segment where the program headers may be found.
5348
5349‘PT_TLS’ (7)
5350     Indicates a segment containing thread local storage.
5351
5352EXPRESSION
5353     An expression giving the numeric type of the program header.  This
5354     may be used for types not defined above.
5355
5356   You can specify that a segment should be loaded at a particular
5357address in memory by using an ‘AT’ expression.  This is identical to the
5358‘AT’ command used as an output section attribute (*note Output Section
5359LMA::).  The ‘AT’ command for a program header overrides the output
5360section attribute.
5361
5362   The linker will normally set the segment flags based on the sections
5363which comprise the segment.  You may use the ‘FLAGS’ keyword to
5364explicitly specify the segment flags.  The value of FLAGS must be an
5365integer.  It is used to set the ‘p_flags’ field of the program header.
5366
5367   Here is an example of ‘PHDRS’.  This shows a typical set of program
5368headers used on a native ELF system.
5369
5370     PHDRS
5371     {
5372       headers PT_PHDR PHDRS ;
5373       interp PT_INTERP ;
5374       text PT_LOAD FILEHDR PHDRS ;
5375       data PT_LOAD ;
5376       dynamic PT_DYNAMIC ;
5377     }
5378
5379     SECTIONS
5380     {
5381       . = SIZEOF_HEADERS;
5382       .interp : { *(.interp) } :text :interp
5383       .text : { *(.text) } :text
5384       .rodata : { *(.rodata) } /* defaults to :text */
5385       ...
5386       . = . + 0x1000; /* move to a new page in memory */
5387       .data : { *(.data) } :data
5388       .dynamic : { *(.dynamic) } :data :dynamic
5389       ...
5390     }
5391
5392
5393File: ld.info,  Node: VERSION,  Next: Expressions,  Prev: PHDRS,  Up: Scripts
5394
53953.9 VERSION Command
5396===================
5397
5398The linker supports symbol versions when using ELF. Symbol versions are
5399only useful when using shared libraries.  The dynamic linker can use
5400symbol versions to select a specific version of a function when it runs
5401a program that may have been linked against an earlier version of the
5402shared library.
5403
5404   You can include a version script directly in the main linker script,
5405or you can supply the version script as an implicit linker script.  You
5406can also use the ‘--version-script’ linker option.
5407
5408   The syntax of the ‘VERSION’ command is simply
5409     VERSION { version-script-commands }
5410
5411   The format of the version script commands is identical to that used
5412by Sun’s linker in Solaris 2.5.  The version script defines a tree of
5413version nodes.  You specify the node names and interdependencies in the
5414version script.  You can specify which symbols are bound to which
5415version nodes, and you can reduce a specified set of symbols to local
5416scope so that they are not globally visible outside of the shared
5417library.
5418
5419   The easiest way to demonstrate the version script language is with a
5420few examples.
5421
5422     VERS_1.1 {
5423     	 global:
5424     		 foo1;
5425     	 local:
5426     		 old*;
5427     		 original*;
5428     		 new*;
5429     };
5430
5431     VERS_1.2 {
5432     		 foo2;
5433     } VERS_1.1;
5434
5435     VERS_2.0 {
5436     		 bar1; bar2;
5437     	 extern "C++" {
5438     		 ns::*;
5439     		 "f(int, double)";
5440     	 };
5441     } VERS_1.2;
5442
5443   This example version script defines three version nodes.  The first
5444version node defined is ‘VERS_1.1’; it has no other dependencies.  The
5445script binds the symbol ‘foo1’ to ‘VERS_1.1’.  It reduces a number of
5446symbols to local scope so that they are not visible outside of the
5447shared library; this is done using wildcard patterns, so that any symbol
5448whose name begins with ‘old’, ‘original’, or ‘new’ is matched.  The
5449wildcard patterns available are the same as those used in the shell when
5450matching filenames (also known as “globbing”).  However, if you specify
5451the symbol name inside double quotes, then the name is treated as
5452literal, rather than as a glob pattern.
5453
5454   Next, the version script defines node ‘VERS_1.2’.  This node depends
5455upon ‘VERS_1.1’.  The script binds the symbol ‘foo2’ to the version node
5456‘VERS_1.2’.
5457
5458   Finally, the version script defines node ‘VERS_2.0’.  This node
5459depends upon ‘VERS_1.2’.  The scripts binds the symbols ‘bar1’ and
5460‘bar2’ are bound to the version node ‘VERS_2.0’.
5461
5462   When the linker finds a symbol defined in a library which is not
5463specifically bound to a version node, it will effectively bind it to an
5464unspecified base version of the library.  You can bind all otherwise
5465unspecified symbols to a given version node by using ‘global: *;’
5466somewhere in the version script.  Note that it’s slightly crazy to use
5467wildcards in a global spec except on the last version node.  Global
5468wildcards elsewhere run the risk of accidentally adding symbols to the
5469set exported for an old version.  That’s wrong since older versions
5470ought to have a fixed set of symbols.
5471
5472   The names of the version nodes have no specific meaning other than
5473what they might suggest to the person reading them.  The ‘2.0’ version
5474could just as well have appeared in between ‘1.1’ and ‘1.2’.  However,
5475this would be a confusing way to write a version script.
5476
5477   Node name can be omitted, provided it is the only version node in the
5478version script.  Such version script doesn’t assign any versions to
5479symbols, only selects which symbols will be globally visible out and
5480which won’t.
5481
5482     { global: foo; bar; local: *; };
5483
5484   When you link an application against a shared library that has
5485versioned symbols, the application itself knows which version of each
5486symbol it requires, and it also knows which version nodes it needs from
5487each shared library it is linked against.  Thus at runtime, the dynamic
5488loader can make a quick check to make sure that the libraries you have
5489linked against do in fact supply all of the version nodes that the
5490application will need to resolve all of the dynamic symbols.  In this
5491way it is possible for the dynamic linker to know with certainty that
5492all external symbols that it needs will be resolvable without having to
5493search for each symbol reference.
5494
5495   The symbol versioning is in effect a much more sophisticated way of
5496doing minor version checking that SunOS does.  The fundamental problem
5497that is being addressed here is that typically references to external
5498functions are bound on an as-needed basis, and are not all bound when
5499the application starts up.  If a shared library is out of date, a
5500required interface may be missing; when the application tries to use
5501that interface, it may suddenly and unexpectedly fail.  With symbol
5502versioning, the user will get a warning when they start their program if
5503the libraries being used with the application are too old.
5504
5505   There are several GNU extensions to Sun’s versioning approach.  The
5506first of these is the ability to bind a symbol to a version node in the
5507source file where the symbol is defined instead of in the versioning
5508script.  This was done mainly to reduce the burden on the library
5509maintainer.  You can do this by putting something like:
5510     __asm__(".symver original_foo,foo@VERS_1.1");
5511in the C source file.  This renames the function ‘original_foo’ to be an
5512alias for ‘foo’ bound to the version node ‘VERS_1.1’.  The ‘local:’
5513directive can be used to prevent the symbol ‘original_foo’ from being
5514exported.  A ‘.symver’ directive takes precedence over a version script.
5515
5516   The second GNU extension is to allow multiple versions of the same
5517function to appear in a given shared library.  In this way you can make
5518an incompatible change to an interface without increasing the major
5519version number of the shared library, while still allowing applications
5520linked against the old interface to continue to function.
5521
5522   To do this, you must use multiple ‘.symver’ directives in the source
5523file.  Here is an example:
5524
5525     __asm__(".symver original_foo,foo@");
5526     __asm__(".symver old_foo,foo@VERS_1.1");
5527     __asm__(".symver old_foo1,foo@VERS_1.2");
5528     __asm__(".symver new_foo,foo@@VERS_2.0");
5529
5530   In this example, ‘foo@’ represents the symbol ‘foo’ bound to the
5531unspecified base version of the symbol.  The source file that contains
5532this example would define 4 C functions: ‘original_foo’, ‘old_foo’,
5533‘old_foo1’, and ‘new_foo’.
5534
5535   When you have multiple definitions of a given symbol, there needs to
5536be some way to specify a default version to which external references to
5537this symbol will be bound.  You can do this with the ‘foo@@VERS_2.0’
5538type of ‘.symver’ directive.  You can only declare one version of a
5539symbol as the default in this manner; otherwise you would effectively
5540have multiple definitions of the same symbol.
5541
5542   If you wish to bind a reference to a specific version of the symbol
5543within the shared library, you can use the aliases of convenience (i.e.,
5544‘old_foo’), or you can use the ‘.symver’ directive to specifically bind
5545to an external version of the function in question.
5546
5547   You can also specify the language in the version script:
5548
5549     VERSION extern "lang" { version-script-commands }
5550
5551   The supported ‘lang’s are ‘C’, ‘C++’, and ‘Java’.  The linker will
5552iterate over the list of symbols at the link time and demangle them
5553according to ‘lang’ before matching them to the patterns specified in
5554‘version-script-commands’.  The default ‘lang’ is ‘C’.
5555
5556   Demangled names may contains spaces and other special characters.  As
5557described above, you can use a glob pattern to match demangled names, or
5558you can use a double-quoted string to match the string exactly.  In the
5559latter case, be aware that minor differences (such as differing
5560whitespace) between the version script and the demangler output will
5561cause a mismatch.  As the exact string generated by the demangler might
5562change in the future, even if the mangled name does not, you should
5563check that all of your version directives are behaving as you expect
5564when you upgrade.
5565
5566
5567File: ld.info,  Node: Expressions,  Next: Implicit Linker Scripts,  Prev: VERSION,  Up: Scripts
5568
55693.10 Expressions in Linker Scripts
5570==================================
5571
5572The syntax for expressions in the linker script language is identical to
5573that of C expressions, except that whitespace is required in some places
5574to resolve syntactic ambiguities.  All expressions are evaluated as
5575integers.  All expressions are evaluated in the same size, which is 32
5576bits if both the host and target are 32 bits, and is otherwise 64 bits.
5577
5578   You can use and set symbol values in expressions.
5579
5580   The linker defines several special purpose builtin functions for use
5581in expressions.
5582
5583* Menu:
5584
5585* Constants::			Constants
5586* Symbolic Constants::          Symbolic constants
5587* Symbols::			Symbol Names
5588* Orphan Sections::		Orphan Sections
5589* Location Counter::		The Location Counter
5590* Operators::			Operators
5591* Evaluation::			Evaluation
5592* Expression Section::		The Section of an Expression
5593* Builtin Functions::		Builtin Functions
5594
5595
5596File: ld.info,  Node: Constants,  Next: Symbolic Constants,  Up: Expressions
5597
55983.10.1 Constants
5599----------------
5600
5601All constants are integers.
5602
5603   As in C, the linker considers an integer beginning with ‘0’ to be
5604octal, and an integer beginning with ‘0x’ or ‘0X’ to be hexadecimal.
5605Alternatively the linker accepts suffixes of ‘h’ or ‘H’ for hexadecimal,
5606‘o’ or ‘O’ for octal, ‘b’ or ‘B’ for binary and ‘d’ or ‘D’ for decimal.
5607Any integer value without a prefix or a suffix is considered to be
5608decimal.
5609
5610   In addition, you can use the suffixes ‘K’ and ‘M’ to scale a constant
5611by ‘1024’ or ‘1024*1024’ respectively.  For example, the following all
5612refer to the same quantity:
5613
5614     _fourk_1 = 4K;
5615     _fourk_2 = 4096;
5616     _fourk_3 = 0x1000;
5617     _fourk_4 = 10000o;
5618
5619   Note - the ‘K’ and ‘M’ suffixes cannot be used in conjunction with
5620the base suffixes mentioned above.
5621
5622
5623File: ld.info,  Node: Symbolic Constants,  Next: Symbols,  Prev: Constants,  Up: Expressions
5624
56253.10.2 Symbolic Constants
5626-------------------------
5627
5628It is possible to refer to target-specific constants via the use of the
5629‘CONSTANT(NAME)’ operator, where NAME is one of:
5630
5631‘MAXPAGESIZE’
5632     The target’s maximum page size.
5633
5634‘COMMONPAGESIZE’
5635     The target’s default page size.
5636
5637   So for example:
5638
5639       .text ALIGN (CONSTANT (MAXPAGESIZE)) : { *(.text) }
5640
5641   will create a text section aligned to the largest page boundary
5642supported by the target.
5643
5644
5645File: ld.info,  Node: Symbols,  Next: Orphan Sections,  Prev: Symbolic Constants,  Up: Expressions
5646
56473.10.3 Symbol Names
5648-------------------
5649
5650Unless quoted, symbol names start with a letter, underscore, or period
5651and may include letters, digits, underscores, periods, and hyphens.
5652Unquoted symbol names must not conflict with any keywords.  You can
5653specify a symbol which contains odd characters or has the same name as a
5654keyword by surrounding the symbol name in double quotes:
5655     "SECTION" = 9;
5656     "with a space" = "also with a space" + 10;
5657
5658   Since symbols can contain many non-alphabetic characters, it is
5659safest to delimit symbols with spaces.  For example, ‘A-B’ is one
5660symbol, whereas ‘A - B’ is an expression involving subtraction.
5661
5662
5663File: ld.info,  Node: Orphan Sections,  Next: Location Counter,  Prev: Symbols,  Up: Expressions
5664
56653.10.4 Orphan Sections
5666----------------------
5667
5668Orphan sections are sections present in the input files which are not
5669explicitly placed into the output file by the linker script.  The linker
5670will still copy these sections into the output file by either finding,
5671or creating a suitable output section in which to place the orphaned
5672input section.
5673
5674   If the name of an orphaned input section exactly matches the name of
5675an existing output section, then the orphaned input section will be
5676placed at the end of that output section.
5677
5678   If there is no output section with a matching name then new output
5679sections will be created.  Each new output section will have the same
5680name as the orphan section placed within it.  If there are multiple
5681orphan sections with the same name, these will all be combined into one
5682new output section.
5683
5684   If new output sections are created to hold orphaned input sections,
5685then the linker must decide where to place these new output sections in
5686relation to existing output sections.  On most modern targets, the
5687linker attempts to place orphan sections after sections of the same
5688attribute, such as code vs data, loadable vs non-loadable, etc.  If no
5689sections with matching attributes are found, or your target lacks this
5690support, the orphan section is placed at the end of the file.
5691
5692   The command-line options ‘--orphan-handling’ and ‘--unique’ (*note
5693Command-line Options: Options.) can be used to control which output
5694sections an orphan is placed in.
5695
5696
5697File: ld.info,  Node: Location Counter,  Next: Operators,  Prev: Orphan Sections,  Up: Expressions
5698
56993.10.5 The Location Counter
5700---------------------------
5701
5702The special linker variable “dot” ‘.’ always contains the current output
5703location counter.  Since the ‘.’ always refers to a location in an
5704output section, it may only appear in an expression within a ‘SECTIONS’
5705command.  The ‘.’ symbol may appear anywhere that an ordinary symbol is
5706allowed in an expression.
5707
5708   Assigning a value to ‘.’ will cause the location counter to be moved.
5709This may be used to create holes in the output section.  The location
5710counter may not be moved backwards inside an output section, and may not
5711be moved backwards outside of an output section if so doing creates
5712areas with overlapping LMAs.
5713
5714     SECTIONS
5715     {
5716       output :
5717         {
5718           file1(.text)
5719           . = . + 1000;
5720           file2(.text)
5721           . += 1000;
5722           file3(.text)
5723         } = 0x12345678;
5724     }
5725In the previous example, the ‘.text’ section from ‘file1’ is located at
5726the beginning of the output section ‘output’.  It is followed by a 1000
5727byte gap.  Then the ‘.text’ section from ‘file2’ appears, also with a
57281000 byte gap following before the ‘.text’ section from ‘file3’.  The
5729notation ‘= 0x12345678’ specifies what data to write in the gaps (*note
5730Output Section Fill::).
5731
5732   Note: ‘.’ actually refers to the byte offset from the start of the
5733current containing object.  Normally this is the ‘SECTIONS’ statement,
5734whose start address is 0, hence ‘.’ can be used as an absolute address.
5735If ‘.’ is used inside a section description however, it refers to the
5736byte offset from the start of that section, not an absolute address.
5737Thus in a script like this:
5738
5739     SECTIONS
5740     {
5741         . = 0x100
5742         .text: {
5743           *(.text)
5744           . = 0x200
5745         }
5746         . = 0x500
5747         .data: {
5748           *(.data)
5749           . += 0x600
5750         }
5751     }
5752
5753   The ‘.text’ section will be assigned a starting address of 0x100 and
5754a size of exactly 0x200 bytes, even if there is not enough data in the
5755‘.text’ input sections to fill this area.  (If there is too much data,
5756an error will be produced because this would be an attempt to move ‘.’
5757backwards).  The ‘.data’ section will start at 0x500 and it will have an
5758extra 0x600 bytes worth of space after the end of the values from the
5759‘.data’ input sections and before the end of the ‘.data’ output section
5760itself.
5761
5762   Setting symbols to the value of the location counter outside of an
5763output section statement can result in unexpected values if the linker
5764needs to place orphan sections.  For example, given the following:
5765
5766     SECTIONS
5767     {
5768         start_of_text = . ;
5769         .text: { *(.text) }
5770         end_of_text = . ;
5771
5772         start_of_data = . ;
5773         .data: { *(.data) }
5774         end_of_data = . ;
5775     }
5776
5777   If the linker needs to place some input section, e.g.  ‘.rodata’, not
5778mentioned in the script, it might choose to place that section between
5779‘.text’ and ‘.data’.  You might think the linker should place ‘.rodata’
5780on the blank line in the above script, but blank lines are of no
5781particular significance to the linker.  As well, the linker doesn’t
5782associate the above symbol names with their sections.  Instead, it
5783assumes that all assignments or other statements belong to the previous
5784output section, except for the special case of an assignment to ‘.’.
5785I.e., the linker will place the orphan ‘.rodata’ section as if the
5786script was written as follows:
5787
5788     SECTIONS
5789     {
5790         start_of_text = . ;
5791         .text: { *(.text) }
5792         end_of_text = . ;
5793
5794         start_of_data = . ;
5795         .rodata: { *(.rodata) }
5796         .data: { *(.data) }
5797         end_of_data = . ;
5798     }
5799
5800   This may or may not be the script author’s intention for the value of
5801‘start_of_data’.  One way to influence the orphan section placement is
5802to assign the location counter to itself, as the linker assumes that an
5803assignment to ‘.’ is setting the start address of a following output
5804section and thus should be grouped with that section.  So you could
5805write:
5806
5807     SECTIONS
5808     {
5809         start_of_text = . ;
5810         .text: { *(.text) }
5811         end_of_text = . ;
5812
5813         . = . ;
5814         start_of_data = . ;
5815         .data: { *(.data) }
5816         end_of_data = . ;
5817     }
5818
5819   Now, the orphan ‘.rodata’ section will be placed between
5820‘end_of_text’ and ‘start_of_data’.
5821
5822
5823File: ld.info,  Node: Operators,  Next: Evaluation,  Prev: Location Counter,  Up: Expressions
5824
58253.10.6 Operators
5826----------------
5827
5828The linker recognizes the standard C set of arithmetic operators, with
5829the standard bindings and precedence levels:
5830     precedence      associativity   Operators                           Notes
5831     (highest)
5832     1               left            !  -  ~                             (1)
5833     2               left            *  /  %
5834     3               left            +  -
5835     4               left            >>  <<
5836     5               left            >  <  <=  >=
5837     6               left            ==  !=
5838     7               left            &
5839     8               left            ^
5840     9               left            |
5841     10              left            &&
5842     11              left            ||
5843     12              right           ? :
5844     13              right           +=  -=  *=  /=  <<=  >>=  &=  |= ^= (2)
5845     (lowest)
5846   Notes: (1) Prefix operators (2) *Note Assignments::.
5847
5848
5849File: ld.info,  Node: Evaluation,  Next: Expression Section,  Prev: Operators,  Up: Expressions
5850
58513.10.7 Evaluation
5852-----------------
5853
5854The linker evaluates expressions lazily.  It only computes the value of
5855an expression when absolutely necessary.
5856
5857   The linker needs some information, such as the value of the start
5858address of the first section, and the origins and lengths of memory
5859regions, in order to do any linking at all.  These values are computed
5860as soon as possible when the linker reads in the linker script.
5861
5862   However, other values (such as symbol values) are not known or needed
5863until after storage allocation.  Such values are evaluated later, when
5864other information (such as the sizes of output sections) is available
5865for use in the symbol assignment expression.
5866
5867   The sizes of sections cannot be known until after allocation, so
5868assignments dependent upon these are not performed until after
5869allocation.
5870
5871   Some expressions, such as those depending upon the location counter
5872‘.’, must be evaluated during section allocation.
5873
5874   If the result of an expression is required, but the value is not
5875available, then an error results.  For example, a script like the
5876following
5877     SECTIONS
5878       {
5879         .text 9+this_isnt_constant :
5880           { *(.text) }
5881       }
5882will cause the error message ‘non constant expression for initial
5883address’.
5884
5885
5886File: ld.info,  Node: Expression Section,  Next: Builtin Functions,  Prev: Evaluation,  Up: Expressions
5887
58883.10.8 The Section of an Expression
5889-----------------------------------
5890
5891Addresses and symbols may be section relative, or absolute.  A section
5892relative symbol is relocatable.  If you request relocatable output using
5893the ‘-r’ option, a further link operation may change the value of a
5894section relative symbol.  On the other hand, an absolute symbol will
5895retain the same value throughout any further link operations.
5896
5897   Some terms in linker expressions are addresses.  This is true of
5898section relative symbols and for builtin functions that return an
5899address, such as ‘ADDR’, ‘LOADADDR’, ‘ORIGIN’ and ‘SEGMENT_START’.
5900Other terms are simply numbers, or are builtin functions that return a
5901non-address value, such as ‘LENGTH’.  One complication is that unless
5902you set ‘LD_FEATURE ("SANE_EXPR")’ (*note Miscellaneous Commands::),
5903numbers and absolute symbols are treated differently depending on their
5904location, for compatibility with older versions of ‘ld’.  Expressions
5905appearing outside an output section definition treat all numbers as
5906absolute addresses.  Expressions appearing inside an output section
5907definition treat absolute symbols as numbers.  If ‘LD_FEATURE
5908("SANE_EXPR")’ is given, then absolute symbols and numbers are simply
5909treated as numbers everywhere.
5910
5911   In the following simple example,
5912
5913     SECTIONS
5914       {
5915         . = 0x100;
5916         __executable_start = 0x100;
5917         .data :
5918         {
5919           . = 0x10;
5920           __data_start = 0x10;
5921           *(.data)
5922         }
5923         ...
5924       }
5925
5926   both ‘.’ and ‘__executable_start’ are set to the absolute address
59270x100 in the first two assignments, then both ‘.’ and ‘__data_start’ are
5928set to 0x10 relative to the ‘.data’ section in the second two
5929assignments.
5930
5931   For expressions involving numbers, relative addresses and absolute
5932addresses, ld follows these rules to evaluate terms:
5933
5934   • Unary operations on an absolute address or number, and binary
5935     operations on two absolute addresses or two numbers, or between one
5936     absolute address and a number, apply the operator to the value(s).
5937   • Unary operations on a relative address, and binary operations on
5938     two relative addresses in the same section or between one relative
5939     address and a number, apply the operator to the offset part of the
5940     address(es).
5941   • Other binary operations, that is, between two relative addresses
5942     not in the same section, or between a relative address and an
5943     absolute address, first convert any non-absolute term to an
5944     absolute address before applying the operator.
5945
5946   The result section of each sub-expression is as follows:
5947
5948   • An operation involving only numbers results in a number.
5949   • The result of comparisons, ‘&&’ and ‘||’ is also a number.
5950   • The result of other binary arithmetic and logical operations on two
5951     relative addresses in the same section or two absolute addresses
5952     (after above conversions) is also a number when ‘LD_FEATURE
5953     ("SANE_EXPR")’ or inside an output section definition but an
5954     absolute address otherwise.
5955   • The result of other operations on relative addresses or one
5956     relative address and a number, is a relative address in the same
5957     section as the relative operand(s).
5958   • The result of other operations on absolute addresses (after above
5959     conversions) is an absolute address.
5960
5961   You can use the builtin function ‘ABSOLUTE’ to force an expression to
5962be absolute when it would otherwise be relative.  For example, to create
5963an absolute symbol set to the address of the end of the output section
5964‘.data’:
5965     SECTIONS
5966       {
5967         .data : { *(.data) _edata = ABSOLUTE(.); }
5968       }
5969If ‘ABSOLUTE’ were not used, ‘_edata’ would be relative to the ‘.data’
5970section.
5971
5972   Using ‘LOADADDR’ also forces an expression absolute, since this
5973particular builtin function returns an absolute address.
5974
5975
5976File: ld.info,  Node: Builtin Functions,  Prev: Expression Section,  Up: Expressions
5977
59783.10.9 Builtin Functions
5979------------------------
5980
5981The linker script language includes a number of builtin functions for
5982use in linker script expressions.
5983
5984‘ABSOLUTE(EXP)’
5985     Return the absolute (non-relocatable, as opposed to non-negative)
5986     value of the expression EXP.  Primarily useful to assign an
5987     absolute value to a symbol within a section definition, where
5988     symbol values are normally section relative.  *Note Expression
5989     Section::.
5990
5991‘ADDR(SECTION)’
5992     Return the address (VMA) of the named SECTION.  Your script must
5993     previously have defined the location of that section.  In the
5994     following example, ‘start_of_output_1’, ‘symbol_1’ and ‘symbol_2’
5995     are assigned equivalent values, except that ‘symbol_1’ will be
5996     relative to the ‘.output1’ section while the other two will be
5997     absolute:
5998          SECTIONS { ...
5999            .output1 :
6000              {
6001              start_of_output_1 = ABSOLUTE(.);
6002              ...
6003              }
6004            .output :
6005              {
6006              symbol_1 = ADDR(.output1);
6007              symbol_2 = start_of_output_1;
6008              }
6009          ... }
6010
6011‘ALIGN(ALIGN)’
6012‘ALIGN(EXP,ALIGN)’
6013     Return the location counter (‘.’) or arbitrary expression aligned
6014     to the next ALIGN boundary.  The single operand ‘ALIGN’ doesn’t
6015     change the value of the location counter—it just does arithmetic on
6016     it.  The two operand ‘ALIGN’ allows an arbitrary expression to be
6017     aligned upwards (‘ALIGN(ALIGN)’ is equivalent to
6018     ‘ALIGN(ABSOLUTE(.), ALIGN)’).
6019
6020     Here is an example which aligns the output ‘.data’ section to the
6021     next ‘0x2000’ byte boundary after the preceding section and sets a
6022     variable within the section to the next ‘0x8000’ boundary after the
6023     input sections:
6024          SECTIONS { ...
6025            .data ALIGN(0x2000): {
6026              *(.data)
6027              variable = ALIGN(0x8000);
6028            }
6029          ... }
6030     The first use of ‘ALIGN’ in this example specifies the location of
6031     a section because it is used as the optional ADDRESS attribute of a
6032     section definition (*note Output Section Address::).  The second
6033     use of ‘ALIGN’ is used to defines the value of a symbol.
6034
6035     The builtin function ‘NEXT’ is closely related to ‘ALIGN’.
6036
6037‘ALIGNOF(SECTION)’
6038     Return the alignment in bytes of the named SECTION, if that section
6039     has been allocated, or zero if the section has not been allocated.
6040     If the section does not exist in the linker script the linker will
6041     report an error.  If SECTION is ‘NEXT_SECTION’ then ‘ALIGNOF’ will
6042     return the alignment of the next allocated section specified in the
6043     linker script, or zero if there is no such section.  In the
6044     following example, the alignment of the ‘.output’ section is stored
6045     as the first value in that section.
6046          SECTIONS{ ...
6047            .output {
6048              LONG (ALIGNOF (.output))
6049              ...
6050              }
6051          ... }
6052
6053‘BLOCK(EXP)’
6054     This is a synonym for ‘ALIGN’, for compatibility with older linker
6055     scripts.  It is most often seen when setting the address of an
6056     output section.
6057
6058‘DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE)’
6059     This is equivalent to either
6060          (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - 1)))
6061     or
6062          (ALIGN(MAXPAGESIZE)
6063           + ((. + COMMONPAGESIZE - 1) & (MAXPAGESIZE - COMMONPAGESIZE)))
6064     depending on whether the latter uses fewer COMMONPAGESIZE sized
6065     pages for the data segment (area between the result of this
6066     expression and ‘DATA_SEGMENT_END’) than the former or not.  If the
6067     latter form is used, it means COMMONPAGESIZE bytes of runtime
6068     memory will be saved at the expense of up to COMMONPAGESIZE wasted
6069     bytes in the on-disk file.
6070
6071     This expression can only be used directly in ‘SECTIONS’ commands,
6072     not in any output section descriptions and only once in the linker
6073     script.  COMMONPAGESIZE should be less or equal to MAXPAGESIZE and
6074     should be the system page size the object wants to be optimized for
6075     while still running on system page sizes up to MAXPAGESIZE.  Note
6076     however that ‘-z relro’ protection will not be effective if the
6077     system page size is larger than COMMONPAGESIZE.
6078
6079     Example:
6080            . = DATA_SEGMENT_ALIGN(0x10000, 0x2000);
6081
6082‘DATA_SEGMENT_END(EXP)’
6083     This defines the end of data segment for ‘DATA_SEGMENT_ALIGN’
6084     evaluation purposes.
6085
6086            . = DATA_SEGMENT_END(.);
6087
6088‘DATA_SEGMENT_RELRO_END(OFFSET, EXP)’
6089     This defines the end of the ‘PT_GNU_RELRO’ segment when ‘-z relro’
6090     option is used.  When ‘-z relro’ option is not present,
6091     ‘DATA_SEGMENT_RELRO_END’ does nothing, otherwise
6092     ‘DATA_SEGMENT_ALIGN’ is padded so that EXP + OFFSET is aligned to
6093     the COMMONPAGESIZE argument given to ‘DATA_SEGMENT_ALIGN’.  If
6094     present in the linker script, it must be placed between
6095     ‘DATA_SEGMENT_ALIGN’ and ‘DATA_SEGMENT_END’.  Evaluates to the
6096     second argument plus any padding needed at the end of the
6097     ‘PT_GNU_RELRO’ segment due to section alignment.
6098
6099            . = DATA_SEGMENT_RELRO_END(24, .);
6100
6101‘DEFINED(SYMBOL)’
6102     Return 1 if SYMBOL is in the linker global symbol table and is
6103     defined before the statement using DEFINED in the script, otherwise
6104     return 0.  You can use this function to provide default values for
6105     symbols.  For example, the following script fragment shows how to
6106     set a global symbol ‘begin’ to the first location in the ‘.text’
6107     section—but if a symbol called ‘begin’ already existed, its value
6108     is preserved:
6109
6110          SECTIONS { ...
6111            .text : {
6112              begin = DEFINED(begin) ? begin : . ;
6113              ...
6114            }
6115            ...
6116          }
6117
6118‘LENGTH(MEMORY)’
6119     Return the length of the memory region named MEMORY.
6120
6121‘LOADADDR(SECTION)’
6122     Return the absolute LMA of the named SECTION.  (*note Output
6123     Section LMA::).
6124
6125‘LOG2CEIL(EXP)’
6126     Return the binary logarithm of EXP rounded towards infinity.
6127     ‘LOG2CEIL(0)’ returns 0.
6128
6129‘MAX(EXP1, EXP2)’
6130     Returns the maximum of EXP1 and EXP2.
6131
6132‘MIN(EXP1, EXP2)’
6133     Returns the minimum of EXP1 and EXP2.
6134
6135‘NEXT(EXP)’
6136     Return the next unallocated address that is a multiple of EXP.
6137     This function is closely related to ‘ALIGN(EXP)’; unless you use
6138     the ‘MEMORY’ command to define discontinuous memory for the output
6139     file, the two functions are equivalent.
6140
6141‘ORIGIN(MEMORY)’
6142     Return the origin of the memory region named MEMORY.
6143
6144‘SEGMENT_START(SEGMENT, DEFAULT)’
6145     Return the base address of the named SEGMENT.  If an explicit value
6146     has already been given for this segment (with a command-line ‘-T’
6147     option) then that value will be returned otherwise the value will
6148     be DEFAULT.  At present, the ‘-T’ command-line option can only be
6149     used to set the base address for the “text”, “data”, and “bss”
6150     sections, but you can use ‘SEGMENT_START’ with any segment name.
6151
6152‘SIZEOF(SECTION)’
6153     Return the size in bytes of the named SECTION, if that section has
6154     been allocated, or zero if the section has not been allocated.  If
6155     the section does not exist in the linker script the linker will
6156     report an error.  If SECTION is ‘NEXT_SECTION’ then ‘SIZEOF’ will
6157     return the alignment of the next allocated section specified in the
6158     linker script, or zero if there is no such section.  In the
6159     following example, ‘symbol_1’ and ‘symbol_2’ are assigned identical
6160     values:
6161          SECTIONS{ ...
6162            .output {
6163              .start = . ;
6164              ...
6165              .end = . ;
6166              }
6167            symbol_1 = .end - .start ;
6168            symbol_2 = SIZEOF(.output);
6169          ... }
6170
6171‘SIZEOF_HEADERS’
6172     Return the size in bytes of the output file’s headers.  This is
6173     information which appears at the start of the output file.  You can
6174     use this number when setting the start address of the first
6175     section, if you choose, to facilitate paging.
6176
6177     When producing an ELF output file, if the linker script uses the
6178     ‘SIZEOF_HEADERS’ builtin function, the linker must compute the
6179     number of program headers before it has determined all the section
6180     addresses and sizes.  If the linker later discovers that it needs
6181     additional program headers, it will report an error ‘not enough
6182     room for program headers’.  To avoid this error, you must avoid
6183     using the ‘SIZEOF_HEADERS’ function, or you must rework your linker
6184     script to avoid forcing the linker to use additional program
6185     headers, or you must define the program headers yourself using the
6186     ‘PHDRS’ command (*note PHDRS::).
6187
6188
6189File: ld.info,  Node: Implicit Linker Scripts,  Prev: Expressions,  Up: Scripts
6190
61913.11 Implicit Linker Scripts
6192============================
6193
6194If you specify a linker input file which the linker can not recognize as
6195an object file or an archive file, it will try to read the file as a
6196linker script.  If the file can not be parsed as a linker script, the
6197linker will report an error.
6198
6199   An implicit linker script will not replace the default linker script.
6200
6201   Typically an implicit linker script would contain only symbol
6202assignments, or the ‘INPUT’, ‘GROUP’, or ‘VERSION’ commands.
6203
6204   Any input files read because of an implicit linker script will be
6205read at the position in the command line where the implicit linker
6206script was read.  This can affect archive searching.
6207
6208
6209File: ld.info,  Node: Plugins,  Next: Special Sections,  Prev: Scripts,  Up: Top
6210
62114 Linker Plugins
6212****************
6213
6214The linker can use dynamically loaded plugins to modify its behavior.
6215For example, the link-time optimization feature that some compilers
6216support is implemented with a linker plugin.
6217
6218   Currently there is only one plugin shipped by default, but more may
6219be added here later.
6220
6221   Plugins are enabled via the use of the ‘-plugin NAME’ command line
6222option.  *Note Options::.
6223
6224* Menu:
6225
6226* libdep Plugin::	Static Library Dependencies Plugin
6227
6228
6229File: ld.info,  Node: libdep Plugin,  Up: Plugins
6230
62314.1 Static Library Dependencies Plugin
6232======================================
6233
6234Originally, static libraries were contained in an archive file
6235consisting just of a collection of relocatable object files.  Later they
6236evolved to optionally include a symbol table, to assist in finding the
6237needed objects within a library.  There their evolution ended, and
6238dynamic libraries rose to ascendance.
6239
6240   One useful feature of dynamic libraries was that, more than just
6241collecting multiple objects into a single file, they also included a
6242list of their dependencies, such that one could specify just the name of
6243a single dynamic library at link time, and all of its dependencies would
6244be implicitly referenced as well.  But static libraries lacked this
6245feature, so if a link invocation was switched from using dynamic
6246libraries to static libraries, the link command would usually fail
6247unless it was rewritten to explicitly list the dependencies of the
6248static library.
6249
6250   The GNU ‘ar’ utility now supports a ‘--record-libdeps’ option to
6251embed dependency lists into static libraries as well, and the ‘libdep’
6252plugin may be used to read this dependency information at link time.
6253The dependency information is stored as a single string, carrying ‘-l’
6254and ‘-L’ arguments as they would normally appear in a linker command
6255line.  As such, the information can be written with any text utility and
6256stored into any archive, even if GNU ‘ar’ is not being used to create
6257the archive.  The information is stored in an archive member named
6258__.LIBDEP’.
6259
6260   For example, given a library ‘libssl.a’ that depends on another
6261library ‘libcrypto.a’ which may be found in ‘/usr/local/lib’, the
6262__.LIBDEP’ member of ‘libssl.a’ would contain
6263
6264     -L/usr/local/lib -lcrypto
6265
6266
6267File: ld.info,  Node: Special Sections,  Next: Machine Dependent,  Prev: Plugins,  Up: Top
6268
62695 Special Sections
6270******************
6271
6272When linking ELF format object files ‘ld’ treats some sections in a
6273special, non standard manner.  This part of the manual describes these
6274sections.
6275
6276.gnu.warning6277     The contents of any section with this name are assumed to be an
6278     ascii format warning message.  The contents will be displayed to
6279     the user if the sections appears in any input file, but the section
6280     will not be copied into the output image.  If the
6281     ‘--fatal-warnings’ option is enabled then the warnings - if any are
6282     encountered - will also stop the link from completing.
6283
6284     Note - the ‘.gnu.warning’ section is not subject to linker garbage
6285     collection or orphan handling.
6286
6287.gnu.warning.SYM6288     The contents of any section whoes name starts with the prefix
6289.gnu.warning.’ and then finishes with the name of a symbol is
6290     treated in a similar fashion to the ‘.gnu.warning’ section, but
6291     only if the named symbol is referenced.  So for example the
6292     contents of a section called ‘.gnu.warning.foo’ will be displayed
6293     as warning message if, and only if, the symbol ‘foo’ is referenced
6294     by one or more of the input files.  This includes object files
6295     pulled in from static libraries, shared objects needed to complete
6296     the link and so on.
6297
6298     Note - because these warning messages are generated before the
6299     linker performs garbage collection (if enabled) it is possible for
6300     a warning to be displayed for a symbol that is later removed and
6301     then never appears in the final output.
6302
6303.note.gnu.property6304     When the linker combines sections of this name it will merge them
6305     together according to various rules encoded into the notes
6306     themselves.  Therefore the contents of the output
6307     .note.gnu.property section may not correspond to a simple
6308     concatenation of the input sections.  If the ‘-Map’ option has been
6309     used to request a linker map then details of any property merging
6310     will be included in the map.
6311
6312
6313File: ld.info,  Node: Machine Dependent,  Next: BFD,  Prev: Special Sections,  Up: Top
6314
63156 Machine Dependent Features
6316****************************
6317
6318‘ld’ has additional features on some platforms; the following sections
6319describe them.  Machines where ‘ld’ has no additional functionality are
6320not listed.
6321
6322* Menu:
6323
6324* H8/300::                      ‘ld’ and the H8/300
6325* M68HC11/68HC12::		‘ld’ and the Motorola 68HC11 and 68HC12 families
6326* ARM::				‘ld’ and the ARM family
6327* HPPA ELF32::                  ‘ld’ and HPPA 32-bit ELF
6328* M68K::			‘ld’ and the Motorola 68K family
6329* MIPS::			‘ld’ and the MIPS family
6330* MMIX::			‘ld’ and MMIX
6331* MSP430::			‘ld’ and MSP430
6332* NDS32::			‘ld’ and NDS32
6333* Nios II::			‘ld’ and the Altera Nios II
6334* PowerPC ELF32::		‘ld’ and PowerPC 32-bit ELF Support
6335* PowerPC64 ELF64::		‘ld’ and PowerPC64 64-bit ELF Support
6336* S/390 ELF::			‘ld’ and S/390 ELF Support
6337* SPU ELF::			‘ld’ and SPU ELF Support
6338* TI COFF::                     ‘ld’ and TI COFF
6339* WIN32::                       ‘ld’ and WIN32 (cygwin/mingw)
6340* Xtensa::                      ‘ld’ and Xtensa Processors
6341
6342
6343File: ld.info,  Node: H8/300,  Next: M68HC11/68HC12,  Up: Machine Dependent
6344
63456.1 ‘ld’ and the H8/300
6346=======================
6347
6348For the H8/300, ‘ld’ can perform these global optimizations when you
6349specify the ‘--relax’ command-line option.
6350
6351_relaxing address modes_
6352     ‘ld’ finds all ‘jsr’ and ‘jmp’ instructions whose targets are
6353     within eight bits, and turns them into eight-bit program-counter
6354     relative ‘bsr’ and ‘bra’ instructions, respectively.
6355
6356_synthesizing instructions_
6357     ‘ld’ finds all ‘mov.b’ instructions which use the sixteen-bit
6358     absolute address form, but refer to the top page of memory, and
6359     changes them to use the eight-bit address form.  (That is: the
6360     linker turns ‘mov.b ‘@’AA:16’ into ‘mov.b ‘@’AA:8’ whenever the
6361     address AA is in the top page of memory).
6362
6363     ‘ld’ finds all ‘mov’ instructions which use the register indirect
6364     with 32-bit displacement addressing mode, but use a small
6365     displacement inside 16-bit displacement range, and changes them to
6366     use the 16-bit displacement form.  (That is: the linker turns
6367mov.b ‘@’D:32,ERx’ into ‘mov.b ‘@’D:16,ERx’ whenever the
6368     displacement D is in the 16 bit signed integer range.  Only
6369     implemented in ELF-format ld).
6370
6371_bit manipulation instructions_
6372     ‘ld’ finds all bit manipulation instructions like ‘band, bclr,
6373     biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst,
6374     bxor’ which use 32 bit and 16 bit absolute address form, but refer
6375     to the top page of memory, and changes them to use the 8 bit
6376     address form.  (That is: the linker turns ‘bset #xx:3,‘@’AA:32’
6377     into ‘bset #xx:3,‘@’AA:8’ whenever the address AA is in the top
6378     page of memory).
6379
6380_system control instructions_
6381     ‘ld’ finds all ‘ldc.w, stc.w’ instructions which use the 32 bit
6382     absolute address form, but refer to the top page of memory, and
6383     changes them to use 16 bit address form.  (That is: the linker
6384     turns ‘ldc.w ‘@’AA:32,ccr’ into ‘ldc.w ‘@’AA:16,ccr’ whenever the
6385     address AA is in the top page of memory).
6386
6387
6388File: ld.info,  Node: M68HC11/68HC12,  Next: ARM,  Prev: H8/300,  Up: Machine Dependent
6389
63906.2 ‘ld’ and the Motorola 68HC11 and 68HC12 families
6391====================================================
6392
63936.2.1 Linker Relaxation
6394-----------------------
6395
6396For the Motorola 68HC11, ‘ld’ can perform these global optimizations
6397when you specify the ‘--relax’ command-line option.
6398
6399_relaxing address modes_
6400     ‘ld’ finds all ‘jsr’ and ‘jmp’ instructions whose targets are
6401     within eight bits, and turns them into eight-bit program-counter
6402     relative ‘bsr’ and ‘bra’ instructions, respectively.
6403
6404     ‘ld’ also looks at all 16-bit extended addressing modes and
6405     transforms them in a direct addressing mode when the address is in
6406     page 0 (between 0 and 0x0ff).
6407
6408_relaxing gcc instruction group_
6409     When ‘gcc’ is called with ‘-mrelax’, it can emit group of
6410     instructions that the linker can optimize to use a 68HC11 direct
6411     addressing mode.  These instructions consists of ‘bclr’ or ‘bset’
6412     instructions.
6413
64146.2.2 Trampoline Generation
6415---------------------------
6416
6417For 68HC11 and 68HC12, ‘ld’ can generate trampoline code to call a far
6418function using a normal ‘jsr’ instruction.  The linker will also change
6419the relocation to some far function to use the trampoline address
6420instead of the function address.  This is typically the case when a
6421pointer to a function is taken.  The pointer will in fact point to the
6422function trampoline.
6423
6424
6425File: ld.info,  Node: ARM,  Next: HPPA ELF32,  Prev: M68HC11/68HC12,  Up: Machine Dependent
6426
64276.3 ‘ld’ and the ARM family
6428===========================
6429
6430For the ARM, ‘ld’ will generate code stubs to allow functions calls
6431between ARM and Thumb code.  These stubs only work with code that has
6432been compiled and assembled with the ‘-mthumb-interwork’ command line
6433option.  If it is necessary to link with old ARM object files or
6434libraries, which have not been compiled with the -mthumb-interwork
6435option then the ‘--support-old-code’ command-line switch should be given
6436to the linker.  This will make it generate larger stub functions which
6437will work with non-interworking aware ARM code.  Note, however, the
6438linker does not support generating stubs for function calls to
6439non-interworking aware Thumb code.
6440
6441   The ‘--thumb-entry’ switch is a duplicate of the generic ‘--entry’
6442switch, in that it sets the program’s starting address.  But it also
6443sets the bottom bit of the address, so that it can be branched to using
6444a BX instruction, and the program will start executing in Thumb mode
6445straight away.
6446
6447   The ‘--use-nul-prefixed-import-tables’ switch is specifying, that the
6448import tables idata4 and idata5 have to be generated with a zero element
6449prefix for import libraries.  This is the old style to generate import
6450tables.  By default this option is turned off.
6451
6452   The ‘--be8’ switch instructs ‘ld’ to generate BE8 format executables.
6453This option is only valid when linking big-endian objects - ie ones
6454which have been assembled with the ‘-EB’ option.  The resulting image
6455will contain big-endian data and little-endian code.
6456
6457   The ‘R_ARM_TARGET1’ relocation is typically used for entries in the
6458‘.init_array’ section.  It is interpreted as either ‘R_ARM_REL32’ or
6459‘R_ARM_ABS32’, depending on the target.  The ‘--target1-rel’ and
6460‘--target1-abs’ switches override the default.
6461
6462   The ‘--target2=type’ switch overrides the default definition of the
6463‘R_ARM_TARGET2’ relocation.  Valid values for ‘type’, their meanings,
6464and target defaults are as follows:
6465‘rel’
6466     ‘R_ARM_REL32’ (arm*-*-elf, arm*-*-eabi)
6467‘abs’
6468     ‘R_ARM_ABS32’
6469‘got-rel’
6470     ‘R_ARM_GOT_PREL’ (arm*-*-linux, arm*-*-*bsd)
6471
6472   The ‘R_ARM_V4BX’ relocation (defined by the ARM AAELF specification)
6473enables objects compiled for the ARMv4 architecture to be
6474interworking-safe when linked with other objects compiled for ARMv4t,
6475but also allows pure ARMv4 binaries to be built from the same ARMv4
6476objects.
6477
6478   In the latter case, the switch ‘--fix-v4bx’ must be passed to the
6479linker, which causes v4t ‘BX rM’ instructions to be rewritten as ‘MOV
6480PC,rM’, since v4 processors do not have a ‘BX’ instruction.
6481
6482   In the former case, the switch should not be used, and ‘R_ARM_V4BX’
6483relocations are ignored.
6484
6485   Replace ‘BX rM’ instructions identified by ‘R_ARM_V4BX’ relocations
6486with a branch to the following veneer:
6487
6488     TST rM, #1
6489     MOVEQ PC, rM
6490     BX Rn
6491
6492   This allows generation of libraries/applications that work on ARMv4
6493cores and are still interworking safe.  Note that the above veneer
6494clobbers the condition flags, so may cause incorrect program behavior in
6495rare cases.
6496
6497   The ‘--use-blx’ switch enables the linker to use ARM/Thumb BLX
6498instructions (available on ARMv5t and above) in various situations.
6499Currently it is used to perform calls via the PLT from Thumb code using
6500BLX rather than using BX and a mode-switching stub before each PLT
6501entry.  This should lead to such calls executing slightly faster.
6502
6503   The ‘--vfp11-denorm-fix’ switch enables a link-time workaround for a
6504bug in certain VFP11 coprocessor hardware, which sometimes allows
6505instructions with denorm operands (which must be handled by support
6506code) to have those operands overwritten by subsequent instructions
6507before the support code can read the intended values.
6508
6509   The bug may be avoided in scalar mode if you allow at least one
6510intervening instruction between a VFP11 instruction which uses a
6511register and another instruction which writes to the same register, or
6512at least two intervening instructions if vector mode is in use.  The bug
6513only affects full-compliance floating-point mode: you do not need this
6514workaround if you are using "runfast" mode.  Please contact ARM for
6515further details.
6516
6517   If you know you are using buggy VFP11 hardware, you can enable this
6518workaround by specifying the linker option ‘--vfp-denorm-fix=scalar’ if
6519you are using the VFP11 scalar mode only, or ‘--vfp-denorm-fix=vector’
6520if you are using vector mode (the latter also works for scalar code).
6521The default is ‘--vfp-denorm-fix=none’.
6522
6523   If the workaround is enabled, instructions are scanned for
6524potentially-troublesome sequences, and a veneer is created for each such
6525sequence which may trigger the erratum.  The veneer consists of the
6526first instruction of the sequence and a branch back to the subsequent
6527instruction.  The original instruction is then replaced with a branch to
6528the veneer.  The extra cycles required to call and return from the
6529veneer are sufficient to avoid the erratum in both the scalar and vector
6530cases.
6531
6532   The ‘--fix-arm1176’ switch enables a link-time workaround for an
6533erratum in certain ARM1176 processors.  The workaround is enabled by
6534default if you are targeting ARM v6 (excluding ARM v6T2) or earlier.  It
6535can be disabled unconditionally by specifying ‘--no-fix-arm1176’.
6536
6537   Further information is available in the “ARM1176JZ-S and ARM1176JZF-S
6538Programmer Advice Notice” available on the ARM documentation website at:
6539http://infocenter.arm.com/.
6540
6541   The ‘--fix-stm32l4xx-629360’ switch enables a link-time workaround
6542for a bug in the bus matrix / memory controller for some of the STM32
6543Cortex-M4 based products (STM32L4xx).  When accessing off-chip memory
6544via the affected bus for bus reads of 9 words or more, the bus can
6545generate corrupt data and/or abort.  These are only core-initiated
6546accesses (not DMA), and might affect any access: integer loads such as
6547LDM, POP and floating-point loads such as VLDM, VPOP. Stores are not
6548affected.
6549
6550   The bug can be avoided by splitting memory accesses into the
6551necessary chunks to keep bus reads below 8 words.
6552
6553   The workaround is not enabled by default, this is equivalent to use
6554‘--fix-stm32l4xx-629360=none’.  If you know you are using buggy
6555STM32L4xx hardware, you can enable the workaround by specifying the
6556linker option ‘--fix-stm32l4xx-629360’, or the equivalent
6557‘--fix-stm32l4xx-629360=default’.
6558
6559   If the workaround is enabled, instructions are scanned for
6560potentially-troublesome sequences, and a veneer is created for each such
6561sequence which may trigger the erratum.  The veneer consists in a
6562replacement sequence emulating the behaviour of the original one and a
6563branch back to the subsequent instruction.  The original instruction is
6564then replaced with a branch to the veneer.
6565
6566   The workaround does not always preserve the memory access order for
6567the LDMDB instruction, when the instruction loads the PC.
6568
6569   The workaround is not able to handle problematic instructions when
6570they are in the middle of an IT block, since a branch is not allowed
6571there.  In that case, the linker reports a warning and no replacement
6572occurs.
6573
6574   The workaround is not able to replace problematic instructions with a
6575PC-relative branch instruction if the ‘.text’ section is too large.  In
6576that case, when the branch that replaces the original code cannot be
6577encoded, the linker reports a warning and no replacement occurs.
6578
6579   The ‘--no-enum-size-warning’ switch prevents the linker from warning
6580when linking object files that specify incompatible EABI enumeration
6581size attributes.  For example, with this switch enabled, linking of an
6582object file using 32-bit enumeration values with another using
6583enumeration values fitted into the smallest possible space will not be
6584diagnosed.
6585
6586   The ‘--no-wchar-size-warning’ switch prevents the linker from warning
6587when linking object files that specify incompatible EABI ‘wchar_t’ size
6588attributes.  For example, with this switch enabled, linking of an object
6589file using 32-bit ‘wchar_t’ values with another using 16-bit ‘wchar_t’
6590values will not be diagnosed.
6591
6592   The ‘--pic-veneer’ switch makes the linker use PIC sequences for
6593ARM/Thumb interworking veneers, even if the rest of the binary is not
6594PIC. This avoids problems on uClinux targets where ‘--emit-relocs’ is
6595used to generate relocatable binaries.
6596
6597   The linker will automatically generate and insert small sequences of
6598code into a linked ARM ELF executable whenever an attempt is made to
6599perform a function call to a symbol that is too far away.  The placement
6600of these sequences of instructions - called stubs - is controlled by the
6601command-line option ‘--stub-group-size=N’.  The placement is important
6602because a poor choice can create a need for duplicate stubs, increasing
6603the code size.  The linker will try to group stubs together in order to
6604reduce interruptions to the flow of code, but it needs guidance as to
6605how big these groups should be and where they should be placed.
6606
6607   The value of ‘N’, the parameter to the ‘--stub-group-size=’ option
6608controls where the stub groups are placed.  If it is negative then all
6609stubs are placed after the first branch that needs them.  If it is
6610positive then the stubs can be placed either before or after the
6611branches that need them.  If the value of ‘N’ is 1 (either +1 or -1)
6612then the linker will choose exactly where to place groups of stubs,
6613using its built in heuristics.  A value of ‘N’ greater than 1 (or
6614smaller than -1) tells the linker that a single group of stubs can
6615service at most ‘N’ bytes from the input sections.
6616
6617   The default, if ‘--stub-group-size=’ is not specified, is ‘N = +1’.
6618
6619   Farcalls stubs insertion is fully supported for the ARM-EABI target
6620only, because it relies on object files properties not present
6621otherwise.
6622
6623   The ‘--fix-cortex-a8’ switch enables a link-time workaround for an
6624erratum in certain Cortex-A8 processors.  The workaround is enabled by
6625default if you are targeting the ARM v7-A architecture profile.  It can
6626be enabled otherwise by specifying ‘--fix-cortex-a8’, or disabled
6627unconditionally by specifying ‘--no-fix-cortex-a8’.
6628
6629   The erratum only affects Thumb-2 code.  Please contact ARM for
6630further details.
6631
6632   The ‘--fix-cortex-a53-835769’ switch enables a link-time workaround
6633for erratum 835769 present on certain early revisions of Cortex-A53
6634processors.  The workaround is disabled by default.  It can be enabled
6635by specifying ‘--fix-cortex-a53-835769’, or disabled unconditionally by
6636specifying ‘--no-fix-cortex-a53-835769’.
6637
6638   Please contact ARM for further details.
6639
6640   The ‘--no-merge-exidx-entries’ switch disables the merging of
6641adjacent exidx entries in debuginfo.
6642
6643   The ‘--long-plt’ option enables the use of 16 byte PLT entries which
6644support up to 4Gb of code.  The default is to use 12 byte PLT entries
6645which only support 512Mb of code.
6646
6647   The ‘--no-apply-dynamic-relocs’ option makes AArch64 linker do not
6648apply link-time values for dynamic relocations.
6649
6650   All SG veneers are placed in the special output section
6651.gnu.sgstubs’.  Its start address must be set, either with the
6652command-line option ‘--section-start’ or in a linker script, to indicate
6653where to place these veneers in memory.
6654
6655   The ‘--cmse-implib’ option requests that the import libraries
6656specified by the ‘--out-implib’ and ‘--in-implib’ options are secure
6657gateway import libraries, suitable for linking a non-secure executable
6658against secure code as per ARMv8-M Security Extensions.
6659
6660   The ‘--in-implib=file’ specifies an input import library whose
6661symbols must keep the same address in the executable being produced.  A
6662warning is given if no ‘--out-implib’ is given but new symbols have been
6663introduced in the executable that should be listed in its import
6664library.  Otherwise, if ‘--out-implib’ is specified, the symbols are
6665added to the output import library.  A warning is also given if some
6666symbols present in the input import library have disappeared from the
6667executable.  This option is only effective for Secure Gateway import
6668libraries, ie.  when ‘--cmse-implib’ is specified.
6669
6670
6671File: ld.info,  Node: HPPA ELF32,  Next: M68K,  Prev: ARM,  Up: Machine Dependent
6672
66736.4 ‘ld’ and HPPA 32-bit ELF Support
6674====================================
6675
6676When generating a shared library, ‘ld’ will by default generate import
6677stubs suitable for use with a single sub-space application.  The
6678‘--multi-subspace’ switch causes ‘ld’ to generate export stubs, and
6679different (larger) import stubs suitable for use with multiple
6680sub-spaces.
6681
6682   Long branch stubs and import/export stubs are placed by ‘ld’ in stub
6683sections located between groups of input sections.  ‘--stub-group-size’
6684specifies the maximum size of a group of input sections handled by one
6685stub section.  Since branch offsets are signed, a stub section may serve
6686two groups of input sections, one group before the stub section, and one
6687group after it.  However, when using conditional branches that require
6688stubs, it may be better (for branch prediction) that stub sections only
6689serve one group of input sections.  A negative value for ‘N’ chooses
6690this scheme, ensuring that branches to stubs always use a negative
6691offset.  Two special values of ‘N’ are recognized, ‘1’ and ‘-1’.  These
6692both instruct ‘ld’ to automatically size input section groups for the
6693branch types detected, with the same behaviour regarding stub placement
6694as other positive or negative values of ‘N’ respectively.
6695
6696   Note that ‘--stub-group-size’ does not split input sections.  A
6697single input section larger than the group size specified will of course
6698create a larger group (of one section).  If input sections are too
6699large, it may not be possible for a branch to reach its stub.
6700
6701
6702File: ld.info,  Node: M68K,  Next: MIPS,  Prev: HPPA ELF32,  Up: Machine Dependent
6703
67046.5 ‘ld’ and the Motorola 68K family
6705====================================
6706
6707The ‘--got=TYPE’ option lets you choose the GOT generation scheme.  The
6708choices are ‘single’, ‘negative’, ‘multigot’ and ‘target’.  When
6709‘target’ is selected the linker chooses the default GOT generation
6710scheme for the current target.  ‘single’ tells the linker to generate a
6711single GOT with entries only at non-negative offsets.  ‘negative’
6712instructs the linker to generate a single GOT with entries at both
6713negative and positive offsets.  Not all environments support such GOTs.
6714‘multigot’ allows the linker to generate several GOTs in the output
6715file.  All GOT references from a single input object file access the
6716same GOT, but references from different input object files might access
6717different GOTs.  Not all environments support such GOTs.
6718
6719
6720File: ld.info,  Node: MIPS,  Next: MMIX,  Prev: M68K,  Up: Machine Dependent
6721
67226.6 ‘ld’ and the MIPS family
6723============================
6724
6725The ‘--insn32’ and ‘--no-insn32’ options control the choice of microMIPS
6726instructions used in code generated by the linker, such as that in the
6727PLT or lazy binding stubs, or in relaxation.  If ‘--insn32’ is used,
6728then the linker only uses 32-bit instruction encodings.  By default or
6729if ‘--no-insn32’ is used, all instruction encodings are used, including
673016-bit ones where possible.
6731
6732   The ‘--ignore-branch-isa’ and ‘--no-ignore-branch-isa’ options
6733control branch relocation checks for invalid ISA mode transitions.  If
6734‘--ignore-branch-isa’ is used, then the linker accepts any branch
6735relocations and any ISA mode transition required is lost in relocation
6736calculation, except for some cases of ‘BAL’ instructions which meet
6737relaxation conditions and are converted to equivalent ‘JALX’
6738instructions as the associated relocation is calculated.  By default or
6739if ‘--no-ignore-branch-isa’ is used a check is made causing the loss of
6740an ISA mode transition to produce an error.
6741
6742
6743File: ld.info,  Node: MMIX,  Next: MSP430,  Prev: MIPS,  Up: Machine Dependent
6744
67456.7 ‘ld’ and MMIX
6746=================
6747
6748For MMIX, there is a choice of generating ‘ELF’ object files or ‘mmo’
6749object files when linking.  The simulator ‘mmix’ understands the ‘mmo’
6750format.  The binutils ‘objcopy’ utility can translate between the two
6751formats.
6752
6753   There is one special section, the ‘.MMIX.reg_contents’ section.
6754Contents in this section is assumed to correspond to that of global
6755registers, and symbols referring to it are translated to special
6756symbols, equal to registers.  In a final link, the start address of the
6757.MMIX.reg_contents’ section corresponds to the first allocated global
6758register multiplied by 8.  Register ‘$255’ is not included in this
6759section; it is always set to the program entry, which is at the symbol
6760‘Main’ for ‘mmo’ files.
6761
6762   Global symbols with the prefix ‘__.MMIX.start.’, for example
6763__.MMIX.start..text’ and ‘__.MMIX.start..data’ are special.  The
6764default linker script uses these to set the default start address of a
6765section.
6766
6767   Initial and trailing multiples of zero-valued 32-bit words in a
6768section, are left out from an mmo file.
6769
6770
6771File: ld.info,  Node: MSP430,  Next: NDS32,  Prev: MMIX,  Up: Machine Dependent
6772
67736.8 ‘ld’ and MSP430
6774===================
6775
6776For the MSP430 it is possible to select the MPU architecture.  The flag
6777‘-m [mpu type]’ will select an appropriate linker script for selected
6778MPU type.  (To get a list of known MPUs just pass ‘-m help’ option to
6779the linker).
6780
6781   The linker will recognize some extra sections which are MSP430
6782specific:
6783
6784‘‘.vectors’’
6785     Defines a portion of ROM where interrupt vectors located.
6786
6787‘‘.bootloader’’
6788     Defines the bootloader portion of the ROM (if applicable).  Any
6789     code in this section will be uploaded to the MPU.
6790
6791‘‘.infomem’’
6792     Defines an information memory section (if applicable).  Any code in
6793     this section will be uploaded to the MPU.
6794
6795‘‘.infomemnobits’’
6796     This is the same as the ‘.infomem’ section except that any code in
6797     this section will not be uploaded to the MPU.
6798
6799‘‘.noinit’’
6800     Denotes a portion of RAM located above ‘.bss’ section.
6801
6802     The last two sections are used by gcc.
6803
6804‘--code-region=[either,lower,upper,none]’
6805     This will transform .text* sections to [either,lower,upper].text*
6806     sections.  The argument passed to GCC for -mcode-region is
6807     propagated to the linker using this option.
6808
6809‘--data-region=[either,lower,upper,none]’
6810     This will transform .data*, .bss* and .rodata* sections to
6811     [either,lower,upper].[data,bss,rodata]* sections.  The argument
6812     passed to GCC for -mdata-region is propagated to the linker using
6813     this option.
6814
6815‘--disable-sec-transformation’
6816     Prevent the transformation of sections as specified by the
6817     ‘--code-region’ and ‘--data-region’ options.  This is useful if you
6818     are compiling and linking using a single call to the GCC wrapper,
6819     and want to compile the source files using -m[code,data]-region but
6820     not transform the sections for prebuilt libraries and objects.
6821
6822
6823File: ld.info,  Node: NDS32,  Next: Nios II,  Prev: MSP430,  Up: Machine Dependent
6824
68256.9 ‘ld’ and NDS32
6826==================
6827
6828For NDS32, there are some options to select relaxation behavior.  The
6829linker relaxes objects according to these options.
6830
6831‘‘--m[no-]fp-as-gp’’
6832     Disable/enable fp-as-gp relaxation.
6833
6834‘‘--mexport-symbols=FILE’’
6835     Exporting symbols and their address into FILE as linker script.
6836
6837‘‘--m[no-]ex9’’
6838     Disable/enable link-time EX9 relaxation.
6839
6840‘‘--mexport-ex9=FILE’’
6841     Export the EX9 table after linking.
6842
6843‘‘--mimport-ex9=FILE’’
6844     Import the Ex9 table for EX9 relaxation.
6845
6846‘‘--mupdate-ex9’’
6847     Update the existing EX9 table.
6848
6849‘‘--mex9-limit=NUM’’
6850     Maximum number of entries in the ex9 table.
6851
6852‘‘--mex9-loop-aware’’
6853     Avoid generating the EX9 instruction inside the loop.
6854
6855‘‘--m[no-]ifc’’
6856     Disable/enable the link-time IFC optimization.
6857
6858‘‘--mifc-loop-aware’’
6859     Avoid generating the IFC instruction inside the loop.
6860
6861
6862File: ld.info,  Node: Nios II,  Next: PowerPC ELF32,  Prev: NDS32,  Up: Machine Dependent
6863
68646.10 ‘ld’ and the Altera Nios II
6865================================
6866
6867Call and immediate jump instructions on Nios II processors are limited
6868to transferring control to addresses in the same 256MB memory segment,
6869which may result in ‘ld’ giving ‘relocation truncated to fit’ errors
6870with very large programs.  The command-line option ‘--relax’ enables the
6871generation of trampolines that can access the entire 32-bit address
6872space for calls outside the normal ‘call’ and ‘jmpi’ address range.
6873These trampolines are inserted at section boundaries, so may not
6874themselves be reachable if an input section and its associated call
6875trampolines are larger than 256MB.
6876
6877   The ‘--relax’ option is enabled by default unless ‘-r’ is also
6878specified.  You can disable trampoline generation by using the
6879‘--no-relax’ linker option.  You can also disable this optimization
6880locally by using the ‘set .noat’ directive in assembly-language source
6881files, as the linker-inserted trampolines use the ‘at’ register as a
6882temporary.
6883
6884   Note that the linker ‘--relax’ option is independent of assembler
6885relaxation options, and that using the GNU assembler’s ‘-relax-all’
6886option interferes with the linker’s more selective call instruction
6887relaxation.
6888
6889
6890File: ld.info,  Node: PowerPC ELF32,  Next: PowerPC64 ELF64,  Prev: Nios II,  Up: Machine Dependent
6891
68926.11 ‘ld’ and PowerPC 32-bit ELF Support
6893========================================
6894
6895Branches on PowerPC processors are limited to a signed 26-bit
6896displacement, which may result in ‘ld’ giving ‘relocation truncated to
6897fit’ errors with very large programs.  ‘--relax’ enables the generation
6898of trampolines that can access the entire 32-bit address space.  These
6899trampolines are inserted at section boundaries, so may not themselves be
6900reachable if an input section exceeds 33M in size.  You may combine ‘-r’
6901and ‘--relax’ to add trampolines in a partial link.  In that case both
6902branches to undefined symbols and inter-section branches are also
6903considered potentially out of range, and trampolines inserted.
6904
6905‘--bss-plt’
6906     Current PowerPC GCC accepts a ‘-msecure-plt’ option that generates
6907     code capable of using a newer PLT and GOT layout that has the
6908     security advantage of no executable section ever needing to be
6909     writable and no writable section ever being executable.  PowerPC
6910     ‘ld’ will generate this layout, including stubs to access the PLT,
6911     if all input files (including startup and static libraries) were
6912     compiled with ‘-msecure-plt’.  ‘--bss-plt’ forces the old BSS PLT
6913     (and GOT layout) which can give slightly better performance.
6914
6915‘--secure-plt’
6916     ‘ld’ will use the new PLT and GOT layout if it is linking new
6917     ‘-fpic’ or ‘-fPIC’ code, but does not do so automatically when
6918     linking non-PIC code.  This option requests the new PLT and GOT
6919     layout.  A warning will be given if some object file requires the
6920     old style BSS PLT.
6921
6922‘--sdata-got’
6923     The new secure PLT and GOT are placed differently relative to other
6924     sections compared to older BSS PLT and GOT placement.  The location
6925     of ‘.plt’ must change because the new secure PLT is an initialized
6926     section while the old PLT is uninitialized.  The reason for the
6927     ‘.got’ change is more subtle: The new placement allows ‘.got’ to be
6928     read-only in applications linked with ‘-z relro -z now’.  However,
6929     this placement means that ‘.sdata’ cannot always be used in shared
6930     libraries, because the PowerPC ABI accesses ‘.sdata’ in shared
6931     libraries from the GOT pointer.  ‘--sdata-got’ forces the old GOT
6932     placement.  PowerPC GCC doesn’t use ‘.sdata’ in shared libraries,
6933     so this option is really only useful for other compilers that may
6934     do so.
6935
6936‘--emit-stub-syms’
6937     This option causes ‘ld’ to label linker stubs with a local symbol
6938     that encodes the stub type and destination.
6939
6940‘--no-tls-optimize’
6941     PowerPC ‘ld’ normally performs some optimization of code sequences
6942     used to access Thread-Local Storage.  Use this option to disable
6943     the optimization.
6944
6945
6946File: ld.info,  Node: PowerPC64 ELF64,  Next: S/390 ELF,  Prev: PowerPC ELF32,  Up: Machine Dependent
6947
69486.12 ‘ld’ and PowerPC64 64-bit ELF Support
6949==========================================
6950
6951‘--stub-group-size’
6952     Long branch stubs, PLT call stubs and TOC adjusting stubs are
6953     placed by ‘ld’ in stub sections located between groups of input
6954     sections.  ‘--stub-group-size’ specifies the maximum size of a
6955     group of input sections handled by one stub section.  Since branch
6956     offsets are signed, a stub section may serve two groups of input
6957     sections, one group before the stub section, and one group after
6958     it.  However, when using conditional branches that require stubs,
6959     it may be better (for branch prediction) that stub sections only
6960     serve one group of input sections.  A negative value for ‘N’
6961     chooses this scheme, ensuring that branches to stubs always use a
6962     negative offset.  Two special values of ‘N’ are recognized, ‘1’ and
6963     ‘-1’.  These both instruct ‘ld’ to automatically size input section
6964     groups for the branch types detected, with the same behaviour
6965     regarding stub placement as other positive or negative values of
6966     ‘N’ respectively.
6967
6968     Note that ‘--stub-group-size’ does not split input sections.  A
6969     single input section larger than the group size specified will of
6970     course create a larger group (of one section).  If input sections
6971     are too large, it may not be possible for a branch to reach its
6972     stub.
6973
6974‘--emit-stub-syms’
6975     This option causes ‘ld’ to label linker stubs with a local symbol
6976     that encodes the stub type and destination.
6977
6978‘--dotsyms’
6979‘--no-dotsyms’
6980     These two options control how ‘ld’ interprets version patterns in a
6981     version script.  Older PowerPC64 compilers emitted both a function
6982     descriptor symbol with the same name as the function, and a code
6983     entry symbol with the name prefixed by a dot (‘.’).  To properly
6984     version a function ‘foo’, the version script thus needs to control
6985     both ‘foo’ and ‘.foo’.  The option ‘--dotsyms’, on by default,
6986     automatically adds the required dot-prefixed patterns.  Use
6987     ‘--no-dotsyms’ to disable this feature.
6988
6989‘--save-restore-funcs’
6990‘--no-save-restore-funcs’
6991     These two options control whether PowerPC64 ‘ld’ automatically
6992     provides out-of-line register save and restore functions used by
6993     ‘-Os’ code.  The default is to provide any such referenced function
6994     for a normal final link, and to not do so for a relocatable link.
6995
6996‘--no-tls-optimize’
6997     PowerPC64 ‘ld’ normally performs some optimization of code
6998     sequences used to access Thread-Local Storage.  Use this option to
6999     disable the optimization.
7000
7001‘--tls-get-addr-optimize’
7002‘--no-tls-get-addr-optimize’
7003     These options control how PowerPC64 ‘ld’ uses a special stub to
7004     call __tls_get_addr.  PowerPC64 glibc 2.22 and later support an
7005     optimization that allows the second and subsequent calls to
7006     ‘__tls_get_addr’ for a given symbol to be resolved by the special
7007     stub without calling in to glibc.  By default the linker enables
7008     generation of the stub when glibc advertises the availability of
7009     __tls_get_addr_opt.  Using ‘--tls-get-addr-optimize’ with an older
7010     glibc won’t do much besides slow down your applications, but may be
7011     useful if linking an application against an older glibc with the
7012     expectation that it will normally be used on systems having a newer
7013     glibc.  ‘--tls-get-addr-regsave’ forces generation of a stub that
7014     saves and restores volatile registers around the call into glibc.
7015     Normally, this is done when the linker detects a call to
7016     __tls_get_addr_desc.  Such calls then go via the register saving
7017     stub to __tls_get_addr_opt.  ‘--no-tls-get-addr-regsave’ disables
7018     generation of the register saves.
7019
7020‘--no-opd-optimize’
7021     PowerPC64 ‘ld’ normally removes ‘.opd’ section entries
7022     corresponding to deleted link-once functions, or functions removed
7023     by the action of ‘--gc-sections’ or linker script ‘/DISCARD/’.  Use
7024     this option to disable ‘.opd’ optimization.
7025
7026‘--non-overlapping-opd’
7027     Some PowerPC64 compilers have an option to generate compressed
7028     ‘.opd’ entries spaced 16 bytes apart, overlapping the third word,
7029     the static chain pointer (unused in C) with the first word of the
7030     next entry.  This option expands such entries to the full 24 bytes.
7031
7032‘--no-toc-optimize’
7033     PowerPC64 ‘ld’ normally removes unused ‘.toc’ section entries.
7034     Such entries are detected by examining relocations that reference
7035     the TOC in code sections.  A reloc in a deleted code section marks
7036     a TOC word as unneeded, while a reloc in a kept code section marks
7037     a TOC word as needed.  Since the TOC may reference itself, TOC
7038     relocs are also examined.  TOC words marked as both needed and
7039     unneeded will of course be kept.  TOC words without any referencing
7040     reloc are assumed to be part of a multi-word entry, and are kept or
7041     discarded as per the nearest marked preceding word.  This works
7042     reliably for compiler generated code, but may be incorrect if
7043     assembly code is used to insert TOC entries.  Use this option to
7044     disable the optimization.
7045
7046‘--no-inline-optimize’
7047     PowerPC64 ‘ld’ normally replaces inline PLT call sequences marked
7048     with ‘R_PPC64_PLTSEQ’, ‘R_PPC64_PLTCALL’, ‘R_PPC64_PLT16_HA’ and
7049     ‘R_PPC64_PLT16_LO_DS’ relocations by a number of ‘nop’s and a
7050     direct call when the function is defined locally and can’t be
7051     overridden by some other definition.  This option disables that
7052     optimization.
7053
7054‘--no-multi-toc’
7055     If given any toc option besides ‘-mcmodel=medium’ or
7056     ‘-mcmodel=large’, PowerPC64 GCC generates code for a TOC model
7057     where TOC entries are accessed with a 16-bit offset from r2.  This
7058     limits the total TOC size to 64K. PowerPC64 ‘ld’ extends this limit
7059     by grouping code sections such that each group uses less than 64K
7060     for its TOC entries, then inserts r2 adjusting stubs between
7061     inter-group calls.  ‘ld’ does not split apart input sections, so
7062     cannot help if a single input file has a ‘.toc’ section that
7063     exceeds 64K, most likely from linking multiple files with ‘ld -r’.
7064     Use this option to turn off this feature.
7065
7066‘--no-toc-sort’
7067     By default, ‘ld’ sorts TOC sections so that those whose file
7068     happens to have a section called ‘.init’ or ‘.fini’ are placed
7069     first, followed by TOC sections referenced by code generated with
7070     PowerPC64 gcc’s ‘-mcmodel=small’, and lastly TOC sections
7071     referenced only by code generated with PowerPC64 gcc’s
7072     ‘-mcmodel=medium’ or ‘-mcmodel=large’ options.  Doing this results
7073     in better TOC grouping for multi-TOC. Use this option to turn off
7074     this feature.
7075
7076‘--plt-align’
7077‘--no-plt-align’
7078     Use these options to control whether individual PLT call stubs are
7079     aligned to a 32-byte boundary, or to the specified power of two
7080     boundary when using ‘--plt-align=’.  A negative value may be
7081     specified to pad PLT call stubs so that they do not cross the
7082     specified power of two boundary (or the minimum number of
7083     boundaries if a PLT stub is so large that it must cross a
7084     boundary).  By default PLT call stubs are aligned to 32-byte
7085     boundaries.
7086
7087‘--plt-static-chain’
7088‘--no-plt-static-chain’
7089     Use these options to control whether PLT call stubs load the static
7090     chain pointer (r11).  ‘ld’ defaults to not loading the static chain
7091     since there is never any need to do so on a PLT call.
7092
7093‘--plt-thread-safe’
7094‘--no-plt-thread-safe’
7095     With power7’s weakly ordered memory model, it is possible when
7096     using lazy binding for ld.so to update a plt entry in one thread
7097     and have another thread see the individual plt entry words update
7098     in the wrong order, despite ld.so carefully writing in the correct
7099     order and using memory write barriers.  To avoid this we need some
7100     sort of read barrier in the call stub, or use LD_BIND_NOW=1.  By
7101     default, ‘ld’ looks for calls to commonly used functions that
7102     create threads, and if seen, adds the necessary barriers.  Use
7103     these options to change the default behaviour.
7104
7105‘--plt-localentry’
7106‘--no-localentry’
7107     ELFv2 functions with localentry:0 are those with a single entry
7108     point, ie.  global entry == local entry, and that have no
7109     requirement on r2 (the TOC/GOT pointer) or r12, and guarantee r2 is
7110     unchanged on return.  Such an external function can be called via
7111     the PLT without saving r2 or restoring it on return, avoiding a
7112     common load-hit-store for small functions.  The optimization is
7113     attractive, with up to 40% reduction in execution time for a small
7114     function, but can result in symbol interposition failures.  Also,
7115     minor changes in a shared library, including system libraries, can
7116     cause a function that was localentry:0 to become localentry:8.
7117     This will result in a dynamic loader complaint and failure to run.
7118     The option is experimental, use with care.  ‘--no-plt-localentry’
7119     is the default.
7120
7121‘--power10-stubs’
7122‘--no-power10-stubs’
7123     When PowerPC64 ‘ld’ links input object files containing relocations
7124     used on power10 prefixed instructions it normally creates linkage
7125     stubs (PLT call and long branch) using power10 instructions for
7126     ‘@notoc’ PLT calls where ‘r2’ is not known.  The power10 notoc
7127     stubs are smaller and faster, so are preferred for power10.
7128     ‘--power10-stubs’ and ‘--no-power10-stubs’ allow you to override
7129     the linker’s selection of stub instructions.
7130     ‘--power10-stubs=auto’ allows the user to select the default auto
7131     mode.
7132
7133
7134File: ld.info,  Node: S/390 ELF,  Next: SPU ELF,  Prev: PowerPC64 ELF64,  Up: Machine Dependent
7135
71366.13 ‘ld’ and S/390 ELF Support
7137===============================
7138
7139‘--s390-pgste’
7140     This option marks the result file with a ‘PT_S390_PGSTE’ segment.
7141     The Linux kernel is supposed to allocate 4k page tables for
7142     binaries marked that way.
7143
7144
7145File: ld.info,  Node: SPU ELF,  Next: TI COFF,  Prev: S/390 ELF,  Up: Machine Dependent
7146
71476.14 ‘ld’ and SPU ELF Support
7148=============================
7149
7150‘--plugin’
7151     This option marks an executable as a PIC plugin module.
7152
7153‘--no-overlays’
7154     Normally, ‘ld’ recognizes calls to functions within overlay
7155     regions, and redirects such calls to an overlay manager via a stub.
7156     ‘ld’ also provides a built-in overlay manager.  This option turns
7157     off all this special overlay handling.
7158
7159‘--emit-stub-syms’
7160     This option causes ‘ld’ to label overlay stubs with a local symbol
7161     that encodes the stub type and destination.
7162
7163‘--extra-overlay-stubs’
7164     This option causes ‘ld’ to add overlay call stubs on all function
7165     calls out of overlay regions.  Normally stubs are not added on
7166     calls to non-overlay regions.
7167
7168‘--local-store=lo:hi’
7169     ‘ld’ usually checks that a final executable for SPU fits in the
7170     address range 0 to 256k.  This option may be used to change the
7171     range.  Disable the check entirely with ‘--local-store=0:0’.
7172
7173‘--stack-analysis’
7174     SPU local store space is limited.  Over-allocation of stack space
7175     unnecessarily limits space available for code and data, while
7176     under-allocation results in runtime failures.  If given this
7177     option, ‘ld’ will provide an estimate of maximum stack usage.  ‘ld’
7178     does this by examining symbols in code sections to determine the
7179     extents of functions, and looking at function prologues for stack
7180     adjusting instructions.  A call-graph is created by looking for
7181     relocations on branch instructions.  The graph is then searched for
7182     the maximum stack usage path.  Note that this analysis does not
7183     find calls made via function pointers, and does not handle
7184     recursion and other cycles in the call graph.  Stack usage may be
7185     under-estimated if your code makes such calls.  Also, stack usage
7186     for dynamic allocation, e.g.  alloca, will not be detected.  If a
7187     link map is requested, detailed information about each function’s
7188     stack usage and calls will be given.
7189
7190‘--emit-stack-syms’
7191     This option, if given along with ‘--stack-analysis’ will result in
7192     ‘ld’ emitting stack sizing symbols for each function.  These take
7193     the form ‘__stack_<function_name>’ for global functions, and
7194     ‘__stack_<number>_<function_name>’ for static functions.
7195     ‘<number>’ is the section id in hex.  The value of such symbols is
7196     the stack requirement for the corresponding function.  The symbol
7197     size will be zero, type ‘STT_NOTYPE’, binding ‘STB_LOCAL’, and
7198     section ‘SHN_ABS’.
7199
7200
7201File: ld.info,  Node: TI COFF,  Next: WIN32,  Prev: SPU ELF,  Up: Machine Dependent
7202
72036.15 ‘ld’’s Support for Various TI COFF Versions
7204================================================
7205
7206The ‘--format’ switch allows selection of one of the various TI COFF
7207versions.  The latest of this writing is 2; versions 0 and 1 are also
7208supported.  The TI COFF versions also vary in header byte-order format;
7209‘ld’ will read any version or byte order, but the output header format
7210depends on the default specified by the specific target.
7211
7212
7213File: ld.info,  Node: WIN32,  Next: Xtensa,  Prev: TI COFF,  Up: Machine Dependent
7214
72156.16 ‘ld’ and WIN32 (cygwin/mingw)
7216==================================
7217
7218This section describes some of the win32 specific ‘ld’ issues.  See
7219*note Command-line Options: Options. for detailed description of the
7220command-line options mentioned here.
7221
7222_import libraries_
7223     The standard Windows linker creates and uses so-called import
7224     libraries, which contains information for linking to dll’s.  They
7225     are regular static archives and are handled as any other static
7226     archive.  The cygwin and mingw ports of ‘ld’ have specific support
7227     for creating such libraries provided with the ‘--out-implib’
7228     command-line option.
7229
7230_Resource only DLLs_
7231     It is possible to create a DLL that only contains resources, ie
7232     just a ‘.rsrc’ section, but in order to do so a custom linker
7233     script must be used.  This is because the built-in default linker
7234     scripts will always create ‘.text’ and ‘.idata’ sections, even if
7235     there is no input to go into them.
7236
7237     The script should look like this, although the ‘OUTPUT_FORMAT’
7238     should be changed to match the desired format.
7239
7240          OUTPUT_FORMAT(pei-i386)
7241          SECTIONS
7242          {
7243            . = SIZEOF_HEADERS;
7244            . = ALIGN(__section_alignment__);
7245            .rsrc __image_base__ + __section_alignment__ : ALIGN(4)
7246            {
7247              KEEP (*(.rsrc))
7248              KEEP (*(.rsrc$*))
7249            }
7250            /DISCARD/ : { *(*) }
7251          }
7252
7253     With this script saved to a file called, eg ‘rsrc.ld’, a command
7254     line like this can be used to create the resource only DLL
7255rsrc.dll’ from an input file called ‘rsrc.o’:
7256
7257          ld -dll --subsystem windows -e 0 -s rsrc.o -o rsrc.dll -T rsrc.ld
7258
7259_exporting DLL symbols_
7260     The cygwin/mingw ‘ld’ has several ways to export symbols for dll’s.
7261
7262     _using auto-export functionality_
7263          By default ‘ld’ exports symbols with the auto-export
7264          functionality, which is controlled by the following
7265          command-line options:
7266
7267             • –export-all-symbols [This is the default]
7268             • –exclude-symbols
7269             • –exclude-libs
7270             • –exclude-modules-for-implib
7271             • –version-script
7272
7273          When auto-export is in operation, ‘ld’ will export all the
7274          non-local (global and common) symbols it finds in a DLL, with
7275          the exception of a few symbols known to belong to the system’s
7276          runtime and libraries.  As it will often not be desirable to
7277          export all of a DLL’s symbols, which may include private
7278          functions that are not part of any public interface, the
7279          command-line options listed above may be used to filter
7280          symbols out from the list for exporting.  The ‘--output-def’
7281          option can be used in order to see the final list of exported
7282          symbols with all exclusions taken into effect.
7283
7284          If ‘--export-all-symbols’ is not given explicitly on the
7285          command line, then the default auto-export behavior will be
7286          _disabled_ if either of the following are true:
7287
7288             • A DEF file is used.
7289             • Any symbol in any object file was marked with the
7290               __declspec(dllexport) attribute.
7291
7292     _using a DEF file_
7293          Another way of exporting symbols is using a DEF file.  A DEF
7294          file is an ASCII file containing definitions of symbols which
7295          should be exported when a dll is created.  Usually it is named
7296          ‘<dll name>.def’ and is added as any other object file to the
7297          linker’s command line.  The file’s name must end in ‘.def’ or
7298          ‘.DEF’.
7299
7300               gcc -o <output> <objectfiles> <dll name>.def
7301
7302          Using a DEF file turns off the normal auto-export behavior,
7303          unless the ‘--export-all-symbols’ option is also used.
7304
7305          Here is an example of a DEF file for a shared library called
7306xyz.dll’:
7307
7308               LIBRARY "xyz.dll" BASE=0x20000000
7309
7310               EXPORTS
7311               foo
7312               bar
7313               _bar = bar
7314               another_foo = abc.dll.afoo
7315               var1 DATA
7316               doo = foo == foo2
7317               eoo DATA == var1
7318
7319          This example defines a DLL with a non-default base address and
7320          seven symbols in the export table.  The third exported symbol
7321          ‘_bar’ is an alias for the second.  The fourth symbol,
7322          ‘another_foo’ is resolved by "forwarding" to another module
7323          and treating it as an alias for ‘afoo’ exported from the DLL
7324abc.dll’.  The final symbol ‘var1’ is declared to be a data
7325          object.  The ‘doo’ symbol in export library is an alias of
7326          ‘foo’, which gets the string name in export table ‘foo2’.  The
7327          ‘eoo’ symbol is an data export symbol, which gets in export
7328          table the name ‘var1’.
7329
7330          The optional ‘LIBRARY <name>’ command indicates the _internal_
7331          name of the output DLL. If ‘<name>’ does not include a suffix,
7332          the default library suffix, ‘.DLL’ is appended.
7333
7334          When the .DEF file is used to build an application, rather
7335          than a library, the ‘NAME <name>’ command should be used
7336          instead of ‘LIBRARY’.  If ‘<name>’ does not include a suffix,
7337          the default executable suffix, ‘.EXE’ is appended.
7338
7339          With either ‘LIBRARY <name>’ or ‘NAME <name>’ the optional
7340          specification ‘BASE = <number>’ may be used to specify a
7341          non-default base address for the image.
7342
7343          If neither ‘LIBRARY <name>’ nor ‘NAME <name>’ is specified, or
7344          they specify an empty string, the internal name is the same as
7345          the filename specified on the command line.
7346
7347          The complete specification of an export symbol is:
7348
7349               EXPORTS
7350                 ( (  ( <name1> [ = <name2> ] )
7351                    | ( <name1> = <module-name> . <external-name>))
7352                 [ @ <integer> ] [NONAME] [DATA] [CONSTANT] [PRIVATE] [== <name3>] ) *
7353
7354          Declares ‘<name1>’ as an exported symbol from the DLL, or
7355          declares ‘<name1>’ as an exported alias for ‘<name2>’; or
7356          declares ‘<name1>’ as a "forward" alias for the symbol
7357          ‘<external-name>’ in the DLL ‘<module-name>’.  Optionally, the
7358          symbol may be exported by the specified ordinal ‘<integer>’
7359          alias.  The optional ‘<name3>’ is the to be used string in
7360          import/export table for the symbol.
7361
7362          The optional keywords that follow the declaration indicate:
7363
7364          ‘NONAME’: Do not put the symbol name in the DLL’s export
7365          table.  It will still be exported by its ordinal alias (either
7366          the value specified by the .def specification or, otherwise,
7367          the value assigned by the linker).  The symbol name, however,
7368          does remain visible in the import library (if any), unless
7369          ‘PRIVATE’ is also specified.
7370
7371          ‘DATA’: The symbol is a variable or object, rather than a
7372          function.  The import lib will export only an indirect
7373          reference to ‘foo’ as the symbol ‘_imp__foo’ (ie, ‘foo’ must
7374          be resolved as ‘*_imp__foo’).
7375
7376          ‘CONSTANT’: Like ‘DATA’, but put the undecorated ‘foo’ as well
7377          as ‘_imp__foo’ into the import library.  Both refer to the
7378          read-only import address table’s pointer to the variable, not
7379          to the variable itself.  This can be dangerous.  If the user
7380          code fails to add the ‘dllimport’ attribute and also fails to
7381          explicitly add the extra indirection that the use of the
7382          attribute enforces, the application will behave unexpectedly.
7383
7384          ‘PRIVATE’: Put the symbol in the DLL’s export table, but do
7385          not put it into the static import library used to resolve
7386          imports at link time.  The symbol can still be imported using
7387          the ‘LoadLibrary/GetProcAddress’ API at runtime or by using
7388          the GNU ld extension of linking directly to the DLL without an
7389          import library.
7390
7391          See ld/deffilep.y in the binutils sources for the full
7392          specification of other DEF file statements
7393
7394          While linking a shared dll, ‘ld’ is able to create a DEF file
7395          with the ‘--output-def <file>’ command-line option.
7396
7397     _Using decorations_
7398          Another way of marking symbols for export is to modify the
7399          source code itself, so that when building the DLL each symbol
7400          to be exported is declared as:
7401
7402               __declspec(dllexport) int a_variable
7403               __declspec(dllexport) void a_function(int with_args)
7404
7405          All such symbols will be exported from the DLL. If, however,
7406          any of the object files in the DLL contain symbols decorated
7407          in this way, then the normal auto-export behavior is disabled,
7408          unless the ‘--export-all-symbols’ option is also used.
7409
7410          Note that object files that wish to access these symbols must
7411          _not_ decorate them with dllexport.  Instead, they should use
7412          dllimport, instead:
7413
7414               __declspec(dllimport) int a_variable
7415               __declspec(dllimport) void a_function(int with_args)
7416
7417          This complicates the structure of library header files,
7418          because when included by the library itself the header must
7419          declare the variables and functions as dllexport, but when
7420          included by client code the header must declare them as
7421          dllimport.  There are a number of idioms that are typically
7422          used to do this; often client code can omit the __declspec()
7423          declaration completely.  See ‘--enable-auto-import’ and
7424          ‘automatic data imports’ for more information.
7425
7426_automatic data imports_
7427     The standard Windows dll format supports data imports from dlls
7428     only by adding special decorations (dllimport/dllexport), which let
7429     the compiler produce specific assembler instructions to deal with
7430     this issue.  This increases the effort necessary to port existing
7431     Un*x code to these platforms, especially for large c++ libraries
7432     and applications.  The auto-import feature, which was initially
7433     provided by Paul Sokolovsky, allows one to omit the decorations to
7434     achieve a behavior that conforms to that on POSIX/Un*x platforms.
7435     This feature is enabled with the ‘--enable-auto-import’
7436     command-line option, although it is enabled by default on
7437     cygwin/mingw.  The ‘--enable-auto-import’ option itself now serves
7438     mainly to suppress any warnings that are ordinarily emitted when
7439     linked objects trigger the feature’s use.
7440
7441     auto-import of variables does not always work flawlessly without
7442     additional assistance.  Sometimes, you will see this message
7443
7444     "variable ’<var>’ can’t be auto-imported.  Please read the
7445     documentation for ld’s ‘--enable-auto-import’ for details."
7446
7447     The ‘--enable-auto-import’ documentation explains why this error
7448     occurs, and several methods that can be used to overcome this
7449     difficulty.  One of these methods is the _runtime pseudo-relocs_
7450     feature, described below.
7451
7452     For complex variables imported from DLLs (such as structs or
7453     classes), object files typically contain a base address for the
7454     variable and an offset (_addend_) within the variable–to specify a
7455     particular field or public member, for instance.  Unfortunately,
7456     the runtime loader used in win32 environments is incapable of
7457     fixing these references at runtime without the additional
7458     information supplied by dllimport/dllexport decorations.  The
7459     standard auto-import feature described above is unable to resolve
7460     these references.
7461
7462     The ‘--enable-runtime-pseudo-relocs’ switch allows these references
7463     to be resolved without error, while leaving the task of adjusting
7464     the references themselves (with their non-zero addends) to
7465     specialized code provided by the runtime environment.  Recent
7466     versions of the cygwin and mingw environments and compilers provide
7467     this runtime support; older versions do not.  However, the support
7468     is only necessary on the developer’s platform; the compiled result
7469     will run without error on an older system.
7470
7471     ‘--enable-runtime-pseudo-relocs’ is not the default; it must be
7472     explicitly enabled as needed.
7473
7474_direct linking to a dll_
7475     The cygwin/mingw ports of ‘ld’ support the direct linking,
7476     including data symbols, to a dll without the usage of any import
7477     libraries.  This is much faster and uses much less memory than does
7478     the traditional import library method, especially when linking
7479     large libraries or applications.  When ‘ld’ creates an import lib,
7480     each function or variable exported from the dll is stored in its
7481     own bfd, even though a single bfd could contain many exports.  The
7482     overhead involved in storing, loading, and processing so many bfd’s
7483     is quite large, and explains the tremendous time, memory, and
7484     storage needed to link against particularly large or complex
7485     libraries when using import libs.
7486
7487     Linking directly to a dll uses no extra command-line switches other
7488     than ‘-L’ and ‘-l’, because ‘ld’ already searches for a number of
7489     names to match each library.  All that is needed from the
7490     developer’s perspective is an understanding of this search, in
7491     order to force ld to select the dll instead of an import library.
7492
7493     For instance, when ld is called with the argument ‘-lxxx’ it will
7494     attempt to find, in the first directory of its search path,
7495
7496          libxxx.dll.a
7497          xxx.dll.a
7498          libxxx.a
7499          xxx.lib
7500          libxxx.lib
7501          cygxxx.dll (*)
7502          libxxx.dll
7503          xxx.dll
7504
7505     before moving on to the next directory in the search path.
7506
7507     (*) Actually, this is not ‘cygxxx.dll’ but in fact is
7508     ‘<prefix>xxx.dll’, where ‘<prefix>’ is set by the ‘ld’ option
7509     ‘--dll-search-prefix=<prefix>’.  In the case of cygwin, the
7510     standard gcc spec file includes ‘--dll-search-prefix=cyg’, so in
7511     effect we actually search for ‘cygxxx.dll’.
7512
7513     Other win32-based unix environments, such as mingw or pw32, may use
7514     other ‘<prefix>’es, although at present only cygwin makes use of
7515     this feature.  It was originally intended to help avoid name
7516     conflicts among dll’s built for the various win32/un*x
7517     environments, so that (for example) two versions of a zlib dll
7518     could coexist on the same machine.
7519
7520     The generic cygwin/mingw path layout uses a ‘bin’ directory for
7521     applications and dll’s and a ‘lib’ directory for the import
7522     libraries (using cygwin nomenclature):
7523
7524          bin/
7525          	cygxxx.dll
7526          lib/
7527          	libxxx.dll.a   (in case of dll's)
7528          	libxxx.a       (in case of static archive)
7529
7530     Linking directly to a dll without using the import library can be
7531     done two ways:
7532
7533     1.  Use the dll directly by adding the ‘bin’ path to the link line
7534          gcc -Wl,-verbose  -o a.exe -L../bin/ -lxxx
7535
7536     However, as the dll’s often have version numbers appended to their
7537     names (‘cygncurses-5.dll’) this will often fail, unless one
7538     specifies ‘-L../bin -lncurses-5’ to include the version.  Import
7539     libs are generally not versioned, and do not have this difficulty.
7540
7541     2.  Create a symbolic link from the dll to a file in the ‘lib’
7542     directory according to the above mentioned search pattern.  This
7543     should be used to avoid unwanted changes in the tools needed for
7544     making the app/dll.
7545
7546          ln -s bin/cygxxx.dll lib/[cyg|lib|]xxx.dll[.a]
7547
7548     Then you can link without any make environment changes.
7549
7550          gcc -Wl,-verbose  -o a.exe -L../lib/ -lxxx
7551
7552     This technique also avoids the version number problems, because the
7553     following is perfectly legal
7554
7555          bin/
7556          	cygxxx-5.dll
7557          lib/
7558          	libxxx.dll.a -> ../bin/cygxxx-5.dll
7559
7560     Linking directly to a dll without using an import lib will work
7561     even when auto-import features are exercised, and even when
7562     ‘--enable-runtime-pseudo-relocs’ is used.
7563
7564     Given the improvements in speed and memory usage, one might
7565     justifiably wonder why import libraries are used at all.  There are
7566     three reasons:
7567
7568     1.  Until recently, the link-directly-to-dll functionality did
7569     _not_ work with auto-imported data.
7570
7571     2.  Sometimes it is necessary to include pure static objects within
7572     the import library (which otherwise contains only bfd’s for
7573     indirection symbols that point to the exports of a dll).  Again,
7574     the import lib for the cygwin kernel makes use of this ability, and
7575     it is not possible to do this without an import lib.
7576
7577     3.  Symbol aliases can only be resolved using an import lib.  This
7578     is critical when linking against OS-supplied dll’s (eg, the win32
7579     API) in which symbols are usually exported as undecorated aliases
7580     of their stdcall-decorated assembly names.
7581
7582     So, import libs are not going away.  But the ability to replace
7583     true import libs with a simple symbolic link to (or a copy of) a
7584     dll, in many cases, is a useful addition to the suite of tools
7585     binutils makes available to the win32 developer.  Given the massive
7586     improvements in memory requirements during linking, storage
7587     requirements, and linking speed, we expect that many developers
7588     will soon begin to use this feature whenever possible.
7589
7590_symbol aliasing_
7591     _adding additional names_
7592          Sometimes, it is useful to export symbols with additional
7593          names.  A symbol ‘foo’ will be exported as ‘foo’, but it can
7594          also be exported as ‘_foo’ by using special directives in the
7595          DEF file when creating the dll.  This will affect also the
7596          optional created import library.  Consider the following DEF
7597          file:
7598
7599               LIBRARY "xyz.dll" BASE=0x61000000
7600
7601               EXPORTS
7602               foo
7603               _foo = foo
7604
7605          The line ‘_foo = foo’ maps the symbol ‘foo’ to ‘_foo’.
7606
7607          Another method for creating a symbol alias is to create it in
7608          the source code using the "weak" attribute:
7609
7610               void foo () { /* Do something.  */; }
7611               void _foo () __attribute__ ((weak, alias ("foo")));
7612
7613          See the gcc manual for more information about attributes and
7614          weak symbols.
7615
7616     _renaming symbols_
7617          Sometimes it is useful to rename exports.  For instance, the
7618          cygwin kernel does this regularly.  A symbol ‘_foo’ can be
7619          exported as ‘foo’ but not as ‘_foo’ by using special
7620          directives in the DEF file.  (This will also affect the import
7621          library, if it is created).  In the following example:
7622
7623               LIBRARY "xyz.dll" BASE=0x61000000
7624
7625               EXPORTS
7626               _foo = foo
7627
7628          The line ‘_foo = foo’ maps the exported symbol ‘foo’ to
7629          ‘_foo’.
7630
7631     Note: using a DEF file disables the default auto-export behavior,
7632     unless the ‘--export-all-symbols’ command-line option is used.  If,
7633     however, you are trying to rename symbols, then you should list
7634     _all_ desired exports in the DEF file, including the symbols that
7635     are not being renamed, and do _not_ use the ‘--export-all-symbols’
7636     option.  If you list only the renamed symbols in the DEF file, and
7637     use ‘--export-all-symbols’ to handle the other symbols, then the
7638     both the new names _and_ the original names for the renamed symbols
7639     will be exported.  In effect, you’d be aliasing those symbols, not
7640     renaming them, which is probably not what you wanted.
7641
7642_weak externals_
7643     The Windows object format, PE, specifies a form of weak symbols
7644     called weak externals.  When a weak symbol is linked and the symbol
7645     is not defined, the weak symbol becomes an alias for some other
7646     symbol.  There are three variants of weak externals:
7647        • Definition is searched for in objects and libraries,
7648          historically called lazy externals.
7649        • Definition is searched for only in other objects, not in
7650          libraries.  This form is not presently implemented.
7651        • No search; the symbol is an alias.  This form is not presently
7652          implemented.
7653     As a GNU extension, weak symbols that do not specify an alternate
7654     symbol are supported.  If the symbol is undefined when linking, the
7655     symbol uses a default value.
7656
7657_aligned common symbols_
7658     As a GNU extension to the PE file format, it is possible to specify
7659     the desired alignment for a common symbol.  This information is
7660     conveyed from the assembler or compiler to the linker by means of
7661     GNU-specific commands carried in the object file’s ‘.drectve’
7662     section, which are recognized by ‘ld’ and respected when laying out
7663     the common symbols.  Native tools will be able to process object
7664     files employing this GNU extension, but will fail to respect the
7665     alignment instructions, and may issue noisy warnings about unknown
7666     linker directives.
7667
7668
7669File: ld.info,  Node: Xtensa,  Prev: WIN32,  Up: Machine Dependent
7670
76716.17 ‘ld’ and Xtensa Processors
7672===============================
7673
7674The default ‘ld’ behavior for Xtensa processors is to interpret
7675‘SECTIONS’ commands so that lists of explicitly named sections in a
7676specification with a wildcard file will be interleaved when necessary to
7677keep literal pools within the range of PC-relative load offsets.  For
7678example, with the command:
7679
7680     SECTIONS
7681     {
7682       .text : {
7683         *(.literal .text)
7684       }
7685     }
7686
7687‘ld’ may interleave some of the ‘.literal’ and ‘.text’ sections from
7688different object files to ensure that the literal pools are within the
7689range of PC-relative load offsets.  A valid interleaving might place the
7690‘.literal’ sections from an initial group of files followed by the
7691‘.text’ sections of that group of files.  Then, the ‘.literal’ sections
7692from the rest of the files and the ‘.text’ sections from the rest of the
7693files would follow.
7694
7695   Relaxation is enabled by default for the Xtensa version of ‘ld’ and
7696provides two important link-time optimizations.  The first optimization
7697is to combine identical literal values to reduce code size.  A redundant
7698literal will be removed and all the ‘L32R’ instructions that use it will
7699be changed to reference an identical literal, as long as the location of
7700the replacement literal is within the offset range of all the ‘L32R’
7701instructions.  The second optimization is to remove unnecessary overhead
7702from assembler-generated “longcall” sequences of ‘L32R’/‘CALLXN’ when
7703the target functions are within range of direct ‘CALLN’ instructions.
7704
7705   For each of these cases where an indirect call sequence can be
7706optimized to a direct call, the linker will change the ‘CALLXN’
7707instruction to a ‘CALLN’ instruction, remove the ‘L32R’ instruction, and
7708remove the literal referenced by the ‘L32R’ instruction if it is not
7709used for anything else.  Removing the ‘L32R’ instruction always reduces
7710code size but can potentially hurt performance by changing the alignment
7711of subsequent branch targets.  By default, the linker will always
7712preserve alignments, either by switching some instructions between
771324-bit encodings and the equivalent density instructions or by inserting
7714a no-op in place of the ‘L32R’ instruction that was removed.  If code
7715size is more important than performance, the ‘--size-opt’ option can be
7716used to prevent the linker from widening density instructions or
7717inserting no-ops, except in a few cases where no-ops are required for
7718correctness.
7719
7720   The following Xtensa-specific command-line options can be used to
7721control the linker:
7722
7723‘--size-opt’
7724     When optimizing indirect calls to direct calls, optimize for code
7725     size more than performance.  With this option, the linker will not
7726     insert no-ops or widen density instructions to preserve branch
7727     target alignment.  There may still be some cases where no-ops are
7728     required to preserve the correctness of the code.
7729
7730‘--abi-windowed’
7731‘--abi-call0’
7732     Choose ABI for the output object and for the generated PLT code.
7733     PLT code inserted by the linker must match ABI of the output object
7734     because windowed and call0 ABI use incompatible function call
7735     conventions.  Default ABI is chosen by the ABI tag in the
7736.xtensa.info’ section of the first input object.  A warning is
7737     issued if ABI tags of input objects do not match each other or the
7738     chosen output object ABI.
7739
7740
7741File: ld.info,  Node: BFD,  Next: Reporting Bugs,  Prev: Machine Dependent,  Up: Top
7742
77437 BFD
7744*****
7745
7746The linker accesses object and archive files using the BFD libraries.
7747These libraries allow the linker to use the same routines to operate on
7748object files whatever the object file format.  A different object file
7749format can be supported simply by creating a new BFD back end and adding
7750it to the library.  To conserve runtime memory, however, the linker and
7751associated tools are usually configured to support only a subset of the
7752object file formats available.  You can use ‘objdump -i’ (*note objdump:
7753(binutils.info)objdump.) to list all the formats available for your
7754configuration.
7755
7756   As with most implementations, BFD is a compromise between several
7757conflicting requirements.  The major factor influencing BFD design was
7758efficiency: any time used converting between formats is time which would
7759not have been spent had BFD not been involved.  This is partly offset by
7760abstraction payback; since BFD simplifies applications and back ends,
7761more time and care may be spent optimizing algorithms for a greater
7762speed.
7763
7764   One minor artifact of the BFD solution which you should bear in mind
7765is the potential for information loss.  There are two places where
7766useful information can be lost using the BFD mechanism: during
7767conversion and during output.  *Note BFD information loss::.
7768
7769* Menu:
7770
7771* BFD outline::                 How it works: an outline of BFD
7772
7773
7774File: ld.info,  Node: BFD outline,  Up: BFD
7775
77767.1 How It Works: An Outline of BFD
7777===================================
7778
7779When an object file is opened, BFD subroutines automatically determine
7780the format of the input object file.  They then build a descriptor in
7781memory with pointers to routines that will be used to access elements of
7782the object file’s data structures.
7783
7784   As different information from the object files is required, BFD reads
7785from different sections of the file and processes them.  For example, a
7786very common operation for the linker is processing symbol tables.  Each
7787BFD back end provides a routine for converting between the object file’s
7788representation of symbols and an internal canonical format.  When the
7789linker asks for the symbol table of an object file, it calls through a
7790memory pointer to the routine from the relevant BFD back end which reads
7791and converts the table into a canonical form.  The linker then operates
7792upon the canonical form.  When the link is finished and the linker
7793writes the output file’s symbol table, another BFD back end routine is
7794called to take the newly created symbol table and convert it into the
7795chosen output format.
7796
7797* Menu:
7798
7799* BFD information loss::	Information Loss
7800* Canonical format::		The BFD	canonical object-file format
7801
7802
7803File: ld.info,  Node: BFD information loss,  Next: Canonical format,  Up: BFD outline
7804
78057.1.1 Information Loss
7806----------------------
7807
7808_Information can be lost during output._  The output formats supported
7809by BFD do not provide identical facilities, and information which can be
7810described in one form has nowhere to go in another format.  One example
7811of this is alignment information in ‘b.out’.  There is nowhere in an
7812a.out’ format file to store alignment information on the contained
7813data, so when a file is linked from ‘b.out’ and an ‘a.out’ image is
7814produced, alignment information will not propagate to the output file.
7815(The linker will still use the alignment information internally, so the
7816link is performed correctly).
7817
7818   Another example is COFF section names.  COFF files may contain an
7819unlimited number of sections, each one with a textual section name.  If
7820the target of the link is a format which does not have many sections
7821(e.g., ‘a.out’) or has sections without names (e.g., the Oasys format),
7822the link cannot be done simply.  You can circumvent this problem by
7823describing the desired input-to-output section mapping with the linker
7824command language.
7825
7826   _Information can be lost during canonicalization._  The BFD internal
7827canonical form of the external formats is not exhaustive; there are
7828structures in input formats for which there is no direct representation
7829internally.  This means that the BFD back ends cannot maintain all
7830possible data richness through the transformation between external to
7831internal and back to external formats.
7832
7833   This limitation is only a problem when an application reads one
7834format and writes another.  Each BFD back end is responsible for
7835maintaining as much data as possible, and the internal BFD canonical
7836form has structures which are opaque to the BFD core, and exported only
7837to the back ends.  When a file is read in one format, the canonical form
7838is generated for BFD and the application.  At the same time, the back
7839end saves away any information which may otherwise be lost.  If the data
7840is then written back in the same format, the back end routine will be
7841able to use the canonical form provided by the BFD core as well as the
7842information it prepared earlier.  Since there is a great deal of
7843commonality between back ends, there is no information lost when linking
7844or copying big endian COFF to little endian COFF, or ‘a.out’ to ‘b.out’.
7845When a mixture of formats is linked, the information is only lost from
7846the files whose format differs from the destination.
7847
7848
7849File: ld.info,  Node: Canonical format,  Prev: BFD information loss,  Up: BFD outline
7850
78517.1.2 The BFD canonical object-file format
7852------------------------------------------
7853
7854The greatest potential for loss of information occurs when there is the
7855least overlap between the information provided by the source format,
7856that stored by the canonical format, and that needed by the destination
7857format.  A brief description of the canonical form may help you
7858understand which kinds of data you can count on preserving across
7859conversions.
7860
7861_files_
7862     Information stored on a per-file basis includes target machine
7863     architecture, particular implementation format type, a demand
7864     pageable bit, and a write protected bit.  Information like Unix
7865     magic numbers is not stored here—only the magic numbers’ meaning,
7866     so a ‘ZMAGIC’ file would have both the demand pageable bit and the
7867     write protected text bit set.  The byte order of the target is
7868     stored on a per-file basis, so that big- and little-endian object
7869     files may be used with one another.
7870
7871_sections_
7872     Each section in the input file contains the name of the section,
7873     the section’s original address in the object file, size and
7874     alignment information, various flags, and pointers into other BFD
7875     data structures.
7876
7877_symbols_
7878     Each symbol contains a pointer to the information for the object
7879     file which originally defined it, its name, its value, and various
7880     flag bits.  When a BFD back end reads in a symbol table, it
7881     relocates all symbols to make them relative to the base of the
7882     section where they were defined.  Doing this ensures that each
7883     symbol points to its containing section.  Each symbol also has a
7884     varying amount of hidden private data for the BFD back end.  Since
7885     the symbol points to the original file, the private data format for
7886     that symbol is accessible.  ‘ld’ can operate on a collection of
7887     symbols of wildly different formats without problems.
7888
7889     Normal global and simple local symbols are maintained on output, so
7890     an output file (no matter its format) will retain symbols pointing
7891     to functions and to global, static, and common variables.  Some
7892     symbol information is not worth retaining; in ‘a.out’, type
7893     information is stored in the symbol table as long symbol names.
7894     This information would be useless to most COFF debuggers; the
7895     linker has command-line switches to allow users to throw it away.
7896
7897     There is one word of type information within the symbol, so if the
7898     format supports symbol type information within symbols (for
7899     example, COFF, Oasys) and the type is simple enough to fit within
7900     one word (nearly everything but aggregates), the information will
7901     be preserved.
7902
7903_relocation level_
7904     Each canonical BFD relocation record contains a pointer to the
7905     symbol to relocate to, the offset of the data to relocate, the
7906     section the data is in, and a pointer to a relocation type
7907     descriptor.  Relocation is performed by passing messages through
7908     the relocation type descriptor and the symbol pointer.  Therefore,
7909     relocations can be performed on output data using a relocation
7910     method that is only available in one of the input formats.  For
7911     instance, Oasys provides a byte relocation format.  A relocation
7912     record requesting this relocation type would point indirectly to a
7913     routine to perform this, so the relocation may be performed on a
7914     byte being written to a 68k COFF file, even though 68k COFF has no
7915     such relocation type.
7916
7917_line numbers_
7918     Object formats can contain, for debugging purposes, some form of
7919     mapping between symbols, source line numbers, and addresses in the
7920     output file.  These addresses have to be relocated along with the
7921     symbol information.  Each symbol with an associated list of line
7922     number records points to the first record of the list.  The head of
7923     a line number list consists of a pointer to the symbol, which
7924     allows finding out the address of the function whose line number is
7925     being described.  The rest of the list is made up of pairs: offsets
7926     into the section and line numbers.  Any format which can simply
7927     derive this information can pass it successfully between formats.
7928
7929
7930File: ld.info,  Node: Reporting Bugs,  Next: MRI,  Prev: BFD,  Up: Top
7931
79328 Reporting Bugs
7933****************
7934
7935Your bug reports play an essential role in making ‘ld’ reliable.
7936
7937   Reporting a bug may help you by bringing a solution to your problem,
7938or it may not.  But in any case the principal function of a bug report
7939is to help the entire community by making the next version of ‘ld’ work
7940better.  Bug reports are your contribution to the maintenance of ‘ld’.
7941
7942   In order for a bug report to serve its purpose, you must include the
7943information that enables us to fix the bug.
7944
7945* Menu:
7946
7947* Bug Criteria::                Have you found a bug?
7948* Bug Reporting::               How to report bugs
7949
7950
7951File: ld.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: Reporting Bugs
7952
79538.1 Have You Found a Bug?
7954=========================
7955
7956If you are not sure whether you have found a bug, here are some
7957guidelines:
7958
7959   • If the linker gets a fatal signal, for any input whatever, that is
7960     a ‘ld’ bug.  Reliable linkers never crash.
7961
7962   • If ‘ld’ produces an error message for valid input, that is a bug.
7963
7964   • If ‘ld’ does not produce an error message for invalid input, that
7965     may be a bug.  In the general case, the linker can not verify that
7966     object files are correct.
7967
7968   • If you are an experienced user of linkers, your suggestions for
7969     improvement of ‘ld’ are welcome in any case.
7970
7971
7972File: ld.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: Reporting Bugs
7973
79748.2 How to Report Bugs
7975======================
7976
7977A number of companies and individuals offer support for GNU products.
7978If you obtained ‘ld’ from a support organization, we recommend you
7979contact that organization first.
7980
7981   You can find contact information for many support companies and
7982individuals in the file ‘etc/SERVICE’ in the GNU Emacs distribution.
7983
7984   Otherwise, send bug reports for ‘ld’ to
7985<https://sourceware.org/bugzilla/>.
7986
7987   The fundamental principle of reporting bugs usefully is this: *report
7988all the facts*.  If you are not sure whether to state a fact or leave it
7989out, state it!
7990
7991   Often people omit facts because they think they know what causes the
7992problem and assume that some details do not matter.  Thus, you might
7993assume that the name of a symbol you use in an example does not matter.
7994Well, probably it does not, but one cannot be sure.  Perhaps the bug is
7995a stray memory reference which happens to fetch from the location where
7996that name is stored in memory; perhaps, if the name were different, the
7997contents of that location would fool the linker into doing the right
7998thing despite the bug.  Play it safe and give a specific, complete
7999example.  That is the easiest thing for you to do, and the most helpful.
8000
8001   Keep in mind that the purpose of a bug report is to enable us to fix
8002the bug if it is new to us.  Therefore, always write your bug reports on
8003the assumption that the bug has not been reported previously.
8004
8005   Sometimes people give a few sketchy facts and ask, “Does this ring a
8006bell?” This cannot help us fix a bug, so it is basically useless.  We
8007respond by asking for enough details to enable us to investigate.  You
8008might as well expedite matters by sending them to begin with.
8009
8010   To enable us to fix the bug, you should include all these things:
8011
8012   • The version of ‘ld’.  ‘ld’ announces it if you start it with the
8013     ‘--version’ argument.
8014
8015     Without this, we will not know whether there is any point in
8016     looking for the bug in the current version of ‘ld’.
8017
8018   • Any patches you may have applied to the ‘ld’ source, including any
8019     patches made to the ‘BFD’ library.
8020
8021   • The type of machine you are using, and the operating system name
8022     and version number.
8023
8024   • What compiler (and its version) was used to compile ‘ld’—e.g.
8025     “‘gcc-2.7’”.
8026
8027   • The command arguments you gave the linker to link your example and
8028     observe the bug.  To guarantee you will not omit something
8029     important, list them all.  A copy of the Makefile (or the output
8030     from make) is sufficient.
8031
8032     If we were to try to guess the arguments, we would probably guess
8033     wrong and then we might not encounter the bug.
8034
8035   • A complete input file, or set of input files, that will reproduce
8036     the bug.  It is generally most helpful to send the actual object
8037     files provided that they are reasonably small.  Say no more than
8038     10K. For bigger files you can either make them available by FTP or
8039     HTTP or else state that you are willing to send the object file(s)
8040     to whomever requests them.  (Note - your email will be going to a
8041     mailing list, so we do not want to clog it up with large
8042     attachments).  But small attachments are best.
8043
8044     If the source files were assembled using ‘gas’ or compiled using
8045     ‘gcc’, then it may be OK to send the source files rather than the
8046     object files.  In this case, be sure to say exactly what version of
8047     ‘gas’ or ‘gcc’ was used to produce the object files.  Also say how
8048     ‘gas’ or ‘gcc’ were configured.
8049
8050   • A description of what behavior you observe that you believe is
8051     incorrect.  For example, “It gets a fatal signal.”
8052
8053     Of course, if the bug is that ‘ld’ gets a fatal signal, then we
8054     will certainly notice it.  But if the bug is incorrect output, we
8055     might not notice unless it is glaringly wrong.  You might as well
8056     not give us a chance to make a mistake.
8057
8058     Even if the problem you experience is a fatal signal, you should
8059     still say so explicitly.  Suppose something strange is going on,
8060     such as, your copy of ‘ld’ is out of sync, or you have encountered
8061     a bug in the C library on your system.  (This has happened!)  Your
8062     copy might crash and ours would not.  If you told us to expect a
8063     crash, then when ours fails to crash, we would know that the bug
8064     was not happening for us.  If you had not told us to expect a
8065     crash, then we would not be able to draw any conclusion from our
8066     observations.
8067
8068   • If you wish to suggest changes to the ‘ld’ source, send us context
8069     diffs, as generated by ‘diff’ with the ‘-u’, ‘-c’, or ‘-p’ option.
8070     Always send diffs from the old file to the new file.  If you even
8071     discuss something in the ‘ld’ source, refer to it by context, not
8072     by line number.
8073
8074     The line numbers in our development sources will not match those in
8075     your sources.  Your line numbers would convey no useful information
8076     to us.
8077
8078   Here are some things that are not necessary:
8079
8080   • A description of the envelope of the bug.
8081
8082     Often people who encounter a bug spend a lot of time investigating
8083     which changes to the input file will make the bug go away and which
8084     changes will not affect it.
8085
8086     This is often time consuming and not very useful, because the way
8087     we will find the bug is by running a single example under the
8088     debugger with breakpoints, not by pure deduction from a series of
8089     examples.  We recommend that you save your time for something else.
8090
8091     Of course, if you can find a simpler example to report _instead_ of
8092     the original one, that is a convenience for us.  Errors in the
8093     output will be easier to spot, running under the debugger will take
8094     less time, and so on.
8095
8096     However, simplification is not vital; if you do not want to do
8097     this, report the bug anyway and send us the entire test case you
8098     used.
8099
8100   • A patch for the bug.
8101
8102     A patch for the bug does help us if it is a good one.  But do not
8103     omit the necessary information, such as the test case, on the
8104     assumption that a patch is all we need.  We might see problems with
8105     your patch and decide to fix the problem another way, or we might
8106     not understand it at all.
8107
8108     Sometimes with a program as complicated as ‘ld’ it is very hard to
8109     construct an example that will make the program follow a certain
8110     path through the code.  If you do not send us the example, we will
8111     not be able to construct one, so we will not be able to verify that
8112     the bug is fixed.
8113
8114     And if we cannot understand what bug you are trying to fix, or why
8115     your patch should be an improvement, we will not install it.  A
8116     test case will help us to understand.
8117
8118   • A guess about what the bug is or what it depends on.
8119
8120     Such guesses are usually wrong.  Even we cannot guess right about
8121     such things without first using the debugger to find the facts.
8122
8123
8124File: ld.info,  Node: MRI,  Next: GNU Free Documentation License,  Prev: Reporting Bugs,  Up: Top
8125
8126Appendix A MRI Compatible Script Files
8127**************************************
8128
8129To aid users making the transition to GNU ‘ld’ from the MRI linker, ‘ld’
8130can use MRI compatible linker scripts as an alternative to the more
8131general-purpose linker scripting language described in *note Scripts::.
8132MRI compatible linker scripts have a much simpler command set than the
8133scripting language otherwise used with ‘ld’.  GNU ‘ld’ supports the most
8134commonly used MRI linker commands; these commands are described here.
8135
8136   In general, MRI scripts aren’t of much use with the ‘a.out’ object
8137file format, since it only has three sections and MRI scripts lack some
8138features to make use of them.
8139
8140   You can specify a file containing an MRI-compatible script using the
8141‘-c’ command-line option.
8142
8143   Each command in an MRI-compatible script occupies its own line; each
8144command line starts with the keyword that identifies the command (though
8145blank lines are also allowed for punctuation).  If a line of an
8146MRI-compatible script begins with an unrecognized keyword, ‘ld’ issues a
8147warning message, but continues processing the script.
8148
8149   Lines beginning with ‘*’ are comments.
8150
8151   You can write these commands using all upper-case letters, or all
8152lower case; for example, ‘chip’ is the same as ‘CHIP’.  The following
8153list shows only the upper-case form of each command.
8154
8155‘ABSOLUTE SECNAME’
8156‘ABSOLUTE SECNAME, SECNAME, ... SECNAME’
8157     Normally, ‘ld’ includes in the output file all sections from all
8158     the input files.  However, in an MRI-compatible script, you can use
8159     the ‘ABSOLUTE’ command to restrict the sections that will be
8160     present in your output program.  If the ‘ABSOLUTE’ command is used
8161     at all in a script, then only the sections named explicitly in
8162     ‘ABSOLUTE’ commands will appear in the linker output.  You can
8163     still use other input sections (whatever you select on the command
8164     line, or using ‘LOAD’) to resolve addresses in the output file.
8165
8166‘ALIAS OUT-SECNAME, IN-SECNAME’
8167     Use this command to place the data from input section IN-SECNAME in
8168     a section called OUT-SECNAME in the linker output file.
8169
8170     IN-SECNAME may be an integer.
8171
8172‘ALIGN SECNAME = EXPRESSION’
8173     Align the section called SECNAME to EXPRESSION.  The EXPRESSION
8174     should be a power of two.
8175
8176‘BASE EXPRESSION’
8177     Use the value of EXPRESSION as the lowest address (other than
8178     absolute addresses) in the output file.
8179
8180‘CHIP EXPRESSION’
8181‘CHIP EXPRESSION, EXPRESSION’
8182     This command does nothing; it is accepted only for compatibility.
8183
8184‘END’
8185     This command does nothing whatever; it’s only accepted for
8186     compatibility.
8187
8188‘FORMAT OUTPUT-FORMAT’
8189     Similar to the ‘OUTPUT_FORMAT’ command in the more general linker
8190     language, but restricted to S-records, if OUTPUT-FORMAT is ‘S’
8191
8192‘LIST ANYTHING...’
8193     Print (to the standard output file) a link map, as produced by the
8194     ‘ld’ command-line option ‘-M’.
8195
8196     The keyword ‘LIST’ may be followed by anything on the same line,
8197     with no change in its effect.
8198
8199‘LOAD FILENAME’
8200‘LOAD FILENAME, FILENAME, ... FILENAME’
8201     Include one or more object file FILENAME in the link; this has the
8202     same effect as specifying FILENAME directly on the ‘ld’ command
8203     line.
8204
8205‘NAME OUTPUT-NAME’
8206     OUTPUT-NAME is the name for the program produced by ‘ld’; the
8207     MRI-compatible command ‘NAME’ is equivalent to the command-line
8208     option ‘-o’ or the general script language command ‘OUTPUT’.
8209
8210‘ORDER SECNAME, SECNAME, ... SECNAME’
8211‘ORDER SECNAME SECNAME SECNAME’
8212     Normally, ‘ld’ orders the sections in its output file in the order
8213     in which they first appear in the input files.  In an
8214     MRI-compatible script, you can override this ordering with the
8215     ‘ORDER’ command.  The sections you list with ‘ORDER’ will appear
8216     first in your output file, in the order specified.
8217
8218‘PUBLIC NAME=EXPRESSION’
8219‘PUBLIC NAME,EXPRESSION’
8220‘PUBLIC NAME EXPRESSION’
8221     Supply a value (EXPRESSION) for external symbol NAME used in the
8222     linker input files.
8223
8224‘SECT SECNAME, EXPRESSION’
8225‘SECT SECNAME=EXPRESSION’
8226‘SECT SECNAME EXPRESSION’
8227     You can use any of these three forms of the ‘SECT’ command to
8228     specify the start address (EXPRESSION) for section SECNAME.  If you
8229     have more than one ‘SECT’ statement for the same SECNAME, only the
8230     _first_ sets the start address.
8231
8232
8233File: ld.info,  Node: GNU Free Documentation License,  Next: LD Index,  Prev: MRI,  Up: Top
8234
8235Appendix B GNU Free Documentation License
8236*****************************************
8237
8238                     Version 1.3, 3 November 2008
8239
8240     Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
8241     <http://fsf.org/>
8242
8243     Everyone is permitted to copy and distribute verbatim copies
8244     of this license document, but changing it is not allowed.
8245
8246  0. PREAMBLE
8247
8248     The purpose of this License is to make a manual, textbook, or other
8249     functional and useful document “free” in the sense of freedom: to
8250     assure everyone the effective freedom to copy and redistribute it,
8251     with or without modifying it, either commercially or
8252     noncommercially.  Secondarily, this License preserves for the
8253     author and publisher a way to get credit for their work, while not
8254     being considered responsible for modifications made by others.
8255
8256     This License is a kind of “copyleft”, which means that derivative
8257     works of the document must themselves be free in the same sense.
8258     It complements the GNU General Public License, which is a copyleft
8259     license designed for free software.
8260
8261     We have designed this License in order to use it for manuals for
8262     free software, because free software needs free documentation: a
8263     free program should come with manuals providing the same freedoms
8264     that the software does.  But this License is not limited to
8265     software manuals; it can be used for any textual work, regardless
8266     of subject matter or whether it is published as a printed book.  We
8267     recommend this License principally for works whose purpose is
8268     instruction or reference.
8269
8270  1. APPLICABILITY AND DEFINITIONS
8271
8272     This License applies to any manual or other work, in any medium,
8273     that contains a notice placed by the copyright holder saying it can
8274     be distributed under the terms of this License.  Such a notice
8275     grants a world-wide, royalty-free license, unlimited in duration,
8276     to use that work under the conditions stated herein.  The
8277     “Document”, below, refers to any such manual or work.  Any member
8278     of the public is a licensee, and is addressed as “you”.  You accept
8279     the license if you copy, modify or distribute the work in a way
8280     requiring permission under copyright law.
8281
8282     A “Modified Version” of the Document means any work containing the
8283     Document or a portion of it, either copied verbatim, or with
8284     modifications and/or translated into another language.
8285
8286     A “Secondary Section” is a named appendix or a front-matter section
8287     of the Document that deals exclusively with the relationship of the
8288     publishers or authors of the Document to the Document’s overall
8289     subject (or to related matters) and contains nothing that could
8290     fall directly within that overall subject.  (Thus, if the Document
8291     is in part a textbook of mathematics, a Secondary Section may not
8292     explain any mathematics.)  The relationship could be a matter of
8293     historical connection with the subject or with related matters, or
8294     of legal, commercial, philosophical, ethical or political position
8295     regarding them.
8296
8297     The “Invariant Sections” are certain Secondary Sections whose
8298     titles are designated, as being those of Invariant Sections, in the
8299     notice that says that the Document is released under this License.
8300     If a section does not fit the above definition of Secondary then it
8301     is not allowed to be designated as Invariant.  The Document may
8302     contain zero Invariant Sections.  If the Document does not identify
8303     any Invariant Sections then there are none.
8304
8305     The “Cover Texts” are certain short passages of text that are
8306     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
8307     that says that the Document is released under this License.  A
8308     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
8309     be at most 25 words.
8310
8311     A “Transparent” copy of the Document means a machine-readable copy,
8312     represented in a format whose specification is available to the
8313     general public, that is suitable for revising the document
8314     straightforwardly with generic text editors or (for images composed
8315     of pixels) generic paint programs or (for drawings) some widely
8316     available drawing editor, and that is suitable for input to text
8317     formatters or for automatic translation to a variety of formats
8318     suitable for input to text formatters.  A copy made in an otherwise
8319     Transparent file format whose markup, or absence of markup, has
8320     been arranged to thwart or discourage subsequent modification by
8321     readers is not Transparent.  An image format is not Transparent if
8322     used for any substantial amount of text.  A copy that is not
8323     “Transparent” is called “Opaque”.
8324
8325     Examples of suitable formats for Transparent copies include plain
8326     ASCII without markup, Texinfo input format, LaTeX input format,
8327     SGML or XML using a publicly available DTD, and standard-conforming
8328     simple HTML, PostScript or PDF designed for human modification.
8329     Examples of transparent image formats include PNG, XCF and JPG.
8330     Opaque formats include proprietary formats that can be read and
8331     edited only by proprietary word processors, SGML or XML for which
8332     the DTD and/or processing tools are not generally available, and
8333     the machine-generated HTML, PostScript or PDF produced by some word
8334     processors for output purposes only.
8335
8336     The “Title Page” means, for a printed book, the title page itself,
8337     plus such following pages as are needed to hold, legibly, the
8338     material this License requires to appear in the title page.  For
8339     works in formats which do not have any title page as such, “Title
8340     Page” means the text near the most prominent appearance of the
8341     work’s title, preceding the beginning of the body of the text.
8342
8343     The “publisher” means any person or entity that distributes copies
8344     of the Document to the public.
8345
8346     A section “Entitled XYZ” means a named subunit of the Document
8347     whose title either is precisely XYZ or contains XYZ in parentheses
8348     following text that translates XYZ in another language.  (Here XYZ
8349     stands for a specific section name mentioned below, such as
8350     “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.)
8351     To “Preserve the Title” of such a section when you modify the
8352     Document means that it remains a section “Entitled XYZ” according
8353     to this definition.
8354
8355     The Document may include Warranty Disclaimers next to the notice
8356     which states that this License applies to the Document.  These
8357     Warranty Disclaimers are considered to be included by reference in
8358     this License, but only as regards disclaiming warranties: any other
8359     implication that these Warranty Disclaimers may have is void and
8360     has no effect on the meaning of this License.
8361
8362  2. VERBATIM COPYING
8363
8364     You may copy and distribute the Document in any medium, either
8365     commercially or noncommercially, provided that this License, the
8366     copyright notices, and the license notice saying this License
8367     applies to the Document are reproduced in all copies, and that you
8368     add no other conditions whatsoever to those of this License.  You
8369     may not use technical measures to obstruct or control the reading
8370     or further copying of the copies you make or distribute.  However,
8371     you may accept compensation in exchange for copies.  If you
8372     distribute a large enough number of copies you must also follow the
8373     conditions in section 3.
8374
8375     You may also lend copies, under the same conditions stated above,
8376     and you may publicly display copies.
8377
8378  3. COPYING IN QUANTITY
8379
8380     If you publish printed copies (or copies in media that commonly
8381     have printed covers) of the Document, numbering more than 100, and
8382     the Document’s license notice requires Cover Texts, you must
8383     enclose the copies in covers that carry, clearly and legibly, all
8384     these Cover Texts: Front-Cover Texts on the front cover, and
8385     Back-Cover Texts on the back cover.  Both covers must also clearly
8386     and legibly identify you as the publisher of these copies.  The
8387     front cover must present the full title with all words of the title
8388     equally prominent and visible.  You may add other material on the
8389     covers in addition.  Copying with changes limited to the covers, as
8390     long as they preserve the title of the Document and satisfy these
8391     conditions, can be treated as verbatim copying in other respects.
8392
8393     If the required texts for either cover are too voluminous to fit
8394     legibly, you should put the first ones listed (as many as fit
8395     reasonably) on the actual cover, and continue the rest onto
8396     adjacent pages.
8397
8398     If you publish or distribute Opaque copies of the Document
8399     numbering more than 100, you must either include a machine-readable
8400     Transparent copy along with each Opaque copy, or state in or with
8401     each Opaque copy a computer-network location from which the general
8402     network-using public has access to download using public-standard
8403     network protocols a complete Transparent copy of the Document, free
8404     of added material.  If you use the latter option, you must take
8405     reasonably prudent steps, when you begin distribution of Opaque
8406     copies in quantity, to ensure that this Transparent copy will
8407     remain thus accessible at the stated location until at least one
8408     year after the last time you distribute an Opaque copy (directly or
8409     through your agents or retailers) of that edition to the public.
8410
8411     It is requested, but not required, that you contact the authors of
8412     the Document well before redistributing any large number of copies,
8413     to give them a chance to provide you with an updated version of the
8414     Document.
8415
8416  4. MODIFICATIONS
8417
8418     You may copy and distribute a Modified Version of the Document
8419     under the conditions of sections 2 and 3 above, provided that you
8420     release the Modified Version under precisely this License, with the
8421     Modified Version filling the role of the Document, thus licensing
8422     distribution and modification of the Modified Version to whoever
8423     possesses a copy of it.  In addition, you must do these things in
8424     the Modified Version:
8425
8426       A. Use in the Title Page (and on the covers, if any) a title
8427          distinct from that of the Document, and from those of previous
8428          versions (which should, if there were any, be listed in the
8429          History section of the Document).  You may use the same title
8430          as a previous version if the original publisher of that
8431          version gives permission.
8432
8433       B. List on the Title Page, as authors, one or more persons or
8434          entities responsible for authorship of the modifications in
8435          the Modified Version, together with at least five of the
8436          principal authors of the Document (all of its principal
8437          authors, if it has fewer than five), unless they release you
8438          from this requirement.
8439
8440       C. State on the Title page the name of the publisher of the
8441          Modified Version, as the publisher.
8442
8443       D. Preserve all the copyright notices of the Document.
8444
8445       E. Add an appropriate copyright notice for your modifications
8446          adjacent to the other copyright notices.
8447
8448       F. Include, immediately after the copyright notices, a license
8449          notice giving the public permission to use the Modified
8450          Version under the terms of this License, in the form shown in
8451          the Addendum below.
8452
8453       G. Preserve in that license notice the full lists of Invariant
8454          Sections and required Cover Texts given in the Document’s
8455          license notice.
8456
8457       H. Include an unaltered copy of this License.
8458
8459       I. Preserve the section Entitled “History”, Preserve its Title,
8460          and add to it an item stating at least the title, year, new
8461          authors, and publisher of the Modified Version as given on the
8462          Title Page.  If there is no section Entitled “History” in the
8463          Document, create one stating the title, year, authors, and
8464          publisher of the Document as given on its Title Page, then add
8465          an item describing the Modified Version as stated in the
8466          previous sentence.
8467
8468       J. Preserve the network location, if any, given in the Document
8469          for public access to a Transparent copy of the Document, and
8470          likewise the network locations given in the Document for
8471          previous versions it was based on.  These may be placed in the
8472          “History” section.  You may omit a network location for a work
8473          that was published at least four years before the Document
8474          itself, or if the original publisher of the version it refers
8475          to gives permission.
8476
8477       K. For any section Entitled “Acknowledgements” or “Dedications”,
8478          Preserve the Title of the section, and preserve in the section
8479          all the substance and tone of each of the contributor
8480          acknowledgements and/or dedications given therein.
8481
8482       L. Preserve all the Invariant Sections of the Document, unaltered
8483          in their text and in their titles.  Section numbers or the
8484          equivalent are not considered part of the section titles.
8485
8486       M. Delete any section Entitled “Endorsements”.  Such a section
8487          may not be included in the Modified Version.
8488
8489       N. Do not retitle any existing section to be Entitled
8490          “Endorsements” or to conflict in title with any Invariant
8491          Section.
8492
8493       O. Preserve any Warranty Disclaimers.
8494
8495     If the Modified Version includes new front-matter sections or
8496     appendices that qualify as Secondary Sections and contain no
8497     material copied from the Document, you may at your option designate
8498     some or all of these sections as invariant.  To do this, add their
8499     titles to the list of Invariant Sections in the Modified Version’s
8500     license notice.  These titles must be distinct from any other
8501     section titles.
8502
8503     You may add a section Entitled “Endorsements”, provided it contains
8504     nothing but endorsements of your Modified Version by various
8505     parties—for example, statements of peer review or that the text has
8506     been approved by an organization as the authoritative definition of
8507     a standard.
8508
8509     You may add a passage of up to five words as a Front-Cover Text,
8510     and a passage of up to 25 words as a Back-Cover Text, to the end of
8511     the list of Cover Texts in the Modified Version.  Only one passage
8512     of Front-Cover Text and one of Back-Cover Text may be added by (or
8513     through arrangements made by) any one entity.  If the Document
8514     already includes a cover text for the same cover, previously added
8515     by you or by arrangement made by the same entity you are acting on
8516     behalf of, you may not add another; but you may replace the old
8517     one, on explicit permission from the previous publisher that added
8518     the old one.
8519
8520     The author(s) and publisher(s) of the Document do not by this
8521     License give permission to use their names for publicity for or to
8522     assert or imply endorsement of any Modified Version.
8523
8524  5. COMBINING DOCUMENTS
8525
8526     You may combine the Document with other documents released under
8527     this License, under the terms defined in section 4 above for
8528     modified versions, provided that you include in the combination all
8529     of the Invariant Sections of all of the original documents,
8530     unmodified, and list them all as Invariant Sections of your
8531     combined work in its license notice, and that you preserve all
8532     their Warranty Disclaimers.
8533
8534     The combined work need only contain one copy of this License, and
8535     multiple identical Invariant Sections may be replaced with a single
8536     copy.  If there are multiple Invariant Sections with the same name
8537     but different contents, make the title of each such section unique
8538     by adding at the end of it, in parentheses, the name of the
8539     original author or publisher of that section if known, or else a
8540     unique number.  Make the same adjustment to the section titles in
8541     the list of Invariant Sections in the license notice of the
8542     combined work.
8543
8544     In the combination, you must combine any sections Entitled
8545     “History” in the various original documents, forming one section
8546     Entitled “History”; likewise combine any sections Entitled
8547     “Acknowledgements”, and any sections Entitled “Dedications”.  You
8548     must delete all sections Entitled “Endorsements.”
8549
8550  6. COLLECTIONS OF DOCUMENTS
8551
8552     You may make a collection consisting of the Document and other
8553     documents released under this License, and replace the individual
8554     copies of this License in the various documents with a single copy
8555     that is included in the collection, provided that you follow the
8556     rules of this License for verbatim copying of each of the documents
8557     in all other respects.
8558
8559     You may extract a single document from such a collection, and
8560     distribute it individually under this License, provided you insert
8561     a copy of this License into the extracted document, and follow this
8562     License in all other respects regarding verbatim copying of that
8563     document.
8564
8565  7. AGGREGATION WITH INDEPENDENT WORKS
8566
8567     A compilation of the Document or its derivatives with other
8568     separate and independent documents or works, in or on a volume of a
8569     storage or distribution medium, is called an “aggregate” if the
8570     copyright resulting from the compilation is not used to limit the
8571     legal rights of the compilation’s users beyond what the individual
8572     works permit.  When the Document is included in an aggregate, this
8573     License does not apply to the other works in the aggregate which
8574     are not themselves derivative works of the Document.
8575
8576     If the Cover Text requirement of section 3 is applicable to these
8577     copies of the Document, then if the Document is less than one half
8578     of the entire aggregate, the Document’s Cover Texts may be placed
8579     on covers that bracket the Document within the aggregate, or the
8580     electronic equivalent of covers if the Document is in electronic
8581     form.  Otherwise they must appear on printed covers that bracket
8582     the whole aggregate.
8583
8584  8. TRANSLATION
8585
8586     Translation is considered a kind of modification, so you may
8587     distribute translations of the Document under the terms of section
8588     4.  Replacing Invariant Sections with translations requires special
8589     permission from their copyright holders, but you may include
8590     translations of some or all Invariant Sections in addition to the
8591     original versions of these Invariant Sections.  You may include a
8592     translation of this License, and all the license notices in the
8593     Document, and any Warranty Disclaimers, provided that you also
8594     include the original English version of this License and the
8595     original versions of those notices and disclaimers.  In case of a
8596     disagreement between the translation and the original version of
8597     this License or a notice or disclaimer, the original version will
8598     prevail.
8599
8600     If a section in the Document is Entitled “Acknowledgements”,
8601     “Dedications”, or “History”, the requirement (section 4) to
8602     Preserve its Title (section 1) will typically require changing the
8603     actual title.
8604
8605  9. TERMINATION
8606
8607     You may not copy, modify, sublicense, or distribute the Document
8608     except as expressly provided under this License.  Any attempt
8609     otherwise to copy, modify, sublicense, or distribute it is void,
8610     and will automatically terminate your rights under this License.
8611
8612     However, if you cease all violation of this License, then your
8613     license from a particular copyright holder is reinstated (a)
8614     provisionally, unless and until the copyright holder explicitly and
8615     finally terminates your license, and (b) permanently, if the
8616     copyright holder fails to notify you of the violation by some
8617     reasonable means prior to 60 days after the cessation.
8618
8619     Moreover, your license from a particular copyright holder is
8620     reinstated permanently if the copyright holder notifies you of the
8621     violation by some reasonable means, this is the first time you have
8622     received notice of violation of this License (for any work) from
8623     that copyright holder, and you cure the violation prior to 30 days
8624     after your receipt of the notice.
8625
8626     Termination of your rights under this section does not terminate
8627     the licenses of parties who have received copies or rights from you
8628     under this License.  If your rights have been terminated and not
8629     permanently reinstated, receipt of a copy of some or all of the
8630     same material does not give you any rights to use it.
8631
8632  10. FUTURE REVISIONS OF THIS LICENSE
8633
8634     The Free Software Foundation may publish new, revised versions of
8635     the GNU Free Documentation License from time to time.  Such new
8636     versions will be similar in spirit to the present version, but may
8637     differ in detail to address new problems or concerns.  See
8638     <http://www.gnu.org/copyleft/>.
8639
8640     Each version of the License is given a distinguishing version
8641     number.  If the Document specifies that a particular numbered
8642     version of this License “or any later version” applies to it, you
8643     have the option of following the terms and conditions either of
8644     that specified version or of any later version that has been
8645     published (not as a draft) by the Free Software Foundation.  If the
8646     Document does not specify a version number of this License, you may
8647     choose any version ever published (not as a draft) by the Free
8648     Software Foundation.  If the Document specifies that a proxy can
8649     decide which future versions of this License can be used, that
8650     proxy’s public statement of acceptance of a version permanently
8651     authorizes you to choose that version for the Document.
8652
8653  11. RELICENSING
8654
8655     “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
8656     World Wide Web server that publishes copyrightable works and also
8657     provides prominent facilities for anybody to edit those works.  A
8658     public wiki that anybody can edit is an example of such a server.
8659     A “Massive Multiauthor Collaboration” (or “MMC”) contained in the
8660     site means any set of copyrightable works thus published on the MMC
8661     site.
8662
8663     “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
8664     license published by Creative Commons Corporation, a not-for-profit
8665     corporation with a principal place of business in San Francisco,
8666     California, as well as future copyleft versions of that license
8667     published by that same organization.
8668
8669     “Incorporate” means to publish or republish a Document, in whole or
8670     in part, as part of another Document.
8671
8672     An MMC is “eligible for relicensing” if it is licensed under this
8673     License, and if all works that were first published under this
8674     License somewhere other than this MMC, and subsequently
8675     incorporated in whole or in part into the MMC, (1) had no cover
8676     texts or invariant sections, and (2) were thus incorporated prior
8677     to November 1, 2008.
8678
8679     The operator of an MMC Site may republish an MMC contained in the
8680     site under CC-BY-SA on the same site at any time before August 1,
8681     2009, provided the MMC is eligible for relicensing.
8682
8683ADDENDUM: How to use this License for your documents
8684====================================================
8685
8686To use this License in a document you have written, include a copy of
8687the License in the document and put the following copyright and license
8688notices just after the title page:
8689
8690       Copyright (C)  YEAR  YOUR NAME.
8691       Permission is granted to copy, distribute and/or modify this document
8692       under the terms of the GNU Free Documentation License, Version 1.3
8693       or any later version published by the Free Software Foundation;
8694       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
8695       Texts.  A copy of the license is included in the section entitled ``GNU
8696       Free Documentation License''.
8697
8698   If you have Invariant Sections, Front-Cover Texts and Back-Cover
8699Texts, replace the “with...Texts.” line with this:
8700
8701         with the Invariant Sections being LIST THEIR TITLES, with
8702         the Front-Cover Texts being LIST, and with the Back-Cover Texts
8703         being LIST.
8704
8705   If you have Invariant Sections without Cover Texts, or some other
8706combination of the three, merge those two alternatives to suit the
8707situation.
8708
8709   If your document contains nontrivial examples of program code, we
8710recommend releasing these examples in parallel under your choice of free
8711software license, such as the GNU General Public License, to permit
8712their use in free software.
8713
8714
8715File: ld.info,  Node: LD Index,  Prev: GNU Free Documentation License,  Up: Top
8716
8717LD Index
8718********
8719
8720�[index�]
8721* Menu:
8722
8723* ":                                     Symbols.            (line    6)
8724* -(:                                    Options.            (line 1218)
8725* --accept-unknown-input-arch:           Options.            (line 1236)
8726* --add-needed:                          Options.            (line 1267)
8727* --add-stdcall-alias:                   Options.            (line 2453)
8728* --allow-multiple-definition:           Options.            (line 1646)
8729* --allow-shlib-undefined:               Options.            (line 1652)
8730* --as-needed:                           Options.            (line 1246)
8731* --audit AUDITLIB:                      Options.            (line  111)
8732* --auxiliary=NAME:                      Options.            (line  308)
8733* --bank-window:                         Options.            (line 2949)
8734* --base-file:                           Options.            (line 2458)
8735* --be8:                                 ARM.                (line   28)
8736* --branch-stub on C-SKY:                Options.            (line 2921)
8737* --bss-plt:                             PowerPC ELF32.      (line   16)
8738* --build-id:                            Options.            (line 2405)
8739* --build-id=STYLE:                      Options.            (line 2405)
8740* --check-sections:                      Options.            (line 1349)
8741* --cmse-implib:                         ARM.                (line  231)
8742* --code-region:                         MSP430.             (line   34)
8743* --compact-branches:                    Options.            (line 2994)
8744* --compress-debug-sections=none:        Options.            (line 2354)
8745* --compress-debug-sections=zlib:        Options.            (line 2354)
8746* --compress-debug-sections=zlib-gabi:   Options.            (line 2354)
8747* --compress-debug-sections=zlib-gnu:    Options.            (line 2354)
8748* --compress-debug-sections=zstd:        Options.            (line 2354)
8749* --copy-dt-needed-entries:              Options.            (line 1361)
8750* --cref:                                Options.            (line 1381)
8751* --ctf-share-types:                     Options.            (line 1405)
8752* --ctf-variables:                       Options.            (line 1394)
8753* --data-region:                         MSP430.             (line   39)
8754* --default-imported-symver:             Options.            (line 1702)
8755* --default-script=SCRIPT:               Options.            (line  743)
8756* --default-symver:                      Options.            (line 1698)
8757* --defsym=SYMBOL=EXP:                   Options.            (line 1449)
8758* --demangle[=STYLE]:                    Options.            (line 1469)
8759* --depaudit AUDITLIB:                   Options.            (line  164)
8760* --dependency-file=DEPFILE:             Options.            (line  609)
8761* --disable-auto-image-base:             Options.            (line 2635)
8762* --disable-auto-import:                 Options.            (line 2774)
8763* --disable-large-address-aware:         Options.            (line 2583)
8764* --disable-linker-version:              Options.            (line  184)
8765* --disable-long-section-names:          Options.            (line 2468)
8766* --disable-multiple-abs-defs:           Options.            (line 1500)
8767* --disable-new-dtags:                   Options.            (line 2328)
8768* --disable-runtime-pseudo-reloc:        Options.            (line 2787)
8769* --disable-sec-transformation:          MSP430.             (line   45)
8770* --disable-stdcall-fixup:               Options.            (line 2490)
8771* --discard-all:                         Options.            (line  836)
8772* --discard-locals:                      Options.            (line  840)
8773* --dll:                                 Options.            (line 2463)
8774* --dll-search-prefix:                   Options.            (line 2641)
8775* --dotsyms:                             PowerPC64 ELF64.    (line   33)
8776* --dsbt-index:                          Options.            (line 2908)
8777* --dsbt-size:                           Options.            (line 2903)
8778* --dynamic-linker=FILE:                 Options.            (line 1482)
8779* --dynamic-list-cpp-new:                Options.            (line 1341)
8780* --dynamic-list-cpp-typeinfo:           Options.            (line 1345)
8781* --dynamic-list-data:                   Options.            (line 1338)
8782* --dynamic-list=DYNAMIC-LIST-FILE:      Options.            (line 1325)
8783* --dynamicbase:                         Options.            (line 2831)
8784* --eh-frame-hdr:                        Options.            (line 2315)
8785* --embedded-relocs:                     Options.            (line 1495)
8786* --emit-relocs:                         Options.            (line  669)
8787* --emit-stack-syms:                     SPU ELF.            (line   46)
8788* --emit-stub-syms:                      PowerPC ELF32.      (line   47)
8789* --emit-stub-syms <1>:                  PowerPC64 ELF64.    (line   29)
8790* --emit-stub-syms <2>:                  SPU ELF.            (line   15)
8791* --enable-auto-image-base:              Options.            (line 2626)
8792* --enable-auto-import:                  Options.            (line 2650)
8793* --enable-extra-pe-debug:               Options.            (line 2792)
8794* --enable-linker-version:               Options.            (line  174)
8795* --enable-long-section-names:           Options.            (line 2468)
8796* --enable-new-dtags:                    Options.            (line 2328)
8797* --enable-non-contiguous-regions:       Options.            (line  188)
8798* --enable-non-contiguous-regions-warnings: Options.         (line  220)
8799* --enable-reloc-section:                Options.            (line 2890)
8800* --enable-runtime-pseudo-reloc:         Options.            (line 2779)
8801* --enable-stdcall-fixup:                Options.            (line 2490)
8802* --entry=ENTRY:                         Options.            (line  226)
8803* --error-execstack:                     Options.            (line 2176)
8804* --error-handling-script=SCRIPTNAME:    Options.            (line 1679)
8805* --error-rwx-segments:                  Options.            (line 2219)
8806* --error-unresolved-symbols:            Options.            (line 2251)
8807* --exclude-all-symbols:                 Options.            (line 2543)
8808* --exclude-libs:                        Options.            (line  236)
8809* --exclude-modules-for-implib:          Options.            (line  247)
8810* --exclude-symbols:                     Options.            (line 2537)
8811* --export-all-symbols:                  Options.            (line 2513)
8812* --export-dynamic:                      Options.            (line  260)
8813* --export-dynamic-symbol-list=FILE:     Options.            (line  296)
8814* --export-dynamic-symbol=GLOB:          Options.            (line  287)
8815* --extra-overlay-stubs:                 SPU ELF.            (line   19)
8816* --fatal-warnings:                      Options.            (line 1504)
8817* --file-alignment:                      Options.            (line 2547)
8818* --filter=NAME:                         Options.            (line  329)
8819* --fix-arm1176:                         ARM.                (line  108)
8820* --fix-cortex-a53-835769:               ARM.                (line  208)
8821* --fix-cortex-a8:                       ARM.                (line  199)
8822* --fix-stm32l4xx-629360:                ARM.                (line  117)
8823* --fix-v4bx:                            ARM.                (line   48)
8824* --fix-v4bx-interworking:               ARM.                (line   61)
8825* --force-dynamic:                       Options.            (line  678)
8826* --force-exe-suffix:                    Options.            (line 1516)
8827* --force-group-allocation:              Options.            (line 1441)
8828* --forceinteg:                          Options.            (line 2839)
8829* --format=FORMAT:                       Options.            (line  121)
8830* --format=VERSION:                      TI COFF.            (line    6)
8831* --gc-keep-exported:                    Options.            (line 1564)
8832* --gc-sections:                         Options.            (line 1526)
8833* --got:                                 Options.            (line 2961)
8834* --got=TYPE:                            M68K.               (line    6)
8835* --gpsize=VALUE:                        Options.            (line  361)
8836* --hash-size=NUMBER:                    Options.            (line 2338)
8837* --hash-style=STYLE:                    Options.            (line 2346)
8838* --heap:                                Options.            (line 2553)
8839* --help:                                Options.            (line 1592)
8840* --high-entropy-va:                     Options.            (line 2823)
8841* --ignore-branch-isa:                   Options.            (line 2982)
8842* --ignore-branch-isa <1>:               MIPS.               (line   13)
8843* --image-base:                          Options.            (line 2560)
8844* --imagic:                              Options.            (line 3031)
8845* --in-implib=FILE:                      ARM.                (line  236)
8846* --insert-timestamp:                    Options.            (line 2874)
8847* --insn32:                              Options.            (line 2973)
8848* --insn32 <1>:                          MIPS.               (line    6)
8849* --just-symbols=FILE:                   Options.            (line  700)
8850* --kill-at:                             Options.            (line 2569)
8851* --large-address-aware:                 Options.            (line 2574)
8852* --ld-generated-unwind-info:            Options.            (line 2321)
8853* --leading-underscore:                  Options.            (line 2507)
8854* --library-path=DIR:                    Options.            (line  419)
8855* --library=NAMESPEC:                    Options.            (line  386)
8856* --local-store=lo:hi:                   SPU ELF.            (line   24)
8857* --long-plt:                            ARM.                (line  219)
8858* --major-image-version:                 Options.            (line 2590)
8859* --major-os-version:                    Options.            (line 2595)
8860* --major-subsystem-version:             Options.            (line 2599)
8861* --max-cache-size=SIZE:                 Options.            (line 2400)
8862* --merge-exidx-entries:                 ARM.                (line  216)
8863* --minor-image-version:                 Options.            (line 2604)
8864* --minor-os-version:                    Options.            (line 2609)
8865* --minor-subsystem-version:             Options.            (line 2613)
8866* --mri-script=MRI-CMDFILE:              Options.            (line  145)
8867* --multi-subspace:                      HPPA ELF32.         (line    6)
8868* --nmagic:                              Options.            (line  582)
8869* --nmagic <1>:                          Options.            (line 3021)
8870* --no-accept-unknown-input-arch:        Options.            (line 1236)
8871* --no-add-needed:                       Options.            (line 1267)
8872* --no-allow-shlib-undefined:            Options.            (line 1652)
8873* --no-apply-dynamic-relocs:             ARM.                (line  223)
8874* --no-as-needed:                        Options.            (line 1246)
8875* --no-bind:                             Options.            (line 2860)
8876* --no-check-sections:                   Options.            (line 1349)
8877* --no-compact-branches:                 Options.            (line 2995)
8878* --no-copy-dt-needed-entries:           Options.            (line 1361)
8879* --no-ctf-variables:                    Options.            (line 1394)
8880* --no-define-common:                    Options.            (line 1425)
8881* --no-demangle:                         Options.            (line 1469)
8882* --no-dotsyms:                          PowerPC64 ELF64.    (line   33)
8883* --no-dynamic-linker:                   Options.            (line 1489)
8884* --no-eh-frame-hdr:                     Options.            (line 2315)
8885* --no-enum-size-warning:                ARM.                (line  155)
8886* --no-export-dynamic:                   Options.            (line  260)
8887* --no-fatal-warnings:                   Options.            (line 1504)
8888* --no-fix-arm1176:                      ARM.                (line  108)
8889* --no-fix-cortex-a53-835769:            ARM.                (line  208)
8890* --no-fix-cortex-a8:                    ARM.                (line  199)
8891* --no-gc-sections:                      Options.            (line 1526)
8892* --no-ignore-branch-isa:                Options.            (line 2983)
8893* --no-ignore-branch-isa <1>:            MIPS.               (line   13)
8894* --no-inline-optimize:                  PowerPC64 ELF64.    (line  101)
8895* --no-insn32:                           Options.            (line 2974)
8896* --no-insn32 <1>:                       MIPS.               (line    6)
8897* --no-isolation:                        Options.            (line 2850)
8898* --no-keep-memory:                      Options.            (line 1629)
8899* --no-leading-underscore:               Options.            (line 2507)
8900* --no-merge-exidx-entries:              Options.            (line 2915)
8901* --no-merge-exidx-entries <1>:          ARM.                (line  216)
8902* --no-multi-toc:                        PowerPC64 ELF64.    (line  109)
8903* --no-omagic:                           Options.            (line  597)
8904* --no-omagic <1>:                       Options.            (line 3045)
8905* --no-opd-optimize:                     PowerPC64 ELF64.    (line   75)
8906* --no-overlays:                         SPU ELF.            (line    9)
8907* --no-plt-align:                        PowerPC64 ELF64.    (line  131)
8908* --no-plt-localentry:                   PowerPC64 ELF64.    (line  160)
8909* --no-plt-static-chain:                 PowerPC64 ELF64.    (line  142)
8910* --no-plt-thread-safe:                  PowerPC64 ELF64.    (line  148)
8911* --no-power10-stubs:                    PowerPC64 ELF64.    (line  176)
8912* --no-print-gc-sections:                Options.            (line 1555)
8913* --no-print-map-discarded:              Options.            (line  569)
8914* --no-print-map-locals:                 Options.            (line  574)
8915* --no-save-restore-funcs:               PowerPC64 ELF64.    (line   44)
8916* --no-seh:                              Options.            (line 2855)
8917* --no-strip-discarded:                  Options.            (line  720)
8918* --no-tls-get-addr-optimize:            PowerPC64 ELF64.    (line   56)
8919* --no-tls-get-addr-regsave:             PowerPC64 ELF64.    (line   56)
8920* --no-tls-optimize:                     PowerPC ELF32.      (line   51)
8921* --no-tls-optimize <1>:                 PowerPC64 ELF64.    (line   51)
8922* --no-toc-optimize:                     PowerPC64 ELF64.    (line   87)
8923* --no-toc-sort:                         PowerPC64 ELF64.    (line  121)
8924* --no-trampoline:                       Options.            (line 2943)
8925* --no-undefined:                        Options.            (line 1636)
8926* --no-undefined-version:                Options.            (line 1693)
8927* --no-warn-mismatch:                    Options.            (line 1706)
8928* --no-warn-search-mismatch:             Options.            (line 1715)
8929* --no-warnings:                         Options.            (line 1509)
8930* --no-wchar-size-warning:               ARM.                (line  162)
8931* --no-whole-archive:                    Options.            (line 1719)
8932* --noinhibit-exec:                      Options.            (line 1723)
8933* --non-overlapping-opd:                 PowerPC64 ELF64.    (line   81)
8934* --nxcompat:                            Options.            (line 2844)
8935* --oformat=OUTPUT-FORMAT:               Options.            (line 1734)
8936* --omagic:                              Options.            (line  588)
8937* --omagic <1>:                          Options.            (line 3010)
8938* --orphan-handling=MODE:                Options.            (line  792)
8939* --out-implib:                          Options.            (line 1747)
8940* --output-def:                          Options.            (line 2618)
8941* --output=OUTPUT:                       Options.            (line  603)
8942* --package-metadata=JSON:               Options.            (line 2427)
8943* --pic-executable:                      Options.            (line 1756)
8944* --pic-veneer:                          ARM.                (line  168)
8945* --plt-align:                           PowerPC64 ELF64.    (line  131)
8946* --plt-localentry:                      PowerPC64 ELF64.    (line  160)
8947* --plt-static-chain:                    PowerPC64 ELF64.    (line  142)
8948* --plt-thread-safe:                     PowerPC64 ELF64.    (line  148)
8949* --plugin:                              SPU ELF.            (line    6)
8950* --pop-state:                           Options.            (line  665)
8951* --power10-stubs:                       PowerPC64 ELF64.    (line  176)
8952* --print-gc-sections:                   Options.            (line 1555)
8953* --print-map:                           Options.            (line  506)
8954* --print-map-discarded:                 Options.            (line  569)
8955* --print-map-locals:                    Options.            (line  574)
8956* --print-memory-usage:                  Options.            (line 1580)
8957* --print-output-format:                 Options.            (line 1574)
8958* --push-state:                          Options.            (line  647)
8959* --reduce-memory-overheads:             Options.            (line 2386)
8960* --relax:                               Options.            (line 1775)
8961* --relax on Nios II:                    Nios II.            (line    6)
8962* --relax on PowerPC:                    PowerPC ELF32.      (line    6)
8963* --relax on Xtensa:                     Xtensa.             (line   27)
8964* --relocatable:                         Options.            (line  682)
8965* --remap-inputs-file=file:              Options.            (line  454)
8966* --remap-inputs=pattern=filename:       Options.            (line  454)
8967* --require-defined=SYMBOL:              Options.            (line  769)
8968* --retain-symbols-file=FILENAME:        Options.            (line 1801)
8969* --s390-pgste:                          S/390 ELF.          (line    6)
8970* --save-restore-funcs:                  PowerPC64 ELF64.    (line   44)
8971* --script=SCRIPT:                       Options.            (line  733)
8972* --sdata-got:                           PowerPC ELF32.      (line   33)
8973* --section-alignment:                   Options.            (line 2797)
8974* --section-start=SECTIONNAME=ORG:       Options.            (line 1996)
8975* --secure-plt:                          PowerPC ELF32.      (line   26)
8976* --sort-common:                         Options.            (line 1928)
8977* --sort-section=alignment:              Options.            (line 1943)
8978* --sort-section=name:                   Options.            (line 1939)
8979* --spare-dynamic-tags:                  Options.            (line 1947)
8980* --split-by-file:                       Options.            (line 1952)
8981* --split-by-reloc:                      Options.            (line 1957)
8982* --stack:                               Options.            (line 2803)
8983* --stack-analysis:                      SPU ELF.            (line   29)
8984* --stats:                               Options.            (line 1970)
8985* --strip-all:                           Options.            (line  711)
8986* --strip-debug:                         Options.            (line  715)
8987* --strip-discarded:                     Options.            (line  720)
8988* --stub-group-size:                     PowerPC64 ELF64.    (line    6)
8989* --stub-group-size on C-SKY:            Options.            (line 2928)
8990* --stub-group-size=N:                   ARM.                (line  173)
8991* --stub-group-size=N <1>:               HPPA ELF32.         (line   12)
8992* --subsystem:                           Options.            (line 2810)
8993* --support-old-code:                    ARM.                (line    6)
8994* --sysroot=DIRECTORY:                   Options.            (line 1974)
8995* --target-help:                         Options.            (line 1596)
8996* --target1-abs:                         ARM.                (line   33)
8997* --target1-rel:                         ARM.                (line   33)
8998* --target2=TYPE:                        ARM.                (line   38)
8999* --task-link:                           Options.            (line 1979)
9000* --thumb-entry=ENTRY:                   ARM.                (line   17)
9001* --tls-get-addr-optimize:               PowerPC64 ELF64.    (line   56)
9002* --tls-get-addr-regsave:                PowerPC64 ELF64.    (line   56)
9003* --trace:                               Options.            (line  725)
9004* --trace-symbol=SYMBOL:                 Options.            (line  846)
9005* --traditional-format:                  Options.            (line 1984)
9006* --tsaware:                             Options.            (line 2869)
9007* --undefined=SYMBOL:                    Options.            (line  756)
9008* --unique[=SECTION]:                    Options.            (line  818)
9009* --unresolved-symbols:                  Options.            (line 2026)
9010* --use-blx:                             ARM.                (line   73)
9011* --use-nul-prefixed-import-tables:      ARM.                (line   23)
9012* --verbose[=NUMBER]:                    Options.            (line 2055)
9013* --version:                             Options.            (line  827)
9014* --version-script=VERSION-SCRIPTFILE:   Options.            (line 2063)
9015* --vfp11-denorm-fix:                    ARM.                (line   79)
9016* --warn-alternate-em:                   Options.            (line 2243)
9017* --warn-common:                         Options.            (line 2073)
9018* --warn-constructors:                   Options.            (line 2141)
9019* --warn-execstack:                      Options.            (line 2146)
9020* --warn-multiple-gp:                    Options.            (line 2188)
9021* --warn-once:                           Options.            (line 2202)
9022* --warn-rwx-segments:                   Options.            (line 2206)
9023* --warn-section-align:                  Options.            (line 2232)
9024* --warn-textrel:                        Options.            (line 2239)
9025* --warn-unresolved-symbols:             Options.            (line 2246)
9026* --wdmdriver:                           Options.            (line 2864)
9027* --whole-archive:                       Options.            (line 2255)
9028* --wrap=SYMBOL:                         Options.            (line 2269)
9029* -a KEYWORD:                            Options.            (line  104)
9030* -assert KEYWORD:                       Options.            (line 1274)
9031* -b FORMAT:                             Options.            (line  121)
9032* -Bdynamic:                             Options.            (line 1277)
9033* -Bgroup:                               Options.            (line 1287)
9034* -Bno-symbolic:                         Options.            (line 1321)
9035* -Bshareable:                           Options.            (line 1921)
9036* -Bstatic:                              Options.            (line 1294)
9037* -Bsymbolic:                            Options.            (line 1308)
9038* -Bsymbolic-functions:                  Options.            (line 1315)
9039* -c MRI-CMDFILE:                        Options.            (line  145)
9040* -call_shared:                          Options.            (line 1277)
9041* -d:                                    Options.            (line  155)
9042* -dc:                                   Options.            (line  155)
9043* -dn:                                   Options.            (line 1294)
9044* -dp:                                   Options.            (line  155)
9045* -dT SCRIPT:                            Options.            (line  743)
9046* -dy:                                   Options.            (line 1277)
9047* -E:                                    Options.            (line  260)
9048* -e ENTRY:                              Options.            (line  226)
9049* -EB:                                   Options.            (line  301)
9050* -EL:                                   Options.            (line  304)
9051* -f NAME:                               Options.            (line  308)
9052* -F NAME:                               Options.            (line  329)
9053* -fini=NAME:                            Options.            (line  352)
9054* -g:                                    Options.            (line  358)
9055* -G VALUE:                              Options.            (line  361)
9056* -h NAME:                               Options.            (line  368)
9057* -i:                                    Options.            (line  377)
9058* -IFILE:                                Options.            (line 1482)
9059* -init=NAME:                            Options.            (line  380)
9060* -L DIR:                                Options.            (line  419)
9061* -l NAMESPEC:                           Options.            (line  386)
9062* -M:                                    Options.            (line  506)
9063* -m EMULATION:                          Options.            (line  444)
9064* -Map=MAPFILE:                          Options.            (line 1600)
9065* -n:                                    Options.            (line  582)
9066* -N:                                    Options.            (line  588)
9067* -N <1>:                                Options.            (line 3009)
9068* -n <1>:                                Options.            (line 3020)
9069* -no-pie:                               Options.            (line 1766)
9070* –no-relax:                             Options.            (line 1775)
9071* -non_shared:                           Options.            (line 1294)
9072* -nostdlib:                             Options.            (line 1729)
9073* -O LEVEL:                              Options.            (line  622)
9074* -o OUTPUT:                             Options.            (line  603)
9075* -P AUDITLIB:                           Options.            (line  164)
9076* -pie:                                  Options.            (line 1756)
9077* -plugin NAME:                          Options.            (line  632)
9078* -q:                                    Options.            (line  669)
9079* -qmagic:                               Options.            (line 1769)
9080* -Qy:                                   Options.            (line 1772)
9081* -r:                                    Options.            (line  682)
9082* -R FILE:                               Options.            (line  700)
9083* -rpath-link=DIR:                       Options.            (line 1842)
9084* -rpath=DIR:                            Options.            (line 1815)
9085* -s:                                    Options.            (line  711)
9086* -S:                                    Options.            (line  715)
9087* -shared:                               Options.            (line 1921)
9088* -soname=NAME:                          Options.            (line  368)
9089* -static:                               Options.            (line 1294)
9090* -t:                                    Options.            (line  725)
9091* -T SCRIPT:                             Options.            (line  733)
9092* -Tbss=ORG:                             Options.            (line 2005)
9093* -Tdata=ORG:                            Options.            (line 2005)
9094* -Tldata-segment=ORG:                   Options.            (line 2021)
9095* -Trodata-segment=ORG:                  Options.            (line 2015)
9096* -Ttext-segment=ORG:                    Options.            (line 2011)
9097* -Ttext=ORG:                            Options.            (line 2005)
9098* -u SYMBOL:                             Options.            (line  756)
9099* -Ur:                                   Options.            (line  777)
9100* -v:                                    Options.            (line  827)
9101* -V:                                    Options.            (line  827)
9102* -w:                                    Options.            (line 1509)
9103* -x:                                    Options.            (line  836)
9104* -X:                                    Options.            (line  840)
9105* -Y PATH:                               Options.            (line  855)
9106* -y SYMBOL:                             Options.            (line  846)
9107* -z:                                    Options.            (line 3030)
9108* -z defs:                               Options.            (line 1636)
9109* -z KEYWORD:                            Options.            (line  859)
9110* -z muldefs:                            Options.            (line 1646)
9111* -z undefs:                             Options.            (line 1636)
9112* .:                                     Location Counter.   (line    6)
9113* /DISCARD/:                             Output Section Discarding.
9114                                                             (line   26)
9115* 32-bit PLT entries:                    ARM.                (line  219)
9116* :PHDR:                                 Output Section Phdr.
9117                                                             (line    6)
9118* =FILLEXP:                              Output Section Fill.
9119                                                             (line    6)
9120* >REGION:                               Output Section Region.
9121                                                             (line    6)
9122* [COMMON]:                              Input Section Common.
9123                                                             (line   29)
9124* AArch64 rela addend:                   ARM.                (line  223)
9125* ABSOLUTE (MRI):                        MRI.                (line   32)
9126* absolute and relocatable symbols:      Expression Section. (line    6)
9127* absolute expressions:                  Expression Section. (line    6)
9128* ABSOLUTE(EXP):                         Builtin Functions.  (line   10)
9129* ADDR(SECTION):                         Builtin Functions.  (line   17)
9130* address, section:                      Output Section Address.
9131                                                             (line    6)
9132* ALIAS (MRI):                           MRI.                (line   43)
9133* ALIGN (MRI):                           MRI.                (line   49)
9134* align expression:                      Builtin Functions.  (line   38)
9135* align location counter:                Builtin Functions.  (line   38)
9136* ALIGN(ALIGN):                          Builtin Functions.  (line   38)
9137* ALIGN(EXP,ALIGN):                      Builtin Functions.  (line   38)
9138* ALIGN(SECTION_ALIGN):                  Forced Output Alignment.
9139                                                             (line    6)
9140* aligned common symbols:                WIN32.              (line  445)
9141* ALIGNOF(SECTION):                      Builtin Functions.  (line   63)
9142* allocating memory:                     MEMORY.             (line    6)
9143* architecture:                          Miscellaneous Commands.
9144                                                             (line  127)
9145* archive files, from cmd line:          Options.            (line  386)
9146* archive search path in linker script:  File Commands.      (line   80)
9147* arithmetic:                            Expressions.        (line    6)
9148* arithmetic operators:                  Operators.          (line    6)
9149* ARM interworking support:              ARM.                (line    6)
9150* ARM1176 erratum workaround:            ARM.                (line  108)
9151* ASCIZ ``STRING'':                      Output Section Data.
9152                                                             (line    6)
9153* ASSERT:                                Miscellaneous Commands.
9154                                                             (line    9)
9155* assertion in linker script:            Miscellaneous Commands.
9156                                                             (line    9)
9157* assignment in scripts:                 Assignments.        (line    6)
9158* AS_NEEDED(FILES):                      File Commands.      (line   60)
9159* AT(LMA):                               Output Section LMA. (line    6)
9160* AT>LMA_REGION:                         Output Section LMA. (line    6)
9161* automatic data imports:                WIN32.              (line  214)
9162* back end:                              BFD.                (line    6)
9163* BASE (MRI):                            MRI.                (line   53)
9164* BE8:                                   ARM.                (line   28)
9165* BFD canonical format:                  Canonical format.   (line   11)
9166* BFD requirements:                      BFD.                (line   16)
9167* big-endian objects:                    Options.            (line  301)
9168* binary input format:                   Options.            (line  121)
9169* BLOCK(EXP):                            Builtin Functions.  (line   79)
9170* bug criteria:                          Bug Criteria.       (line    6)
9171* bug reports:                           Bug Reporting.      (line    6)
9172* bugs in ld:                            Reporting Bugs.     (line    6)
9173* BYTE(EXPRESSION):                      Output Section Data.
9174                                                             (line    6)
9175* C++ constructors, arranging in link:   Output Section Keywords.
9176                                                             (line   19)
9177* CHIP (MRI):                            MRI.                (line   57)
9178* COLLECT_NO_DEMANGLE:                   Environment.        (line   29)
9179* combining symbols, warnings on:        Options.            (line 2073)
9180* COMDAT:                                Options.            (line 1441)
9181* COMDAT <1>:                            Miscellaneous Commands.
9182                                                             (line   56)
9183* command files:                         Scripts.            (line    6)
9184* command line:                          Options.            (line    6)
9185* common allocation:                     Options.            (line  155)
9186* common allocation <1>:                 Options.            (line 1425)
9187* common allocation in linker script:    Miscellaneous Commands.
9188                                                             (line   46)
9189* common allocation in linker script <1>: Miscellaneous Commands.
9190                                                             (line   51)
9191* common symbol placement:               Input Section Common.
9192                                                             (line    6)
9193* COMMONPAGESIZE:                        Symbolic Constants. (line   13)
9194* compatibility, MRI:                    Options.            (line  145)
9195* CONSTANT:                              Symbolic Constants. (line    6)
9196* constants in linker scripts:           Constants.          (line    6)
9197* constraints on output sections:        Output Section Constraint.
9198                                                             (line    6)
9199* constructors:                          Options.            (line  777)
9200* CONSTRUCTORS:                          Output Section Keywords.
9201                                                             (line   19)
9202* constructors, arranging in link:       Output Section Keywords.
9203                                                             (line   19)
9204* Cortex-A53 erratum 835769 workaround:  ARM.                (line  208)
9205* Cortex-A8 erratum workaround:          ARM.                (line  199)
9206* crash of linker:                       Bug Criteria.       (line    9)
9207* CREATE_OBJECT_SYMBOLS:                 Output Section Keywords.
9208                                                             (line    9)
9209* creating a DEF file:                   WIN32.              (line  182)
9210* cross reference table:                 Options.            (line 1381)
9211* cross references:                      Miscellaneous Commands.
9212                                                             (line   94)
9213* cross references <1>:                  Miscellaneous Commands.
9214                                                             (line  110)
9215* ctf type sharing:                      Options.            (line 1405)
9216* ctf variables:                         Options.            (line 1394)
9217* current output location:               Location Counter.   (line    6)
9218* data:                                  Output Section Data.
9219                                                             (line    6)
9220* DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE): Builtin Functions.
9221                                                             (line   84)
9222* DATA_SEGMENT_END(EXP):                 Builtin Functions.  (line  108)
9223* DATA_SEGMENT_RELRO_END(OFFSET, EXP):   Builtin Functions.  (line  114)
9224* dbx:                                   Options.            (line 1989)
9225* DEF files, creating:                   Options.            (line 2618)
9226* default emulation:                     Environment.        (line   21)
9227* default input format:                  Environment.        (line    9)
9228* defined symbol:                        Options.            (line  769)
9229* DEFINED(SYMBOL):                       Builtin Functions.  (line  127)
9230* deleting local symbols:                Options.            (line  836)
9231* demangling, default:                   Environment.        (line   29)
9232* demangling, from command line:         Options.            (line 1469)
9233* dependency file:                       Options.            (line  609)
9234* direct linking to a dll:               WIN32.              (line  262)
9235* discarding sections:                   Output Section Discarding.
9236                                                             (line    6)
9237* discontinuous memory:                  MEMORY.             (line    6)
9238* DLLs, creating:                        Options.            (line 2513)
9239* DLLs, creating <1>:                    Options.            (line 2618)
9240* DLLs, creating <2>:                    Options.            (line 2626)
9241* DLLs, linking to:                      Options.            (line 2641)
9242* dot:                                   Location Counter.   (line    6)
9243* dot inside sections:                   Location Counter.   (line   36)
9244* dot outside sections:                  Location Counter.   (line   66)
9245* dynamic linker, from command line:     Options.            (line 1482)
9246* dynamic symbol table:                  Options.            (line  260)
9247* ELF program headers:                   PHDRS.              (line    6)
9248* ELF symbol visibility:                 Options.            (line 1174)
9249* emulation:                             Options.            (line  444)
9250* emulation, default:                    Environment.        (line   21)
9251* END (MRI):                             MRI.                (line   61)
9252* endianness:                            Options.            (line  301)
9253* entry point:                           Entry Point.        (line    6)
9254* entry point, from command line:        Options.            (line  226)
9255* entry point, thumb:                    ARM.                (line   17)
9256* ENTRY(SYMBOL):                         Entry Point.        (line    6)
9257* error on valid input:                  Bug Criteria.       (line   12)
9258* example of linker script:              Simple Example.     (line    6)
9259* EXCLUDE_FILE:                          Input Section Basics.
9260                                                             (line   17)
9261* executable segments, warnings on:      Options.            (line 2206)
9262* executable stack, warnings on:         Options.            (line 2146)
9263* export dynamic symbol:                 Options.            (line  287)
9264* export dynamic symbol list:            Options.            (line  296)
9265* exporting DLL symbols:                 WIN32.              (line   48)
9266* expression evaluation order:           Evaluation.         (line    6)
9267* expression sections:                   Expression Section. (line    6)
9268* expression, absolute:                  Builtin Functions.  (line   10)
9269* expressions:                           Expressions.        (line    6)
9270* EXTERN:                                Miscellaneous Commands.
9271                                                             (line   39)
9272* fatal signal:                          Bug Criteria.       (line    9)
9273* file name wildcard patterns:           Input Section Wildcards.
9274                                                             (line    6)
9275* FILEHDR:                               PHDRS.              (line   62)
9276* filename symbols:                      Output Section Keywords.
9277                                                             (line    9)
9278* fill pattern, entire section:          Output Section Fill.
9279                                                             (line    6)
9280* FILL(EXPRESSION):                      Output Section Data.
9281                                                             (line   49)
9282* finalization function:                 Options.            (line  352)
9283* first input file:                      File Commands.      (line   88)
9284* first instruction:                     Entry Point.        (line    6)
9285* FIX_V4BX:                              ARM.                (line   48)
9286* FIX_V4BX_INTERWORKING:                 ARM.                (line   61)
9287* FORCE_COMMON_ALLOCATION:               Miscellaneous Commands.
9288                                                             (line   46)
9289* FORCE_GROUP_ALLOCATION:                Miscellaneous Commands.
9290                                                             (line   56)
9291* forcing input section alignment:       Forced Input Alignment.
9292                                                             (line    6)
9293* forcing output section alignment:      Forced Output Alignment.
9294                                                             (line    6)
9295* forcing the creation of dynamic sections: Options.         (line  678)
9296* FORMAT (MRI):                          MRI.                (line   65)
9297* functions in expressions:              Builtin Functions.  (line    6)
9298* garbage collection:                    Options.            (line 1526)
9299* garbage collection <1>:                Options.            (line 1555)
9300* garbage collection <2>:                Options.            (line 1564)
9301* garbage collection <3>:                Input Section Keep. (line    6)
9302* generating optimized output:           Options.            (line  622)
9303* GNU linker:                            Overview.           (line    6)
9304* GNUTARGET:                             Environment.        (line    9)
9305* group allocation in linker script:     Options.            (line 1441)
9306* group allocation in linker script <1>: Miscellaneous Commands.
9307                                                             (line   56)
9308* GROUP(FILES):                          File Commands.      (line   53)
9309* grouping input files:                  File Commands.      (line   53)
9310* groups of archives:                    Options.            (line 1218)
9311* H8/300 support:                        H8/300.             (line    6)
9312* header size:                           Builtin Functions.  (line  197)
9313* heap size:                             Options.            (line 2553)
9314* help:                                  Options.            (line 1592)
9315* HIDDEN:                                HIDDEN.             (line    6)
9316* holes:                                 Location Counter.   (line   12)
9317* holes, filling:                        Output Section Data.
9318                                                             (line   49)
9319* HPPA multiple sub-space stubs:         HPPA ELF32.         (line    6)
9320* HPPA stub grouping:                    HPPA ELF32.         (line   12)
9321* image base:                            Options.            (line 2560)
9322* implicit linker scripts:               Implicit Linker Scripts.
9323                                                             (line    6)
9324* import libraries:                      WIN32.              (line   10)
9325* INCLUDE FILENAME:                      File Commands.      (line    9)
9326* including a linker script:             File Commands.      (line    9)
9327* including an entire archive:           Options.            (line 2255)
9328* incremental link:                      Options.            (line  377)
9329* INHIBIT_COMMON_ALLOCATION:             Miscellaneous Commands.
9330                                                             (line   51)
9331* initialization function:               Options.            (line  380)
9332* initialized data in ROM:               Output Section LMA. (line   39)
9333* input file format in linker script:    Format Commands.    (line   35)
9334* input filename symbols:                Output Section Keywords.
9335                                                             (line    9)
9336* input files in linker scripts:         File Commands.      (line   19)
9337* input files, displaying:               Options.            (line  725)
9338* input format:                          Options.            (line  121)
9339* input format <1>:                      Options.            (line  121)
9340* Input import library:                  ARM.                (line  236)
9341* input object files in linker scripts:  File Commands.      (line   19)
9342* input section alignment:               Forced Input Alignment.
9343                                                             (line    6)
9344* input section basics:                  Input Section Basics.
9345                                                             (line    6)
9346* input section wildcards:               Input Section Wildcards.
9347                                                             (line    6)
9348* input sections:                        Input Section.      (line    6)
9349* INPUT(FILES):                          File Commands.      (line   19)
9350* INSERT:                                Miscellaneous Commands.
9351                                                             (line   62)
9352* insert user script into default script: Miscellaneous Commands.
9353                                                             (line   62)
9354* integer notation:                      Constants.          (line    6)
9355* integer suffixes:                      Constants.          (line   15)
9356* internal object-file format:           Canonical format.   (line   11)
9357* invalid input:                         Bug Criteria.       (line   14)
9358* K and M integer suffixes:              Constants.          (line   15)
9359* KEEP:                                  Input Section Keep. (line    6)
9360* l =:                                   MEMORY.             (line   72)
9361* lazy evaluation:                       Evaluation.         (line    6)
9362* ld bugs, reporting:                    Bug Reporting.      (line    6)
9363* ldata segment origin, cmd line:        Options.            (line 2022)
9364* LDEMULATION:                           Environment.        (line   21)
9365* LD_FEATURE(STRING):                    Miscellaneous Commands.
9366                                                             (line  133)
9367* len =:                                 MEMORY.             (line   72)
9368* LENGTH =:                              MEMORY.             (line   72)
9369* LENGTH(MEMORY):                        Builtin Functions.  (line  144)
9370* library search path in linker script:  File Commands.      (line   80)
9371* link map:                              Options.            (line  506)
9372* link map discarded:                    Options.            (line  569)
9373* link-time runtime library search path: Options.            (line 1842)
9374* linker crash:                          Bug Criteria.       (line    9)
9375* linker plugins:                        Plugins.            (line    6)
9376* linker script concepts:                Basic Script Concepts.
9377                                                             (line    6)
9378* linker script example:                 Simple Example.     (line    6)
9379* linker script file commands:           File Commands.      (line    6)
9380* linker script format:                  Script Format.      (line    6)
9381* linker script input object files:      File Commands.      (line   19)
9382* linker script simple commands:         Simple Commands.    (line    6)
9383* linker scripts:                        Scripts.            (line    6)
9384* LINKER_VERSION:                        Output Section Data.
9385                                                             (line   96)
9386* LINKER_VERSION <1>:                    Output Section Data.
9387                                                             (line   96)
9388* LIST (MRI):                            MRI.                (line   69)
9389* little-endian objects:                 Options.            (line  304)
9390* LOAD (MRI):                            MRI.                (line   76)
9391* load address:                          Output Section LMA. (line    6)
9392* LOADADDR(SECTION):                     Builtin Functions.  (line  147)
9393* loading, preventing:                   Output Section Type.
9394                                                             (line   49)
9395* local symbols, deleting:               Options.            (line  840)
9396* location counter:                      Location Counter.   (line    6)
9397* LOG2CEIL(EXP):                         Builtin Functions.  (line  151)
9398* LONG(EXPRESSION):                      Output Section Data.
9399                                                             (line    6)
9400* M and K integer suffixes:              Constants.          (line   15)
9401* M68HC11 and 68HC12 support:            M68HC11/68HC12.     (line    5)
9402* machine architecture:                  Miscellaneous Commands.
9403                                                             (line  127)
9404* machine dependencies:                  Machine Dependent.  (line    6)
9405* mapping input sections to output sections: Input Section.  (line    6)
9406* MAX:                                   Builtin Functions.  (line  154)
9407* MAXPAGESIZE:                           Symbolic Constants. (line   10)
9408* MEMORY:                                MEMORY.             (line    6)
9409* memory region attributes:              MEMORY.             (line   34)
9410* memory regions:                        MEMORY.             (line    6)
9411* memory regions and sections:           Output Section Region.
9412                                                             (line    6)
9413* memory usage:                          Options.            (line 1580)
9414* memory usage <1>:                      Options.            (line 1629)
9415* Merging exidx entries:                 ARM.                (line  216)
9416* MIN:                                   Builtin Functions.  (line  157)
9417* MIPS branch relocation check control:  MIPS.               (line   13)
9418* MIPS microMIPS instruction choice selection: MIPS.         (line    6)
9419* Motorola 68K GOT generation:           M68K.               (line    6)
9420* MRI compatibility:                     MRI.                (line    6)
9421* MSP430 extra sections:                 MSP430.             (line   11)
9422* MSP430 Options:                        MSP430.             (line   34)
9423* NAME (MRI):                            MRI.                (line   82)
9424* name, section:                         Output Section Name.
9425                                                             (line    6)
9426* names:                                 Symbols.            (line    6)
9427* naming the output file:                Options.            (line  603)
9428* NEXT(EXP):                             Builtin Functions.  (line  161)
9429* Nios II call relaxation:               Nios II.            (line    6)
9430* NMAGIC:                                Options.            (line  582)
9431* NOCROSSREFS(SECTIONS):                 Miscellaneous Commands.
9432                                                             (line   94)
9433* NOCROSSREFS_TO(TOSECTION FROMSECTIONS): Miscellaneous Commands.
9434                                                             (line  110)
9435* NOLOAD:                                Output Section Type.
9436                                                             (line   49)
9437* not enough room for program headers:   Builtin Functions.  (line  202)
9438* NO_ENUM_SIZE_WARNING:                  ARM.                (line  155)
9439* NO_WCHAR_SIZE_WARNING:                 ARM.                (line  162)
9440* o =:                                   MEMORY.             (line   67)
9441* objdump -i:                            BFD.                (line    6)
9442* object file management:                BFD.                (line    6)
9443* object files:                          Options.            (line   29)
9444* object formats available:              BFD.                (line    6)
9445* object size:                           Options.            (line  361)
9446* OMAGIC:                                Options.            (line  588)
9447* OMAGIC <1>:                            Options.            (line  597)
9448* ONLY_IF_RO:                            Output Section Constraint.
9449                                                             (line    6)
9450* ONLY_IF_RW:                            Output Section Constraint.
9451                                                             (line    6)
9452* opening object files:                  BFD outline.        (line    6)
9453* operators for arithmetic:              Operators.          (line    6)
9454* options:                               Options.            (line    6)
9455* ORDER (MRI):                           MRI.                (line   87)
9456* org =:                                 MEMORY.             (line   67)
9457* ORIGIN =:                              MEMORY.             (line   67)
9458* ORIGIN(MEMORY):                        Builtin Functions.  (line  167)
9459* orphan:                                Orphan Sections.    (line    6)
9460* orphan sections:                       Options.            (line  792)
9461* output file after errors:              Options.            (line 1723)
9462* output file format in linker script:   Format Commands.    (line   10)
9463* output file name in linker script:     File Commands.      (line   70)
9464* output format:                         Options.            (line 1574)
9465* output section alignment:              Forced Output Alignment.
9466                                                             (line    6)
9467* output section attributes:             Output Section Attributes.
9468                                                             (line    6)
9469* output section data:                   Output Section Data.
9470                                                             (line    6)
9471* OUTPUT(FILENAME):                      File Commands.      (line   70)
9472* OUTPUT_ARCH(BFDARCH):                  Miscellaneous Commands.
9473                                                             (line  127)
9474* OUTPUT_FORMAT(BFDNAME):                Format Commands.    (line   10)
9475* OVERLAY:                               Overlay Description.
9476                                                             (line    6)
9477* overlays:                              Overlay Description.
9478                                                             (line    6)
9479* partial link:                          Options.            (line  682)
9480* PE import table prefixing:             ARM.                (line   23)
9481* PHDRS:                                 PHDRS.              (line    6)
9482* PHDRS <1>:                             PHDRS.              (line   62)
9483* PIC_VENEER:                            ARM.                (line  168)
9484* Placement of SG veneers:               ARM.                (line  226)
9485* plugins:                               Plugins.            (line    6)
9486* pop state governing input file handling: Options.          (line  665)
9487* position dependent executables:        Options.            (line 1767)
9488* position independent executables:      Options.            (line 1758)
9489* PowerPC ELF32 options:                 PowerPC ELF32.      (line   16)
9490* PowerPC GOT:                           PowerPC ELF32.      (line   33)
9491* PowerPC long branches:                 PowerPC ELF32.      (line    6)
9492* PowerPC PLT:                           PowerPC ELF32.      (line   16)
9493* PowerPC stub symbols:                  PowerPC ELF32.      (line   47)
9494* PowerPC TLS optimization:              PowerPC ELF32.      (line   51)
9495* PowerPC64 dot symbols:                 PowerPC64 ELF64.    (line   33)
9496* PowerPC64 ELF64 options:               PowerPC64 ELF64.    (line    6)
9497* PowerPC64 ELFv2 PLT localentry optimization: PowerPC64 ELF64.
9498                                                             (line  160)
9499* PowerPC64 inline PLT call optimization: PowerPC64 ELF64.   (line  101)
9500* PowerPC64 multi-TOC:                   PowerPC64 ELF64.    (line  109)
9501* PowerPC64 OPD optimization:            PowerPC64 ELF64.    (line   75)
9502* PowerPC64 OPD spacing:                 PowerPC64 ELF64.    (line   81)
9503* PowerPC64 PLT call stub static chain:  PowerPC64 ELF64.    (line  142)
9504* PowerPC64 PLT call stub thread safety: PowerPC64 ELF64.    (line  148)
9505* PowerPC64 PLT stub alignment:          PowerPC64 ELF64.    (line  131)
9506* PowerPC64 Power10 stubs:               PowerPC64 ELF64.    (line  176)
9507* PowerPC64 register save/restore functions: PowerPC64 ELF64.
9508                                                             (line   44)
9509* PowerPC64 stub grouping:               PowerPC64 ELF64.    (line    6)
9510* PowerPC64 stub symbols:                PowerPC64 ELF64.    (line   29)
9511* PowerPC64 TLS optimization:            PowerPC64 ELF64.    (line   51)
9512* PowerPC64 TOC optimization:            PowerPC64 ELF64.    (line   87)
9513* PowerPC64 TOC sorting:                 PowerPC64 ELF64.    (line  121)
9514* PowerPC64 __tls_get_addr optimization: PowerPC64 ELF64.    (line   56)
9515* precedence in expressions:             Operators.          (line    6)
9516* prevent unnecessary loading:           Output Section Type.
9517                                                             (line   49)
9518* program headers:                       PHDRS.              (line    6)
9519* program headers and sections:          Output Section Phdr.
9520                                                             (line    6)
9521* program headers, not enough room:      Builtin Functions.  (line  202)
9522* program segments:                      PHDRS.              (line    6)
9523* PROVIDE:                               PROVIDE.            (line    6)
9524* PROVIDE_HIDDEN:                        PROVIDE_HIDDEN.     (line    6)
9525* PUBLIC (MRI):                          MRI.                (line   95)
9526* push state governing input file handling: Options.         (line  647)
9527* QUAD(EXPRESSION):                      Output Section Data.
9528                                                             (line    6)
9529* quoted symbol names:                   Symbols.            (line    6)
9530* read-only text:                        Options.            (line  582)
9531* read/write from cmd line:              Options.            (line  588)
9532* region alias:                          REGION_ALIAS.       (line    6)
9533* region names:                          REGION_ALIAS.       (line    6)
9534* regions of memory:                     MEMORY.             (line    6)
9535* REGION_ALIAS(ALIAS, REGION):           REGION_ALIAS.       (line    6)
9536* relative expressions:                  Expression Section. (line    6)
9537* relaxing addressing modes:             Options.            (line 1775)
9538* relaxing on H8/300:                    H8/300.             (line    9)
9539* relaxing on M68HC11:                   M68HC11/68HC12.     (line   12)
9540* relaxing on NDS32:                     NDS32.              (line    6)
9541* relaxing on Xtensa:                    Xtensa.             (line   27)
9542* relocatable and absolute symbols:      Expression Section. (line    6)
9543* relocatable output:                    Options.            (line  682)
9544* remapping inputs:                      Options.            (line  454)
9545* removing sections:                     Output Section Discarding.
9546                                                             (line    6)
9547* reporting bugs in ld:                  Reporting Bugs.     (line    6)
9548* requirements for BFD:                  BFD.                (line   16)
9549* retain relocations in final executable: Options.           (line  669)
9550* retaining specified symbols:           Options.            (line 1801)
9551* REVERSE:                               Input Section Wildcards.
9552                                                             (line   60)
9553* rodata segment origin, cmd line:       Options.            (line 2016)
9554* ROM initialized data:                  Output Section LMA. (line   39)
9555* round up expression:                   Builtin Functions.  (line   38)
9556* round up location counter:             Builtin Functions.  (line   38)
9557* runtime library name:                  Options.            (line  368)
9558* runtime library search path:           Options.            (line 1815)
9559* runtime pseudo-relocation:             WIN32.              (line  240)
9560* S/390:                                 S/390 ELF.          (line    6)
9561* S/390 ELF options:                     S/390 ELF.          (line    6)
9562* scaled integers:                       Constants.          (line   15)
9563* scommon section:                       Input Section Common.
9564                                                             (line   20)
9565* script files:                          Options.            (line  733)
9566* script files <1>:                      Options.            (line  743)
9567* scripts:                               Scripts.            (line    6)
9568* search directory, from cmd line:       Options.            (line  419)
9569* search path in linker script:          File Commands.      (line   80)
9570* SEARCH_DIR(PATH):                      File Commands.      (line   80)
9571* SECT (MRI):                            MRI.                (line  101)
9572* section address:                       Output Section Address.
9573                                                             (line    6)
9574* section address in expression:         Builtin Functions.  (line   17)
9575* section alignment:                     Builtin Functions.  (line   63)
9576* section alignment, warnings on:        Options.            (line 2232)
9577* section data:                          Output Section Data.
9578                                                             (line    6)
9579* section fill pattern:                  Output Section Fill.
9580                                                             (line    6)
9581* section groups:                        Options.            (line 1441)
9582* section groups <1>:                    Miscellaneous Commands.
9583                                                             (line   56)
9584* section load address:                  Output Section LMA. (line    6)
9585* section load address in expression:    Builtin Functions.  (line  147)
9586* section name:                          Output Section Name.
9587                                                             (line    6)
9588* section name wildcard patterns:        Input Section Wildcards.
9589                                                             (line    6)
9590* section size:                          Builtin Functions.  (line  178)
9591* section, assigning to memory region:   Output Section Region.
9592                                                             (line    6)
9593* section, assigning to program header:  Output Section Phdr.
9594                                                             (line    6)
9595* SECTIONS:                              SECTIONS.           (line    6)
9596* sections, discarding:                  Output Section Discarding.
9597                                                             (line    6)
9598* sections, orphan:                      Options.            (line  792)
9599* Secure gateway import library:         ARM.                (line  231)
9600* segment origins, cmd line:             Options.            (line 2005)
9601* segments, ELF:                         PHDRS.              (line    6)
9602* SEGMENT_START(SEGMENT, DEFAULT):       Builtin Functions.  (line  170)
9603* shared libraries:                      Options.            (line 1923)
9604* SHORT(EXPRESSION):                     Output Section Data.
9605                                                             (line    6)
9606* SIZEOF(SECTION):                       Builtin Functions.  (line  178)
9607* SIZEOF_HEADERS:                        Builtin Functions.  (line  197)
9608* small common symbols:                  Input Section Common.
9609                                                             (line   20)
9610* SORT:                                  Input Section Wildcards.
9611                                                             (line   58)
9612* SORT_BY_ALIGNMENT:                     Input Section Wildcards.
9613                                                             (line   45)
9614* SORT_BY_INIT_PRIORITY:                 Input Section Wildcards.
9615                                                             (line   51)
9616* SORT_BY_NAME:                          Input Section Wildcards.
9617                                                             (line   37)
9618* SORT_NONE:                             Input Section Wildcards.
9619                                                             (line  119)
9620* SPU:                                   SPU ELF.            (line   29)
9621* SPU <1>:                               SPU ELF.            (line   46)
9622* SPU ELF options:                       SPU ELF.            (line    6)
9623* SPU extra overlay stubs:               SPU ELF.            (line   19)
9624* SPU local store size:                  SPU ELF.            (line   24)
9625* SPU overlay stub symbols:              SPU ELF.            (line   15)
9626* SPU overlays:                          SPU ELF.            (line    9)
9627* SPU plugins:                           SPU ELF.            (line    6)
9628* SQUAD(EXPRESSION):                     Output Section Data.
9629                                                             (line    6)
9630* stack size:                            Options.            (line 2803)
9631* standard Unix system:                  Options.            (line    7)
9632* start of execution:                    Entry Point.        (line    6)
9633* start-stop-gc:                         Options.            (line 1159)
9634* STARTUP(FILENAME):                     File Commands.      (line   88)
9635* static library dependencies:           libdep Plugin.      (line    6)
9636* STM32L4xx erratum workaround:          ARM.                (line  117)
9637* strip all symbols:                     Options.            (line  711)
9638* strip debugger symbols:                Options.            (line  715)
9639* stripping all but some symbols:        Options.            (line 1801)
9640* STUB_GROUP_SIZE:                       ARM.                (line  173)
9641* SUBALIGN(SUBSECTION_ALIGN):            Forced Input Alignment.
9642                                                             (line    6)
9643* suffixes for integers:                 Constants.          (line   15)
9644* symbol defaults:                       Builtin Functions.  (line  127)
9645* symbol definition, scripts:            Assignments.        (line    6)
9646* symbol names:                          Symbols.            (line    6)
9647* symbol tracing:                        Options.            (line  846)
9648* symbol versions:                       VERSION.            (line    6)
9649* symbol-only input:                     Options.            (line  700)
9650* symbolic constants:                    Symbolic Constants. (line    6)
9651* symbols, from command line:            Options.            (line 1449)
9652* symbols, relocatable and absolute:     Expression Section. (line    6)
9653* symbols, require defined:              Options.            (line  769)
9654* symbols, retaining selectively:        Options.            (line 1801)
9655* synthesizing linker:                   Options.            (line 1775)
9656* synthesizing on H8/300:                H8/300.             (line   14)
9657* TARGET(BFDNAME):                       Format Commands.    (line   35)
9658* TARGET1:                               ARM.                (line   33)
9659* TARGET2:                               ARM.                (line   38)
9660* text segment origin, cmd line:         Options.            (line 2012)
9661* thumb entry point:                     ARM.                (line   17)
9662* TI COFF versions:                      TI COFF.            (line    6)
9663* traditional format:                    Options.            (line 1984)
9664* trampoline generation on M68HC11:      M68HC11/68HC12.     (line   30)
9665* trampoline generation on M68HC12:      M68HC11/68HC12.     (line   30)
9666* unallocated address, next:             Builtin Functions.  (line  161)
9667* undefined symbol:                      Options.            (line  756)
9668* undefined symbol in linker script:     Miscellaneous Commands.
9669                                                             (line   39)
9670* undefined symbols, warnings on:        Options.            (line 2202)
9671* uninitialized data placement:          Input Section Common.
9672                                                             (line    6)
9673* unspecified memory:                    Output Section Data.
9674                                                             (line   49)
9675* usage:                                 Options.            (line 1592)
9676* USE_BLX:                               ARM.                (line   73)
9677* using a DEF file:                      WIN32.              (line   81)
9678* using auto-export functionality:       WIN32.              (line   51)
9679* Using decorations:                     WIN32.              (line  186)
9680* variables, defining:                   Assignments.        (line    6)
9681* verbose[=NUMBER]:                      Options.            (line 2055)
9682* version:                               Options.            (line  827)
9683* version script:                        VERSION.            (line    6)
9684* version script, symbol versions:       Options.            (line 2063)
9685* VERSION {script text}:                 VERSION.            (line    6)
9686* versions of symbols:                   VERSION.            (line    6)
9687* VFP11_DENORM_FIX:                      ARM.                (line   79)
9688* visibility:                            Options.            (line 1174)
9689* warnings, on combining symbols:        Options.            (line 2073)
9690* warnings, on executable stack:         Options.            (line 2146)
9691* warnings, on section alignment:        Options.            (line 2232)
9692* warnings, on undefined symbols:        Options.            (line 2202)
9693* warnings, on writeable and exectuable segments: Options.   (line 2206)
9694* weak externals:                        WIN32.              (line  430)
9695* what is this?:                         Overview.           (line    6)
9696* wildcard file name patterns:           Input Section Wildcards.
9697                                                             (line    6)
9698* Xtensa options:                        Xtensa.             (line   55)
9699* Xtensa processors:                     Xtensa.             (line    6)
9700
9701
9702
9703Tag Table:
9704Node: Top708
9705Node: Overview1589
9706Node: Invocation2736
9707Node: Options3148
9708Node: Environment148320
9709Node: Scripts150169
9710Node: Basic Script Concepts151913
9711Node: Script Format154693
9712Node: Simple Example155564
9713Node: Simple Commands158800
9714Node: Entry Point159305
9715Node: File Commands160379
9716Node: Format Commands164906
9717Node: REGION_ALIAS166954
9718Node: Miscellaneous Commands171949
9719Node: Assignments178260
9720Node: Simple Assignments178771
9721Node: HIDDEN180574
9722Node: PROVIDE181211
9723Node: PROVIDE_HIDDEN182789
9724Node: Source Code Reference183039
9725Node: SECTIONS187002
9726Node: Output Section Description188922
9727Node: Output Section Name190171
9728Node: Output Section Address191072
9729Node: Input Section193325
9730Node: Input Section Basics194126
9731Node: Input Section Wildcards199280
9732Node: Input Section Common205523
9733Node: Input Section Keep207033
9734Node: Input Section Example207541
9735Node: Output Section Data209012
9736Node: Output Section Keywords214353
9737Node: Output Section Discarding218028
9738Node: Output Section Attributes219970
9739Node: Output Section Type221091
9740Node: Output Section LMA223476
9741Node: Forced Output Alignment226619
9742Node: Forced Input Alignment227050
9743Node: Output Section Constraint227438
9744Node: Output Section Region227874
9745Node: Output Section Phdr228311
9746Node: Output Section Fill228987
9747Node: Overlay Description230374
9748Node: MEMORY234919
9749Node: PHDRS239671
9750Node: VERSION245149
9751Node: Expressions253440
9752Node: Constants254453
9753Node: Symbolic Constants255395
9754Node: Symbols255962
9755Node: Orphan Sections256717
9756Node: Location Counter258310
9757Node: Operators262888
9758Node: Evaluation263918
9759Node: Expression Section265290
9760Node: Builtin Functions269368
9761Node: Implicit Linker Scripts278449
9762Node: Plugins279236
9763Node: libdep Plugin279796
9764Node: Special Sections281641
9765Node: Machine Dependent283799
9766Node: H8/300284972
9767Node: M68HC11/68HC12287173
9768Node: ARM288680
9769Node: HPPA ELF32301108
9770Node: M68K302783
9771Node: MIPS303732
9772Node: MMIX304892
9773Node: MSP430306113
9774Node: NDS32308106
9775Node: Nios II309154
9776Node: PowerPC ELF32310526
9777Node: PowerPC64 ELF64313471
9778Node: S/390 ELF323589
9779Node: SPU ELF323948
9780Node: TI COFF326674
9781Node: WIN32327214
9782Node: Xtensa348969
9783Node: BFD352524
9784Node: BFD outline353986
9785Node: BFD information loss355280
9786Node: Canonical format357834
9787Node: Reporting Bugs362179
9788Node: Bug Criteria362885
9789Node: Bug Reporting363608
9790Node: MRI370781
9791Node: GNU Free Documentation License375460
9792Node: LD Index400800
9793
9794End Tag Table
9795
9796
9797Local Variables:
9798coding: utf-8
9799End:
9800