OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [share/] [info/] [ld.info] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
This is ld.info, produced by makeinfo version 4.13 from ld.texinfo.
2
 
3
INFO-DIR-SECTION Software development
4
START-INFO-DIR-ENTRY
5
* Ld: (ld).                       The GNU linker.
6
END-INFO-DIR-ENTRY
7
 
8
   This file documents the GNU linker LD (GNU Binutils) version 2.23.51.
9
 
10
   Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
11
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Free
12
Software Foundation, Inc.
13
 
14
   Permission is granted to copy, distribute and/or modify this document
15
under the terms of the GNU Free Documentation License, Version 1.3 or
16
any later version published by the Free Software Foundation; with no
17
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
18
Texts.  A copy of the license is included in the section entitled "GNU
19
Free Documentation License".
20
 
21

22
File: ld.info,  Node: Top,  Next: Overview,  Up: (dir)
23
 
24
LD
25
**
26
 
27
This file documents the GNU linker ld (GNU Binutils) version 2.23.51.
28
 
29
   This document is distributed under the terms of the GNU Free
30
Documentation License version 1.3.  A copy of the license is included
31
in the section entitled "GNU Free Documentation License".
32
 
33
* Menu:
34
 
35
* Overview::                    Overview
36
* Invocation::                  Invocation
37
* Scripts::                     Linker Scripts
38
 
39
* Machine Dependent::           Machine Dependent Features
40
 
41
* BFD::                         BFD
42
 
43
* Reporting Bugs::              Reporting Bugs
44
* MRI::                         MRI Compatible Script Files
45
* GNU Free Documentation License::  GNU Free Documentation License
46
* LD Index::                       LD Index
47
 
48

49
File: ld.info,  Node: Overview,  Next: Invocation,  Prev: Top,  Up: Top
50
 
51
1 Overview
52
**********
53
 
54
`ld' combines a number of object and archive files, relocates their
55
data and ties up symbol references. Usually the last step in compiling
56
a program is to run `ld'.
57
 
58
   `ld' accepts Linker Command Language files written in a superset of
59
AT&T's Link Editor Command Language syntax, to provide explicit and
60
total control over the linking process.
61
 
62
   This version of `ld' uses the general purpose BFD libraries to
63
operate on object files. This allows `ld' to read, combine, and write
64
object files in many different formats--for example, COFF or `a.out'.
65
Different formats may be linked together to produce any available kind
66
of object file.  *Note BFD::, for more information.
67
 
68
   Aside from its flexibility, the GNU linker is more helpful than other
69
linkers in providing diagnostic information.  Many linkers abandon
70
execution immediately upon encountering an error; whenever possible,
71
`ld' continues executing, allowing you to identify other errors (or, in
72
some cases, to get an output file in spite of the error).
73
 
74

75
File: ld.info,  Node: Invocation,  Next: Scripts,  Prev: Overview,  Up: Top
76
 
77
2 Invocation
78
************
79
 
80
The GNU linker `ld' is meant to cover a broad range of situations, and
81
to be as compatible as possible with other linkers.  As a result, you
82
have many choices to control its behavior.
83
 
84
* Menu:
85
 
86
* Options::                     Command Line Options
87
* Environment::                 Environment Variables
88
 
89

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

2134
File: ld.info,  Node: Environment,  Prev: Options,  Up: Invocation
2135
 
2136
2.2 Environment Variables
2137
=========================
2138
 
2139
You can change the behaviour of `ld' with the environment variables
2140
`GNUTARGET', `LDEMULATION' and `COLLECT_NO_DEMANGLE'.
2141
 
2142
   `GNUTARGET' determines the input-file object format if you don't use
2143
`-b' (or its synonym `--format').  Its value should be one of the BFD
2144
names for an input format (*note BFD::).  If there is no `GNUTARGET' in
2145
the environment, `ld' uses the natural format of the target. If
2146
`GNUTARGET' is set to `default' then BFD attempts to discover the input
2147
format by examining binary input files; this method often succeeds, but
2148
there are potential ambiguities, since there is no method of ensuring
2149
that the magic number used to specify object-file formats is unique.
2150
However, the configuration procedure for BFD on each system places the
2151
conventional format for that system first in the search-list, so
2152
ambiguities are resolved in favor of convention.
2153
 
2154
   `LDEMULATION' determines the default emulation if you don't use the
2155
`-m' option.  The emulation can affect various aspects of linker
2156
behaviour, particularly the default linker script.  You can list the
2157
available emulations with the `--verbose' or `-V' options.  If the `-m'
2158
option is not used, and the `LDEMULATION' environment variable is not
2159
defined, the default emulation depends upon how the linker was
2160
configured.
2161
 
2162
   Normally, the linker will default to demangling symbols.  However, if
2163
`COLLECT_NO_DEMANGLE' is set in the environment, then it will default
2164
to not demangling symbols.  This environment variable is used in a
2165
similar fashion by the `gcc' linker wrapper program.  The default may
2166
be overridden by the `--demangle' and `--no-demangle' options.
2167
 
2168

2169
File: ld.info,  Node: Scripts,  Next: Machine Dependent,  Prev: Invocation,  Up: Top
2170
 
2171
3 Linker Scripts
2172
****************
2173
 
2174
Every link is controlled by a "linker script".  This script is written
2175
in the linker command language.
2176
 
2177
   The main purpose of the linker script is to describe how the
2178
sections in the input files should be mapped into the output file, and
2179
to control the memory layout of the output file.  Most linker scripts
2180
do nothing more than this.  However, when necessary, the linker script
2181
can also direct the linker to perform many other operations, using the
2182
commands described below.
2183
 
2184
   The linker always uses a linker script.  If you do not supply one
2185
yourself, the linker will use a default script that is compiled into the
2186
linker executable.  You can use the `--verbose' command line option to
2187
display the default linker script.  Certain command line options, such
2188
as `-r' or `-N', will affect the default linker script.
2189
 
2190
   You may supply your own linker script by using the `-T' command line
2191
option.  When you do this, your linker script will replace the default
2192
linker script.
2193
 
2194
   You may also use linker scripts implicitly by naming them as input
2195
files to the linker, as though they were files to be linked.  *Note
2196
Implicit Linker Scripts::.
2197
 
2198
* Menu:
2199
 
2200
* Basic Script Concepts::       Basic Linker Script Concepts
2201
* Script Format::               Linker Script Format
2202
* Simple Example::              Simple Linker Script Example
2203
* Simple Commands::             Simple Linker Script Commands
2204
* Assignments::                 Assigning Values to Symbols
2205
* SECTIONS::                    SECTIONS Command
2206
* MEMORY::                      MEMORY Command
2207
* PHDRS::                       PHDRS Command
2208
* VERSION::                     VERSION Command
2209
* Expressions::                 Expressions in Linker Scripts
2210
* Implicit Linker Scripts::     Implicit Linker Scripts
2211
 
2212

2213
File: ld.info,  Node: Basic Script Concepts,  Next: Script Format,  Up: Scripts
2214
 
2215
3.1 Basic Linker Script Concepts
2216
================================
2217
 
2218
We need to define some basic concepts and vocabulary in order to
2219
describe the linker script language.
2220
 
2221
   The linker combines input files into a single output file.  The
2222
output file and each input file are in a special data format known as an
2223
"object file format".  Each file is called an "object file".  The
2224
output file is often called an "executable", but for our purposes we
2225
will also call it an object file.  Each object file has, among other
2226
things, a list of "sections".  We sometimes refer to a section in an
2227
input file as an "input section"; similarly, a section in the output
2228
file is an "output section".
2229
 
2230
   Each section in an object file has a name and a size.  Most sections
2231
also have an associated block of data, known as the "section contents".
2232
A section may be marked as "loadable", which mean that the contents
2233
should be loaded into memory when the output file is run.  A section
2234
with no contents may be "allocatable", which means that an area in
2235
memory should be set aside, but nothing in particular should be loaded
2236
there (in some cases this memory must be zeroed out).  A section which
2237
is neither loadable nor allocatable typically contains some sort of
2238
debugging information.
2239
 
2240
   Every loadable or allocatable output section has two addresses.  The
2241
first is the "VMA", or virtual memory address.  This is the address the
2242
section will have when the output file is run.  The second is the
2243
"LMA", or load memory address.  This is the address at which the
2244
section will be loaded.  In most cases the two addresses will be the
2245
same.  An example of when they might be different is when a data section
2246
is loaded into ROM, and then copied into RAM when the program starts up
2247
(this technique is often used to initialize global variables in a ROM
2248
based system).  In this case the ROM address would be the LMA, and the
2249
RAM address would be the VMA.
2250
 
2251
   You can see the sections in an object file by using the `objdump'
2252
program with the `-h' option.
2253
 
2254
   Every object file also has a list of "symbols", known as the "symbol
2255
table".  A symbol may be defined or undefined.  Each symbol has a name,
2256
and each defined symbol has an address, among other information.  If
2257
you compile a C or C++ program into an object file, you will get a
2258
defined symbol for every defined function and global or static
2259
variable.  Every undefined function or global variable which is
2260
referenced in the input file will become an undefined symbol.
2261
 
2262
   You can see the symbols in an object file by using the `nm' program,
2263
or by using the `objdump' program with the `-t' option.
2264
 
2265

2266
File: ld.info,  Node: Script Format,  Next: Simple Example,  Prev: Basic Script Concepts,  Up: Scripts
2267
 
2268
3.2 Linker Script Format
2269
========================
2270
 
2271
Linker scripts are text files.
2272
 
2273
   You write a linker script as a series of commands.  Each command is
2274
either a keyword, possibly followed by arguments, or an assignment to a
2275
symbol.  You may separate commands using semicolons.  Whitespace is
2276
generally ignored.
2277
 
2278
   Strings such as file or format names can normally be entered
2279
directly.  If the file name contains a character such as a comma which
2280
would otherwise serve to separate file names, you may put the file name
2281
in double quotes.  There is no way to use a double quote character in a
2282
file name.
2283
 
2284
   You may include comments in linker scripts just as in C, delimited by
2285
`/*' and `*/'.  As in C, comments are syntactically equivalent to
2286
whitespace.
2287
 
2288

2289
File: ld.info,  Node: Simple Example,  Next: Simple Commands,  Prev: Script Format,  Up: Scripts
2290
 
2291
3.3 Simple Linker Script Example
2292
================================
2293
 
2294
Many linker scripts are fairly simple.
2295
 
2296
   The simplest possible linker script has just one command:
2297
`SECTIONS'.  You use the `SECTIONS' command to describe the memory
2298
layout of the output file.
2299
 
2300
   The `SECTIONS' command is a powerful command.  Here we will describe
2301
a simple use of it.  Let's assume your program consists only of code,
2302
initialized data, and uninitialized data.  These will be in the
2303
`.text', `.data', and `.bss' sections, respectively.  Let's assume
2304
further that these are the only sections which appear in your input
2305
files.
2306
 
2307
   For this example, let's say that the code should be loaded at address
2308
0x10000, and that the data should start at address 0x8000000.  Here is a
2309
linker script which will do that:
2310
     SECTIONS
2311
     {
2312
       . = 0x10000;
2313
       .text : { *(.text) }
2314
       . = 0x8000000;
2315
       .data : { *(.data) }
2316
       .bss : { *(.bss) }
2317
     }
2318
 
2319
   You write the `SECTIONS' command as the keyword `SECTIONS', followed
2320
by a series of symbol assignments and output section descriptions
2321
enclosed in curly braces.
2322
 
2323
   The first line inside the `SECTIONS' command of the above example
2324
sets the value of the special symbol `.', which is the location
2325
counter.  If you do not specify the address of an output section in some
2326
other way (other ways are described later), the address is set from the
2327
current value of the location counter.  The location counter is then
2328
incremented by the size of the output section.  At the start of the
2329
`SECTIONS' command, the location counter has the value `0'.
2330
 
2331
   The second line defines an output section, `.text'.  The colon is
2332
required syntax which may be ignored for now.  Within the curly braces
2333
after the output section name, you list the names of the input sections
2334
which should be placed into this output section.  The `*' is a wildcard
2335
which matches any file name.  The expression `*(.text)' means all
2336
`.text' input sections in all input files.
2337
 
2338
   Since the location counter is `0x10000' when the output section
2339
`.text' is defined, the linker will set the address of the `.text'
2340
section in the output file to be `0x10000'.
2341
 
2342
   The remaining lines define the `.data' and `.bss' sections in the
2343
output file.  The linker will place the `.data' output section at
2344
address `0x8000000'.  After the linker places the `.data' output
2345
section, the value of the location counter will be `0x8000000' plus the
2346
size of the `.data' output section.  The effect is that the linker will
2347
place the `.bss' output section immediately after the `.data' output
2348
section in memory.
2349
 
2350
   The linker will ensure that each output section has the required
2351
alignment, by increasing the location counter if necessary.  In this
2352
example, the specified addresses for the `.text' and `.data' sections
2353
will probably satisfy any alignment constraints, but the linker may
2354
have to create a small gap between the `.data' and `.bss' sections.
2355
 
2356
   That's it!  That's a simple and complete linker script.
2357
 
2358

2359
File: ld.info,  Node: Simple Commands,  Next: Assignments,  Prev: Simple Example,  Up: Scripts
2360
 
2361
3.4 Simple Linker Script Commands
2362
=================================
2363
 
2364
In this section we describe the simple linker script commands.
2365
 
2366
* Menu:
2367
 
2368
* Entry Point::                 Setting the entry point
2369
* File Commands::               Commands dealing with files
2370
 
2371
* Format Commands::             Commands dealing with object file formats
2372
 
2373
* REGION_ALIAS::                Assign alias names to memory regions
2374
* Miscellaneous Commands::      Other linker script commands
2375
 
2376

2377
File: ld.info,  Node: Entry Point,  Next: File Commands,  Up: Simple Commands
2378
 
2379
3.4.1 Setting the Entry Point
2380
-----------------------------
2381
 
2382
The first instruction to execute in a program is called the "entry
2383
point".  You can use the `ENTRY' linker script command to set the entry
2384
point.  The argument is a symbol name:
2385
     ENTRY(SYMBOL)
2386
 
2387
   There are several ways to set the entry point.  The linker will set
2388
the entry point by trying each of the following methods in order, and
2389
stopping when one of them succeeds:
2390
   * the `-e' ENTRY command-line option;
2391
 
2392
   * the `ENTRY(SYMBOL)' command in a linker script;
2393
 
2394
   * the value of a target specific symbol, if it is defined;  For many
2395
     targets this is `start', but PE and BeOS based systems for example
2396
     check a list of possible entry symbols, matching the first one
2397
     found.
2398
 
2399
   * the address of the first byte of the `.text' section, if present;
2400
 
2401
   * The address `0'.
2402
 
2403

2404
File: ld.info,  Node: File Commands,  Next: Format Commands,  Prev: Entry Point,  Up: Simple Commands
2405
 
2406
3.4.2 Commands Dealing with Files
2407
---------------------------------
2408
 
2409
Several linker script commands deal with files.
2410
 
2411
`INCLUDE FILENAME'
2412
     Include the linker script FILENAME at this point.  The file will
2413
     be searched for in the current directory, and in any directory
2414
     specified with the `-L' option.  You can nest calls to `INCLUDE'
2415
     up to 10 levels deep.
2416
 
2417
     You can place `INCLUDE' directives at the top level, in `MEMORY' or
2418
     `SECTIONS' commands, or in output section descriptions.
2419
 
2420
`INPUT(FILE, FILE, ...)'
2421
`INPUT(FILE FILE ...)'
2422
     The `INPUT' command directs the linker to include the named files
2423
     in the link, as though they were named on the command line.
2424
 
2425
     For example, if you always want to include `subr.o' any time you do
2426
     a link, but you can't be bothered to put it on every link command
2427
     line, then you can put `INPUT (subr.o)' in your linker script.
2428
 
2429
     In fact, if you like, you can list all of your input files in the
2430
     linker script, and then invoke the linker with nothing but a `-T'
2431
     option.
2432
 
2433
     In case a "sysroot prefix" is configured, and the filename starts
2434
     with the `/' character, and the script being processed was located
2435
     inside the "sysroot prefix", the filename will be looked for in
2436
     the "sysroot prefix".  Otherwise, the linker will try to open the
2437
     file in the current directory.  If it is not found, the linker
2438
     will search through the archive library search path.  See the
2439
     description of `-L' in *note Command Line Options: Options.
2440
 
2441
     If you use `INPUT (-lFILE)', `ld' will transform the name to
2442
     `libFILE.a', as with the command line argument `-l'.
2443
 
2444
     When you use the `INPUT' command in an implicit linker script, the
2445
     files will be included in the link at the point at which the linker
2446
     script file is included.  This can affect archive searching.
2447
 
2448
`GROUP(FILE, FILE, ...)'
2449
`GROUP(FILE FILE ...)'
2450
     The `GROUP' command is like `INPUT', except that the named files
2451
     should all be archives, and they are searched repeatedly until no
2452
     new undefined references are created.  See the description of `-('
2453
     in *note Command Line Options: Options.
2454
 
2455
`AS_NEEDED(FILE, FILE, ...)'
2456
`AS_NEEDED(FILE FILE ...)'
2457
     This construct can appear only inside of the `INPUT' or `GROUP'
2458
     commands, among other filenames.  The files listed will be handled
2459
     as if they appear directly in the `INPUT' or `GROUP' commands,
2460
     with the exception of ELF shared libraries, that will be added only
2461
     when they are actually needed.  This construct essentially enables
2462
     `--as-needed' option for all the files listed inside of it and
2463
     restores previous `--as-needed' resp. `--no-as-needed' setting
2464
     afterwards.
2465
 
2466
`OUTPUT(FILENAME)'
2467
     The `OUTPUT' command names the output file.  Using
2468
     `OUTPUT(FILENAME)' in the linker script is exactly like using `-o
2469
     FILENAME' on the command line (*note Command Line Options:
2470
     Options.).  If both are used, the command line option takes
2471
     precedence.
2472
 
2473
     You can use the `OUTPUT' command to define a default name for the
2474
     output file other than the usual default of `a.out'.
2475
 
2476
`SEARCH_DIR(PATH)'
2477
     The `SEARCH_DIR' command adds PATH to the list of paths where `ld'
2478
     looks for archive libraries.  Using `SEARCH_DIR(PATH)' is exactly
2479
     like using `-L PATH' on the command line (*note Command Line
2480
     Options: Options.).  If both are used, then the linker will search
2481
     both paths.  Paths specified using the command line option are
2482
     searched first.
2483
 
2484
`STARTUP(FILENAME)'
2485
     The `STARTUP' command is just like the `INPUT' command, except
2486
     that FILENAME will become the first input file to be linked, as
2487
     though it were specified first on the command line.  This may be
2488
     useful when using a system in which the entry point is always the
2489
     start of the first file.
2490
 
2491

2492
File: ld.info,  Node: Format Commands,  Next: REGION_ALIAS,  Prev: File Commands,  Up: Simple Commands
2493
 
2494
3.4.3 Commands Dealing with Object File Formats
2495
-----------------------------------------------
2496
 
2497
A couple of linker script commands deal with object file formats.
2498
 
2499
`OUTPUT_FORMAT(BFDNAME)'
2500
`OUTPUT_FORMAT(DEFAULT, BIG, LITTLE)'
2501
     The `OUTPUT_FORMAT' command names the BFD format to use for the
2502
     output file (*note BFD::).  Using `OUTPUT_FORMAT(BFDNAME)' is
2503
     exactly like using `--oformat BFDNAME' on the command line (*note
2504
     Command Line Options: Options.).  If both are used, the command
2505
     line option takes precedence.
2506
 
2507
     You can use `OUTPUT_FORMAT' with three arguments to use different
2508
     formats based on the `-EB' and `-EL' command line options.  This
2509
     permits the linker script to set the output format based on the
2510
     desired endianness.
2511
 
2512
     If neither `-EB' nor `-EL' are used, then the output format will
2513
     be the first argument, DEFAULT.  If `-EB' is used, the output
2514
     format will be the second argument, BIG.  If `-EL' is used, the
2515
     output format will be the third argument, LITTLE.
2516
 
2517
     For example, the default linker script for the MIPS ELF target
2518
     uses this command:
2519
          OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)
2520
     This says that the default format for the output file is
2521
     `elf32-bigmips', but if the user uses the `-EL' command line
2522
     option, the output file will be created in the `elf32-littlemips'
2523
     format.
2524
 
2525
`TARGET(BFDNAME)'
2526
     The `TARGET' command names the BFD format to use when reading input
2527
     files.  It affects subsequent `INPUT' and `GROUP' commands.  This
2528
     command is like using `-b BFDNAME' on the command line (*note
2529
     Command Line Options: Options.).  If the `TARGET' command is used
2530
     but `OUTPUT_FORMAT' is not, then the last `TARGET' command is also
2531
     used to set the format for the output file.  *Note BFD::.
2532
 
2533

2534
File: ld.info,  Node: REGION_ALIAS,  Next: Miscellaneous Commands,  Prev: Format Commands,  Up: Simple Commands
2535
 
2536
3.4.4 Assign alias names to memory regions
2537
------------------------------------------
2538
 
2539
Alias names can be added to existing memory regions created with the
2540
*note MEMORY:: command.  Each name corresponds to at most one memory
2541
region.
2542
 
2543
     REGION_ALIAS(ALIAS, REGION)
2544
 
2545
   The `REGION_ALIAS' function creates an alias name ALIAS for the
2546
memory region REGION.  This allows a flexible mapping of output sections
2547
to memory regions.  An example follows.
2548
 
2549
   Suppose we have an application for embedded systems which come with
2550
various memory storage devices.  All have a general purpose, volatile
2551
memory `RAM' that allows code execution or data storage.  Some may have
2552
a read-only, non-volatile memory `ROM' that allows code execution and
2553
read-only data access.  The last variant is a read-only, non-volatile
2554
memory `ROM2' with read-only data access and no code execution
2555
capability.  We have four output sections:
2556
 
2557
   * `.text' program code;
2558
 
2559
   * `.rodata' read-only data;
2560
 
2561
   * `.data' read-write initialized data;
2562
 
2563
   * `.bss' read-write zero initialized data.
2564
 
2565
   The goal is to provide a linker command file that contains a system
2566
independent part defining the output sections and a system dependent
2567
part mapping the output sections to the memory regions available on the
2568
system.  Our embedded systems come with three different memory setups
2569
`A', `B' and `C':
2570
Section            Variant A          Variant B          Variant C
2571
.text              RAM                ROM                ROM
2572
.rodata            RAM                ROM                ROM2
2573
.data              RAM                RAM/ROM            RAM/ROM2
2574
.bss               RAM                RAM                RAM
2575
   The notation `RAM/ROM' or `RAM/ROM2' means that this section is
2576
loaded into region `ROM' or `ROM2' respectively.  Please note that the
2577
load address of the `.data' section starts in all three variants at the
2578
end of the `.rodata' section.
2579
 
2580
   The base linker script that deals with the output sections follows.
2581
It includes the system dependent `linkcmds.memory' file that describes
2582
the memory layout:
2583
     INCLUDE linkcmds.memory
2584
 
2585
     SECTIONS
2586
       {
2587
         .text :
2588
           {
2589
             *(.text)
2590
           } > REGION_TEXT
2591
         .rodata :
2592
           {
2593
             *(.rodata)
2594
             rodata_end = .;
2595
           } > REGION_RODATA
2596
         .data : AT (rodata_end)
2597
           {
2598
             data_start = .;
2599
             *(.data)
2600
           } > REGION_DATA
2601
         data_size = SIZEOF(.data);
2602
         data_load_start = LOADADDR(.data);
2603
         .bss :
2604
           {
2605
             *(.bss)
2606
           } > REGION_BSS
2607
       }
2608
 
2609
   Now we need three different `linkcmds.memory' files to define memory
2610
regions and alias names.  The content of `linkcmds.memory' for the three
2611
variants `A', `B' and `C':
2612
`A'
2613
     Here everything goes into the `RAM'.
2614
          MEMORY
2615
            {
2616
              RAM : ORIGIN = 0, LENGTH = 4M
2617
            }
2618
 
2619
          REGION_ALIAS("REGION_TEXT", RAM);
2620
          REGION_ALIAS("REGION_RODATA", RAM);
2621
          REGION_ALIAS("REGION_DATA", RAM);
2622
          REGION_ALIAS("REGION_BSS", RAM);
2623
 
2624
`B'
2625
     Program code and read-only data go into the `ROM'.  Read-write
2626
     data goes into the `RAM'.  An image of the initialized data is
2627
     loaded into the `ROM' and will be copied during system start into
2628
     the `RAM'.
2629
          MEMORY
2630
            {
2631
              ROM : ORIGIN = 0, LENGTH = 3M
2632
              RAM : ORIGIN = 0x10000000, LENGTH = 1M
2633
            }
2634
 
2635
          REGION_ALIAS("REGION_TEXT", ROM);
2636
          REGION_ALIAS("REGION_RODATA", ROM);
2637
          REGION_ALIAS("REGION_DATA", RAM);
2638
          REGION_ALIAS("REGION_BSS", RAM);
2639
 
2640
`C'
2641
     Program code goes into the `ROM'.  Read-only data goes into the
2642
     `ROM2'.  Read-write data goes into the `RAM'.  An image of the
2643
     initialized data is loaded into the `ROM2' and will be copied
2644
     during system start into the `RAM'.
2645
          MEMORY
2646
            {
2647
              ROM : ORIGIN = 0, LENGTH = 2M
2648
              ROM2 : ORIGIN = 0x10000000, LENGTH = 1M
2649
              RAM : ORIGIN = 0x20000000, LENGTH = 1M
2650
            }
2651
 
2652
          REGION_ALIAS("REGION_TEXT", ROM);
2653
          REGION_ALIAS("REGION_RODATA", ROM2);
2654
          REGION_ALIAS("REGION_DATA", RAM);
2655
          REGION_ALIAS("REGION_BSS", RAM);
2656
 
2657
   It is possible to write a common system initialization routine to
2658
copy the `.data' section from `ROM' or `ROM2' into the `RAM' if
2659
necessary:
2660
     #include 
2661
 
2662
     extern char data_start [];
2663
     extern char data_size [];
2664
     extern char data_load_start [];
2665
 
2666
     void copy_data(void)
2667
     {
2668
       if (data_start != data_load_start)
2669
         {
2670
           memcpy(data_start, data_load_start, (size_t) data_size);
2671
         }
2672
     }
2673
 
2674

2675
File: ld.info,  Node: Miscellaneous Commands,  Prev: REGION_ALIAS,  Up: Simple Commands
2676
 
2677
3.4.5 Other Linker Script Commands
2678
----------------------------------
2679
 
2680
There are a few other linker scripts commands.
2681
 
2682
`ASSERT(EXP, MESSAGE)'
2683
     Ensure that EXP is non-zero.  If it is zero, then exit the linker
2684
     with an error code, and print MESSAGE.
2685
 
2686
`EXTERN(SYMBOL SYMBOL ...)'
2687
     Force SYMBOL to be entered in the output file as an undefined
2688
     symbol.  Doing this may, for example, trigger linking of additional
2689
     modules from standard libraries.  You may list several SYMBOLs for
2690
     each `EXTERN', and you may use `EXTERN' multiple times.  This
2691
     command has the same effect as the `-u' command-line option.
2692
 
2693
`FORCE_COMMON_ALLOCATION'
2694
     This command has the same effect as the `-d' command-line option:
2695
     to make `ld' assign space to common symbols even if a relocatable
2696
     output file is specified (`-r').
2697
 
2698
`INHIBIT_COMMON_ALLOCATION'
2699
     This command has the same effect as the `--no-define-common'
2700
     command-line option: to make `ld' omit the assignment of addresses
2701
     to common symbols even for a non-relocatable output file.
2702
 
2703
`INSERT [ AFTER | BEFORE ] OUTPUT_SECTION'
2704
     This command is typically used in a script specified by `-T' to
2705
     augment the default `SECTIONS' with, for example, overlays.  It
2706
     inserts all prior linker script statements after (or before)
2707
     OUTPUT_SECTION, and also causes `-T' to not override the default
2708
     linker script.  The exact insertion point is as for orphan
2709
     sections.  *Note Location Counter::.  The insertion happens after
2710
     the linker has mapped input sections to output sections.  Prior to
2711
     the insertion, since `-T' scripts are parsed before the default
2712
     linker script, statements in the `-T' script occur before the
2713
     default linker script statements in the internal linker
2714
     representation of the script.  In particular, input section
2715
     assignments will be made to `-T' output sections before those in
2716
     the default script.  Here is an example of how a `-T' script using
2717
     `INSERT' might look:
2718
 
2719
          SECTIONS
2720
          {
2721
            OVERLAY :
2722
            {
2723
              .ov1 { ov1*(.text) }
2724
              .ov2 { ov2*(.text) }
2725
            }
2726
          }
2727
          INSERT AFTER .text;
2728
 
2729
`NOCROSSREFS(SECTION SECTION ...)'
2730
     This command may be used to tell `ld' to issue an error about any
2731
     references among certain output sections.
2732
 
2733
     In certain types of programs, particularly on embedded systems when
2734
     using overlays, when one section is loaded into memory, another
2735
     section will not be.  Any direct references between the two
2736
     sections would be errors.  For example, it would be an error if
2737
     code in one section called a function defined in the other section.
2738
 
2739
     The `NOCROSSREFS' command takes a list of output section names.  If
2740
     `ld' detects any cross references between the sections, it reports
2741
     an error and returns a non-zero exit status.  Note that the
2742
     `NOCROSSREFS' command uses output section names, not input section
2743
     names.
2744
 
2745
`OUTPUT_ARCH(BFDARCH)'
2746
     Specify a particular output machine architecture.  The argument is
2747
     one of the names used by the BFD library (*note BFD::).  You can
2748
     see the architecture of an object file by using the `objdump'
2749
     program with the `-f' option.
2750
 
2751
`LD_FEATURE(STRING)'
2752
     This command may be used to modify `ld' behavior.  If STRING is
2753
     `"SANE_EXPR"' then absolute symbols and numbers in a script are
2754
     simply treated as numbers everywhere.  *Note Expression Section::.
2755
 
2756

2757
File: ld.info,  Node: Assignments,  Next: SECTIONS,  Prev: Simple Commands,  Up: Scripts
2758
 
2759
3.5 Assigning Values to Symbols
2760
===============================
2761
 
2762
You may assign a value to a symbol in a linker script.  This will define
2763
the symbol and place it into the symbol table with a global scope.
2764
 
2765
* Menu:
2766
 
2767
* Simple Assignments::          Simple Assignments
2768
* HIDDEN::                      HIDDEN
2769
* PROVIDE::                     PROVIDE
2770
* PROVIDE_HIDDEN::              PROVIDE_HIDDEN
2771
* Source Code Reference::       How to use a linker script defined symbol in source code
2772
 
2773

2774
File: ld.info,  Node: Simple Assignments,  Next: HIDDEN,  Up: Assignments
2775
 
2776
3.5.1 Simple Assignments
2777
------------------------
2778
 
2779
You may assign to a symbol using any of the C assignment operators:
2780
 
2781
`SYMBOL = EXPRESSION ;'
2782
`SYMBOL += EXPRESSION ;'
2783
`SYMBOL -= EXPRESSION ;'
2784
`SYMBOL *= EXPRESSION ;'
2785
`SYMBOL /= EXPRESSION ;'
2786
`SYMBOL <<= EXPRESSION ;'
2787
`SYMBOL >>= EXPRESSION ;'
2788
`SYMBOL &= EXPRESSION ;'
2789
`SYMBOL |= EXPRESSION ;'
2790
 
2791
   The first case will define SYMBOL to the value of EXPRESSION.  In
2792
the other cases, SYMBOL must already be defined, and the value will be
2793
adjusted accordingly.
2794
 
2795
   The special symbol name `.' indicates the location counter.  You may
2796
only use this within a `SECTIONS' command.  *Note Location Counter::.
2797
 
2798
   The semicolon after EXPRESSION is required.
2799
 
2800
   Expressions are defined below; see *note Expressions::.
2801
 
2802
   You may write symbol assignments as commands in their own right, or
2803
as statements within a `SECTIONS' command, or as part of an output
2804
section description in a `SECTIONS' command.
2805
 
2806
   The section of the symbol will be set from the section of the
2807
expression; for more information, see *note Expression Section::.
2808
 
2809
   Here is an example showing the three different places that symbol
2810
assignments may be used:
2811
 
2812
     floating_point = 0;
2813
     SECTIONS
2814
     {
2815
       .text :
2816
         {
2817
           *(.text)
2818
           _etext = .;
2819
         }
2820
       _bdata = (. + 3) & ~ 3;
2821
       .data : { *(.data) }
2822
     }
2823
   In this example, the symbol `floating_point' will be defined as
2824
zero.  The symbol `_etext' will be defined as the address following the
2825
last `.text' input section.  The symbol `_bdata' will be defined as the
2826
address following the `.text' output section aligned upward to a 4 byte
2827
boundary.
2828
 
2829

2830
File: ld.info,  Node: HIDDEN,  Next: PROVIDE,  Prev: Simple Assignments,  Up: Assignments
2831
 
2832
3.5.2 HIDDEN
2833
------------
2834
 
2835
For ELF targeted ports, define a symbol that will be hidden and won't be
2836
exported.  The syntax is `HIDDEN(SYMBOL = EXPRESSION)'.
2837
 
2838
   Here is the example from *note Simple Assignments::, rewritten to use
2839
`HIDDEN':
2840
 
2841
     HIDDEN(floating_point = 0);
2842
     SECTIONS
2843
     {
2844
       .text :
2845
         {
2846
           *(.text)
2847
           HIDDEN(_etext = .);
2848
         }
2849
       HIDDEN(_bdata = (. + 3) & ~ 3);
2850
       .data : { *(.data) }
2851
     }
2852
   In this case none of the three symbols will be visible outside this
2853
module.
2854
 
2855

2856
File: ld.info,  Node: PROVIDE,  Next: PROVIDE_HIDDEN,  Prev: HIDDEN,  Up: Assignments
2857
 
2858
3.5.3 PROVIDE
2859
-------------
2860
 
2861
In some cases, it is desirable for a linker script to define a symbol
2862
only if it is referenced and is not defined by any object included in
2863
the link.  For example, traditional linkers defined the symbol `etext'.
2864
However, ANSI C requires that the user be able to use `etext' as a
2865
function name without encountering an error.  The `PROVIDE' keyword may
2866
be used to define a symbol, such as `etext', only if it is referenced
2867
but not defined.  The syntax is `PROVIDE(SYMBOL = EXPRESSION)'.
2868
 
2869
   Here is an example of using `PROVIDE' to define `etext':
2870
     SECTIONS
2871
     {
2872
       .text :
2873
         {
2874
           *(.text)
2875
           _etext = .;
2876
           PROVIDE(etext = .);
2877
         }
2878
     }
2879
 
2880
   In this example, if the program defines `_etext' (with a leading
2881
underscore), the linker will give a multiple definition error.  If, on
2882
the other hand, the program defines `etext' (with no leading
2883
underscore), the linker will silently use the definition in the program.
2884
If the program references `etext' but does not define it, the linker
2885
will use the definition in the linker script.
2886
 
2887

2888
File: ld.info,  Node: PROVIDE_HIDDEN,  Next: Source Code Reference,  Prev: PROVIDE,  Up: Assignments
2889
 
2890
3.5.4 PROVIDE_HIDDEN
2891
--------------------
2892
 
2893
Similar to `PROVIDE'.  For ELF targeted ports, the symbol will be
2894
hidden and won't be exported.
2895
 
2896

2897
File: ld.info,  Node: Source Code Reference,  Prev: PROVIDE_HIDDEN,  Up: Assignments
2898
 
2899
3.5.5 Source Code Reference
2900
---------------------------
2901
 
2902
Accessing a linker script defined variable from source code is not
2903
intuitive.  In particular a linker script symbol is not equivalent to a
2904
variable declaration in a high level language, it is instead a symbol
2905
that does not have a value.
2906
 
2907
   Before going further, it is important to note that compilers often
2908
transform names in the source code into different names when they are
2909
stored in the symbol table.  For example, Fortran compilers commonly
2910
prepend or append an underscore, and C++ performs extensive `name
2911
mangling'.  Therefore there might be a discrepancy between the name of
2912
a variable as it is used in source code and the name of the same
2913
variable as it is defined in a linker script.  For example in C a
2914
linker script variable might be referred to as:
2915
 
2916
       extern int foo;
2917
 
2918
   But in the linker script it might be defined as:
2919
 
2920
       _foo = 1000;
2921
 
2922
   In the remaining examples however it is assumed that no name
2923
transformation has taken place.
2924
 
2925
   When a symbol is declared in a high level language such as C, two
2926
things happen.  The first is that the compiler reserves enough space in
2927
the program's memory to hold the _value_ of the symbol.  The second is
2928
that the compiler creates an entry in the program's symbol table which
2929
holds the symbol's _address_.  ie the symbol table contains the address
2930
of the block of memory holding the symbol's value.  So for example the
2931
following C declaration, at file scope:
2932
 
2933
       int foo = 1000;
2934
 
2935
   creates a entry called `foo' in the symbol table.  This entry holds
2936
the address of an `int' sized block of memory where the number 1000 is
2937
initially stored.
2938
 
2939
   When a program references a symbol the compiler generates code that
2940
first accesses the symbol table to find the address of the symbol's
2941
memory block and then code to read the value from that memory block.
2942
So:
2943
 
2944
       foo = 1;
2945
 
2946
   looks up the symbol `foo' in the symbol table, gets the address
2947
associated with this symbol and then writes the value 1 into that
2948
address.  Whereas:
2949
 
2950
       int * a = & foo;
2951
 
2952
   looks up the symbol `foo' in the symbol table, gets it address and
2953
then copies this address into the block of memory associated with the
2954
variable `a'.
2955
 
2956
   Linker scripts symbol declarations, by contrast, create an entry in
2957
the symbol table but do not assign any memory to them.  Thus they are
2958
an address without a value.  So for example the linker script
2959
definition:
2960
 
2961
       foo = 1000;
2962
 
2963
   creates an entry in the symbol table called `foo' which holds the
2964
address of memory location 1000, but nothing special is stored at
2965
address 1000.  This means that you cannot access the _value_ of a
2966
linker script defined symbol - it has no value - all you can do is
2967
access the _address_ of a linker script defined symbol.
2968
 
2969
   Hence when you are using a linker script defined symbol in source
2970
code you should always take the address of the symbol, and never
2971
attempt to use its value.  For example suppose you want to copy the
2972
contents of a section of memory called .ROM into a section called
2973
.FLASH and the linker script contains these declarations:
2974
 
2975
       start_of_ROM   = .ROM;
2976
       end_of_ROM     = .ROM + sizeof (.ROM) - 1;
2977
       start_of_FLASH = .FLASH;
2978
 
2979
   Then the C source code to perform the copy would be:
2980
 
2981
       extern char start_of_ROM, end_of_ROM, start_of_FLASH;
2982
 
2983
       memcpy (& start_of_FLASH, & start_of_ROM, & end_of_ROM - & start_of_ROM);
2984
 
2985
   Note the use of the `&' operators.  These are correct.
2986
 
2987

2988
File: ld.info,  Node: SECTIONS,  Next: MEMORY,  Prev: Assignments,  Up: Scripts
2989
 
2990
3.6 SECTIONS Command
2991
====================
2992
 
2993
The `SECTIONS' command tells the linker how to map input sections into
2994
output sections, and how to place the output sections in memory.
2995
 
2996
   The format of the `SECTIONS' command is:
2997
     SECTIONS
2998
     {
2999
       SECTIONS-COMMAND
3000
       SECTIONS-COMMAND
3001
       ...
3002
     }
3003
 
3004
   Each SECTIONS-COMMAND may of be one of the following:
3005
 
3006
   * an `ENTRY' command (*note Entry command: Entry Point.)
3007
 
3008
   * a symbol assignment (*note Assignments::)
3009
 
3010
   * an output section description
3011
 
3012
   * an overlay description
3013
 
3014
   The `ENTRY' command and symbol assignments are permitted inside the
3015
`SECTIONS' command for convenience in using the location counter in
3016
those commands.  This can also make the linker script easier to
3017
understand because you can use those commands at meaningful points in
3018
the layout of the output file.
3019
 
3020
   Output section descriptions and overlay descriptions are described
3021
below.
3022
 
3023
   If you do not use a `SECTIONS' command in your linker script, the
3024
linker will place each input section into an identically named output
3025
section in the order that the sections are first encountered in the
3026
input files.  If all input sections are present in the first file, for
3027
example, the order of sections in the output file will match the order
3028
in the first input file.  The first section will be at address zero.
3029
 
3030
* Menu:
3031
 
3032
* Output Section Description::  Output section description
3033
* Output Section Name::         Output section name
3034
* Output Section Address::      Output section address
3035
* Input Section::               Input section description
3036
* Output Section Data::         Output section data
3037
* Output Section Keywords::     Output section keywords
3038
* Output Section Discarding::   Output section discarding
3039
* Output Section Attributes::   Output section attributes
3040
* Overlay Description::         Overlay description
3041
 
3042

3043
File: ld.info,  Node: Output Section Description,  Next: Output Section Name,  Up: SECTIONS
3044
 
3045
3.6.1 Output Section Description
3046
--------------------------------
3047
 
3048
The full description of an output section looks like this:
3049
     SECTION [ADDRESS] [(TYPE)] :
3050
       [AT(LMA)]
3051
       [ALIGN(SECTION_ALIGN)]
3052
       [SUBALIGN(SUBSECTION_ALIGN)]
3053
       [CONSTRAINT]
3054
       {
3055
         OUTPUT-SECTION-COMMAND
3056
         OUTPUT-SECTION-COMMAND
3057
         ...
3058
       } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
3059
 
3060
   Most output sections do not use most of the optional section
3061
attributes.
3062
 
3063
   The whitespace around SECTION is required, so that the section name
3064
is unambiguous.  The colon and the curly braces are also required.  The
3065
line breaks and other white space are optional.
3066
 
3067
   Each OUTPUT-SECTION-COMMAND may be one of the following:
3068
 
3069
   * a symbol assignment (*note Assignments::)
3070
 
3071
   * an input section description (*note Input Section::)
3072
 
3073
   * data values to include directly (*note Output Section Data::)
3074
 
3075
   * a special output section keyword (*note Output Section Keywords::)
3076
 
3077

3078
File: ld.info,  Node: Output Section Name,  Next: Output Section Address,  Prev: Output Section Description,  Up: SECTIONS
3079
 
3080
3.6.2 Output Section Name
3081
-------------------------
3082
 
3083
The name of the output section is SECTION.  SECTION must meet the
3084
constraints of your output format.  In formats which only support a
3085
limited number of sections, such as `a.out', the name must be one of
3086
the names supported by the format (`a.out', for example, allows only
3087
`.text', `.data' or `.bss'). If the output format supports any number
3088
of sections, but with numbers and not names (as is the case for Oasys),
3089
the name should be supplied as a quoted numeric string.  A section name
3090
may consist of any sequence of characters, but a name which contains
3091
any unusual characters such as commas must be quoted.
3092
 
3093
   The output section name `/DISCARD/' is special; *note Output Section
3094
Discarding::.
3095
 
3096

3097
File: ld.info,  Node: Output Section Address,  Next: Input Section,  Prev: Output Section Name,  Up: SECTIONS
3098
 
3099
3.6.3 Output Section Address
3100
----------------------------
3101
 
3102
The ADDRESS is an expression for the VMA (the virtual memory address)
3103
of the output section.  This address is optional, but if it is provided
3104
then the output address will be set exactly as specified.
3105
 
3106
   If the output address is not specified then one will be chosen for
3107
the section, based on the heuristic below.  This address will be
3108
adjusted to fit the alignment requirement of the output section.  The
3109
alignment requirement is the strictest alignment of any input section
3110
contained within the output section.
3111
 
3112
   The output section address heuristic is as follows:
3113
 
3114
   * If an output memory REGION is set for the section then it is added
3115
     to this region and its address will be the next free address in
3116
     that region.
3117
 
3118
   * If the MEMORY command has been used to create a list of memory
3119
     regions then the first region which has attributes compatible with
3120
     the section is selected to contain it.  The section's output
3121
     address will be the next free address in that region; *note
3122
     MEMORY::.
3123
 
3124
   * If no memory regions were specified, or none match the section then
3125
     the output address will be based on the current value of the
3126
     location counter.
3127
 
3128
For example:
3129
 
3130
     .text . : { *(.text) }
3131
 
3132
and
3133
 
3134
     .text : { *(.text) }
3135
 
3136
are subtly different.  The first will set the address of the `.text'
3137
output section to the current value of the location counter.  The
3138
second will set it to the current value of the location counter aligned
3139
to the strictest alignment of any of the `.text' input sections.
3140
 
3141
   The ADDRESS may be an arbitrary expression; *note Expressions::.
3142
For example, if you want to align the section on a 0x10 byte boundary,
3143
so that the lowest four bits of the section address are zero, you could
3144
do something like this:
3145
     .text ALIGN(0x10) : { *(.text) }
3146
   This works because `ALIGN' returns the current location counter
3147
aligned upward to the specified value.
3148
 
3149
   Specifying ADDRESS for a section will change the value of the
3150
location counter, provided that the section is non-empty.  (Empty
3151
sections are ignored).
3152
 
3153

3154
File: ld.info,  Node: Input Section,  Next: Output Section Data,  Prev: Output Section Address,  Up: SECTIONS
3155
 
3156
3.6.4 Input Section Description
3157
-------------------------------
3158
 
3159
The most common output section command is an input section description.
3160
 
3161
   The input section description is the most basic linker script
3162
operation.  You use output sections to tell the linker how to lay out
3163
your program in memory.  You use input section descriptions to tell the
3164
linker how to map the input files into your memory layout.
3165
 
3166
* Menu:
3167
 
3168
* Input Section Basics::        Input section basics
3169
* Input Section Wildcards::     Input section wildcard patterns
3170
* Input Section Common::        Input section for common symbols
3171
* Input Section Keep::          Input section and garbage collection
3172
* Input Section Example::       Input section example
3173
 
3174

3175
File: ld.info,  Node: Input Section Basics,  Next: Input Section Wildcards,  Up: Input Section
3176
 
3177
3.6.4.1 Input Section Basics
3178
............................
3179
 
3180
An input section description consists of a file name optionally followed
3181
by a list of section names in parentheses.
3182
 
3183
   The file name and the section name may be wildcard patterns, which we
3184
describe further below (*note Input Section Wildcards::).
3185
 
3186
   The most common input section description is to include all input
3187
sections with a particular name in the output section.  For example, to
3188
include all input `.text' sections, you would write:
3189
     *(.text)
3190
   Here the `*' is a wildcard which matches any file name.  To exclude
3191
a list of files from matching the file name wildcard, EXCLUDE_FILE may
3192
be used to match all files except the ones specified in the
3193
EXCLUDE_FILE list.  For example:
3194
     *(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors)
3195
   will cause all .ctors sections from all files except `crtend.o' and
3196
`otherfile.o' to be included.
3197
 
3198
   There are two ways to include more than one section:
3199
     *(.text .rdata)
3200
     *(.text) *(.rdata)
3201
   The difference between these is the order in which the `.text' and
3202
`.rdata' input sections will appear in the output section.  In the
3203
first example, they will be intermingled, appearing in the same order as
3204
they are found in the linker input.  In the second example, all `.text'
3205
input sections will appear first, followed by all `.rdata' input
3206
sections.
3207
 
3208
   You can specify a file name to include sections from a particular
3209
file.  You would do this if one or more of your files contain special
3210
data that needs to be at a particular location in memory.  For example:
3211
     data.o(.data)
3212
 
3213
   To refine the sections that are included based on the section flags
3214
of an input section, INPUT_SECTION_FLAGS may be used.
3215
 
3216
   Here is a simple example for using Section header flags for ELF
3217
sections:
3218
 
3219
     SECTIONS {
3220
       .text : { INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS) *(.text) }
3221
       .text2 :  { INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) }
3222
     }
3223
 
3224
   In this example, the output section `.text' will be comprised of any
3225
input section matching the name *(.text) whose section header flags
3226
`SHF_MERGE' and `SHF_STRINGS' are set.  The output section `.text2'
3227
will be comprised of any input section matching the name *(.text) whose
3228
section header flag `SHF_WRITE' is clear.
3229
 
3230
   You can also specify files within archives by writing a pattern
3231
matching the archive, a colon, then the pattern matching the file, with
3232
no whitespace around the colon.
3233
 
3234
`archive:file'
3235
     matches file within archive
3236
 
3237
`archive:'
3238
     matches the whole archive
3239
 
3240
`:file'
3241
     matches file but not one in an archive
3242
 
3243
   Either one or both of `archive' and `file' can contain shell
3244
wildcards.  On DOS based file systems, the linker will assume that a
3245
single letter followed by a colon is a drive specifier, so `c:myfile.o'
3246
is a simple file specification, not `myfile.o' within an archive called
3247
`c'.  `archive:file' filespecs may also be used within an
3248
`EXCLUDE_FILE' list, but may not appear in other linker script
3249
contexts.  For instance, you cannot extract a file from an archive by
3250
using `archive:file' in an `INPUT' command.
3251
 
3252
   If you use a file name without a list of sections, then all sections
3253
in the input file will be included in the output section.  This is not
3254
commonly done, but it may by useful on occasion.  For example:
3255
     data.o
3256
 
3257
   When you use a file name which is not an `archive:file' specifier
3258
and does not contain any wild card characters, the linker will first
3259
see if you also specified the file name on the linker command line or
3260
in an `INPUT' command.  If you did not, the linker will attempt to open
3261
the file as an input file, as though it appeared on the command line.
3262
Note that this differs from an `INPUT' command, because the linker will
3263
not search for the file in the archive search path.
3264
 
3265

3266
File: ld.info,  Node: Input Section Wildcards,  Next: Input Section Common,  Prev: Input Section Basics,  Up: Input Section
3267
 
3268
3.6.4.2 Input Section Wildcard Patterns
3269
.......................................
3270
 
3271
In an input section description, either the file name or the section
3272
name or both may be wildcard patterns.
3273
 
3274
   The file name of `*' seen in many examples is a simple wildcard
3275
pattern for the file name.
3276
 
3277
   The wildcard patterns are like those used by the Unix shell.
3278
 
3279
`*'
3280
     matches any number of characters
3281
 
3282
`?'
3283
     matches any single character
3284
 
3285
`[CHARS]'
3286
     matches a single instance of any of the CHARS; the `-' character
3287
     may be used to specify a range of characters, as in `[a-z]' to
3288
     match any lower case letter
3289
 
3290
`\'
3291
     quotes the following character
3292
 
3293
   When a file name is matched with a wildcard, the wildcard characters
3294
will not match a `/' character (used to separate directory names on
3295
Unix).  A pattern consisting of a single `*' character is an exception;
3296
it will always match any file name, whether it contains a `/' or not.
3297
In a section name, the wildcard characters will match a `/' character.
3298
 
3299
   File name wildcard patterns only match files which are explicitly
3300
specified on the command line or in an `INPUT' command.  The linker
3301
does not search directories to expand wildcards.
3302
 
3303
   If a file name matches more than one wildcard pattern, or if a file
3304
name appears explicitly and is also matched by a wildcard pattern, the
3305
linker will use the first match in the linker script.  For example, this
3306
sequence of input section descriptions is probably in error, because the
3307
`data.o' rule will not be used:
3308
     .data : { *(.data) }
3309
     .data1 : { data.o(.data) }
3310
 
3311
   Normally, the linker will place files and sections matched by
3312
wildcards in the order in which they are seen during the link.  You can
3313
change this by using the `SORT_BY_NAME' keyword, which appears before a
3314
wildcard pattern in parentheses (e.g., `SORT_BY_NAME(.text*)').  When
3315
the `SORT_BY_NAME' keyword is used, the linker will sort the files or
3316
sections into ascending order by name before placing them in the output
3317
file.
3318
 
3319
   `SORT_BY_ALIGNMENT' is very similar to `SORT_BY_NAME'. The
3320
difference is `SORT_BY_ALIGNMENT' will sort sections into ascending
3321
order by alignment before placing them in the output file.
3322
 
3323
   `SORT_BY_INIT_PRIORITY' is very similar to `SORT_BY_NAME'. The
3324
difference is `SORT_BY_INIT_PRIORITY' will sort sections into ascending
3325
order by numerical value of the GCC init_priority attribute encoded in
3326
the section name before placing them in the output file.
3327
 
3328
   `SORT' is an alias for `SORT_BY_NAME'.
3329
 
3330
   When there are nested section sorting commands in linker script,
3331
there can be at most 1 level of nesting for section sorting commands.
3332
 
3333
  1. `SORT_BY_NAME' (`SORT_BY_ALIGNMENT' (wildcard section pattern)).
3334
     It will sort the input sections by name first, then by alignment
3335
     if 2 sections have the same name.
3336
 
3337
  2. `SORT_BY_ALIGNMENT' (`SORT_BY_NAME' (wildcard section pattern)).
3338
     It will sort the input sections by alignment first, then by name
3339
     if 2 sections have the same alignment.
3340
 
3341
  3. `SORT_BY_NAME' (`SORT_BY_NAME' (wildcard section pattern)) is
3342
     treated the same as `SORT_BY_NAME' (wildcard section pattern).
3343
 
3344
  4. `SORT_BY_ALIGNMENT' (`SORT_BY_ALIGNMENT' (wildcard section
3345
     pattern)) is treated the same as `SORT_BY_ALIGNMENT' (wildcard
3346
     section pattern).
3347
 
3348
  5. All other nested section sorting commands are invalid.
3349
 
3350
   When both command line section sorting option and linker script
3351
section sorting command are used, section sorting command always takes
3352
precedence over the command line option.
3353
 
3354
   If the section sorting command in linker script isn't nested, the
3355
command line option will make the section sorting command to be treated
3356
as nested sorting command.
3357
 
3358
  1. `SORT_BY_NAME' (wildcard section pattern ) with `--sort-sections
3359
     alignment' is equivalent to `SORT_BY_NAME' (`SORT_BY_ALIGNMENT'
3360
     (wildcard section pattern)).
3361
 
3362
  2. `SORT_BY_ALIGNMENT' (wildcard section pattern) with
3363
     `--sort-section name' is equivalent to `SORT_BY_ALIGNMENT'
3364
     (`SORT_BY_NAME' (wildcard section pattern)).
3365
 
3366
   If the section sorting command in linker script is nested, the
3367
command line option will be ignored.
3368
 
3369
   `SORT_NONE' disables section sorting by ignoring the command line
3370
section sorting option.
3371
 
3372
   If you ever get confused about where input sections are going, use
3373
the `-M' linker option to generate a map file.  The map file shows
3374
precisely how input sections are mapped to output sections.
3375
 
3376
   This example shows how wildcard patterns might be used to partition
3377
files.  This linker script directs the linker to place all `.text'
3378
sections in `.text' and all `.bss' sections in `.bss'.  The linker will
3379
place the `.data' section from all files beginning with an upper case
3380
character in `.DATA'; for all other files, the linker will place the
3381
`.data' section in `.data'.
3382
     SECTIONS {
3383
       .text : { *(.text) }
3384
       .DATA : { [A-Z]*(.data) }
3385
       .data : { *(.data) }
3386
       .bss : { *(.bss) }
3387
     }
3388
 
3389

3390
File: ld.info,  Node: Input Section Common,  Next: Input Section Keep,  Prev: Input Section Wildcards,  Up: Input Section
3391
 
3392
3.6.4.3 Input Section for Common Symbols
3393
........................................
3394
 
3395
A special notation is needed for common symbols, because in many object
3396
file formats common symbols do not have a particular input section.  The
3397
linker treats common symbols as though they are in an input section
3398
named `COMMON'.
3399
 
3400
   You may use file names with the `COMMON' section just as with any
3401
other input sections.  You can use this to place common symbols from a
3402
particular input file in one section while common symbols from other
3403
input files are placed in another section.
3404
 
3405
   In most cases, common symbols in input files will be placed in the
3406
`.bss' section in the output file.  For example:
3407
     .bss { *(.bss) *(COMMON) }
3408
 
3409
   Some object file formats have more than one type of common symbol.
3410
For example, the MIPS ELF object file format distinguishes standard
3411
common symbols and small common symbols.  In this case, the linker will
3412
use a different special section name for other types of common symbols.
3413
In the case of MIPS ELF, the linker uses `COMMON' for standard common
3414
symbols and `.scommon' for small common symbols.  This permits you to
3415
map the different types of common symbols into memory at different
3416
locations.
3417
 
3418
   You will sometimes see `[COMMON]' in old linker scripts.  This
3419
notation is now considered obsolete.  It is equivalent to `*(COMMON)'.
3420
 
3421

3422
File: ld.info,  Node: Input Section Keep,  Next: Input Section Example,  Prev: Input Section Common,  Up: Input Section
3423
 
3424
3.6.4.4 Input Section and Garbage Collection
3425
............................................
3426
 
3427
When link-time garbage collection is in use (`--gc-sections'), it is
3428
often useful to mark sections that should not be eliminated.  This is
3429
accomplished by surrounding an input section's wildcard entry with
3430
`KEEP()', as in `KEEP(*(.init))' or `KEEP(SORT_BY_NAME(*)(.ctors))'.
3431
 
3432

3433
File: ld.info,  Node: Input Section Example,  Prev: Input Section Keep,  Up: Input Section
3434
 
3435
3.6.4.5 Input Section Example
3436
.............................
3437
 
3438
The following example is a complete linker script.  It tells the linker
3439
to read all of the sections from file `all.o' and place them at the
3440
start of output section `outputa' which starts at location `0x10000'.
3441
All of section `.input1' from file `foo.o' follows immediately, in the
3442
same output section.  All of section `.input2' from `foo.o' goes into
3443
output section `outputb', followed by section `.input1' from `foo1.o'.
3444
All of the remaining `.input1' and `.input2' sections from any files
3445
are written to output section `outputc'.
3446
 
3447
     SECTIONS {
3448
       outputa 0x10000 :
3449
         {
3450
         all.o
3451
         foo.o (.input1)
3452
         }
3453
       outputb :
3454
         {
3455
         foo.o (.input2)
3456
         foo1.o (.input1)
3457
         }
3458
       outputc :
3459
         {
3460
         *(.input1)
3461
         *(.input2)
3462
         }
3463
     }
3464
 
3465

3466
File: ld.info,  Node: Output Section Data,  Next: Output Section Keywords,  Prev: Input Section,  Up: SECTIONS
3467
 
3468
3.6.5 Output Section Data
3469
-------------------------
3470
 
3471
You can include explicit bytes of data in an output section by using
3472
`BYTE', `SHORT', `LONG', `QUAD', or `SQUAD' as an output section
3473
command.  Each keyword is followed by an expression in parentheses
3474
providing the value to store (*note Expressions::).  The value of the
3475
expression is stored at the current value of the location counter.
3476
 
3477
   The `BYTE', `SHORT', `LONG', and `QUAD' commands store one, two,
3478
four, and eight bytes (respectively).  After storing the bytes, the
3479
location counter is incremented by the number of bytes stored.
3480
 
3481
   For example, this will store the byte 1 followed by the four byte
3482
value of the symbol `addr':
3483
     BYTE(1)
3484
     LONG(addr)
3485
 
3486
   When using a 64 bit host or target, `QUAD' and `SQUAD' are the same;
3487
they both store an 8 byte, or 64 bit, value.  When both host and target
3488
are 32 bits, an expression is computed as 32 bits.  In this case `QUAD'
3489
stores a 32 bit value zero extended to 64 bits, and `SQUAD' stores a 32
3490
bit value sign extended to 64 bits.
3491
 
3492
   If the object file format of the output file has an explicit
3493
endianness, which is the normal case, the value will be stored in that
3494
endianness.  When the object file format does not have an explicit
3495
endianness, as is true of, for example, S-records, the value will be
3496
stored in the endianness of the first input object file.
3497
 
3498
   Note--these commands only work inside a section description and not
3499
between them, so the following will produce an error from the linker:
3500
     SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }
3501
   whereas this will work:
3502
     SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }
3503
 
3504
   You may use the `FILL' command to set the fill pattern for the
3505
current section.  It is followed by an expression in parentheses.  Any
3506
otherwise unspecified regions of memory within the section (for example,
3507
gaps left due to the required alignment of input sections) are filled
3508
with the value of the expression, repeated as necessary.  A `FILL'
3509
statement covers memory locations after the point at which it occurs in
3510
the section definition; by including more than one `FILL' statement,
3511
you can have different fill patterns in different parts of an output
3512
section.
3513
 
3514
   This example shows how to fill unspecified regions of memory with the
3515
value `0x90':
3516
     FILL(0x90909090)
3517
 
3518
   The `FILL' command is similar to the `=FILLEXP' output section
3519
attribute, but it only affects the part of the section following the
3520
`FILL' command, rather than the entire section.  If both are used, the
3521
`FILL' command takes precedence.  *Note Output Section Fill::, for
3522
details on the fill expression.
3523
 
3524

3525
File: ld.info,  Node: Output Section Keywords,  Next: Output Section Discarding,  Prev: Output Section Data,  Up: SECTIONS
3526
 
3527
3.6.6 Output Section Keywords
3528
-----------------------------
3529
 
3530
There are a couple of keywords which can appear as output section
3531
commands.
3532
 
3533
`CREATE_OBJECT_SYMBOLS'
3534
     The command tells the linker to create a symbol for each input
3535
     file.  The name of each symbol will be the name of the
3536
     corresponding input file.  The section of each symbol will be the
3537
     output section in which the `CREATE_OBJECT_SYMBOLS' command
3538
     appears.
3539
 
3540
     This is conventional for the a.out object file format.  It is not
3541
     normally used for any other object file format.
3542
 
3543
`CONSTRUCTORS'
3544
     When linking using the a.out object file format, the linker uses an
3545
     unusual set construct to support C++ global constructors and
3546
     destructors.  When linking object file formats which do not support
3547
     arbitrary sections, such as ECOFF and XCOFF, the linker will
3548
     automatically recognize C++ global constructors and destructors by
3549
     name.  For these object file formats, the `CONSTRUCTORS' command
3550
     tells the linker to place constructor information in the output
3551
     section where the `CONSTRUCTORS' command appears.  The
3552
     `CONSTRUCTORS' command is ignored for other object file formats.
3553
 
3554
     The symbol `__CTOR_LIST__' marks the start of the global
3555
     constructors, and the symbol `__CTOR_END__' marks the end.
3556
     Similarly, `__DTOR_LIST__' and `__DTOR_END__' mark the start and
3557
     end of the global destructors.  The first word in the list is the
3558
     number of entries, followed by the address of each constructor or
3559
     destructor, followed by a zero word.  The compiler must arrange to
3560
     actually run the code.  For these object file formats GNU C++
3561
     normally calls constructors from a subroutine `__main'; a call to
3562
     `__main' is automatically inserted into the startup code for
3563
     `main'.  GNU C++ normally runs destructors either by using
3564
     `atexit', or directly from the function `exit'.
3565
 
3566
     For object file formats such as `COFF' or `ELF' which support
3567
     arbitrary section names, GNU C++ will normally arrange to put the
3568
     addresses of global constructors and destructors into the `.ctors'
3569
     and `.dtors' sections.  Placing the following sequence into your
3570
     linker script will build the sort of table which the GNU C++
3571
     runtime code expects to see.
3572
 
3573
                __CTOR_LIST__ = .;
3574
                LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
3575
                *(.ctors)
3576
                LONG(0)
3577
                __CTOR_END__ = .;
3578
                __DTOR_LIST__ = .;
3579
                LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
3580
                *(.dtors)
3581
                LONG(0)
3582
                __DTOR_END__ = .;
3583
 
3584
     If you are using the GNU C++ support for initialization priority,
3585
     which provides some control over the order in which global
3586
     constructors are run, you must sort the constructors at link time
3587
     to ensure that they are executed in the correct order.  When using
3588
     the `CONSTRUCTORS' command, use `SORT_BY_NAME(CONSTRUCTORS)'
3589
     instead.  When using the `.ctors' and `.dtors' sections, use
3590
     `*(SORT_BY_NAME(.ctors))' and `*(SORT_BY_NAME(.dtors))' instead of
3591
     just `*(.ctors)' and `*(.dtors)'.
3592
 
3593
     Normally the compiler and linker will handle these issues
3594
     automatically, and you will not need to concern yourself with
3595
     them.  However, you may need to consider this if you are using C++
3596
     and writing your own linker scripts.
3597
 
3598
 
3599

3600
File: ld.info,  Node: Output Section Discarding,  Next: Output Section Attributes,  Prev: Output Section Keywords,  Up: SECTIONS
3601
 
3602
3.6.7 Output Section Discarding
3603
-------------------------------
3604
 
3605
The linker will not create output sections with no contents.  This is
3606
for convenience when referring to input sections that may or may not be
3607
present in any of the input files.  For example:
3608
     .foo : { *(.foo) }
3609
   will only create a `.foo' section in the output file if there is a
3610
`.foo' section in at least one input file, and if the input sections
3611
are not all empty.  Other link script directives that allocate space in
3612
an output section will also create the output section.
3613
 
3614
   The linker will ignore address assignments (*note Output Section
3615
Address::) on discarded output sections, except when the linker script
3616
defines symbols in the output section.  In that case the linker will
3617
obey the address assignments, possibly advancing dot even though the
3618
section is discarded.
3619
 
3620
   The special output section name `/DISCARD/' may be used to discard
3621
input sections.  Any input sections which are assigned to an output
3622
section named `/DISCARD/' are not included in the output file.
3623
 
3624

3625
File: ld.info,  Node: Output Section Attributes,  Next: Overlay Description,  Prev: Output Section Discarding,  Up: SECTIONS
3626
 
3627
3.6.8 Output Section Attributes
3628
-------------------------------
3629
 
3630
We showed above that the full description of an output section looked
3631
like this:
3632
 
3633
     SECTION [ADDRESS] [(TYPE)] :
3634
       [AT(LMA)]
3635
       [ALIGN(SECTION_ALIGN)]
3636
       [SUBALIGN(SUBSECTION_ALIGN)]
3637
       [CONSTRAINT]
3638
       {
3639
         OUTPUT-SECTION-COMMAND
3640
         OUTPUT-SECTION-COMMAND
3641
         ...
3642
       } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
3643
 
3644
   We've already described SECTION, ADDRESS, and
3645
OUTPUT-SECTION-COMMAND.  In this section we will describe the remaining
3646
section attributes.
3647
 
3648
* Menu:
3649
 
3650
* Output Section Type::         Output section type
3651
* Output Section LMA::          Output section LMA
3652
* Forced Output Alignment::     Forced Output Alignment
3653
* Forced Input Alignment::      Forced Input Alignment
3654
* Output Section Constraint::   Output section constraint
3655
* Output Section Region::       Output section region
3656
* Output Section Phdr::         Output section phdr
3657
* Output Section Fill::         Output section fill
3658
 
3659

3660
File: ld.info,  Node: Output Section Type,  Next: Output Section LMA,  Up: Output Section Attributes
3661
 
3662
3.6.8.1 Output Section Type
3663
...........................
3664
 
3665
Each output section may have a type.  The type is a keyword in
3666
parentheses.  The following types are defined:
3667
 
3668
`NOLOAD'
3669
     The section should be marked as not loadable, so that it will not
3670
     be loaded into memory when the program is run.
3671
 
3672
`DSECT'
3673
`COPY'
3674
`INFO'
3675
`OVERLAY'
3676
     These type names are supported for backward compatibility, and are
3677
     rarely used.  They all have the same effect: the section should be
3678
     marked as not allocatable, so that no memory is allocated for the
3679
     section when the program is run.
3680
 
3681
   The linker normally sets the attributes of an output section based on
3682
the input sections which map into it.  You can override this by using
3683
the section type.  For example, in the script sample below, the `ROM'
3684
section is addressed at memory location `0' and does not need to be
3685
loaded when the program is run.
3686
     SECTIONS {
3687
       ROM 0 (NOLOAD) : { ... }
3688
       ...
3689
     }
3690
 
3691

3692
File: ld.info,  Node: Output Section LMA,  Next: Forced Output Alignment,  Prev: Output Section Type,  Up: Output Section Attributes
3693
 
3694
3.6.8.2 Output Section LMA
3695
..........................
3696
 
3697
Every section has a virtual address (VMA) and a load address (LMA); see
3698
*note Basic Script Concepts::.  The virtual address is specified by the
3699
*note Output Section Address:: described earlier.  The load address is
3700
specified by the `AT' or `AT>' keywords.  Specifying a load address is
3701
optional.
3702
 
3703
   The `AT' keyword takes an expression as an argument.  This specifies
3704
the exact load address of the section.  The `AT>' keyword takes the
3705
name of a memory region as an argument.  *Note MEMORY::.  The load
3706
address of the section is set to the next free address in the region,
3707
aligned to the section's alignment requirements.
3708
 
3709
   If neither `AT' nor `AT>' is specified for an allocatable section,
3710
the linker will use the following heuristic to determine the load
3711
address:
3712
 
3713
   * If the section has a specific VMA address, then this is used as
3714
     the LMA address as well.
3715
 
3716
   * If the section is not allocatable then its LMA is set to its VMA.
3717
 
3718
   * Otherwise if a memory region can be found that is compatible with
3719
     the current section, and this region contains at least one
3720
     section, then the LMA is set so the difference between the VMA and
3721
     LMA is the same as the difference between the VMA and LMA of the
3722
     last section in the located region.
3723
 
3724
   * If no memory regions have been declared then a default region that
3725
     covers the entire address space is used in the previous step.
3726
 
3727
   * If no suitable region could be found, or there was no previous
3728
     section then the LMA is set equal to the VMA.
3729
 
3730
   This feature is designed to make it easy to build a ROM image.  For
3731
example, the following linker script creates three output sections: one
3732
called `.text', which starts at `0x1000', one called `.mdata', which is
3733
loaded at the end of the `.text' section even though its VMA is
3734
`0x2000', and one called `.bss' to hold uninitialized data at address
3735
`0x3000'.  The symbol `_data' is defined with the value `0x2000', which
3736
shows that the location counter holds the VMA value, not the LMA value.
3737
 
3738
     SECTIONS
3739
       {
3740
       .text 0x1000 : { *(.text) _etext = . ; }
3741
       .mdata 0x2000 :
3742
         AT ( ADDR (.text) + SIZEOF (.text) )
3743
         { _data = . ; *(.data); _edata = . ;  }
3744
       .bss 0x3000 :
3745
         { _bstart = . ;  *(.bss) *(COMMON) ; _bend = . ;}
3746
     }
3747
 
3748
   The run-time initialization code for use with a program generated
3749
with this linker script would include something like the following, to
3750
copy the initialized data from the ROM image to its runtime address.
3751
Notice how this code takes advantage of the symbols defined by the
3752
linker script.
3753
 
3754
     extern char _etext, _data, _edata, _bstart, _bend;
3755
     char *src = &_etext;
3756
     char *dst = &_data;
3757
 
3758
     /* ROM has data at end of text; copy it.  */
3759
     while (dst < &_edata)
3760
       *dst++ = *src++;
3761
 
3762
     /* Zero bss.  */
3763
     for (dst = &_bstart; dst< &_bend; dst++)
3764
       *dst = 0;
3765
 
3766

3767
File: ld.info,  Node: Forced Output Alignment,  Next: Forced Input Alignment,  Prev: Output Section LMA,  Up: Output Section Attributes
3768
 
3769
3.6.8.3 Forced Output Alignment
3770
...............................
3771
 
3772
You can increase an output section's alignment by using ALIGN.
3773
 
3774

3775
File: ld.info,  Node: Forced Input Alignment,  Next: Output Section Constraint,  Prev: Forced Output Alignment,  Up: Output Section Attributes
3776
 
3777
3.6.8.4 Forced Input Alignment
3778
..............................
3779
 
3780
You can force input section alignment within an output section by using
3781
SUBALIGN.  The value specified overrides any alignment given by input
3782
sections, whether larger or smaller.
3783
 
3784

3785
File: ld.info,  Node: Output Section Constraint,  Next: Output Section Region,  Prev: Forced Input Alignment,  Up: Output Section Attributes
3786
 
3787
3.6.8.5 Output Section Constraint
3788
.................................
3789
 
3790
You can specify that an output section should only be created if all of
3791
its input sections are read-only or all of its input sections are
3792
read-write by using the keyword `ONLY_IF_RO' and `ONLY_IF_RW'
3793
respectively.
3794
 
3795

3796
File: ld.info,  Node: Output Section Region,  Next: Output Section Phdr,  Prev: Output Section Constraint,  Up: Output Section Attributes
3797
 
3798
3.6.8.6 Output Section Region
3799
.............................
3800
 
3801
You can assign a section to a previously defined region of memory by
3802
using `>REGION'.  *Note MEMORY::.
3803
 
3804
   Here is a simple example:
3805
     MEMORY { rom : ORIGIN = 0x1000, LENGTH = 0x1000 }
3806
     SECTIONS { ROM : { *(.text) } >rom }
3807
 
3808

3809
File: ld.info,  Node: Output Section Phdr,  Next: Output Section Fill,  Prev: Output Section Region,  Up: Output Section Attributes
3810
 
3811
3.6.8.7 Output Section Phdr
3812
...........................
3813
 
3814
You can assign a section to a previously defined program segment by
3815
using `:PHDR'.  *Note PHDRS::.  If a section is assigned to one or more
3816
segments, then all subsequent allocated sections will be assigned to
3817
those segments as well, unless they use an explicitly `:PHDR' modifier.
3818
You can use `:NONE' to tell the linker to not put the section in any
3819
segment at all.
3820
 
3821
   Here is a simple example:
3822
     PHDRS { text PT_LOAD ; }
3823
     SECTIONS { .text : { *(.text) } :text }
3824
 
3825

3826
File: ld.info,  Node: Output Section Fill,  Prev: Output Section Phdr,  Up: Output Section Attributes
3827
 
3828
3.6.8.8 Output Section Fill
3829
...........................
3830
 
3831
You can set the fill pattern for an entire section by using `=FILLEXP'.
3832
FILLEXP is an expression (*note Expressions::).  Any otherwise
3833
unspecified regions of memory within the output section (for example,
3834
gaps left due to the required alignment of input sections) will be
3835
filled with the value, repeated as necessary.  If the fill expression
3836
is a simple hex number, ie. a string of hex digit starting with `0x'
3837
and without a trailing `k' or `M', then an arbitrarily long sequence of
3838
hex digits can be used to specify the fill pattern;  Leading zeros
3839
become part of the pattern too.  For all other cases, including extra
3840
parentheses or a unary `+', the fill pattern is the four least
3841
significant bytes of the value of the expression.  In all cases, the
3842
number is big-endian.
3843
 
3844
   You can also change the fill value with a `FILL' command in the
3845
output section commands; (*note Output Section Data::).
3846
 
3847
   Here is a simple example:
3848
     SECTIONS { .text : { *(.text) } =0x90909090 }
3849
 
3850

3851
File: ld.info,  Node: Overlay Description,  Prev: Output Section Attributes,  Up: SECTIONS
3852
 
3853
3.6.9 Overlay Description
3854
-------------------------
3855
 
3856
An overlay description provides an easy way to describe sections which
3857
are to be loaded as part of a single memory image but are to be run at
3858
the same memory address.  At run time, some sort of overlay manager will
3859
copy the overlaid sections in and out of the runtime memory address as
3860
required, perhaps by simply manipulating addressing bits.  This approach
3861
can be useful, for example, when a certain region of memory is faster
3862
than another.
3863
 
3864
   Overlays are described using the `OVERLAY' command.  The `OVERLAY'
3865
command is used within a `SECTIONS' command, like an output section
3866
description.  The full syntax of the `OVERLAY' command is as follows:
3867
     OVERLAY [START] : [NOCROSSREFS] [AT ( LDADDR )]
3868
       {
3869
         SECNAME1
3870
           {
3871
             OUTPUT-SECTION-COMMAND
3872
             OUTPUT-SECTION-COMMAND
3873
             ...
3874
           } [:PHDR...] [=FILL]
3875
         SECNAME2
3876
           {
3877
             OUTPUT-SECTION-COMMAND
3878
             OUTPUT-SECTION-COMMAND
3879
             ...
3880
           } [:PHDR...] [=FILL]
3881
         ...
3882
       } [>REGION] [:PHDR...] [=FILL]
3883
 
3884
   Everything is optional except `OVERLAY' (a keyword), and each
3885
section must have a name (SECNAME1 and SECNAME2 above).  The section
3886
definitions within the `OVERLAY' construct are identical to those
3887
within the general `SECTIONS' construct (*note SECTIONS::), except that
3888
no addresses and no memory regions may be defined for sections within
3889
an `OVERLAY'.
3890
 
3891
   The sections are all defined with the same starting address.  The
3892
load addresses of the sections are arranged such that they are
3893
consecutive in memory starting at the load address used for the
3894
`OVERLAY' as a whole (as with normal section definitions, the load
3895
address is optional, and defaults to the start address; the start
3896
address is also optional, and defaults to the current value of the
3897
location counter).
3898
 
3899
   If the `NOCROSSREFS' keyword is used, and there any references among
3900
the sections, the linker will report an error.  Since the sections all
3901
run at the same address, it normally does not make sense for one
3902
section to refer directly to another.  *Note NOCROSSREFS: Miscellaneous
3903
Commands.
3904
 
3905
   For each section within the `OVERLAY', the linker automatically
3906
provides two symbols.  The symbol `__load_start_SECNAME' is defined as
3907
the starting load address of the section.  The symbol
3908
`__load_stop_SECNAME' is defined as the final load address of the
3909
section.  Any characters within SECNAME which are not legal within C
3910
identifiers are removed.  C (or assembler) code may use these symbols
3911
to move the overlaid sections around as necessary.
3912
 
3913
   At the end of the overlay, the value of the location counter is set
3914
to the start address of the overlay plus the size of the largest
3915
section.
3916
 
3917
   Here is an example.  Remember that this would appear inside a
3918
`SECTIONS' construct.
3919
       OVERLAY 0x1000 : AT (0x4000)
3920
        {
3921
          .text0 { o1/*.o(.text) }
3922
          .text1 { o2/*.o(.text) }
3923
        }
3924
This will define both `.text0' and `.text1' to start at address 0x1000.
3925
`.text0' will be loaded at address 0x4000, and `.text1' will be loaded
3926
immediately after `.text0'.  The following symbols will be defined if
3927
referenced: `__load_start_text0', `__load_stop_text0',
3928
`__load_start_text1', `__load_stop_text1'.
3929
 
3930
   C code to copy overlay `.text1' into the overlay area might look
3931
like the following.
3932
 
3933
       extern char __load_start_text1, __load_stop_text1;
3934
       memcpy ((char *) 0x1000, &__load_start_text1,
3935
               &__load_stop_text1 - &__load_start_text1);
3936
 
3937
   Note that the `OVERLAY' command is just syntactic sugar, since
3938
everything it does can be done using the more basic commands.  The above
3939
example could have been written identically as follows.
3940
 
3941
       .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
3942
       PROVIDE (__load_start_text0 = LOADADDR (.text0));
3943
       PROVIDE (__load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0));
3944
       .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
3945
       PROVIDE (__load_start_text1 = LOADADDR (.text1));
3946
       PROVIDE (__load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1));
3947
       . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
3948
 
3949

3950
File: ld.info,  Node: MEMORY,  Next: PHDRS,  Prev: SECTIONS,  Up: Scripts
3951
 
3952
3.7 MEMORY Command
3953
==================
3954
 
3955
The linker's default configuration permits allocation of all available
3956
memory.  You can override this by using the `MEMORY' command.
3957
 
3958
   The `MEMORY' command describes the location and size of blocks of
3959
memory in the target.  You can use it to describe which memory regions
3960
may be used by the linker, and which memory regions it must avoid.  You
3961
can then assign sections to particular memory regions.  The linker will
3962
set section addresses based on the memory regions, and will warn about
3963
regions that become too full.  The linker will not shuffle sections
3964
around to fit into the available regions.
3965
 
3966
   A linker script may contain at most one use of the `MEMORY' command.
3967
However, you can define as many blocks of memory within it as you wish.
3968
The syntax is:
3969
     MEMORY
3970
       {
3971
         NAME [(ATTR)] : ORIGIN = ORIGIN, LENGTH = LEN
3972
         ...
3973
       }
3974
 
3975
   The NAME is a name used in the linker script to refer to the region.
3976
The region name has no meaning outside of the linker script.  Region
3977
names are stored in a separate name space, and will not conflict with
3978
symbol names, file names, or section names.  Each memory region must
3979
have a distinct name within the `MEMORY' command.  However you can add
3980
later alias names to existing memory regions with the *note
3981
REGION_ALIAS:: command.
3982
 
3983
   The ATTR string is an optional list of attributes that specify
3984
whether to use a particular memory region for an input section which is
3985
not explicitly mapped in the linker script.  As described in *note
3986
SECTIONS::, if you do not specify an output section for some input
3987
section, the linker will create an output section with the same name as
3988
the input section.  If you define region attributes, the linker will use
3989
them to select the memory region for the output section that it creates.
3990
 
3991
   The ATTR string must consist only of the following characters:
3992
`R'
3993
     Read-only section
3994
 
3995
`W'
3996
     Read/write section
3997
 
3998
`X'
3999
     Executable section
4000
 
4001
`A'
4002
     Allocatable section
4003
 
4004
`I'
4005
     Initialized section
4006
 
4007
`L'
4008
     Same as `I'
4009
 
4010
`!'
4011
     Invert the sense of any of the attributes that follow
4012
 
4013
   If a unmapped section matches any of the listed attributes other than
4014
`!', it will be placed in the memory region.  The `!' attribute
4015
reverses this test, so that an unmapped section will be placed in the
4016
memory region only if it does not match any of the listed attributes.
4017
 
4018
   The ORIGIN is an numerical expression for the start address of the
4019
memory region.  The expression must evaluate to a constant and it
4020
cannot involve any symbols.  The keyword `ORIGIN' may be abbreviated to
4021
`org' or `o' (but not, for example, `ORG').
4022
 
4023
   The LEN is an expression for the size in bytes of the memory region.
4024
As with the ORIGIN expression, the expression must be numerical only
4025
and must evaluate to a constant.  The keyword `LENGTH' may be
4026
abbreviated to `len' or `l'.
4027
 
4028
   In the following example, we specify that there are two memory
4029
regions available for allocation: one starting at `0' for 256 kilobytes,
4030
and the other starting at `0x40000000' for four megabytes.  The linker
4031
will place into the `rom' memory region every section which is not
4032
explicitly mapped into a memory region, and is either read-only or
4033
executable.  The linker will place other sections which are not
4034
explicitly mapped into a memory region into the `ram' memory region.
4035
 
4036
     MEMORY
4037
       {
4038
         rom (rx)  : ORIGIN = 0, LENGTH = 256K
4039
         ram (!rx) : org = 0x40000000, l = 4M
4040
       }
4041
 
4042
   Once you define a memory region, you can direct the linker to place
4043
specific output sections into that memory region by using the `>REGION'
4044
output section attribute.  For example, if you have a memory region
4045
named `mem', you would use `>mem' in the output section definition.
4046
*Note Output Section Region::.  If no address was specified for the
4047
output section, the linker will set the address to the next available
4048
address within the memory region.  If the combined output sections
4049
directed to a memory region are too large for the region, the linker
4050
will issue an error message.
4051
 
4052
   It is possible to access the origin and length of a memory in an
4053
expression via the `ORIGIN(MEMORY)' and `LENGTH(MEMORY)' functions:
4054
 
4055
       _fstack = ORIGIN(ram) + LENGTH(ram) - 4;
4056
 
4057

4058
File: ld.info,  Node: PHDRS,  Next: VERSION,  Prev: MEMORY,  Up: Scripts
4059
 
4060
3.8 PHDRS Command
4061
=================
4062
 
4063
The ELF object file format uses "program headers", also knows as
4064
"segments".  The program headers describe how the program should be
4065
loaded into memory.  You can print them out by using the `objdump'
4066
program with the `-p' option.
4067
 
4068
   When you run an ELF program on a native ELF system, the system loader
4069
reads the program headers in order to figure out how to load the
4070
program.  This will only work if the program headers are set correctly.
4071
This manual does not describe the details of how the system loader
4072
interprets program headers; for more information, see the ELF ABI.
4073
 
4074
   The linker will create reasonable program headers by default.
4075
However, in some cases, you may need to specify the program headers more
4076
precisely.  You may use the `PHDRS' command for this purpose.  When the
4077
linker sees the `PHDRS' command in the linker script, it will not
4078
create any program headers other than the ones specified.
4079
 
4080
   The linker only pays attention to the `PHDRS' command when
4081
generating an ELF output file.  In other cases, the linker will simply
4082
ignore `PHDRS'.
4083
 
4084
   This is the syntax of the `PHDRS' command.  The words `PHDRS',
4085
`FILEHDR', `AT', and `FLAGS' are keywords.
4086
 
4087
     PHDRS
4088
     {
4089
       NAME TYPE [ FILEHDR ] [ PHDRS ] [ AT ( ADDRESS ) ]
4090
             [ FLAGS ( FLAGS ) ] ;
4091
     }
4092
 
4093
   The NAME is used only for reference in the `SECTIONS' command of the
4094
linker script.  It is not put into the output file.  Program header
4095
names are stored in a separate name space, and will not conflict with
4096
symbol names, file names, or section names.  Each program header must
4097
have a distinct name.  The headers are processed in order and it is
4098
usual for them to map to sections in ascending load address order.
4099
 
4100
   Certain program header types describe segments of memory which the
4101
system loader will load from the file.  In the linker script, you
4102
specify the contents of these segments by placing allocatable output
4103
sections in the segments.  You use the `:PHDR' output section attribute
4104
to place a section in a particular segment.  *Note Output Section
4105
Phdr::.
4106
 
4107
   It is normal to put certain sections in more than one segment.  This
4108
merely implies that one segment of memory contains another.  You may
4109
repeat `:PHDR', using it once for each segment which should contain the
4110
section.
4111
 
4112
   If you place a section in one or more segments using `:PHDR', then
4113
the linker will place all subsequent allocatable sections which do not
4114
specify `:PHDR' in the same segments.  This is for convenience, since
4115
generally a whole set of contiguous sections will be placed in a single
4116
segment.  You can use `:NONE' to override the default segment and tell
4117
the linker to not put the section in any segment at all.
4118
 
4119
   You may use the `FILEHDR' and `PHDRS' keywords after the program
4120
header type to further describe the contents of the segment.  The
4121
`FILEHDR' keyword means that the segment should include the ELF file
4122
header.  The `PHDRS' keyword means that the segment should include the
4123
ELF program headers themselves.  If applied to a loadable segment
4124
(`PT_LOAD'), all prior loadable segments must have one of these
4125
keywords.
4126
 
4127
   The TYPE may be one of the following.  The numbers indicate the
4128
value of the keyword.
4129
 
4130
`PT_NULL' (0)
4131
     Indicates an unused program header.
4132
 
4133
`PT_LOAD' (1)
4134
     Indicates that this program header describes a segment to be
4135
     loaded from the file.
4136
 
4137
`PT_DYNAMIC' (2)
4138
     Indicates a segment where dynamic linking information can be found.
4139
 
4140
`PT_INTERP' (3)
4141
     Indicates a segment where the name of the program interpreter may
4142
     be found.
4143
 
4144
`PT_NOTE' (4)
4145
     Indicates a segment holding note information.
4146
 
4147
`PT_SHLIB' (5)
4148
     A reserved program header type, defined but not specified by the
4149
     ELF ABI.
4150
 
4151
`PT_PHDR' (6)
4152
     Indicates a segment where the program headers may be found.
4153
 
4154
EXPRESSION
4155
     An expression giving the numeric type of the program header.  This
4156
     may be used for types not defined above.
4157
 
4158
   You can specify that a segment should be loaded at a particular
4159
address in memory by using an `AT' expression.  This is identical to the
4160
`AT' command used as an output section attribute (*note Output Section
4161
LMA::).  The `AT' command for a program header overrides the output
4162
section attribute.
4163
 
4164
   The linker will normally set the segment flags based on the sections
4165
which comprise the segment.  You may use the `FLAGS' keyword to
4166
explicitly specify the segment flags.  The value of FLAGS must be an
4167
integer.  It is used to set the `p_flags' field of the program header.
4168
 
4169
   Here is an example of `PHDRS'.  This shows a typical set of program
4170
headers used on a native ELF system.
4171
 
4172
     PHDRS
4173
     {
4174
       headers PT_PHDR PHDRS ;
4175
       interp PT_INTERP ;
4176
       text PT_LOAD FILEHDR PHDRS ;
4177
       data PT_LOAD ;
4178
       dynamic PT_DYNAMIC ;
4179
     }
4180
 
4181
     SECTIONS
4182
     {
4183
       . = SIZEOF_HEADERS;
4184
       .interp : { *(.interp) } :text :interp
4185
       .text : { *(.text) } :text
4186
       .rodata : { *(.rodata) } /* defaults to :text */
4187
       ...
4188
       . = . + 0x1000; /* move to a new page in memory */
4189
       .data : { *(.data) } :data
4190
       .dynamic : { *(.dynamic) } :data :dynamic
4191
       ...
4192
     }
4193
 
4194

4195
File: ld.info,  Node: VERSION,  Next: Expressions,  Prev: PHDRS,  Up: Scripts
4196
 
4197
3.9 VERSION Command
4198
===================
4199
 
4200
The linker supports symbol versions when using ELF.  Symbol versions are
4201
only useful when using shared libraries.  The dynamic linker can use
4202
symbol versions to select a specific version of a function when it runs
4203
a program that may have been linked against an earlier version of the
4204
shared library.
4205
 
4206
   You can include a version script directly in the main linker script,
4207
or you can supply the version script as an implicit linker script.  You
4208
can also use the `--version-script' linker option.
4209
 
4210
   The syntax of the `VERSION' command is simply
4211
     VERSION { version-script-commands }
4212
 
4213
   The format of the version script commands is identical to that used
4214
by Sun's linker in Solaris 2.5.  The version script defines a tree of
4215
version nodes.  You specify the node names and interdependencies in the
4216
version script.  You can specify which symbols are bound to which
4217
version nodes, and you can reduce a specified set of symbols to local
4218
scope so that they are not globally visible outside of the shared
4219
library.
4220
 
4221
   The easiest way to demonstrate the version script language is with a
4222
few examples.
4223
 
4224
     VERS_1.1 {
4225
         global:
4226
                 foo1;
4227
         local:
4228
                 old*;
4229
                 original*;
4230
                 new*;
4231
     };
4232
 
4233
     VERS_1.2 {
4234
                 foo2;
4235
     } VERS_1.1;
4236
 
4237
     VERS_2.0 {
4238
                 bar1; bar2;
4239
         extern "C++" {
4240
                 ns::*;
4241
                 "f(int, double)";
4242
         };
4243
     } VERS_1.2;
4244
 
4245
   This example version script defines three version nodes.  The first
4246
version node defined is `VERS_1.1'; it has no other dependencies.  The
4247
script binds the symbol `foo1' to `VERS_1.1'.  It reduces a number of
4248
symbols to local scope so that they are not visible outside of the
4249
shared library; this is done using wildcard patterns, so that any
4250
symbol whose name begins with `old', `original', or `new' is matched.
4251
The wildcard patterns available are the same as those used in the shell
4252
when matching filenames (also known as "globbing").  However, if you
4253
specify the symbol name inside double quotes, then the name is treated
4254
as literal, rather than as a glob pattern.
4255
 
4256
   Next, the version script defines node `VERS_1.2'.  This node depends
4257
upon `VERS_1.1'.  The script binds the symbol `foo2' to the version
4258
node `VERS_1.2'.
4259
 
4260
   Finally, the version script defines node `VERS_2.0'.  This node
4261
depends upon `VERS_1.2'.  The scripts binds the symbols `bar1' and
4262
`bar2' are bound to the version node `VERS_2.0'.
4263
 
4264
   When the linker finds a symbol defined in a library which is not
4265
specifically bound to a version node, it will effectively bind it to an
4266
unspecified base version of the library.  You can bind all otherwise
4267
unspecified symbols to a given version node by using `global: *;'
4268
somewhere in the version script.  Note that it's slightly crazy to use
4269
wildcards in a global spec except on the last version node.  Global
4270
wildcards elsewhere run the risk of accidentally adding symbols to the
4271
set exported for an old version.  That's wrong since older versions
4272
ought to have a fixed set of symbols.
4273
 
4274
   The names of the version nodes have no specific meaning other than
4275
what they might suggest to the person reading them.  The `2.0' version
4276
could just as well have appeared in between `1.1' and `1.2'.  However,
4277
this would be a confusing way to write a version script.
4278
 
4279
   Node name can be omitted, provided it is the only version node in
4280
the version script.  Such version script doesn't assign any versions to
4281
symbols, only selects which symbols will be globally visible out and
4282
which won't.
4283
 
4284
     { global: foo; bar; local: *; };
4285
 
4286
   When you link an application against a shared library that has
4287
versioned symbols, the application itself knows which version of each
4288
symbol it requires, and it also knows which version nodes it needs from
4289
each shared library it is linked against.  Thus at runtime, the dynamic
4290
loader can make a quick check to make sure that the libraries you have
4291
linked against do in fact supply all of the version nodes that the
4292
application will need to resolve all of the dynamic symbols.  In this
4293
way it is possible for the dynamic linker to know with certainty that
4294
all external symbols that it needs will be resolvable without having to
4295
search for each symbol reference.
4296
 
4297
   The symbol versioning is in effect a much more sophisticated way of
4298
doing minor version checking that SunOS does.  The fundamental problem
4299
that is being addressed here is that typically references to external
4300
functions are bound on an as-needed basis, and are not all bound when
4301
the application starts up.  If a shared library is out of date, a
4302
required interface may be missing; when the application tries to use
4303
that interface, it may suddenly and unexpectedly fail.  With symbol
4304
versioning, the user will get a warning when they start their program if
4305
the libraries being used with the application are too old.
4306
 
4307
   There are several GNU extensions to Sun's versioning approach.  The
4308
first of these is the ability to bind a symbol to a version node in the
4309
source file where the symbol is defined instead of in the versioning
4310
script.  This was done mainly to reduce the burden on the library
4311
maintainer.  You can do this by putting something like:
4312
     __asm__(".symver original_foo,foo@VERS_1.1");
4313
   in the C source file.  This renames the function `original_foo' to
4314
be an alias for `foo' bound to the version node `VERS_1.1'.  The
4315
`local:' directive can be used to prevent the symbol `original_foo'
4316
from being exported. A `.symver' directive takes precedence over a
4317
version script.
4318
 
4319
   The second GNU extension is to allow multiple versions of the same
4320
function to appear in a given shared library.  In this way you can make
4321
an incompatible change to an interface without increasing the major
4322
version number of the shared library, while still allowing applications
4323
linked against the old interface to continue to function.
4324
 
4325
   To do this, you must use multiple `.symver' directives in the source
4326
file.  Here is an example:
4327
 
4328
     __asm__(".symver original_foo,foo@");
4329
     __asm__(".symver old_foo,foo@VERS_1.1");
4330
     __asm__(".symver old_foo1,foo@VERS_1.2");
4331
     __asm__(".symver new_foo,foo@@VERS_2.0");
4332
 
4333
   In this example, `foo@' represents the symbol `foo' bound to the
4334
unspecified base version of the symbol.  The source file that contains
4335
this example would define 4 C functions: `original_foo', `old_foo',
4336
`old_foo1', and `new_foo'.
4337
 
4338
   When you have multiple definitions of a given symbol, there needs to
4339
be some way to specify a default version to which external references to
4340
this symbol will be bound.  You can do this with the `foo@@VERS_2.0'
4341
type of `.symver' directive.  You can only declare one version of a
4342
symbol as the default in this manner; otherwise you would effectively
4343
have multiple definitions of the same symbol.
4344
 
4345
   If you wish to bind a reference to a specific version of the symbol
4346
within the shared library, you can use the aliases of convenience
4347
(i.e., `old_foo'), or you can use the `.symver' directive to
4348
specifically bind to an external version of the function in question.
4349
 
4350
   You can also specify the language in the version script:
4351
 
4352
     VERSION extern "lang" { version-script-commands }
4353
 
4354
   The supported `lang's are `C', `C++', and `Java'.  The linker will
4355
iterate over the list of symbols at the link time and demangle them
4356
according to `lang' before matching them to the patterns specified in
4357
`version-script-commands'.  The default `lang' is `C'.
4358
 
4359
   Demangled names may contains spaces and other special characters.  As
4360
described above, you can use a glob pattern to match demangled names,
4361
or you can use a double-quoted string to match the string exactly.  In
4362
the latter case, be aware that minor differences (such as differing
4363
whitespace) between the version script and the demangler output will
4364
cause a mismatch.  As the exact string generated by the demangler might
4365
change in the future, even if the mangled name does not, you should
4366
check that all of your version directives are behaving as you expect
4367
when you upgrade.
4368
 
4369

4370
File: ld.info,  Node: Expressions,  Next: Implicit Linker Scripts,  Prev: VERSION,  Up: Scripts
4371
 
4372
3.10 Expressions in Linker Scripts
4373
==================================
4374
 
4375
The syntax for expressions in the linker script language is identical to
4376
that of C expressions.  All expressions are evaluated as integers.  All
4377
expressions are evaluated in the same size, which is 32 bits if both the
4378
host and target are 32 bits, and is otherwise 64 bits.
4379
 
4380
   You can use and set symbol values in expressions.
4381
 
4382
   The linker defines several special purpose builtin functions for use
4383
in expressions.
4384
 
4385
* Menu:
4386
 
4387
* Constants::                   Constants
4388
* Symbolic Constants::          Symbolic constants
4389
* Symbols::                     Symbol Names
4390
* Orphan Sections::             Orphan Sections
4391
* Location Counter::            The Location Counter
4392
* Operators::                   Operators
4393
* Evaluation::                  Evaluation
4394
* Expression Section::          The Section of an Expression
4395
* Builtin Functions::           Builtin Functions
4396
 
4397

4398
File: ld.info,  Node: Constants,  Next: Symbolic Constants,  Up: Expressions
4399
 
4400
3.10.1 Constants
4401
----------------
4402
 
4403
All constants are integers.
4404
 
4405
   As in C, the linker considers an integer beginning with `0' to be
4406
octal, and an integer beginning with `0x' or `0X' to be hexadecimal.
4407
Alternatively the linker accepts suffixes of `h' or `H' for
4408
hexadecimal, `o' or `O' for octal, `b' or `B' for binary and `d' or `D'
4409
for decimal.  Any integer value without a prefix or a suffix is
4410
considered to be decimal.
4411
 
4412
   In addition, you can use the suffixes `K' and `M' to scale a
4413
constant by `1024' or `1024*1024' respectively.  For example, the
4414
following all refer to the same quantity:
4415
 
4416
     _fourk_1 = 4K;
4417
     _fourk_2 = 4096;
4418
     _fourk_3 = 0x1000;
4419
     _fourk_4 = 10000o;
4420
 
4421
   Note - the `K' and `M' suffixes cannot be used in conjunction with
4422
the base suffixes mentioned above.
4423
 
4424

4425
File: ld.info,  Node: Symbolic Constants,  Next: Symbols,  Prev: Constants,  Up: Expressions
4426
 
4427
3.10.2 Symbolic Constants
4428
-------------------------
4429
 
4430
It is possible to refer to target specific constants via the use of the
4431
`CONSTANT(NAME)' operator, where NAME is one of:
4432
 
4433
`MAXPAGESIZE'
4434
     The target's maximum page size.
4435
 
4436
`COMMONPAGESIZE'
4437
     The target's default page size.
4438
 
4439
   So for example:
4440
 
4441
       .text ALIGN (CONSTANT (MAXPAGESIZE)) : { *(.text) }
4442
 
4443
   will create a text section aligned to the largest page boundary
4444
supported by the target.
4445
 
4446

4447
File: ld.info,  Node: Symbols,  Next: Orphan Sections,  Prev: Symbolic Constants,  Up: Expressions
4448
 
4449
3.10.3 Symbol Names
4450
-------------------
4451
 
4452
Unless quoted, symbol names start with a letter, underscore, or period
4453
and may include letters, digits, underscores, periods, and hyphens.
4454
Unquoted symbol names must not conflict with any keywords.  You can
4455
specify a symbol which contains odd characters or has the same name as a
4456
keyword by surrounding the symbol name in double quotes:
4457
     "SECTION" = 9;
4458
     "with a space" = "also with a space" + 10;
4459
 
4460
   Since symbols can contain many non-alphabetic characters, it is
4461
safest to delimit symbols with spaces.  For example, `A-B' is one
4462
symbol, whereas `A - B' is an expression involving subtraction.
4463
 
4464

4465
File: ld.info,  Node: Orphan Sections,  Next: Location Counter,  Prev: Symbols,  Up: Expressions
4466
 
4467
3.10.4 Orphan Sections
4468
----------------------
4469
 
4470
Orphan sections are sections present in the input files which are not
4471
explicitly placed into the output file by the linker script.  The
4472
linker will still copy these sections into the output file, but it has
4473
to guess as to where they should be placed.  The linker uses a simple
4474
heuristic to do this.  It attempts to place orphan sections after
4475
non-orphan sections of the same attribute, such as code vs data,
4476
loadable vs non-loadable, etc.  If there is not enough room to do this
4477
then it places at the end of the file.
4478
 
4479
   For ELF targets, the attribute of the section includes section type
4480
as well as section flag.
4481
 
4482
   If an orphaned section's name is representable as a C identifier then
4483
the linker will automatically *note PROVIDE:: two symbols:
4484
__start_SECNAME and __stop_SECNAME, where SECNAME is the name of the
4485
section.  These indicate the start address and end address of the
4486
orphaned section respectively.  Note: most section names are not
4487
representable as C identifiers because they contain a `.' character.
4488
 
4489

4490
File: ld.info,  Node: Location Counter,  Next: Operators,  Prev: Orphan Sections,  Up: Expressions
4491
 
4492
3.10.5 The Location Counter
4493
---------------------------
4494
 
4495
The special linker variable "dot" `.' always contains the current
4496
output location counter.  Since the `.' always refers to a location in
4497
an output section, it may only appear in an expression within a
4498
`SECTIONS' command.  The `.' symbol may appear anywhere that an
4499
ordinary symbol is allowed in an expression.
4500
 
4501
   Assigning a value to `.' will cause the location counter to be
4502
moved.  This may be used to create holes in the output section.  The
4503
location counter may not be moved backwards inside an output section,
4504
and may not be moved backwards outside of an output section if so doing
4505
creates areas with overlapping LMAs.
4506
 
4507
     SECTIONS
4508
     {
4509
       output :
4510
         {
4511
           file1(.text)
4512
           . = . + 1000;
4513
           file2(.text)
4514
           . += 1000;
4515
           file3(.text)
4516
         } = 0x12345678;
4517
     }
4518
   In the previous example, the `.text' section from `file1' is located
4519
at the beginning of the output section `output'.  It is followed by a
4520
1000 byte gap.  Then the `.text' section from `file2' appears, also
4521
with a 1000 byte gap following before the `.text' section from `file3'.
4522
The notation `= 0x12345678' specifies what data to write in the gaps
4523
(*note Output Section Fill::).
4524
 
4525
   Note: `.' actually refers to the byte offset from the start of the
4526
current containing object.  Normally this is the `SECTIONS' statement,
4527
whose start address is 0, hence `.' can be used as an absolute address.
4528
If `.' is used inside a section description however, it refers to the
4529
byte offset from the start of that section, not an absolute address.
4530
Thus in a script like this:
4531
 
4532
     SECTIONS
4533
     {
4534
         . = 0x100
4535
         .text: {
4536
           *(.text)
4537
           . = 0x200
4538
         }
4539
         . = 0x500
4540
         .data: {
4541
           *(.data)
4542
           . += 0x600
4543
         }
4544
     }
4545
 
4546
   The `.text' section will be assigned a starting address of 0x100 and
4547
a size of exactly 0x200 bytes, even if there is not enough data in the
4548
`.text' input sections to fill this area.  (If there is too much data,
4549
an error will be produced because this would be an attempt to move `.'
4550
backwards).  The `.data' section will start at 0x500 and it will have
4551
an extra 0x600 bytes worth of space after the end of the values from
4552
the `.data' input sections and before the end of the `.data' output
4553
section itself.
4554
 
4555
   Setting symbols to the value of the location counter outside of an
4556
output section statement can result in unexpected values if the linker
4557
needs to place orphan sections.  For example, given the following:
4558
 
4559
     SECTIONS
4560
     {
4561
         start_of_text = . ;
4562
         .text: { *(.text) }
4563
         end_of_text = . ;
4564
 
4565
         start_of_data = . ;
4566
         .data: { *(.data) }
4567
         end_of_data = . ;
4568
     }
4569
 
4570
   If the linker needs to place some input section, e.g. `.rodata', not
4571
mentioned in the script, it might choose to place that section between
4572
`.text' and `.data'.  You might think the linker should place `.rodata'
4573
on the blank line in the above script, but blank lines are of no
4574
particular significance to the linker.  As well, the linker doesn't
4575
associate the above symbol names with their sections.  Instead, it
4576
assumes that all assignments or other statements belong to the previous
4577
output section, except for the special case of an assignment to `.'.
4578
I.e., the linker will place the orphan `.rodata' section as if the
4579
script was written as follows:
4580
 
4581
     SECTIONS
4582
     {
4583
         start_of_text = . ;
4584
         .text: { *(.text) }
4585
         end_of_text = . ;
4586
 
4587
         start_of_data = . ;
4588
         .rodata: { *(.rodata) }
4589
         .data: { *(.data) }
4590
         end_of_data = . ;
4591
     }
4592
 
4593
   This may or may not be the script author's intention for the value of
4594
`start_of_data'.  One way to influence the orphan section placement is
4595
to assign the location counter to itself, as the linker assumes that an
4596
assignment to `.' is setting the start address of a following output
4597
section and thus should be grouped with that section.  So you could
4598
write:
4599
 
4600
     SECTIONS
4601
     {
4602
         start_of_text = . ;
4603
         .text: { *(.text) }
4604
         end_of_text = . ;
4605
 
4606
         . = . ;
4607
         start_of_data = . ;
4608
         .data: { *(.data) }
4609
         end_of_data = . ;
4610
     }
4611
 
4612
   Now, the orphan `.rodata' section will be placed between
4613
`end_of_text' and `start_of_data'.
4614
 
4615

4616
File: ld.info,  Node: Operators,  Next: Evaluation,  Prev: Location Counter,  Up: Expressions
4617
 
4618
3.10.6 Operators
4619
----------------
4620
 
4621
The linker recognizes the standard C set of arithmetic operators, with
4622
the standard bindings and precedence levels:
4623
     precedence      associativity   Operators                Notes
4624
     (highest)
4625
     1               left            !  -  ~                  (1)
4626
     2               left            *  /  %
4627
     3               left            +  -
4628
     4               left            >>  <<
4629
     5               left            ==  !=  >  <  <=  >=
4630
     6               left            &
4631
     7               left            |
4632
     8               left            &&
4633
     9               left            ||
4634
     10              right           ? :
4635
     11              right           &=  +=  -=  *=  /=       (2)
4636
     (lowest)
4637
   Notes: (1) Prefix operators (2) *Note Assignments::.
4638
 
4639

4640
File: ld.info,  Node: Evaluation,  Next: Expression Section,  Prev: Operators,  Up: Expressions
4641
 
4642
3.10.7 Evaluation
4643
-----------------
4644
 
4645
The linker evaluates expressions lazily.  It only computes the value of
4646
an expression when absolutely necessary.
4647
 
4648
   The linker needs some information, such as the value of the start
4649
address of the first section, and the origins and lengths of memory
4650
regions, in order to do any linking at all.  These values are computed
4651
as soon as possible when the linker reads in the linker script.
4652
 
4653
   However, other values (such as symbol values) are not known or needed
4654
until after storage allocation.  Such values are evaluated later, when
4655
other information (such as the sizes of output sections) is available
4656
for use in the symbol assignment expression.
4657
 
4658
   The sizes of sections cannot be known until after allocation, so
4659
assignments dependent upon these are not performed until after
4660
allocation.
4661
 
4662
   Some expressions, such as those depending upon the location counter
4663
`.', must be evaluated during section allocation.
4664
 
4665
   If the result of an expression is required, but the value is not
4666
available, then an error results.  For example, a script like the
4667
following
4668
     SECTIONS
4669
       {
4670
         .text 9+this_isnt_constant :
4671
           { *(.text) }
4672
       }
4673
will cause the error message `non constant expression for initial
4674
address'.
4675
 
4676

4677
File: ld.info,  Node: Expression Section,  Next: Builtin Functions,  Prev: Evaluation,  Up: Expressions
4678
 
4679
3.10.8 The Section of an Expression
4680
-----------------------------------
4681
 
4682
Addresses and symbols may be section relative, or absolute.  A section
4683
relative symbol is relocatable.  If you request relocatable output
4684
using the `-r' option, a further link operation may change the value of
4685
a section relative symbol.  On the other hand, an absolute symbol will
4686
retain the same value throughout any further link operations.
4687
 
4688
   Some terms in linker expressions are addresses.  This is true of
4689
section relative symbols and for builtin functions that return an
4690
address, such as `ADDR', `LOADADDR', `ORIGIN' and `SEGMENT_START'.
4691
Other terms are simply numbers, or are builtin functions that return a
4692
non-address value, such as `LENGTH'.  One complication is that unless
4693
you set `LD_FEATURE ("SANE_EXPR")' (*note Miscellaneous Commands::),
4694
numbers and absolute symbols are treated differently depending on their
4695
location, for compatibility with older versions of `ld'.  Expressions
4696
appearing outside an output section definition treat all numbers as
4697
absolute addresses.  Expressions appearing inside an output section
4698
definition treat absolute symbols as numbers.  If `LD_FEATURE
4699
("SANE_EXPR")' is given, then absolute symbols and numbers are simply
4700
treated as numbers everywhere.
4701
 
4702
   In the following simple example,
4703
 
4704
     SECTIONS
4705
       {
4706
         . = 0x100;
4707
         __executable_start = 0x100;
4708
         .data :
4709
         {
4710
           . = 0x10;
4711
           __data_start = 0x10;
4712
           *(.data)
4713
         }
4714
         ...
4715
       }
4716
 
4717
   both `.' and `__executable_start' are set to the absolute address
4718
0x100 in the first two assignments, then both `.' and `__data_start'
4719
are set to 0x10 relative to the `.data' section in the second two
4720
assignments.
4721
 
4722
   For expressions involving numbers, relative addresses and absolute
4723
addresses, ld follows these rules to evaluate terms:
4724
 
4725
   * Unary operations on an absolute address or number, and binary
4726
     operations on two absolute addresses or two numbers, or between one
4727
     absolute address and a number, apply the operator to the value(s).
4728
 
4729
   * Unary operations on a relative address, and binary operations on
4730
     two relative addresses in the same section or between one relative
4731
     address and a number, apply the operator to the offset part of the
4732
     address(es).
4733
 
4734
   * Other binary operations, that is, between two relative addresses
4735
     not in the same section, or between a relative address and an
4736
     absolute address, first convert any non-absolute term to an
4737
     absolute address before applying the operator.
4738
 
4739
   The result section of each sub-expression is as follows:
4740
 
4741
   * An operation involving only numbers results in a number.
4742
 
4743
   * The result of comparisons, `&&' and `||' is also a number.
4744
 
4745
   * The result of other binary arithmetic and logical operations on two
4746
     relative addresses in the same section or two absolute addresses
4747
     (after above conversions) is also a number.
4748
 
4749
   * The result of other operations on relative addresses or one
4750
     relative address and a number, is a relative address in the same
4751
     section as the relative operand(s).
4752
 
4753
   * The result of other operations on absolute addresses (after above
4754
     conversions) is an absolute address.
4755
 
4756
   You can use the builtin function `ABSOLUTE' to force an expression
4757
to be absolute when it would otherwise be relative.  For example, to
4758
create an absolute symbol set to the address of the end of the output
4759
section `.data':
4760
     SECTIONS
4761
       {
4762
         .data : { *(.data) _edata = ABSOLUTE(.); }
4763
       }
4764
   If `ABSOLUTE' were not used, `_edata' would be relative to the
4765
`.data' section.
4766
 
4767
   Using `LOADADDR' also forces an expression absolute, since this
4768
particular builtin function returns an absolute address.
4769
 
4770

4771
File: ld.info,  Node: Builtin Functions,  Prev: Expression Section,  Up: Expressions
4772
 
4773
3.10.9 Builtin Functions
4774
------------------------
4775
 
4776
The linker script language includes a number of builtin functions for
4777
use in linker script expressions.
4778
 
4779
`ABSOLUTE(EXP)'
4780
     Return the absolute (non-relocatable, as opposed to non-negative)
4781
     value of the expression EXP.  Primarily useful to assign an
4782
     absolute value to a symbol within a section definition, where
4783
     symbol values are normally section relative.  *Note Expression
4784
     Section::.
4785
 
4786
`ADDR(SECTION)'
4787
     Return the address (VMA) of the named SECTION.  Your script must
4788
     previously have defined the location of that section.  In the
4789
     following example, `start_of_output_1', `symbol_1' and `symbol_2'
4790
     are assigned equivalent values, except that `symbol_1' will be
4791
     relative to the `.output1' section while the other two will be
4792
     absolute:
4793
          SECTIONS { ...
4794
            .output1 :
4795
              {
4796
              start_of_output_1 = ABSOLUTE(.);
4797
              ...
4798
              }
4799
            .output :
4800
              {
4801
              symbol_1 = ADDR(.output1);
4802
              symbol_2 = start_of_output_1;
4803
              }
4804
          ... }
4805
 
4806
`ALIGN(ALIGN)'
4807
`ALIGN(EXP,ALIGN)'
4808
     Return the location counter (`.') or arbitrary expression aligned
4809
     to the next ALIGN boundary.  The single operand `ALIGN' doesn't
4810
     change the value of the location counter--it just does arithmetic
4811
     on it.  The two operand `ALIGN' allows an arbitrary expression to
4812
     be aligned upwards (`ALIGN(ALIGN)' is equivalent to `ALIGN(.,
4813
     ALIGN)').
4814
 
4815
     Here is an example which aligns the output `.data' section to the
4816
     next `0x2000' byte boundary after the preceding section and sets a
4817
     variable within the section to the next `0x8000' boundary after the
4818
     input sections:
4819
          SECTIONS { ...
4820
            .data ALIGN(0x2000): {
4821
              *(.data)
4822
              variable = ALIGN(0x8000);
4823
            }
4824
          ... }
4825
     The first use of `ALIGN' in this example specifies the location of
4826
     a section because it is used as the optional ADDRESS attribute of
4827
     a section definition (*note Output Section Address::).  The second
4828
     use of `ALIGN' is used to defines the value of a symbol.
4829
 
4830
     The builtin function `NEXT' is closely related to `ALIGN'.
4831
 
4832
`ALIGNOF(SECTION)'
4833
     Return the alignment in bytes of the named SECTION, if that
4834
     section has been allocated.  If the section has not been allocated
4835
     when this is evaluated, the linker will report an error. In the
4836
     following example, the alignment of the `.output' section is
4837
     stored as the first value in that section.
4838
          SECTIONS{ ...
4839
            .output {
4840
              LONG (ALIGNOF (.output))
4841
              ...
4842
              }
4843
          ... }
4844
 
4845
`BLOCK(EXP)'
4846
     This is a synonym for `ALIGN', for compatibility with older linker
4847
     scripts.  It is most often seen when setting the address of an
4848
     output section.
4849
 
4850
`DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE)'
4851
     This is equivalent to either
4852
          (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - 1)))
4853
     or
4854
          (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - COMMONPAGESIZE)))
4855
     depending on whether the latter uses fewer COMMONPAGESIZE sized
4856
     pages for the data segment (area between the result of this
4857
     expression and `DATA_SEGMENT_END') than the former or not.  If the
4858
     latter form is used, it means COMMONPAGESIZE bytes of runtime
4859
     memory will be saved at the expense of up to COMMONPAGESIZE wasted
4860
     bytes in the on-disk file.
4861
 
4862
     This expression can only be used directly in `SECTIONS' commands,
4863
     not in any output section descriptions and only once in the linker
4864
     script.  COMMONPAGESIZE should be less or equal to MAXPAGESIZE and
4865
     should be the system page size the object wants to be optimized
4866
     for (while still working on system page sizes up to MAXPAGESIZE).
4867
 
4868
     Example:
4869
            . = DATA_SEGMENT_ALIGN(0x10000, 0x2000);
4870
 
4871
`DATA_SEGMENT_END(EXP)'
4872
     This defines the end of data segment for `DATA_SEGMENT_ALIGN'
4873
     evaluation purposes.
4874
 
4875
            . = DATA_SEGMENT_END(.);
4876
 
4877
`DATA_SEGMENT_RELRO_END(OFFSET, EXP)'
4878
     This defines the end of the `PT_GNU_RELRO' segment when `-z relro'
4879
     option is used.  Second argument is returned.  When `-z relro'
4880
     option is not present, `DATA_SEGMENT_RELRO_END' does nothing,
4881
     otherwise `DATA_SEGMENT_ALIGN' is padded so that EXP + OFFSET is
4882
     aligned to the most commonly used page boundary for particular
4883
     target.  If present in the linker script, it must always come in
4884
     between `DATA_SEGMENT_ALIGN' and `DATA_SEGMENT_END'.
4885
 
4886
            . = DATA_SEGMENT_RELRO_END(24, .);
4887
 
4888
`DEFINED(SYMBOL)'
4889
     Return 1 if SYMBOL is in the linker global symbol table and is
4890
     defined before the statement using DEFINED in the script, otherwise
4891
     return 0.  You can use this function to provide default values for
4892
     symbols.  For example, the following script fragment shows how to
4893
     set a global symbol `begin' to the first location in the `.text'
4894
     section--but if a symbol called `begin' already existed, its value
4895
     is preserved:
4896
 
4897
          SECTIONS { ...
4898
            .text : {
4899
              begin = DEFINED(begin) ? begin : . ;
4900
              ...
4901
            }
4902
            ...
4903
          }
4904
 
4905
`LENGTH(MEMORY)'
4906
     Return the length of the memory region named MEMORY.
4907
 
4908
`LOADADDR(SECTION)'
4909
     Return the absolute LMA of the named SECTION.  (*note Output
4910
     Section LMA::).
4911
 
4912
`MAX(EXP1, EXP2)'
4913
     Returns the maximum of EXP1 and EXP2.
4914
 
4915
`MIN(EXP1, EXP2)'
4916
     Returns the minimum of EXP1 and EXP2.
4917
 
4918
`NEXT(EXP)'
4919
     Return the next unallocated address that is a multiple of EXP.
4920
     This function is closely related to `ALIGN(EXP)'; unless you use
4921
     the `MEMORY' command to define discontinuous memory for the output
4922
     file, the two functions are equivalent.
4923
 
4924
`ORIGIN(MEMORY)'
4925
     Return the origin of the memory region named MEMORY.
4926
 
4927
`SEGMENT_START(SEGMENT, DEFAULT)'
4928
     Return the base address of the named SEGMENT.  If an explicit
4929
     value has been given for this segment (with a command-line `-T'
4930
     option) that value will be returned; otherwise the value will be
4931
     DEFAULT.  At present, the `-T' command-line option can only be
4932
     used to set the base address for the "text", "data", and "bss"
4933
     sections, but you can use `SEGMENT_START' with any segment name.
4934
 
4935
`SIZEOF(SECTION)'
4936
     Return the size in bytes of the named SECTION, if that section has
4937
     been allocated.  If the section has not been allocated when this is
4938
     evaluated, the linker will report an error.  In the following
4939
     example, `symbol_1' and `symbol_2' are assigned identical values:
4940
          SECTIONS{ ...
4941
            .output {
4942
              .start = . ;
4943
              ...
4944
              .end = . ;
4945
              }
4946
            symbol_1 = .end - .start ;
4947
            symbol_2 = SIZEOF(.output);
4948
          ... }
4949
 
4950
`SIZEOF_HEADERS'
4951
`sizeof_headers'
4952
     Return the size in bytes of the output file's headers.  This is
4953
     information which appears at the start of the output file.  You
4954
     can use this number when setting the start address of the first
4955
     section, if you choose, to facilitate paging.
4956
 
4957
     When producing an ELF output file, if the linker script uses the
4958
     `SIZEOF_HEADERS' builtin function, the linker must compute the
4959
     number of program headers before it has determined all the section
4960
     addresses and sizes.  If the linker later discovers that it needs
4961
     additional program headers, it will report an error `not enough
4962
     room for program headers'.  To avoid this error, you must avoid
4963
     using the `SIZEOF_HEADERS' function, or you must rework your linker
4964
     script to avoid forcing the linker to use additional program
4965
     headers, or you must define the program headers yourself using the
4966
     `PHDRS' command (*note PHDRS::).
4967
 
4968

4969
File: ld.info,  Node: Implicit Linker Scripts,  Prev: Expressions,  Up: Scripts
4970
 
4971
3.11 Implicit Linker Scripts
4972
============================
4973
 
4974
If you specify a linker input file which the linker can not recognize as
4975
an object file or an archive file, it will try to read the file as a
4976
linker script.  If the file can not be parsed as a linker script, the
4977
linker will report an error.
4978
 
4979
   An implicit linker script will not replace the default linker script.
4980
 
4981
   Typically an implicit linker script would contain only symbol
4982
assignments, or the `INPUT', `GROUP', or `VERSION' commands.
4983
 
4984
   Any input files read because of an implicit linker script will be
4985
read at the position in the command line where the implicit linker
4986
script was read.  This can affect archive searching.
4987
 
4988

4989
File: ld.info,  Node: Machine Dependent,  Next: BFD,  Prev: Scripts,  Up: Top
4990
 
4991
4 Machine Dependent Features
4992
****************************
4993
 
4994
`ld' has additional features on some platforms; the following sections
4995
describe them.  Machines where `ld' has no additional functionality are
4996
not listed.
4997
 
4998
* Menu:
4999
 
5000
 
5001
* H8/300::                      `ld' and the H8/300
5002
 
5003
* i960::                        `ld' and the Intel 960 family
5004
 
5005
* ARM::                         `ld' and the ARM family
5006
 
5007
* HPPA ELF32::                  `ld' and HPPA 32-bit ELF
5008
 
5009
* M68K::                        `ld' and the Motorola 68K family
5010
 
5011
* MMIX::                        `ld' and MMIX
5012
 
5013
* MSP430::                      `ld' and MSP430
5014
 
5015
* M68HC11/68HC12::              `ld' and the Motorola 68HC11 and 68HC12 families
5016
 
5017
* PowerPC ELF32::               `ld' and PowerPC 32-bit ELF Support
5018
 
5019
* PowerPC64 ELF64::             `ld' and PowerPC64 64-bit ELF Support
5020
 
5021
* SPU ELF::                     `ld' and SPU ELF Support
5022
 
5023
* TI COFF::                     `ld' and TI COFF
5024
 
5025
* WIN32::                       `ld' and WIN32 (cygwin/mingw)
5026
 
5027
* Xtensa::                      `ld' and Xtensa Processors
5028
 
5029

5030
File: ld.info,  Node: H8/300,  Next: i960,  Up: Machine Dependent
5031
 
5032
4.1 `ld' and the H8/300
5033
=======================
5034
 
5035
For the H8/300, `ld' can perform these global optimizations when you
5036
specify the `--relax' command-line option.
5037
 
5038
_relaxing address modes_
5039
     `ld' finds all `jsr' and `jmp' instructions whose targets are
5040
     within eight bits, and turns them into eight-bit program-counter
5041
     relative `bsr' and `bra' instructions, respectively.
5042
 
5043
_synthesizing instructions_
5044
     `ld' finds all `mov.b' instructions which use the sixteen-bit
5045
     absolute address form, but refer to the top page of memory, and
5046
     changes them to use the eight-bit address form.  (That is: the
5047
     linker turns `mov.b `@'AA:16' into `mov.b `@'AA:8' whenever the
5048
     address AA is in the top page of memory).
5049
 
5050
_bit manipulation instructions_
5051
     `ld' finds all bit manipulation instructions like `band, bclr,
5052
     biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst,
5053
     bxor' which use 32 bit and 16 bit absolute address form, but refer
5054
     to the top page of memory, and changes them to use the 8 bit
5055
     address form.  (That is: the linker turns `bset #xx:3,`@'AA:32'
5056
     into `bset #xx:3,`@'AA:8' whenever the address AA is in the top
5057
     page of memory).
5058
 
5059
_system control instructions_
5060
     `ld' finds all `ldc.w, stc.w' instructions which use the 32 bit
5061
     absolute address form, but refer to the top page of memory, and
5062
     changes them to use 16 bit address form.  (That is: the linker
5063
     turns `ldc.w `@'AA:32,ccr' into `ldc.w `@'AA:16,ccr' whenever the
5064
     address AA is in the top page of memory).
5065
 
5066

5067
File: ld.info,  Node: i960,  Next: ARM,  Prev: H8/300,  Up: Machine Dependent
5068
 
5069
4.2 `ld' and the Intel 960 Family
5070
=================================
5071
 
5072
You can use the `-AARCHITECTURE' command line option to specify one of
5073
the two-letter names identifying members of the 960 family; the option
5074
specifies the desired output target, and warns of any incompatible
5075
instructions in the input files.  It also modifies the linker's search
5076
strategy for archive libraries, to support the use of libraries
5077
specific to each particular architecture, by including in the search
5078
loop names suffixed with the string identifying the architecture.
5079
 
5080
   For example, if your `ld' command line included `-ACA' as well as
5081
`-ltry', the linker would look (in its built-in search paths, and in
5082
any paths you specify with `-L') for a library with the names
5083
 
5084
     try
5085
     libtry.a
5086
     tryca
5087
     libtryca.a
5088
 
5089
The first two possibilities would be considered in any event; the last
5090
two are due to the use of `-ACA'.
5091
 
5092
   You can meaningfully use `-A' more than once on a command line, since
5093
the 960 architecture family allows combination of target architectures;
5094
each use will add another pair of name variants to search for when `-l'
5095
specifies a library.
5096
 
5097
   `ld' supports the `--relax' option for the i960 family.  If you
5098
specify `--relax', `ld' finds all `balx' and `calx' instructions whose
5099
targets are within 24 bits, and turns them into 24-bit program-counter
5100
relative `bal' and `cal' instructions, respectively.  `ld' also turns
5101
`cal' instructions into `bal' instructions when it determines that the
5102
target subroutine is a leaf routine (that is, the target subroutine does
5103
not itself call any subroutines).
5104
 
5105
   The `--fix-cortex-a8' switch enables a link-time workaround for an
5106
erratum in certain Cortex-A8 processors.  The workaround is enabled by
5107
default if you are targeting the ARM v7-A architecture profile.  It can
5108
be enabled otherwise by specifying `--fix-cortex-a8', or disabled
5109
unconditionally by specifying `--no-fix-cortex-a8'.
5110
 
5111
   The erratum only affects Thumb-2 code.  Please contact ARM for
5112
further details.
5113
 
5114
   The `--no-merge-exidx-entries' switch disables the merging of
5115
adjacent exidx entries in debuginfo.
5116
 
5117

5118
File: ld.info,  Node: M68HC11/68HC12,  Next: PowerPC ELF32,  Prev: MSP430,  Up: Machine Dependent
5119
 
5120
4.3 `ld' and the Motorola 68HC11 and 68HC12 families
5121
====================================================
5122
 
5123
4.3.1 Linker Relaxation
5124
-----------------------
5125
 
5126
For the Motorola 68HC11, `ld' can perform these global optimizations
5127
when you specify the `--relax' command-line option.
5128
 
5129
_relaxing address modes_
5130
     `ld' finds all `jsr' and `jmp' instructions whose targets are
5131
     within eight bits, and turns them into eight-bit program-counter
5132
     relative `bsr' and `bra' instructions, respectively.
5133
 
5134
     `ld' also looks at all 16-bit extended addressing modes and
5135
     transforms them in a direct addressing mode when the address is in
5136
     page 0 (between 0 and 0x0ff).
5137
 
5138
_relaxing gcc instruction group_
5139
     When `gcc' is called with `-mrelax', it can emit group of
5140
     instructions that the linker can optimize to use a 68HC11 direct
5141
     addressing mode. These instructions consists of `bclr' or `bset'
5142
     instructions.
5143
 
5144
 
5145
4.3.2 Trampoline Generation
5146
---------------------------
5147
 
5148
For 68HC11 and 68HC12, `ld' can generate trampoline code to call a far
5149
function using a normal `jsr' instruction. The linker will also change
5150
the relocation to some far function to use the trampoline address
5151
instead of the function address. This is typically the case when a
5152
pointer to a function is taken. The pointer will in fact point to the
5153
function trampoline.
5154
 
5155

5156
File: ld.info,  Node: ARM,  Next: HPPA ELF32,  Prev: i960,  Up: Machine Dependent
5157
 
5158
4.4 `ld' and the ARM family
5159
===========================
5160
 
5161
For the ARM, `ld' will generate code stubs to allow functions calls
5162
between ARM and Thumb code.  These stubs only work with code that has
5163
been compiled and assembled with the `-mthumb-interwork' command line
5164
option.  If it is necessary to link with old ARM object files or
5165
libraries, which have not been compiled with the -mthumb-interwork
5166
option then the `--support-old-code' command line switch should be
5167
given to the linker.  This will make it generate larger stub functions
5168
which will work with non-interworking aware ARM code.  Note, however,
5169
the linker does not support generating stubs for function calls to
5170
non-interworking aware Thumb code.
5171
 
5172
   The `--thumb-entry' switch is a duplicate of the generic `--entry'
5173
switch, in that it sets the program's starting address.  But it also
5174
sets the bottom bit of the address, so that it can be branched to using
5175
a BX instruction, and the program will start executing in Thumb mode
5176
straight away.
5177
 
5178
   The `--use-nul-prefixed-import-tables' switch is specifying, that
5179
the import tables idata4 and idata5 have to be generated with a zero
5180
element prefix for import libraries. This is the old style to generate
5181
import tables. By default this option is turned off.
5182
 
5183
   The `--be8' switch instructs `ld' to generate BE8 format
5184
executables.  This option is only valid when linking big-endian objects.
5185
The resulting image will contain big-endian data and little-endian code.
5186
 
5187
   The `R_ARM_TARGET1' relocation is typically used for entries in the
5188
`.init_array' section.  It is interpreted as either `R_ARM_REL32' or
5189
`R_ARM_ABS32', depending on the target.  The `--target1-rel' and
5190
`--target1-abs' switches override the default.
5191
 
5192
   The `--target2=type' switch overrides the default definition of the
5193
`R_ARM_TARGET2' relocation.  Valid values for `type', their meanings,
5194
and target defaults are as follows:
5195
`rel'
5196
     `R_ARM_REL32' (arm*-*-elf, arm*-*-eabi)
5197
 
5198
`abs'
5199
     `R_ARM_ABS32' (arm*-*-symbianelf)
5200
 
5201
`got-rel'
5202
     `R_ARM_GOT_PREL' (arm*-*-linux, arm*-*-*bsd)
5203
 
5204
   The `R_ARM_V4BX' relocation (defined by the ARM AAELF specification)
5205
enables objects compiled for the ARMv4 architecture to be
5206
interworking-safe when linked with other objects compiled for ARMv4t,
5207
but also allows pure ARMv4 binaries to be built from the same ARMv4
5208
objects.
5209
 
5210
   In the latter case, the switch `--fix-v4bx' must be passed to the
5211
linker, which causes v4t `BX rM' instructions to be rewritten as `MOV
5212
PC,rM', since v4 processors do not have a `BX' instruction.
5213
 
5214
   In the former case, the switch should not be used, and `R_ARM_V4BX'
5215
relocations are ignored.
5216
 
5217
   Replace `BX rM' instructions identified by `R_ARM_V4BX' relocations
5218
with a branch to the following veneer:
5219
 
5220
     TST rM, #1
5221
     MOVEQ PC, rM
5222
     BX Rn
5223
 
5224
   This allows generation of libraries/applications that work on ARMv4
5225
cores and are still interworking safe.  Note that the above veneer
5226
clobbers the condition flags, so may cause incorrect program behavior
5227
in rare cases.
5228
 
5229
   The `--use-blx' switch enables the linker to use ARM/Thumb BLX
5230
instructions (available on ARMv5t and above) in various situations.
5231
Currently it is used to perform calls via the PLT from Thumb code using
5232
BLX rather than using BX and a mode-switching stub before each PLT
5233
entry. This should lead to such calls executing slightly faster.
5234
 
5235
   This option is enabled implicitly for SymbianOS, so there is no need
5236
to specify it if you are using that target.
5237
 
5238
   The `--vfp11-denorm-fix' switch enables a link-time workaround for a
5239
bug in certain VFP11 coprocessor hardware, which sometimes allows
5240
instructions with denorm operands (which must be handled by support
5241
code) to have those operands overwritten by subsequent instructions
5242
before the support code can read the intended values.
5243
 
5244
   The bug may be avoided in scalar mode if you allow at least one
5245
intervening instruction between a VFP11 instruction which uses a
5246
register and another instruction which writes to the same register, or
5247
at least two intervening instructions if vector mode is in use. The bug
5248
only affects full-compliance floating-point mode: you do not need this
5249
workaround if you are using "runfast" mode. Please contact ARM for
5250
further details.
5251
 
5252
   If you know you are using buggy VFP11 hardware, you can enable this
5253
workaround by specifying the linker option `--vfp-denorm-fix=scalar' if
5254
you are using the VFP11 scalar mode only, or `--vfp-denorm-fix=vector'
5255
if you are using vector mode (the latter also works for scalar code).
5256
The default is `--vfp-denorm-fix=none'.
5257
 
5258
   If the workaround is enabled, instructions are scanned for
5259
potentially-troublesome sequences, and a veneer is created for each
5260
such sequence which may trigger the erratum. The veneer consists of the
5261
first instruction of the sequence and a branch back to the subsequent
5262
instruction. The original instruction is then replaced with a branch to
5263
the veneer. The extra cycles required to call and return from the veneer
5264
are sufficient to avoid the erratum in both the scalar and vector cases.
5265
 
5266
   The `--fix-arm1176' switch enables a link-time workaround for an
5267
erratum in certain ARM1176 processors.  The workaround is enabled by
5268
default if you are targeting ARM v6 (excluding ARM v6T2) or earlier.
5269
It can be disabled unconditionally by specifying `--no-fix-arm1176'.
5270
 
5271
   Further information is available in the "ARM1176JZ-S and ARM1176JZF-S
5272
Programmer Advice Notice" available on the ARM documentation website at:
5273
http://infocenter.arm.com/.
5274
 
5275
   The `--no-enum-size-warning' switch prevents the linker from warning
5276
when linking object files that specify incompatible EABI enumeration
5277
size attributes.  For example, with this switch enabled, linking of an
5278
object file using 32-bit enumeration values with another using
5279
enumeration values fitted into the smallest possible space will not be
5280
diagnosed.
5281
 
5282
   The `--no-wchar-size-warning' switch prevents the linker from
5283
warning when linking object files that specify incompatible EABI
5284
`wchar_t' size attributes.  For example, with this switch enabled,
5285
linking of an object file using 32-bit `wchar_t' values with another
5286
using 16-bit `wchar_t' values will not be diagnosed.
5287
 
5288
   The `--pic-veneer' switch makes the linker use PIC sequences for
5289
ARM/Thumb interworking veneers, even if the rest of the binary is not
5290
PIC.  This avoids problems on uClinux targets where `--emit-relocs' is
5291
used to generate relocatable binaries.
5292
 
5293
   The linker will automatically generate and insert small sequences of
5294
code into a linked ARM ELF executable whenever an attempt is made to
5295
perform a function call to a symbol that is too far away.  The
5296
placement of these sequences of instructions - called stubs - is
5297
controlled by the command line option `--stub-group-size=N'.  The
5298
placement is important because a poor choice can create a need for
5299
duplicate stubs, increasing the code size.  The linker will try to
5300
group stubs together in order to reduce interruptions to the flow of
5301
code, but it needs guidance as to how big these groups should be and
5302
where they should be placed.
5303
 
5304
   The value of `N', the parameter to the `--stub-group-size=' option
5305
controls where the stub groups are placed.  If it is negative then all
5306
stubs are placed after the first branch that needs them.  If it is
5307
positive then the stubs can be placed either before or after the
5308
branches that need them.  If the value of `N' is 1 (either +1 or -1)
5309
then the linker will choose exactly where to place groups of stubs,
5310
using its built in heuristics.  A value of `N' greater than 1 (or
5311
smaller than -1) tells the linker that a single group of stubs can
5312
service at most `N' bytes from the input sections.
5313
 
5314
   The default, if `--stub-group-size=' is not specified, is `N = +1'.
5315
 
5316
   Farcalls stubs insertion is fully supported for the ARM-EABI target
5317
only, because it relies on object files properties not present
5318
otherwise.
5319
 
5320

5321
File: ld.info,  Node: HPPA ELF32,  Next: M68K,  Prev: ARM,  Up: Machine Dependent
5322
 
5323
4.5 `ld' and HPPA 32-bit ELF Support
5324
====================================
5325
 
5326
When generating a shared library, `ld' will by default generate import
5327
stubs suitable for use with a single sub-space application.  The
5328
`--multi-subspace' switch causes `ld' to generate export stubs, and
5329
different (larger) import stubs suitable for use with multiple
5330
sub-spaces.
5331
 
5332
   Long branch stubs and import/export stubs are placed by `ld' in stub
5333
sections located between groups of input sections.  `--stub-group-size'
5334
specifies the maximum size of a group of input sections handled by one
5335
stub section.  Since branch offsets are signed, a stub section may
5336
serve two groups of input sections, one group before the stub section,
5337
and one group after it.  However, when using conditional branches that
5338
require stubs, it may be better (for branch prediction) that stub
5339
sections only serve one group of input sections.  A negative value for
5340
`N' chooses this scheme, ensuring that branches to stubs always use a
5341
negative offset.  Two special values of `N' are recognized, `1' and
5342
`-1'.  These both instruct `ld' to automatically size input section
5343
groups for the branch types detected, with the same behaviour regarding
5344
stub placement as other positive or negative values of `N' respectively.
5345
 
5346
   Note that `--stub-group-size' does not split input sections.  A
5347
single input section larger than the group size specified will of course
5348
create a larger group (of one section).  If input sections are too
5349
large, it may not be possible for a branch to reach its stub.
5350
 
5351

5352
File: ld.info,  Node: M68K,  Next: MMIX,  Prev: HPPA ELF32,  Up: Machine Dependent
5353
 
5354
4.6 `ld' and the Motorola 68K family
5355
====================================
5356
 
5357
The `--got=TYPE' option lets you choose the GOT generation scheme.  The
5358
choices are `single', `negative', `multigot' and `target'.  When
5359
`target' is selected the linker chooses the default GOT generation
5360
scheme for the current target.  `single' tells the linker to generate a
5361
single GOT with entries only at non-negative offsets.  `negative'
5362
instructs the linker to generate a single GOT with entries at both
5363
negative and positive offsets.  Not all environments support such GOTs.
5364
`multigot' allows the linker to generate several GOTs in the output
5365
file.  All GOT references from a single input object file access the
5366
same GOT, but references from different input object files might access
5367
different GOTs.  Not all environments support such GOTs.
5368
 
5369

5370
File: ld.info,  Node: MMIX,  Next: MSP430,  Prev: M68K,  Up: Machine Dependent
5371
 
5372
4.7 `ld' and MMIX
5373
=================
5374
 
5375
For MMIX, there is a choice of generating `ELF' object files or `mmo'
5376
object files when linking.  The simulator `mmix' understands the `mmo'
5377
format.  The binutils `objcopy' utility can translate between the two
5378
formats.
5379
 
5380
   There is one special section, the `.MMIX.reg_contents' section.
5381
Contents in this section is assumed to correspond to that of global
5382
registers, and symbols referring to it are translated to special
5383
symbols, equal to registers.  In a final link, the start address of the
5384
`.MMIX.reg_contents' section corresponds to the first allocated global
5385
register multiplied by 8.  Register `$255' is not included in this
5386
section; it is always set to the program entry, which is at the symbol
5387
`Main' for `mmo' files.
5388
 
5389
   Global symbols with the prefix `__.MMIX.start.', for example
5390
`__.MMIX.start..text' and `__.MMIX.start..data' are special.  The
5391
default linker script uses these to set the default start address of a
5392
section.
5393
 
5394
   Initial and trailing multiples of zero-valued 32-bit words in a
5395
section, are left out from an mmo file.
5396
 
5397

5398
File: ld.info,  Node: MSP430,  Next: M68HC11/68HC12,  Prev: MMIX,  Up: Machine Dependent
5399
 
5400
4.8 `ld' and MSP430
5401
===================
5402
 
5403
For the MSP430 it is possible to select the MPU architecture.  The flag
5404
`-m [mpu type]' will select an appropriate linker script for selected
5405
MPU type.  (To get a list of known MPUs just pass `-m help' option to
5406
the linker).
5407
 
5408
   The linker will recognize some extra sections which are MSP430
5409
specific:
5410
 
5411
``.vectors''
5412
     Defines a portion of ROM where interrupt vectors located.
5413
 
5414
``.bootloader''
5415
     Defines the bootloader portion of the ROM (if applicable).  Any
5416
     code in this section will be uploaded to the MPU.
5417
 
5418
``.infomem''
5419
     Defines an information memory section (if applicable).  Any code in
5420
     this section will be uploaded to the MPU.
5421
 
5422
``.infomemnobits''
5423
     This is the same as the `.infomem' section except that any code in
5424
     this section will not be uploaded to the MPU.
5425
 
5426
``.noinit''
5427
     Denotes a portion of RAM located above `.bss' section.
5428
 
5429
     The last two sections are used by gcc.
5430
 
5431

5432
File: ld.info,  Node: PowerPC ELF32,  Next: PowerPC64 ELF64,  Prev: M68HC11/68HC12,  Up: Machine Dependent
5433
 
5434
4.9 `ld' and PowerPC 32-bit ELF Support
5435
=======================================
5436
 
5437
Branches on PowerPC processors are limited to a signed 26-bit
5438
displacement, which may result in `ld' giving `relocation truncated to
5439
fit' errors with very large programs.  `--relax' enables the generation
5440
of trampolines that can access the entire 32-bit address space.  These
5441
trampolines are inserted at section boundaries, so may not themselves
5442
be reachable if an input section exceeds 33M in size.  You may combine
5443
`-r' and `--relax' to add trampolines in a partial link.  In that case
5444
both branches to undefined symbols and inter-section branches are also
5445
considered potentially out of range, and trampolines inserted.
5446
 
5447
`--bss-plt'
5448
     Current PowerPC GCC accepts a `-msecure-plt' option that generates
5449
     code capable of using a newer PLT and GOT layout that has the
5450
     security advantage of no executable section ever needing to be
5451
     writable and no writable section ever being executable.  PowerPC
5452
     `ld' will generate this layout, including stubs to access the PLT,
5453
     if all input files (including startup and static libraries) were
5454
     compiled with `-msecure-plt'.  `--bss-plt' forces the old BSS PLT
5455
     (and GOT layout) which can give slightly better performance.
5456
 
5457
`--secure-plt'
5458
     `ld' will use the new PLT and GOT layout if it is linking new
5459
     `-fpic' or `-fPIC' code, but does not do so automatically when
5460
     linking non-PIC code.  This option requests the new PLT and GOT
5461
     layout.  A warning will be given if some object file requires the
5462
     old style BSS PLT.
5463
 
5464
`--sdata-got'
5465
     The new secure PLT and GOT are placed differently relative to other
5466
     sections compared to older BSS PLT and GOT placement.  The
5467
     location of `.plt' must change because the new secure PLT is an
5468
     initialized section while the old PLT is uninitialized.  The
5469
     reason for the `.got' change is more subtle:  The new placement
5470
     allows `.got' to be read-only in applications linked with `-z
5471
     relro -z now'.  However, this placement means that `.sdata' cannot
5472
     always be used in shared libraries, because the PowerPC ABI
5473
     accesses `.sdata' in shared libraries from the GOT pointer.
5474
     `--sdata-got' forces the old GOT placement.  PowerPC GCC doesn't
5475
     use `.sdata' in shared libraries, so this option is really only
5476
     useful for other compilers that may do so.
5477
 
5478
`--emit-stub-syms'
5479
     This option causes `ld' to label linker stubs with a local symbol
5480
     that encodes the stub type and destination.
5481
 
5482
`--no-tls-optimize'
5483
     PowerPC `ld' normally performs some optimization of code sequences
5484
     used to access Thread-Local Storage.  Use this option to disable
5485
     the optimization.
5486
 
5487

5488
File: ld.info,  Node: PowerPC64 ELF64,  Next: SPU ELF,  Prev: PowerPC ELF32,  Up: Machine Dependent
5489
 
5490
4.10 `ld' and PowerPC64 64-bit ELF Support
5491
==========================================
5492
 
5493
`--stub-group-size'
5494
     Long branch stubs, PLT call stubs  and TOC adjusting stubs are
5495
     placed by `ld' in stub sections located between groups of input
5496
     sections.  `--stub-group-size' specifies the maximum size of a
5497
     group of input sections handled by one stub section.  Since branch
5498
     offsets are signed, a stub section may serve two groups of input
5499
     sections, one group before the stub section, and one group after
5500
     it.  However, when using conditional branches that require stubs,
5501
     it may be better (for branch prediction) that stub sections only
5502
     serve one group of input sections.  A negative value for `N'
5503
     chooses this scheme, ensuring that branches to stubs always use a
5504
     negative offset.  Two special values of `N' are recognized, `1'
5505
     and `-1'.  These both instruct `ld' to automatically size input
5506
     section groups for the branch types detected, with the same
5507
     behaviour regarding stub placement as other positive or negative
5508
     values of `N' respectively.
5509
 
5510
     Note that `--stub-group-size' does not split input sections.  A
5511
     single input section larger than the group size specified will of
5512
     course create a larger group (of one section).  If input sections
5513
     are too large, it may not be possible for a branch to reach its
5514
     stub.
5515
 
5516
`--emit-stub-syms'
5517
     This option causes `ld' to label linker stubs with a local symbol
5518
     that encodes the stub type and destination.
5519
 
5520
`--dotsyms, --no-dotsyms'
5521
     These two options control how `ld' interprets version patterns in
5522
     a version script.  Older PowerPC64 compilers emitted both a
5523
     function descriptor symbol with the same name as the function, and
5524
     a code entry symbol with the name prefixed by a dot (`.').  To
5525
     properly version a function `foo', the version script thus needs
5526
     to control both `foo' and `.foo'.  The option `--dotsyms', on by
5527
     default, automatically adds the required dot-prefixed patterns.
5528
     Use `--no-dotsyms' to disable this feature.
5529
 
5530
`--no-tls-optimize'
5531
     PowerPC64 `ld' normally performs some optimization of code
5532
     sequences used to access Thread-Local Storage.  Use this option to
5533
     disable the optimization.
5534
 
5535
`--no-opd-optimize'
5536
     PowerPC64 `ld' normally removes `.opd' section entries
5537
     corresponding to deleted link-once functions, or functions removed
5538
     by the action of `--gc-sections' or linker script `/DISCARD/'.
5539
     Use this option to disable `.opd' optimization.
5540
 
5541
`--non-overlapping-opd'
5542
     Some PowerPC64 compilers have an option to generate compressed
5543
     `.opd' entries spaced 16 bytes apart, overlapping the third word,
5544
     the static chain pointer (unused in C) with the first word of the
5545
     next entry.  This option expands such entries to the full 24 bytes.
5546
 
5547
`--no-toc-optimize'
5548
     PowerPC64 `ld' normally removes unused `.toc' section entries.
5549
     Such entries are detected by examining relocations that reference
5550
     the TOC in code sections.  A reloc in a deleted code section marks
5551
     a TOC word as unneeded, while a reloc in a kept code section marks
5552
     a TOC word as needed.  Since the TOC may reference itself, TOC
5553
     relocs are also examined.  TOC words marked as both needed and
5554
     unneeded will of course be kept.  TOC words without any referencing
5555
     reloc are assumed to be part of a multi-word entry, and are kept or
5556
     discarded as per the nearest marked preceding word.  This works
5557
     reliably for compiler generated code, but may be incorrect if
5558
     assembly code is used to insert TOC entries.  Use this option to
5559
     disable the optimization.
5560
 
5561
`--no-multi-toc'
5562
     If given any toc option besides `-mcmodel=medium' or
5563
     `-mcmodel=large', PowerPC64 GCC generates code for a TOC model
5564
     where TOC entries are accessed with a 16-bit offset from r2.  This
5565
     limits the total TOC size to 64K.  PowerPC64 `ld' extends this
5566
     limit by grouping code sections such that each group uses less
5567
     than 64K for its TOC entries, then inserts r2 adjusting stubs
5568
     between inter-group calls.  `ld' does not split apart input
5569
     sections, so cannot help if a single input file has a `.toc'
5570
     section that exceeds 64K, most likely from linking multiple files
5571
     with `ld -r'.  Use this option to turn off this feature.
5572
 
5573
`--no-toc-sort'
5574
     By default, `ld' sorts TOC sections so that those whose file
5575
     happens to have a section called `.init' or `.fini' are placed
5576
     first, followed by TOC sections referenced by code generated with
5577
     PowerPC64 gcc's `-mcmodel=small', and lastly TOC sections
5578
     referenced only by code generated with PowerPC64 gcc's
5579
     `-mcmodel=medium' or `-mcmodel=large' options.  Doing this results
5580
     in better TOC grouping for multi-TOC.  Use this option to turn off
5581
     this feature.
5582
 
5583
`--plt-align'
5584
`--no-plt-align'
5585
     Use these options to control whether individual PLT call stubs are
5586
     aligned to a 32-byte boundary, or to the specified power of two
5587
     boundary when using `--plt-align='.  By default PLT call stubs are
5588
     packed tightly.
5589
 
5590
`--plt-static-chain'
5591
`--no-plt-static-chain'
5592
     Use these options to control whether PLT call stubs load the static
5593
     chain pointer (r11).  `ld' defaults to not loading the static
5594
     chain since there is never any need to do so on a PLT call.
5595
 
5596
`--plt-thread-safe'
5597
`--no-thread-safe'
5598
     With power7's weakly ordered memory model, it is possible when
5599
     using lazy binding for ld.so to update a plt entry in one thread
5600
     and have another thread see the individual plt entry words update
5601
     in the wrong order, despite ld.so carefully writing in the correct
5602
     order and using memory write barriers.  To avoid this we need some
5603
     sort of read barrier in the call stub, or use LD_BIND_NOW=1.  By
5604
     default, `ld' looks for calls to commonly used functions that
5605
     create threads, and if seen, adds the necessary barriers.  Use
5606
     these options to change the default behaviour.
5607
 
5608

5609
File: ld.info,  Node: SPU ELF,  Next: TI COFF,  Prev: PowerPC64 ELF64,  Up: Machine Dependent
5610
 
5611
4.11 `ld' and SPU ELF Support
5612
=============================
5613
 
5614
`--plugin'
5615
     This option marks an executable as a PIC plugin module.
5616
 
5617
`--no-overlays'
5618
     Normally, `ld' recognizes calls to functions within overlay
5619
     regions, and redirects such calls to an overlay manager via a stub.
5620
     `ld' also provides a built-in overlay manager.  This option turns
5621
     off all this special overlay handling.
5622
 
5623
`--emit-stub-syms'
5624
     This option causes `ld' to label overlay stubs with a local symbol
5625
     that encodes the stub type and destination.
5626
 
5627
`--extra-overlay-stubs'
5628
     This option causes `ld' to add overlay call stubs on all function
5629
     calls out of overlay regions.  Normally stubs are not added on
5630
     calls to non-overlay regions.
5631
 
5632
`--local-store=lo:hi'
5633
     `ld' usually checks that a final executable for SPU fits in the
5634
     address range 0 to 256k.  This option may be used to change the
5635
     range.  Disable the check entirely with `--local-store=0:0'.
5636
 
5637
`--stack-analysis'
5638
     SPU local store space is limited.  Over-allocation of stack space
5639
     unnecessarily limits space available for code and data, while
5640
     under-allocation results in runtime failures.  If given this
5641
     option, `ld' will provide an estimate of maximum stack usage.
5642
     `ld' does this by examining symbols in code sections to determine
5643
     the extents of functions, and looking at function prologues for
5644
     stack adjusting instructions.  A call-graph is created by looking
5645
     for relocations on branch instructions.  The graph is then searched
5646
     for the maximum stack usage path.  Note that this analysis does not
5647
     find calls made via function pointers, and does not handle
5648
     recursion and other cycles in the call graph.  Stack usage may be
5649
     under-estimated if your code makes such calls.  Also, stack usage
5650
     for dynamic allocation, e.g. alloca, will not be detected.  If a
5651
     link map is requested, detailed information about each function's
5652
     stack usage and calls will be given.
5653
 
5654
`--emit-stack-syms'
5655
     This option, if given along with `--stack-analysis' will result in
5656
     `ld' emitting stack sizing symbols for each function.  These take
5657
     the form `__stack_' for global functions, and
5658
     `__stack__' for static functions.
5659
     `' is the section id in hex.  The value of such symbols is
5660
     the stack requirement for the corresponding function.  The symbol
5661
     size will be zero, type `STT_NOTYPE', binding `STB_LOCAL', and
5662
     section `SHN_ABS'.
5663
 
5664

5665
File: ld.info,  Node: TI COFF,  Next: WIN32,  Prev: SPU ELF,  Up: Machine Dependent
5666
 
5667
4.12 `ld''s Support for Various TI COFF Versions
5668
================================================
5669
 
5670
The `--format' switch allows selection of one of the various TI COFF
5671
versions.  The latest of this writing is 2; versions 0 and 1 are also
5672
supported.  The TI COFF versions also vary in header byte-order format;
5673
`ld' will read any version or byte order, but the output header format
5674
depends on the default specified by the specific target.
5675
 
5676

5677
File: ld.info,  Node: WIN32,  Next: Xtensa,  Prev: TI COFF,  Up: Machine Dependent
5678
 
5679
4.13 `ld' and WIN32 (cygwin/mingw)
5680
==================================
5681
 
5682
This section describes some of the win32 specific `ld' issues.  See
5683
*note Command Line Options: Options. for detailed description of the
5684
command line options mentioned here.
5685
 
5686
_import libraries_
5687
     The standard Windows linker creates and uses so-called import
5688
     libraries, which contains information for linking to dll's.  They
5689
     are regular static archives and are handled as any other static
5690
     archive.  The cygwin and mingw ports of `ld' have specific support
5691
     for creating such libraries provided with the `--out-implib'
5692
     command line option.
5693
 
5694
_exporting DLL symbols_
5695
     The cygwin/mingw `ld' has several ways to export symbols for dll's.
5696
 
5697
    _using auto-export functionality_
5698
          By default `ld' exports symbols with the auto-export
5699
          functionality, which is controlled by the following command
5700
          line options:
5701
 
5702
             * -export-all-symbols   [This is the default]
5703
 
5704
             * -exclude-symbols
5705
 
5706
             * -exclude-libs
5707
 
5708
             * -exclude-modules-for-implib
5709
 
5710
             * -version-script
5711
 
5712
          When auto-export is in operation, `ld' will export all the
5713
          non-local (global and common) symbols it finds in a DLL, with
5714
          the exception of a few symbols known to belong to the
5715
          system's runtime and libraries.  As it will often not be
5716
          desirable to export all of a DLL's symbols, which may include
5717
          private functions that are not part of any public interface,
5718
          the command-line options listed above may be used to filter
5719
          symbols out from the list for exporting.  The `--output-def'
5720
          option can be used in order to see the final list of exported
5721
          symbols with all exclusions taken into effect.
5722
 
5723
          If `--export-all-symbols' is not given explicitly on the
5724
          command line, then the default auto-export behavior will be
5725
          _disabled_ if either of the following are true:
5726
 
5727
             * A DEF file is used.
5728
 
5729
             * Any symbol in any object file was marked with the
5730
               __declspec(dllexport) attribute.
5731
 
5732
    _using a DEF file_
5733
          Another way of exporting symbols is using a DEF file.  A DEF
5734
          file is an ASCII file containing definitions of symbols which
5735
          should be exported when a dll is created.  Usually it is
5736
          named `.def' and is added as any other object file
5737
          to the linker's command line.  The file's name must end in
5738
          `.def' or `.DEF'.
5739
 
5740
               gcc -o   .def
5741
 
5742
          Using a DEF file turns off the normal auto-export behavior,
5743
          unless the `--export-all-symbols' option is also used.
5744
 
5745
          Here is an example of a DEF file for a shared library called
5746
          `xyz.dll':
5747
 
5748
               LIBRARY "xyz.dll" BASE=0x20000000
5749
 
5750
               EXPORTS
5751
               foo
5752
               bar
5753
               _bar = bar
5754
               another_foo = abc.dll.afoo
5755
               var1 DATA
5756
               doo = foo == foo2
5757
               eoo DATA == var1
5758
 
5759
          This example defines a DLL with a non-default base address
5760
          and seven symbols in the export table. The third exported
5761
          symbol `_bar' is an alias for the second. The fourth symbol,
5762
          `another_foo' is resolved by "forwarding" to another module
5763
          and treating it as an alias for `afoo' exported from the DLL
5764
          `abc.dll'. The final symbol `var1' is declared to be a data
5765
          object. The `doo' symbol in export library is an alias of
5766
          `foo', which gets the string name in export table `foo2'. The
5767
          `eoo' symbol is an data export symbol, which gets in export
5768
          table the name `var1'.
5769
 
5770
          The optional `LIBRARY ' command indicates the _internal_
5771
          name of the output DLL. If `' does not include a suffix,
5772
          the default library suffix, `.DLL' is appended.
5773
 
5774
          When the .DEF file is used to build an application, rather
5775
          than a library, the `NAME ' command should be used
5776
          instead of `LIBRARY'. If `' does not include a suffix,
5777
          the default executable suffix, `.EXE' is appended.
5778
 
5779
          With either `LIBRARY ' or `NAME ' the optional
5780
          specification `BASE = ' may be used to specify a
5781
          non-default base address for the image.
5782
 
5783
          If neither `LIBRARY ' nor  `NAME ' is specified,
5784
          or they specify an empty string, the internal name is the
5785
          same as the filename specified on the command line.
5786
 
5787
          The complete specification of an export symbol is:
5788
 
5789
               EXPORTS
5790
                 ( (  (  [ =  ] )
5791
                    | (  =  . ))
5792
                 [ @  ] [NONAME] [DATA] [CONSTANT] [PRIVATE] [== ] ) *
5793
 
5794
          Declares `' as an exported symbol from the DLL, or
5795
          declares `' as an exported alias for `'; or
5796
          declares `' as a "forward" alias for the symbol
5797
          `' in the DLL `'.  Optionally,
5798
          the symbol may be exported by the specified ordinal
5799
          `' alias. The optional `' is the to be used
5800
          string in import/export table for the symbol.
5801
 
5802
          The optional keywords that follow the declaration indicate:
5803
 
5804
          `NONAME': Do not put the symbol name in the DLL's export
5805
          table.  It will still be exported by its ordinal alias
5806
          (either the value specified by the .def specification or,
5807
          otherwise, the value assigned by the linker). The symbol
5808
          name, however, does remain visible in the import library (if
5809
          any), unless `PRIVATE' is also specified.
5810
 
5811
          `DATA': The symbol is a variable or object, rather than a
5812
          function.  The import lib will export only an indirect
5813
          reference to `foo' as the symbol `_imp__foo' (ie, `foo' must
5814
          be resolved as `*_imp__foo').
5815
 
5816
          `CONSTANT': Like `DATA', but put the undecorated `foo' as
5817
          well as `_imp__foo' into the import library. Both refer to the
5818
          read-only import address table's pointer to the variable, not
5819
          to the variable itself. This can be dangerous. If the user
5820
          code fails to add the `dllimport' attribute and also fails to
5821
          explicitly add the extra indirection that the use of the
5822
          attribute enforces, the application will behave unexpectedly.
5823
 
5824
          `PRIVATE': Put the symbol in the DLL's export table, but do
5825
          not put it into the static import library used to resolve
5826
          imports at link time. The symbol can still be imported using
5827
          the `LoadLibrary/GetProcAddress' API at runtime or by by
5828
          using the GNU ld extension of linking directly to the DLL
5829
          without an import library.
5830
 
5831
          See ld/deffilep.y in the binutils sources for the full
5832
          specification of other DEF file statements
5833
 
5834
          While linking a shared dll, `ld' is able to create a DEF file
5835
          with the `--output-def ' command line option.
5836
 
5837
    _Using decorations_
5838
          Another way of marking symbols for export is to modify the
5839
          source code itself, so that when building the DLL each symbol
5840
          to be exported is declared as:
5841
 
5842
               __declspec(dllexport) int a_variable
5843
               __declspec(dllexport) void a_function(int with_args)
5844
 
5845
          All such symbols will be exported from the DLL.  If, however,
5846
          any of the object files in the DLL contain symbols decorated
5847
          in this way, then the normal auto-export behavior is
5848
          disabled, unless the `--export-all-symbols' option is also
5849
          used.
5850
 
5851
          Note that object files that wish to access these symbols must
5852
          _not_ decorate them with dllexport.  Instead, they should use
5853
          dllimport, instead:
5854
 
5855
               __declspec(dllimport) int a_variable
5856
               __declspec(dllimport) void a_function(int with_args)
5857
 
5858
          This complicates the structure of library header files,
5859
          because when included by the library itself the header must
5860
          declare the variables and functions as dllexport, but when
5861
          included by client code the header must declare them as
5862
          dllimport.  There are a number of idioms that are typically
5863
          used to do this; often client code can omit the __declspec()
5864
          declaration completely.  See `--enable-auto-import' and
5865
          `automatic data imports' for more information.
5866
 
5867
_automatic data imports_
5868
     The standard Windows dll format supports data imports from dlls
5869
     only by adding special decorations (dllimport/dllexport), which
5870
     let the compiler produce specific assembler instructions to deal
5871
     with this issue.  This increases the effort necessary to port
5872
     existing Un*x code to these platforms, especially for large c++
5873
     libraries and applications.  The auto-import feature, which was
5874
     initially provided by Paul Sokolovsky, allows one to omit the
5875
     decorations to achieve a behavior that conforms to that on
5876
     POSIX/Un*x platforms. This feature is enabled with the
5877
     `--enable-auto-import' command-line option, although it is enabled
5878
     by default on cygwin/mingw.  The `--enable-auto-import' option
5879
     itself now serves mainly to suppress any warnings that are
5880
     ordinarily emitted when linked objects trigger the feature's use.
5881
 
5882
     auto-import of variables does not always work flawlessly without
5883
     additional assistance.  Sometimes, you will see this message
5884
 
5885
     "variable '' can't be auto-imported. Please read the
5886
     documentation for ld's `--enable-auto-import' for details."
5887
 
5888
     The `--enable-auto-import' documentation explains why this error
5889
     occurs, and several methods that can be used to overcome this
5890
     difficulty.  One of these methods is the _runtime pseudo-relocs_
5891
     feature, described below.
5892
 
5893
     For complex variables imported from DLLs (such as structs or
5894
     classes), object files typically contain a base address for the
5895
     variable and an offset (_addend_) within the variable-to specify a
5896
     particular field or public member, for instance.  Unfortunately,
5897
     the runtime loader used in win32 environments is incapable of
5898
     fixing these references at runtime without the additional
5899
     information supplied by dllimport/dllexport decorations.  The
5900
     standard auto-import feature described above is unable to resolve
5901
     these references.
5902
 
5903
     The `--enable-runtime-pseudo-relocs' switch allows these
5904
     references to be resolved without error, while leaving the task of
5905
     adjusting the references themselves (with their non-zero addends)
5906
     to specialized code provided by the runtime environment.  Recent
5907
     versions of the cygwin and mingw environments and compilers
5908
     provide this runtime support; older versions do not.  However, the
5909
     support is only necessary on the developer's platform; the
5910
     compiled result will run without error on an older system.
5911
 
5912
     `--enable-runtime-pseudo-relocs' is not the default; it must be
5913
     explicitly enabled as needed.
5914
 
5915
_direct linking to a dll_
5916
     The cygwin/mingw ports of `ld' support the direct linking,
5917
     including data symbols, to a dll without the usage of any import
5918
     libraries.  This is much faster and uses much less memory than
5919
     does the traditional import library method, especially when
5920
     linking large libraries or applications.  When `ld' creates an
5921
     import lib, each function or variable exported from the dll is
5922
     stored in its own bfd, even though a single bfd could contain many
5923
     exports.  The overhead involved in storing, loading, and
5924
     processing so many bfd's is quite large, and explains the
5925
     tremendous time, memory, and storage needed to link against
5926
     particularly large or complex libraries when using import libs.
5927
 
5928
     Linking directly to a dll uses no extra command-line switches
5929
     other than `-L' and `-l', because `ld' already searches for a
5930
     number of names to match each library.  All that is needed from
5931
     the developer's perspective is an understanding of this search, in
5932
     order to force ld to select the dll instead of an import library.
5933
 
5934
     For instance, when ld is called with the argument `-lxxx' it will
5935
     attempt to find, in the first directory of its search path,
5936
 
5937
          libxxx.dll.a
5938
          xxx.dll.a
5939
          libxxx.a
5940
          xxx.lib
5941
          cygxxx.dll (*)
5942
          libxxx.dll
5943
          xxx.dll
5944
 
5945
     before moving on to the next directory in the search path.
5946
 
5947
     (*) Actually, this is not `cygxxx.dll' but in fact is
5948
     `xxx.dll', where `' is set by the `ld' option
5949
     `--dll-search-prefix='. In the case of cygwin, the
5950
     standard gcc spec file includes `--dll-search-prefix=cyg', so in
5951
     effect we actually search for `cygxxx.dll'.
5952
 
5953
     Other win32-based unix environments, such as mingw or pw32, may
5954
     use other `'es, although at present only cygwin makes use
5955
     of this feature.  It was originally intended to help avoid name
5956
     conflicts among dll's built for the various win32/un*x
5957
     environments, so that (for example) two versions of a zlib dll
5958
     could coexist on the same machine.
5959
 
5960
     The generic cygwin/mingw path layout uses a `bin' directory for
5961
     applications and dll's and a `lib' directory for the import
5962
     libraries (using cygwin nomenclature):
5963
 
5964
          bin/
5965
                cygxxx.dll
5966
          lib/
5967
                libxxx.dll.a   (in case of dll's)
5968
                libxxx.a       (in case of static archive)
5969
 
5970
     Linking directly to a dll without using the import library can be
5971
     done two ways:
5972
 
5973
     1. Use the dll directly by adding the `bin' path to the link line
5974
          gcc -Wl,-verbose  -o a.exe -L../bin/ -lxxx
5975
 
5976
     However, as the dll's often have version numbers appended to their
5977
     names (`cygncurses-5.dll') this will often fail, unless one
5978
     specifies `-L../bin -lncurses-5' to include the version.  Import
5979
     libs are generally not versioned, and do not have this difficulty.
5980
 
5981
     2. Create a symbolic link from the dll to a file in the `lib'
5982
     directory according to the above mentioned search pattern.  This
5983
     should be used to avoid unwanted changes in the tools needed for
5984
     making the app/dll.
5985
 
5986
          ln -s bin/cygxxx.dll lib/[cyg|lib|]xxx.dll[.a]
5987
 
5988
     Then you can link without any make environment changes.
5989
 
5990
          gcc -Wl,-verbose  -o a.exe -L../lib/ -lxxx
5991
 
5992
     This technique also avoids the version number problems, because
5993
     the following is perfectly legal
5994
 
5995
          bin/
5996
                cygxxx-5.dll
5997
          lib/
5998
                libxxx.dll.a -> ../bin/cygxxx-5.dll
5999
 
6000
     Linking directly to a dll without using an import lib will work
6001
     even when auto-import features are exercised, and even when
6002
     `--enable-runtime-pseudo-relocs' is used.
6003
 
6004
     Given the improvements in speed and memory usage, one might
6005
     justifiably wonder why import libraries are used at all.  There
6006
     are three reasons:
6007
 
6008
     1. Until recently, the link-directly-to-dll functionality did _not_
6009
     work with auto-imported data.
6010
 
6011
     2. Sometimes it is necessary to include pure static objects within
6012
     the import library (which otherwise contains only bfd's for
6013
     indirection symbols that point to the exports of a dll).  Again,
6014
     the import lib for the cygwin kernel makes use of this ability,
6015
     and it is not possible to do this without an import lib.
6016
 
6017
     3. Symbol aliases can only be resolved using an import lib.  This
6018
     is critical when linking against OS-supplied dll's (eg, the win32
6019
     API) in which symbols are usually exported as undecorated aliases
6020
     of their stdcall-decorated assembly names.
6021
 
6022
     So, import libs are not going away.  But the ability to replace
6023
     true import libs with a simple symbolic link to (or a copy of) a
6024
     dll, in many cases, is a useful addition to the suite of tools
6025
     binutils makes available to the win32 developer.  Given the
6026
     massive improvements in memory requirements during linking, storage
6027
     requirements, and linking speed, we expect that many developers
6028
     will soon begin to use this feature whenever possible.
6029
 
6030
_symbol aliasing_
6031
 
6032
    _adding additional names_
6033
          Sometimes, it is useful to export symbols with additional
6034
          names.  A symbol `foo' will be exported as `foo', but it can
6035
          also be exported as `_foo' by using special directives in the
6036
          DEF file when creating the dll.  This will affect also the
6037
          optional created import library.  Consider the following DEF
6038
          file:
6039
 
6040
               LIBRARY "xyz.dll" BASE=0x61000000
6041
 
6042
               EXPORTS
6043
               foo
6044
               _foo = foo
6045
 
6046
          The line `_foo = foo' maps the symbol `foo' to `_foo'.
6047
 
6048
          Another method for creating a symbol alias is to create it in
6049
          the source code using the "weak" attribute:
6050
 
6051
               void foo () { /* Do something.  */; }
6052
               void _foo () __attribute__ ((weak, alias ("foo")));
6053
 
6054
          See the gcc manual for more information about attributes and
6055
          weak symbols.
6056
 
6057
    _renaming symbols_
6058
          Sometimes it is useful to rename exports.  For instance, the
6059
          cygwin kernel does this regularly.  A symbol `_foo' can be
6060
          exported as `foo' but not as `_foo' by using special
6061
          directives in the DEF file. (This will also affect the import
6062
          library, if it is created).  In the following example:
6063
 
6064
               LIBRARY "xyz.dll" BASE=0x61000000
6065
 
6066
               EXPORTS
6067
               _foo = foo
6068
 
6069
          The line `_foo = foo' maps the exported symbol `foo' to
6070
          `_foo'.
6071
 
6072
     Note: using a DEF file disables the default auto-export behavior,
6073
     unless the `--export-all-symbols' command line option is used.
6074
     If, however, you are trying to rename symbols, then you should list
6075
     _all_ desired exports in the DEF file, including the symbols that
6076
     are not being renamed, and do _not_ use the `--export-all-symbols'
6077
     option.  If you list only the renamed symbols in the DEF file, and
6078
     use `--export-all-symbols' to handle the other symbols, then the
6079
     both the new names _and_ the original names for the renamed
6080
     symbols will be exported.  In effect, you'd be aliasing those
6081
     symbols, not renaming them, which is probably not what you wanted.
6082
 
6083
_weak externals_
6084
     The Windows object format, PE, specifies a form of weak symbols
6085
     called weak externals.  When a weak symbol is linked and the
6086
     symbol is not defined, the weak symbol becomes an alias for some
6087
     other symbol.  There are three variants of weak externals:
6088
        * Definition is searched for in objects and libraries,
6089
          historically called lazy externals.
6090
 
6091
        * Definition is searched for only in other objects, not in
6092
          libraries.  This form is not presently implemented.
6093
 
6094
        * No search; the symbol is an alias.  This form is not presently
6095
          implemented.
6096
     As a GNU extension, weak symbols that do not specify an alternate
6097
     symbol are supported.  If the symbol is undefined when linking,
6098
     the symbol uses a default value.
6099
 
6100
_aligned common symbols_
6101
     As a GNU extension to the PE file format, it is possible to
6102
     specify the desired alignment for a common symbol.  This
6103
     information is conveyed from the assembler or compiler to the
6104
     linker by means of GNU-specific commands carried in the object
6105
     file's `.drectve' section, which are recognized by `ld' and
6106
     respected when laying out the common symbols.  Native tools will
6107
     be able to process object files employing this GNU extension, but
6108
     will fail to respect the alignment instructions, and may issue
6109
     noisy warnings about unknown linker directives.
6110
 
6111

6112
File: ld.info,  Node: Xtensa,  Prev: WIN32,  Up: Machine Dependent
6113
 
6114
4.14 `ld' and Xtensa Processors
6115
===============================
6116
 
6117
The default `ld' behavior for Xtensa processors is to interpret
6118
`SECTIONS' commands so that lists of explicitly named sections in a
6119
specification with a wildcard file will be interleaved when necessary to
6120
keep literal pools within the range of PC-relative load offsets.  For
6121
example, with the command:
6122
 
6123
     SECTIONS
6124
     {
6125
       .text : {
6126
         *(.literal .text)
6127
       }
6128
     }
6129
 
6130
`ld' may interleave some of the `.literal' and `.text' sections from
6131
different object files to ensure that the literal pools are within the
6132
range of PC-relative load offsets.  A valid interleaving might place
6133
the `.literal' sections from an initial group of files followed by the
6134
`.text' sections of that group of files.  Then, the `.literal' sections
6135
from the rest of the files and the `.text' sections from the rest of
6136
the files would follow.
6137
 
6138
   Relaxation is enabled by default for the Xtensa version of `ld' and
6139
provides two important link-time optimizations.  The first optimization
6140
is to combine identical literal values to reduce code size.  A redundant
6141
literal will be removed and all the `L32R' instructions that use it
6142
will be changed to reference an identical literal, as long as the
6143
location of the replacement literal is within the offset range of all
6144
the `L32R' instructions.  The second optimization is to remove
6145
unnecessary overhead from assembler-generated "longcall" sequences of
6146
`L32R'/`CALLXN' when the target functions are within range of direct
6147
`CALLN' instructions.
6148
 
6149
   For each of these cases where an indirect call sequence can be
6150
optimized to a direct call, the linker will change the `CALLXN'
6151
instruction to a `CALLN' instruction, remove the `L32R' instruction,
6152
and remove the literal referenced by the `L32R' instruction if it is
6153
not used for anything else.  Removing the `L32R' instruction always
6154
reduces code size but can potentially hurt performance by changing the
6155
alignment of subsequent branch targets.  By default, the linker will
6156
always preserve alignments, either by switching some instructions
6157
between 24-bit encodings and the equivalent density instructions or by
6158
inserting a no-op in place of the `L32R' instruction that was removed.
6159
If code size is more important than performance, the `--size-opt'
6160
option can be used to prevent the linker from widening density
6161
instructions or inserting no-ops, except in a few cases where no-ops
6162
are required for correctness.
6163
 
6164
   The following Xtensa-specific command-line options can be used to
6165
control the linker:
6166
 
6167
`--size-opt'
6168
     When optimizing indirect calls to direct calls, optimize for code
6169
     size more than performance.  With this option, the linker will not
6170
     insert no-ops or widen density instructions to preserve branch
6171
     target alignment.  There may still be some cases where no-ops are
6172
     required to preserve the correctness of the code.
6173
 
6174

6175
File: ld.info,  Node: BFD,  Next: Reporting Bugs,  Prev: Machine Dependent,  Up: Top
6176
 
6177
5 BFD
6178
*****
6179
 
6180
The linker accesses object and archive files using the BFD libraries.
6181
These libraries allow the linker to use the same routines to operate on
6182
object files whatever the object file format.  A different object file
6183
format can be supported simply by creating a new BFD back end and adding
6184
it to the library.  To conserve runtime memory, however, the linker and
6185
associated tools are usually configured to support only a subset of the
6186
object file formats available.  You can use `objdump -i' (*note
6187
objdump: (binutils.info)objdump.) to list all the formats available for
6188
your configuration.
6189
 
6190
   As with most implementations, BFD is a compromise between several
6191
conflicting requirements. The major factor influencing BFD design was
6192
efficiency: any time used converting between formats is time which
6193
would not have been spent had BFD not been involved. This is partly
6194
offset by abstraction payback; since BFD simplifies applications and
6195
back ends, more time and care may be spent optimizing algorithms for a
6196
greater speed.
6197
 
6198
   One minor artifact of the BFD solution which you should bear in mind
6199
is the potential for information loss.  There are two places where
6200
useful information can be lost using the BFD mechanism: during
6201
conversion and during output. *Note BFD information loss::.
6202
 
6203
* Menu:
6204
 
6205
* BFD outline::                 How it works: an outline of BFD
6206
 
6207

6208
File: ld.info,  Node: BFD outline,  Up: BFD
6209
 
6210
5.1 How It Works: An Outline of BFD
6211
===================================
6212
 
6213
When an object file is opened, BFD subroutines automatically determine
6214
the format of the input object file.  They then build a descriptor in
6215
memory with pointers to routines that will be used to access elements of
6216
the object file's data structures.
6217
 
6218
   As different information from the object files is required, BFD
6219
reads from different sections of the file and processes them.  For
6220
example, a very common operation for the linker is processing symbol
6221
tables.  Each BFD back end provides a routine for converting between
6222
the object file's representation of symbols and an internal canonical
6223
format. When the linker asks for the symbol table of an object file, it
6224
calls through a memory pointer to the routine from the relevant BFD
6225
back end which reads and converts the table into a canonical form.  The
6226
linker then operates upon the canonical form. When the link is finished
6227
and the linker writes the output file's symbol table, another BFD back
6228
end routine is called to take the newly created symbol table and
6229
convert it into the chosen output format.
6230
 
6231
* Menu:
6232
 
6233
* BFD information loss::        Information Loss
6234
* Canonical format::            The BFD canonical object-file format
6235
 
6236

6237
File: ld.info,  Node: BFD information loss,  Next: Canonical format,  Up: BFD outline
6238
 
6239
5.1.1 Information Loss
6240
----------------------
6241
 
6242
_Information can be lost during output._ The output formats supported
6243
by BFD do not provide identical facilities, and information which can
6244
be described in one form has nowhere to go in another format. One
6245
example of this is alignment information in `b.out'. There is nowhere
6246
in an `a.out' format file to store alignment information on the
6247
contained data, so when a file is linked from `b.out' and an `a.out'
6248
image is produced, alignment information will not propagate to the
6249
output file. (The linker will still use the alignment information
6250
internally, so the link is performed correctly).
6251
 
6252
   Another example is COFF section names. COFF files may contain an
6253
unlimited number of sections, each one with a textual section name. If
6254
the target of the link is a format which does not have many sections
6255
(e.g., `a.out') or has sections without names (e.g., the Oasys format),
6256
the link cannot be done simply. You can circumvent this problem by
6257
describing the desired input-to-output section mapping with the linker
6258
command language.
6259
 
6260
   _Information can be lost during canonicalization._ The BFD internal
6261
canonical form of the external formats is not exhaustive; there are
6262
structures in input formats for which there is no direct representation
6263
internally.  This means that the BFD back ends cannot maintain all
6264
possible data richness through the transformation between external to
6265
internal and back to external formats.
6266
 
6267
   This limitation is only a problem when an application reads one
6268
format and writes another.  Each BFD back end is responsible for
6269
maintaining as much data as possible, and the internal BFD canonical
6270
form has structures which are opaque to the BFD core, and exported only
6271
to the back ends. When a file is read in one format, the canonical form
6272
is generated for BFD and the application. At the same time, the back
6273
end saves away any information which may otherwise be lost. If the data
6274
is then written back in the same format, the back end routine will be
6275
able to use the canonical form provided by the BFD core as well as the
6276
information it prepared earlier.  Since there is a great deal of
6277
commonality between back ends, there is no information lost when
6278
linking or copying big endian COFF to little endian COFF, or `a.out' to
6279
`b.out'.  When a mixture of formats is linked, the information is only
6280
lost from the files whose format differs from the destination.
6281
 
6282

6283
File: ld.info,  Node: Canonical format,  Prev: BFD information loss,  Up: BFD outline
6284
 
6285
5.1.2 The BFD canonical object-file format
6286
------------------------------------------
6287
 
6288
The greatest potential for loss of information occurs when there is the
6289
least overlap between the information provided by the source format,
6290
that stored by the canonical format, and that needed by the destination
6291
format. A brief description of the canonical form may help you
6292
understand which kinds of data you can count on preserving across
6293
conversions.
6294
 
6295
_files_
6296
     Information stored on a per-file basis includes target machine
6297
     architecture, particular implementation format type, a demand
6298
     pageable bit, and a write protected bit.  Information like Unix
6299
     magic numbers is not stored here--only the magic numbers' meaning,
6300
     so a `ZMAGIC' file would have both the demand pageable bit and the
6301
     write protected text bit set.  The byte order of the target is
6302
     stored on a per-file basis, so that big- and little-endian object
6303
     files may be used with one another.
6304
 
6305
_sections_
6306
     Each section in the input file contains the name of the section,
6307
     the section's original address in the object file, size and
6308
     alignment information, various flags, and pointers into other BFD
6309
     data structures.
6310
 
6311
_symbols_
6312
     Each symbol contains a pointer to the information for the object
6313
     file which originally defined it, its name, its value, and various
6314
     flag bits.  When a BFD back end reads in a symbol table, it
6315
     relocates all symbols to make them relative to the base of the
6316
     section where they were defined.  Doing this ensures that each
6317
     symbol points to its containing section.  Each symbol also has a
6318
     varying amount of hidden private data for the BFD back end.  Since
6319
     the symbol points to the original file, the private data format
6320
     for that symbol is accessible.  `ld' can operate on a collection
6321
     of symbols of wildly different formats without problems.
6322
 
6323
     Normal global and simple local symbols are maintained on output,
6324
     so an output file (no matter its format) will retain symbols
6325
     pointing to functions and to global, static, and common variables.
6326
     Some symbol information is not worth retaining; in `a.out', type
6327
     information is stored in the symbol table as long symbol names.
6328
     This information would be useless to most COFF debuggers; the
6329
     linker has command line switches to allow users to throw it away.
6330
 
6331
     There is one word of type information within the symbol, so if the
6332
     format supports symbol type information within symbols (for
6333
     example, COFF, IEEE, Oasys) and the type is simple enough to fit
6334
     within one word (nearly everything but aggregates), the
6335
     information will be preserved.
6336
 
6337
_relocation level_
6338
     Each canonical BFD relocation record contains a pointer to the
6339
     symbol to relocate to, the offset of the data to relocate, the
6340
     section the data is in, and a pointer to a relocation type
6341
     descriptor. Relocation is performed by passing messages through
6342
     the relocation type descriptor and the symbol pointer. Therefore,
6343
     relocations can be performed on output data using a relocation
6344
     method that is only available in one of the input formats. For
6345
     instance, Oasys provides a byte relocation format.  A relocation
6346
     record requesting this relocation type would point indirectly to a
6347
     routine to perform this, so the relocation may be performed on a
6348
     byte being written to a 68k COFF file, even though 68k COFF has no
6349
     such relocation type.
6350
 
6351
_line numbers_
6352
     Object formats can contain, for debugging purposes, some form of
6353
     mapping between symbols, source line numbers, and addresses in the
6354
     output file.  These addresses have to be relocated along with the
6355
     symbol information.  Each symbol with an associated list of line
6356
     number records points to the first record of the list.  The head
6357
     of a line number list consists of a pointer to the symbol, which
6358
     allows finding out the address of the function whose line number
6359
     is being described. The rest of the list is made up of pairs:
6360
     offsets into the section and line numbers. Any format which can
6361
     simply derive this information can pass it successfully between
6362
     formats (COFF, IEEE and Oasys).
6363
 
6364

6365
File: ld.info,  Node: Reporting Bugs,  Next: MRI,  Prev: BFD,  Up: Top
6366
 
6367
6 Reporting Bugs
6368
****************
6369
 
6370
Your bug reports play an essential role in making `ld' reliable.
6371
 
6372
   Reporting a bug may help you by bringing a solution to your problem,
6373
or it may not.  But in any case the principal function of a bug report
6374
is to help the entire community by making the next version of `ld' work
6375
better.  Bug reports are your contribution to the maintenance of `ld'.
6376
 
6377
   In order for a bug report to serve its purpose, you must include the
6378
information that enables us to fix the bug.
6379
 
6380
* Menu:
6381
 
6382
* Bug Criteria::                Have you found a bug?
6383
* Bug Reporting::               How to report bugs
6384
 
6385

6386
File: ld.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: Reporting Bugs
6387
 
6388
6.1 Have You Found a Bug?
6389
=========================
6390
 
6391
If you are not sure whether you have found a bug, here are some
6392
guidelines:
6393
 
6394
   * If the linker gets a fatal signal, for any input whatever, that is
6395
     a `ld' bug.  Reliable linkers never crash.
6396
 
6397
   * If `ld' produces an error message for valid input, that is a bug.
6398
 
6399
   * If `ld' does not produce an error message for invalid input, that
6400
     may be a bug.  In the general case, the linker can not verify that
6401
     object files are correct.
6402
 
6403
   * If you are an experienced user of linkers, your suggestions for
6404
     improvement of `ld' are welcome in any case.
6405
 
6406

6407
File: ld.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: Reporting Bugs
6408
 
6409
6.2 How to Report Bugs
6410
======================
6411
 
6412
A number of companies and individuals offer support for GNU products.
6413
If you obtained `ld' from a support organization, we recommend you
6414
contact that organization first.
6415
 
6416
   You can find contact information for many support companies and
6417
individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
6418
 
6419
   Otherwise, send bug reports for `ld' to
6420
`http://www.sourceware.org/bugzilla/'.
6421
 
6422
   The fundamental principle of reporting bugs usefully is this:
6423
*report all the facts*.  If you are not sure whether to state a fact or
6424
leave it out, state it!
6425
 
6426
   Often people omit facts because they think they know what causes the
6427
problem and assume that some details do not matter.  Thus, you might
6428
assume that the name of a symbol you use in an example does not matter.
6429
Well, probably it does not, but one cannot be sure.  Perhaps the bug is
6430
a stray memory reference which happens to fetch from the location where
6431
that name is stored in memory; perhaps, if the name were different, the
6432
contents of that location would fool the linker into doing the right
6433
thing despite the bug.  Play it safe and give a specific, complete
6434
example.  That is the easiest thing for you to do, and the most helpful.
6435
 
6436
   Keep in mind that the purpose of a bug report is to enable us to fix
6437
the bug if it is new to us.  Therefore, always write your bug reports
6438
on the assumption that the bug has not been reported previously.
6439
 
6440
   Sometimes people give a few sketchy facts and ask, "Does this ring a
6441
bell?"  This cannot help us fix a bug, so it is basically useless.  We
6442
respond by asking for enough details to enable us to investigate.  You
6443
might as well expedite matters by sending them to begin with.
6444
 
6445
   To enable us to fix the bug, you should include all these things:
6446
 
6447
   * The version of `ld'.  `ld' announces it if you start it with the
6448
     `--version' argument.
6449
 
6450
     Without this, we will not know whether there is any point in
6451
     looking for the bug in the current version of `ld'.
6452
 
6453
   * Any patches you may have applied to the `ld' source, including any
6454
     patches made to the `BFD' library.
6455
 
6456
   * The type of machine you are using, and the operating system name
6457
     and version number.
6458
 
6459
   * What compiler (and its version) was used to compile `ld'--e.g.
6460
     "`gcc-2.7'".
6461
 
6462
   * The command arguments you gave the linker to link your example and
6463
     observe the bug.  To guarantee you will not omit something
6464
     important, list them all.  A copy of the Makefile (or the output
6465
     from make) is sufficient.
6466
 
6467
     If we were to try to guess the arguments, we would probably guess
6468
     wrong and then we might not encounter the bug.
6469
 
6470
   * A complete input file, or set of input files, that will reproduce
6471
     the bug.  It is generally most helpful to send the actual object
6472
     files provided that they are reasonably small.  Say no more than
6473
     10K.  For bigger files you can either make them available by FTP
6474
     or HTTP or else state that you are willing to send the object
6475
     file(s) to whomever requests them.  (Note - your email will be
6476
     going to a mailing list, so we do not want to clog it up with
6477
     large attachments).  But small attachments are best.
6478
 
6479
     If the source files were assembled using `gas' or compiled using
6480
     `gcc', then it may be OK to send the source files rather than the
6481
     object files.  In this case, be sure to say exactly what version of
6482
     `gas' or `gcc' was used to produce the object files.  Also say how
6483
     `gas' or `gcc' were configured.
6484
 
6485
   * A description of what behavior you observe that you believe is
6486
     incorrect.  For example, "It gets a fatal signal."
6487
 
6488
     Of course, if the bug is that `ld' gets a fatal signal, then we
6489
     will certainly notice it.  But if the bug is incorrect output, we
6490
     might not notice unless it is glaringly wrong.  You might as well
6491
     not give us a chance to make a mistake.
6492
 
6493
     Even if the problem you experience is a fatal signal, you should
6494
     still say so explicitly.  Suppose something strange is going on,
6495
     such as, your copy of `ld' is out of sync, or you have encountered
6496
     a bug in the C library on your system.  (This has happened!)  Your
6497
     copy might crash and ours would not.  If you told us to expect a
6498
     crash, then when ours fails to crash, we would know that the bug
6499
     was not happening for us.  If you had not told us to expect a
6500
     crash, then we would not be able to draw any conclusion from our
6501
     observations.
6502
 
6503
   * If you wish to suggest changes to the `ld' source, send us context
6504
     diffs, as generated by `diff' with the `-u', `-c', or `-p' option.
6505
     Always send diffs from the old file to the new file.  If you even
6506
     discuss something in the `ld' source, refer to it by context, not
6507
     by line number.
6508
 
6509
     The line numbers in our development sources will not match those
6510
     in your sources.  Your line numbers would convey no useful
6511
     information to us.
6512
 
6513
   Here are some things that are not necessary:
6514
 
6515
   * A description of the envelope of the bug.
6516
 
6517
     Often people who encounter a bug spend a lot of time investigating
6518
     which changes to the input file will make the bug go away and which
6519
     changes will not affect it.
6520
 
6521
     This is often time consuming and not very useful, because the way
6522
     we will find the bug is by running a single example under the
6523
     debugger with breakpoints, not by pure deduction from a series of
6524
     examples.  We recommend that you save your time for something else.
6525
 
6526
     Of course, if you can find a simpler example to report _instead_
6527
     of the original one, that is a convenience for us.  Errors in the
6528
     output will be easier to spot, running under the debugger will take
6529
     less time, and so on.
6530
 
6531
     However, simplification is not vital; if you do not want to do
6532
     this, report the bug anyway and send us the entire test case you
6533
     used.
6534
 
6535
   * A patch for the bug.
6536
 
6537
     A patch for the bug does help us if it is a good one.  But do not
6538
     omit the necessary information, such as the test case, on the
6539
     assumption that a patch is all we need.  We might see problems
6540
     with your patch and decide to fix the problem another way, or we
6541
     might not understand it at all.
6542
 
6543
     Sometimes with a program as complicated as `ld' it is very hard to
6544
     construct an example that will make the program follow a certain
6545
     path through the code.  If you do not send us the example, we will
6546
     not be able to construct one, so we will not be able to verify
6547
     that the bug is fixed.
6548
 
6549
     And if we cannot understand what bug you are trying to fix, or why
6550
     your patch should be an improvement, we will not install it.  A
6551
     test case will help us to understand.
6552
 
6553
   * A guess about what the bug is or what it depends on.
6554
 
6555
     Such guesses are usually wrong.  Even we cannot guess right about
6556
     such things without first using the debugger to find the facts.
6557
 
6558

6559
File: ld.info,  Node: MRI,  Next: GNU Free Documentation License,  Prev: Reporting Bugs,  Up: Top
6560
 
6561
Appendix A MRI Compatible Script Files
6562
**************************************
6563
 
6564
To aid users making the transition to GNU `ld' from the MRI linker,
6565
`ld' can use MRI compatible linker scripts as an alternative to the
6566
more general-purpose linker scripting language described in *note
6567
Scripts::.  MRI compatible linker scripts have a much simpler command
6568
set than the scripting language otherwise used with `ld'.  GNU `ld'
6569
supports the most commonly used MRI linker commands; these commands are
6570
described here.
6571
 
6572
   In general, MRI scripts aren't of much use with the `a.out' object
6573
file format, since it only has three sections and MRI scripts lack some
6574
features to make use of them.
6575
 
6576
   You can specify a file containing an MRI-compatible script using the
6577
`-c' command-line option.
6578
 
6579
   Each command in an MRI-compatible script occupies its own line; each
6580
command line starts with the keyword that identifies the command (though
6581
blank lines are also allowed for punctuation).  If a line of an
6582
MRI-compatible script begins with an unrecognized keyword, `ld' issues
6583
a warning message, but continues processing the script.
6584
 
6585
   Lines beginning with `*' are comments.
6586
 
6587
   You can write these commands using all upper-case letters, or all
6588
lower case; for example, `chip' is the same as `CHIP'.  The following
6589
list shows only the upper-case form of each command.
6590
 
6591
`ABSOLUTE SECNAME'
6592
`ABSOLUTE SECNAME, SECNAME, ... SECNAME'
6593
     Normally, `ld' includes in the output file all sections from all
6594
     the input files.  However, in an MRI-compatible script, you can
6595
     use the `ABSOLUTE' command to restrict the sections that will be
6596
     present in your output program.  If the `ABSOLUTE' command is used
6597
     at all in a script, then only the sections named explicitly in
6598
     `ABSOLUTE' commands will appear in the linker output.  You can
6599
     still use other input sections (whatever you select on the command
6600
     line, or using `LOAD') to resolve addresses in the output file.
6601
 
6602
`ALIAS OUT-SECNAME, IN-SECNAME'
6603
     Use this command to place the data from input section IN-SECNAME
6604
     in a section called OUT-SECNAME in the linker output file.
6605
 
6606
     IN-SECNAME may be an integer.
6607
 
6608
`ALIGN SECNAME = EXPRESSION'
6609
     Align the section called SECNAME to EXPRESSION.  The EXPRESSION
6610
     should be a power of two.
6611
 
6612
`BASE EXPRESSION'
6613
     Use the value of EXPRESSION as the lowest address (other than
6614
     absolute addresses) in the output file.
6615
 
6616
`CHIP EXPRESSION'
6617
`CHIP EXPRESSION, EXPRESSION'
6618
     This command does nothing; it is accepted only for compatibility.
6619
 
6620
`END'
6621
     This command does nothing whatever; it's only accepted for
6622
     compatibility.
6623
 
6624
`FORMAT OUTPUT-FORMAT'
6625
     Similar to the `OUTPUT_FORMAT' command in the more general linker
6626
     language, but restricted to one of these output formats:
6627
 
6628
       1. S-records, if OUTPUT-FORMAT is `S'
6629
 
6630
       2. IEEE, if OUTPUT-FORMAT is `IEEE'
6631
 
6632
       3. COFF (the `coff-m68k' variant in BFD), if OUTPUT-FORMAT is
6633
          `COFF'
6634
 
6635
`LIST ANYTHING...'
6636
     Print (to the standard output file) a link map, as produced by the
6637
     `ld' command-line option `-M'.
6638
 
6639
     The keyword `LIST' may be followed by anything on the same line,
6640
     with no change in its effect.
6641
 
6642
`LOAD FILENAME'
6643
`LOAD FILENAME, FILENAME, ... FILENAME'
6644
     Include one or more object file FILENAME in the link; this has the
6645
     same effect as specifying FILENAME directly on the `ld' command
6646
     line.
6647
 
6648
`NAME OUTPUT-NAME'
6649
     OUTPUT-NAME is the name for the program produced by `ld'; the
6650
     MRI-compatible command `NAME' is equivalent to the command-line
6651
     option `-o' or the general script language command `OUTPUT'.
6652
 
6653
`ORDER SECNAME, SECNAME, ... SECNAME'
6654
`ORDER SECNAME SECNAME SECNAME'
6655
     Normally, `ld' orders the sections in its output file in the order
6656
     in which they first appear in the input files.  In an
6657
     MRI-compatible script, you can override this ordering with the
6658
     `ORDER' command.  The sections you list with `ORDER' will appear
6659
     first in your output file, in the order specified.
6660
 
6661
`PUBLIC NAME=EXPRESSION'
6662
`PUBLIC NAME,EXPRESSION'
6663
`PUBLIC NAME EXPRESSION'
6664
     Supply a value (EXPRESSION) for external symbol NAME used in the
6665
     linker input files.
6666
 
6667
`SECT SECNAME, EXPRESSION'
6668
`SECT SECNAME=EXPRESSION'
6669
`SECT SECNAME EXPRESSION'
6670
     You can use any of these three forms of the `SECT' command to
6671
     specify the start address (EXPRESSION) for section SECNAME.  If
6672
     you have more than one `SECT' statement for the same SECNAME, only
6673
     the _first_ sets the start address.
6674
 
6675

6676
File: ld.info,  Node: GNU Free Documentation License,  Next: LD Index,  Prev: MRI,  Up: Top
6677
 
6678
Appendix B GNU Free Documentation License
6679
*****************************************
6680
 
6681
                     Version 1.3, 3 November 2008
6682
 
6683
     Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
6684
     `http://fsf.org/'
6685
 
6686
     Everyone is permitted to copy and distribute verbatim copies
6687
     of this license document, but changing it is not allowed.
6688
 
6689
  0. PREAMBLE
6690
 
6691
     The purpose of this License is to make a manual, textbook, or other
6692
     functional and useful document "free" in the sense of freedom: to
6693
     assure everyone the effective freedom to copy and redistribute it,
6694
     with or without modifying it, either commercially or
6695
     noncommercially.  Secondarily, this License preserves for the
6696
     author and publisher a way to get credit for their work, while not
6697
     being considered responsible for modifications made by others.
6698
 
6699
     This License is a kind of "copyleft", which means that derivative
6700
     works of the document must themselves be free in the same sense.
6701
     It complements the GNU General Public License, which is a copyleft
6702
     license designed for free software.
6703
 
6704
     We have designed this License in order to use it for manuals for
6705
     free software, because free software needs free documentation: a
6706
     free program should come with manuals providing the same freedoms
6707
     that the software does.  But this License is not limited to
6708
     software manuals; it can be used for any textual work, regardless
6709
     of subject matter or whether it is published as a printed book.
6710
     We recommend this License principally for works whose purpose is
6711
     instruction or reference.
6712
 
6713
  1. APPLICABILITY AND DEFINITIONS
6714
 
6715
     This License applies to any manual or other work, in any medium,
6716
     that contains a notice placed by the copyright holder saying it
6717
     can be distributed under the terms of this License.  Such a notice
6718
     grants a world-wide, royalty-free license, unlimited in duration,
6719
     to use that work under the conditions stated herein.  The
6720
     "Document", below, refers to any such manual or work.  Any member
6721
     of the public is a licensee, and is addressed as "you".  You
6722
     accept the license if you copy, modify or distribute the work in a
6723
     way requiring permission under copyright law.
6724
 
6725
     A "Modified Version" of the Document means any work containing the
6726
     Document or a portion of it, either copied verbatim, or with
6727
     modifications and/or translated into another language.
6728
 
6729
     A "Secondary Section" is a named appendix or a front-matter section
6730
     of the Document that deals exclusively with the relationship of the
6731
     publishers or authors of the Document to the Document's overall
6732
     subject (or to related matters) and contains nothing that could
6733
     fall directly within that overall subject.  (Thus, if the Document
6734
     is in part a textbook of mathematics, a Secondary Section may not
6735
     explain any mathematics.)  The relationship could be a matter of
6736
     historical connection with the subject or with related matters, or
6737
     of legal, commercial, philosophical, ethical or political position
6738
     regarding them.
6739
 
6740
     The "Invariant Sections" are certain Secondary Sections whose
6741
     titles are designated, as being those of Invariant Sections, in
6742
     the notice that says that the Document is released under this
6743
     License.  If a section does not fit the above definition of
6744
     Secondary then it is not allowed to be designated as Invariant.
6745
     The Document may contain zero Invariant Sections.  If the Document
6746
     does not identify any Invariant Sections then there are none.
6747
 
6748
     The "Cover Texts" are certain short passages of text that are
6749
     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
6750
     that says that the Document is released under this License.  A
6751
     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
6752
     be at most 25 words.
6753
 
6754
     A "Transparent" copy of the Document means a machine-readable copy,
6755
     represented in a format whose specification is available to the
6756
     general public, that is suitable for revising the document
6757
     straightforwardly with generic text editors or (for images
6758
     composed of pixels) generic paint programs or (for drawings) some
6759
     widely available drawing editor, and that is suitable for input to
6760
     text formatters or for automatic translation to a variety of
6761
     formats suitable for input to text formatters.  A copy made in an
6762
     otherwise Transparent file format whose markup, or absence of
6763
     markup, has been arranged to thwart or discourage subsequent
6764
     modification by readers is not Transparent.  An image format is
6765
     not Transparent if used for any substantial amount of text.  A
6766
     copy that is not "Transparent" is called "Opaque".
6767
 
6768
     Examples of suitable formats for Transparent copies include plain
6769
     ASCII without markup, Texinfo input format, LaTeX input format,
6770
     SGML or XML using a publicly available DTD, and
6771
     standard-conforming simple HTML, PostScript or PDF designed for
6772
     human modification.  Examples of transparent image formats include
6773
     PNG, XCF and JPG.  Opaque formats include proprietary formats that
6774
     can be read and edited only by proprietary word processors, SGML or
6775
     XML for which the DTD and/or processing tools are not generally
6776
     available, and the machine-generated HTML, PostScript or PDF
6777
     produced by some word processors for output purposes only.
6778
 
6779
     The "Title Page" means, for a printed book, the title page itself,
6780
     plus such following pages as are needed to hold, legibly, the
6781
     material this License requires to appear in the title page.  For
6782
     works in formats which do not have any title page as such, "Title
6783
     Page" means the text near the most prominent appearance of the
6784
     work's title, preceding the beginning of the body of the text.
6785
 
6786
     The "publisher" means any person or entity that distributes copies
6787
     of the Document to the public.
6788
 
6789
     A section "Entitled XYZ" means a named subunit of the Document
6790
     whose title either is precisely XYZ or contains XYZ in parentheses
6791
     following text that translates XYZ in another language.  (Here XYZ
6792
     stands for a specific section name mentioned below, such as
6793
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
6794
     To "Preserve the Title" of such a section when you modify the
6795
     Document means that it remains a section "Entitled XYZ" according
6796
     to this definition.
6797
 
6798
     The Document may include Warranty Disclaimers next to the notice
6799
     which states that this License applies to the Document.  These
6800
     Warranty Disclaimers are considered to be included by reference in
6801
     this License, but only as regards disclaiming warranties: any other
6802
     implication that these Warranty Disclaimers may have is void and
6803
     has no effect on the meaning of this License.
6804
 
6805
  2. VERBATIM COPYING
6806
 
6807
     You may copy and distribute the Document in any medium, either
6808
     commercially or noncommercially, provided that this License, the
6809
     copyright notices, and the license notice saying this License
6810
     applies to the Document are reproduced in all copies, and that you
6811
     add no other conditions whatsoever to those of this License.  You
6812
     may not use technical measures to obstruct or control the reading
6813
     or further copying of the copies you make or distribute.  However,
6814
     you may accept compensation in exchange for copies.  If you
6815
     distribute a large enough number of copies you must also follow
6816
     the conditions in section 3.
6817
 
6818
     You may also lend copies, under the same conditions stated above,
6819
     and you may publicly display copies.
6820
 
6821
  3. COPYING IN QUANTITY
6822
 
6823
     If you publish printed copies (or copies in media that commonly
6824
     have printed covers) of the Document, numbering more than 100, and
6825
     the Document's license notice requires Cover Texts, you must
6826
     enclose the copies in covers that carry, clearly and legibly, all
6827
     these Cover Texts: Front-Cover Texts on the front cover, and
6828
     Back-Cover Texts on the back cover.  Both covers must also clearly
6829
     and legibly identify you as the publisher of these copies.  The
6830
     front cover must present the full title with all words of the
6831
     title equally prominent and visible.  You may add other material
6832
     on the covers in addition.  Copying with changes limited to the
6833
     covers, as long as they preserve the title of the Document and
6834
     satisfy these conditions, can be treated as verbatim copying in
6835
     other respects.
6836
 
6837
     If the required texts for either cover are too voluminous to fit
6838
     legibly, you should put the first ones listed (as many as fit
6839
     reasonably) on the actual cover, and continue the rest onto
6840
     adjacent pages.
6841
 
6842
     If you publish or distribute Opaque copies of the Document
6843
     numbering more than 100, you must either include a
6844
     machine-readable Transparent copy along with each Opaque copy, or
6845
     state in or with each Opaque copy a computer-network location from
6846
     which the general network-using public has access to download
6847
     using public-standard network protocols a complete Transparent
6848
     copy of the Document, free of added material.  If you use the
6849
     latter option, you must take reasonably prudent steps, when you
6850
     begin distribution of Opaque copies in quantity, to ensure that
6851
     this Transparent copy will remain thus accessible at the stated
6852
     location until at least one year after the last time you
6853
     distribute an Opaque copy (directly or through your agents or
6854
     retailers) of that edition to the public.
6855
 
6856
     It is requested, but not required, that you contact the authors of
6857
     the Document well before redistributing any large number of
6858
     copies, to give them a chance to provide you with an updated
6859
     version of the Document.
6860
 
6861
  4. MODIFICATIONS
6862
 
6863
     You may copy and distribute a Modified Version of the Document
6864
     under the conditions of sections 2 and 3 above, provided that you
6865
     release the Modified Version under precisely this License, with
6866
     the Modified Version filling the role of the Document, thus
6867
     licensing distribution and modification of the Modified Version to
6868
     whoever possesses a copy of it.  In addition, you must do these
6869
     things in the Modified Version:
6870
 
6871
       A. Use in the Title Page (and on the covers, if any) a title
6872
          distinct from that of the Document, and from those of
6873
          previous versions (which should, if there were any, be listed
6874
          in the History section of the Document).  You may use the
6875
          same title as a previous version if the original publisher of
6876
          that version gives permission.
6877
 
6878
       B. List on the Title Page, as authors, one or more persons or
6879
          entities responsible for authorship of the modifications in
6880
          the Modified Version, together with at least five of the
6881
          principal authors of the Document (all of its principal
6882
          authors, if it has fewer than five), unless they release you
6883
          from this requirement.
6884
 
6885
       C. State on the Title page the name of the publisher of the
6886
          Modified Version, as the publisher.
6887
 
6888
       D. Preserve all the copyright notices of the Document.
6889
 
6890
       E. Add an appropriate copyright notice for your modifications
6891
          adjacent to the other copyright notices.
6892
 
6893
       F. Include, immediately after the copyright notices, a license
6894
          notice giving the public permission to use the Modified
6895
          Version under the terms of this License, in the form shown in
6896
          the Addendum below.
6897
 
6898
       G. Preserve in that license notice the full lists of Invariant
6899
          Sections and required Cover Texts given in the Document's
6900
          license notice.
6901
 
6902
       H. Include an unaltered copy of this License.
6903
 
6904
       I. Preserve the section Entitled "History", Preserve its Title,
6905
          and add to it an item stating at least the title, year, new
6906
          authors, and publisher of the Modified Version as given on
6907
          the Title Page.  If there is no section Entitled "History" in
6908
          the Document, create one stating the title, year, authors,
6909
          and publisher of the Document as given on its Title Page,
6910
          then add an item describing the Modified Version as stated in
6911
          the previous sentence.
6912
 
6913
       J. Preserve the network location, if any, given in the Document
6914
          for public access to a Transparent copy of the Document, and
6915
          likewise the network locations given in the Document for
6916
          previous versions it was based on.  These may be placed in
6917
          the "History" section.  You may omit a network location for a
6918
          work that was published at least four years before the
6919
          Document itself, or if the original publisher of the version
6920
          it refers to gives permission.
6921
 
6922
       K. For any section Entitled "Acknowledgements" or "Dedications",
6923
          Preserve the Title of the section, and preserve in the
6924
          section all the substance and tone of each of the contributor
6925
          acknowledgements and/or dedications given therein.
6926
 
6927
       L. Preserve all the Invariant Sections of the Document,
6928
          unaltered in their text and in their titles.  Section numbers
6929
          or the equivalent are not considered part of the section
6930
          titles.
6931
 
6932
       M. Delete any section Entitled "Endorsements".  Such a section
6933
          may not be included in the Modified Version.
6934
 
6935
       N. Do not retitle any existing section to be Entitled
6936
          "Endorsements" or to conflict in title with any Invariant
6937
          Section.
6938
 
6939
       O. Preserve any Warranty Disclaimers.
6940
 
6941
     If the Modified Version includes new front-matter sections or
6942
     appendices that qualify as Secondary Sections and contain no
6943
     material copied from the Document, you may at your option
6944
     designate some or all of these sections as invariant.  To do this,
6945
     add their titles to the list of Invariant Sections in the Modified
6946
     Version's license notice.  These titles must be distinct from any
6947
     other section titles.
6948
 
6949
     You may add a section Entitled "Endorsements", provided it contains
6950
     nothing but endorsements of your Modified Version by various
6951
     parties--for example, statements of peer review or that the text
6952
     has been approved by an organization as the authoritative
6953
     definition of a standard.
6954
 
6955
     You may add a passage of up to five words as a Front-Cover Text,
6956
     and a passage of up to 25 words as a Back-Cover Text, to the end
6957
     of the list of Cover Texts in the Modified Version.  Only one
6958
     passage of Front-Cover Text and one of Back-Cover Text may be
6959
     added by (or through arrangements made by) any one entity.  If the
6960
     Document already includes a cover text for the same cover,
6961
     previously added by you or by arrangement made by the same entity
6962
     you are acting on behalf of, you may not add another; but you may
6963
     replace the old one, on explicit permission from the previous
6964
     publisher that added the old one.
6965
 
6966
     The author(s) and publisher(s) of the Document do not by this
6967
     License give permission to use their names for publicity for or to
6968
     assert or imply endorsement of any Modified Version.
6969
 
6970
  5. COMBINING DOCUMENTS
6971
 
6972
     You may combine the Document with other documents released under
6973
     this License, under the terms defined in section 4 above for
6974
     modified versions, provided that you include in the combination
6975
     all of the Invariant Sections of all of the original documents,
6976
     unmodified, and list them all as Invariant Sections of your
6977
     combined work in its license notice, and that you preserve all
6978
     their Warranty Disclaimers.
6979
 
6980
     The combined work need only contain one copy of this License, and
6981
     multiple identical Invariant Sections may be replaced with a single
6982
     copy.  If there are multiple Invariant Sections with the same name
6983
     but different contents, make the title of each such section unique
6984
     by adding at the end of it, in parentheses, the name of the
6985
     original author or publisher of that section if known, or else a
6986
     unique number.  Make the same adjustment to the section titles in
6987
     the list of Invariant Sections in the license notice of the
6988
     combined work.
6989
 
6990
     In the combination, you must combine any sections Entitled
6991
     "History" in the various original documents, forming one section
6992
     Entitled "History"; likewise combine any sections Entitled
6993
     "Acknowledgements", and any sections Entitled "Dedications".  You
6994
     must delete all sections Entitled "Endorsements."
6995
 
6996
  6. COLLECTIONS OF DOCUMENTS
6997
 
6998
     You may make a collection consisting of the Document and other
6999
     documents released under this License, and replace the individual
7000
     copies of this License in the various documents with a single copy
7001
     that is included in the collection, provided that you follow the
7002
     rules of this License for verbatim copying of each of the
7003
     documents in all other respects.
7004
 
7005
     You may extract a single document from such a collection, and
7006
     distribute it individually under this License, provided you insert
7007
     a copy of this License into the extracted document, and follow
7008
     this License in all other respects regarding verbatim copying of
7009
     that document.
7010
 
7011
  7. AGGREGATION WITH INDEPENDENT WORKS
7012
 
7013
     A compilation of the Document or its derivatives with other
7014
     separate and independent documents or works, in or on a volume of
7015
     a storage or distribution medium, is called an "aggregate" if the
7016
     copyright resulting from the compilation is not used to limit the
7017
     legal rights of the compilation's users beyond what the individual
7018
     works permit.  When the Document is included in an aggregate, this
7019
     License does not apply to the other works in the aggregate which
7020
     are not themselves derivative works of the Document.
7021
 
7022
     If the Cover Text requirement of section 3 is applicable to these
7023
     copies of the Document, then if the Document is less than one half
7024
     of the entire aggregate, the Document's Cover Texts may be placed
7025
     on covers that bracket the Document within the aggregate, or the
7026
     electronic equivalent of covers if the Document is in electronic
7027
     form.  Otherwise they must appear on printed covers that bracket
7028
     the whole aggregate.
7029
 
7030
  8. TRANSLATION
7031
 
7032
     Translation is considered a kind of modification, so you may
7033
     distribute translations of the Document under the terms of section
7034
     4.  Replacing Invariant Sections with translations requires special
7035
     permission from their copyright holders, but you may include
7036
     translations of some or all Invariant Sections in addition to the
7037
     original versions of these Invariant Sections.  You may include a
7038
     translation of this License, and all the license notices in the
7039
     Document, and any Warranty Disclaimers, provided that you also
7040
     include the original English version of this License and the
7041
     original versions of those notices and disclaimers.  In case of a
7042
     disagreement between the translation and the original version of
7043
     this License or a notice or disclaimer, the original version will
7044
     prevail.
7045
 
7046
     If a section in the Document is Entitled "Acknowledgements",
7047
     "Dedications", or "History", the requirement (section 4) to
7048
     Preserve its Title (section 1) will typically require changing the
7049
     actual title.
7050
 
7051
  9. TERMINATION
7052
 
7053
     You may not copy, modify, sublicense, or distribute the Document
7054
     except as expressly provided under this License.  Any attempt
7055
     otherwise to copy, modify, sublicense, or distribute it is void,
7056
     and will automatically terminate your rights under this License.
7057
 
7058
     However, if you cease all violation of this License, then your
7059
     license from a particular copyright holder is reinstated (a)
7060
     provisionally, unless and until the copyright holder explicitly
7061
     and finally terminates your license, and (b) permanently, if the
7062
     copyright holder fails to notify you of the violation by some
7063
     reasonable means prior to 60 days after the cessation.
7064
 
7065
     Moreover, your license from a particular copyright holder is
7066
     reinstated permanently if the copyright holder notifies you of the
7067
     violation by some reasonable means, this is the first time you have
7068
     received notice of violation of this License (for any work) from
7069
     that copyright holder, and you cure the violation prior to 30 days
7070
     after your receipt of the notice.
7071
 
7072
     Termination of your rights under this section does not terminate
7073
     the licenses of parties who have received copies or rights from
7074
     you under this License.  If your rights have been terminated and
7075
     not permanently reinstated, receipt of a copy of some or all of
7076
     the same material does not give you any rights to use it.
7077
 
7078
 10. FUTURE REVISIONS OF THIS LICENSE
7079
 
7080
     The Free Software Foundation may publish new, revised versions of
7081
     the GNU Free Documentation License from time to time.  Such new
7082
     versions will be similar in spirit to the present version, but may
7083
     differ in detail to address new problems or concerns.  See
7084
     `http://www.gnu.org/copyleft/'.
7085
 
7086
     Each version of the License is given a distinguishing version
7087
     number.  If the Document specifies that a particular numbered
7088
     version of this License "or any later version" applies to it, you
7089
     have the option of following the terms and conditions either of
7090
     that specified version or of any later version that has been
7091
     published (not as a draft) by the Free Software Foundation.  If
7092
     the Document does not specify a version number of this License,
7093
     you may choose any version ever published (not as a draft) by the
7094
     Free Software Foundation.  If the Document specifies that a proxy
7095
     can decide which future versions of this License can be used, that
7096
     proxy's public statement of acceptance of a version permanently
7097
     authorizes you to choose that version for the Document.
7098
 
7099
 11. RELICENSING
7100
 
7101
     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
7102
     World Wide Web server that publishes copyrightable works and also
7103
     provides prominent facilities for anybody to edit those works.  A
7104
     public wiki that anybody can edit is an example of such a server.
7105
     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
7106
     site means any set of copyrightable works thus published on the MMC
7107
     site.
7108
 
7109
     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
7110
     license published by Creative Commons Corporation, a not-for-profit
7111
     corporation with a principal place of business in San Francisco,
7112
     California, as well as future copyleft versions of that license
7113
     published by that same organization.
7114
 
7115
     "Incorporate" means to publish or republish a Document, in whole or
7116
     in part, as part of another Document.
7117
 
7118
     An MMC is "eligible for relicensing" if it is licensed under this
7119
     License, and if all works that were first published under this
7120
     License somewhere other than this MMC, and subsequently
7121
     incorporated in whole or in part into the MMC, (1) had no cover
7122
     texts or invariant sections, and (2) were thus incorporated prior
7123
     to November 1, 2008.
7124
 
7125
     The operator of an MMC Site may republish an MMC contained in the
7126
     site under CC-BY-SA on the same site at any time before August 1,
7127
     2009, provided the MMC is eligible for relicensing.
7128
 
7129
 
7130
ADDENDUM: How to use this License for your documents
7131
====================================================
7132
 
7133
To use this License in a document you have written, include a copy of
7134
the License in the document and put the following copyright and license
7135
notices just after the title page:
7136
 
7137
       Copyright (C)  YEAR  YOUR NAME.
7138
       Permission is granted to copy, distribute and/or modify this document
7139
       under the terms of the GNU Free Documentation License, Version 1.3
7140
       or any later version published by the Free Software Foundation;
7141
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
7142
       Texts.  A copy of the license is included in the section entitled ``GNU
7143
       Free Documentation License''.
7144
 
7145
   If you have Invariant Sections, Front-Cover Texts and Back-Cover
7146
Texts, replace the "with...Texts." line with this:
7147
 
7148
         with the Invariant Sections being LIST THEIR TITLES, with
7149
         the Front-Cover Texts being LIST, and with the Back-Cover Texts
7150
         being LIST.
7151
 
7152
   If you have Invariant Sections without Cover Texts, or some other
7153
combination of the three, merge those two alternatives to suit the
7154
situation.
7155
 
7156
   If your document contains nontrivial examples of program code, we
7157
recommend releasing these examples in parallel under your choice of
7158
free software license, such as the GNU General Public License, to
7159
permit their use in free software.
7160
 
7161

7162
File: ld.info,  Node: LD Index,  Prev: GNU Free Documentation License,  Up: Top
7163
 
7164
LD Index
7165
********
7166
 
7167
 
7168
* Menu:
7169
7170
* ":                                     Symbols.            (line    6)
7171
* -(:                                    Options.            (line  706)
7172
* --accept-unknown-input-arch:           Options.            (line  724)
7173
* --add-needed:                          Options.            (line  748)
7174
* --add-stdcall-alias:                   Options.            (line 1593)
7175
* --allow-multiple-definition:           Options.            (line  999)
7176
* --allow-shlib-undefined:               Options.            (line 1005)
7177
* --architecture=ARCH:                   Options.            (line  123)
7178
* --as-needed:                           Options.            (line  734)
7179
* --audit AUDITLIB:                      Options.            (line  112)
7180
* --auxiliary=NAME:                      Options.            (line  255)
7181
* --bank-window:                         Options.            (line 2025)
7182
* --base-file:                           Options.            (line 1598)
7183
* --be8:                                 ARM.                (line   28)
7184
* --bss-plt:                             PowerPC ELF32.      (line   16)
7185
* --build-id:                            Options.            (line 1555)
7186
* --build-id=STYLE:                      Options.            (line 1555)
7187
* --check-sections:                      Options.            (line  827)
7188
* --copy-dt-needed-entries:              Options.            (line  839)
7189
* --cref:                                Options.            (line  859)
7190
* --default-imported-symver:             Options.            (line 1042)
7191
* --default-script=SCRIPT:               Options.            (line  541)
7192
* --default-symver:                      Options.            (line 1038)
7193
* --defsym=SYMBOL=EXP:                   Options.            (line  887)
7194
* --demangle[=STYLE]:                    Options.            (line  900)
7195
* --depaudit AUDITLIB:                   Options.            (line  177)
7196
* --disable-auto-image-base:             Options.            (line 1777)
7197
* --disable-auto-import:                 Options.            (line 1912)
7198
* --disable-long-section-names:          Options.            (line 1608)
7199
* --disable-new-dtags:                   Options.            (line 1518)
7200
* --disable-runtime-pseudo-reloc:        Options.            (line 1925)
7201
* --disable-stdcall-fixup:               Options.            (line 1630)
7202
* --discard-all:                         Options.            (line  587)
7203
* --discard-locals:                      Options.            (line  591)
7204
* --dll:                                 Options.            (line 1603)
7205
* --dll-search-prefix:                   Options.            (line 1783)
7206
* --dotsyms:                             PowerPC64 ELF64.    (line   33)
7207
* --dsbt-index:                          Options.            (line 2002)
7208
* --dsbt-size:                           Options.            (line 1997)
7209
* --dynamic-linker=FILE:                 Options.            (line  913)
7210
* --dynamic-list-cpp-new:                Options.            (line  819)
7211
* --dynamic-list-cpp-typeinfo:           Options.            (line  823)
7212
* --dynamic-list-data:                   Options.            (line  816)
7213
* --dynamic-list=DYNAMIC-LIST-FILE:      Options.            (line  803)
7214
* --dynamicbase:                         Options.            (line 1961)
7215
* --eh-frame-hdr:                        Options.            (line 1509)
7216
* --emit-relocs:                         Options.            (line  476)
7217
* --emit-stack-syms:                     SPU ELF.            (line   46)
7218
* --emit-stub-syms <1>:                  SPU ELF.            (line   15)
7219
* --emit-stub-syms <2>:                  PowerPC64 ELF64.    (line   29)
7220
* --emit-stub-syms:                      PowerPC ELF32.      (line   47)
7221
* --enable-auto-image-base:              Options.            (line 1769)
7222
* --enable-auto-import:                  Options.            (line 1792)
7223
* --enable-extra-pe-debug:               Options.            (line 1930)
7224
* --enable-long-section-names:           Options.            (line 1608)
7225
* --enable-new-dtags:                    Options.            (line 1518)
7226
* --enable-runtime-pseudo-reloc:         Options.            (line 1917)
7227
* --enable-stdcall-fixup:                Options.            (line 1630)
7228
* --entry=ENTRY:                         Options.            (line  187)
7229
* --error-unresolved-symbols:            Options.            (line 1462)
7230
* --exclude-all-symbols:                 Options.            (line 1684)
7231
* --exclude-libs:                        Options.            (line  197)
7232
* --exclude-modules-for-implib:          Options.            (line  208)
7233
* --exclude-symbols:                     Options.            (line 1678)
7234
* --export-all-symbols:                  Options.            (line 1654)
7235
* --export-dynamic:                      Options.            (line  221)
7236
* --extra-overlay-stubs:                 SPU ELF.            (line   19)
7237
* --fatal-warnings:                      Options.            (line  920)
7238
* --file-alignment:                      Options.            (line 1688)
7239
* --filter=NAME:                         Options.            (line  276)
7240
* --fix-arm1176:                         ARM.                (line  111)
7241
* --fix-cortex-a8:                       i960.               (line   39)
7242
* --fix-v4bx:                            ARM.                (line   49)
7243
* --fix-v4bx-interworking:               ARM.                (line   62)
7244
* --force-dynamic:                       Options.            (line  485)
7245
* --force-exe-suffix:                    Options.            (line  925)
7246
* --forceinteg:                          Options.            (line 1966)
7247
* --format=FORMAT:                       Options.            (line  134)
7248
* --format=VERSION:                      TI COFF.            (line    6)
7249
* --gc-sections:                         Options.            (line  935)
7250
* --got:                                 Options.            (line 2038)
7251
* --got=TYPE:                            M68K.               (line    6)
7252
* --gpsize=VALUE:                        Options.            (line  309)
7253
* --hash-size=NUMBER:                    Options.            (line 1527)
7254
* --hash-style=STYLE:                    Options.            (line 1535)
7255
* --heap:                                Options.            (line 1694)
7256
* --help:                                Options.            (line  972)
7257
* --image-base:                          Options.            (line 1701)
7258
* --just-symbols=FILE:                   Options.            (line  508)
7259
* --kill-at:                             Options.            (line 1710)
7260
* --large-address-aware:                 Options.            (line 1715)
7261
* --ld-generated-unwind-info:            Options.            (line 1513)
7262
* --leading-underscore:                  Options.            (line 1648)
7263
* --library-path=DIR:                    Options.            (line  368)
7264
* --library=NAMESPEC:                    Options.            (line  335)
7265
* --local-store=lo:hi:                   SPU ELF.            (line   24)
7266
* --major-image-version:                 Options.            (line 1724)
7267
* --major-os-version:                    Options.            (line 1729)
7268
* --major-subsystem-version:             Options.            (line 1733)
7269
* --merge-exidx-entries:                 i960.               (line   48)
7270
* --minor-image-version:                 Options.            (line 1738)
7271
* --minor-os-version:                    Options.            (line 1743)
7272
* --minor-subsystem-version:             Options.            (line 1747)
7273
* --mri-script=MRI-CMDFILE:              Options.            (line  158)
7274
* --multi-subspace:                      HPPA ELF32.         (line    6)
7275
* --nmagic:                              Options.            (line  439)
7276
* --no-accept-unknown-input-arch:        Options.            (line  724)
7277
* --no-add-needed:                       Options.            (line  748)
7278
* --no-allow-shlib-undefined:            Options.            (line 1005)
7279
* --no-as-needed:                        Options.            (line  734)
7280
* --no-bind:                             Options.            (line 1980)
7281
* --no-check-sections:                   Options.            (line  827)
7282
* --no-copy-dt-needed-entries:           Options.            (line  839)
7283
* --no-define-common:                    Options.            (line  871)
7284
* --no-demangle:                         Options.            (line  900)
7285
* --no-dotsyms:                          PowerPC64 ELF64.    (line   33)
7286
* --no-enum-size-warning:                ARM.                (line  120)
7287
* --no-export-dynamic:                   Options.            (line  221)
7288
* --no-fatal-warnings:                   Options.            (line  920)
7289
* --no-fix-arm1176:                      ARM.                (line  111)
7290
* --no-fix-cortex-a8:                    i960.               (line   39)
7291
* --no-gc-sections:                      Options.            (line  935)
7292
* --no-isolation:                        Options.            (line 1973)
7293
* --no-keep-memory:                      Options.            (line  984)
7294
* --no-leading-underscore:               Options.            (line 1648)
7295
* --no-merge-exidx-entries <1>:          i960.               (line   48)
7296
* --no-merge-exidx-entries:              Options.            (line 2009)
7297
* --no-multi-toc:                        PowerPC64 ELF64.    (line   74)
7298
* --no-omagic:                           Options.            (line  454)
7299
* --no-opd-optimize:                     PowerPC64 ELF64.    (line   48)
7300
* --no-overlays:                         SPU ELF.            (line    9)
7301
* --no-plt-align:                        PowerPC64 ELF64.    (line   96)
7302
* --no-plt-static-chain:                 PowerPC64 ELF64.    (line  103)
7303
* --no-plt-thread-safe:                  PowerPC64 ELF64.    (line  109)
7304
* --no-print-gc-sections:                Options.            (line  957)
7305
* --no-seh:                              Options.            (line 1976)
7306
* --no-tls-optimize <1>:                 PowerPC64 ELF64.    (line   43)
7307
* --no-tls-optimize:                     PowerPC ELF32.      (line   51)
7308
* --no-toc-optimize:                     PowerPC64 ELF64.    (line   60)
7309
* --no-toc-sort:                         PowerPC64 ELF64.    (line   86)
7310
* --no-trampoline:                       Options.            (line 2019)
7311
* --no-undefined:                        Options.            (line  991)
7312
* --no-undefined-version:                Options.            (line 1033)
7313
* --no-warn-mismatch:                    Options.            (line 1046)
7314
* --no-warn-search-mismatch:             Options.            (line 1055)
7315
* --no-wchar-size-warning:               ARM.                (line  127)
7316
* --no-whole-archive:                    Options.            (line 1059)
7317
* --noinhibit-exec:                      Options.            (line 1063)
7318
* --non-overlapping-opd:                 PowerPC64 ELF64.    (line   54)
7319
* --nxcompat:                            Options.            (line 1969)
7320
* --oformat=OUTPUT-FORMAT:               Options.            (line 1075)
7321
* --omagic:                              Options.            (line  445)
7322
* --out-implib:                          Options.            (line 1760)
7323
* --output-def:                          Options.            (line 1752)
7324
* --output=OUTPUT:                       Options.            (line  460)
7325
* --pic-executable:                      Options.            (line 1088)
7326
* --pic-veneer:                          ARM.                (line  133)
7327
* --plt-align:                           PowerPC64 ELF64.    (line   96)
7328
* --plt-static-chain:                    PowerPC64 ELF64.    (line  103)
7329
* --plt-thread-safe:                     PowerPC64 ELF64.    (line  109)
7330
* --plugin:                              SPU ELF.            (line    6)
7331
* --print-gc-sections:                   Options.            (line  957)
7332
* --print-map:                           Options.            (line  402)
7333
* --print-output-format:                 Options.            (line  966)
7334
* --reduce-memory-overheads:             Options.            (line 1541)
7335
* --relax:                               Options.            (line 1104)
7336
* --relax on i960:                       i960.               (line   31)
7337
* --relax on PowerPC:                    PowerPC ELF32.      (line    6)
7338
* --relax on Xtensa:                     Xtensa.             (line   27)
7339
* --relocatable:                         Options.            (line  489)
7340
* --retain-symbols-file=FILENAME:        Options.            (line 1130)
7341
* --script=SCRIPT:                       Options.            (line  532)
7342
* --sdata-got:                           PowerPC ELF32.      (line   33)
7343
* --section-alignment:                   Options.            (line 1935)
7344
* --section-start=SECTIONNAME=ORG:       Options.            (line 1286)
7345
* --secure-plt:                          PowerPC ELF32.      (line   26)
7346
* --sort-common:                         Options.            (line 1228)
7347
* --sort-section=alignment:              Options.            (line 1243)
7348
* --sort-section=name:                   Options.            (line 1239)
7349
* --split-by-file:                       Options.            (line 1247)
7350
* --split-by-reloc:                      Options.            (line 1252)
7351
* --stack:                               Options.            (line 1941)
7352
* --stack-analysis:                      SPU ELF.            (line   29)
7353
* --stats:                               Options.            (line 1265)
7354
* --strip-all:                           Options.            (line  519)
7355
* --strip-debug:                         Options.            (line  523)
7356
* --stub-group-size:                     PowerPC64 ELF64.    (line    6)
7357
* --stub-group-size=N <1>:               HPPA ELF32.         (line   12)
7358
* --stub-group-size=N:                   ARM.                (line  138)
7359
* --subsystem:                           Options.            (line 1948)
7360
* --support-old-code:                    ARM.                (line    6)
7361
* --sysroot=DIRECTORY:                   Options.            (line 1269)
7362
* --target-help:                         Options.            (line  976)
7363
* --target1-abs:                         ARM.                (line   32)
7364
* --target1-rel:                         ARM.                (line   32)
7365
* --target2=TYPE:                        ARM.                (line   37)
7366
* --thumb-entry=ENTRY:                   ARM.                (line   17)
7367
* --trace:                               Options.            (line  528)
7368
* --trace-symbol=SYMBOL:                 Options.            (line  597)
7369
* --traditional-format:                  Options.            (line 1274)
7370
* --tsaware:                             Options.            (line 1986)
7371
* --undefined=SYMBOL:                    Options.            (line  554)
7372
* --unique[=SECTION]:                    Options.            (line  572)
7373
* --unresolved-symbols:                  Options.            (line 1305)
7374
* --use-blx:                             ARM.                (line   74)
7375
* --use-nul-prefixed-import-tables:      ARM.                (line   23)
7376
* --verbose[=NUMBER]:                    Options.            (line 1334)
7377
* --version:                             Options.            (line  581)
7378
* --version-script=VERSION-SCRIPTFILE:   Options.            (line 1342)
7379
* --vfp11-denorm-fix:                    ARM.                (line   83)
7380
* --warn-alternate-em:                   Options.            (line 1454)
7381
* --warn-common:                         Options.            (line 1353)
7382
* --warn-constructors:                   Options.            (line 1421)
7383
* --warn-multiple-gp:                    Options.            (line 1426)
7384
* --warn-once:                           Options.            (line 1440)
7385
* --warn-section-align:                  Options.            (line 1444)
7386
* --warn-shared-textrel:                 Options.            (line 1451)
7387
* --warn-unresolved-symbols:             Options.            (line 1457)
7388
* --wdmdriver:                           Options.            (line 1983)
7389
* --whole-archive:                       Options.            (line 1466)
7390
* --wrap=SYMBOL:                         Options.            (line 1480)
7391
* -A ARCH:                               Options.            (line  122)
7392
* -a KEYWORD:                            Options.            (line  105)
7393
* -assert KEYWORD:                       Options.            (line  755)
7394
* -b FORMAT:                             Options.            (line  134)
7395
* -Bdynamic:                             Options.            (line  758)
7396
* -Bgroup:                               Options.            (line  768)
7397
* -Bshareable:                           Options.            (line 1221)
7398
* -Bstatic:                              Options.            (line  775)
7399
* -Bsymbolic:                            Options.            (line  790)
7400
* -Bsymbolic-functions:                  Options.            (line  797)
7401
* -c MRI-CMDFILE:                        Options.            (line  158)
7402
* -call_shared:                          Options.            (line  758)
7403
* -d:                                    Options.            (line  168)
7404
* -dc:                                   Options.            (line  168)
7405
* -dn:                                   Options.            (line  775)
7406
* -dp:                                   Options.            (line  168)
7407
* -dT SCRIPT:                            Options.            (line  541)
7408
* -dy:                                   Options.            (line  758)
7409
* -E:                                    Options.            (line  221)
7410
* -e ENTRY:                              Options.            (line  187)
7411
* -EB:                                   Options.            (line  248)
7412
* -EL:                                   Options.            (line  251)
7413
* -F NAME:                               Options.            (line  276)
7414
* -f NAME:                               Options.            (line  255)
7415
* -fini=NAME:                            Options.            (line  300)
7416
* -g:                                    Options.            (line  306)
7417
* -G VALUE:                              Options.            (line  309)
7418
* -h NAME:                               Options.            (line  317)
7419
* -i:                                    Options.            (line  326)
7420
* -IFILE:                                Options.            (line  913)
7421
* -init=NAME:                            Options.            (line  329)
7422
* -L DIR:                                Options.            (line  368)
7423
* -l NAMESPEC:                           Options.            (line  335)
7424
* -M:                                    Options.            (line  402)
7425
* -m EMULATION:                          Options.            (line  392)
7426
* -Map=MAPFILE:                          Options.            (line  980)
7427
* -N:                                    Options.            (line  445)
7428
* -n:                                    Options.            (line  439)
7429
* -no-relax:                             Options.            (line 1104)
7430
* -non_shared:                           Options.            (line  775)
7431
* -nostdlib:                             Options.            (line 1069)
7432
* -O LEVEL:                              Options.            (line  466)
7433
* -o OUTPUT:                             Options.            (line  460)
7434
* -P AUDITLIB:                           Options.            (line  177)
7435
* -pie:                                  Options.            (line 1088)
7436
* -q:                                    Options.            (line  476)
7437
* -qmagic:                               Options.            (line 1098)
7438
* -Qy:                                   Options.            (line 1101)
7439
* -r:                                    Options.            (line  489)
7440
* -R FILE:                               Options.            (line  508)
7441
* -rpath-link=DIR:                       Options.            (line 1166)
7442
* -rpath=DIR:                            Options.            (line 1144)
7443
* -S:                                    Options.            (line  523)
7444
* -s:                                    Options.            (line  519)
7445
* -shared:                               Options.            (line 1221)
7446
* -soname=NAME:                          Options.            (line  317)
7447
* -static:                               Options.            (line  775)
7448
* -t:                                    Options.            (line  528)
7449
* -T SCRIPT:                             Options.            (line  532)
7450
* -Tbss=ORG:                             Options.            (line 1295)
7451
* -Tdata=ORG:                            Options.            (line 1295)
7452
* -Ttext-segment=ORG:                    Options.            (line 1301)
7453
* -Ttext=ORG:                            Options.            (line 1295)
7454
* -u SYMBOL:                             Options.            (line  554)
7455
* -Ur:                                   Options.            (line  562)
7456
* -V:                                    Options.            (line  581)
7457
* -v:                                    Options.            (line  581)
7458
* -X:                                    Options.            (line  591)
7459
* -x:                                    Options.            (line  587)
7460
* -Y PATH:                               Options.            (line  606)
7461
* -y SYMBOL:                             Options.            (line  597)
7462
* -z defs:                               Options.            (line  991)
7463
* -z KEYWORD:                            Options.            (line  610)
7464
* -z muldefs:                            Options.            (line  999)
7465
* .:                                     Location Counter.   (line    6)
7466
* /DISCARD/:                             Output Section Discarding.
7467
                                                             (line   21)
7468
* :PHDR:                                 Output Section Phdr.
7469
                                                             (line    6)
7470
* =FILLEXP:                              Output Section Fill.
7471
                                                             (line    6)
7472
* >REGION:                               Output Section Region.
7473
                                                             (line    6)
7474
* [COMMON]:                              Input Section Common.
7475
                                                             (line   29)
7476
* ABSOLUTE (MRI):                        MRI.                (line   33)
7477
* absolute and relocatable symbols:      Expression Section. (line    6)
7478
* absolute expressions:                  Expression Section. (line    6)
7479
* ABSOLUTE(EXP):                         Builtin Functions.  (line   10)
7480
* ADDR(SECTION):                         Builtin Functions.  (line   17)
7481
* address, section:                      Output Section Address.
7482
                                                             (line    6)
7483
* ALIAS (MRI):                           MRI.                (line   44)
7484
* ALIGN (MRI):                           MRI.                (line   50)
7485
* align expression:                      Builtin Functions.  (line   38)
7486
* align location counter:                Builtin Functions.  (line   38)
7487
* ALIGN(ALIGN):                          Builtin Functions.  (line   38)
7488
* ALIGN(EXP,ALIGN):                      Builtin Functions.  (line   38)
7489
* ALIGN(SECTION_ALIGN):                  Forced Output Alignment.
7490
                                                             (line    6)
7491
* aligned common symbols:                WIN32.              (line  424)
7492
* ALIGNOF(SECTION):                      Builtin Functions.  (line   63)
7493
* allocating memory:                     MEMORY.             (line    6)
7494
* architecture:                          Miscellaneous Commands.
7495
                                                             (line   72)
7496
* architectures:                         Options.            (line  122)
7497
* archive files, from cmd line:          Options.            (line  335)
7498
* archive search path in linker script:  File Commands.      (line   74)
7499
* arithmetic:                            Expressions.        (line    6)
7500
* arithmetic operators:                  Operators.          (line    6)
7501
* ARM interworking support:              ARM.                (line    6)
7502
* ARM1176 erratum workaround:            ARM.                (line  111)
7503
* AS_NEEDED(FILES):                      File Commands.      (line   54)
7504
* ASSERT:                                Miscellaneous Commands.
7505
                                                             (line    9)
7506
* assertion in linker script:            Miscellaneous Commands.
7507
                                                             (line    9)
7508
* assignment in scripts:                 Assignments.        (line    6)
7509
* AT(LMA):                               Output Section LMA. (line    6)
7510
* AT>LMA_REGION:                         Output Section LMA. (line    6)
7511
* automatic data imports:                WIN32.              (line  191)
7512
* back end:                              BFD.                (line    6)
7513
* BASE (MRI):                            MRI.                (line   54)
7514
* BE8:                                   ARM.                (line   28)
7515
* BFD canonical format:                  Canonical format.   (line   11)
7516
* BFD requirements:                      BFD.                (line   16)
7517
* big-endian objects:                    Options.            (line  248)
7518
* binary input format:                   Options.            (line  134)
7519
* BLOCK(EXP):                            Builtin Functions.  (line   76)
7520
* bug criteria:                          Bug Criteria.       (line    6)
7521
* bug reports:                           Bug Reporting.      (line    6)
7522
* bugs in ld:                            Reporting Bugs.     (line    6)
7523
* BYTE(EXPRESSION):                      Output Section Data.
7524
                                                             (line    6)
7525
* C++ constructors, arranging in link:   Output Section Keywords.
7526
                                                             (line   19)
7527
* CHIP (MRI):                            MRI.                (line   58)
7528
* COLLECT_NO_DEMANGLE:                   Environment.        (line   29)
7529
* combining symbols, warnings on:        Options.            (line 1353)
7530
* command files:                         Scripts.            (line    6)
7531
* command line:                          Options.            (line    6)
7532
* common allocation:                     Options.            (line  168)
7533
* common allocation in linker script:    Miscellaneous Commands.
7534
                                                             (line   20)
7535
* common symbol placement:               Input Section Common.
7536
                                                             (line    6)
7537
* COMMONPAGESIZE:                        Symbolic Constants. (line   13)
7538
* compatibility, MRI:                    Options.            (line  158)
7539
* CONSTANT:                              Symbolic Constants. (line    6)
7540
* constants in linker scripts:           Constants.          (line    6)
7541
* constraints on output sections:        Output Section Constraint.
7542
                                                             (line    6)
7543
* CONSTRUCTORS:                          Output Section Keywords.
7544
                                                             (line   19)
7545
* constructors:                          Options.            (line  562)
7546
* constructors, arranging in link:       Output Section Keywords.
7547
                                                             (line   19)
7548
* Cortex-A8 erratum workaround:          i960.               (line   39)
7549
* crash of linker:                       Bug Criteria.       (line    9)
7550
* CREATE_OBJECT_SYMBOLS:                 Output Section Keywords.
7551
                                                             (line    9)
7552
* creating a DEF file:                   WIN32.              (line  158)
7553
* cross reference table:                 Options.            (line  859)
7554
* cross references:                      Miscellaneous Commands.
7555
                                                             (line   56)
7556
* current output location:               Location Counter.   (line    6)
7557
* data:                                  Output Section Data.
7558
                                                             (line    6)
7559
* DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE): Builtin Functions.
7560
                                                             (line   81)
7561
* DATA_SEGMENT_END(EXP):                 Builtin Functions.  (line  102)
7562
* DATA_SEGMENT_RELRO_END(OFFSET, EXP):   Builtin Functions.  (line  108)
7563
* dbx:                                   Options.            (line 1279)
7564
* DEF files, creating:                   Options.            (line 1752)
7565
* default emulation:                     Environment.        (line   21)
7566
* default input format:                  Environment.        (line    9)
7567
* DEFINED(SYMBOL):                       Builtin Functions.  (line  119)
7568
* deleting local symbols:                Options.            (line  587)
7569
* demangling, default:                   Environment.        (line   29)
7570
* demangling, from command line:         Options.            (line  900)
7571
* direct linking to a dll:               WIN32.              (line  239)
7572
* discarding sections:                   Output Section Discarding.
7573
                                                             (line    6)
7574
* discontinuous memory:                  MEMORY.             (line    6)
7575
* DLLs, creating:                        Options.            (line 1654)
7576
* DLLs, linking to:                      Options.            (line 1783)
7577
* dot:                                   Location Counter.   (line    6)
7578
* dot inside sections:                   Location Counter.   (line   36)
7579
* dot outside sections:                  Location Counter.   (line   66)
7580
* dynamic linker, from command line:     Options.            (line  913)
7581
* dynamic symbol table:                  Options.            (line  221)
7582
* ELF program headers:                   PHDRS.              (line    6)
7583
* emulation:                             Options.            (line  392)
7584
* emulation, default:                    Environment.        (line   21)
7585
* END (MRI):                             MRI.                (line   62)
7586
* endianness:                            Options.            (line  248)
7587
* entry point:                           Entry Point.        (line    6)
7588
* entry point, from command line:        Options.            (line  187)
7589
* entry point, thumb:                    ARM.                (line   17)
7590
* ENTRY(SYMBOL):                         Entry Point.        (line    6)
7591
* error on valid input:                  Bug Criteria.       (line   12)
7592
* example of linker script:              Simple Example.     (line    6)
7593
* exporting DLL symbols:                 WIN32.              (line   19)
7594
* expression evaluation order:           Evaluation.         (line    6)
7595
* expression sections:                   Expression Section. (line    6)
7596
* expression, absolute:                  Builtin Functions.  (line   10)
7597
* expressions:                           Expressions.        (line    6)
7598
* EXTERN:                                Miscellaneous Commands.
7599
                                                             (line   13)
7600
* fatal signal:                          Bug Criteria.       (line    9)
7601
* file name wildcard patterns:           Input Section Wildcards.
7602
                                                             (line    6)
7603
* FILEHDR:                               PHDRS.              (line   62)
7604
* filename symbols:                      Output Section Keywords.
7605
                                                             (line    9)
7606
* fill pattern, entire section:          Output Section Fill.
7607
                                                             (line    6)
7608
* FILL(EXPRESSION):                      Output Section Data.
7609
                                                             (line   39)
7610
* finalization function:                 Options.            (line  300)
7611
* first input file:                      File Commands.      (line   82)
7612
* first instruction:                     Entry Point.        (line    6)
7613
* FIX_V4BX:                              ARM.                (line   49)
7614
* FIX_V4BX_INTERWORKING:                 ARM.                (line   62)
7615
* FORCE_COMMON_ALLOCATION:               Miscellaneous Commands.
7616
                                                             (line   20)
7617
* forcing input section alignment:       Forced Input Alignment.
7618
                                                             (line    6)
7619
* forcing output section alignment:      Forced Output Alignment.
7620
                                                             (line    6)
7621
* forcing the creation of dynamic sections: Options.         (line  485)
7622
* FORMAT (MRI):                          MRI.                (line   66)
7623
* functions in expressions:              Builtin Functions.  (line    6)
7624
* garbage collection <1>:                Input Section Keep. (line    6)
7625
* garbage collection:                    Options.            (line  935)
7626
* generating optimized output:           Options.            (line  466)
7627
* GNU linker:                            Overview.           (line    6)
7628
* GNUTARGET:                             Environment.        (line    9)
7629
* GROUP(FILES):                          File Commands.      (line   47)
7630
* grouping input files:                  File Commands.      (line   47)
7631
* groups of archives:                    Options.            (line  706)
7632
* H8/300 support:                        H8/300.             (line    6)
7633
* header size:                           Builtin Functions.  (line  182)
7634
* heap size:                             Options.            (line 1694)
7635
* help:                                  Options.            (line  972)
7636
* HIDDEN:                                HIDDEN.             (line    6)
7637
* holes:                                 Location Counter.   (line   12)
7638
* holes, filling:                        Output Section Data.
7639
                                                             (line   39)
7640
* HPPA multiple sub-space stubs:         HPPA ELF32.         (line    6)
7641
* HPPA stub grouping:                    HPPA ELF32.         (line   12)
7642
* i960 support:                          i960.               (line    6)
7643
* image base:                            Options.            (line 1701)
7644
* implicit linker scripts:               Implicit Linker Scripts.
7645
                                                             (line    6)
7646
* import libraries:                      WIN32.              (line   10)
7647
* INCLUDE FILENAME:                      File Commands.      (line    9)
7648
* including a linker script:             File Commands.      (line    9)
7649
* including an entire archive:           Options.            (line 1466)
7650
* incremental link:                      Options.            (line  326)
7651
* INHIBIT_COMMON_ALLOCATION:             Miscellaneous Commands.
7652
                                                             (line   25)
7653
* initialization function:               Options.            (line  329)
7654
* initialized data in ROM:               Output Section LMA. (line   39)
7655
* input file format in linker script:    Format Commands.    (line   35)
7656
* input filename symbols:                Output Section Keywords.
7657
                                                             (line    9)
7658
* input files in linker scripts:         File Commands.      (line   19)
7659
* input files, displaying:               Options.            (line  528)
7660
* input format:                          Options.            (line  134)
7661
* input object files in linker scripts:  File Commands.      (line   19)
7662
* input section alignment:               Forced Input Alignment.
7663
                                                             (line    6)
7664
* input section basics:                  Input Section Basics.
7665
                                                             (line    6)
7666
* input section wildcards:               Input Section Wildcards.
7667
                                                             (line    6)
7668
* input sections:                        Input Section.      (line    6)
7669
* INPUT(FILES):                          File Commands.      (line   19)
7670
* INSERT:                                Miscellaneous Commands.
7671
                                                             (line   30)
7672
* insert user script into default script: Miscellaneous Commands.
7673
                                                             (line   30)
7674
* integer notation:                      Constants.          (line    6)
7675
* integer suffixes:                      Constants.          (line   15)
7676
* internal object-file format:           Canonical format.   (line   11)
7677
* invalid input:                         Bug Criteria.       (line   14)
7678
* K and M integer suffixes:              Constants.          (line   15)
7679
* KEEP:                                  Input Section Keep. (line    6)
7680
* l =:                                   MEMORY.             (line   74)
7681
* lazy evaluation:                       Evaluation.         (line    6)
7682
* ld bugs, reporting:                    Bug Reporting.      (line    6)
7683
* LD_FEATURE(STRING):                    Miscellaneous Commands.
7684
                                                             (line   78)
7685
* LDEMULATION:                           Environment.        (line   21)
7686
* len =:                                 MEMORY.             (line   74)
7687
* LENGTH =:                              MEMORY.             (line   74)
7688
* LENGTH(MEMORY):                        Builtin Functions.  (line  136)
7689
* library search path in linker script:  File Commands.      (line   74)
7690
* link map:                              Options.            (line  402)
7691
* link-time runtime library search path: Options.            (line 1166)
7692
* linker crash:                          Bug Criteria.       (line    9)
7693
* linker script concepts:                Basic Script Concepts.
7694
                                                             (line    6)
7695
* linker script example:                 Simple Example.     (line    6)
7696
* linker script file commands:           File Commands.      (line    6)
7697
* linker script format:                  Script Format.      (line    6)
7698
* linker script input object files:      File Commands.      (line   19)
7699
* linker script simple commands:         Simple Commands.    (line    6)
7700
* linker scripts:                        Scripts.            (line    6)
7701
* LIST (MRI):                            MRI.                (line   77)
7702
* little-endian objects:                 Options.            (line  251)
7703
* LOAD (MRI):                            MRI.                (line   84)
7704
* load address:                          Output Section LMA. (line    6)
7705
* LOADADDR(SECTION):                     Builtin Functions.  (line  139)
7706
* loading, preventing:                   Output Section Type.
7707
                                                             (line   22)
7708
* local symbols, deleting:               Options.            (line  591)
7709
* location counter:                      Location Counter.   (line    6)
7710
* LONG(EXPRESSION):                      Output Section Data.
7711
                                                             (line    6)
7712
* M and K integer suffixes:              Constants.          (line   15)
7713
* M68HC11 and 68HC12 support:            M68HC11/68HC12.     (line    6)
7714
* machine architecture:                  Miscellaneous Commands.
7715
                                                             (line   72)
7716
* machine dependencies:                  Machine Dependent.  (line    6)
7717
* mapping input sections to output sections: Input Section.  (line    6)
7718
* MAX:                                   Builtin Functions.  (line  142)
7719
* MAXPAGESIZE:                           Symbolic Constants. (line   10)
7720
* MEMORY:                                MEMORY.             (line    6)
7721
* memory region attributes:              MEMORY.             (line   34)
7722
* memory regions:                        MEMORY.             (line    6)
7723
* memory regions and sections:           Output Section Region.
7724
                                                             (line    6)
7725
* memory usage:                          Options.            (line  984)
7726
* MIN:                                   Builtin Functions.  (line  145)
7727
* Motorola 68K GOT generation:           M68K.               (line    6)
7728
* MRI compatibility:                     MRI.                (line    6)
7729
* MSP430 extra sections:                 MSP430.             (line   11)
7730
* NAME (MRI):                            MRI.                (line   90)
7731
* name, section:                         Output Section Name.
7732
                                                             (line    6)
7733
* names:                                 Symbols.            (line    6)
7734
* naming the output file:                Options.            (line  460)
7735
* NEXT(EXP):                             Builtin Functions.  (line  149)
7736
* NMAGIC:                                Options.            (line  439)
7737
* NO_ENUM_SIZE_WARNING:                  ARM.                (line  120)
7738
* NO_WCHAR_SIZE_WARNING:                 ARM.                (line  127)
7739
* NOCROSSREFS(SECTIONS):                 Miscellaneous Commands.
7740
                                                             (line   56)
7741
* NOLOAD:                                Output Section Type.
7742
                                                             (line   22)
7743
* not enough room for program headers:   Builtin Functions.  (line  187)
7744
* o =:                                   MEMORY.             (line   69)
7745
* objdump -i:                            BFD.                (line    6)
7746
* object file management:                BFD.                (line    6)
7747
* object files:                          Options.            (line   29)
7748
* object formats available:              BFD.                (line    6)
7749
* object size:                           Options.            (line  309)
7750
* OMAGIC:                                Options.            (line  445)
7751
* ONLY_IF_RO:                            Output Section Constraint.
7752
                                                             (line    6)
7753
* ONLY_IF_RW:                            Output Section Constraint.
7754
                                                             (line    6)
7755
* opening object files:                  BFD outline.        (line    6)
7756
* operators for arithmetic:              Operators.          (line    6)
7757
* options:                               Options.            (line    6)
7758
* ORDER (MRI):                           MRI.                (line   95)
7759
* org =:                                 MEMORY.             (line   69)
7760
* ORIGIN =:                              MEMORY.             (line   69)
7761
* ORIGIN(MEMORY):                        Builtin Functions.  (line  155)
7762
* orphan:                                Orphan Sections.    (line    6)
7763
* output file after errors:              Options.            (line 1063)
7764
* output file format in linker script:   Format Commands.    (line   10)
7765
* output file name in linker script:     File Commands.      (line   64)
7766
* output format:                         Options.            (line  966)
7767
* output section alignment:              Forced Output Alignment.
7768
                                                             (line    6)
7769
* output section attributes:             Output Section Attributes.
7770
                                                             (line    6)
7771
* output section data:                   Output Section Data.
7772
                                                             (line    6)
7773
* OUTPUT(FILENAME):                      File Commands.      (line   64)
7774
* OUTPUT_ARCH(BFDARCH):                  Miscellaneous Commands.
7775
                                                             (line   72)
7776
* OUTPUT_FORMAT(BFDNAME):                Format Commands.    (line   10)
7777
* OVERLAY:                               Overlay Description.
7778
                                                             (line    6)
7779
* overlays:                              Overlay Description.
7780
                                                             (line    6)
7781
* partial link:                          Options.            (line  489)
7782
* PE import table prefixing:             ARM.                (line   23)
7783
* PHDRS:                                 PHDRS.              (line    6)
7784
* PIC_VENEER:                            ARM.                (line  133)
7785
* position independent executables:      Options.            (line 1090)
7786
* PowerPC ELF32 options:                 PowerPC ELF32.      (line   16)
7787
* PowerPC GOT:                           PowerPC ELF32.      (line   33)
7788
* PowerPC long branches:                 PowerPC ELF32.      (line    6)
7789
* PowerPC PLT:                           PowerPC ELF32.      (line   16)
7790
* PowerPC stub symbols:                  PowerPC ELF32.      (line   47)
7791
* PowerPC TLS optimization:              PowerPC ELF32.      (line   51)
7792
* PowerPC64 dot symbols:                 PowerPC64 ELF64.    (line   33)
7793
* PowerPC64 ELF64 options:               PowerPC64 ELF64.    (line    6)
7794
* PowerPC64 multi-TOC:                   PowerPC64 ELF64.    (line   74)
7795
* PowerPC64 OPD optimization:            PowerPC64 ELF64.    (line   48)
7796
* PowerPC64 OPD spacing:                 PowerPC64 ELF64.    (line   54)
7797
* PowerPC64 PLT call stub static chain:  PowerPC64 ELF64.    (line  103)
7798
* PowerPC64 PLT call stub thread safety: PowerPC64 ELF64.    (line  109)
7799
* PowerPC64 PLT stub alignment:          PowerPC64 ELF64.    (line   96)
7800
* PowerPC64 stub grouping:               PowerPC64 ELF64.    (line    6)
7801
* PowerPC64 stub symbols:                PowerPC64 ELF64.    (line   29)
7802
* PowerPC64 TLS optimization:            PowerPC64 ELF64.    (line   43)
7803
* PowerPC64 TOC optimization:            PowerPC64 ELF64.    (line   60)
7804
* PowerPC64 TOC sorting:                 PowerPC64 ELF64.    (line   86)
7805
* precedence in expressions:             Operators.          (line    6)
7806
* prevent unnecessary loading:           Output Section Type.
7807
                                                             (line   22)
7808
* program headers:                       PHDRS.              (line    6)
7809
* program headers and sections:          Output Section Phdr.
7810
                                                             (line    6)
7811
* program headers, not enough room:      Builtin Functions.  (line  187)
7812
* program segments:                      PHDRS.              (line    6)
7813
* PROVIDE:                               PROVIDE.            (line    6)
7814
* PROVIDE_HIDDEN:                        PROVIDE_HIDDEN.     (line    6)
7815
* PUBLIC (MRI):                          MRI.                (line  103)
7816
* QUAD(EXPRESSION):                      Output Section Data.
7817
                                                             (line    6)
7818
* quoted symbol names:                   Symbols.            (line    6)
7819
* read-only text:                        Options.            (line  439)
7820
* read/write from cmd line:              Options.            (line  445)
7821
* region alias:                          REGION_ALIAS.       (line    6)
7822
* region names:                          REGION_ALIAS.       (line    6)
7823
* REGION_ALIAS(ALIAS, REGION):           REGION_ALIAS.       (line    6)
7824
* regions of memory:                     MEMORY.             (line    6)
7825
* relative expressions:                  Expression Section. (line    6)
7826
* relaxing addressing modes:             Options.            (line 1104)
7827
* relaxing on H8/300:                    H8/300.             (line    9)
7828
* relaxing on i960:                      i960.               (line   31)
7829
* relaxing on M68HC11:                   M68HC11/68HC12.     (line   12)
7830
* relaxing on Xtensa:                    Xtensa.             (line   27)
7831
* relocatable and absolute symbols:      Expression Section. (line    6)
7832
* relocatable output:                    Options.            (line  489)
7833
* removing sections:                     Output Section Discarding.
7834
                                                             (line    6)
7835
* reporting bugs in ld:                  Reporting Bugs.     (line    6)
7836
* requirements for BFD:                  BFD.                (line   16)
7837
* retain relocations in final executable: Options.           (line  476)
7838
* retaining specified symbols:           Options.            (line 1130)
7839
* ROM initialized data:                  Output Section LMA. (line   39)
7840
* round up expression:                   Builtin Functions.  (line   38)
7841
* round up location counter:             Builtin Functions.  (line   38)
7842
* runtime library name:                  Options.            (line  317)
7843
* runtime library search path:           Options.            (line 1144)
7844
* runtime pseudo-relocation:             WIN32.              (line  217)
7845
* scaled integers:                       Constants.          (line   15)
7846
* scommon section:                       Input Section Common.
7847
                                                             (line   20)
7848
* script files:                          Options.            (line  532)
7849
* scripts:                               Scripts.            (line    6)
7850
* search directory, from cmd line:       Options.            (line  368)
7851
* search path in linker script:          File Commands.      (line   74)
7852
* SEARCH_DIR(PATH):                      File Commands.      (line   74)
7853
* SECT (MRI):                            MRI.                (line  109)
7854
* section address:                       Output Section Address.
7855
                                                             (line    6)
7856
* section address in expression:         Builtin Functions.  (line   17)
7857
* section alignment:                     Builtin Functions.  (line   63)
7858
* section alignment, warnings on:        Options.            (line 1444)
7859
* section data:                          Output Section Data.
7860
                                                             (line    6)
7861
* section fill pattern:                  Output Section Fill.
7862
                                                             (line    6)
7863
* section load address:                  Output Section LMA. (line    6)
7864
* section load address in expression:    Builtin Functions.  (line  139)
7865
* section name:                          Output Section Name.
7866
                                                             (line    6)
7867
* section name wildcard patterns:        Input Section Wildcards.
7868
                                                             (line    6)
7869
* section size:                          Builtin Functions.  (line  166)
7870
* section, assigning to memory region:   Output Section Region.
7871
                                                             (line    6)
7872
* section, assigning to program header:  Output Section Phdr.
7873
                                                             (line    6)
7874
* SECTIONS:                              SECTIONS.           (line    6)
7875
* sections, discarding:                  Output Section Discarding.
7876
                                                             (line    6)
7877
* segment origins, cmd line:             Options.            (line 1295)
7878
* SEGMENT_START(SEGMENT, DEFAULT):       Builtin Functions.  (line  158)
7879
* segments, ELF:                         PHDRS.              (line    6)
7880
* shared libraries:                      Options.            (line 1223)
7881
* SHORT(EXPRESSION):                     Output Section Data.
7882
                                                             (line    6)
7883
* SIZEOF(SECTION):                       Builtin Functions.  (line  166)
7884
* SIZEOF_HEADERS:                        Builtin Functions.  (line  182)
7885
* small common symbols:                  Input Section Common.
7886
                                                             (line   20)
7887
* SORT:                                  Input Section Wildcards.
7888
                                                             (line   63)
7889
* SORT_BY_ALIGNMENT:                     Input Section Wildcards.
7890
                                                             (line   54)
7891
* SORT_BY_INIT_PRIORITY:                 Input Section Wildcards.
7892
                                                             (line   58)
7893
* SORT_BY_NAME:                          Input Section Wildcards.
7894
                                                             (line   46)
7895
* SORT_NONE:                             Input Section Wildcards.
7896
                                                             (line  104)
7897
* SPU:                                   SPU ELF.            (line   29)
7898
* SPU ELF options:                       SPU ELF.            (line    6)
7899
* SPU extra overlay stubs:               SPU ELF.            (line   19)
7900
* SPU local store size:                  SPU ELF.            (line   24)
7901
* SPU overlay stub symbols:              SPU ELF.            (line   15)
7902
* SPU overlays:                          SPU ELF.            (line    9)
7903
* SPU plugins:                           SPU ELF.            (line    6)
7904
* SQUAD(EXPRESSION):                     Output Section Data.
7905
                                                             (line    6)
7906
* stack size:                            Options.            (line 1941)
7907
* standard Unix system:                  Options.            (line    7)
7908
* start of execution:                    Entry Point.        (line    6)
7909
* STARTUP(FILENAME):                     File Commands.      (line   82)
7910
* strip all symbols:                     Options.            (line  519)
7911
* strip debugger symbols:                Options.            (line  523)
7912
* stripping all but some symbols:        Options.            (line 1130)
7913
* STUB_GROUP_SIZE:                       ARM.                (line  138)
7914
* SUBALIGN(SUBSECTION_ALIGN):            Forced Input Alignment.
7915
                                                             (line    6)
7916
* suffixes for integers:                 Constants.          (line   15)
7917
* symbol defaults:                       Builtin Functions.  (line  119)
7918
* symbol definition, scripts:            Assignments.        (line    6)
7919
* symbol names:                          Symbols.            (line    6)
7920
* symbol tracing:                        Options.            (line  597)
7921
* symbol versions:                       VERSION.            (line    6)
7922
* symbol-only input:                     Options.            (line  508)
7923
* symbolic constants:                    Symbolic Constants. (line    6)
7924
* symbols, from command line:            Options.            (line  887)
7925
* symbols, relocatable and absolute:     Expression Section. (line    6)
7926
* symbols, retaining selectively:        Options.            (line 1130)
7927
* synthesizing linker:                   Options.            (line 1104)
7928
* synthesizing on H8/300:                H8/300.             (line   14)
7929
* TARGET(BFDNAME):                       Format Commands.    (line   35)
7930
* TARGET1:                               ARM.                (line   32)
7931
* TARGET2:                               ARM.                (line   37)
7932
* text segment origin, cmd line:         Options.            (line 1302)
7933
* thumb entry point:                     ARM.                (line   17)
7934
* TI COFF versions:                      TI COFF.            (line    6)
7935
* traditional format:                    Options.            (line 1274)
7936
* trampoline generation on M68HC11:      M68HC11/68HC12.     (line   31)
7937
* trampoline generation on M68HC12:      M68HC11/68HC12.     (line   31)
7938
* unallocated address, next:             Builtin Functions.  (line  149)
7939
* undefined symbol:                      Options.            (line  554)
7940
* undefined symbol in linker script:     Miscellaneous Commands.
7941
                                                             (line   13)
7942
* undefined symbols, warnings on:        Options.            (line 1440)
7943
* uninitialized data placement:          Input Section Common.
7944
                                                             (line    6)
7945
* unspecified memory:                    Output Section Data.
7946
                                                             (line   39)
7947
* usage:                                 Options.            (line  972)
7948
* USE_BLX:                               ARM.                (line   74)
7949
* using a DEF file:                      WIN32.              (line   57)
7950
* using auto-export functionality:       WIN32.              (line   22)
7951
* Using decorations:                     WIN32.              (line  162)
7952
* variables, defining:                   Assignments.        (line    6)
7953
* verbose[=NUMBER]:                      Options.            (line 1334)
7954
* version:                               Options.            (line  581)
7955
* version script:                        VERSION.            (line    6)
7956
* version script, symbol versions:       Options.            (line 1342)
7957
* VERSION {script text}:                 VERSION.            (line    6)
7958
* versions of symbols:                   VERSION.            (line    6)
7959
* VFP11_DENORM_FIX:                      ARM.                (line   83)
7960
* warnings, on combining symbols:        Options.            (line 1353)
7961
* warnings, on section alignment:        Options.            (line 1444)
7962
* warnings, on undefined symbols:        Options.            (line 1440)
7963
* weak externals:                        WIN32.              (line  407)
7964
* what is this?:                         Overview.           (line    6)
7965
* wildcard file name patterns:           Input Section Wildcards.
7966
 
7967
 
7968
* Xtensa processors:                     Xtensa.             (line    6)
7969
7970
7971

7972
Tag Table:
7973
Node: Top823
7974
Node: Overview1609
7975
Node: Invocation2723
7976
Node: Options3131
7977
Node: Environment95229
7978
Node: Scripts96989
7979
Node: Basic Script Concepts98723
7980
Node: Script Format101430
7981
Node: Simple Example102293
7982
Node: Simple Commands105389
7983
Node: Entry Point105895
7984
Node: File Commands106828
7985
Node: Format Commands110829
7986
Node: REGION_ALIAS112785
7987
Node: Miscellaneous Commands117617
7988
Node: Assignments121225
7989
Node: Simple Assignments121736
7990
Node: HIDDEN123471
7991
Node: PROVIDE124101
7992
Node: PROVIDE_HIDDEN125294
7993
Node: Source Code Reference125538
7994
Node: SECTIONS129118
7995
Node: Output Section Description131009
7996
Node: Output Section Name132096
7997
Node: Output Section Address132972
7998
Node: Input Section135207
7999
Node: Input Section Basics136008
8000
Node: Input Section Wildcards139914
8001
Node: Input Section Common145008
8002
Node: Input Section Keep146490
8003
Node: Input Section Example146980
8004
Node: Output Section Data147948
8005
Node: Output Section Keywords150725
8006
Node: Output Section Discarding154294
8007
Node: Output Section Attributes155475
8008
Node: Output Section Type156576
8009
Node: Output Section LMA157647
8010
Node: Forced Output Alignment160718
8011
Node: Forced Input Alignment160986
8012
Node: Output Section Constraint161375
8013
Node: Output Section Region161803
8014
Node: Output Section Phdr162236
8015
Node: Output Section Fill162900
8016
Node: Overlay Description164042
8017
Node: MEMORY168345
8018
Node: PHDRS172679
8019
Node: VERSION177933
8020
Node: Expressions186026
8021
Node: Constants186955
8022
Node: Symbolic Constants187830
8023
Node: Symbols188381
8024
Node: Orphan Sections189128
8025
Node: Location Counter190293
8026
Node: Operators194729
8027
Node: Evaluation195651
8028
Node: Expression Section197015
8029
Node: Builtin Functions200879
8030
Node: Implicit Linker Scripts208835
8031
Node: Machine Dependent209610
8032
Node: H8/300210626
8033
Node: i960212251
8034
Node: M68HC11/68HC12214455
8035
Node: ARM215909
8036
Node: HPPA ELF32223873
8037
Node: M68K225496
8038
Node: MMIX226405
8039
Node: MSP430227570
8040
Node: PowerPC ELF32228619
8041
Node: PowerPC64 ELF64231455
8042
Node: SPU ELF237611
8043
Node: TI COFF240243
8044
Node: WIN32240769
8045
Node: Xtensa260894
8046
Node: BFD263859
8047
Node: BFD outline265314
8048
Node: BFD information loss266600
8049
Node: Canonical format269117
8050
Node: Reporting Bugs273474
8051
Node: Bug Criteria274168
8052
Node: Bug Reporting274867
8053
Node: MRI281906
8054
Node: GNU Free Documentation License286549

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.