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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [ld/] [ld.info] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
This is ld.info, produced by makeinfo version 4.8 from ld.texinfo.
2
 
3
START-INFO-DIR-ENTRY
4
* Ld: (ld).                       The GNU linker.
5
END-INFO-DIR-ENTRY
6
 
7
   This file documents the GNU linker LD (GNU Binutils) version 2.18.50.
8
 
9
   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001,
10
2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
11
 
12
   Permission is granted to copy, distribute and/or modify this document
13
under the terms of the GNU Free Documentation License, Version 1.1 or
14
any later version published by the Free Software Foundation; with no
15
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
16
Texts.  A copy of the license is included in the section entitled "GNU
17
Free Documentation License".
18
 
19

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

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

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

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

1906
File: ld.info,  Node: Environment,  Prev: Options,  Up: Invocation
1907
 
1908
2.2 Environment Variables
1909
=========================
1910
 
1911
You can change the behaviour of `ld' with the environment variables
1912
`GNUTARGET', `LDEMULATION' and `COLLECT_NO_DEMANGLE'.
1913
 
1914
   `GNUTARGET' determines the input-file object format if you don't use
1915
`-b' (or its synonym `--format').  Its value should be one of the BFD
1916
names for an input format (*note BFD::).  If there is no `GNUTARGET' in
1917
the environment, `ld' uses the natural format of the target. If
1918
`GNUTARGET' is set to `default' then BFD attempts to discover the input
1919
format by examining binary input files; this method often succeeds, but
1920
there are potential ambiguities, since there is no method of ensuring
1921
that the magic number used to specify object-file formats is unique.
1922
However, the configuration procedure for BFD on each system places the
1923
conventional format for that system first in the search-list, so
1924
ambiguities are resolved in favor of convention.
1925
 
1926
   `LDEMULATION' determines the default emulation if you don't use the
1927
`-m' option.  The emulation can affect various aspects of linker
1928
behaviour, particularly the default linker script.  You can list the
1929
available emulations with the `--verbose' or `-V' options.  If the `-m'
1930
option is not used, and the `LDEMULATION' environment variable is not
1931
defined, the default emulation depends upon how the linker was
1932
configured.
1933
 
1934
   Normally, the linker will default to demangling symbols.  However, if
1935
`COLLECT_NO_DEMANGLE' is set in the environment, then it will default
1936
to not demangling symbols.  This environment variable is used in a
1937
similar fashion by the `gcc' linker wrapper program.  The default may
1938
be overridden by the `--demangle' and `--no-demangle' options.
1939
 
1940

1941
File: ld.info,  Node: Scripts,  Next: Machine Dependent,  Prev: Invocation,  Up: Top
1942
 
1943
3 Linker Scripts
1944
****************
1945
 
1946
Every link is controlled by a "linker script".  This script is written
1947
in the linker command language.
1948
 
1949
   The main purpose of the linker script is to describe how the
1950
sections in the input files should be mapped into the output file, and
1951
to control the memory layout of the output file.  Most linker scripts
1952
do nothing more than this.  However, when necessary, the linker script
1953
can also direct the linker to perform many other operations, using the
1954
commands described below.
1955
 
1956
   The linker always uses a linker script.  If you do not supply one
1957
yourself, the linker will use a default script that is compiled into the
1958
linker executable.  You can use the `--verbose' command line option to
1959
display the default linker script.  Certain command line options, such
1960
as `-r' or `-N', will affect the default linker script.
1961
 
1962
   You may supply your own linker script by using the `-T' command line
1963
option.  When you do this, your linker script will replace the default
1964
linker script.
1965
 
1966
   You may also use linker scripts implicitly by naming them as input
1967
files to the linker, as though they were files to be linked.  *Note
1968
Implicit Linker Scripts::.
1969
 
1970
* Menu:
1971
 
1972
* Basic Script Concepts::       Basic Linker Script Concepts
1973
* Script Format::               Linker Script Format
1974
* Simple Example::              Simple Linker Script Example
1975
* Simple Commands::             Simple Linker Script Commands
1976
* Assignments::                 Assigning Values to Symbols
1977
* SECTIONS::                    SECTIONS Command
1978
* MEMORY::                      MEMORY Command
1979
* PHDRS::                       PHDRS Command
1980
* VERSION::                     VERSION Command
1981
* Expressions::                 Expressions in Linker Scripts
1982
* Implicit Linker Scripts::     Implicit Linker Scripts
1983
 
1984

1985
File: ld.info,  Node: Basic Script Concepts,  Next: Script Format,  Up: Scripts
1986
 
1987
3.1 Basic Linker Script Concepts
1988
================================
1989
 
1990
We need to define some basic concepts and vocabulary in order to
1991
describe the linker script language.
1992
 
1993
   The linker combines input files into a single output file.  The
1994
output file and each input file are in a special data format known as an
1995
"object file format".  Each file is called an "object file".  The
1996
output file is often called an "executable", but for our purposes we
1997
will also call it an object file.  Each object file has, among other
1998
things, a list of "sections".  We sometimes refer to a section in an
1999
input file as an "input section"; similarly, a section in the output
2000
file is an "output section".
2001
 
2002
   Each section in an object file has a name and a size.  Most sections
2003
also have an associated block of data, known as the "section contents".
2004
A section may be marked as "loadable", which mean that the contents
2005
should be loaded into memory when the output file is run.  A section
2006
with no contents may be "allocatable", which means that an area in
2007
memory should be set aside, but nothing in particular should be loaded
2008
there (in some cases this memory must be zeroed out).  A section which
2009
is neither loadable nor allocatable typically contains some sort of
2010
debugging information.
2011
 
2012
   Every loadable or allocatable output section has two addresses.  The
2013
first is the "VMA", or virtual memory address.  This is the address the
2014
section will have when the output file is run.  The second is the
2015
"LMA", or load memory address.  This is the address at which the
2016
section will be loaded.  In most cases the two addresses will be the
2017
same.  An example of when they might be different is when a data section
2018
is loaded into ROM, and then copied into RAM when the program starts up
2019
(this technique is often used to initialize global variables in a ROM
2020
based system).  In this case the ROM address would be the LMA, and the
2021
RAM address would be the VMA.
2022
 
2023
   You can see the sections in an object file by using the `objdump'
2024
program with the `-h' option.
2025
 
2026
   Every object file also has a list of "symbols", known as the "symbol
2027
table".  A symbol may be defined or undefined.  Each symbol has a name,
2028
and each defined symbol has an address, among other information.  If
2029
you compile a C or C++ program into an object file, you will get a
2030
defined symbol for every defined function and global or static
2031
variable.  Every undefined function or global variable which is
2032
referenced in the input file will become an undefined symbol.
2033
 
2034
   You can see the symbols in an object file by using the `nm' program,
2035
or by using the `objdump' program with the `-t' option.
2036
 
2037

2038
File: ld.info,  Node: Script Format,  Next: Simple Example,  Prev: Basic Script Concepts,  Up: Scripts
2039
 
2040
3.2 Linker Script Format
2041
========================
2042
 
2043
Linker scripts are text files.
2044
 
2045
   You write a linker script as a series of commands.  Each command is
2046
either a keyword, possibly followed by arguments, or an assignment to a
2047
symbol.  You may separate commands using semicolons.  Whitespace is
2048
generally ignored.
2049
 
2050
   Strings such as file or format names can normally be entered
2051
directly.  If the file name contains a character such as a comma which
2052
would otherwise serve to separate file names, you may put the file name
2053
in double quotes.  There is no way to use a double quote character in a
2054
file name.
2055
 
2056
   You may include comments in linker scripts just as in C, delimited by
2057
`/*' and `*/'.  As in C, comments are syntactically equivalent to
2058
whitespace.
2059
 
2060

2061
File: ld.info,  Node: Simple Example,  Next: Simple Commands,  Prev: Script Format,  Up: Scripts
2062
 
2063
3.3 Simple Linker Script Example
2064
================================
2065
 
2066
Many linker scripts are fairly simple.
2067
 
2068
   The simplest possible linker script has just one command:
2069
`SECTIONS'.  You use the `SECTIONS' command to describe the memory
2070
layout of the output file.
2071
 
2072
   The `SECTIONS' command is a powerful command.  Here we will describe
2073
a simple use of it.  Let's assume your program consists only of code,
2074
initialized data, and uninitialized data.  These will be in the
2075
`.text', `.data', and `.bss' sections, respectively.  Let's assume
2076
further that these are the only sections which appear in your input
2077
files.
2078
 
2079
   For this example, let's say that the code should be loaded at address
2080
0x10000, and that the data should start at address 0x8000000.  Here is a
2081
linker script which will do that:
2082
     SECTIONS
2083
     {
2084
       . = 0x10000;
2085
       .text : { *(.text) }
2086
       . = 0x8000000;
2087
       .data : { *(.data) }
2088
       .bss : { *(.bss) }
2089
     }
2090
 
2091
   You write the `SECTIONS' command as the keyword `SECTIONS', followed
2092
by a series of symbol assignments and output section descriptions
2093
enclosed in curly braces.
2094
 
2095
   The first line inside the `SECTIONS' command of the above example
2096
sets the value of the special symbol `.', which is the location
2097
counter.  If you do not specify the address of an output section in some
2098
other way (other ways are described later), the address is set from the
2099
current value of the location counter.  The location counter is then
2100
incremented by the size of the output section.  At the start of the
2101
`SECTIONS' command, the location counter has the value `0'.
2102
 
2103
   The second line defines an output section, `.text'.  The colon is
2104
required syntax which may be ignored for now.  Within the curly braces
2105
after the output section name, you list the names of the input sections
2106
which should be placed into this output section.  The `*' is a wildcard
2107
which matches any file name.  The expression `*(.text)' means all
2108
`.text' input sections in all input files.
2109
 
2110
   Since the location counter is `0x10000' when the output section
2111
`.text' is defined, the linker will set the address of the `.text'
2112
section in the output file to be `0x10000'.
2113
 
2114
   The remaining lines define the `.data' and `.bss' sections in the
2115
output file.  The linker will place the `.data' output section at
2116
address `0x8000000'.  After the linker places the `.data' output
2117
section, the value of the location counter will be `0x8000000' plus the
2118
size of the `.data' output section.  The effect is that the linker will
2119
place the `.bss' output section immediately after the `.data' output
2120
section in memory.
2121
 
2122
   The linker will ensure that each output section has the required
2123
alignment, by increasing the location counter if necessary.  In this
2124
example, the specified addresses for the `.text' and `.data' sections
2125
will probably satisfy any alignment constraints, but the linker may
2126
have to create a small gap between the `.data' and `.bss' sections.
2127
 
2128
   That's it!  That's a simple and complete linker script.
2129
 
2130

2131
File: ld.info,  Node: Simple Commands,  Next: Assignments,  Prev: Simple Example,  Up: Scripts
2132
 
2133
3.4 Simple Linker Script Commands
2134
=================================
2135
 
2136
In this section we describe the simple linker script commands.
2137
 
2138
* Menu:
2139
 
2140
* Entry Point::                 Setting the entry point
2141
* File Commands::               Commands dealing with files
2142
 
2143
* Format Commands::             Commands dealing with object file formats
2144
 
2145
* Miscellaneous Commands::      Other linker script commands
2146
 
2147

2148
File: ld.info,  Node: Entry Point,  Next: File Commands,  Up: Simple Commands
2149
 
2150
3.4.1 Setting the Entry Point
2151
-----------------------------
2152
 
2153
The first instruction to execute in a program is called the "entry
2154
point".  You can use the `ENTRY' linker script command to set the entry
2155
point.  The argument is a symbol name:
2156
     ENTRY(SYMBOL)
2157
 
2158
   There are several ways to set the entry point.  The linker will set
2159
the entry point by trying each of the following methods in order, and
2160
stopping when one of them succeeds:
2161
   * the `-e' ENTRY command-line option;
2162
 
2163
   * the `ENTRY(SYMBOL)' command in a linker script;
2164
 
2165
   * the value of the symbol `start', if defined;
2166
 
2167
   * the address of the first byte of the `.text' section, if present;
2168
 
2169
   * The address `0'.
2170
 
2171

2172
File: ld.info,  Node: File Commands,  Next: Format Commands,  Prev: Entry Point,  Up: Simple Commands
2173
 
2174
3.4.2 Commands Dealing with Files
2175
---------------------------------
2176
 
2177
Several linker script commands deal with files.
2178
 
2179
`INCLUDE FILENAME'
2180
     Include the linker script FILENAME at this point.  The file will
2181
     be searched for in the current directory, and in any directory
2182
     specified with the `-L' option.  You can nest calls to `INCLUDE'
2183
     up to 10 levels deep.
2184
 
2185
`INPUT(FILE, FILE, ...)'
2186
`INPUT(FILE FILE ...)'
2187
     The `INPUT' command directs the linker to include the named files
2188
     in the link, as though they were named on the command line.
2189
 
2190
     For example, if you always want to include `subr.o' any time you do
2191
     a link, but you can't be bothered to put it on every link command
2192
     line, then you can put `INPUT (subr.o)' in your linker script.
2193
 
2194
     In fact, if you like, you can list all of your input files in the
2195
     linker script, and then invoke the linker with nothing but a `-T'
2196
     option.
2197
 
2198
     In case a "sysroot prefix" is configured, and the filename starts
2199
     with the `/' character, and the script being processed was located
2200
     inside the "sysroot prefix", the filename will be looked for in
2201
     the "sysroot prefix".  Otherwise, the linker will try to open the
2202
     file in the current directory.  If it is not found, the linker
2203
     will search through the archive library search path.  See the
2204
     description of `-L' in *Note Command Line Options: Options.
2205
 
2206
     If you use `INPUT (-lFILE)', `ld' will transform the name to
2207
     `libFILE.a', as with the command line argument `-l'.
2208
 
2209
     When you use the `INPUT' command in an implicit linker script, the
2210
     files will be included in the link at the point at which the linker
2211
     script file is included.  This can affect archive searching.
2212
 
2213
`GROUP(FILE, FILE, ...)'
2214
`GROUP(FILE FILE ...)'
2215
     The `GROUP' command is like `INPUT', except that the named files
2216
     should all be archives, and they are searched repeatedly until no
2217
     new undefined references are created.  See the description of `-('
2218
     in *Note Command Line Options: Options.
2219
 
2220
`AS_NEEDED(FILE, FILE, ...)'
2221
`AS_NEEDED(FILE FILE ...)'
2222
     This construct can appear only inside of the `INPUT' or `GROUP'
2223
     commands, among other filenames.  The files listed will be handled
2224
     as if they appear directly in the `INPUT' or `GROUP' commands,
2225
     with the exception of ELF shared libraries, that will be added only
2226
     when they are actually needed.  This construct essentially enables
2227
     `--as-needed' option for all the files listed inside of it and
2228
     restores previous `--as-needed' resp. `--no-as-needed' setting
2229
     afterwards.
2230
 
2231
`OUTPUT(FILENAME)'
2232
     The `OUTPUT' command names the output file.  Using
2233
     `OUTPUT(FILENAME)' in the linker script is exactly like using `-o
2234
     FILENAME' on the command line (*note Command Line Options:
2235
     Options.).  If both are used, the command line option takes
2236
     precedence.
2237
 
2238
     You can use the `OUTPUT' command to define a default name for the
2239
     output file other than the usual default of `a.out'.
2240
 
2241
`SEARCH_DIR(PATH)'
2242
     The `SEARCH_DIR' command adds PATH to the list of paths where `ld'
2243
     looks for archive libraries.  Using `SEARCH_DIR(PATH)' is exactly
2244
     like using `-L PATH' on the command line (*note Command Line
2245
     Options: Options.).  If both are used, then the linker will search
2246
     both paths.  Paths specified using the command line option are
2247
     searched first.
2248
 
2249
`STARTUP(FILENAME)'
2250
     The `STARTUP' command is just like the `INPUT' command, except
2251
     that FILENAME will become the first input file to be linked, as
2252
     though it were specified first on the command line.  This may be
2253
     useful when using a system in which the entry point is always the
2254
     start of the first file.
2255
 
2256

2257
File: ld.info,  Node: Format Commands,  Next: Miscellaneous Commands,  Prev: File Commands,  Up: Simple Commands
2258
 
2259
3.4.3 Commands Dealing with Object File Formats
2260
-----------------------------------------------
2261
 
2262
A couple of linker script commands deal with object file formats.
2263
 
2264
`OUTPUT_FORMAT(BFDNAME)'
2265
`OUTPUT_FORMAT(DEFAULT, BIG, LITTLE)'
2266
     The `OUTPUT_FORMAT' command names the BFD format to use for the
2267
     output file (*note BFD::).  Using `OUTPUT_FORMAT(BFDNAME)' is
2268
     exactly like using `--oformat BFDNAME' on the command line (*note
2269
     Command Line Options: Options.).  If both are used, the command
2270
     line option takes precedence.
2271
 
2272
     You can use `OUTPUT_FORMAT' with three arguments to use different
2273
     formats based on the `-EB' and `-EL' command line options.  This
2274
     permits the linker script to set the output format based on the
2275
     desired endianness.
2276
 
2277
     If neither `-EB' nor `-EL' are used, then the output format will
2278
     be the first argument, DEFAULT.  If `-EB' is used, the output
2279
     format will be the second argument, BIG.  If `-EL' is used, the
2280
     output format will be the third argument, LITTLE.
2281
 
2282
     For example, the default linker script for the MIPS ELF target
2283
     uses this command:
2284
          OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips)
2285
     This says that the default format for the output file is
2286
     `elf32-bigmips', but if the user uses the `-EL' command line
2287
     option, the output file will be created in the `elf32-littlemips'
2288
     format.
2289
 
2290
`TARGET(BFDNAME)'
2291
     The `TARGET' command names the BFD format to use when reading input
2292
     files.  It affects subsequent `INPUT' and `GROUP' commands.  This
2293
     command is like using `-b BFDNAME' on the command line (*note
2294
     Command Line Options: Options.).  If the `TARGET' command is used
2295
     but `OUTPUT_FORMAT' is not, then the last `TARGET' command is also
2296
     used to set the format for the output file.  *Note BFD::.
2297
 
2298

2299
File: ld.info,  Node: Miscellaneous Commands,  Prev: Format Commands,  Up: Simple Commands
2300
 
2301
3.4.4 Other Linker Script Commands
2302
----------------------------------
2303
 
2304
There are a few other linker scripts commands.
2305
 
2306
`ASSERT(EXP, MESSAGE)'
2307
     Ensure that EXP is non-zero.  If it is zero, then exit the linker
2308
     with an error code, and print MESSAGE.
2309
 
2310
`EXTERN(SYMBOL SYMBOL ...)'
2311
     Force SYMBOL to be entered in the output file as an undefined
2312
     symbol.  Doing this may, for example, trigger linking of additional
2313
     modules from standard libraries.  You may list several SYMBOLs for
2314
     each `EXTERN', and you may use `EXTERN' multiple times.  This
2315
     command has the same effect as the `-u' command-line option.
2316
 
2317
`FORCE_COMMON_ALLOCATION'
2318
     This command has the same effect as the `-d' command-line option:
2319
     to make `ld' assign space to common symbols even if a relocatable
2320
     output file is specified (`-r').
2321
 
2322
`INHIBIT_COMMON_ALLOCATION'
2323
     This command has the same effect as the `--no-define-common'
2324
     command-line option: to make `ld' omit the assignment of addresses
2325
     to common symbols even for a non-relocatable output file.
2326
 
2327
`INSERT [ AFTER | BEFORE ] OUTPUT_SECTION'
2328
     This command is typically used in a script specified by `-T' to
2329
     augment the default `SECTIONS' with, for example, overlays.  It
2330
     inserts all prior linker script statements after (or before)
2331
     OUTPUT_SECTION, and also causes `-T' to not override the default
2332
     linker script.  The exact insertion point is as for orphan
2333
     sections.  *Note Location Counter::.  The insertion happens after
2334
     the linker has mapped input sections to output sections.  Prior to
2335
     the insertion, since `-T' scripts are parsed before the default
2336
     linker script, statements in the `-T' script occur before the
2337
     default linker script statements in the internal linker
2338
     representation of the script.  In particular, input section
2339
     assignments will be made to `-T' output sections before those in
2340
     the default script.  Here is an example of how a `-T' script using
2341
     `INSERT' might look:
2342
 
2343
          SECTIONS
2344
          {
2345
            OVERLAY :
2346
            {
2347
              .ov1 { ov1*(.text) }
2348
              .ov2 { ov2*(.text) }
2349
            }
2350
          }
2351
          INSERT AFTER .text;
2352
 
2353
`NOCROSSREFS(SECTION SECTION ...)'
2354
     This command may be used to tell `ld' to issue an error about any
2355
     references among certain output sections.
2356
 
2357
     In certain types of programs, particularly on embedded systems when
2358
     using overlays, when one section is loaded into memory, another
2359
     section will not be.  Any direct references between the two
2360
     sections would be errors.  For example, it would be an error if
2361
     code in one section called a function defined in the other section.
2362
 
2363
     The `NOCROSSREFS' command takes a list of output section names.  If
2364
     `ld' detects any cross references between the sections, it reports
2365
     an error and returns a non-zero exit status.  Note that the
2366
     `NOCROSSREFS' command uses output section names, not input section
2367
     names.
2368
 
2369
`OUTPUT_ARCH(BFDARCH)'
2370
     Specify a particular output machine architecture.  The argument is
2371
     one of the names used by the BFD library (*note BFD::).  You can
2372
     see the architecture of an object file by using the `objdump'
2373
     program with the `-f' option.
2374
 
2375

2376
File: ld.info,  Node: Assignments,  Next: SECTIONS,  Prev: Simple Commands,  Up: Scripts
2377
 
2378
3.5 Assigning Values to Symbols
2379
===============================
2380
 
2381
You may assign a value to a symbol in a linker script.  This will define
2382
the symbol and place it into the symbol table with a global scope.
2383
 
2384
* Menu:
2385
 
2386
* Simple Assignments::          Simple Assignments
2387
* PROVIDE::                     PROVIDE
2388
* PROVIDE_HIDDEN::              PROVIDE_HIDDEN
2389
* Source Code Reference::       How to use a linker script defined symbol in source code
2390
 
2391

2392
File: ld.info,  Node: Simple Assignments,  Next: PROVIDE,  Up: Assignments
2393
 
2394
3.5.1 Simple Assignments
2395
------------------------
2396
 
2397
You may assign to a symbol using any of the C assignment operators:
2398
 
2399
`SYMBOL = EXPRESSION ;'
2400
`SYMBOL += EXPRESSION ;'
2401
`SYMBOL -= EXPRESSION ;'
2402
`SYMBOL *= EXPRESSION ;'
2403
`SYMBOL /= EXPRESSION ;'
2404
`SYMBOL <<= EXPRESSION ;'
2405
`SYMBOL >>= EXPRESSION ;'
2406
`SYMBOL &= EXPRESSION ;'
2407
`SYMBOL |= EXPRESSION ;'
2408
 
2409
   The first case will define SYMBOL to the value of EXPRESSION.  In
2410
the other cases, SYMBOL must already be defined, and the value will be
2411
adjusted accordingly.
2412
 
2413
   The special symbol name `.' indicates the location counter.  You may
2414
only use this within a `SECTIONS' command.  *Note Location Counter::.
2415
 
2416
   The semicolon after EXPRESSION is required.
2417
 
2418
   Expressions are defined below; see *Note Expressions::.
2419
 
2420
   You may write symbol assignments as commands in their own right, or
2421
as statements within a `SECTIONS' command, or as part of an output
2422
section description in a `SECTIONS' command.
2423
 
2424
   The section of the symbol will be set from the section of the
2425
expression; for more information, see *Note Expression Section::.
2426
 
2427
   Here is an example showing the three different places that symbol
2428
assignments may be used:
2429
 
2430
     floating_point = 0;
2431
     SECTIONS
2432
     {
2433
       .text :
2434
         {
2435
           *(.text)
2436
           _etext = .;
2437
         }
2438
       _bdata = (. + 3) & ~ 3;
2439
       .data : { *(.data) }
2440
     }
2441
   In this example, the symbol `floating_point' will be defined as
2442
zero.  The symbol `_etext' will be defined as the address following the
2443
last `.text' input section.  The symbol `_bdata' will be defined as the
2444
address following the `.text' output section aligned upward to a 4 byte
2445
boundary.
2446
 
2447

2448
File: ld.info,  Node: PROVIDE,  Next: PROVIDE_HIDDEN,  Prev: Simple Assignments,  Up: Assignments
2449
 
2450
3.5.2 PROVIDE
2451
-------------
2452
 
2453
In some cases, it is desirable for a linker script to define a symbol
2454
only if it is referenced and is not defined by any object included in
2455
the link.  For example, traditional linkers defined the symbol `etext'.
2456
However, ANSI C requires that the user be able to use `etext' as a
2457
function name without encountering an error.  The `PROVIDE' keyword may
2458
be used to define a symbol, such as `etext', only if it is referenced
2459
but not defined.  The syntax is `PROVIDE(SYMBOL = EXPRESSION)'.
2460
 
2461
   Here is an example of using `PROVIDE' to define `etext':
2462
     SECTIONS
2463
     {
2464
       .text :
2465
         {
2466
           *(.text)
2467
           _etext = .;
2468
           PROVIDE(etext = .);
2469
         }
2470
     }
2471
 
2472
   In this example, if the program defines `_etext' (with a leading
2473
underscore), the linker will give a multiple definition error.  If, on
2474
the other hand, the program defines `etext' (with no leading
2475
underscore), the linker will silently use the definition in the program.
2476
If the program references `etext' but does not define it, the linker
2477
will use the definition in the linker script.
2478
 
2479

2480
File: ld.info,  Node: PROVIDE_HIDDEN,  Next: Source Code Reference,  Prev: PROVIDE,  Up: Assignments
2481
 
2482
3.5.3 PROVIDE_HIDDEN
2483
--------------------
2484
 
2485
Similar to `PROVIDE'.  For ELF targeted ports, the symbol will be
2486
hidden and won't be exported.
2487
 
2488

2489
File: ld.info,  Node: Source Code Reference,  Prev: PROVIDE_HIDDEN,  Up: Assignments
2490
 
2491
3.5.4 Source Code Reference
2492
---------------------------
2493
 
2494
Accessing a linker script defined variable from source code is not
2495
intuitive.  In particular a linker script symbol is not equivalent to a
2496
variable declaration in a high level language, it is instead a symbol
2497
that does not have a value.
2498
 
2499
   Before going further, it is important to note that compilers often
2500
transform names in the source code into different names when they are
2501
stored in the symbol table.  For example, Fortran compilers commonly
2502
prepend or append an underscore, and C++ performs extensive `name
2503
mangling'.  Therefore there might be a discrepancy between the name of
2504
a variable as it is used in source code and the name of the same
2505
variable as it is defined in a linker script.  For example in C a
2506
linker script variable might be referred to as:
2507
 
2508
       extern int foo;
2509
 
2510
   But in the linker script it might be defined as:
2511
 
2512
       _foo = 1000;
2513
 
2514
   In the remaining examples however it is assumed that no name
2515
transformation has taken place.
2516
 
2517
   When a symbol is declared in a high level language such as C, two
2518
things happen.  The first is that the compiler reserves enough space in
2519
the program's memory to hold the _value_ of the symbol.  The second is
2520
that the compiler creates an entry in the program's symbol table which
2521
holds the symbol's _address_.  ie the symbol table contains the address
2522
of the block of memory holding the symbol's value.  So for example the
2523
following C declaration, at file scope:
2524
 
2525
       int foo = 1000;
2526
 
2527
   creates a entry called `foo' in the symbol table.  This entry holds
2528
the address of an `int' sized block of memory where the number 1000 is
2529
initially stored.
2530
 
2531
   When a program references a symbol the compiler generates code that
2532
first accesses the symbol table to find the address of the symbol's
2533
memory block and then code to read the value from that memory block.
2534
So:
2535
 
2536
       foo = 1;
2537
 
2538
   looks up the symbol `foo' in the symbol table, gets the address
2539
associated with this symbol and then writes the value 1 into that
2540
address.  Whereas:
2541
 
2542
       int * a = & foo;
2543
 
2544
   looks up the symbol `foo' in the symbol table, gets it address and
2545
then copies this address into the block of memory associated with the
2546
variable `a'.
2547
 
2548
   Linker scripts symbol declarations, by contrast, create an entry in
2549
the symbol table but do not assign any memory to them.  Thus they are
2550
an address without a value.  So for example the linker script
2551
definition:
2552
 
2553
       foo = 1000;
2554
 
2555
   creates an entry in the symbol table called `foo' which holds the
2556
address of memory location 1000, but nothing special is stored at
2557
address 1000.  This means that you cannot access the _value_ of a
2558
linker script defined symbol - it has no value - all you can do is
2559
access the _address_ of a linker script defined symbol.
2560
 
2561
   Hence when you are using a linker script defined symbol in source
2562
code you should always take the address of the symbol, and never
2563
attempt to use its value.  For example suppose you want to copy the
2564
contents of a section of memory called .ROM into a section called
2565
.FLASH and the linker script contains these declarations:
2566
 
2567
       start_of_ROM   = .ROM;
2568
       end_of_ROM     = .ROM + sizeof (.ROM) - 1;
2569
       start_of_FLASH = .FLASH;
2570
 
2571
   Then the C source code to perform the copy would be:
2572
 
2573
       extern char start_of_ROM, end_of_ROM, start_of_FLASH;
2574
 
2575
       memcpy (& start_of_FLASH, & start_of_ROM, & end_of_ROM - & start_of_ROM);
2576
 
2577
   Note the use of the `&' operators.  These are correct.
2578
 
2579

2580
File: ld.info,  Node: SECTIONS,  Next: MEMORY,  Prev: Assignments,  Up: Scripts
2581
 
2582
3.6 SECTIONS Command
2583
====================
2584
 
2585
The `SECTIONS' command tells the linker how to map input sections into
2586
output sections, and how to place the output sections in memory.
2587
 
2588
   The format of the `SECTIONS' command is:
2589
     SECTIONS
2590
     {
2591
       SECTIONS-COMMAND
2592
       SECTIONS-COMMAND
2593
       ...
2594
     }
2595
 
2596
   Each SECTIONS-COMMAND may of be one of the following:
2597
 
2598
   * an `ENTRY' command (*note Entry command: Entry Point.)
2599
 
2600
   * a symbol assignment (*note Assignments::)
2601
 
2602
   * an output section description
2603
 
2604
   * an overlay description
2605
 
2606
   The `ENTRY' command and symbol assignments are permitted inside the
2607
`SECTIONS' command for convenience in using the location counter in
2608
those commands.  This can also make the linker script easier to
2609
understand because you can use those commands at meaningful points in
2610
the layout of the output file.
2611
 
2612
   Output section descriptions and overlay descriptions are described
2613
below.
2614
 
2615
   If you do not use a `SECTIONS' command in your linker script, the
2616
linker will place each input section into an identically named output
2617
section in the order that the sections are first encountered in the
2618
input files.  If all input sections are present in the first file, for
2619
example, the order of sections in the output file will match the order
2620
in the first input file.  The first section will be at address zero.
2621
 
2622
* Menu:
2623
 
2624
* Output Section Description::  Output section description
2625
* Output Section Name::         Output section name
2626
* Output Section Address::      Output section address
2627
* Input Section::               Input section description
2628
* Output Section Data::         Output section data
2629
* Output Section Keywords::     Output section keywords
2630
* Output Section Discarding::   Output section discarding
2631
* Output Section Attributes::   Output section attributes
2632
* Overlay Description::         Overlay description
2633
 
2634

2635
File: ld.info,  Node: Output Section Description,  Next: Output Section Name,  Up: SECTIONS
2636
 
2637
3.6.1 Output Section Description
2638
--------------------------------
2639
 
2640
The full description of an output section looks like this:
2641
     SECTION [ADDRESS] [(TYPE)] :
2642
       [AT(LMA)] [ALIGN(SECTION_ALIGN)] [SUBALIGN(SUBSECTION_ALIGN)]
2643
       {
2644
         OUTPUT-SECTION-COMMAND
2645
         OUTPUT-SECTION-COMMAND
2646
         ...
2647
       } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
2648
 
2649
   Most output sections do not use most of the optional section
2650
attributes.
2651
 
2652
   The whitespace around SECTION is required, so that the section name
2653
is unambiguous.  The colon and the curly braces are also required.  The
2654
line breaks and other white space are optional.
2655
 
2656
   Each OUTPUT-SECTION-COMMAND may be one of the following:
2657
 
2658
   * a symbol assignment (*note Assignments::)
2659
 
2660
   * an input section description (*note Input Section::)
2661
 
2662
   * data values to include directly (*note Output Section Data::)
2663
 
2664
   * a special output section keyword (*note Output Section Keywords::)
2665
 
2666

2667
File: ld.info,  Node: Output Section Name,  Next: Output Section Address,  Prev: Output Section Description,  Up: SECTIONS
2668
 
2669
3.6.2 Output Section Name
2670
-------------------------
2671
 
2672
The name of the output section is SECTION.  SECTION must meet the
2673
constraints of your output format.  In formats which only support a
2674
limited number of sections, such as `a.out', the name must be one of
2675
the names supported by the format (`a.out', for example, allows only
2676
`.text', `.data' or `.bss'). If the output format supports any number
2677
of sections, but with numbers and not names (as is the case for Oasys),
2678
the name should be supplied as a quoted numeric string.  A section name
2679
may consist of any sequence of characters, but a name which contains
2680
any unusual characters such as commas must be quoted.
2681
 
2682
   The output section name `/DISCARD/' is special; *Note Output Section
2683
Discarding::.
2684
 
2685

2686
File: ld.info,  Node: Output Section Address,  Next: Input Section,  Prev: Output Section Name,  Up: SECTIONS
2687
 
2688
3.6.3 Output Section Address
2689
----------------------------
2690
 
2691
The ADDRESS is an expression for the VMA (the virtual memory address)
2692
of the output section.  If you do not provide ADDRESS, the linker will
2693
set it based on REGION if present, or otherwise based on the current
2694
value of the location counter.
2695
 
2696
   If you provide ADDRESS, the address of the output section will be
2697
set to precisely that.  If you provide neither ADDRESS nor REGION, then
2698
the address of the output section will be set to the current value of
2699
the location counter aligned to the alignment requirements of the
2700
output section.  The alignment requirement of the output section is the
2701
strictest alignment of any input section contained within the output
2702
section.
2703
 
2704
   For example,
2705
     .text . : { *(.text) }
2706
   and
2707
     .text : { *(.text) }
2708
   are subtly different.  The first will set the address of the `.text'
2709
output section to the current value of the location counter.  The
2710
second will set it to the current value of the location counter aligned
2711
to the strictest alignment of a `.text' input section.
2712
 
2713
   The ADDRESS may be an arbitrary expression; *Note Expressions::.
2714
For example, if you want to align the section on a 0x10 byte boundary,
2715
so that the lowest four bits of the section address are zero, you could
2716
do something like this:
2717
     .text ALIGN(0x10) : { *(.text) }
2718
   This works because `ALIGN' returns the current location counter
2719
aligned upward to the specified value.
2720
 
2721
   Specifying ADDRESS for a section will change the value of the
2722
location counter.
2723
 
2724

2725
File: ld.info,  Node: Input Section,  Next: Output Section Data,  Prev: Output Section Address,  Up: SECTIONS
2726
 
2727
3.6.4 Input Section Description
2728
-------------------------------
2729
 
2730
The most common output section command is an input section description.
2731
 
2732
   The input section description is the most basic linker script
2733
operation.  You use output sections to tell the linker how to lay out
2734
your program in memory.  You use input section descriptions to tell the
2735
linker how to map the input files into your memory layout.
2736
 
2737
* Menu:
2738
 
2739
* Input Section Basics::        Input section basics
2740
* Input Section Wildcards::     Input section wildcard patterns
2741
* Input Section Common::        Input section for common symbols
2742
* Input Section Keep::          Input section and garbage collection
2743
* Input Section Example::       Input section example
2744
 
2745

2746
File: ld.info,  Node: Input Section Basics,  Next: Input Section Wildcards,  Up: Input Section
2747
 
2748
3.6.4.1 Input Section Basics
2749
............................
2750
 
2751
An input section description consists of a file name optionally followed
2752
by a list of section names in parentheses.
2753
 
2754
   The file name and the section name may be wildcard patterns, which we
2755
describe further below (*note Input Section Wildcards::).
2756
 
2757
   The most common input section description is to include all input
2758
sections with a particular name in the output section.  For example, to
2759
include all input `.text' sections, you would write:
2760
     *(.text)
2761
   Here the `*' is a wildcard which matches any file name.  To exclude
2762
a list of files from matching the file name wildcard, EXCLUDE_FILE may
2763
be used to match all files except the ones specified in the
2764
EXCLUDE_FILE list.  For example:
2765
     *(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors)
2766
   will cause all .ctors sections from all files except `crtend.o' and
2767
`otherfile.o' to be included.
2768
 
2769
   There are two ways to include more than one section:
2770
     *(.text .rdata)
2771
     *(.text) *(.rdata)
2772
   The difference between these is the order in which the `.text' and
2773
`.rdata' input sections will appear in the output section.  In the
2774
first example, they will be intermingled, appearing in the same order as
2775
they are found in the linker input.  In the second example, all `.text'
2776
input sections will appear first, followed by all `.rdata' input
2777
sections.
2778
 
2779
   You can specify a file name to include sections from a particular
2780
file.  You would do this if one or more of your files contain special
2781
data that needs to be at a particular location in memory.  For example:
2782
     data.o(.data)
2783
 
2784
   If you use a file name without a list of sections, then all sections
2785
in the input file will be included in the output section.  This is not
2786
commonly done, but it may by useful on occasion.  For example:
2787
     data.o
2788
 
2789
   When you use a file name which does not contain any wild card
2790
characters, the linker will first see if you also specified the file
2791
name on the linker command line or in an `INPUT' command.  If you did
2792
not, the linker will attempt to open the file as an input file, as
2793
though it appeared on the command line.  Note that this differs from an
2794
`INPUT' command, because the linker will not search for the file in the
2795
archive search path.
2796
 
2797

2798
File: ld.info,  Node: Input Section Wildcards,  Next: Input Section Common,  Prev: Input Section Basics,  Up: Input Section
2799
 
2800
3.6.4.2 Input Section Wildcard Patterns
2801
.......................................
2802
 
2803
In an input section description, either the file name or the section
2804
name or both may be wildcard patterns.
2805
 
2806
   The file name of `*' seen in many examples is a simple wildcard
2807
pattern for the file name.
2808
 
2809
   The wildcard patterns are like those used by the Unix shell.
2810
 
2811
`*'
2812
     matches any number of characters
2813
 
2814
`?'
2815
     matches any single character
2816
 
2817
`[CHARS]'
2818
     matches a single instance of any of the CHARS; the `-' character
2819
     may be used to specify a range of characters, as in `[a-z]' to
2820
     match any lower case letter
2821
 
2822
`\'
2823
     quotes the following character
2824
 
2825
   When a file name is matched with a wildcard, the wildcard characters
2826
will not match a `/' character (used to separate directory names on
2827
Unix).  A pattern consisting of a single `*' character is an exception;
2828
it will always match any file name, whether it contains a `/' or not.
2829
In a section name, the wildcard characters will match a `/' character.
2830
 
2831
   File name wildcard patterns only match files which are explicitly
2832
specified on the command line or in an `INPUT' command.  The linker
2833
does not search directories to expand wildcards.
2834
 
2835
   If a file name matches more than one wildcard pattern, or if a file
2836
name appears explicitly and is also matched by a wildcard pattern, the
2837
linker will use the first match in the linker script.  For example, this
2838
sequence of input section descriptions is probably in error, because the
2839
`data.o' rule will not be used:
2840
     .data : { *(.data) }
2841
     .data1 : { data.o(.data) }
2842
 
2843
   Normally, the linker will place files and sections matched by
2844
wildcards in the order in which they are seen during the link.  You can
2845
change this by using the `SORT_BY_NAME' keyword, which appears before a
2846
wildcard pattern in parentheses (e.g., `SORT_BY_NAME(.text*)').  When
2847
the `SORT_BY_NAME' keyword is used, the linker will sort the files or
2848
sections into ascending order by name before placing them in the output
2849
file.
2850
 
2851
   `SORT_BY_ALIGNMENT' is very similar to `SORT_BY_NAME'. The
2852
difference is `SORT_BY_ALIGNMENT' will sort sections into ascending
2853
order by alignment before placing them in the output file.
2854
 
2855
   `SORT' is an alias for `SORT_BY_NAME'.
2856
 
2857
   When there are nested section sorting commands in linker script,
2858
there can be at most 1 level of nesting for section sorting commands.
2859
 
2860
  1. `SORT_BY_NAME' (`SORT_BY_ALIGNMENT' (wildcard section pattern)).
2861
     It will sort the input sections by name first, then by alignment
2862
     if 2 sections have the same name.
2863
 
2864
  2. `SORT_BY_ALIGNMENT' (`SORT_BY_NAME' (wildcard section pattern)).
2865
     It will sort the input sections by alignment first, then by name
2866
     if 2 sections have the same alignment.
2867
 
2868
  3. `SORT_BY_NAME' (`SORT_BY_NAME' (wildcard section pattern)) is
2869
     treated the same as `SORT_BY_NAME' (wildcard section pattern).
2870
 
2871
  4. `SORT_BY_ALIGNMENT' (`SORT_BY_ALIGNMENT' (wildcard section
2872
     pattern)) is treated the same as `SORT_BY_ALIGNMENT' (wildcard
2873
     section pattern).
2874
 
2875
  5. All other nested section sorting commands are invalid.
2876
 
2877
   When both command line section sorting option and linker script
2878
section sorting command are used, section sorting command always takes
2879
precedence over the command line option.
2880
 
2881
   If the section sorting command in linker script isn't nested, the
2882
command line option will make the section sorting command to be treated
2883
as nested sorting command.
2884
 
2885
  1. `SORT_BY_NAME' (wildcard section pattern ) with `--sort-sections
2886
     alignment' is equivalent to `SORT_BY_NAME' (`SORT_BY_ALIGNMENT'
2887
     (wildcard section pattern)).
2888
 
2889
  2. `SORT_BY_ALIGNMENT' (wildcard section pattern) with
2890
     `--sort-section name' is equivalent to `SORT_BY_ALIGNMENT'
2891
     (`SORT_BY_NAME' (wildcard section pattern)).
2892
 
2893
   If the section sorting command in linker script is nested, the
2894
command line option will be ignored.
2895
 
2896
   If you ever get confused about where input sections are going, use
2897
the `-M' linker option to generate a map file.  The map file shows
2898
precisely how input sections are mapped to output sections.
2899
 
2900
   This example shows how wildcard patterns might be used to partition
2901
files.  This linker script directs the linker to place all `.text'
2902
sections in `.text' and all `.bss' sections in `.bss'.  The linker will
2903
place the `.data' section from all files beginning with an upper case
2904
character in `.DATA'; for all other files, the linker will place the
2905
`.data' section in `.data'.
2906
     SECTIONS {
2907
       .text : { *(.text) }
2908
       .DATA : { [A-Z]*(.data) }
2909
       .data : { *(.data) }
2910
       .bss : { *(.bss) }
2911
     }
2912
 
2913

2914
File: ld.info,  Node: Input Section Common,  Next: Input Section Keep,  Prev: Input Section Wildcards,  Up: Input Section
2915
 
2916
3.6.4.3 Input Section for Common Symbols
2917
........................................
2918
 
2919
A special notation is needed for common symbols, because in many object
2920
file formats common symbols do not have a particular input section.  The
2921
linker treats common symbols as though they are in an input section
2922
named `COMMON'.
2923
 
2924
   You may use file names with the `COMMON' section just as with any
2925
other input sections.  You can use this to place common symbols from a
2926
particular input file in one section while common symbols from other
2927
input files are placed in another section.
2928
 
2929
   In most cases, common symbols in input files will be placed in the
2930
`.bss' section in the output file.  For example:
2931
     .bss { *(.bss) *(COMMON) }
2932
 
2933
   Some object file formats have more than one type of common symbol.
2934
For example, the MIPS ELF object file format distinguishes standard
2935
common symbols and small common symbols.  In this case, the linker will
2936
use a different special section name for other types of common symbols.
2937
In the case of MIPS ELF, the linker uses `COMMON' for standard common
2938
symbols and `.scommon' for small common symbols.  This permits you to
2939
map the different types of common symbols into memory at different
2940
locations.
2941
 
2942
   You will sometimes see `[COMMON]' in old linker scripts.  This
2943
notation is now considered obsolete.  It is equivalent to `*(COMMON)'.
2944
 
2945

2946
File: ld.info,  Node: Input Section Keep,  Next: Input Section Example,  Prev: Input Section Common,  Up: Input Section
2947
 
2948
3.6.4.4 Input Section and Garbage Collection
2949
............................................
2950
 
2951
When link-time garbage collection is in use (`--gc-sections'), it is
2952
often useful to mark sections that should not be eliminated.  This is
2953
accomplished by surrounding an input section's wildcard entry with
2954
`KEEP()', as in `KEEP(*(.init))' or `KEEP(SORT_BY_NAME(*)(.ctors))'.
2955
 
2956

2957
File: ld.info,  Node: Input Section Example,  Prev: Input Section Keep,  Up: Input Section
2958
 
2959
3.6.4.5 Input Section Example
2960
.............................
2961
 
2962
The following example is a complete linker script.  It tells the linker
2963
to read all of the sections from file `all.o' and place them at the
2964
start of output section `outputa' which starts at location `0x10000'.
2965
All of section `.input1' from file `foo.o' follows immediately, in the
2966
same output section.  All of section `.input2' from `foo.o' goes into
2967
output section `outputb', followed by section `.input1' from `foo1.o'.
2968
All of the remaining `.input1' and `.input2' sections from any files
2969
are written to output section `outputc'.
2970
 
2971
     SECTIONS {
2972
       outputa 0x10000 :
2973
         {
2974
         all.o
2975
         foo.o (.input1)
2976
         }
2977
       outputb :
2978
         {
2979
         foo.o (.input2)
2980
         foo1.o (.input1)
2981
         }
2982
       outputc :
2983
         {
2984
         *(.input1)
2985
         *(.input2)
2986
         }
2987
     }
2988
 
2989

2990
File: ld.info,  Node: Output Section Data,  Next: Output Section Keywords,  Prev: Input Section,  Up: SECTIONS
2991
 
2992
3.6.5 Output Section Data
2993
-------------------------
2994
 
2995
You can include explicit bytes of data in an output section by using
2996
`BYTE', `SHORT', `LONG', `QUAD', or `SQUAD' as an output section
2997
command.  Each keyword is followed by an expression in parentheses
2998
providing the value to store (*note Expressions::).  The value of the
2999
expression is stored at the current value of the location counter.
3000
 
3001
   The `BYTE', `SHORT', `LONG', and `QUAD' commands store one, two,
3002
four, and eight bytes (respectively).  After storing the bytes, the
3003
location counter is incremented by the number of bytes stored.
3004
 
3005
   For example, this will store the byte 1 followed by the four byte
3006
value of the symbol `addr':
3007
     BYTE(1)
3008
     LONG(addr)
3009
 
3010
   When using a 64 bit host or target, `QUAD' and `SQUAD' are the same;
3011
they both store an 8 byte, or 64 bit, value.  When both host and target
3012
are 32 bits, an expression is computed as 32 bits.  In this case `QUAD'
3013
stores a 32 bit value zero extended to 64 bits, and `SQUAD' stores a 32
3014
bit value sign extended to 64 bits.
3015
 
3016
   If the object file format of the output file has an explicit
3017
endianness, which is the normal case, the value will be stored in that
3018
endianness.  When the object file format does not have an explicit
3019
endianness, as is true of, for example, S-records, the value will be
3020
stored in the endianness of the first input object file.
3021
 
3022
   Note--these commands only work inside a section description and not
3023
between them, so the following will produce an error from the linker:
3024
     SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }
3025
   whereas this will work:
3026
     SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }
3027
 
3028
   You may use the `FILL' command to set the fill pattern for the
3029
current section.  It is followed by an expression in parentheses.  Any
3030
otherwise unspecified regions of memory within the section (for example,
3031
gaps left due to the required alignment of input sections) are filled
3032
with the value of the expression, repeated as necessary.  A `FILL'
3033
statement covers memory locations after the point at which it occurs in
3034
the section definition; by including more than one `FILL' statement,
3035
you can have different fill patterns in different parts of an output
3036
section.
3037
 
3038
   This example shows how to fill unspecified regions of memory with the
3039
value `0x90':
3040
     FILL(0x90909090)
3041
 
3042
   The `FILL' command is similar to the `=FILLEXP' output section
3043
attribute, but it only affects the part of the section following the
3044
`FILL' command, rather than the entire section.  If both are used, the
3045
`FILL' command takes precedence.  *Note Output Section Fill::, for
3046
details on the fill expression.
3047
 
3048

3049
File: ld.info,  Node: Output Section Keywords,  Next: Output Section Discarding,  Prev: Output Section Data,  Up: SECTIONS
3050
 
3051
3.6.6 Output Section Keywords
3052
-----------------------------
3053
 
3054
There are a couple of keywords which can appear as output section
3055
commands.
3056
 
3057
`CREATE_OBJECT_SYMBOLS'
3058
     The command tells the linker to create a symbol for each input
3059
     file.  The name of each symbol will be the name of the
3060
     corresponding input file.  The section of each symbol will be the
3061
     output section in which the `CREATE_OBJECT_SYMBOLS' command
3062
     appears.
3063
 
3064
     This is conventional for the a.out object file format.  It is not
3065
     normally used for any other object file format.
3066
 
3067
`CONSTRUCTORS'
3068
     When linking using the a.out object file format, the linker uses an
3069
     unusual set construct to support C++ global constructors and
3070
     destructors.  When linking object file formats which do not support
3071
     arbitrary sections, such as ECOFF and XCOFF, the linker will
3072
     automatically recognize C++ global constructors and destructors by
3073
     name.  For these object file formats, the `CONSTRUCTORS' command
3074
     tells the linker to place constructor information in the output
3075
     section where the `CONSTRUCTORS' command appears.  The
3076
     `CONSTRUCTORS' command is ignored for other object file formats.
3077
 
3078
     The symbol `__CTOR_LIST__' marks the start of the global
3079
     constructors, and the symbol `__CTOR_END__' marks the end.
3080
     Similarly, `__DTOR_LIST__' and `__DTOR_END__' mark the start and
3081
     end of the global destructors.  The first word in the list is the
3082
     number of entries, followed by the address of each constructor or
3083
     destructor, followed by a zero word.  The compiler must arrange to
3084
     actually run the code.  For these object file formats GNU C++
3085
     normally calls constructors from a subroutine `__main'; a call to
3086
     `__main' is automatically inserted into the startup code for
3087
     `main'.  GNU C++ normally runs destructors either by using
3088
     `atexit', or directly from the function `exit'.
3089
 
3090
     For object file formats such as `COFF' or `ELF' which support
3091
     arbitrary section names, GNU C++ will normally arrange to put the
3092
     addresses of global constructors and destructors into the `.ctors'
3093
     and `.dtors' sections.  Placing the following sequence into your
3094
     linker script will build the sort of table which the GNU C++
3095
     runtime code expects to see.
3096
 
3097
                __CTOR_LIST__ = .;
3098
                LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
3099
                *(.ctors)
3100
                LONG(0)
3101
                __CTOR_END__ = .;
3102
                __DTOR_LIST__ = .;
3103
                LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
3104
                *(.dtors)
3105
                LONG(0)
3106
                __DTOR_END__ = .;
3107
 
3108
     If you are using the GNU C++ support for initialization priority,
3109
     which provides some control over the order in which global
3110
     constructors are run, you must sort the constructors at link time
3111
     to ensure that they are executed in the correct order.  When using
3112
     the `CONSTRUCTORS' command, use `SORT_BY_NAME(CONSTRUCTORS)'
3113
     instead.  When using the `.ctors' and `.dtors' sections, use
3114
     `*(SORT_BY_NAME(.ctors))' and `*(SORT_BY_NAME(.dtors))' instead of
3115
     just `*(.ctors)' and `*(.dtors)'.
3116
 
3117
     Normally the compiler and linker will handle these issues
3118
     automatically, and you will not need to concern yourself with
3119
     them.  However, you may need to consider this if you are using C++
3120
     and writing your own linker scripts.
3121
 
3122
 
3123

3124
File: ld.info,  Node: Output Section Discarding,  Next: Output Section Attributes,  Prev: Output Section Keywords,  Up: SECTIONS
3125
 
3126
3.6.7 Output Section Discarding
3127
-------------------------------
3128
 
3129
The linker will not create output sections with no contents.  This is
3130
for convenience when referring to input sections that may or may not be
3131
present in any of the input files.  For example:
3132
     .foo : { *(.foo) }
3133
   will only create a `.foo' section in the output file if there is a
3134
`.foo' section in at least one input file, and if the input sections
3135
are not all empty.  Other link script directives that allocate space in
3136
an output section will also create the output section.
3137
 
3138
   The linker will ignore address assignments (*note Output Section
3139
Address::) on discarded output sections, except when the linker script
3140
defines symbols in the output section.  In that case the linker will
3141
obey the address assignments, possibly advancing dot even though the
3142
section is discarded.
3143
 
3144
   The special output section name `/DISCARD/' may be used to discard
3145
input sections.  Any input sections which are assigned to an output
3146
section named `/DISCARD/' are not included in the output file.
3147
 
3148

3149
File: ld.info,  Node: Output Section Attributes,  Next: Overlay Description,  Prev: Output Section Discarding,  Up: SECTIONS
3150
 
3151
3.6.8 Output Section Attributes
3152
-------------------------------
3153
 
3154
We showed above that the full description of an output section looked
3155
like this:
3156
     SECTION [ADDRESS] [(TYPE)] :
3157
       [AT(LMA)] [ALIGN(SECTION_ALIGN)] [SUBALIGN(SUBSECTION_ALIGN)]
3158
       {
3159
         OUTPUT-SECTION-COMMAND
3160
         OUTPUT-SECTION-COMMAND
3161
         ...
3162
       } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP]
3163
We've already described SECTION, ADDRESS, and
3164
OUTPUT-SECTION-COMMAND.  In this section we will describe the remaining
3165
section attributes.
3166
 
3167
* Menu:
3168
 
3169
* Output Section Type::         Output section type
3170
* Output Section LMA::          Output section LMA
3171
* Forced Output Alignment::     Forced Output Alignment
3172
* Forced Input Alignment::      Forced Input Alignment
3173
* Output Section Region::       Output section region
3174
* Output Section Phdr::         Output section phdr
3175
* Output Section Fill::         Output section fill
3176
 
3177

3178
File: ld.info,  Node: Output Section Type,  Next: Output Section LMA,  Up: Output Section Attributes
3179
 
3180
3.6.8.1 Output Section Type
3181
...........................
3182
 
3183
Each output section may have a type.  The type is a keyword in
3184
parentheses.  The following types are defined:
3185
 
3186
`NOLOAD'
3187
     The section should be marked as not loadable, so that it will not
3188
     be loaded into memory when the program is run.
3189
 
3190
`DSECT'
3191
`COPY'
3192
`INFO'
3193
`OVERLAY'
3194
     These type names are supported for backward compatibility, and are
3195
     rarely used.  They all have the same effect: the section should be
3196
     marked as not allocatable, so that no memory is allocated for the
3197
     section when the program is run.
3198
 
3199
   The linker normally sets the attributes of an output section based on
3200
the input sections which map into it.  You can override this by using
3201
the section type.  For example, in the script sample below, the `ROM'
3202
section is addressed at memory location `0' and does not need to be
3203
loaded when the program is run.  The contents of the `ROM' section will
3204
appear in the linker output file as usual.
3205
     SECTIONS {
3206
       ROM 0 (NOLOAD) : { ... }
3207
       ...
3208
     }
3209
 
3210

3211
File: ld.info,  Node: Output Section LMA,  Next: Forced Output Alignment,  Prev: Output Section Type,  Up: Output Section Attributes
3212
 
3213
3.6.8.2 Output Section LMA
3214
..........................
3215
 
3216
Every section has a virtual address (VMA) and a load address (LMA); see
3217
*Note Basic Script Concepts::.  The address expression which may appear
3218
in an output section description sets the VMA (*note Output Section
3219
Address::).
3220
 
3221
   The expression LMA that follows the `AT' keyword specifies the load
3222
address of the section.
3223
 
3224
   Alternatively, with `AT>LMA_REGION' expression, you may specify a
3225
memory region for the section's load address. *Note MEMORY::.  Note
3226
that if the section has not had a VMA assigned to it then the linker
3227
will use the LMA_REGION as the VMA region as well.
3228
 
3229
   If neither `AT' nor `AT>' is specified for an allocatable section,
3230
the linker will set the LMA such that the difference between VMA and
3231
LMA for the section is the same as the preceding output section in the
3232
same region.  If there is no preceding output section or the section is
3233
not allocatable, the linker will set the LMA equal to the VMA.  *Note
3234
Output Section Region::.
3235
 
3236
   This feature is designed to make it easy to build a ROM image.  For
3237
example, the following linker script creates three output sections: one
3238
called `.text', which starts at `0x1000', one called `.mdata', which is
3239
loaded at the end of the `.text' section even though its VMA is
3240
`0x2000', and one called `.bss' to hold uninitialized data at address
3241
`0x3000'.  The symbol `_data' is defined with the value `0x2000', which
3242
shows that the location counter holds the VMA value, not the LMA value.
3243
 
3244
     SECTIONS
3245
       {
3246
       .text 0x1000 : { *(.text) _etext = . ; }
3247
       .mdata 0x2000 :
3248
         AT ( ADDR (.text) + SIZEOF (.text) )
3249
         { _data = . ; *(.data); _edata = . ;  }
3250
       .bss 0x3000 :
3251
         { _bstart = . ;  *(.bss) *(COMMON) ; _bend = . ;}
3252
     }
3253
 
3254
   The run-time initialization code for use with a program generated
3255
with this linker script would include something like the following, to
3256
copy the initialized data from the ROM image to its runtime address.
3257
Notice how this code takes advantage of the symbols defined by the
3258
linker script.
3259
 
3260
     extern char _etext, _data, _edata, _bstart, _bend;
3261
     char *src = &_etext;
3262
     char *dst = &_data;
3263
 
3264
     /* ROM has data at end of text; copy it. */
3265
     while (dst < &_edata) {
3266
       *dst++ = *src++;
3267
     }
3268
 
3269
     /* Zero bss */
3270
     for (dst = &_bstart; dst< &_bend; dst++)
3271
       *dst = 0;
3272
 
3273

3274
File: ld.info,  Node: Forced Output Alignment,  Next: Forced Input Alignment,  Prev: Output Section LMA,  Up: Output Section Attributes
3275
 
3276
3.6.8.3 Forced Output Alignment
3277
...............................
3278
 
3279
You can increase an output section's alignment by using ALIGN.
3280
 
3281

3282
File: ld.info,  Node: Forced Input Alignment,  Next: Output Section Region,  Prev: Forced Output Alignment,  Up: Output Section Attributes
3283
 
3284
3.6.8.4 Forced Input Alignment
3285
..............................
3286
 
3287
You can force input section alignment within an output section by using
3288
SUBALIGN.  The value specified overrides any alignment given by input
3289
sections, whether larger or smaller.
3290
 
3291

3292
File: ld.info,  Node: Output Section Region,  Next: Output Section Phdr,  Prev: Forced Input Alignment,  Up: Output Section Attributes
3293
 
3294
3.6.8.5 Output Section Region
3295
.............................
3296
 
3297
You can assign a section to a previously defined region of memory by
3298
using `>REGION'.  *Note MEMORY::.
3299
 
3300
   Here is a simple example:
3301
     MEMORY { rom : ORIGIN = 0x1000, LENGTH = 0x1000 }
3302
     SECTIONS { ROM : { *(.text) } >rom }
3303
 
3304

3305
File: ld.info,  Node: Output Section Phdr,  Next: Output Section Fill,  Prev: Output Section Region,  Up: Output Section Attributes
3306
 
3307
3.6.8.6 Output Section Phdr
3308
...........................
3309
 
3310
You can assign a section to a previously defined program segment by
3311
using `:PHDR'.  *Note PHDRS::.  If a section is assigned to one or more
3312
segments, then all subsequent allocated sections will be assigned to
3313
those segments as well, unless they use an explicitly `:PHDR' modifier.
3314
You can use `:NONE' to tell the linker to not put the section in any
3315
segment at all.
3316
 
3317
   Here is a simple example:
3318
     PHDRS { text PT_LOAD ; }
3319
     SECTIONS { .text : { *(.text) } :text }
3320
 
3321

3322
File: ld.info,  Node: Output Section Fill,  Prev: Output Section Phdr,  Up: Output Section Attributes
3323
 
3324
3.6.8.7 Output Section Fill
3325
...........................
3326
 
3327
You can set the fill pattern for an entire section by using `=FILLEXP'.
3328
FILLEXP is an expression (*note Expressions::).  Any otherwise
3329
unspecified regions of memory within the output section (for example,
3330
gaps left due to the required alignment of input sections) will be
3331
filled with the value, repeated as necessary.  If the fill expression
3332
is a simple hex number, ie. a string of hex digit starting with `0x'
3333
and without a trailing `k' or `M', then an arbitrarily long sequence of
3334
hex digits can be used to specify the fill pattern;  Leading zeros
3335
become part of the pattern too.  For all other cases, including extra
3336
parentheses or a unary `+', the fill pattern is the four least
3337
significant bytes of the value of the expression.  In all cases, the
3338
number is big-endian.
3339
 
3340
   You can also change the fill value with a `FILL' command in the
3341
output section commands; (*note Output Section Data::).
3342
 
3343
   Here is a simple example:
3344
     SECTIONS { .text : { *(.text) } =0x90909090 }
3345
 
3346

3347
File: ld.info,  Node: Overlay Description,  Prev: Output Section Attributes,  Up: SECTIONS
3348
 
3349
3.6.9 Overlay Description
3350
-------------------------
3351
 
3352
An overlay description provides an easy way to describe sections which
3353
are to be loaded as part of a single memory image but are to be run at
3354
the same memory address.  At run time, some sort of overlay manager will
3355
copy the overlaid sections in and out of the runtime memory address as
3356
required, perhaps by simply manipulating addressing bits.  This approach
3357
can be useful, for example, when a certain region of memory is faster
3358
than another.
3359
 
3360
   Overlays are described using the `OVERLAY' command.  The `OVERLAY'
3361
command is used within a `SECTIONS' command, like an output section
3362
description.  The full syntax of the `OVERLAY' command is as follows:
3363
     OVERLAY [START] : [NOCROSSREFS] [AT ( LDADDR )]
3364
       {
3365
         SECNAME1
3366
           {
3367
             OUTPUT-SECTION-COMMAND
3368
             OUTPUT-SECTION-COMMAND
3369
             ...
3370
           } [:PHDR...] [=FILL]
3371
         SECNAME2
3372
           {
3373
             OUTPUT-SECTION-COMMAND
3374
             OUTPUT-SECTION-COMMAND
3375
             ...
3376
           } [:PHDR...] [=FILL]
3377
         ...
3378
       } [>REGION] [:PHDR...] [=FILL]
3379
 
3380
   Everything is optional except `OVERLAY' (a keyword), and each
3381
section must have a name (SECNAME1 and SECNAME2 above).  The section
3382
definitions within the `OVERLAY' construct are identical to those
3383
within the general `SECTIONS' contruct (*note SECTIONS::), except that
3384
no addresses and no memory regions may be defined for sections within
3385
an `OVERLAY'.
3386
 
3387
   The sections are all defined with the same starting address.  The
3388
load addresses of the sections are arranged such that they are
3389
consecutive in memory starting at the load address used for the
3390
`OVERLAY' as a whole (as with normal section definitions, the load
3391
address is optional, and defaults to the start address; the start
3392
address is also optional, and defaults to the current value of the
3393
location counter).
3394
 
3395
   If the `NOCROSSREFS' keyword is used, and there any references among
3396
the sections, the linker will report an error.  Since the sections all
3397
run at the same address, it normally does not make sense for one
3398
section to refer directly to another.  *Note NOCROSSREFS: Miscellaneous
3399
Commands.
3400
 
3401
   For each section within the `OVERLAY', the linker automatically
3402
provides two symbols.  The symbol `__load_start_SECNAME' is defined as
3403
the starting load address of the section.  The symbol
3404
`__load_stop_SECNAME' is defined as the final load address of the
3405
section.  Any characters within SECNAME which are not legal within C
3406
identifiers are removed.  C (or assembler) code may use these symbols
3407
to move the overlaid sections around as necessary.
3408
 
3409
   At the end of the overlay, the value of the location counter is set
3410
to the start address of the overlay plus the size of the largest
3411
section.
3412
 
3413
   Here is an example.  Remember that this would appear inside a
3414
`SECTIONS' construct.
3415
       OVERLAY 0x1000 : AT (0x4000)
3416
        {
3417
          .text0 { o1/*.o(.text) }
3418
          .text1 { o2/*.o(.text) }
3419
        }
3420
This will define both `.text0' and `.text1' to start at address
3421
0x1000.  `.text0' will be loaded at address 0x4000, and `.text1' will
3422
be loaded immediately after `.text0'.  The following symbols will be
3423
defined if referenced: `__load_start_text0', `__load_stop_text0',
3424
`__load_start_text1', `__load_stop_text1'.
3425
 
3426
   C code to copy overlay `.text1' into the overlay area might look
3427
like the following.
3428
 
3429
       extern char __load_start_text1, __load_stop_text1;
3430
       memcpy ((char *) 0x1000, &__load_start_text1,
3431
               &__load_stop_text1 - &__load_start_text1);
3432
 
3433
   Note that the `OVERLAY' command is just syntactic sugar, since
3434
everything it does can be done using the more basic commands.  The above
3435
example could have been written identically as follows.
3436
 
3437
       .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
3438
       PROVIDE (__load_start_text0 = LOADADDR (.text0));
3439
       PROVIDE (__load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0));
3440
       .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
3441
       PROVIDE (__load_start_text1 = LOADADDR (.text1));
3442
       PROVIDE (__load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1));
3443
       . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
3444
 
3445

3446
File: ld.info,  Node: MEMORY,  Next: PHDRS,  Prev: SECTIONS,  Up: Scripts
3447
 
3448
3.7 MEMORY Command
3449
==================
3450
 
3451
The linker's default configuration permits allocation of all available
3452
memory.  You can override this by using the `MEMORY' command.
3453
 
3454
   The `MEMORY' command describes the location and size of blocks of
3455
memory in the target.  You can use it to describe which memory regions
3456
may be used by the linker, and which memory regions it must avoid.  You
3457
can then assign sections to particular memory regions.  The linker will
3458
set section addresses based on the memory regions, and will warn about
3459
regions that become too full.  The linker will not shuffle sections
3460
around to fit into the available regions.
3461
 
3462
   A linker script may contain at most one use of the `MEMORY' command.
3463
However, you can define as many blocks of memory within it as you
3464
wish.  The syntax is:
3465
     MEMORY
3466
       {
3467
         NAME [(ATTR)] : ORIGIN = ORIGIN, LENGTH = LEN
3468
         ...
3469
       }
3470
 
3471
   The NAME is a name used in the linker script to refer to the region.
3472
The region name has no meaning outside of the linker script.  Region
3473
names are stored in a separate name space, and will not conflict with
3474
symbol names, file names, or section names.  Each memory region must
3475
have a distinct name.
3476
 
3477
   The ATTR string is an optional list of attributes that specify
3478
whether to use a particular memory region for an input section which is
3479
not explicitly mapped in the linker script.  As described in *Note
3480
SECTIONS::, if you do not specify an output section for some input
3481
section, the linker will create an output section with the same name as
3482
the input section.  If you define region attributes, the linker will use
3483
them to select the memory region for the output section that it creates.
3484
 
3485
   The ATTR string must consist only of the following characters:
3486
`R'
3487
     Read-only section
3488
 
3489
`W'
3490
     Read/write section
3491
 
3492
`X'
3493
     Executable section
3494
 
3495
`A'
3496
     Allocatable section
3497
 
3498
`I'
3499
     Initialized section
3500
 
3501
`L'
3502
     Same as `I'
3503
 
3504
`!'
3505
     Invert the sense of any of the preceding attributes
3506
 
3507
   If a unmapped section matches any of the listed attributes other than
3508
`!', it will be placed in the memory region.  The `!' attribute
3509
reverses this test, so that an unmapped section will be placed in the
3510
memory region only if it does not match any of the listed attributes.
3511
 
3512
   The ORIGIN is an numerical expression for the start address of the
3513
memory region.  The expression must evaluate to a constant and it
3514
cannot involve any symbols.  The keyword `ORIGIN' may be abbreviated to
3515
`org' or `o' (but not, for example, `ORG').
3516
 
3517
   The LEN is an expression for the size in bytes of the memory region.
3518
As with the ORIGIN expression, the expression must be numerical only
3519
and must evaluate to a constant.  The keyword `LENGTH' may be
3520
abbreviated to `len' or `l'.
3521
 
3522
   In the following example, we specify that there are two memory
3523
regions available for allocation: one starting at `0' for 256 kilobytes,
3524
and the other starting at `0x40000000' for four megabytes.  The linker
3525
will place into the `rom' memory region every section which is not
3526
explicitly mapped into a memory region, and is either read-only or
3527
executable.  The linker will place other sections which are not
3528
explicitly mapped into a memory region into the `ram' memory region.
3529
 
3530
     MEMORY
3531
       {
3532
         rom (rx)  : ORIGIN = 0, LENGTH = 256K
3533
         ram (!rx) : org = 0x40000000, l = 4M
3534
       }
3535
 
3536
   Once you define a memory region, you can direct the linker to place
3537
specific output sections into that memory region by using the `>REGION'
3538
output section attribute.  For example, if you have a memory region
3539
named `mem', you would use `>mem' in the output section definition.
3540
*Note Output Section Region::.  If no address was specified for the
3541
output section, the linker will set the address to the next available
3542
address within the memory region.  If the combined output sections
3543
directed to a memory region are too large for the region, the linker
3544
will issue an error message.
3545
 
3546
   It is possible to access the origin and length of a memory in an
3547
expression via the `ORIGIN(MEMORY)' and `LENGTH(MEMORY)' functions:
3548
 
3549
       _fstack = ORIGIN(ram) + LENGTH(ram) - 4;
3550
 
3551

3552
File: ld.info,  Node: PHDRS,  Next: VERSION,  Prev: MEMORY,  Up: Scripts
3553
 
3554
3.8 PHDRS Command
3555
=================
3556
 
3557
The ELF object file format uses "program headers", also knows as
3558
"segments".  The program headers describe how the program should be
3559
loaded into memory.  You can print them out by using the `objdump'
3560
program with the `-p' option.
3561
 
3562
   When you run an ELF program on a native ELF system, the system loader
3563
reads the program headers in order to figure out how to load the
3564
program.  This will only work if the program headers are set correctly.
3565
This manual does not describe the details of how the system loader
3566
interprets program headers; for more information, see the ELF ABI.
3567
 
3568
   The linker will create reasonable program headers by default.
3569
However, in some cases, you may need to specify the program headers more
3570
precisely.  You may use the `PHDRS' command for this purpose.  When the
3571
linker sees the `PHDRS' command in the linker script, it will not
3572
create any program headers other than the ones specified.
3573
 
3574
   The linker only pays attention to the `PHDRS' command when
3575
generating an ELF output file.  In other cases, the linker will simply
3576
ignore `PHDRS'.
3577
 
3578
   This is the syntax of the `PHDRS' command.  The words `PHDRS',
3579
`FILEHDR', `AT', and `FLAGS' are keywords.
3580
 
3581
     PHDRS
3582
     {
3583
       NAME TYPE [ FILEHDR ] [ PHDRS ] [ AT ( ADDRESS ) ]
3584
             [ FLAGS ( FLAGS ) ] ;
3585
     }
3586
 
3587
   The NAME is used only for reference in the `SECTIONS' command of the
3588
linker script.  It is not put into the output file.  Program header
3589
names are stored in a separate name space, and will not conflict with
3590
symbol names, file names, or section names.  Each program header must
3591
have a distinct name.
3592
 
3593
   Certain program header types describe segments of memory which the
3594
system loader will load from the file.  In the linker script, you
3595
specify the contents of these segments by placing allocatable output
3596
sections in the segments.  You use the `:PHDR' output section attribute
3597
to place a section in a particular segment.  *Note Output Section
3598
Phdr::.
3599
 
3600
   It is normal to put certain sections in more than one segment.  This
3601
merely implies that one segment of memory contains another.  You may
3602
repeat `:PHDR', using it once for each segment which should contain the
3603
section.
3604
 
3605
   If you place a section in one or more segments using `:PHDR', then
3606
the linker will place all subsequent allocatable sections which do not
3607
specify `:PHDR' in the same segments.  This is for convenience, since
3608
generally a whole set of contiguous sections will be placed in a single
3609
segment.  You can use `:NONE' to override the default segment and tell
3610
the linker to not put the section in any segment at all.
3611
 
3612
   You may use the `FILEHDR' and `PHDRS' keywords appear after the
3613
program header type to further describe the contents of the segment.
3614
The `FILEHDR' keyword means that the segment should include the ELF
3615
file header.  The `PHDRS' keyword means that the segment should include
3616
the ELF program headers themselves.
3617
 
3618
   The TYPE may be one of the following.  The numbers indicate the
3619
value of the keyword.
3620
 
3621
`PT_NULL' (0)
3622
     Indicates an unused program header.
3623
 
3624
`PT_LOAD' (1)
3625
     Indicates that this program header describes a segment to be
3626
     loaded from the file.
3627
 
3628
`PT_DYNAMIC' (2)
3629
     Indicates a segment where dynamic linking information can be found.
3630
 
3631
`PT_INTERP' (3)
3632
     Indicates a segment where the name of the program interpreter may
3633
     be found.
3634
 
3635
`PT_NOTE' (4)
3636
     Indicates a segment holding note information.
3637
 
3638
`PT_SHLIB' (5)
3639
     A reserved program header type, defined but not specified by the
3640
     ELF ABI.
3641
 
3642
`PT_PHDR' (6)
3643
     Indicates a segment where the program headers may be found.
3644
 
3645
EXPRESSION
3646
     An expression giving the numeric type of the program header.  This
3647
     may be used for types not defined above.
3648
 
3649
   You can specify that a segment should be loaded at a particular
3650
address in memory by using an `AT' expression.  This is identical to the
3651
`AT' command used as an output section attribute (*note Output Section
3652
LMA::).  The `AT' command for a program header overrides the output
3653
section attribute.
3654
 
3655
   The linker will normally set the segment flags based on the sections
3656
which comprise the segment.  You may use the `FLAGS' keyword to
3657
explicitly specify the segment flags.  The value of FLAGS must be an
3658
integer.  It is used to set the `p_flags' field of the program header.
3659
 
3660
   Here is an example of `PHDRS'.  This shows a typical set of program
3661
headers used on a native ELF system.
3662
 
3663
     PHDRS
3664
     {
3665
       headers PT_PHDR PHDRS ;
3666
       interp PT_INTERP ;
3667
       text PT_LOAD FILEHDR PHDRS ;
3668
       data PT_LOAD ;
3669
       dynamic PT_DYNAMIC ;
3670
     }
3671
 
3672
     SECTIONS
3673
     {
3674
       . = SIZEOF_HEADERS;
3675
       .interp : { *(.interp) } :text :interp
3676
       .text : { *(.text) } :text
3677
       .rodata : { *(.rodata) } /* defaults to :text */
3678
       ...
3679
       . = . + 0x1000; /* move to a new page in memory */
3680
       .data : { *(.data) } :data
3681
       .dynamic : { *(.dynamic) } :data :dynamic
3682
       ...
3683
     }
3684
 
3685

3686
File: ld.info,  Node: VERSION,  Next: Expressions,  Prev: PHDRS,  Up: Scripts
3687
 
3688
3.9 VERSION Command
3689
===================
3690
 
3691
The linker supports symbol versions when using ELF.  Symbol versions are
3692
only useful when using shared libraries.  The dynamic linker can use
3693
symbol versions to select a specific version of a function when it runs
3694
a program that may have been linked against an earlier version of the
3695
shared library.
3696
 
3697
   You can include a version script directly in the main linker script,
3698
or you can supply the version script as an implicit linker script.  You
3699
can also use the `--version-script' linker option.
3700
 
3701
   The syntax of the `VERSION' command is simply
3702
     VERSION { version-script-commands }
3703
 
3704
   The format of the version script commands is identical to that used
3705
by Sun's linker in Solaris 2.5.  The version script defines a tree of
3706
version nodes.  You specify the node names and interdependencies in the
3707
version script.  You can specify which symbols are bound to which
3708
version nodes, and you can reduce a specified set of symbols to local
3709
scope so that they are not globally visible outside of the shared
3710
library.
3711
 
3712
   The easiest way to demonstrate the version script language is with a
3713
few examples.
3714
 
3715
     VERS_1.1 {
3716
         global:
3717
                 foo1;
3718
         local:
3719
                 old*;
3720
                 original*;
3721
                 new*;
3722
     };
3723
 
3724
     VERS_1.2 {
3725
                 foo2;
3726
     } VERS_1.1;
3727
 
3728
     VERS_2.0 {
3729
                 bar1; bar2;
3730
         extern "C++" {
3731
                 ns::*;
3732
                 "int f(int, double)";
3733
              }
3734
     } VERS_1.2;
3735
 
3736
   This example version script defines three version nodes.  The first
3737
version node defined is `VERS_1.1'; it has no other dependencies.  The
3738
script binds the symbol `foo1' to `VERS_1.1'.  It reduces a number of
3739
symbols to local scope so that they are not visible outside of the
3740
shared library; this is done using wildcard patterns, so that any
3741
symbol whose name begins with `old', `original', or `new' is matched.
3742
The wildcard patterns available are the same as those used in the shell
3743
when matching filenames (also known as "globbing").  However, if you
3744
specify the symbol name inside double quotes, then the name is treated
3745
as literal, rather than as a glob pattern.
3746
 
3747
   Next, the version script defines node `VERS_1.2'.  This node depends
3748
upon `VERS_1.1'.  The script binds the symbol `foo2' to the version
3749
node `VERS_1.2'.
3750
 
3751
   Finally, the version script defines node `VERS_2.0'.  This node
3752
depends upon `VERS_1.2'.  The scripts binds the symbols `bar1' and
3753
`bar2' are bound to the version node `VERS_2.0'.
3754
 
3755
   When the linker finds a symbol defined in a library which is not
3756
specifically bound to a version node, it will effectively bind it to an
3757
unspecified base version of the library.  You can bind all otherwise
3758
unspecified symbols to a given version node by using `global: *;'
3759
somewhere in the version script.
3760
 
3761
   The names of the version nodes have no specific meaning other than
3762
what they might suggest to the person reading them.  The `2.0' version
3763
could just as well have appeared in between `1.1' and `1.2'.  However,
3764
this would be a confusing way to write a version script.
3765
 
3766
   Node name can be omitted, provided it is the only version node in
3767
the version script.  Such version script doesn't assign any versions to
3768
symbols, only selects which symbols will be globally visible out and
3769
which won't.
3770
 
3771
     { global: foo; bar; local: *; };
3772
 
3773
   When you link an application against a shared library that has
3774
versioned symbols, the application itself knows which version of each
3775
symbol it requires, and it also knows which version nodes it needs from
3776
each shared library it is linked against.  Thus at runtime, the dynamic
3777
loader can make a quick check to make sure that the libraries you have
3778
linked against do in fact supply all of the version nodes that the
3779
application will need to resolve all of the dynamic symbols.  In this
3780
way it is possible for the dynamic linker to know with certainty that
3781
all external symbols that it needs will be resolvable without having to
3782
search for each symbol reference.
3783
 
3784
   The symbol versioning is in effect a much more sophisticated way of
3785
doing minor version checking that SunOS does.  The fundamental problem
3786
that is being addressed here is that typically references to external
3787
functions are bound on an as-needed basis, and are not all bound when
3788
the application starts up.  If a shared library is out of date, a
3789
required interface may be missing; when the application tries to use
3790
that interface, it may suddenly and unexpectedly fail.  With symbol
3791
versioning, the user will get a warning when they start their program if
3792
the libraries being used with the application are too old.
3793
 
3794
   There are several GNU extensions to Sun's versioning approach.  The
3795
first of these is the ability to bind a symbol to a version node in the
3796
source file where the symbol is defined instead of in the versioning
3797
script.  This was done mainly to reduce the burden on the library
3798
maintainer.  You can do this by putting something like:
3799
     __asm__(".symver original_foo,foo@VERS_1.1");
3800
   in the C source file.  This renames the function `original_foo' to
3801
be an alias for `foo' bound to the version node `VERS_1.1'.  The
3802
`local:' directive can be used to prevent the symbol `original_foo'
3803
from being exported. A `.symver' directive takes precedence over a
3804
version script.
3805
 
3806
   The second GNU extension is to allow multiple versions of the same
3807
function to appear in a given shared library.  In this way you can make
3808
an incompatible change to an interface without increasing the major
3809
version number of the shared library, while still allowing applications
3810
linked against the old interface to continue to function.
3811
 
3812
   To do this, you must use multiple `.symver' directives in the source
3813
file.  Here is an example:
3814
 
3815
     __asm__(".symver original_foo,foo@");
3816
     __asm__(".symver old_foo,foo@VERS_1.1");
3817
     __asm__(".symver old_foo1,foo@VERS_1.2");
3818
     __asm__(".symver new_foo,foo@@VERS_2.0");
3819
 
3820
   In this example, `foo@' represents the symbol `foo' bound to the
3821
unspecified base version of the symbol.  The source file that contains
3822
this example would define 4 C functions: `original_foo', `old_foo',
3823
`old_foo1', and `new_foo'.
3824
 
3825
   When you have multiple definitions of a given symbol, there needs to
3826
be some way to specify a default version to which external references to
3827
this symbol will be bound.  You can do this with the `foo@@VERS_2.0'
3828
type of `.symver' directive.  You can only declare one version of a
3829
symbol as the default in this manner; otherwise you would effectively
3830
have multiple definitions of the same symbol.
3831
 
3832
   If you wish to bind a reference to a specific version of the symbol
3833
within the shared library, you can use the aliases of convenience
3834
(i.e., `old_foo'), or you can use the `.symver' directive to
3835
specifically bind to an external version of the function in question.
3836
 
3837
   You can also specify the language in the version script:
3838
 
3839
     VERSION extern "lang" { version-script-commands }
3840
 
3841
   The supported `lang's are `C', `C++', and `Java'.  The linker will
3842
iterate over the list of symbols at the link time and demangle them
3843
according to `lang' before matching them to the patterns specified in
3844
`version-script-commands'.
3845
 
3846
   Demangled names may contains spaces and other special characters.  As
3847
described above, you can use a glob pattern to match demangled names,
3848
or you can use a double-quoted string to match the string exactly.  In
3849
the latter case, be aware that minor differences (such as differing
3850
whitespace) between the version script and the demangler output will
3851
cause a mismatch.  As the exact string generated by the demangler might
3852
change in the future, even if the mangled name does not, you should
3853
check that all of your version directives are behaving as you expect
3854
when you upgrade.
3855
 
3856

3857
File: ld.info,  Node: Expressions,  Next: Implicit Linker Scripts,  Prev: VERSION,  Up: Scripts
3858
 
3859
3.10 Expressions in Linker Scripts
3860
==================================
3861
 
3862
The syntax for expressions in the linker script language is identical to
3863
that of C expressions.  All expressions are evaluated as integers.  All
3864
expressions are evaluated in the same size, which is 32 bits if both the
3865
host and target are 32 bits, and is otherwise 64 bits.
3866
 
3867
   You can use and set symbol values in expressions.
3868
 
3869
   The linker defines several special purpose builtin functions for use
3870
in expressions.
3871
 
3872
* Menu:
3873
 
3874
* Constants::                   Constants
3875
* Symbols::                     Symbol Names
3876
* Orphan Sections::             Orphan Sections
3877
* Location Counter::            The Location Counter
3878
* Operators::                   Operators
3879
* Evaluation::                  Evaluation
3880
* Expression Section::          The Section of an Expression
3881
* Builtin Functions::           Builtin Functions
3882
 
3883

3884
File: ld.info,  Node: Constants,  Next: Symbols,  Up: Expressions
3885
 
3886
3.10.1 Constants
3887
----------------
3888
 
3889
All constants are integers.
3890
 
3891
   As in C, the linker considers an integer beginning with `0' to be
3892
octal, and an integer beginning with `0x' or `0X' to be hexadecimal.
3893
The linker considers other integers to be decimal.
3894
 
3895
   In addition, you can use the suffixes `K' and `M' to scale a
3896
constant by `1024' or `1024*1024' respectively. For example, the
3897
following all refer to the same quantity:
3898
     _fourk_1 = 4K;
3899
     _fourk_2 = 4096;
3900
     _fourk_3 = 0x1000;
3901
 
3902

3903
File: ld.info,  Node: Symbols,  Next: Orphan Sections,  Prev: Constants,  Up: Expressions
3904
 
3905
3.10.2 Symbol Names
3906
-------------------
3907
 
3908
Unless quoted, symbol names start with a letter, underscore, or period
3909
and may include letters, digits, underscores, periods, and hyphens.
3910
Unquoted symbol names must not conflict with any keywords.  You can
3911
specify a symbol which contains odd characters or has the same name as a
3912
keyword by surrounding the symbol name in double quotes:
3913
     "SECTION" = 9;
3914
     "with a space" = "also with a space" + 10;
3915
 
3916
   Since symbols can contain many non-alphabetic characters, it is
3917
safest to delimit symbols with spaces.  For example, `A-B' is one
3918
symbol, whereas `A - B' is an expression involving subtraction.
3919
 
3920

3921
File: ld.info,  Node: Orphan Sections,  Next: Location Counter,  Prev: Symbols,  Up: Expressions
3922
 
3923
3.10.3 Orphan Sections
3924
----------------------
3925
 
3926
Orphan sections are sections present in the input files which are not
3927
explicitly placed into the output file by the linker script.  The
3928
linker will still copy these sections into the output file, but it has
3929
to guess as to where they should be placed.  The linker uses a simple
3930
heuristic to do this.  It attempts to place orphan sections after
3931
non-orphan sections of the same attribute, such as code vs data,
3932
loadable vs non-loadable, etc.  If there is not enough room to do this
3933
then it places at the end of the file.
3934
 
3935
   For ELF targets, the attribute of the section includes section type
3936
as well as section flag.
3937
 
3938

3939
File: ld.info,  Node: Location Counter,  Next: Operators,  Prev: Orphan Sections,  Up: Expressions
3940
 
3941
3.10.4 The Location Counter
3942
---------------------------
3943
 
3944
The special linker variable "dot" `.' always contains the current
3945
output location counter.  Since the `.' always refers to a location in
3946
an output section, it may only appear in an expression within a
3947
`SECTIONS' command.  The `.' symbol may appear anywhere that an
3948
ordinary symbol is allowed in an expression.
3949
 
3950
   Assigning a value to `.' will cause the location counter to be
3951
moved.  This may be used to create holes in the output section.  The
3952
location counter may not be moved backwards inside an output section,
3953
and may not be moved backwards outside of an output section if so doing
3954
creates areas with overlapping LMAs.
3955
 
3956
     SECTIONS
3957
     {
3958
       output :
3959
         {
3960
           file1(.text)
3961
           . = . + 1000;
3962
           file2(.text)
3963
           . += 1000;
3964
           file3(.text)
3965
         } = 0x12345678;
3966
     }
3967
   In the previous example, the `.text' section from `file1' is located
3968
at the beginning of the output section `output'.  It is followed by a
3969
1000 byte gap.  Then the `.text' section from `file2' appears, also
3970
with a 1000 byte gap following before the `.text' section from `file3'.
3971
The notation `= 0x12345678' specifies what data to write in the gaps
3972
(*note Output Section Fill::).
3973
 
3974
   Note: `.' actually refers to the byte offset from the start of the
3975
current containing object.  Normally this is the `SECTIONS' statement,
3976
whose start address is 0, hence `.' can be used as an absolute address.
3977
If `.' is used inside a section description however, it refers to the
3978
byte offset from the start of that section, not an absolute address.
3979
Thus in a script like this:
3980
 
3981
     SECTIONS
3982
     {
3983
         . = 0x100
3984
         .text: {
3985
           *(.text)
3986
           . = 0x200
3987
         }
3988
         . = 0x500
3989
         .data: {
3990
           *(.data)
3991
           . += 0x600
3992
         }
3993
     }
3994
 
3995
   The `.text' section will be assigned a starting address of 0x100 and
3996
a size of exactly 0x200 bytes, even if there is not enough data in the
3997
`.text' input sections to fill this area.  (If there is too much data,
3998
an error will be produced because this would be an attempt to move `.'
3999
backwards).  The `.data' section will start at 0x500 and it will have
4000
an extra 0x600 bytes worth of space after the end of the values from
4001
the `.data' input sections and before the end of the `.data' output
4002
section itself.
4003
 
4004
   Setting symbols to the value of the location counter outside of an
4005
output section statement can result in unexpected values if the linker
4006
needs to place orphan sections.  For example, given the following:
4007
 
4008
     SECTIONS
4009
     {
4010
         start_of_text = . ;
4011
         .text: { *(.text) }
4012
         end_of_text = . ;
4013
 
4014
         start_of_data = . ;
4015
         .data: { *(.data) }
4016
         end_of_data = . ;
4017
     }
4018
 
4019
   If the linker needs to place some input section, e.g. `.rodata', not
4020
mentioned in the script, it might choose to place that section between
4021
`.text' and `.data'.  You might think the linker should place `.rodata'
4022
on the blank line in the above script, but blank lines are of no
4023
particular significance to the linker.  As well, the linker doesn't
4024
associate the above symbol names with their sections.  Instead, it
4025
assumes that all assignments or other statements belong to the previous
4026
output section, except for the special case of an assignment to `.'.
4027
I.e., the linker will place the orphan `.rodata' section as if the
4028
script was written as follows:
4029
 
4030
     SECTIONS
4031
     {
4032
         start_of_text = . ;
4033
         .text: { *(.text) }
4034
         end_of_text = . ;
4035
 
4036
         start_of_data = . ;
4037
         .rodata: { *(.rodata) }
4038
         .data: { *(.data) }
4039
         end_of_data = . ;
4040
     }
4041
 
4042
   This may or may not be the script author's intention for the value of
4043
`start_of_data'.  One way to influence the orphan section placement is
4044
to assign the location counter to itself, as the linker assumes that an
4045
assignment to `.' is setting the start address of a following output
4046
section and thus should be grouped with that section.  So you could
4047
write:
4048
 
4049
     SECTIONS
4050
     {
4051
         start_of_text = . ;
4052
         .text: { *(.text) }
4053
         end_of_text = . ;
4054
 
4055
         . = . ;
4056
         start_of_data = . ;
4057
         .data: { *(.data) }
4058
         end_of_data = . ;
4059
     }
4060
 
4061
   Now, the orphan `.rodata' section will be placed between
4062
`end_of_text' and `start_of_data'.
4063
 
4064

4065
File: ld.info,  Node: Operators,  Next: Evaluation,  Prev: Location Counter,  Up: Expressions
4066
 
4067
3.10.5 Operators
4068
----------------
4069
 
4070
The linker recognizes the standard C set of arithmetic operators, with
4071
the standard bindings and precedence levels:
4072
     precedence      associativity   Operators                Notes
4073
     (highest)
4074
     1               left            !  -  ~                  (1)
4075
     2               left            *  /  %
4076
     3               left            +  -
4077
     4               left            >>  <<
4078
     5               left            ==  !=  >  <  <=  >=
4079
     6               left            &
4080
     7               left            |
4081
     8               left            &&
4082
     9               left            ||
4083
     10              right           ? :
4084
     11              right           &=  +=  -=  *=  /=       (2)
4085
     (lowest)
4086
   Notes: (1) Prefix operators (2) *Note Assignments::.
4087
 
4088

4089
File: ld.info,  Node: Evaluation,  Next: Expression Section,  Prev: Operators,  Up: Expressions
4090
 
4091
3.10.6 Evaluation
4092
-----------------
4093
 
4094
The linker evaluates expressions lazily.  It only computes the value of
4095
an expression when absolutely necessary.
4096
 
4097
   The linker needs some information, such as the value of the start
4098
address of the first section, and the origins and lengths of memory
4099
regions, in order to do any linking at all.  These values are computed
4100
as soon as possible when the linker reads in the linker script.
4101
 
4102
   However, other values (such as symbol values) are not known or needed
4103
until after storage allocation.  Such values are evaluated later, when
4104
other information (such as the sizes of output sections) is available
4105
for use in the symbol assignment expression.
4106
 
4107
   The sizes of sections cannot be known until after allocation, so
4108
assignments dependent upon these are not performed until after
4109
allocation.
4110
 
4111
   Some expressions, such as those depending upon the location counter
4112
`.', must be evaluated during section allocation.
4113
 
4114
   If the result of an expression is required, but the value is not
4115
available, then an error results.  For example, a script like the
4116
following
4117
     SECTIONS
4118
       {
4119
         .text 9+this_isnt_constant :
4120
           { *(.text) }
4121
       }
4122
will cause the error message `non constant expression for initial
4123
address'.
4124
 
4125

4126
File: ld.info,  Node: Expression Section,  Next: Builtin Functions,  Prev: Evaluation,  Up: Expressions
4127
 
4128
3.10.7 The Section of an Expression
4129
-----------------------------------
4130
 
4131
When the linker evaluates an expression, the result is either absolute
4132
or relative to some section.  A relative expression is expressed as a
4133
fixed offset from the base of a section.
4134
 
4135
   The position of the expression within the linker script determines
4136
whether it is absolute or relative.  An expression which appears within
4137
an output section definition is relative to the base of the output
4138
section.  An expression which appears elsewhere will be absolute.
4139
 
4140
   A symbol set to a relative expression will be relocatable if you
4141
request relocatable output using the `-r' option.  That means that a
4142
further link operation may change the value of the symbol.  The symbol's
4143
section will be the section of the relative expression.
4144
 
4145
   A symbol set to an absolute expression will retain the same value
4146
through any further link operation.  The symbol will be absolute, and
4147
will not have any particular associated section.
4148
 
4149
   You can use the builtin function `ABSOLUTE' to force an expression
4150
to be absolute when it would otherwise be relative.  For example, to
4151
create an absolute symbol set to the address of the end of the output
4152
section `.data':
4153
     SECTIONS
4154
       {
4155
         .data : { *(.data) _edata = ABSOLUTE(.); }
4156
       }
4157
   If `ABSOLUTE' were not used, `_edata' would be relative to the
4158
`.data' section.
4159
 
4160

4161
File: ld.info,  Node: Builtin Functions,  Prev: Expression Section,  Up: Expressions
4162
 
4163
3.10.8 Builtin Functions
4164
------------------------
4165
 
4166
The linker script language includes a number of builtin functions for
4167
use in linker script expressions.
4168
 
4169
`ABSOLUTE(EXP)'
4170
     Return the absolute (non-relocatable, as opposed to non-negative)
4171
     value of the expression EXP.  Primarily useful to assign an
4172
     absolute value to a symbol within a section definition, where
4173
     symbol values are normally section relative.  *Note Expression
4174
     Section::.
4175
 
4176
`ADDR(SECTION)'
4177
     Return the absolute address (the VMA) of the named SECTION.  Your
4178
     script must previously have defined the location of that section.
4179
     In the following example, `symbol_1' and `symbol_2' are assigned
4180
     identical values:
4181
          SECTIONS { ...
4182
            .output1 :
4183
              {
4184
              start_of_output_1 = ABSOLUTE(.);
4185
              ...
4186
              }
4187
            .output :
4188
              {
4189
              symbol_1 = ADDR(.output1);
4190
              symbol_2 = start_of_output_1;
4191
              }
4192
          ... }
4193
 
4194
`ALIGN(ALIGN)'
4195
`ALIGN(EXP,ALIGN)'
4196
     Return the location counter (`.') or arbitrary expression aligned
4197
     to the next ALIGN boundary.  The single operand `ALIGN' doesn't
4198
     change the value of the location counter--it just does arithmetic
4199
     on it.  The two operand `ALIGN' allows an arbitrary expression to
4200
     be aligned upwards (`ALIGN(ALIGN)' is equivalent to `ALIGN(.,
4201
     ALIGN)').
4202
 
4203
     Here is an example which aligns the output `.data' section to the
4204
     next `0x2000' byte boundary after the preceding section and sets a
4205
     variable within the section to the next `0x8000' boundary after the
4206
     input sections:
4207
          SECTIONS { ...
4208
            .data ALIGN(0x2000): {
4209
              *(.data)
4210
              variable = ALIGN(0x8000);
4211
            }
4212
          ... }
4213
     The first use of `ALIGN' in this example specifies the
4214
     location of a section because it is used as the optional ADDRESS
4215
     attribute of a section definition (*note Output Section
4216
     Address::).  The second use of `ALIGN' is used to defines the
4217
     value of a symbol.
4218
 
4219
     The builtin function `NEXT' is closely related to `ALIGN'.
4220
 
4221
`ALIGNOF(SECTION)'
4222
     Return the alignment in bytes of the named SECTION, if that
4223
     section has been allocated.  If the section has not been allocated
4224
     when this is evaluated, the linker will report an error. In the
4225
     following example, the alignment of the `.output' section is
4226
     stored as the first value in that section.
4227
          SECTIONS{ ...
4228
            .output {
4229
              LONG (ALIGNOF (.output))
4230
              ...
4231
              }
4232
          ... }
4233
 
4234
`BLOCK(EXP)'
4235
     This is a synonym for `ALIGN', for compatibility with older linker
4236
     scripts.  It is most often seen when setting the address of an
4237
     output section.
4238
 
4239
`DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE)'
4240
     This is equivalent to either
4241
          (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - 1)))
4242
     or
4243
          (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - COMMONPAGESIZE)))
4244
     depending on whether the latter uses fewer COMMONPAGESIZE sized
4245
     pages for the data segment (area between the result of this
4246
     expression and `DATA_SEGMENT_END') than the former or not.  If the
4247
     latter form is used, it means COMMONPAGESIZE bytes of runtime
4248
     memory will be saved at the expense of up to COMMONPAGESIZE wasted
4249
     bytes in the on-disk file.
4250
 
4251
     This expression can only be used directly in `SECTIONS' commands,
4252
     not in any output section descriptions and only once in the linker
4253
     script.  COMMONPAGESIZE should be less or equal to MAXPAGESIZE and
4254
     should be the system page size the object wants to be optimized
4255
     for (while still working on system page sizes up to MAXPAGESIZE).
4256
 
4257
     Example:
4258
            . = DATA_SEGMENT_ALIGN(0x10000, 0x2000);
4259
 
4260
`DATA_SEGMENT_END(EXP)'
4261
     This defines the end of data segment for `DATA_SEGMENT_ALIGN'
4262
     evaluation purposes.
4263
 
4264
            . = DATA_SEGMENT_END(.);
4265
 
4266
`DATA_SEGMENT_RELRO_END(OFFSET, EXP)'
4267
     This defines the end of the `PT_GNU_RELRO' segment when `-z relro'
4268
     option is used.  Second argument is returned.  When `-z relro'
4269
     option is not present, `DATA_SEGMENT_RELRO_END' does nothing,
4270
     otherwise `DATA_SEGMENT_ALIGN' is padded so that EXP + OFFSET is
4271
     aligned to the most commonly used page boundary for particular
4272
     target.  If present in the linker script, it must always come in
4273
     between `DATA_SEGMENT_ALIGN' and `DATA_SEGMENT_END'.
4274
 
4275
            . = DATA_SEGMENT_RELRO_END(24, .);
4276
 
4277
`DEFINED(SYMBOL)'
4278
     Return 1 if SYMBOL is in the linker global symbol table and is
4279
     defined before the statement using DEFINED in the script, otherwise
4280
     return 0.  You can use this function to provide default values for
4281
     symbols.  For example, the following script fragment shows how to
4282
     set a global symbol `begin' to the first location in the `.text'
4283
     section--but if a symbol called `begin' already existed, its value
4284
     is preserved:
4285
 
4286
          SECTIONS { ...
4287
            .text : {
4288
              begin = DEFINED(begin) ? begin : . ;
4289
              ...
4290
            }
4291
            ...
4292
          }
4293
 
4294
`LENGTH(MEMORY)'
4295
     Return the length of the memory region named MEMORY.
4296
 
4297
`LOADADDR(SECTION)'
4298
     Return the absolute LMA of the named SECTION.  This is normally
4299
     the same as `ADDR', but it may be different if the `AT' attribute
4300
     is used in the output section definition (*note Output Section
4301
     LMA::).
4302
 
4303
`MAX(EXP1, EXP2)'
4304
     Returns the maximum of EXP1 and EXP2.
4305
 
4306
`MIN(EXP1, EXP2)'
4307
     Returns the minimum of EXP1 and EXP2.
4308
 
4309
`NEXT(EXP)'
4310
     Return the next unallocated address that is a multiple of EXP.
4311
     This function is closely related to `ALIGN(EXP)'; unless you use
4312
     the `MEMORY' command to define discontinuous memory for the output
4313
     file, the two functions are equivalent.
4314
 
4315
`ORIGIN(MEMORY)'
4316
     Return the origin of the memory region named MEMORY.
4317
 
4318
`SEGMENT_START(SEGMENT, DEFAULT)'
4319
     Return the base address of the named SEGMENT.  If an explicit
4320
     value has been given for this segment (with a command-line `-T'
4321
     option) that value will be returned; otherwise the value will be
4322
     DEFAULT.  At present, the `-T' command-line option can only be
4323
     used to set the base address for the "text", "data", and "bss"
4324
     sections, but you use `SEGMENT_START' with any segment name.
4325
 
4326
`SIZEOF(SECTION)'
4327
     Return the size in bytes of the named SECTION, if that section has
4328
     been allocated.  If the section has not been allocated when this is
4329
     evaluated, the linker will report an error.  In the following
4330
     example, `symbol_1' and `symbol_2' are assigned identical values:
4331
          SECTIONS{ ...
4332
            .output {
4333
              .start = . ;
4334
              ...
4335
              .end = . ;
4336
              }
4337
            symbol_1 = .end - .start ;
4338
            symbol_2 = SIZEOF(.output);
4339
          ... }
4340
 
4341
`SIZEOF_HEADERS'
4342
`sizeof_headers'
4343
     Return the size in bytes of the output file's headers.  This is
4344
     information which appears at the start of the output file.  You
4345
     can use this number when setting the start address of the first
4346
     section, if you choose, to facilitate paging.
4347
 
4348
     When producing an ELF output file, if the linker script uses the
4349
     `SIZEOF_HEADERS' builtin function, the linker must compute the
4350
     number of program headers before it has determined all the section
4351
     addresses and sizes.  If the linker later discovers that it needs
4352
     additional program headers, it will report an error `not enough
4353
     room for program headers'.  To avoid this error, you must avoid
4354
     using the `SIZEOF_HEADERS' function, or you must rework your linker
4355
     script to avoid forcing the linker to use additional program
4356
     headers, or you must define the program headers yourself using the
4357
     `PHDRS' command (*note PHDRS::).
4358
 
4359

4360
File: ld.info,  Node: Implicit Linker Scripts,  Prev: Expressions,  Up: Scripts
4361
 
4362
3.11 Implicit Linker Scripts
4363
============================
4364
 
4365
If you specify a linker input file which the linker can not recognize as
4366
an object file or an archive file, it will try to read the file as a
4367
linker script.  If the file can not be parsed as a linker script, the
4368
linker will report an error.
4369
 
4370
   An implicit linker script will not replace the default linker script.
4371
 
4372
   Typically an implicit linker script would contain only symbol
4373
assignments, or the `INPUT', `GROUP', or `VERSION' commands.
4374
 
4375
   Any input files read because of an implicit linker script will be
4376
read at the position in the command line where the implicit linker
4377
script was read.  This can affect archive searching.
4378
 
4379

4380
File: ld.info,  Node: Machine Dependent,  Next: BFD,  Prev: Scripts,  Up: Top
4381
 
4382
4 Machine Dependent Features
4383
****************************
4384
 
4385
`ld' has additional features on some platforms; the following sections
4386
describe them.  Machines where `ld' has no additional functionality are
4387
not listed.
4388
 
4389
* Menu:
4390
 
4391
 
4392
* H8/300::                      `ld' and the H8/300
4393
 
4394
* i960::                        `ld' and the Intel 960 family
4395
 
4396
* ARM::                         `ld' and the ARM family
4397
 
4398
* HPPA ELF32::                  `ld' and HPPA 32-bit ELF
4399
 
4400
* MMIX::                        `ld' and MMIX
4401
 
4402
* MSP430::                      `ld' and MSP430
4403
 
4404
* M68HC11/68HC12::              `ld' and the Motorola 68HC11 and 68HC12 families
4405
 
4406
* PowerPC ELF32::               `ld' and PowerPC 32-bit ELF Support
4407
 
4408
* PowerPC64 ELF64::             `ld' and PowerPC64 64-bit ELF Support
4409
 
4410
* SPU ELF::                     `ld' and SPU ELF Support
4411
 
4412
* TI COFF::                     `ld' and TI COFF
4413
 
4414
* WIN32::                       `ld' and WIN32 (cygwin/mingw)
4415
 
4416
* Xtensa::                      `ld' and Xtensa Processors
4417
 
4418

4419
File: ld.info,  Node: H8/300,  Next: i960,  Up: Machine Dependent
4420
 
4421
4.1 `ld' and the H8/300
4422
=======================
4423
 
4424
For the H8/300, `ld' can perform these global optimizations when you
4425
specify the `--relax' command-line option.
4426
 
4427
_relaxing address modes_
4428
     `ld' finds all `jsr' and `jmp' instructions whose targets are
4429
     within eight bits, and turns them into eight-bit program-counter
4430
     relative `bsr' and `bra' instructions, respectively.
4431
 
4432
_synthesizing instructions_
4433
     `ld' finds all `mov.b' instructions which use the sixteen-bit
4434
     absolute address form, but refer to the top page of memory, and
4435
     changes them to use the eight-bit address form.  (That is: the
4436
     linker turns `mov.b `@'AA:16' into `mov.b `@'AA:8' whenever the
4437
     address AA is in the top page of memory).
4438
 
4439
_bit manipulation instructions_
4440
     `ld' finds all bit manipulation instructions like `band, bclr,
4441
     biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst,
4442
     bxor' which use 32 bit and 16 bit absolute address form, but refer
4443
     to the top page of memory, and changes them to use the 8 bit
4444
     address form.  (That is: the linker turns `bset #xx:3,`@'AA:32'
4445
     into `bset #xx:3,`@'AA:8' whenever the address AA is in the top
4446
     page of memory).
4447
 
4448
_system control instructions_
4449
     `ld' finds all `ldc.w, stc.w' instructions which use the 32 bit
4450
     absolute address form, but refer to the top page of memory, and
4451
     changes them to use 16 bit address form.  (That is: the linker
4452
     turns `ldc.w `@'AA:32,ccr' into `ldc.w `@'AA:16,ccr' whenever the
4453
     address AA is in the top page of memory).
4454
 
4455

4456
File: ld.info,  Node: i960,  Next: ARM,  Prev: H8/300,  Up: Machine Dependent
4457
 
4458
4.2 `ld' and the Intel 960 Family
4459
=================================
4460
 
4461
You can use the `-AARCHITECTURE' command line option to specify one of
4462
the two-letter names identifying members of the 960 family; the option
4463
specifies the desired output target, and warns of any incompatible
4464
instructions in the input files.  It also modifies the linker's search
4465
strategy for archive libraries, to support the use of libraries
4466
specific to each particular architecture, by including in the search
4467
loop names suffixed with the string identifying the architecture.
4468
 
4469
   For example, if your `ld' command line included `-ACA' as well as
4470
`-ltry', the linker would look (in its built-in search paths, and in
4471
any paths you specify with `-L') for a library with the names
4472
 
4473
     try
4474
     libtry.a
4475
     tryca
4476
     libtryca.a
4477
 
4478
The first two possibilities would be considered in any event; the last
4479
two are due to the use of `-ACA'.
4480
 
4481
   You can meaningfully use `-A' more than once on a command line, since
4482
the 960 architecture family allows combination of target architectures;
4483
each use will add another pair of name variants to search for when `-l'
4484
specifies a library.
4485
 
4486
   `ld' supports the `--relax' option for the i960 family.  If you
4487
specify `--relax', `ld' finds all `balx' and `calx' instructions whose
4488
targets are within 24 bits, and turns them into 24-bit program-counter
4489
relative `bal' and `cal' instructions, respectively.  `ld' also turns
4490
`cal' instructions into `bal' instructions when it determines that the
4491
target subroutine is a leaf routine (that is, the target subroutine does
4492
not itself call any subroutines).
4493
 
4494

4495
File: ld.info,  Node: M68HC11/68HC12,  Next: PowerPC ELF32,  Prev: MSP430,  Up: Machine Dependent
4496
 
4497
4.3 `ld' and the Motorola 68HC11 and 68HC12 families
4498
====================================================
4499
 
4500
4.3.1 Linker Relaxation
4501
-----------------------
4502
 
4503
For the Motorola 68HC11, `ld' can perform these global optimizations
4504
when you specify the `--relax' command-line option.
4505
 
4506
_relaxing address modes_
4507
     `ld' finds all `jsr' and `jmp' instructions whose targets are
4508
     within eight bits, and turns them into eight-bit program-counter
4509
     relative `bsr' and `bra' instructions, respectively.
4510
 
4511
     `ld' also looks at all 16-bit extended addressing modes and
4512
     transforms them in a direct addressing mode when the address is in
4513
     page 0 (between 0 and 0x0ff).
4514
 
4515
_relaxing gcc instruction group_
4516
     When `gcc' is called with `-mrelax', it can emit group of
4517
     instructions that the linker can optimize to use a 68HC11 direct
4518
     addressing mode. These instructions consists of `bclr' or `bset'
4519
     instructions.
4520
 
4521
 
4522
4.3.2 Trampoline Generation
4523
---------------------------
4524
 
4525
For 68HC11 and 68HC12, `ld' can generate trampoline code to call a far
4526
function using a normal `jsr' instruction. The linker will also change
4527
the relocation to some far function to use the trampoline address
4528
instead of the function address. This is typically the case when a
4529
pointer to a function is taken. The pointer will in fact point to the
4530
function trampoline.
4531
 
4532
   The `--pic-veneer' switch makes the linker use PIC sequences for
4533
ARM/Thumb interworking veneers, even if the rest of the binary is not
4534
PIC.  This avoids problems on uClinux targets where `--emit-relocs' is
4535
used to generate relocatable binaries.
4536
 
4537

4538
File: ld.info,  Node: ARM,  Next: HPPA ELF32,  Prev: i960,  Up: Machine Dependent
4539
 
4540
4.4 `ld' and the ARM family
4541
===========================
4542
 
4543
For the ARM, `ld' will generate code stubs to allow functions calls
4544
between ARM and Thumb code.  These stubs only work with code that has
4545
been compiled and assembled with the `-mthumb-interwork' command line
4546
option.  If it is necessary to link with old ARM object files or
4547
libraries, which have not been compiled with the -mthumb-interwork
4548
option then the `--support-old-code' command line switch should be
4549
given to the linker.  This will make it generate larger stub functions
4550
which will work with non-interworking aware ARM code.  Note, however,
4551
the linker does not support generating stubs for function calls to
4552
non-interworking aware Thumb code.
4553
 
4554
   The `--thumb-entry' switch is a duplicate of the generic `--entry'
4555
switch, in that it sets the program's starting address.  But it also
4556
sets the bottom bit of the address, so that it can be branched to using
4557
a BX instruction, and the program will start executing in Thumb mode
4558
straight away.
4559
 
4560
   The `--be8' switch instructs `ld' to generate BE8 format
4561
executables.  This option is only valid when linking big-endian objects.
4562
The resulting image will contain big-endian data and little-endian code.
4563
 
4564
   The `R_ARM_TARGET1' relocation is typically used for entries in the
4565
`.init_array' section.  It is interpreted as either `R_ARM_REL32' or
4566
`R_ARM_ABS32', depending on the target.  The `--target1-rel' and
4567
`--target1-abs' switches override the default.
4568
 
4569
   The `--target2=type' switch overrides the default definition of the
4570
`R_ARM_TARGET2' relocation.  Valid values for `type', their meanings,
4571
and target defaults are as follows:
4572
`rel'
4573
     `R_ARM_REL32' (arm*-*-elf, arm*-*-eabi)
4574
 
4575
`abs'
4576
     `R_ARM_ABS32' (arm*-*-symbianelf)
4577
 
4578
`got-rel'
4579
     `R_ARM_GOT_PREL' (arm*-*-linux, arm*-*-*bsd)
4580
 
4581
   The `R_ARM_V4BX' relocation (defined by the ARM AAELF specification)
4582
enables objects compiled for the ARMv4 architecture to be
4583
interworking-safe when linked with other objects compiled for ARMv4t,
4584
but also allows pure ARMv4 binaries to be built from the same ARMv4
4585
objects.
4586
 
4587
   In the latter case, the switch `--fix-v4bx' must be passed to the
4588
linker, which causes v4t `BX rM' instructions to be rewritten as `MOV
4589
PC,rM', since v4 processors do not have a `BX' instruction.
4590
 
4591
   In the former case, the switch should not be used, and `R_ARM_V4BX'
4592
relocations are ignored.
4593
 
4594
   Replace `BX rM' instructions identified by `R_ARM_V4BX' relocations
4595
with a branch to the following veneer:
4596
 
4597
     TST rM, #1
4598
     MOVEQ PC, rM
4599
     BX Rn
4600
 
4601
   This allows generation of libraries/applications that work on ARMv4
4602
cores and are still interworking safe.  Note that the above veneer
4603
clobbers the condition flags, so may cause incorrect progrm behavior in
4604
rare cases.
4605
 
4606
   The `--use-blx' switch enables the linker to use ARM/Thumb BLX
4607
instructions (available on ARMv5t and above) in various situations.
4608
Currently it is used to perform calls via the PLT from Thumb code using
4609
BLX rather than using BX and a mode-switching stub before each PLT
4610
entry. This should lead to such calls executing slightly faster.
4611
 
4612
   This option is enabled implicitly for SymbianOS, so there is no need
4613
to specify it if you are using that target.
4614
 
4615
   The `--vfp11-denorm-fix' switch enables a link-time workaround for a
4616
bug in certain VFP11 coprocessor hardware, which sometimes allows
4617
instructions with denorm operands (which must be handled by support
4618
code) to have those operands overwritten by subsequent instructions
4619
before the support code can read the intended values.
4620
 
4621
   The bug may be avoided in scalar mode if you allow at least one
4622
intervening instruction between a VFP11 instruction which uses a
4623
register and another instruction which writes to the same register, or
4624
at least two intervening instructions if vector mode is in use. The bug
4625
only affects full-compliance floating-point mode: you do not need this
4626
workaround if you are using "runfast" mode. Please contact ARM for
4627
further details.
4628
 
4629
   If you know you are using buggy VFP11 hardware, you can enable this
4630
workaround by specifying the linker option `--vfp-denorm-fix=scalar' if
4631
you are using the VFP11 scalar mode only, or `--vfp-denorm-fix=vector'
4632
if you are using vector mode (the latter also works for scalar code).
4633
The default is `--vfp-denorm-fix=none'.
4634
 
4635
   If the workaround is enabled, instructions are scanned for
4636
potentially-troublesome sequences, and a veneer is created for each
4637
such sequence which may trigger the erratum. The veneer consists of the
4638
first instruction of the sequence and a branch back to the subsequent
4639
instruction. The original instruction is then replaced with a branch to
4640
the veneer. The extra cycles required to call and return from the veneer
4641
are sufficient to avoid the erratum in both the scalar and vector cases.
4642
 
4643
   The `--no-enum-size-warning' switch prevents the linker from warning
4644
when linking object files that specify incompatible EABI enumeration
4645
size attributes.  For example, with this switch enabled, linking of an
4646
object file using 32-bit enumeration values with another using
4647
enumeration values fitted into the smallest possible space will not be
4648
diagnosed.
4649
 
4650

4651
File: ld.info,  Node: HPPA ELF32,  Next: MMIX,  Prev: ARM,  Up: Machine Dependent
4652
 
4653
4.5 `ld' and HPPA 32-bit ELF Support
4654
====================================
4655
 
4656
When generating a shared library, `ld' will by default generate import
4657
stubs suitable for use with a single sub-space application.  The
4658
`--multi-subspace' switch causes `ld' to generate export stubs, and
4659
different (larger) import stubs suitable for use with multiple
4660
sub-spaces.
4661
 
4662
   Long branch stubs and import/export stubs are placed by `ld' in stub
4663
sections located between groups of input sections.  `--stub-group-size'
4664
specifies the maximum size of a group of input sections handled by one
4665
stub section.  Since branch offsets are signed, a stub section may
4666
serve two groups of input sections, one group before the stub section,
4667
and one group after it.  However, when using conditional branches that
4668
require stubs, it may be better (for branch prediction) that stub
4669
sections only serve one group of input sections.  A negative value for
4670
`N' chooses this scheme, ensuring that branches to stubs always use a
4671
negative offset.  Two special values of `N' are recognized, `1' and
4672
`-1'.  These both instruct `ld' to automatically size input section
4673
groups for the branch types detected, with the same behaviour regarding
4674
stub placement as other positive or negative values of `N' respectively.
4675
 
4676
   Note that `--stub-group-size' does not split input sections.  A
4677
single input section larger than the group size specified will of course
4678
create a larger group (of one section).  If input sections are too
4679
large, it may not be possible for a branch to reach its stub.
4680
 
4681

4682
File: ld.info,  Node: MMIX,  Next: MSP430,  Prev: HPPA ELF32,  Up: Machine Dependent
4683
 
4684
4.6 `ld' and MMIX
4685
=================
4686
 
4687
For MMIX, there is a choice of generating `ELF' object files or `mmo'
4688
object files when linking.  The simulator `mmix' understands the `mmo'
4689
format.  The binutils `objcopy' utility can translate between the two
4690
formats.
4691
 
4692
   There is one special section, the `.MMIX.reg_contents' section.
4693
Contents in this section is assumed to correspond to that of global
4694
registers, and symbols referring to it are translated to special
4695
symbols, equal to registers.  In a final link, the start address of the
4696
`.MMIX.reg_contents' section corresponds to the first allocated global
4697
register multiplied by 8.  Register `$255' is not included in this
4698
section; it is always set to the program entry, which is at the symbol
4699
`Main' for `mmo' files.
4700
 
4701
   Symbols with the prefix `__.MMIX.start.', for example
4702
`__.MMIX.start..text' and `__.MMIX.start..data' are special; there must
4703
be only one each, even if they are local.  The default linker script
4704
uses these to set the default start address of a section.
4705
 
4706
   Initial and trailing multiples of zero-valued 32-bit words in a
4707
section, are left out from an mmo file.
4708
 
4709

4710
File: ld.info,  Node: MSP430,  Next: M68HC11/68HC12,  Prev: MMIX,  Up: Machine Dependent
4711
 
4712
4.7 `ld' and MSP430
4713
===================
4714
 
4715
For the MSP430 it is possible to select the MPU architecture.  The flag
4716
`-m [mpu type]' will select an appropriate linker script for selected
4717
MPU type.  (To get a list of known MPUs just pass `-m help' option to
4718
the linker).
4719
 
4720
   The linker will recognize some extra sections which are MSP430
4721
specific:
4722
 
4723
``.vectors''
4724
     Defines a portion of ROM where interrupt vectors located.
4725
 
4726
``.bootloader''
4727
     Defines the bootloader portion of the ROM (if applicable).  Any
4728
     code in this section will be uploaded to the MPU.
4729
 
4730
``.infomem''
4731
     Defines an information memory section (if applicable).  Any code in
4732
     this section will be uploaded to the MPU.
4733
 
4734
``.infomemnobits''
4735
     This is the same as the `.infomem' section except that any code in
4736
     this section will not be uploaded to the MPU.
4737
 
4738
``.noinit''
4739
     Denotes a portion of RAM located above `.bss' section.
4740
 
4741
     The last two sections are used by gcc.
4742
 
4743

4744
File: ld.info,  Node: PowerPC ELF32,  Next: PowerPC64 ELF64,  Prev: M68HC11/68HC12,  Up: Machine Dependent
4745
 
4746
4.8 `ld' and PowerPC 32-bit ELF Support
4747
=======================================
4748
 
4749
Branches on PowerPC processors are limited to a signed 26-bit
4750
displacement, which may result in `ld' giving `relocation truncated to
4751
fit' errors with very large programs.  `--relax' enables the generation
4752
of trampolines that can access the entire 32-bit address space.  These
4753
trampolines are inserted at section boundaries, so may not themselves
4754
be reachable if an input section exceeds 33M in size.
4755
 
4756
`--bss-plt'
4757
     Current PowerPC GCC accepts a `-msecure-plt' option that generates
4758
     code capable of using a newer PLT and GOT layout that has the
4759
     security advantage of no executable section ever needing to be
4760
     writable and no writable section ever being executable.  PowerPC
4761
     `ld' will generate this layout, including stubs to access the PLT,
4762
     if all input files (including startup and static libraries) were
4763
     compiled with `-msecure-plt'.  `--bss-plt' forces the old BSS PLT
4764
     (and GOT layout) which can give slightly better performance.
4765
 
4766
`--secure-plt'
4767
     `ld' will use the new PLT and GOT layout if it is linking new
4768
     `-fpic' or `-fPIC' code, but does not do so automatically when
4769
     linking non-PIC code.  This option requests the new PLT and GOT
4770
     layout.  A warning will be given if some object file requires the
4771
     old style BSS PLT.
4772
 
4773
`--sdata-got'
4774
     The new secure PLT and GOT are placed differently relative to other
4775
     sections compared to older BSS PLT and GOT placement.  The
4776
     location of `.plt' must change because the new secure PLT is an
4777
     initialized section while the old PLT is uninitialized.  The
4778
     reason for the `.got' change is more subtle:  The new placement
4779
     allows `.got' to be read-only in applications linked with `-z
4780
     relro -z now'.  However, this placement means that `.sdata' cannot
4781
     always be used in shared libraries, because the PowerPC ABI
4782
     accesses `.sdata' in shared libraries from the GOT pointer.
4783
     `--sdata-got' forces the old GOT placement.  PowerPC GCC doesn't
4784
     use `.sdata' in shared libraries, so this option is really only
4785
     useful for other compilers that may do so.
4786
 
4787
`--emit-stub-syms'
4788
     This option causes `ld' to label linker stubs with a local symbol
4789
     that encodes the stub type and destination.
4790
 
4791
`--no-tls-optimize'
4792
     PowerPC `ld' normally performs some optimization of code sequences
4793
     used to access Thread-Local Storage.  Use this option to disable
4794
     the optimization.
4795
 
4796

4797
File: ld.info,  Node: PowerPC64 ELF64,  Next: SPU ELF,  Prev: PowerPC ELF32,  Up: Machine Dependent
4798
 
4799
4.9 `ld' and PowerPC64 64-bit ELF Support
4800
=========================================
4801
 
4802
`--stub-group-size'
4803
     Long branch stubs, PLT call stubs  and TOC adjusting stubs are
4804
     placed by `ld' in stub sections located between groups of input
4805
     sections.  `--stub-group-size' specifies the maximum size of a
4806
     group of input sections handled by one stub section.  Since branch
4807
     offsets are signed, a stub section may serve two groups of input
4808
     sections, one group before the stub section, and one group after
4809
     it.  However, when using conditional branches that require stubs,
4810
     it may be better (for branch prediction) that stub sections only
4811
     serve one group of input sections.  A negative value for `N'
4812
     chooses this scheme, ensuring that branches to stubs always use a
4813
     negative offset.  Two special values of `N' are recognized, `1'
4814
     and `-1'.  These both instruct `ld' to automatically size input
4815
     section groups for the branch types detected, with the same
4816
     behaviour regarding stub placement as other positive or negative
4817
     values of `N' respectively.
4818
 
4819
     Note that `--stub-group-size' does not split input sections.  A
4820
     single input section larger than the group size specified will of
4821
     course create a larger group (of one section).  If input sections
4822
     are too large, it may not be possible for a branch to reach its
4823
     stub.
4824
 
4825
`--emit-stub-syms'
4826
     This option causes `ld' to label linker stubs with a local symbol
4827
     that encodes the stub type and destination.
4828
 
4829
`--dotsyms, --no-dotsyms'
4830
     These two options control how `ld' interprets version patterns in
4831
     a version script.  Older PowerPC64 compilers emitted both a
4832
     function descriptor symbol with the same name as the function, and
4833
     a code entry symbol with the name prefixed by a dot (`.').  To
4834
     properly version a function `foo', the version script thus needs
4835
     to control both `foo' and `.foo'.  The option `--dotsyms', on by
4836
     default, automatically adds the required dot-prefixed patterns.
4837
     Use `--no-dotsyms' to disable this feature.
4838
 
4839
`--no-tls-optimize'
4840
     PowerPC64 `ld' normally performs some optimization of code
4841
     sequences used to access Thread-Local Storage.  Use this option to
4842
     disable the optimization.
4843
 
4844
`--no-opd-optimize'
4845
     PowerPC64 `ld' normally removes `.opd' section entries
4846
     corresponding to deleted link-once functions, or functions removed
4847
     by the action of `--gc-sections' or linker scrip `/DISCARD/'.  Use
4848
     this option to disable `.opd' optimization.
4849
 
4850
`--non-overlapping-opd'
4851
     Some PowerPC64 compilers have an option to generate compressed
4852
     `.opd' entries spaced 16 bytes apart, overlapping the third word,
4853
     the static chain pointer (unused in C) with the first word of the
4854
     next entry.  This option expands such entries to the full 24 bytes.
4855
 
4856
`--no-toc-optimize'
4857
     PowerPC64 `ld' normally removes unused `.toc' section entries.
4858
     Such entries are detected by examining relocations that reference
4859
     the TOC in code sections.  A reloc in a deleted code section marks
4860
     a TOC word as unneeded, while a reloc in a kept code section marks
4861
     a TOC word as needed.  Since the TOC may reference itself, TOC
4862
     relocs are also examined.  TOC words marked as both needed and
4863
     unneeded will of course be kept.  TOC words without any referencing
4864
     reloc are assumed to be part of a multi-word entry, and are kept or
4865
     discarded as per the nearest marked preceding word.  This works
4866
     reliably for compiler generated code, but may be incorrect if
4867
     assembly code is used to insert TOC entries.  Use this option to
4868
     disable the optimization.
4869
 
4870
`--no-multi-toc'
4871
     By default, PowerPC64 GCC generates code for a TOC model where TOC
4872
     entries are accessed with a 16-bit offset from r2.  This limits the
4873
     total TOC size to 64K.  PowerPC64 `ld' extends this limit by
4874
     grouping code sections such that each group uses less than 64K for
4875
     its TOC entries, then inserts r2 adjusting stubs between
4876
     inter-group calls.  `ld' does not split apart input sections, so
4877
     cannot help if a single input file has a `.toc' section that
4878
     exceeds 64K, most likely from linking multiple files with `ld -r'.
4879
     Use this option to turn off this feature.
4880
 
4881

4882
File: ld.info,  Node: SPU ELF,  Next: TI COFF,  Prev: PowerPC64 ELF64,  Up: Machine Dependent
4883
 
4884
4.10 `ld' and SPU ELF Support
4885
=============================
4886
 
4887
`--plugin'
4888
     This option marks an executable as a PIC plugin module.
4889
 
4890
`--no-overlays'
4891
     Normally, `ld' recognizes calls to functions within overlay
4892
     regions, and redirects such calls to an overlay manager via a stub.
4893
     `ld' also provides a built-in overlay manager.  This option turns
4894
     off all this special overlay handling.
4895
 
4896
`--emit-stub-syms'
4897
     This option causes `ld' to label overlay stubs with a local symbol
4898
     that encodes the stub type and destination.
4899
 
4900
`--extra-overlay-stubs'
4901
     This option causes `ld' to add overlay call stubs on all function
4902
     calls out of overlay regions.  Normally stubs are not added on
4903
     calls to non-overlay regions.
4904
 
4905
`--local-store=lo:hi'
4906
     `ld' usually checks that a final executable for SPU fits in the
4907
     address range 0 to 256k.  This option may be used to change the
4908
     range.  Disable the check entirely with `--local-store=0:0'.
4909
 
4910
`--stack-analysis'
4911
     SPU local store space is limited.  Over-allocation of stack space
4912
     unnecessarily limits space available for code and data, while
4913
     under-allocation results in runtime failures.  If given this
4914
     option, `ld' will provide an estimate of maximum stack usage.
4915
     `ld' does this by examining symbols in code sections to determine
4916
     the extents of functions, and looking at function prologues for
4917
     stack adjusting instructions.  A call-graph is created by looking
4918
     for relocations on branch instructions.  The graph is then searched
4919
     for the maximum stack usage path.  Note that this analysis does not
4920
     find calls made via function pointers, and does not handle
4921
     recursion and other cycles in the call graph.  Stack usage may be
4922
     under-estimated if your code makes such calls.  Also, stack usage
4923
     for dynamic allocation, e.g. alloca, will not be detected.  If a
4924
     link map is requested, detailed information about each function's
4925
     stack usage and calls will be given.
4926
 
4927
`--emit-stack-syms'
4928
     This option, if given along with `--stack-analysis' will result in
4929
     `ld' emitting stack sizing symbols for each function.  These take
4930
     the form `__stack_' for global functions, and
4931
     `__stack__' for static functions.
4932
     `' is the section id in hex.  The value of such symbols is
4933
     the stack requirement for the corresponding function.  The symbol
4934
     size will be zero, type `STT_NOTYPE', binding `STB_LOCAL', and
4935
     section `SHN_ABS'.
4936
 
4937

4938
File: ld.info,  Node: TI COFF,  Next: WIN32,  Prev: SPU ELF,  Up: Machine Dependent
4939
 
4940
4.11 `ld''s Support for Various TI COFF Versions
4941
================================================
4942
 
4943
The `--format' switch allows selection of one of the various TI COFF
4944
versions.  The latest of this writing is 2; versions 0 and 1 are also
4945
supported.  The TI COFF versions also vary in header byte-order format;
4946
`ld' will read any version or byte order, but the output header format
4947
depends on the default specified by the specific target.
4948
 
4949

4950
File: ld.info,  Node: WIN32,  Next: Xtensa,  Prev: TI COFF,  Up: Machine Dependent
4951
 
4952
4.12 `ld' and WIN32 (cygwin/mingw)
4953
==================================
4954
 
4955
This section describes some of the win32 specific `ld' issues.  See
4956
*Note Command Line Options: Options. for detailed description of the
4957
command line options mentioned here.
4958
 
4959
_import libraries_
4960
     The standard Windows linker creates and uses so-called import
4961
     libraries, which contains information for linking to dll's.  They
4962
     are regular static archives and are handled as any other static
4963
     archive.  The cygwin and mingw ports of `ld' have specific support
4964
     for creating such libraries provided with the `--out-implib'
4965
     command line option.
4966
 
4967
_exporting DLL symbols_
4968
     The cygwin/mingw `ld' has several ways to export symbols for dll's.
4969
 
4970
    _using auto-export functionality_
4971
          By default `ld' exports symbols with the auto-export
4972
          functionality, which is controlled by the following command
4973
          line options:
4974
 
4975
             * -export-all-symbols   [This is the default]
4976
 
4977
             * -exclude-symbols
4978
 
4979
             * -exclude-libs
4980
 
4981
          If, however, `--export-all-symbols' is not given explicitly
4982
          on the command line, then the default auto-export behavior
4983
          will be _disabled_ if either of the following are true:
4984
 
4985
             * A DEF file is used.
4986
 
4987
             * Any symbol in any object file was marked with the
4988
               __declspec(dllexport) attribute.
4989
 
4990
    _using a DEF file_
4991
          Another way of exporting symbols is using a DEF file.  A DEF
4992
          file is an ASCII file containing definitions of symbols which
4993
          should be exported when a dll is created.  Usually it is
4994
          named `.def' and is added as any other object file
4995
          to the linker's command line.  The file's name must end in
4996
          `.def' or `.DEF'.
4997
 
4998
               gcc -o   .def
4999
 
5000
          Using a DEF file turns off the normal auto-export behavior,
5001
          unless the `--export-all-symbols' option is also used.
5002
 
5003
          Here is an example of a DEF file for a shared library called
5004
          `xyz.dll':
5005
 
5006
               LIBRARY "xyz.dll" BASE=0x20000000
5007
 
5008
               EXPORTS
5009
               foo
5010
               bar
5011
               _bar = bar
5012
               another_foo = abc.dll.afoo
5013
               var1 DATA
5014
 
5015
          This example defines a DLL with a non-default base address
5016
          and five symbols in the export table. The third exported
5017
          symbol `_bar' is an alias for the second. The fourth symbol,
5018
          `another_foo' is resolved by "forwarding" to another module
5019
          and treating it as an alias for `afoo' exported from the DLL
5020
          `abc.dll'. The final symbol `var1' is declared to be a data
5021
          object.
5022
 
5023
          The optional `LIBRARY ' command indicates the _internal_
5024
          name of the output DLL. If `' does not include a suffix,
5025
          the default library suffix, `.DLL' is appended.
5026
 
5027
          When the .DEF file is used to build an application, rather
5028
          than a library, the `NAME ' command should be used
5029
          instead of `LIBRARY'. If `' does not include a suffix,
5030
          the default executable suffix, `.EXE' is appended.
5031
 
5032
          With either `LIBRARY ' or `NAME ' the optional
5033
          specification `BASE = ' may be used to specify a
5034
          non-default base address for the image.
5035
 
5036
          If neither `LIBRARY ' nor  `NAME ' is specified,
5037
          or they specify an empty string, the internal name is the
5038
          same as the filename specified on the command line.
5039
 
5040
          The complete specification of an export symbol is:
5041
 
5042
               EXPORTS
5043
                 ( (  (  [ =  ] )
5044
                    | (  =  . ))
5045
                 [ @  ] [NONAME] [DATA] [CONSTANT] [PRIVATE] ) *
5046
 
5047
          Declares `' as an exported symbol from the DLL, or
5048
          declares `' as an exported alias for `'; or
5049
          declares `' as a "forward" alias for the symbol
5050
          `' in the DLL `'.  Optionally,
5051
          the symbol may be exported by the specified ordinal
5052
          `' alias.
5053
 
5054
          The optional keywords that follow the declaration indicate:
5055
 
5056
          `NONAME': Do not put the symbol name in the DLL's export
5057
          table.  It will still be exported by its ordinal alias
5058
          (either the value specified by the .def specification or,
5059
          otherwise, the value assigned by the linker). The symbol
5060
          name, however, does remain visible in the import library (if
5061
          any), unless `PRIVATE' is also specified.
5062
 
5063
          `DATA': The symbol is a variable or object, rather than a
5064
          function.  The import lib will export only an indirect
5065
          reference to `foo' as the symbol `_imp__foo' (ie, `foo' must
5066
          be resolved as `*_imp__foo').
5067
 
5068
          `CONSTANT': Like `DATA', but put the undecorated `foo' as
5069
          well as `_imp__foo' into the import library. Both refer to the
5070
          read-only import address table's pointer to the variable, not
5071
          to the variable itself. This can be dangerous. If the user
5072
          code fails to add the `dllimport' attribute and also fails to
5073
          explicitly add the extra indirection that the use of the
5074
          attribute enforces, the application will behave unexpectedly.
5075
 
5076
          `PRIVATE': Put the symbol in the DLL's export table, but do
5077
          not put it into the static import library used to resolve
5078
          imports at link time. The symbol can still be imported using
5079
          the `LoadLibrary/GetProcAddress' API at runtime or by by
5080
          using the GNU ld extension of linking directly to the DLL
5081
          without an import library.
5082
 
5083
          See ld/deffilep.y in the binutils sources for the full
5084
          specification of other DEF file statements
5085
 
5086
          While linking a shared dll, `ld' is able to create a DEF file
5087
          with the `--output-def ' command line option.
5088
 
5089
    _Using decorations_
5090
          Another way of marking symbols for export is to modify the
5091
          source code itself, so that when building the DLL each symbol
5092
          to be exported is declared as:
5093
 
5094
               __declspec(dllexport) int a_variable
5095
               __declspec(dllexport) void a_function(int with_args)
5096
 
5097
          All such symbols will be exported from the DLL.  If, however,
5098
          any of the object files in the DLL contain symbols decorated
5099
          in this way, then the normal auto-export behavior is
5100
          disabled, unless the `--export-all-symbols' option is also
5101
          used.
5102
 
5103
          Note that object files that wish to access these symbols must
5104
          _not_ decorate them with dllexport.  Instead, they should use
5105
          dllimport, instead:
5106
 
5107
               __declspec(dllimport) int a_variable
5108
               __declspec(dllimport) void a_function(int with_args)
5109
 
5110
          This complicates the structure of library header files,
5111
          because when included by the library itself the header must
5112
          declare the variables and functions as dllexport, but when
5113
          included by client code the header must declare them as
5114
          dllimport.  There are a number of idioms that are typically
5115
          used to do this; often client code can omit the __declspec()
5116
          declaration completely.  See `--enable-auto-import' and
5117
          `automatic data imports' for more information.
5118
 
5119
_automatic data imports_
5120
     The standard Windows dll format supports data imports from dlls
5121
     only by adding special decorations (dllimport/dllexport), which
5122
     let the compiler produce specific assembler instructions to deal
5123
     with this issue.  This increases the effort necessary to port
5124
     existing Un*x code to these platforms, especially for large c++
5125
     libraries and applications.  The auto-import feature, which was
5126
     initially provided by Paul Sokolovsky, allows one to omit the
5127
     decorations to achieve a behavior that conforms to that on
5128
     POSIX/Un*x platforms. This feature is enabled with the
5129
     `--enable-auto-import' command-line option, although it is enabled
5130
     by default on cygwin/mingw.  The `--enable-auto-import' option
5131
     itself now serves mainly to suppress any warnings that are
5132
     ordinarily emitted when linked objects trigger the feature's use.
5133
 
5134
     auto-import of variables does not always work flawlessly without
5135
     additional assistance.  Sometimes, you will see this message
5136
 
5137
     "variable '' can't be auto-imported. Please read the
5138
     documentation for ld's `--enable-auto-import' for details."
5139
 
5140
     The `--enable-auto-import' documentation explains why this error
5141
     occurs, and several methods that can be used to overcome this
5142
     difficulty.  One of these methods is the _runtime pseudo-relocs_
5143
     feature, described below.
5144
 
5145
     For complex variables imported from DLLs (such as structs or
5146
     classes), object files typically contain a base address for the
5147
     variable and an offset (_addend_) within the variable-to specify a
5148
     particular field or public member, for instance.  Unfortunately,
5149
     the runtime loader used in win32 environments is incapable of
5150
     fixing these references at runtime without the additional
5151
     information supplied by dllimport/dllexport decorations.  The
5152
     standard auto-import feature described above is unable to resolve
5153
     these references.
5154
 
5155
     The `--enable-runtime-pseudo-relocs' switch allows these
5156
     references to be resolved without error, while leaving the task of
5157
     adjusting the references themselves (with their non-zero addends)
5158
     to specialized code provided by the runtime environment.  Recent
5159
     versions of the cygwin and mingw environments and compilers
5160
     provide this runtime support; older versions do not.  However, the
5161
     support is only necessary on the developer's platform; the
5162
     compiled result will run without error on an older system.
5163
 
5164
     `--enable-runtime-pseudo-relocs' is not the default; it must be
5165
     explicitly enabled as needed.
5166
 
5167
_direct linking to a dll_
5168
     The cygwin/mingw ports of `ld' support the direct linking,
5169
     including data symbols, to a dll without the usage of any import
5170
     libraries.  This is much faster and uses much less memory than
5171
     does the traditional import library method, especially when
5172
     linking large libraries or applications.  When `ld' creates an
5173
     import lib, each function or variable exported from the dll is
5174
     stored in its own bfd, even though a single bfd could contain many
5175
     exports.  The overhead involved in storing, loading, and
5176
     processing so many bfd's is quite large, and explains the
5177
     tremendous time, memory, and storage needed to link against
5178
     particularly large or complex libraries when using import libs.
5179
 
5180
     Linking directly to a dll uses no extra command-line switches
5181
     other than `-L' and `-l', because `ld' already searches for a
5182
     number of names to match each library.  All that is needed from
5183
     the developer's perspective is an understanding of this search, in
5184
     order to force ld to select the dll instead of an import library.
5185
 
5186
     For instance, when ld is called with the argument `-lxxx' it will
5187
     attempt to find, in the first directory of its search path,
5188
 
5189
          libxxx.dll.a
5190
          xxx.dll.a
5191
          libxxx.a
5192
          xxx.lib
5193
          cygxxx.dll (*)
5194
          libxxx.dll
5195
          xxx.dll
5196
 
5197
     before moving on to the next directory in the search path.
5198
 
5199
     (*) Actually, this is not `cygxxx.dll' but in fact is
5200
     `xxx.dll', where `' is set by the `ld' option
5201
     `--dll-search-prefix='. In the case of cygwin, the
5202
     standard gcc spec file includes `--dll-search-prefix=cyg', so in
5203
     effect we actually search for `cygxxx.dll'.
5204
 
5205
     Other win32-based unix environments, such as mingw or pw32, may
5206
     use other `'es, although at present only cygwin makes use
5207
     of this feature.  It was originally intended to help avoid name
5208
     conflicts among dll's built for the various win32/un*x
5209
     environments, so that (for example) two versions of a zlib dll
5210
     could coexist on the same machine.
5211
 
5212
     The generic cygwin/mingw path layout uses a `bin' directory for
5213
     applications and dll's and a `lib' directory for the import
5214
     libraries (using cygwin nomenclature):
5215
 
5216
          bin/
5217
                cygxxx.dll
5218
          lib/
5219
                libxxx.dll.a   (in case of dll's)
5220
                libxxx.a       (in case of static archive)
5221
 
5222
     Linking directly to a dll without using the import library can be
5223
     done two ways:
5224
 
5225
     1. Use the dll directly by adding the `bin' path to the link line
5226
          gcc -Wl,-verbose  -o a.exe -L../bin/ -lxxx
5227
 
5228
     However, as the dll's often have version numbers appended to their
5229
     names (`cygncurses-5.dll') this will often fail, unless one
5230
     specifies `-L../bin -lncurses-5' to include the version.  Import
5231
     libs are generally not versioned, and do not have this difficulty.
5232
 
5233
     2. Create a symbolic link from the dll to a file in the `lib'
5234
     directory according to the above mentioned search pattern.  This
5235
     should be used to avoid unwanted changes in the tools needed for
5236
     making the app/dll.
5237
 
5238
          ln -s bin/cygxxx.dll lib/[cyg|lib|]xxx.dll[.a]
5239
 
5240
     Then you can link without any make environment changes.
5241
 
5242
          gcc -Wl,-verbose  -o a.exe -L../lib/ -lxxx
5243
 
5244
     This technique also avoids the version number problems, because
5245
     the following is perfectly legal
5246
 
5247
          bin/
5248
                cygxxx-5.dll
5249
          lib/
5250
                libxxx.dll.a -> ../bin/cygxxx-5.dll
5251
 
5252
     Linking directly to a dll without using an import lib will work
5253
     even when auto-import features are exercised, and even when
5254
     `--enable-runtime-pseudo-relocs' is used.
5255
 
5256
     Given the improvements in speed and memory usage, one might
5257
     justifiably wonder why import libraries are used at all.  There
5258
     are three reasons:
5259
 
5260
     1. Until recently, the link-directly-to-dll functionality did _not_
5261
     work with auto-imported data.
5262
 
5263
     2. Sometimes it is necessary to include pure static objects within
5264
     the import library (which otherwise contains only bfd's for
5265
     indirection symbols that point to the exports of a dll).  Again,
5266
     the import lib for the cygwin kernel makes use of this ability,
5267
     and it is not possible to do this without an import lib.
5268
 
5269
     3. Symbol aliases can only be resolved using an import lib.  This
5270
     is critical when linking against OS-supplied dll's (eg, the win32
5271
     API) in which symbols are usually exported as undecorated aliases
5272
     of their stdcall-decorated assembly names.
5273
 
5274
     So, import libs are not going away.  But the ability to replace
5275
     true import libs with a simple symbolic link to (or a copy of) a
5276
     dll, in many cases, is a useful addition to the suite of tools
5277
     binutils makes available to the win32 developer.  Given the
5278
     massive improvements in memory requirements during linking, storage
5279
     requirements, and linking speed, we expect that many developers
5280
     will soon begin to use this feature whenever possible.
5281
 
5282
_symbol aliasing_
5283
 
5284
    _adding additional names_
5285
          Sometimes, it is useful to export symbols with additional
5286
          names.  A symbol `foo' will be exported as `foo', but it can
5287
          also be exported as `_foo' by using special directives in the
5288
          DEF file when creating the dll.  This will affect also the
5289
          optional created import library.  Consider the following DEF
5290
          file:
5291
 
5292
               LIBRARY "xyz.dll" BASE=0x61000000
5293
 
5294
               EXPORTS
5295
               foo
5296
               _foo = foo
5297
 
5298
          The line `_foo = foo' maps the symbol `foo' to `_foo'.
5299
 
5300
          Another method for creating a symbol alias is to create it in
5301
          the source code using the "weak" attribute:
5302
 
5303
               void foo () { /* Do something.  */; }
5304
               void _foo () __attribute__ ((weak, alias ("foo")));
5305
 
5306
          See the gcc manual for more information about attributes and
5307
          weak symbols.
5308
 
5309
    _renaming symbols_
5310
          Sometimes it is useful to rename exports.  For instance, the
5311
          cygwin kernel does this regularly.  A symbol `_foo' can be
5312
          exported as `foo' but not as `_foo' by using special
5313
          directives in the DEF file. (This will also affect the import
5314
          library, if it is created).  In the following example:
5315
 
5316
               LIBRARY "xyz.dll" BASE=0x61000000
5317
 
5318
               EXPORTS
5319
               _foo = foo
5320
 
5321
          The line `_foo = foo' maps the exported symbol `foo' to
5322
          `_foo'.
5323
 
5324
     Note: using a DEF file disables the default auto-export behavior,
5325
     unless the `--export-all-symbols' command line option is used.
5326
     If, however, you are trying to rename symbols, then you should list
5327
     _all_ desired exports in the DEF file, including the symbols that
5328
     are not being renamed, and do _not_ use the `--export-all-symbols'
5329
     option.  If you list only the renamed symbols in the DEF file, and
5330
     use `--export-all-symbols' to handle the other symbols, then the
5331
     both the new names _and_ the original names for the renamed
5332
     symbols will be exported.  In effect, you'd be aliasing those
5333
     symbols, not renaming them, which is probably not what you wanted.
5334
 
5335
_weak externals_
5336
     The Windows object format, PE, specifies a form of weak symbols
5337
     called weak externals.  When a weak symbol is linked and the
5338
     symbol is not defined, the weak symbol becomes an alias for some
5339
     other symbol.  There are three variants of weak externals:
5340
        * Definition is searched for in objects and libraries,
5341
          historically called lazy externals.
5342
 
5343
        * Definition is searched for only in other objects, not in
5344
          libraries.  This form is not presently implemented.
5345
 
5346
        * No search; the symbol is an alias.  This form is not presently
5347
          implemented.
5348
     As a GNU extension, weak symbols that do not specify an alternate
5349
     symbol are supported.  If the symbol is undefined when linking,
5350
     the symbol uses a default value.
5351
 
5352

5353
File: ld.info,  Node: Xtensa,  Prev: WIN32,  Up: Machine Dependent
5354
 
5355
4.13 `ld' and Xtensa Processors
5356
===============================
5357
 
5358
The default `ld' behavior for Xtensa processors is to interpret
5359
`SECTIONS' commands so that lists of explicitly named sections in a
5360
specification with a wildcard file will be interleaved when necessary to
5361
keep literal pools within the range of PC-relative load offsets.  For
5362
example, with the command:
5363
 
5364
     SECTIONS
5365
     {
5366
       .text : {
5367
         *(.literal .text)
5368
       }
5369
     }
5370
 
5371
`ld' may interleave some of the `.literal' and `.text' sections from
5372
different object files to ensure that the literal pools are within the
5373
range of PC-relative load offsets.  A valid interleaving might place
5374
the `.literal' sections from an initial group of files followed by the
5375
`.text' sections of that group of files.  Then, the `.literal' sections
5376
from the rest of the files and the `.text' sections from the rest of
5377
the files would follow.
5378
 
5379
   Relaxation is enabled by default for the Xtensa version of `ld' and
5380
provides two important link-time optimizations.  The first optimization
5381
is to combine identical literal values to reduce code size.  A redundant
5382
literal will be removed and all the `L32R' instructions that use it
5383
will be changed to reference an identical literal, as long as the
5384
location of the replacement literal is within the offset range of all
5385
the `L32R' instructions.  The second optimization is to remove
5386
unnecessary overhead from assembler-generated "longcall" sequences of
5387
`L32R'/`CALLXN' when the target functions are within range of direct
5388
`CALLN' instructions.
5389
 
5390
   For each of these cases where an indirect call sequence can be
5391
optimized to a direct call, the linker will change the `CALLXN'
5392
instruction to a `CALLN' instruction, remove the `L32R' instruction,
5393
and remove the literal referenced by the `L32R' instruction if it is
5394
not used for anything else.  Removing the `L32R' instruction always
5395
reduces code size but can potentially hurt performance by changing the
5396
alignment of subsequent branch targets.  By default, the linker will
5397
always preserve alignments, either by switching some instructions
5398
between 24-bit encodings and the equivalent density instructions or by
5399
inserting a no-op in place of the `L32R' instruction that was removed.
5400
If code size is more important than performance, the `--size-opt'
5401
option can be used to prevent the linker from widening density
5402
instructions or inserting no-ops, except in a few cases where no-ops
5403
are required for correctness.
5404
 
5405
   The following Xtensa-specific command-line options can be used to
5406
control the linker:
5407
 
5408
`--no-relax'
5409
     Since the Xtensa version of `ld' enables the `--relax' option by
5410
     default, the `--no-relax' option is provided to disable relaxation.
5411
 
5412
`--size-opt'
5413
     When optimizing indirect calls to direct calls, optimize for code
5414
     size more than performance.  With this option, the linker will not
5415
     insert no-ops or widen density instructions to preserve branch
5416
     target alignment.  There may still be some cases where no-ops are
5417
     required to preserve the correctness of the code.
5418
 
5419

5420
File: ld.info,  Node: BFD,  Next: Reporting Bugs,  Prev: Machine Dependent,  Up: Top
5421
 
5422
5 BFD
5423
*****
5424
 
5425
The linker accesses object and archive files using the BFD libraries.
5426
These libraries allow the linker to use the same routines to operate on
5427
object files whatever the object file format.  A different object file
5428
format can be supported simply by creating a new BFD back end and adding
5429
it to the library.  To conserve runtime memory, however, the linker and
5430
associated tools are usually configured to support only a subset of the
5431
object file formats available.  You can use `objdump -i' (*note
5432
objdump: (binutils.info)objdump.) to list all the formats available for
5433
your configuration.
5434
 
5435
   As with most implementations, BFD is a compromise between several
5436
conflicting requirements. The major factor influencing BFD design was
5437
efficiency: any time used converting between formats is time which
5438
would not have been spent had BFD not been involved. This is partly
5439
offset by abstraction payback; since BFD simplifies applications and
5440
back ends, more time and care may be spent optimizing algorithms for a
5441
greater speed.
5442
 
5443
   One minor artifact of the BFD solution which you should bear in mind
5444
is the potential for information loss.  There are two places where
5445
useful information can be lost using the BFD mechanism: during
5446
conversion and during output. *Note BFD information loss::.
5447
 
5448
* Menu:
5449
 
5450
* BFD outline::                 How it works: an outline of BFD
5451
 
5452

5453
File: ld.info,  Node: BFD outline,  Up: BFD
5454
 
5455
5.1 How It Works: An Outline of BFD
5456
===================================
5457
 
5458
When an object file is opened, BFD subroutines automatically determine
5459
the format of the input object file.  They then build a descriptor in
5460
memory with pointers to routines that will be used to access elements of
5461
the object file's data structures.
5462
 
5463
   As different information from the object files is required, BFD
5464
reads from different sections of the file and processes them.  For
5465
example, a very common operation for the linker is processing symbol
5466
tables.  Each BFD back end provides a routine for converting between
5467
the object file's representation of symbols and an internal canonical
5468
format. When the linker asks for the symbol table of an object file, it
5469
calls through a memory pointer to the routine from the relevant BFD
5470
back end which reads and converts the table into a canonical form.  The
5471
linker then operates upon the canonical form. When the link is finished
5472
and the linker writes the output file's symbol table, another BFD back
5473
end routine is called to take the newly created symbol table and
5474
convert it into the chosen output format.
5475
 
5476
* Menu:
5477
 
5478
* BFD information loss::        Information Loss
5479
* Canonical format::            The BFD canonical object-file format
5480
 
5481

5482
File: ld.info,  Node: BFD information loss,  Next: Canonical format,  Up: BFD outline
5483
 
5484
5.1.1 Information Loss
5485
----------------------
5486
 
5487
_Information can be lost during output._ The output formats supported
5488
by BFD do not provide identical facilities, and information which can
5489
be described in one form has nowhere to go in another format. One
5490
example of this is alignment information in `b.out'. There is nowhere
5491
in an `a.out' format file to store alignment information on the
5492
contained data, so when a file is linked from `b.out' and an `a.out'
5493
image is produced, alignment information will not propagate to the
5494
output file. (The linker will still use the alignment information
5495
internally, so the link is performed correctly).
5496
 
5497
   Another example is COFF section names. COFF files may contain an
5498
unlimited number of sections, each one with a textual section name. If
5499
the target of the link is a format which does not have many sections
5500
(e.g., `a.out') or has sections without names (e.g., the Oasys format),
5501
the link cannot be done simply. You can circumvent this problem by
5502
describing the desired input-to-output section mapping with the linker
5503
command language.
5504
 
5505
   _Information can be lost during canonicalization._ The BFD internal
5506
canonical form of the external formats is not exhaustive; there are
5507
structures in input formats for which there is no direct representation
5508
internally.  This means that the BFD back ends cannot maintain all
5509
possible data richness through the transformation between external to
5510
internal and back to external formats.
5511
 
5512
   This limitation is only a problem when an application reads one
5513
format and writes another.  Each BFD back end is responsible for
5514
maintaining as much data as possible, and the internal BFD canonical
5515
form has structures which are opaque to the BFD core, and exported only
5516
to the back ends. When a file is read in one format, the canonical form
5517
is generated for BFD and the application. At the same time, the back
5518
end saves away any information which may otherwise be lost. If the data
5519
is then written back in the same format, the back end routine will be
5520
able to use the canonical form provided by the BFD core as well as the
5521
information it prepared earlier.  Since there is a great deal of
5522
commonality between back ends, there is no information lost when
5523
linking or copying big endian COFF to little endian COFF, or `a.out' to
5524
`b.out'.  When a mixture of formats is linked, the information is only
5525
lost from the files whose format differs from the destination.
5526
 
5527

5528
File: ld.info,  Node: Canonical format,  Prev: BFD information loss,  Up: BFD outline
5529
 
5530
5.1.2 The BFD canonical object-file format
5531
------------------------------------------
5532
 
5533
The greatest potential for loss of information occurs when there is the
5534
least overlap between the information provided by the source format,
5535
that stored by the canonical format, and that needed by the destination
5536
format. A brief description of the canonical form may help you
5537
understand which kinds of data you can count on preserving across
5538
conversions.
5539
 
5540
_files_
5541
     Information stored on a per-file basis includes target machine
5542
     architecture, particular implementation format type, a demand
5543
     pageable bit, and a write protected bit.  Information like Unix
5544
     magic numbers is not stored here--only the magic numbers' meaning,
5545
     so a `ZMAGIC' file would have both the demand pageable bit and the
5546
     write protected text bit set.  The byte order of the target is
5547
     stored on a per-file basis, so that big- and little-endian object
5548
     files may be used with one another.
5549
 
5550
_sections_
5551
     Each section in the input file contains the name of the section,
5552
     the section's original address in the object file, size and
5553
     alignment information, various flags, and pointers into other BFD
5554
     data structures.
5555
 
5556
_symbols_
5557
     Each symbol contains a pointer to the information for the object
5558
     file which originally defined it, its name, its value, and various
5559
     flag bits.  When a BFD back end reads in a symbol table, it
5560
     relocates all symbols to make them relative to the base of the
5561
     section where they were defined.  Doing this ensures that each
5562
     symbol points to its containing section.  Each symbol also has a
5563
     varying amount of hidden private data for the BFD back end.  Since
5564
     the symbol points to the original file, the private data format
5565
     for that symbol is accessible.  `ld' can operate on a collection
5566
     of symbols of wildly different formats without problems.
5567
 
5568
     Normal global and simple local symbols are maintained on output,
5569
     so an output file (no matter its format) will retain symbols
5570
     pointing to functions and to global, static, and common variables.
5571
     Some symbol information is not worth retaining; in `a.out', type
5572
     information is stored in the symbol table as long symbol names.
5573
     This information would be useless to most COFF debuggers; the
5574
     linker has command line switches to allow users to throw it away.
5575
 
5576
     There is one word of type information within the symbol, so if the
5577
     format supports symbol type information within symbols (for
5578
     example, COFF, IEEE, Oasys) and the type is simple enough to fit
5579
     within one word (nearly everything but aggregates), the
5580
     information will be preserved.
5581
 
5582
_relocation level_
5583
     Each canonical BFD relocation record contains a pointer to the
5584
     symbol to relocate to, the offset of the data to relocate, the
5585
     section the data is in, and a pointer to a relocation type
5586
     descriptor. Relocation is performed by passing messages through
5587
     the relocation type descriptor and the symbol pointer. Therefore,
5588
     relocations can be performed on output data using a relocation
5589
     method that is only available in one of the input formats. For
5590
     instance, Oasys provides a byte relocation format.  A relocation
5591
     record requesting this relocation type would point indirectly to a
5592
     routine to perform this, so the relocation may be performed on a
5593
     byte being written to a 68k COFF file, even though 68k COFF has no
5594
     such relocation type.
5595
 
5596
_line numbers_
5597
     Object formats can contain, for debugging purposes, some form of
5598
     mapping between symbols, source line numbers, and addresses in the
5599
     output file.  These addresses have to be relocated along with the
5600
     symbol information.  Each symbol with an associated list of line
5601
     number records points to the first record of the list.  The head
5602
     of a line number list consists of a pointer to the symbol, which
5603
     allows finding out the address of the function whose line number
5604
     is being described. The rest of the list is made up of pairs:
5605
     offsets into the section and line numbers. Any format which can
5606
     simply derive this information can pass it successfully between
5607
     formats (COFF, IEEE and Oasys).
5608
 
5609

5610
File: ld.info,  Node: Reporting Bugs,  Next: MRI,  Prev: BFD,  Up: Top
5611
 
5612
6 Reporting Bugs
5613
****************
5614
 
5615
Your bug reports play an essential role in making `ld' reliable.
5616
 
5617
   Reporting a bug may help you by bringing a solution to your problem,
5618
or it may not.  But in any case the principal function of a bug report
5619
is to help the entire community by making the next version of `ld' work
5620
better.  Bug reports are your contribution to the maintenance of `ld'.
5621
 
5622
   In order for a bug report to serve its purpose, you must include the
5623
information that enables us to fix the bug.
5624
 
5625
* Menu:
5626
 
5627
* Bug Criteria::                Have you found a bug?
5628
* Bug Reporting::               How to report bugs
5629
 
5630

5631
File: ld.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: Reporting Bugs
5632
 
5633
6.1 Have You Found a Bug?
5634
=========================
5635
 
5636
If you are not sure whether you have found a bug, here are some
5637
guidelines:
5638
 
5639
   * If the linker gets a fatal signal, for any input whatever, that is
5640
     a `ld' bug.  Reliable linkers never crash.
5641
 
5642
   * If `ld' produces an error message for valid input, that is a bug.
5643
 
5644
   * If `ld' does not produce an error message for invalid input, that
5645
     may be a bug.  In the general case, the linker can not verify that
5646
     object files are correct.
5647
 
5648
   * If you are an experienced user of linkers, your suggestions for
5649
     improvement of `ld' are welcome in any case.
5650
 
5651

5652
File: ld.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: Reporting Bugs
5653
 
5654
6.2 How to Report Bugs
5655
======================
5656
 
5657
A number of companies and individuals offer support for GNU products.
5658
If you obtained `ld' from a support organization, we recommend you
5659
contact that organization first.
5660
 
5661
   You can find contact information for many support companies and
5662
individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
5663
 
5664
   Otherwise, send bug reports for `ld' to
5665
`http://www.sourceware.org/bugzilla/'.
5666
 
5667
   The fundamental principle of reporting bugs usefully is this:
5668
*report all the facts*.  If you are not sure whether to state a fact or
5669
leave it out, state it!
5670
 
5671
   Often people omit facts because they think they know what causes the
5672
problem and assume that some details do not matter.  Thus, you might
5673
assume that the name of a symbol you use in an example does not matter.
5674
Well, probably it does not, but one cannot be sure.  Perhaps the bug
5675
is a stray memory reference which happens to fetch from the location
5676
where that name is stored in memory; perhaps, if the name were
5677
different, the contents of that location would fool the linker into
5678
doing the right thing despite the bug.  Play it safe and give a
5679
specific, complete example.  That is the easiest thing for you to do,
5680
and the most helpful.
5681
 
5682
   Keep in mind that the purpose of a bug report is to enable us to fix
5683
the bug if it is new to us.  Therefore, always write your bug reports
5684
on the assumption that the bug has not been reported previously.
5685
 
5686
   Sometimes people give a few sketchy facts and ask, "Does this ring a
5687
bell?"  This cannot help us fix a bug, so it is basically useless.  We
5688
respond by asking for enough details to enable us to investigate.  You
5689
might as well expedite matters by sending them to begin with.
5690
 
5691
   To enable us to fix the bug, you should include all these things:
5692
 
5693
   * The version of `ld'.  `ld' announces it if you start it with the
5694
     `--version' argument.
5695
 
5696
     Without this, we will not know whether there is any point in
5697
     looking for the bug in the current version of `ld'.
5698
 
5699
   * Any patches you may have applied to the `ld' source, including any
5700
     patches made to the `BFD' library.
5701
 
5702
   * The type of machine you are using, and the operating system name
5703
     and version number.
5704
 
5705
   * What compiler (and its version) was used to compile `ld'--e.g.
5706
     "`gcc-2.7'".
5707
 
5708
   * The command arguments you gave the linker to link your example and
5709
     observe the bug.  To guarantee you will not omit something
5710
     important, list them all.  A copy of the Makefile (or the output
5711
     from make) is sufficient.
5712
 
5713
     If we were to try to guess the arguments, we would probably guess
5714
     wrong and then we might not encounter the bug.
5715
 
5716
   * A complete input file, or set of input files, that will reproduce
5717
     the bug.  It is generally most helpful to send the actual object
5718
     files provided that they are reasonably small.  Say no more than
5719
     10K.  For bigger files you can either make them available by FTP
5720
     or HTTP or else state that you are willing to send the object
5721
     file(s) to whomever requests them.  (Note - your email will be
5722
     going to a mailing list, so we do not want to clog it up with
5723
     large attachments).  But small attachments are best.
5724
 
5725
     If the source files were assembled using `gas' or compiled using
5726
     `gcc', then it may be OK to send the source files rather than the
5727
     object files.  In this case, be sure to say exactly what version of
5728
     `gas' or `gcc' was used to produce the object files.  Also say how
5729
     `gas' or `gcc' were configured.
5730
 
5731
   * A description of what behavior you observe that you believe is
5732
     incorrect.  For example, "It gets a fatal signal."
5733
 
5734
     Of course, if the bug is that `ld' gets a fatal signal, then we
5735
     will certainly notice it.  But if the bug is incorrect output, we
5736
     might not notice unless it is glaringly wrong.  You might as well
5737
     not give us a chance to make a mistake.
5738
 
5739
     Even if the problem you experience is a fatal signal, you should
5740
     still say so explicitly.  Suppose something strange is going on,
5741
     such as, your copy of `ld' is out of sync, or you have encountered
5742
     a bug in the C library on your system.  (This has happened!)  Your
5743
     copy might crash and ours would not.  If you told us to expect a
5744
     crash, then when ours fails to crash, we would know that the bug
5745
     was not happening for us.  If you had not told us to expect a
5746
     crash, then we would not be able to draw any conclusion from our
5747
     observations.
5748
 
5749
   * If you wish to suggest changes to the `ld' source, send us context
5750
     diffs, as generated by `diff' with the `-u', `-c', or `-p' option.
5751
     Always send diffs from the old file to the new file.  If you even
5752
     discuss something in the `ld' source, refer to it by context, not
5753
     by line number.
5754
 
5755
     The line numbers in our development sources will not match those
5756
     in your sources.  Your line numbers would convey no useful
5757
     information to us.
5758
 
5759
   Here are some things that are not necessary:
5760
 
5761
   * A description of the envelope of the bug.
5762
 
5763
     Often people who encounter a bug spend a lot of time investigating
5764
     which changes to the input file will make the bug go away and which
5765
     changes will not affect it.
5766
 
5767
     This is often time consuming and not very useful, because the way
5768
     we will find the bug is by running a single example under the
5769
     debugger with breakpoints, not by pure deduction from a series of
5770
     examples.  We recommend that you save your time for something else.
5771
 
5772
     Of course, if you can find a simpler example to report _instead_
5773
     of the original one, that is a convenience for us.  Errors in the
5774
     output will be easier to spot, running under the debugger will take
5775
     less time, and so on.
5776
 
5777
     However, simplification is not vital; if you do not want to do
5778
     this, report the bug anyway and send us the entire test case you
5779
     used.
5780
 
5781
   * A patch for the bug.
5782
 
5783
     A patch for the bug does help us if it is a good one.  But do not
5784
     omit the necessary information, such as the test case, on the
5785
     assumption that a patch is all we need.  We might see problems
5786
     with your patch and decide to fix the problem another way, or we
5787
     might not understand it at all.
5788
 
5789
     Sometimes with a program as complicated as `ld' it is very hard to
5790
     construct an example that will make the program follow a certain
5791
     path through the code.  If you do not send us the example, we will
5792
     not be able to construct one, so we will not be able to verify
5793
     that the bug is fixed.
5794
 
5795
     And if we cannot understand what bug you are trying to fix, or why
5796
     your patch should be an improvement, we will not install it.  A
5797
     test case will help us to understand.
5798
 
5799
   * A guess about what the bug is or what it depends on.
5800
 
5801
     Such guesses are usually wrong.  Even we cannot guess right about
5802
     such things without first using the debugger to find the facts.
5803
 
5804

5805
File: ld.info,  Node: MRI,  Next: GNU Free Documentation License,  Prev: Reporting Bugs,  Up: Top
5806
 
5807
Appendix A MRI Compatible Script Files
5808
**************************************
5809
 
5810
To aid users making the transition to GNU `ld' from the MRI linker,
5811
`ld' can use MRI compatible linker scripts as an alternative to the
5812
more general-purpose linker scripting language described in *Note
5813
Scripts::.  MRI compatible linker scripts have a much simpler command
5814
set than the scripting language otherwise used with `ld'.  GNU `ld'
5815
supports the most commonly used MRI linker commands; these commands are
5816
described here.
5817
 
5818
   In general, MRI scripts aren't of much use with the `a.out' object
5819
file format, since it only has three sections and MRI scripts lack some
5820
features to make use of them.
5821
 
5822
   You can specify a file containing an MRI-compatible script using the
5823
`-c' command-line option.
5824
 
5825
   Each command in an MRI-compatible script occupies its own line; each
5826
command line starts with the keyword that identifies the command (though
5827
blank lines are also allowed for punctuation).  If a line of an
5828
MRI-compatible script begins with an unrecognized keyword, `ld' issues
5829
a warning message, but continues processing the script.
5830
 
5831
   Lines beginning with `*' are comments.
5832
 
5833
   You can write these commands using all upper-case letters, or all
5834
lower case; for example, `chip' is the same as `CHIP'.  The following
5835
list shows only the upper-case form of each command.
5836
 
5837
`ABSOLUTE SECNAME'
5838
`ABSOLUTE SECNAME, SECNAME, ... SECNAME'
5839
     Normally, `ld' includes in the output file all sections from all
5840
     the input files.  However, in an MRI-compatible script, you can
5841
     use the `ABSOLUTE' command to restrict the sections that will be
5842
     present in your output program.  If the `ABSOLUTE' command is used
5843
     at all in a script, then only the sections named explicitly in
5844
     `ABSOLUTE' commands will appear in the linker output.  You can
5845
     still use other input sections (whatever you select on the command
5846
     line, or using `LOAD') to resolve addresses in the output file.
5847
 
5848
`ALIAS OUT-SECNAME, IN-SECNAME'
5849
     Use this command to place the data from input section IN-SECNAME
5850
     in a section called OUT-SECNAME in the linker output file.
5851
 
5852
     IN-SECNAME may be an integer.
5853
 
5854
`ALIGN SECNAME = EXPRESSION'
5855
     Align the section called SECNAME to EXPRESSION.  The EXPRESSION
5856
     should be a power of two.
5857
 
5858
`BASE EXPRESSION'
5859
     Use the value of EXPRESSION as the lowest address (other than
5860
     absolute addresses) in the output file.
5861
 
5862
`CHIP EXPRESSION'
5863
`CHIP EXPRESSION, EXPRESSION'
5864
     This command does nothing; it is accepted only for compatibility.
5865
 
5866
`END'
5867
     This command does nothing whatever; it's only accepted for
5868
     compatibility.
5869
 
5870
`FORMAT OUTPUT-FORMAT'
5871
     Similar to the `OUTPUT_FORMAT' command in the more general linker
5872
     language, but restricted to one of these output formats:
5873
 
5874
       1. S-records, if OUTPUT-FORMAT is `S'
5875
 
5876
       2. IEEE, if OUTPUT-FORMAT is `IEEE'
5877
 
5878
       3. COFF (the `coff-m68k' variant in BFD), if OUTPUT-FORMAT is
5879
          `COFF'
5880
 
5881
`LIST ANYTHING...'
5882
     Print (to the standard output file) a link map, as produced by the
5883
     `ld' command-line option `-M'.
5884
 
5885
     The keyword `LIST' may be followed by anything on the same line,
5886
     with no change in its effect.
5887
 
5888
`LOAD FILENAME'
5889
`LOAD FILENAME, FILENAME, ... FILENAME'
5890
     Include one or more object file FILENAME in the link; this has the
5891
     same effect as specifying FILENAME directly on the `ld' command
5892
     line.
5893
 
5894
`NAME OUTPUT-NAME'
5895
     OUTPUT-NAME is the name for the program produced by `ld'; the
5896
     MRI-compatible command `NAME' is equivalent to the command-line
5897
     option `-o' or the general script language command `OUTPUT'.
5898
 
5899
`ORDER SECNAME, SECNAME, ... SECNAME'
5900
`ORDER SECNAME SECNAME SECNAME'
5901
     Normally, `ld' orders the sections in its output file in the order
5902
     in which they first appear in the input files.  In an
5903
     MRI-compatible script, you can override this ordering with the
5904
     `ORDER' command.  The sections you list with `ORDER' will appear
5905
     first in your output file, in the order specified.
5906
 
5907
`PUBLIC NAME=EXPRESSION'
5908
`PUBLIC NAME,EXPRESSION'
5909
`PUBLIC NAME EXPRESSION'
5910
     Supply a value (EXPRESSION) for external symbol NAME used in the
5911
     linker input files.
5912
 
5913
`SECT SECNAME, EXPRESSION'
5914
`SECT SECNAME=EXPRESSION'
5915
`SECT SECNAME EXPRESSION'
5916
     You can use any of these three forms of the `SECT' command to
5917
     specify the start address (EXPRESSION) for section SECNAME.  If
5918
     you have more than one `SECT' statement for the same SECNAME, only
5919
     the _first_ sets the start address.
5920
 
5921

5922
File: ld.info,  Node: GNU Free Documentation License,  Next: LD Index,  Prev: MRI,  Up: Top
5923
 
5924
Appendix B GNU Free Documentation License
5925
*****************************************
5926
 
5927
                        Version 1.1, March 2000
5928
 
5929
     Copyright (C) 2000, 2003 Free Software Foundation, Inc.
5930
     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
5931
 
5932
     Everyone is permitted to copy and distribute verbatim copies
5933
     of this license document, but changing it is not allowed.
5934
 
5935
 
5936
  0. PREAMBLE
5937
 
5938
     The purpose of this License is to make a manual, textbook, or other
5939
     written document "free" in the sense of freedom: to assure everyone
5940
     the effective freedom to copy and redistribute it, with or without
5941
     modifying it, either commercially or noncommercially.  Secondarily,
5942
     this License preserves for the author and publisher a way to get
5943
     credit for their work, while not being considered responsible for
5944
     modifications made by others.
5945
 
5946
     This License is a kind of "copyleft", which means that derivative
5947
     works of the document must themselves be free in the same sense.
5948
     It complements the GNU General Public License, which is a copyleft
5949
     license designed for free software.
5950
 
5951
     We have designed this License in order to use it for manuals for
5952
     free software, because free software needs free documentation: a
5953
     free program should come with manuals providing the same freedoms
5954
     that the software does.  But this License is not limited to
5955
     software manuals; it can be used for any textual work, regardless
5956
     of subject matter or whether it is published as a printed book.
5957
     We recommend this License principally for works whose purpose is
5958
     instruction or reference.
5959
 
5960
 
5961
  1. APPLICABILITY AND DEFINITIONS
5962
 
5963
     This License applies to any manual or other work that contains a
5964
     notice placed by the copyright holder saying it can be distributed
5965
     under the terms of this License.  The "Document", below, refers to
5966
     any such manual or work.  Any member of the public is a licensee,
5967
     and is addressed as "you."
5968
 
5969
     A "Modified Version" of the Document means any work containing the
5970
     Document or a portion of it, either copied verbatim, or with
5971
     modifications and/or translated into another language.
5972
 
5973
     A "Secondary Section" is a named appendix or a front-matter
5974
     section of the Document that deals exclusively with the
5975
     relationship of the publishers or authors of the Document to the
5976
     Document's overall subject (or to related matters) and contains
5977
     nothing that could fall directly within that overall subject.
5978
     (For example, if the Document is in part a textbook of
5979
     mathematics, a Secondary Section may not explain any mathematics.)
5980
     The relationship could be a matter of historical connection with
5981
     the subject or with related matters, or of legal, commercial,
5982
     philosophical, ethical or political position regarding them.
5983
 
5984
     The "Invariant Sections" are certain Secondary Sections whose
5985
     titles are designated, as being those of Invariant Sections, in
5986
     the notice that says that the Document is released under this
5987
     License.
5988
 
5989
     The "Cover Texts" are certain short passages of text that are
5990
     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
5991
     that says that the Document is released under this License.
5992
 
5993
     A "Transparent" copy of the Document means a machine-readable copy,
5994
     represented in a format whose specification is available to the
5995
     general public, whose contents can be viewed and edited directly
5996
     and straightforwardly with generic text editors or (for images
5997
     composed of pixels) generic paint programs or (for drawings) some
5998
     widely available drawing editor, and that is suitable for input to
5999
     text formatters or for automatic translation to a variety of
6000
     formats suitable for input to text formatters.  A copy made in an
6001
     otherwise Transparent file format whose markup has been designed
6002
     to thwart or discourage subsequent modification by readers is not
6003
     Transparent.  A copy that is not "Transparent" is called "Opaque."
6004
 
6005
     Examples of suitable formats for Transparent copies include plain
6006
     ASCII without markup, Texinfo input format, LaTeX input format,
6007
     SGML or XML using a publicly available DTD, and
6008
     standard-conforming simple HTML designed for human modification.
6009
     Opaque formats include PostScript, PDF, proprietary formats that
6010
     can be read and edited only by proprietary word processors, SGML
6011
     or XML for which the DTD and/or processing tools are not generally
6012
     available, and the machine-generated HTML produced by some word
6013
     processors for output purposes only.
6014
 
6015
     The "Title Page" means, for a printed book, the title page itself,
6016
     plus such following pages as are needed to hold, legibly, the
6017
     material this License requires to appear in the title page.  For
6018
     works in formats which do not have any title page as such, "Title
6019
     Page" means the text near the most prominent appearance of the
6020
     work's title, preceding the beginning of the body of the text.
6021
 
6022
  2. VERBATIM COPYING
6023
 
6024
     You may copy and distribute the Document in any medium, either
6025
     commercially or noncommercially, provided that this License, the
6026
     copyright notices, and the license notice saying this License
6027
     applies to the Document are reproduced in all copies, and that you
6028
     add no other conditions whatsoever to those of this License.  You
6029
     may not use technical measures to obstruct or control the reading
6030
     or further copying of the copies you make or distribute.  However,
6031
     you may accept compensation in exchange for copies.  If you
6032
     distribute a large enough number of copies you must also follow
6033
     the conditions in section 3.
6034
 
6035
     You may also lend copies, under the same conditions stated above,
6036
     and you may publicly display copies.
6037
 
6038
  3. COPYING IN QUANTITY
6039
 
6040
     If you publish printed copies of the Document numbering more than
6041
     100, and the Document's license notice requires Cover Texts, you
6042
     must enclose the copies in covers that carry, clearly and legibly,
6043
     all these Cover Texts: Front-Cover Texts on the front cover, and
6044
     Back-Cover Texts on the back cover.  Both covers must also clearly
6045
     and legibly identify you as the publisher of these copies.  The
6046
     front cover must present the full title with all words of the
6047
     title equally prominent and visible.  You may add other material
6048
     on the covers in addition.  Copying with changes limited to the
6049
     covers, as long as they preserve the title of the Document and
6050
     satisfy these conditions, can be treated as verbatim copying in
6051
     other respects.
6052
 
6053
     If the required texts for either cover are too voluminous to fit
6054
     legibly, you should put the first ones listed (as many as fit
6055
     reasonably) on the actual cover, and continue the rest onto
6056
     adjacent pages.
6057
 
6058
     If you publish or distribute Opaque copies of the Document
6059
     numbering more than 100, you must either include a
6060
     machine-readable Transparent copy along with each Opaque copy, or
6061
     state in or with each Opaque copy a publicly-accessible
6062
     computer-network location containing a complete Transparent copy
6063
     of the Document, free of added material, which the general
6064
     network-using public has access to download anonymously at no
6065
     charge using public-standard network protocols.  If you use the
6066
     latter option, you must take reasonably prudent steps, when you
6067
     begin distribution of Opaque copies in quantity, to ensure that
6068
     this Transparent copy will remain thus accessible at the stated
6069
     location until at least one year after the last time you
6070
     distribute an Opaque copy (directly or through your agents or
6071
     retailers) of that edition to the public.
6072
 
6073
     It is requested, but not required, that you contact the authors of
6074
     the Document well before redistributing any large number of
6075
     copies, to give them a chance to provide you with an updated
6076
     version of the Document.
6077
 
6078
  4. MODIFICATIONS
6079
 
6080
     You may copy and distribute a Modified Version of the Document
6081
     under the conditions of sections 2 and 3 above, provided that you
6082
     release the Modified Version under precisely this License, with
6083
     the Modified Version filling the role of the Document, thus
6084
     licensing distribution and modification of the Modified Version to
6085
     whoever possesses a copy of it.  In addition, you must do these
6086
     things in the Modified Version:
6087
 
6088
     A. Use in the Title Page (and on the covers, if any) a title
6089
     distinct    from that of the Document, and from those of previous
6090
     versions    (which should, if there were any, be listed in the
6091
     History section    of the Document).  You may use the same title
6092
     as a previous version    if the original publisher of that version
6093
     gives permission.
6094
     B. List on the Title Page, as authors, one or more persons or
6095
     entities    responsible for authorship of the modifications in the
6096
     Modified    Version, together with at least five of the principal
6097
     authors of the    Document (all of its principal authors, if it
6098
     has less than five).
6099
     C. State on the Title page the name of the publisher of the
6100
     Modified Version, as the publisher.
6101
     D. Preserve all the copyright notices of the Document.
6102
     E. Add an appropriate copyright notice for your modifications
6103
     adjacent to the other copyright notices.
6104
     F. Include, immediately after the copyright notices, a license
6105
     notice    giving the public permission to use the Modified Version
6106
     under the    terms of this License, in the form shown in the
6107
     Addendum below.
6108
     G. Preserve in that license notice the full lists of Invariant
6109
     Sections    and required Cover Texts given in the Document's
6110
     license notice.
6111
     H. Include an unaltered copy of this License.
6112
     I. Preserve the section entitled "History", and its title, and add
6113
     to    it an item stating at least the title, year, new authors, and
6114
       publisher of the Modified Version as given on the Title Page.
6115
     If    there is no section entitled "History" in the Document,
6116
     create one    stating the title, year, authors, and publisher of
6117
     the Document as    given on its Title Page, then add an item
6118
     describing the Modified    Version as stated in the previous
6119
     sentence.
6120
     J. Preserve the network location, if any, given in the Document for
6121
       public access to a Transparent copy of the Document, and
6122
     likewise    the network locations given in the Document for
6123
     previous versions    it was based on.  These may be placed in the
6124
     "History" section.     You may omit a network location for a work
6125
     that was published at    least four years before the Document
6126
     itself, or if the original    publisher of the version it refers
6127
     to gives permission.
6128
     K. In any section entitled "Acknowledgements" or "Dedications",
6129
     preserve the section's title, and preserve in the section all the
6130
      substance and tone of each of the contributor acknowledgements
6131
     and/or dedications given therein.
6132
     L. Preserve all the Invariant Sections of the Document,
6133
     unaltered in their text and in their titles.  Section numbers
6134
     or the equivalent are not considered part of the section titles.
6135
     M. Delete any section entitled "Endorsements."  Such a section
6136
     may not be included in the Modified Version.
6137
     N. Do not retitle any existing section as "Endorsements"    or to
6138
     conflict in title with any Invariant Section.
6139
 
6140
     If the Modified Version includes new front-matter sections or
6141
     appendices that qualify as Secondary Sections and contain no
6142
     material copied from the Document, you may at your option
6143
     designate some or all of these sections as invariant.  To do this,
6144
     add their titles to the list of Invariant Sections in the Modified
6145
     Version's license notice.  These titles must be distinct from any
6146
     other section titles.
6147
 
6148
     You may add a section entitled "Endorsements", provided it contains
6149
     nothing but endorsements of your Modified Version by various
6150
     parties-for example, statements of peer review or that the text has
6151
     been approved by an organization as the authoritative definition
6152
     of a standard.
6153
 
6154
     You may add a passage of up to five words as a Front-Cover Text,
6155
     and a passage of up to 25 words as a Back-Cover Text, to the end
6156
     of the list of Cover Texts in the Modified Version.  Only one
6157
     passage of Front-Cover Text and one of Back-Cover Text may be
6158
     added by (or through arrangements made by) any one entity.  If the
6159
     Document already includes a cover text for the same cover,
6160
     previously added by you or by arrangement made by the same entity
6161
     you are acting on behalf of, you may not add another; but you may
6162
     replace the old one, on explicit permission from the previous
6163
     publisher that added the old one.
6164
 
6165
     The author(s) and publisher(s) of the Document do not by this
6166
     License give permission to use their names for publicity for or to
6167
     assert or imply endorsement of any Modified Version.
6168
 
6169
  5. COMBINING DOCUMENTS
6170
 
6171
     You may combine the Document with other documents released under
6172
     this License, under the terms defined in section 4 above for
6173
     modified versions, provided that you include in the combination
6174
     all of the Invariant Sections of all of the original documents,
6175
     unmodified, and list them all as Invariant Sections of your
6176
     combined work in its license notice.
6177
 
6178
     The combined work need only contain one copy of this License, and
6179
     multiple identical Invariant Sections may be replaced with a single
6180
     copy.  If there are multiple Invariant Sections with the same name
6181
     but different contents, make the title of each such section unique
6182
     by adding at the end of it, in parentheses, the name of the
6183
     original author or publisher of that section if known, or else a
6184
     unique number.  Make the same adjustment to the section titles in
6185
     the list of Invariant Sections in the license notice of the
6186
     combined work.
6187
 
6188
     In the combination, you must combine any sections entitled
6189
     "History" in the various original documents, forming one section
6190
     entitled "History"; likewise combine any sections entitled
6191
     "Acknowledgements", and any sections entitled "Dedications."  You
6192
     must delete all sections entitled "Endorsements."
6193
 
6194
  6. COLLECTIONS OF DOCUMENTS
6195
 
6196
     You may make a collection consisting of the Document and other
6197
     documents released under this License, and replace the individual
6198
     copies of this License in the various documents with a single copy
6199
     that is included in the collection, provided that you follow the
6200
     rules of this License for verbatim copying of each of the
6201
     documents in all other respects.
6202
 
6203
     You may extract a single document from such a collection, and
6204
     distribute it individually under this License, provided you insert
6205
     a copy of this License into the extracted document, and follow
6206
     this License in all other respects regarding verbatim copying of
6207
     that document.
6208
 
6209
  7. AGGREGATION WITH INDEPENDENT WORKS
6210
 
6211
     A compilation of the Document or its derivatives with other
6212
     separate and independent documents or works, in or on a volume of
6213
     a storage or distribution medium, does not as a whole count as a
6214
     Modified Version of the Document, provided no compilation
6215
     copyright is claimed for the compilation.  Such a compilation is
6216
     called an "aggregate", and this License does not apply to the
6217
     other self-contained works thus compiled with the Document, on
6218
     account of their being thus compiled, if they are not themselves
6219
     derivative works of the Document.
6220
 
6221
     If the Cover Text requirement of section 3 is applicable to these
6222
     copies of the Document, then if the Document is less than one
6223
     quarter of the entire aggregate, the Document's Cover Texts may be
6224
     placed on covers that surround only the Document within the
6225
     aggregate.  Otherwise they must appear on covers around the whole
6226
     aggregate.
6227
 
6228
  8. TRANSLATION
6229
 
6230
     Translation is considered a kind of modification, so you may
6231
     distribute translations of the Document under the terms of section
6232
     4.  Replacing Invariant Sections with translations requires special
6233
     permission from their copyright holders, but you may include
6234
     translations of some or all Invariant Sections in addition to the
6235
     original versions of these Invariant Sections.  You may include a
6236
     translation of this License provided that you also include the
6237
     original English version of this License.  In case of a
6238
     disagreement between the translation and the original English
6239
     version of this License, the original English version will prevail.
6240
 
6241
  9. TERMINATION
6242
 
6243
     You may not copy, modify, sublicense, or distribute the Document
6244
     except as expressly provided for under this License.  Any other
6245
     attempt to copy, modify, sublicense or distribute the Document is
6246
     void, and will automatically terminate your rights under this
6247
     License.  However, parties who have received copies, or rights,
6248
     from you under this License will not have their licenses
6249
     terminated so long as such parties remain in full compliance.
6250
 
6251
 10. FUTURE REVISIONS OF THIS LICENSE
6252
 
6253
     The Free Software Foundation may publish new, revised versions of
6254
     the GNU Free Documentation License from time to time.  Such new
6255
     versions will be similar in spirit to the present version, but may
6256
     differ in detail to address new problems or concerns.  See
6257
     http://www.gnu.org/copyleft/.
6258
 
6259
     Each version of the License is given a distinguishing version
6260
     number.  If the Document specifies that a particular numbered
6261
     version of this License "or any later version" applies to it, you
6262
     have the option of following the terms and conditions either of
6263
     that specified version or of any later version that has been
6264
     published (not as a draft) by the Free Software Foundation.  If
6265
     the Document does not specify a version number of this License,
6266
     you may choose any version ever published (not as a draft) by the
6267
     Free Software Foundation.
6268
 
6269
 
6270
ADDENDUM: How to use this License for your documents
6271
====================================================
6272
 
6273
To use this License in a document you have written, include a copy of
6274
the License in the document and put the following copyright and license
6275
notices just after the title page:
6276
 
6277
     Copyright (C)  YEAR  YOUR NAME.
6278
     Permission is granted to copy, distribute and/or modify this document
6279
     under the terms of the GNU Free Documentation License, Version 1.1
6280
     or any later version published by the Free Software Foundation;
6281
     with the Invariant Sections being LIST THEIR TITLES, with the
6282
     Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
6283
     A copy of the license is included in the section entitled "GNU
6284
     Free Documentation License."
6285
 
6286
   If you have no Invariant Sections, write "with no Invariant Sections"
6287
instead of saying which ones are invariant.  If you have no Front-Cover
6288
Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
6289
LIST"; likewise for Back-Cover Texts.
6290
 
6291
   If your document contains nontrivial examples of program code, we
6292
recommend releasing these examples in parallel under your choice of
6293
free software license, such as the GNU General Public License, to
6294
permit their use in free software.
6295
 
6296

6297
File: ld.info,  Node: LD Index,  Prev: GNU Free Documentation License,  Up: Top
6298
 
6299
LD Index
6300
********
6301
 
6302
 
6303
* Menu:
6304
6305
* ":                                     Symbols.            (line    6)
6306
* -(:                                    Options.            (line  645)
6307
* --accept-unknown-input-arch:           Options.            (line  663)
6308
* --add-needed:                          Options.            (line  685)
6309
* --add-stdcall-alias:                   Options.            (line 1466)
6310
* --allow-multiple-definition:           Options.            (line  908)
6311
* --allow-shlib-undefined:               Options.            (line  914)
6312
* --architecture=ARCH:                   Options.            (line  106)
6313
* --as-needed:                           Options.            (line  673)
6314
* --auxiliary:                           Options.            (line  207)
6315
* --bank-window:                         Options.            (line 1811)
6316
* --base-file:                           Options.            (line 1471)
6317
* --be8:                                 ARM.                (line   23)
6318
* --bss-plt:                             PowerPC ELF32.      (line   13)
6319
* --build-id:                            Options.            (line 1428)
6320
* --build-id=STYLE:                      Options.            (line 1428)
6321
* --check-sections:                      Options.            (line  767)
6322
* --cref:                                Options.            (line  777)
6323
* --default-imported-symver:             Options.            (line  942)
6324
* --default-script=SCRIPT:               Options.            (line  490)
6325
* --default-symver:                      Options.            (line  938)
6326
* --defsym SYMBOL=EXP:                   Options.            (line  805)
6327
* --demangle[=STYLE]:                    Options.            (line  818)
6328
* --disable-auto-image-base:             Options.            (line 1618)
6329
* --disable-auto-import:                 Options.            (line 1753)
6330
* --disable-new-dtags:                   Options.            (line 1391)
6331
* --disable-runtime-pseudo-reloc:        Options.            (line 1766)
6332
* --disable-stdcall-fixup:               Options.            (line 1481)
6333
* --discard-all:                         Options.            (line  536)
6334
* --discard-locals:                      Options.            (line  540)
6335
* --dll:                                 Options.            (line 1476)
6336
* --dll-search-prefix:                   Options.            (line 1624)
6337
* --dotsyms:                             PowerPC64 ELF64.    (line   33)
6338
* --dynamic-linker FILE:                 Options.            (line  831)
6339
* --dynamic-list-cpp-new:                Options.            (line  759)
6340
* --dynamic-list-cpp-typeinfo:           Options.            (line  763)
6341
* --dynamic-list-data:                   Options.            (line  756)
6342
* --dynamic-list=DYNAMIC-LIST-FILE:      Options.            (line  743)
6343
* --eh-frame-hdr:                        Options.            (line 1387)
6344
* --emit-relocs:                         Options.            (line  425)
6345
* --emit-stack-syms:                     SPU ELF.            (line   46)
6346
* --emit-stub-syms <1>:                  SPU ELF.            (line   15)
6347
* --emit-stub-syms <2>:                  PowerPC64 ELF64.    (line   29)
6348
* --emit-stub-syms:                      PowerPC ELF32.      (line   44)
6349
* --enable-auto-image-base:              Options.            (line 1610)
6350
* --enable-auto-import:                  Options.            (line 1633)
6351
* --enable-extra-pe-debug:               Options.            (line 1771)
6352
* --enable-new-dtags:                    Options.            (line 1391)
6353
* --enable-runtime-pseudo-reloc:         Options.            (line 1758)
6354
* --enable-stdcall-fixup:                Options.            (line 1481)
6355
* --entry=ENTRY:                         Options.            (line  160)
6356
* --error-unresolved-symbols:            Options.            (line 1340)
6357
* --exclude-libs:                        Options.            (line  170)
6358
* --exclude-symbols:                     Options.            (line 1523)
6359
* --export-all-symbols:                  Options.            (line 1499)
6360
* --export-dynamic:                      Options.            (line  181)
6361
* --extra-overlay-stubs:                 SPU ELF.            (line   19)
6362
* --fatal-warnings:                      Options.            (line  837)
6363
* --file-alignment:                      Options.            (line 1529)
6364
* --filter:                              Options.            (line  228)
6365
* --fix-v4bx:                            ARM.                (line   44)
6366
* --fix-v4bx-interworking:               ARM.                (line   57)
6367
* --force-dynamic:                       Options.            (line  434)
6368
* --force-exe-suffix:                    Options.            (line  840)
6369
* --format=FORMAT:                       Options.            (line  117)
6370
* --format=VERSION:                      TI COFF.            (line    6)
6371
* --gc-sections:                         Options.            (line  850)
6372
* --gpsize:                              Options.            (line  261)
6373
* --hash-size=NUMBER:                    Options.            (line 1400)
6374
* --hash-style=STYLE:                    Options.            (line 1408)
6375
* --heap:                                Options.            (line 1535)
6376
* --help:                                Options.            (line  881)
6377
* --image-base:                          Options.            (line 1542)
6378
* --just-symbols=FILE:                   Options.            (line  457)
6379
* --kill-at:                             Options.            (line 1551)
6380
* --large-address-aware:                 Options.            (line 1556)
6381
* --library-path=DIR:                    Options.            (line  320)
6382
* --library=NAMESPEC:                    Options.            (line  287)
6383
* --local-store=lo:hi:                   SPU ELF.            (line   24)
6384
* --major-image-version:                 Options.            (line 1565)
6385
* --major-os-version:                    Options.            (line 1570)
6386
* --major-subsystem-version:             Options.            (line 1574)
6387
* --minor-image-version:                 Options.            (line 1579)
6388
* --minor-os-version:                    Options.            (line 1584)
6389
* --minor-subsystem-version:             Options.            (line 1588)
6390
* --mri-script=MRI-CMDFILE:              Options.            (line  141)
6391
* --multi-subspace:                      HPPA ELF32.         (line    6)
6392
* --nmagic:                              Options.            (line  389)
6393
* --no-accept-unknown-input-arch:        Options.            (line  663)
6394
* --no-add-needed:                       Options.            (line  685)
6395
* --no-allow-shlib-undefined:            Options.            (line  914)
6396
* --no-as-needed:                        Options.            (line  673)
6397
* --no-check-sections:                   Options.            (line  767)
6398
* --no-define-common:                    Options.            (line  789)
6399
* --no-demangle:                         Options.            (line  818)
6400
* --no-dotsyms:                          PowerPC64 ELF64.    (line   33)
6401
* --no-enum-size-warning:                ARM.                (line  106)
6402
* --no-gc-sections:                      Options.            (line  850)
6403
* --no-keep-memory:                      Options.            (line  893)
6404
* --no-multi-toc:                        PowerPC64 ELF64.    (line   74)
6405
* --no-omagic:                           Options.            (line  403)
6406
* --no-opd-optimize:                     PowerPC64 ELF64.    (line   48)
6407
* --no-overlays:                         SPU ELF.            (line    9)
6408
* --no-print-gc-sections:                Options.            (line  872)
6409
* --no-relax:                            Xtensa.             (line   56)
6410
* --no-tls-optimize <1>:                 PowerPC64 ELF64.    (line   43)
6411
* --no-tls-optimize:                     PowerPC ELF32.      (line   48)
6412
* --no-toc-optimize:                     PowerPC64 ELF64.    (line   60)
6413
* --no-trampoline:                       Options.            (line 1805)
6414
* --no-undefined:                        Options.            (line  900)
6415
* --no-undefined-version:                Options.            (line  933)
6416
* --no-warn-mismatch:                    Options.            (line  946)
6417
* --no-warn-search-mismatch:             Options.            (line  955)
6418
* --no-whole-archive:                    Options.            (line  959)
6419
* --noinhibit-exec:                      Options.            (line  963)
6420
* --non-overlapping-opd:                 PowerPC64 ELF64.    (line   54)
6421
* --oformat:                             Options.            (line  975)
6422
* --omagic:                              Options.            (line  394)
6423
* --out-implib:                          Options.            (line 1601)
6424
* --output-def:                          Options.            (line 1593)
6425
* --output=OUTPUT:                       Options.            (line  409)
6426
* --pic-executable:                      Options.            (line  988)
6427
* --pic-veneer:                          M68HC11/68HC12.     (line   38)
6428
* --plugin:                              SPU ELF.            (line    6)
6429
* --print-gc-sections:                   Options.            (line  872)
6430
* --print-map:                           Options.            (line  352)
6431
* --reduce-memory-overheads:             Options.            (line 1414)
6432
* --relax:                               Options.            (line 1004)
6433
* --relax on i960:                       i960.               (line   31)
6434
* --relax on PowerPC:                    PowerPC ELF32.      (line    6)
6435
* --relax on Xtensa:                     Xtensa.             (line   27)
6436
* --relocatable:                         Options.            (line  438)
6437
* --script=SCRIPT:                       Options.            (line  481)
6438
* --sdata-got:                           PowerPC ELF32.      (line   30)
6439
* --section-alignment:                   Options.            (line 1776)
6440
* --section-start SECTIONNAME=ORG:       Options.            (line 1177)
6441
* --secure-plt:                          PowerPC ELF32.      (line   23)
6442
* --sort-common:                         Options.            (line 1124)
6443
* --sort-section alignment:              Options.            (line 1134)
6444
* --sort-section name:                   Options.            (line 1130)
6445
* --split-by-file:                       Options.            (line 1138)
6446
* --split-by-reloc:                      Options.            (line 1143)
6447
* --stack:                               Options.            (line 1782)
6448
* --stack-analysis:                      SPU ELF.            (line   29)
6449
* --stats:                               Options.            (line 1156)
6450
* --strip-all:                           Options.            (line  468)
6451
* --strip-debug:                         Options.            (line  472)
6452
* --stub-group-size:                     PowerPC64 ELF64.    (line    6)
6453
* --stub-group-size=N:                   HPPA ELF32.         (line   12)
6454
* --subsystem:                           Options.            (line 1789)
6455
* --support-old-code:                    ARM.                (line    6)
6456
* --sysroot:                             Options.            (line 1160)
6457
* --target-help:                         Options.            (line  885)
6458
* --target1-abs:                         ARM.                (line   27)
6459
* --target1-rel:                         ARM.                (line   27)
6460
* --target2=TYPE:                        ARM.                (line   32)
6461
* --thumb-entry=ENTRY:                   ARM.                (line   17)
6462
* --trace:                               Options.            (line  477)
6463
* --trace-symbol=SYMBOL:                 Options.            (line  546)
6464
* --traditional-format:                  Options.            (line 1165)
6465
* --undefined=SYMBOL:                    Options.            (line  503)
6466
* --unique[=SECTION]:                    Options.            (line  521)
6467
* --unresolved-symbols:                  Options.            (line 1192)
6468
* --use-blx:                             ARM.                (line   69)
6469
* --verbose:                             Options.            (line 1221)
6470
* --version:                             Options.            (line  530)
6471
* --version-script=VERSION-SCRIPTFILE:   Options.            (line 1227)
6472
* --vfp11-denorm-fix:                    ARM.                (line   78)
6473
* --warn-common:                         Options.            (line 1234)
6474
* --warn-constructors:                   Options.            (line 1302)
6475
* --warn-multiple-gp:                    Options.            (line 1307)
6476
* --warn-once:                           Options.            (line 1321)
6477
* --warn-section-align:                  Options.            (line 1325)
6478
* --warn-shared-textrel:                 Options.            (line 1332)
6479
* --warn-unresolved-symbols:             Options.            (line 1335)
6480
* --whole-archive:                       Options.            (line 1344)
6481
* --wrap:                                Options.            (line 1358)
6482
* -AARCH:                                Options.            (line  105)
6483
* -aKEYWORD:                             Options.            (line   98)
6484
* -assert KEYWORD:                       Options.            (line  695)
6485
* -b FORMAT:                             Options.            (line  117)
6486
* -Bdynamic:                             Options.            (line  698)
6487
* -Bgroup:                               Options.            (line  708)
6488
* -Bshareable:                           Options.            (line 1116)
6489
* -Bstatic:                              Options.            (line  715)
6490
* -Bsymbolic:                            Options.            (line  730)
6491
* -Bsymbolic-functions:                  Options.            (line  737)
6492
* -c MRI-CMDFILE:                        Options.            (line  141)
6493
* -call_shared:                          Options.            (line  698)
6494
* -d:                                    Options.            (line  151)
6495
* -dc:                                   Options.            (line  151)
6496
* -dn:                                   Options.            (line  715)
6497
* -dp:                                   Options.            (line  151)
6498
* -dT SCRIPT:                            Options.            (line  490)
6499
* -dy:                                   Options.            (line  698)
6500
* -E:                                    Options.            (line  181)
6501
* -e ENTRY:                              Options.            (line  160)
6502
* -EB:                                   Options.            (line  200)
6503
* -EL:                                   Options.            (line  203)
6504
* -F:                                    Options.            (line  228)
6505
* -f:                                    Options.            (line  207)
6506
* -fini:                                 Options.            (line  252)
6507
* -G:                                    Options.            (line  261)
6508
* -g:                                    Options.            (line  258)
6509
* -hNAME:                                Options.            (line  269)
6510
* -i:                                    Options.            (line  278)
6511
* -IFILE:                                Options.            (line  831)
6512
* -init:                                 Options.            (line  281)
6513
* -LDIR:                                 Options.            (line  320)
6514
* -lNAMESPEC:                            Options.            (line  287)
6515
* -M:                                    Options.            (line  352)
6516
* -m EMULATION:                          Options.            (line  342)
6517
* -Map:                                  Options.            (line  889)
6518
* -N:                                    Options.            (line  394)
6519
* -n:                                    Options.            (line  389)
6520
* -non_shared:                           Options.            (line  715)
6521
* -nostdlib:                             Options.            (line  969)
6522
* -O LEVEL:                              Options.            (line  415)
6523
* -o OUTPUT:                             Options.            (line  409)
6524
* -pie:                                  Options.            (line  988)
6525
* -q:                                    Options.            (line  425)
6526
* -qmagic:                               Options.            (line  998)
6527
* -Qy:                                   Options.            (line 1001)
6528
* -r:                                    Options.            (line  438)
6529
* -R FILE:                               Options.            (line  457)
6530
* -rpath:                                Options.            (line 1039)
6531
* -rpath-link:                           Options.            (line 1061)
6532
* -S:                                    Options.            (line  472)
6533
* -s:                                    Options.            (line  468)
6534
* -shared:                               Options.            (line 1116)
6535
* -soname=NAME:                          Options.            (line  269)
6536
* -static:                               Options.            (line  715)
6537
* -t:                                    Options.            (line  477)
6538
* -T SCRIPT:                             Options.            (line  481)
6539
* -Tbss ORG:                             Options.            (line 1186)
6540
* -Tdata ORG:                            Options.            (line 1186)
6541
* -Ttext ORG:                            Options.            (line 1186)
6542
* -u SYMBOL:                             Options.            (line  503)
6543
* -Ur:                                   Options.            (line  511)
6544
* -V:                                    Options.            (line  530)
6545
* -v:                                    Options.            (line  530)
6546
* -X:                                    Options.            (line  540)
6547
* -x:                                    Options.            (line  536)
6548
* -Y PATH:                               Options.            (line  555)
6549
* -y SYMBOL:                             Options.            (line  546)
6550
* -z defs:                               Options.            (line  900)
6551
* -z KEYWORD:                            Options.            (line  559)
6552
* -z muldefs:                            Options.            (line  908)
6553
* .:                                     Location Counter.   (line    6)
6554
* /DISCARD/:                             Output Section Discarding.
6555
                                                             (line   21)
6556
* :PHDR:                                 Output Section Phdr.
6557
                                                             (line    6)
6558
* =FILLEXP:                              Output Section Fill.
6559
                                                             (line    6)
6560
* >REGION:                               Output Section Region.
6561
                                                             (line    6)
6562
* [COMMON]:                              Input Section Common.
6563
                                                             (line   29)
6564
* ABSOLUTE (MRI):                        MRI.                (line   33)
6565
* absolute and relocatable symbols:      Expression Section. (line    6)
6566
* absolute expressions:                  Expression Section. (line    6)
6567
* ABSOLUTE(EXP):                         Builtin Functions.  (line   10)
6568
* ADDR(SECTION):                         Builtin Functions.  (line   17)
6569
* address, section:                      Output Section Address.
6570
                                                             (line    6)
6571
* ALIAS (MRI):                           MRI.                (line   44)
6572
* ALIGN (MRI):                           MRI.                (line   50)
6573
* align expression:                      Builtin Functions.  (line   36)
6574
* align location counter:                Builtin Functions.  (line   36)
6575
* ALIGN(ALIGN):                          Builtin Functions.  (line   36)
6576
* ALIGN(EXP,ALIGN):                      Builtin Functions.  (line   36)
6577
* ALIGN(SECTION_ALIGN):                  Forced Output Alignment.
6578
                                                             (line    6)
6579
* ALIGNOF(SECTION):                      Builtin Functions.  (line   62)
6580
* allocating memory:                     MEMORY.             (line    6)
6581
* architecture:                          Miscellaneous Commands.
6582
                                                             (line   72)
6583
* architectures:                         Options.            (line  105)
6584
* archive files, from cmd line:          Options.            (line  287)
6585
* archive search path in linker script:  File Commands.      (line   71)
6586
* arithmetic:                            Expressions.        (line    6)
6587
* arithmetic operators:                  Operators.          (line    6)
6588
* ARM interworking support:              ARM.                (line    6)
6589
* AS_NEEDED(FILES):                      File Commands.      (line   51)
6590
* ASSERT:                                Miscellaneous Commands.
6591
                                                             (line    9)
6592
* assertion in linker script:            Miscellaneous Commands.
6593
                                                             (line    9)
6594
* assignment in scripts:                 Assignments.        (line    6)
6595
* AT(LMA):                               Output Section LMA. (line    6)
6596
* AT>LMA_REGION:                         Output Section LMA. (line    6)
6597
* automatic data imports:                WIN32.              (line  170)
6598
* back end:                              BFD.                (line    6)
6599
* BASE (MRI):                            MRI.                (line   54)
6600
* BE8:                                   ARM.                (line   23)
6601
* BFD canonical format:                  Canonical format.   (line   11)
6602
* BFD requirements:                      BFD.                (line   16)
6603
* big-endian objects:                    Options.            (line  200)
6604
* binary input format:                   Options.            (line  117)
6605
* BLOCK(EXP):                            Builtin Functions.  (line   75)
6606
* bug criteria:                          Bug Criteria.       (line    6)
6607
* bug reports:                           Bug Reporting.      (line    6)
6608
* bugs in ld:                            Reporting Bugs.     (line    6)
6609
* BYTE(EXPRESSION):                      Output Section Data.
6610
                                                             (line    6)
6611
* C++ constructors, arranging in link:   Output Section Keywords.
6612
                                                             (line   19)
6613
* CHIP (MRI):                            MRI.                (line   58)
6614
* COLLECT_NO_DEMANGLE:                   Environment.        (line   29)
6615
* combining symbols, warnings on:        Options.            (line 1234)
6616
* command files:                         Scripts.            (line    6)
6617
* command line:                          Options.            (line    6)
6618
* common allocation:                     Options.            (line  151)
6619
* common allocation in linker script:    Miscellaneous Commands.
6620
                                                             (line   20)
6621
* common symbol placement:               Input Section Common.
6622
                                                             (line    6)
6623
* compatibility, MRI:                    Options.            (line  141)
6624
* constants in linker scripts:           Constants.          (line    6)
6625
* CONSTRUCTORS:                          Output Section Keywords.
6626
                                                             (line   19)
6627
* constructors:                          Options.            (line  511)
6628
* constructors, arranging in link:       Output Section Keywords.
6629
                                                             (line   19)
6630
* crash of linker:                       Bug Criteria.       (line    9)
6631
* CREATE_OBJECT_SYMBOLS:                 Output Section Keywords.
6632
                                                             (line    9)
6633
* creating a DEF file:                   WIN32.              (line  137)
6634
* cross reference table:                 Options.            (line  777)
6635
* cross references:                      Miscellaneous Commands.
6636
                                                             (line   56)
6637
* current output location:               Location Counter.   (line    6)
6638
* data:                                  Output Section Data.
6639
                                                             (line    6)
6640
* DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE): Builtin Functions.
6641
                                                             (line   80)
6642
* DATA_SEGMENT_END(EXP):                 Builtin Functions.  (line  101)
6643
* DATA_SEGMENT_RELRO_END(OFFSET, EXP):   Builtin Functions.  (line  107)
6644
* dbx:                                   Options.            (line 1170)
6645
* DEF files, creating:                   Options.            (line 1593)
6646
* default emulation:                     Environment.        (line   21)
6647
* default input format:                  Environment.        (line    9)
6648
* DEFINED(SYMBOL):                       Builtin Functions.  (line  118)
6649
* deleting local symbols:                Options.            (line  536)
6650
* demangling, default:                   Environment.        (line   29)
6651
* demangling, from command line:         Options.            (line  818)
6652
* direct linking to a dll:               WIN32.              (line  218)
6653
* discarding sections:                   Output Section Discarding.
6654
                                                             (line    6)
6655
* discontinuous memory:                  MEMORY.             (line    6)
6656
* DLLs, creating:                        Options.            (line 1499)
6657
* DLLs, linking to:                      Options.            (line 1624)
6658
* dot:                                   Location Counter.   (line    6)
6659
* dot inside sections:                   Location Counter.   (line   36)
6660
* dot outside sections:                  Location Counter.   (line   66)
6661
* dynamic linker, from command line:     Options.            (line  831)
6662
* dynamic symbol table:                  Options.            (line  181)
6663
* ELF program headers:                   PHDRS.              (line    6)
6664
* emulation:                             Options.            (line  342)
6665
* emulation, default:                    Environment.        (line   21)
6666
* END (MRI):                             MRI.                (line   62)
6667
* endianness:                            Options.            (line  200)
6668
* entry point:                           Entry Point.        (line    6)
6669
* entry point, from command line:        Options.            (line  160)
6670
* entry point, thumb:                    ARM.                (line   17)
6671
* ENTRY(SYMBOL):                         Entry Point.        (line    6)
6672
* error on valid input:                  Bug Criteria.       (line   12)
6673
* example of linker script:              Simple Example.     (line    6)
6674
* exporting DLL symbols:                 WIN32.              (line   19)
6675
* expression evaluation order:           Evaluation.         (line    6)
6676
* expression sections:                   Expression Section. (line    6)
6677
* expression, absolute:                  Builtin Functions.  (line   10)
6678
* expressions:                           Expressions.        (line    6)
6679
* EXTERN:                                Miscellaneous Commands.
6680
                                                             (line   13)
6681
* fatal signal:                          Bug Criteria.       (line    9)
6682
* file name wildcard patterns:           Input Section Wildcards.
6683
                                                             (line    6)
6684
* FILEHDR:                               PHDRS.              (line   61)
6685
* filename symbols:                      Output Section Keywords.
6686
                                                             (line    9)
6687
* fill pattern, entire section:          Output Section Fill.
6688
                                                             (line    6)
6689
* FILL(EXPRESSION):                      Output Section Data.
6690
                                                             (line   39)
6691
* finalization function:                 Options.            (line  252)
6692
* first input file:                      File Commands.      (line   79)
6693
* first instruction:                     Entry Point.        (line    6)
6694
* FIX_V4BX:                              ARM.                (line   44)
6695
* FIX_V4BX_INTERWORKING:                 ARM.                (line   57)
6696
* FORCE_COMMON_ALLOCATION:               Miscellaneous Commands.
6697
                                                             (line   20)
6698
* forcing input section alignment:       Forced Input Alignment.
6699
                                                             (line    6)
6700
* forcing output section alignment:      Forced Output Alignment.
6701
                                                             (line    6)
6702
* forcing the creation of dynamic sections: Options.         (line  434)
6703
* FORMAT (MRI):                          MRI.                (line   66)
6704
* functions in expressions:              Builtin Functions.  (line    6)
6705
* garbage collection <1>:                Input Section Keep. (line    6)
6706
* garbage collection:                    Options.            (line  850)
6707
* generating optimized output:           Options.            (line  415)
6708
* GNU linker:                            Overview.           (line    6)
6709
* GNUTARGET:                             Environment.        (line    9)
6710
* GROUP(FILES):                          File Commands.      (line   44)
6711
* grouping input files:                  File Commands.      (line   44)
6712
* groups of archives:                    Options.            (line  645)
6713
* H8/300 support:                        H8/300.             (line    6)
6714
* header size:                           Builtin Functions.  (line  183)
6715
* heap size:                             Options.            (line 1535)
6716
* help:                                  Options.            (line  881)
6717
* holes:                                 Location Counter.   (line   12)
6718
* holes, filling:                        Output Section Data.
6719
                                                             (line   39)
6720
* HPPA multiple sub-space stubs:         HPPA ELF32.         (line    6)
6721
* HPPA stub grouping:                    HPPA ELF32.         (line   12)
6722
* i960 support:                          i960.               (line    6)
6723
* image base:                            Options.            (line 1542)
6724
* implicit linker scripts:               Implicit Linker Scripts.
6725
                                                             (line    6)
6726
* import libraries:                      WIN32.              (line   10)
6727
* INCLUDE FILENAME:                      File Commands.      (line    9)
6728
* including a linker script:             File Commands.      (line    9)
6729
* including an entire archive:           Options.            (line 1344)
6730
* incremental link:                      Options.            (line  278)
6731
* INHIBIT_COMMON_ALLOCATION:             Miscellaneous Commands.
6732
                                                             (line   25)
6733
* initialization function:               Options.            (line  281)
6734
* initialized data in ROM:               Output Section LMA. (line   26)
6735
* input file format in linker script:    Format Commands.    (line   35)
6736
* input filename symbols:                Output Section Keywords.
6737
                                                             (line    9)
6738
* input files in linker scripts:         File Commands.      (line   16)
6739
* input files, displaying:               Options.            (line  477)
6740
* input format:                          Options.            (line  117)
6741
* input object files in linker scripts:  File Commands.      (line   16)
6742
* input section alignment:               Forced Input Alignment.
6743
                                                             (line    6)
6744
* input section basics:                  Input Section Basics.
6745
                                                             (line    6)
6746
* input section wildcards:               Input Section Wildcards.
6747
                                                             (line    6)
6748
* input sections:                        Input Section.      (line    6)
6749
* INPUT(FILES):                          File Commands.      (line   16)
6750
* INSERT:                                Miscellaneous Commands.
6751
                                                             (line   30)
6752
* insert user script into default script: Miscellaneous Commands.
6753
                                                             (line   30)
6754
* integer notation:                      Constants.          (line    6)
6755
* integer suffixes:                      Constants.          (line   12)
6756
* internal object-file format:           Canonical format.   (line   11)
6757
* invalid input:                         Bug Criteria.       (line   14)
6758
* K and M integer suffixes:              Constants.          (line   12)
6759
* KEEP:                                  Input Section Keep. (line    6)
6760
* l =:                                   MEMORY.             (line   72)
6761
* lazy evaluation:                       Evaluation.         (line    6)
6762
* ld bugs, reporting:                    Bug Reporting.      (line    6)
6763
* LDEMULATION:                           Environment.        (line   21)
6764
* len =:                                 MEMORY.             (line   72)
6765
* LENGTH =:                              MEMORY.             (line   72)
6766
* LENGTH(MEMORY):                        Builtin Functions.  (line  135)
6767
* library search path in linker script:  File Commands.      (line   71)
6768
* link map:                              Options.            (line  352)
6769
* link-time runtime library search path: Options.            (line 1061)
6770
* linker crash:                          Bug Criteria.       (line    9)
6771
* linker script concepts:                Basic Script Concepts.
6772
                                                             (line    6)
6773
* linker script example:                 Simple Example.     (line    6)
6774
* linker script file commands:           File Commands.      (line    6)
6775
* linker script format:                  Script Format.      (line    6)
6776
* linker script input object files:      File Commands.      (line   16)
6777
* linker script simple commands:         Simple Commands.    (line    6)
6778
* linker scripts:                        Scripts.            (line    6)
6779
* LIST (MRI):                            MRI.                (line   77)
6780
* little-endian objects:                 Options.            (line  203)
6781
* LOAD (MRI):                            MRI.                (line   84)
6782
* load address:                          Output Section LMA. (line    6)
6783
* LOADADDR(SECTION):                     Builtin Functions.  (line  138)
6784
* loading, preventing:                   Output Section Type.
6785
                                                             (line   22)
6786
* local symbols, deleting:               Options.            (line  540)
6787
* location counter:                      Location Counter.   (line    6)
6788
* LONG(EXPRESSION):                      Output Section Data.
6789
                                                             (line    6)
6790
* M and K integer suffixes:              Constants.          (line   12)
6791
* M68HC11 and 68HC12 support:            M68HC11/68HC12.     (line    6)
6792
* machine architecture:                  Miscellaneous Commands.
6793
                                                             (line   72)
6794
* machine dependencies:                  Machine Dependent.  (line    6)
6795
* mapping input sections to output sections: Input Section.  (line    6)
6796
* MAX:                                   Builtin Functions.  (line  143)
6797
* MEMORY:                                MEMORY.             (line    6)
6798
* memory region attributes:              MEMORY.             (line   32)
6799
* memory regions:                        MEMORY.             (line    6)
6800
* memory regions and sections:           Output Section Region.
6801
                                                             (line    6)
6802
* memory usage:                          Options.            (line  893)
6803
* MIN:                                   Builtin Functions.  (line  146)
6804
* MRI compatibility:                     MRI.                (line    6)
6805
* MSP430 extra sections:                 MSP430.             (line   11)
6806
* NAME (MRI):                            MRI.                (line   90)
6807
* name, section:                         Output Section Name.
6808
                                                             (line    6)
6809
* names:                                 Symbols.            (line    6)
6810
* naming the output file:                Options.            (line  409)
6811
* NEXT(EXP):                             Builtin Functions.  (line  150)
6812
* NMAGIC:                                Options.            (line  389)
6813
* NO_ENUM_SIZE_WARNING:                  ARM.                (line  106)
6814
* NOCROSSREFS(SECTIONS):                 Miscellaneous Commands.
6815
                                                             (line   56)
6816
* NOLOAD:                                Output Section Type.
6817
                                                             (line   22)
6818
* not enough room for program headers:   Builtin Functions.  (line  188)
6819
* o =:                                   MEMORY.             (line   67)
6820
* objdump -i:                            BFD.                (line    6)
6821
* object file management:                BFD.                (line    6)
6822
* object files:                          Options.            (line   29)
6823
* object formats available:              BFD.                (line    6)
6824
* object size:                           Options.            (line  261)
6825
* OMAGIC:                                Options.            (line  394)
6826
* opening object files:                  BFD outline.        (line    6)
6827
* operators for arithmetic:              Operators.          (line    6)
6828
* options:                               Options.            (line    6)
6829
* ORDER (MRI):                           MRI.                (line   95)
6830
* org =:                                 MEMORY.             (line   67)
6831
* ORIGIN =:                              MEMORY.             (line   67)
6832
* ORIGIN(MEMORY):                        Builtin Functions.  (line  156)
6833
* orphan:                                Orphan Sections.    (line    6)
6834
* output file after errors:              Options.            (line  963)
6835
* output file format in linker script:   Format Commands.    (line   10)
6836
* output file name in linker script:     File Commands.      (line   61)
6837
* output section alignment:              Forced Output Alignment.
6838
                                                             (line    6)
6839
* output section attributes:             Output Section Attributes.
6840
                                                             (line    6)
6841
* output section data:                   Output Section Data.
6842
                                                             (line    6)
6843
* OUTPUT(FILENAME):                      File Commands.      (line   61)
6844
* OUTPUT_ARCH(BFDARCH):                  Miscellaneous Commands.
6845
                                                             (line   72)
6846
* OUTPUT_FORMAT(BFDNAME):                Format Commands.    (line   10)
6847
* OVERLAY:                               Overlay Description.
6848
                                                             (line    6)
6849
* overlays:                              Overlay Description.
6850
                                                             (line    6)
6851
* partial link:                          Options.            (line  438)
6852
* PHDRS:                                 PHDRS.              (line    6)
6853
* PIC_VENEER:                            M68HC11/68HC12.     (line   38)
6854
* position independent executables:      Options.            (line  990)
6855
* PowerPC ELF32 options:                 PowerPC ELF32.      (line   13)
6856
* PowerPC GOT:                           PowerPC ELF32.      (line   30)
6857
* PowerPC long branches:                 PowerPC ELF32.      (line    6)
6858
* PowerPC PLT:                           PowerPC ELF32.      (line   13)
6859
* PowerPC stub symbols:                  PowerPC ELF32.      (line   44)
6860
* PowerPC TLS optimization:              PowerPC ELF32.      (line   48)
6861
* PowerPC64 dot symbols:                 PowerPC64 ELF64.    (line   33)
6862
* PowerPC64 ELF64 options:               PowerPC64 ELF64.    (line    6)
6863
* PowerPC64 multi-TOC:                   PowerPC64 ELF64.    (line   74)
6864
* PowerPC64 OPD optimization:            PowerPC64 ELF64.    (line   48)
6865
* PowerPC64 OPD spacing:                 PowerPC64 ELF64.    (line   54)
6866
* PowerPC64 stub grouping:               PowerPC64 ELF64.    (line    6)
6867
* PowerPC64 stub symbols:                PowerPC64 ELF64.    (line   29)
6868
* PowerPC64 TLS optimization:            PowerPC64 ELF64.    (line   43)
6869
* PowerPC64 TOC optimization:            PowerPC64 ELF64.    (line   60)
6870
* precedence in expressions:             Operators.          (line    6)
6871
* prevent unnecessary loading:           Output Section Type.
6872
                                                             (line   22)
6873
* program headers:                       PHDRS.              (line    6)
6874
* program headers and sections:          Output Section Phdr.
6875
                                                             (line    6)
6876
* program headers, not enough room:      Builtin Functions.  (line  188)
6877
* program segments:                      PHDRS.              (line    6)
6878
* PROVIDE:                               PROVIDE.            (line    6)
6879
* PROVIDE_HIDDEN:                        PROVIDE_HIDDEN.     (line    6)
6880
* PUBLIC (MRI):                          MRI.                (line  103)
6881
* QUAD(EXPRESSION):                      Output Section Data.
6882
                                                             (line    6)
6883
* quoted symbol names:                   Symbols.            (line    6)
6884
* read-only text:                        Options.            (line  389)
6885
* read/write from cmd line:              Options.            (line  394)
6886
* regions of memory:                     MEMORY.             (line    6)
6887
* relative expressions:                  Expression Section. (line    6)
6888
* relaxing addressing modes:             Options.            (line 1004)
6889
* relaxing on H8/300:                    H8/300.             (line    9)
6890
* relaxing on i960:                      i960.               (line   31)
6891
* relaxing on M68HC11:                   M68HC11/68HC12.     (line   12)
6892
* relaxing on Xtensa:                    Xtensa.             (line   27)
6893
* relocatable and absolute symbols:      Expression Section. (line    6)
6894
* relocatable output:                    Options.            (line  438)
6895
* removing sections:                     Output Section Discarding.
6896
                                                             (line    6)
6897
* reporting bugs in ld:                  Reporting Bugs.     (line    6)
6898
* requirements for BFD:                  BFD.                (line   16)
6899
* retain relocations in final executable: Options.           (line  425)
6900
* retaining specified symbols:           Options.            (line 1025)
6901
* ROM initialized data:                  Output Section LMA. (line   26)
6902
* round up expression:                   Builtin Functions.  (line   36)
6903
* round up location counter:             Builtin Functions.  (line   36)
6904
* runtime library name:                  Options.            (line  269)
6905
* runtime library search path:           Options.            (line 1039)
6906
* runtime pseudo-relocation:             WIN32.              (line  196)
6907
* scaled integers:                       Constants.          (line   12)
6908
* scommon section:                       Input Section Common.
6909
                                                             (line   20)
6910
* script files:                          Options.            (line  481)
6911
* scripts:                               Scripts.            (line    6)
6912
* search directory, from cmd line:       Options.            (line  320)
6913
* search path in linker script:          File Commands.      (line   71)
6914
* SEARCH_DIR(PATH):                      File Commands.      (line   71)
6915
* SECT (MRI):                            MRI.                (line  109)
6916
* section address:                       Output Section Address.
6917
                                                             (line    6)
6918
* section address in expression:         Builtin Functions.  (line   17)
6919
* section alignment:                     Builtin Functions.  (line   62)
6920
* section alignment, warnings on:        Options.            (line 1325)
6921
* section data:                          Output Section Data.
6922
                                                             (line    6)
6923
* section fill pattern:                  Output Section Fill.
6924
                                                             (line    6)
6925
* section load address:                  Output Section LMA. (line    6)
6926
* section load address in expression:    Builtin Functions.  (line  138)
6927
* section name:                          Output Section Name.
6928
                                                             (line    6)
6929
* section name wildcard patterns:        Input Section Wildcards.
6930
                                                             (line    6)
6931
* section size:                          Builtin Functions.  (line  167)
6932
* section, assigning to memory region:   Output Section Region.
6933
                                                             (line    6)
6934
* section, assigning to program header:  Output Section Phdr.
6935
                                                             (line    6)
6936
* SECTIONS:                              SECTIONS.           (line    6)
6937
* sections, discarding:                  Output Section Discarding.
6938
                                                             (line    6)
6939
* segment origins, cmd line:             Options.            (line 1186)
6940
* SEGMENT_START(SEGMENT, DEFAULT):       Builtin Functions.  (line  159)
6941
* segments, ELF:                         PHDRS.              (line    6)
6942
* shared libraries:                      Options.            (line 1118)
6943
* SHORT(EXPRESSION):                     Output Section Data.
6944
                                                             (line    6)
6945
* SIZEOF(SECTION):                       Builtin Functions.  (line  167)
6946
* SIZEOF_HEADERS:                        Builtin Functions.  (line  183)
6947
* small common symbols:                  Input Section Common.
6948
                                                             (line   20)
6949
* SORT:                                  Input Section Wildcards.
6950
                                                             (line   58)
6951
* SORT_BY_ALIGNMENT:                     Input Section Wildcards.
6952
                                                             (line   54)
6953
* SORT_BY_NAME:                          Input Section Wildcards.
6954
                                                             (line   46)
6955
* SPU:                                   SPU ELF.            (line   29)
6956
* SPU ELF options:                       SPU ELF.            (line    6)
6957
* SPU extra overlay stubs:               SPU ELF.            (line   19)
6958
* SPU local store size:                  SPU ELF.            (line   24)
6959
* SPU overlay stub symbols:              SPU ELF.            (line   15)
6960
* SPU overlays:                          SPU ELF.            (line    9)
6961
* SPU plugins:                           SPU ELF.            (line    6)
6962
* SQUAD(EXPRESSION):                     Output Section Data.
6963
                                                             (line    6)
6964
* stack size:                            Options.            (line 1782)
6965
* standard Unix system:                  Options.            (line    7)
6966
* start of execution:                    Entry Point.        (line    6)
6967
* STARTUP(FILENAME):                     File Commands.      (line   79)
6968
* strip all symbols:                     Options.            (line  468)
6969
* strip debugger symbols:                Options.            (line  472)
6970
* stripping all but some symbols:        Options.            (line 1025)
6971
* SUBALIGN(SUBSECTION_ALIGN):            Forced Input Alignment.
6972
                                                             (line    6)
6973
* suffixes for integers:                 Constants.          (line   12)
6974
* symbol defaults:                       Builtin Functions.  (line  118)
6975
* symbol definition, scripts:            Assignments.        (line    6)
6976
* symbol names:                          Symbols.            (line    6)
6977
* symbol tracing:                        Options.            (line  546)
6978
* symbol versions:                       VERSION.            (line    6)
6979
* symbol-only input:                     Options.            (line  457)
6980
* symbols, from command line:            Options.            (line  805)
6981
* symbols, relocatable and absolute:     Expression Section. (line    6)
6982
* symbols, retaining selectively:        Options.            (line 1025)
6983
* synthesizing linker:                   Options.            (line 1004)
6984
* synthesizing on H8/300:                H8/300.             (line   14)
6985
* TARGET(BFDNAME):                       Format Commands.    (line   35)
6986
* TARGET1:                               ARM.                (line   27)
6987
* TARGET2:                               ARM.                (line   32)
6988
* thumb entry point:                     ARM.                (line   17)
6989
* TI COFF versions:                      TI COFF.            (line    6)
6990
* traditional format:                    Options.            (line 1165)
6991
* trampoline generation on M68HC11:      M68HC11/68HC12.     (line   31)
6992
* trampoline generation on M68HC12:      M68HC11/68HC12.     (line   31)
6993
* unallocated address, next:             Builtin Functions.  (line  150)
6994
* undefined symbol:                      Options.            (line  503)
6995
* undefined symbol in linker script:     Miscellaneous Commands.
6996
                                                             (line   13)
6997
* undefined symbols, warnings on:        Options.            (line 1321)
6998
* uninitialized data placement:          Input Section Common.
6999
                                                             (line    6)
7000
* unspecified memory:                    Output Section Data.
7001
                                                             (line   39)
7002
* usage:                                 Options.            (line  881)
7003
* USE_BLX:                               ARM.                (line   69)
7004
* using a DEF file:                      WIN32.              (line   42)
7005
* using auto-export functionality:       WIN32.              (line   22)
7006
* Using decorations:                     WIN32.              (line  141)
7007
* variables, defining:                   Assignments.        (line    6)
7008
* verbose:                               Options.            (line 1221)
7009
* version:                               Options.            (line  530)
7010
* version script:                        VERSION.            (line    6)
7011
* version script, symbol versions:       Options.            (line 1227)
7012
* VERSION {script text}:                 VERSION.            (line    6)
7013
* versions of symbols:                   VERSION.            (line    6)
7014
* VFP11_DENORM_FIX:                      ARM.                (line   78)
7015
* warnings, on combining symbols:        Options.            (line 1234)
7016
* warnings, on section alignment:        Options.            (line 1325)
7017
* warnings, on undefined symbols:        Options.            (line 1321)
7018
* weak externals:                        WIN32.              (line  386)
7019
* what is this?:                         Overview.           (line    6)
7020
* wildcard file name patterns:           Input Section Wildcards.
7021
 
7022
 
7023
* Xtensa processors:                     Xtensa.             (line    6)
7024
7025
7026

7027
Tag Table:
7028
Node: Top750
7029
Node: Overview1524
7030
Node: Invocation2638
7031
Node: Options3046
7032
Node: Environment84848
7033
Node: Scripts86608
7034
Node: Basic Script Concepts88342
7035
Node: Script Format91049
7036
Node: Simple Example91912
7037
Node: Simple Commands95008
7038
Node: Entry Point95459
7039
Node: File Commands96218
7040
Node: Format Commands100084
7041
Node: Miscellaneous Commands102050
7042
Node: Assignments105429
7043
Node: Simple Assignments105920
7044
Node: PROVIDE107656
7045
Node: PROVIDE_HIDDEN108861
7046
Node: Source Code Reference109105
7047
Node: SECTIONS112685
7048
Node: Output Section Description114576
7049
Node: Output Section Name115629
7050
Node: Output Section Address116505
7051
Node: Input Section118154
7052
Node: Input Section Basics118955
7053
Node: Input Section Wildcards121305
7054
Node: Input Section Common126038
7055
Node: Input Section Keep127520
7056
Node: Input Section Example128010
7057
Node: Output Section Data128978
7058
Node: Output Section Keywords131755
7059
Node: Output Section Discarding135324
7060
Node: Output Section Attributes136505
7061
Node: Output Section Type137509
7062
Node: Output Section LMA138663
7063
Node: Forced Output Alignment141176
7064
Node: Forced Input Alignment141444
7065
Node: Output Section Region141829
7066
Node: Output Section Phdr142259
7067
Node: Output Section Fill142923
7068
Node: Overlay Description144065
7069
Node: MEMORY148368
7070
Node: PHDRS152568
7071
Node: VERSION157607
7072
Node: Expressions165399
7073
Node: Constants166277
7074
Node: Symbols166838
7075
Node: Orphan Sections167576
7076
Node: Location Counter168339
7077
Node: Operators172775
7078
Node: Evaluation173697
7079
Node: Expression Section175061
7080
Node: Builtin Functions176550
7081
Node: Implicit Linker Scripts184517
7082
Node: Machine Dependent185292
7083
Node: H8/300186263
7084
Node: i960187888
7085
Node: M68HC11/68HC12189573
7086
Node: ARM191276
7087
Node: HPPA ELF32196506
7088
Node: MMIX198129
7089
Node: MSP430199346
7090
Node: PowerPC ELF32200395
7091
Node: PowerPC64 ELF64203009
7092
Node: SPU ELF207423
7093
Node: TI COFF210055
7094
Node: WIN32210581
7095
Node: Xtensa228938
7096
Node: BFD232060
7097
Node: BFD outline233515
7098
Node: BFD information loss234801
7099
Node: Canonical format237318
7100
Node: Reporting Bugs241675
7101
Node: Bug Criteria242369
7102
Node: Bug Reporting243068
7103
Node: MRI250107
7104
Node: GNU Free Documentation License254750

powered by: WebSVN 2.1.0

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