Wed Jan 8 15:14:59 1997 Geoffrey Noer <noer@cygnus.com>
[deliverable/binutils-gdb.git] / ld / ld.texinfo
CommitLineData
f22eee08 1\input texinfo
c8072296 2@setfilename ld.info
b4d4e8e3 3@syncodeindex ky cp
7f9ae73e 4@include configdoc.texi
8de26d62 5@c (configdoc.texi is generated by the Makefile)
ec40bbb8
DM
6
7@c @smallbook
1c48127e
RP
8
9@ifinfo
10@format
11START-INFO-DIR-ENTRY
f9d3d71a 12* Ld: (ld). The GNU linker.
1c48127e
RP
13END-INFO-DIR-ENTRY
14@end format
15@end ifinfo
16
b4d4e8e3 17@ifinfo
c653b370 18This file documents the @sc{gnu} linker LD.
b4d4e8e3 19
431e1e85 20Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
b4d4e8e3
RP
21
22Permission is granted to make and distribute verbatim copies of
23this manual provided the copyright notice and this permission notice
24are preserved on all copies.
25
d76ae847
RP
26Permission is granted to copy and distribute modified versions of this
27manual under the conditions for verbatim copying, provided also that
28the entire resulting derived work is distributed under the terms of a
29permission notice identical to this one.
30
31Permission is granted to copy and distribute translations of this manual
32into another language, under the above conditions for modified versions.
33
b4d4e8e3
RP
34@ignore
35Permission is granted to process this file through Tex and print the
36results, provided the printed document carries copying permission
37notice identical to this one except for the removal of this paragraph
38(this paragraph not being relevant to the printed manual).
39
40@end ignore
b4d4e8e3 41@end ifinfo
2c5c0674
RP
42@iftex
43@finalout
b4d4e8e3 44@setchapternewpage odd
246504a5 45@settitle Using LD, the GNU linker
f22eee08 46@titlepage
246504a5 47@title Using ld
c8072296 48@subtitle The GNU linker
f22eee08 49@sp 1
cb70c872 50@subtitle @code{ld} version 2
d4e5e3c3 51@subtitle January 1994
c653b370 52@author Steve Chamberlain
c8072296 53@author Cygnus Support
b4d4e8e3
RP
54@page
55
56@tex
b4d4e8e3
RP
57{\parskip=0pt
58\hfill Cygnus Support\par
c653b370 59\hfill steve\@cygnus.com, doc\@cygnus.com\par
ec40bbb8 60\hfill {\it Using LD, the GNU linker}\par
d4e5e3c3 61\hfill Edited by Jeffrey Osier (jeffrey\@cygnus.com)\par
b4d4e8e3
RP
62}
63\global\parindent=0pt % Steve likes it this way.
64@end tex
65
f22eee08 66@vskip 0pt plus 1filll
431e1e85 67Copyright @copyright{} 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
f22eee08
RP
68
69Permission is granted to make and distribute verbatim copies of
70this manual provided the copyright notice and this permission notice
71are preserved on all copies.
72
73Permission is granted to copy and distribute modified versions of this
74manual under the conditions for verbatim copying, provided also that
75the entire resulting derived work is distributed under the terms of a
76permission notice identical to this one.
77
78Permission is granted to copy and distribute translations of this manual
79into another language, under the above conditions for modified versions.
f22eee08 80@end titlepage
2c5c0674 81@end iftex
b4d4e8e3 82@c FIXME: Talk about importance of *order* of args, cmds to linker!
f22eee08 83
f22eee08 84@ifinfo
ec40bbb8
DM
85@node Top
86@top Using ld
c653b370 87This file documents the @sc{gnu} linker ld.
f22eee08 88
2c5c0674 89@menu
2d59b2c3
RP
90* Overview:: Overview
91* Invocation:: Invocation
92* Commands:: Command Language
ec40bbb8 93@ifset GENERIC
2d59b2c3 94* Machine Dependent:: Machine Dependent Features
ec40bbb8
DM
95@end ifset
96@ifclear GENERIC
97@ifset H8300
98* H8/300:: ld and the H8/300
99@end ifset
f9d3d71a
ILT
100@ifset Hitachi
101* Hitachi:: ld and other Hitachi micros
102@end ifset
ec40bbb8
DM
103@ifset I960
104* i960:: ld and the Intel 960 family
105@end ifset
106@end ifclear
107@ifclear SingleFormat
2d59b2c3 108* BFD:: BFD
ec40bbb8
DM
109@end ifclear
110@c Following blank line required for remaining bug in makeinfo conds/menus
111
9fde46a4 112* Reporting Bugs:: Reporting Bugs
2d59b2c3
RP
113* MRI:: MRI Compatible Script Files
114* Index:: Index
2c5c0674 115@end menu
ec40bbb8 116@end ifinfo
2c5c0674 117
ec40bbb8 118@node Overview
f22eee08
RP
119@chapter Overview
120
c653b370 121@cindex @sc{gnu} linker
2c5c0674 122@cindex what is this?
246504a5 123@code{ld} combines a number of object and archive files, relocates
ec40bbb8
DM
124their data and ties up symbol references. Usually the last step in
125compiling a program is to run @code{ld}.
f22eee08 126
246504a5 127@code{ld} accepts Linker Command Language files written in
2c5c0674 128a superset of AT&T's Link Editor Command Language syntax,
b4d4e8e3 129to provide explicit and total control over the linking process.
f22eee08 130
ec40bbb8 131@ifclear SingleFormat
246504a5
RP
132This version of @code{ld} uses the general purpose BFD libraries
133to operate on object files. This allows @code{ld} to read, combine, and
b4d4e8e3
RP
134write object files in many different formats---for example, COFF or
135@code{a.out}. Different formats may be linked together to produce any
d4e5e3c3 136available kind of object file. @xref{BFD}, for more information.
ec40bbb8 137@end ifclear
f22eee08 138
c653b370 139Aside from its flexibility, the @sc{gnu} linker is more helpful than other
2c5c0674
RP
140linkers in providing diagnostic information. Many linkers abandon
141execution immediately upon encountering an error; whenever possible,
246504a5 142@code{ld} continues executing, allowing you to identify other errors
2c5c0674
RP
143(or, in some cases, to get an output file in spite of the error).
144
ec40bbb8 145@node Invocation
2c5c0674
RP
146@chapter Invocation
147
c653b370 148The @sc{gnu} linker @code{ld} is meant to cover a broad range of situations,
2c5c0674 149and to be as compatible as possible with other linkers. As a result,
ec40bbb8 150you have many choices to control its behavior.
2c5c0674 151
ec40bbb8 152@ifset UsesEnvVars
2c5c0674 153@menu
2d59b2c3
RP
154* Options:: Command Line Options
155* Environment:: Environment Variables
2c5c0674 156@end menu
f22eee08 157
ec40bbb8 158@node Options
2c5c0674 159@section Command Line Options
ec40bbb8 160@end ifset
2c5c0674
RP
161
162@cindex command line
163@cindex options
67afbcea
DE
164The linker supports a plethora of command-line options, but in actual
165practice few of them are used in any particular context.
2c5c0674 166@cindex standard Unix system
246504a5 167For instance, a frequent use of @code{ld} is to link standard Unix
b4d4e8e3
RP
168object files on a standard, supported Unix system. On such a system, to
169link a file @code{hello.o}:
ec40bbb8 170
c653b370 171@smallexample
ec40bbb8 172ld -o @var{output} /lib/crt0.o hello.o -lc
c653b370 173@end smallexample
ec40bbb8 174
d76ae847 175This tells @code{ld} to produce a file called @var{output} as the
b4d4e8e3 176result of linking the file @code{/lib/crt0.o} with @code{hello.o} and
ec40bbb8
DM
177the library @code{libc.a}, which will come from the standard search
178directories. (See the discussion of the @samp{-l} option below.)
f22eee08 179
246504a5 180The command-line options to @code{ld} may be specified in any order, and
67afbcea
DE
181may be repeated at will. Repeating most options with a different
182argument will either have no further effect, or override prior
ec40bbb8 183occurrences (those further to the left on the command line) of that
67afbcea
DE
184option. Options which may be meaningfully specified more than once are
185noted in the descriptions below.
f22eee08 186
2c5c0674 187@cindex object files
67afbcea
DE
188Non-option arguments are objects files which are to be linked together.
189They may follow, precede, or be mixed in with command-line options,
190except that an object file argument may not be placed between an option
191and its argument.
f22eee08 192
7f9ae73e
RP
193Usually the linker is invoked with at least one object file, but you can
194specify other forms of binary input files using @samp{-l}, @samp{-R},
195and the script command language. If @emph{no} binary input files at all
196are specified, the linker does not produce any output, and issues the
197message @samp{No input files}.
2c5c0674 198
0b3499f6
ILT
199If the linker can not recognize the format of an object file, it will
200assume that it is a linker script. A script specified in this way
201augments the main linker script used for the link (either the default
202linker script or the one specified by using @samp{-T}). This feature
203permits the linker to link against a file which appears to be an object
204or an archive, but actually merely defines some symbol values, or uses
205@code{INPUT} or @code{GROUP} to load other objects. @xref{Commands}.
206
d4e5e3c3
DM
207For options whose names are a single letter,
208option arguments must either follow the option letter without intervening
f22eee08
RP
209whitespace, or be given as separate arguments immediately following the
210option that requires them.
211
d4e5e3c3
DM
212For options whose names are multiple letters, either one dash or two can
213precede the option name; for example, @samp{--oformat} and
9fde46a4 214@samp{--oformat} are equivalent. Arguments to multiple-letter options
d4e5e3c3
DM
215must either be separated from the option name by an equals sign, or be
216given as separate arguments immediately following the option that
217requires them. For example, @samp{--oformat srec} and
218@samp{--oformat=srec} are equivalent. Unique abbreviations of the names
219of multiple-letter options are accepted.
220
f22eee08 221@table @code
67afbcea
DE
222@kindex -a@var{keyword}
223@item -a@var{keyword}
224This option is supported for HP/UX compatibility. The @var{keyword}
225argument must be one of the strings @samp{archive}, @samp{shared}, or
226@samp{default}. @samp{-aarchive} is functionally equivalent to
227@samp{-Bstatic}, and the other two keywords are functionally equivalent
228to @samp{-Bdynamic}. This option may be used any number of times.
229
ec40bbb8 230@ifset I960
2c5c0674
RP
231@cindex architectures
232@kindex -A@var{arch}
b4d4e8e3 233@item -A@var{architecture}
67afbcea
DE
234@kindex --architecture=@var{arch}
235@itemx --architecture=@var{architecture}
246504a5
RP
236In the current release of @code{ld}, this option is useful only for the
237Intel 960 family of architectures. In that @code{ld} configuration, the
1c48127e
RP
238@var{architecture} argument identifies the particular architecture in
239the 960 family, enabling some safeguards and modifying the
d76ae847
RP
240archive-library search path. @xref{i960,,@code{ld} and the Intel 960
241family}, for details.
b4d4e8e3 242
246504a5 243Future releases of @code{ld} may support similar functionality for
b4d4e8e3 244other architecture families.
ec40bbb8 245@end ifset
b4d4e8e3 246
ec40bbb8 247@ifclear SingleFormat
2c5c0674
RP
248@cindex binary input format
249@kindex -b @var{format}
67afbcea 250@kindex --format=@var{format}
2c5c0674 251@cindex input format
2c5c0674 252@cindex input format
c653b370 253@item -b @var{input-format}
67afbcea 254@itemx --format=@var{input-format}
1fb57a5d
RP
255@code{ld} may be configured to support more than one kind of object
256file. If your @code{ld} is configured this way, you can use the
257@samp{-b} option to specify the binary format for input object files
258that follow this option on the command line. Even when @code{ld} is
259configured to support alternative object formats, you don't usually need
260to specify this, as @code{ld} should be configured to expect as a
261default input format the most usual format on each machine.
262@var{input-format} is a text string, the name of a particular format
263supported by the BFD libraries. (You can list the available binary
67afbcea 264formats with @samp{objdump -i}.)
1fb57a5d 265@xref{BFD}.
2c5c0674
RP
266
267You may want to use this option if you are linking files with an unusual
ec40bbb8 268binary format. You can also use @samp{-b} to switch formats explicitly (when
2c5c0674 269linking object files of different formats), by including
ec40bbb8 270@samp{-b @var{input-format}} before each group of object files in a
2c5c0674
RP
271particular format.
272
273The default format is taken from the environment variable
ec40bbb8
DM
274@code{GNUTARGET}.
275@ifset UsesEnvVars
276@xref{Environment}.
277@end ifset
278You can also define the input
867a1b8a 279format from a script, using the command @code{TARGET}; see @ref{Option
d76ae847 280Commands}.
ec40bbb8 281@end ifclear
2c5c0674 282
2d59b2c3 283@kindex -c @var{MRI-cmdfile}
67afbcea 284@kindex --mri-script=@var{MRI-cmdfile}
2d59b2c3
RP
285@cindex compatibility, MRI
286@item -c @var{MRI-commandfile}
67afbcea 287@itemx --mri-script=@var{MRI-commandfile}
2d59b2c3
RP
288For compatibility with linkers produced by MRI, @code{ld} accepts script
289files written in an alternate, restricted command language, described in
d76ae847 290@ref{MRI,,MRI Compatible Script Files}. Introduce MRI script files with
ec40bbb8 291the option @samp{-c}; use the @samp{-T} option to run linker
d76ae847 292scripts written in the general-purpose @code{ld} scripting language.
8ddef552
DM
293If @var{MRI-cmdfile} does not exist, @code{ld} looks for it in the directories
294specified by any @samp{-L} options.
b4d4e8e3 295
2c5c0674
RP
296@cindex common allocation
297@kindex -d
2c5c0674 298@kindex -dc
2c5c0674 299@kindex -dp
c653b370
ILT
300@item -d
301@itemx -dc
b4d4e8e3
RP
302@itemx -dp
303These three options are equivalent; multiple forms are supported for
ec40bbb8 304compatibility with other linkers. They
2c5c0674 305assign space to common symbols even if a relocatable output file is
ec40bbb8 306specified (with @samp{-r}). The script command
867a1b8a 307@code{FORCE_COMMON_ALLOCATION} has the same effect. @xref{Option
d76ae847 308Commands}.
b4d4e8e3 309
2c5c0674
RP
310@cindex entry point, from command line
311@kindex -e @var{entry}
67afbcea 312@kindex --entry=@var{entry}
f22eee08 313@item -e @var{entry}
67afbcea 314@itemx --entry=@var{entry}
f22eee08 315Use @var{entry} as the explicit symbol for beginning execution of your
b4d4e8e3
RP
316program, rather than the default entry point. @xref{Entry Point}, for a
317discussion of defaults and other ways of specifying the
318entry point.
f22eee08 319
c653b370 320@cindex dynamic symbol table
7ec9d825 321@kindex -E
9fde46a4 322@kindex --export-dynamic
7ec9d825 323@item -E
9fde46a4 324@itemx --export-dynamic
67afbcea
DE
325When creating a dynamically linked executable, add all symbols to the
326dynamic symbol table. Normally, the dynamic symbol table contains only
327symbols which are used by a dynamic object. This option is needed for
328some uses of @code{dlopen}.
c653b370 329
de220cbd
ILT
330@kindex -f
331@kindex --auxiliary
332@item -f
333@itemx --auxiliary @var{name}
334When creating an ELF shared object, set the internal DT_AUXILIARY field
335to the specified name. This tells the dynamic linker that the symbol
336table of the shared object should be used as an auxiliary filter on the
337symbol table of the shared object @var{name}.
338
2c5c0674 339@kindex -F
de220cbd
ILT
340@kindex --filter
341@item -F @var{name}
342@itemx --filter @var{name}
343When creating an ELF shared object, set the internal DT_FILTER field to
344the specified name. This tells the dynamic linker that the symbol table
345of the shared object should be used as a filter on the symbol table of
346the shared object @var{name}.
347
348Some older linkers used the @code{-F} option throughout a compilation
ec40bbb8 349toolchain for specifying object-file format for both input and output
de220cbd
ILT
350object files. The @sc{gnu} linker uses other mechanisms for this
351purpose: the @code{-b}, @code{--format}, @code{--oformat} options, the
352@code{TARGET} command in linker scripts, and the @code{GNUTARGET}
353environment variable. The @sc{gnu} linker will ignore the @code{-F}
354option when not creating an ELF shared object.
2c5c0674 355
a1d393cf
ILT
356@kindex --force-exe-suffix
357@item --force-exe-suffix
358Make sure that an output file has a .exe suffix.
359
360If a successfully built fully linked output file does not have a
361@code{.exe} or @code{.dll} suffix, this option forces the linker to copy
362the output file to one of the same name with a @code{.exe} suffix. This
363option is useful when using unmodified Unix makefiles on a Microsoft
364Windows host, since some versions of Windows won't run an image unless
365it ends in a @code{.exe} suffix.
366
2c5c0674 367@kindex -g
b4d4e8e3 368@item -g
ec40bbb8 369Ignored. Provided for compatibility with other tools.
b4d4e8e3 370
8ddef552 371@kindex -G
67afbcea 372@kindex --gpsize
8ddef552
DM
373@cindex object size
374@item -G@var{value}
67afbcea 375@itemx --gpsize=@var{value}
8ddef552 376Set the maximum size of objects to be optimized using the GP register to
67afbcea
DE
377@var{size}. This is only meaningful for object file formats such as
378MIPS ECOFF which supports putting large and small objects into different
379sections. This is ignored for other object file formats.
8ddef552 380
67afbcea
DE
381@cindex runtime library name
382@kindex -h@var{name}
383@kindex -soname=@var{name}
384@item -h@var{name}
385@itemx -soname=@var{name}
386When creating an ELF shared object, set the internal DT_SONAME field to
387the specified name. When an executable is linked with a shared object
388which has a DT_SONAME field, then when the executable is run the dynamic
389linker will attempt to load the shared object specified by the DT_SONAME
390field rather than the using the file name given to the linker.
de87cdb4 391
2c5c0674
RP
392@kindex -i
393@cindex incremental link
f22eee08 394@item -i
ec40bbb8 395Perform an incremental link (same as option @samp{-r}).
f22eee08 396
2c5c0674 397@cindex archive files, from cmd line
de87cdb4 398@kindex -l@var{archive}
67afbcea
DE
399@kindex --library=@var{archive}
400@item -l@var{archive}
401@itemx --library=@var{archive}
402Add archive file @var{archive} to the list of files to link. This
f22eee08 403option may be used any number of times. @code{ld} will search its
67afbcea 404path-list for occurrences of @code{lib@var{archive}.a} for every
4164f2d5
ILT
405@var{archive} specified.
406
407On systems which support shared libraries, @code{ld} may also search for
408libraries with extensions other than @code{.a}. Specifically, on ELF
409and SunOS systems, @code{ld} will search a directory for a library with
410an extension of @code{.so} before searching for one with an extension of
411@code{.a}. By convention, a @code{.so} extension indicates a shared
412library.
f22eee08 413
b61364cc
ILT
414The linker will search an archive only once, at the location where it is
415specified on the command line. If the archive defines a symbol which
416was undefined in some object which appeared before the archive on the
417command line, the linker will include the appropriate file(s) from the
418archive. However, an undefined symbol in an object appearing later on
419the command line will not cause the linker to search the archive again.
420
421See the @code{-(} option for a way to force the linker to search
422archives multiple times.
423
424You may list the same archive multiple times on the command line.
425
426@ifset GENERIC
427This type of archive searching is standard for Unix linkers. However,
428if you are using @code{ld} on AIX, note that it is different from the
429behaviour of the AIX linker.
430@end ifset
431
2c5c0674
RP
432@cindex search directory, from cmd line
433@kindex -L@var{dir}
67afbcea 434@kindex --library-path=@var{dir}
b4d4e8e3 435@item -L@var{searchdir}
67afbcea 436@itemx --library-path=@var{searchdir}
ec40bbb8 437Add path @var{searchdir} to the list of paths that @code{ld} will search
8ddef552 438for archive libraries and @code{ld} control scripts. You may use this
0b0642d6
ILT
439option any number of times. The directories are searched in the order
440in which they are specified on the command line. Directories specified
441on the command line are searched before the default directories. All
442@code{-L} options apply to all @code{-l} options, regardless of the
443order in which the options appear.
f22eee08 444
ec40bbb8 445@ifset UsesEnvVars
2c5c0674 446The default set of paths searched (without being specified with
ec40bbb8
DM
447@samp{-L}) depends on which emulation mode @code{ld} is using, and in
448some cases also on how it was configured. @xref{Environment}.
449@end ifset
450
451The paths can also be specified in a link script with the
0b0642d6
ILT
452@code{SEARCH_DIR} command. Directories specified this way are searched
453at the point in which the linker script appears in the command line.
f22eee08 454
8ddef552
DM
455@cindex emulation
456@kindex -m @var{emulation}
457@item -m@var{emulation}
8ddef552 458Emulate the @var{emulation} linker. You can list the available
01bc8f35
ILT
459emulations with the @samp{--verbose} or @samp{-V} options. The default
460depends on how your @code{ld} was configured.
8ddef552 461
67afbcea
DE
462@cindex link map
463@kindex -M
464@kindex --print-map
465@item -M
466@itemx --print-map
467Print (to the standard output) a link map---diagnostic information about
468where symbols are mapped by @code{ld}, and information on global common
469storage allocation.
470
471@kindex -n
472@cindex read-only text
473@cindex NMAGIC
474@kindex --nmagic
475@item -n
476@itemx --nmagic
477Set the text segment to be read only, and mark the output as
478@code{NMAGIC} if possible.
479
2c5c0674 480@kindex -N
67afbcea 481@kindex --omagic
2c5c0674 482@cindex read/write from cmd line
67afbcea 483@cindex OMAGIC
f22eee08 484@item -N
67afbcea 485@itemx --omagic
ec40bbb8
DM
486Set the text and data sections to be readable and writable. Also, do
487not page-align the data segment. If the output format supports Unix
488style magic numbers, mark the output as @code{OMAGIC}.
f22eee08 489
67afbcea
DE
490@kindex -o @var{output}
491@kindex --output=@var{output}
492@cindex naming the output file
493@item -o @var{output}
494@itemx --output=@var{output}
495Use @var{output} as the name for the program produced by @code{ld}; if this
496option is not specified, the name @file{a.out} is used by default. The
497script command @code{OUTPUT} can also specify the output file name.
f22eee08 498
67afbcea
DE
499@cindex partial link
500@cindex relocatable output
501@kindex -r
502@kindex --relocateable
503@item -r
504@itemx --relocateable
505Generate relocatable output---i.e., generate an output file that can in
506turn serve as input to @code{ld}. This is often called @dfn{partial
507linking}. As a side effect, in environments that support standard Unix
508magic numbers, this option also sets the output file's magic number to
509@code{OMAGIC}.
510@c ; see @code{-N}.
511If this option is not specified, an absolute file is produced. When
512linking C++ programs, this option @emph{will not} resolve references to
513constructors; to do that, use @samp{-Ur}.
514
515This option does the same thing as @samp{-i}.
516
517@kindex -R @var{file}
518@kindex --just-symbols=@var{file}
519@cindex symbol-only input
520@item -R @var{filename}
521@itemx --just-symbols=@var{filename}
522Read symbol names and their addresses from @var{filename}, but do not
523relocate it or include it in the output. This allows your output file
524to refer symbolically to absolute locations of memory defined in other
525programs. You may use this option more than once.
526
527For compatibility with other ELF linkers, if the @code{-R} option is
528followed by a directory name, rather than a file name, it is treated as
529the @code{-rpath} option.
530
531@kindex -s
532@kindex --strip-all
533@cindex strip all symbols
534@item -s
535@itemx --strip-all
536Omit all symbol information from the output file.
537
538@kindex -S
539@kindex --strip-debug
540@cindex strip debugger symbols
541@item -S
542@itemx --strip-debug
543Omit debugger symbol information (but not all symbols) from the output file.
544
545@kindex -t
546@kindex --trace
547@cindex input files, displaying
548@item -t
549@itemx --trace
550Print the names of the input files as @code{ld} processes them.
551
552@kindex -T @var{script}
553@kindex --script=@var{script}
554@cindex script files
555@item -T @var{commandfile}
556@itemx --script=@var{commandfile}
557Read link commands from the file @var{commandfile}. These commands
558replace @code{ld}'s default link script (rather than adding
559to it), so @var{commandfile} must specify everything necessary to describe
560the target format. @xref{Commands}. If @var{commandfile} does not
561exist, @code{ld} looks for it in the directories specified by any
562preceding @samp{-L} options. Multiple @samp{-T} options accumulate.
563
564@kindex -u @var{symbol}
565@kindex --undefined=@var{symbol}
566@cindex undefined symbol
567@item -u @var{symbol}
568@itemx --undefined=@var{symbol}
569Force @var{symbol} to be entered in the output file as an undefined symbol.
570Doing this may, for example, trigger linking of additional modules from
571standard libraries. @samp{-u} may be repeated with different option
572arguments to enter additional undefined symbols.
573@c Nice idea, but no such command: This option is equivalent
574@c to the @code{EXTERN} linker command.
575
576@kindex -v
577@kindex -V
578@kindex --version
579@cindex version
580@item -v
581@itemx --version
582@itemx -V
583Display the version number for @code{ld}. The @code{-V} option also
584lists the supported emulations.
585
586@kindex -x
587@kindex --discard-all
588@cindex deleting local symbols
589@item -x
590@itemx --discard-all
591Delete all local symbols.
592
593@kindex -X
594@kindex --discard-locals
595@cindex local symbols, deleting
596@cindex L, deleting symbols beginning
597@item -X
598@itemx --discard-locals
599Delete all temporary local symbols. For most targets, this is all local
600symbols whose names begin with @samp{L}.
601
602@kindex -y @var{symbol}
603@kindex --trace-symbol=@var{symbol}
604@cindex symbol tracing
605@item -y @var{symbol}
606@itemx --trace-symbol=@var{symbol}
607Print the name of each linked file in which @var{symbol} appears. This
608option may be given any number of times. On many systems it is necessary
609to prepend an underscore.
610
611This option is useful when you have an undefined symbol in your link but
612don't know where the reference is coming from.
613
614@kindex -Y @var{path}
615@item -Y @var{path}
616Add @var{path} to the default library search path. This option exists
617for Solaris compatibility.
618
619@kindex -z @var{keyword}
620@item -z @var{keyword}
621This option is ignored for Solaris compatibility.
622
623@kindex -(
624@cindex groups of archives
625@item -( @var{archives} -)
626@itemx --start-group @var{archives} --end-group
627The @var{archives} should be a list of archive files. They may be
628either explicit file names, or @samp{-l} options.
629
630The specified archives are searched repeatedly until no new undefined
631references are created. Normally, an archive is searched only once in
632the order that it is specified on the command line. If a symbol in that
633archive is needed to resolve an undefined symbol referred to by an
634object in an archive that appears later on the command line, the linker
635would not be able to resolve that reference. By grouping the archives,
636they all be searched repeatedly until all possible references are
637resolved.
638
639Using this option has a significant performance cost. It is best to use
640it only when there are unavoidable circular references between two or
641more archives.
642
643@kindex -assert @var{keyword}
644@item -assert @var{keyword}
645This option is ignored for SunOS compatibility.
646
647@kindex -Bdynamic
648@kindex -dy
649@kindex -call_shared
650@item -Bdynamic
651@itemx -dy
652@itemx -call_shared
653Link against dynamic libraries. This is only meaningful on platforms
654for which shared libraries are supported. This option is normally the
655default on such platforms. The different variants of this option are
656for compatibility with various systems. You may use this option
657multiple times on the command line: it affects library searching for
658@code{-l} options which follow it.
659
660@kindex -Bstatic
661@kindex -dn
662@kindex -non_shared
663@kindex -static
664@item -Bstatic
665@itemx -dn
666@itemx -non_shared
667@itemx -static
668Do not link against shared libraries. This is only meaningful on
669platforms for which shared libraries are supported. The different
670variants of this option are for compatibility with various systems. You
671may use this option multiple times on the command line: it affects
672library searching for @code{-l} options which follow it.
673
674@kindex -Bsymbolic
675@item -Bsymbolic
676When creating a shared library, bind references to global symbols to the
677definition within the shared library, if any. Normally, it is possible
678for a program linked against a shared library to override the definition
679within the shared library. This option is only meaningful on ELF
680platforms which support shared libraries.
681
86bc0974
ILT
682@cindex cross reference table
683@kindex --cref
684@item --cref
685Output a cross reference table. If a linker map file is being
686generated, the cross reference table is printed to the map file.
687Otherwise, it is printed on the standard output.
688
689The format of the table is intentionally simple, so that it may be
690easily processed by a script if necessary. The symbols are printed out,
691sorted by name. For each symbol, a list of file names is given. If the
692symbol is defined, the first file listed is the location of the
693definition. The remaining files contain references to the symbol.
694
67afbcea
DE
695@cindex symbols, from command line
696@kindex --defsym @var{symbol}=@var{exp}
697@item --defsym @var{symbol}=@var{expression}
698Create a global symbol in the output file, containing the absolute
699address given by @var{expression}. You may use this option as many
700times as necessary to define multiple symbols in the command line. A
701limited form of arithmetic is supported for the @var{expression} in this
702context: you may give a hexadecimal constant or the name of an existing
703symbol, or use @code{+} and @code{-} to add or subtract hexadecimal
704constants or symbols. If you need more elaborate expressions, consider
705using the linker command language from a script (@pxref{Assignment, ,
706Assignment: Symbol Definitions}). @emph{Note:} there should be no
707white space between @var{symbol}, the equals sign (``@key{=}''), and
708@var{expression}.
709
710@cindex dynamic linker, from command line
711@kindex --dynamic-linker @var{file}
712@item --dynamic-linker @var{file}
713Set the name of the dynamic linker. This is only meaningful when
714generating dynamically linked ELF executables. The default dynamic
715linker is normally correct; don't use this unless you know what you are
716doing.
717
718@cindex big-endian objects
719@cindex endianness
720@kindex -EB
721@item -EB
722Link big-endian objects. This affects the default output format.
723
724@cindex little-endian objects
725@kindex -EL
726@item -EL
727Link little-endian objects. This affects the default output format.
728
729@cindex MIPS embedded PIC code
9fde46a4
ILT
730@kindex --embedded-relocs
731@item --embedded-relocs
67afbcea
DE
732This option is only meaningful when linking MIPS embedded PIC code,
733generated by the -membedded-pic option to the @sc{gnu} compiler and
734assembler. It causes the linker to create a table which may be used at
735runtime to relocate any data which was statically initialized to pointer
736values. See the code in testsuite/ld-empic for details.
737
738@cindex help
739@cindex usage
740@kindex --help
741@item --help
742Print a summary of the command-line options on the standard output and exit.
743
744@cindex link map
745@kindex -Map
746@item -Map @var{mapfile}
747Print to the file @var{mapfile} a link map---diagnostic information
748about where symbols are mapped by @code{ld}, and information on global
749common storage allocation.
b4d4e8e3 750
4551e108 751@cindex memory usage
67afbcea
DE
752@kindex --no-keep-memory
753@item --no-keep-memory
4551e108
ILT
754@code{ld} normally optimizes for speed over memory usage by caching the
755symbol tables of input files in memory. This option tells @code{ld} to
756instead optimize for memory usage, by rereading the symbol tables as
757necessary. This may be required if @code{ld} runs out of memory space
758while linking a large executable.
759
67afbcea
DE
760@kindex --no-whole-archive
761@item --no-whole-archive
762Turn off the effect of the @code{--whole-archive} option for subsequent
763archive files.
764
765@cindex output file after errors
766@kindex --noinhibit-exec
767@item --noinhibit-exec
768Retain the executable output file whenever it is still usable.
769Normally, the linker will not produce an output file if it encounters
770errors during the link process; it exits without writing an output file
771when it issues any error whatsoever.
f22eee08 772
7f9ae73e 773@ifclear SingleFormat
9fde46a4
ILT
774@kindex --oformat
775@item --oformat @var{output-format}
1fb57a5d
RP
776@code{ld} may be configured to support more than one kind of object
777file. If your @code{ld} is configured this way, you can use the
9fde46a4 778@samp{--oformat} option to specify the binary format for the output
1fb57a5d
RP
779object file. Even when @code{ld} is configured to support alternative
780object formats, you don't usually need to specify this, as @code{ld}
781should be configured to produce as a default output format the most
782usual format on each machine. @var{output-format} is a text string, the
783name of a particular format supported by the BFD libraries. (You can
784list the available binary formats with @samp{objdump -i}.) The script
785command @code{OUTPUT_FORMAT} can also specify the output format, but
786this option overrides it. @xref{BFD}.
7f9ae73e 787@end ifclear
346535cc 788
67afbcea
DE
789@kindex -qmagic
790@item -qmagic
791This option is ignored for Linux compatibility.
c653b370 792
67afbcea
DE
793@kindex -Qy
794@item -Qy
795This option is ignored for SVR4 compatibility.
c653b370 796
67afbcea 797@kindex --relax
1c48127e
RP
798@cindex synthesizing linker
799@cindex relaxing addressing modes
67afbcea 800@item --relax
1fb57a5d
RP
801An option with machine dependent effects.
802@ifset GENERIC
67afbcea 803This option is only supported on a few targets.
1fb57a5d 804@end ifset
ec40bbb8
DM
805@ifset H8300
806@xref{H8/300,,@code{ld} and the H8/300}.
807@end ifset
1fb57a5d
RP
808@ifset I960
809@xref{i960,, @code{ld} and the Intel 960 family}.
810@end ifset
1c48127e 811
67afbcea
DE
812On some platforms, the @samp{--relax} option performs global
813optimizations that become possible when the linker resolves addressing
814in the program, such as relaxing address modes and synthesizing new
815instructions in the output object file.
1c48127e 816
1fb57a5d 817@ifset GENERIC
9fde46a4
ILT
818On platforms where this is not supported, @samp{--relax} is accepted,
819but ignored.
1fb57a5d 820@end ifset
1c48127e 821
7c8fab26
RP
822@cindex retaining specified symbols
823@cindex stripping all but some symbols
824@cindex symbols, retaining selectively
67afbcea 825@item --retain-symbols-file @var{filename}
7c8fab26
RP
826Retain @emph{only} the symbols listed in the file @var{filename},
827discarding all others. @var{filename} is simply a flat file, with one
828symbol name per line. This option is especially useful in environments
829@ifset GENERIC
830(such as VxWorks)
831@end ifset
832where a large global symbol table is accumulated gradually, to conserve
833run-time memory.
834
9fde46a4 835@samp{--retain-symbols-file} does @emph{not} discard undefined symbols,
7c8fab26
RP
836or symbols needed for relocations.
837
9fde46a4 838You may only specify @samp{--retain-symbols-file} once in the command
7c8fab26
RP
839line. It overrides @samp{-s} and @samp{-S}.
840
a1ad915d
ILT
841@ifset GENERIC
842@item -rpath @var{dir}
843@cindex runtime library search path
844@kindex -rpath
0b0642d6
ILT
845Add a directory to the runtime library search path. This is used when
846linking an ELF executable with shared objects. All @code{-rpath}
847arguments are concatenated and passed to the runtime linker, which uses
e54bf1c1
ILT
848them to locate shared objects at runtime. The @code{-rpath} option is
849also used when locating shared objects which are needed by shared
850objects explicitly included in the link; see the description of the
c653b370
ILT
851@code{-rpath-link} option. If @code{-rpath} is not used when linking an
852ELF executable, the contents of the environment variable
853@code{LD_RUN_PATH} will be used if it is defined.
0b0642d6
ILT
854
855The @code{-rpath} option may also be used on SunOS. By default, on
856SunOS, the linker will form a runtime search patch out of all the
e54bf1c1 857@code{-L} options it is given. If a @code{-rpath} option is used, the
0b0642d6
ILT
858runtime search path will be formed exclusively using the @code{-rpath}
859options, ignoring the @code{-L} options. This can be useful when using
860gcc, which adds many @code{-L} options which may be on NFS mounted
861filesystems.
c653b370
ILT
862
863For compatibility with other ELF linkers, if the @code{-R} option is
864followed by a directory name, rather than a file name, it is treated as
865the @code{-rpath} option.
a1ad915d
ILT
866@end ifset
867
e54bf1c1
ILT
868@ifset GENERIC
869@cindex link-time runtime library search path
870@kindex -rpath-link
871@item -rpath-link @var{DIR}
872When using ELF or SunOS, one shared library may require another. This
873happens when an @code{ld -shared} link includes a shared library as one
874of the input files.
875
876When the linker encounters such a dependency when doing a non-shared,
877non-relocateable link, it will automatically try to locate the required
878shared library and include it in the link, if it is not included
879explicitly. In such a case, the @code{-rpath-link} option
880specifies the first set of directories to search. The
881@code{-rpath-link} option may specify a sequence of directory names
882either by specifying a list of names separated by colons, or by
883appearing multiple times.
884
885The linker uses the following search paths to locate required shared
886libraries.
887@enumerate
888@item
889Any directories specified by @code{-rpath-link} options.
890@item
891Any directories specified by @code{-rpath} options. The difference
892between @code{-rpath} and @code{-rpath-link} is that directories
893specified by @code{-rpath} options are included in the executable and
894used at runtime, whereas the @code{-rpath-link} option is only effective
895at link time.
896@item
c653b370
ILT
897On an ELF system, if the @code{-rpath} and @code{rpath-link} options
898were not used, search the contents of the environment variable
899@code{LD_RUN_PATH}.
900@item
e54bf1c1
ILT
901On SunOS, if the @code{-rpath} option was not used, search any
902directories specified using @code{-L} options.
903@item
904For a native linker, the contents of the environment variable
905@code{LD_LIBRARY_PATH}.
906@item
907The default directories, normally @file{/lib} and @file{/usr/lib}.
908@end enumerate
909
910If the required shared library is not found, the linker will issue a
911warning and continue with the link.
912@end ifset
913
67afbcea
DE
914@kindex -shared
915@kindex -Bshareable
4551e108 916@item -shared
67afbcea 917@itemx -Bshareable
4551e108 918@cindex shared libraries
67afbcea
DE
919Create a shared library. This is currently only supported on ELF, XCOFF
920and SunOS platforms. On SunOS, the linker will automatically create a
e54bf1c1
ILT
921shared library if the @code{-e} option is not used and there are
922undefined symbols in the link.
4551e108 923
67afbcea
DE
924@item --sort-common
925@kindex --sort-common
926This option tells @code{ld} to sort the common symbols by size when it
927places them in the appropriate output sections. First come all the one
928byte symbols, then all the two bytes, then all the four bytes, and then
929everything else. This is to prevent gaps between symbols due to
930alignment constraints.
931
932@kindex --split-by-file
933@item --split-by-file
934Similar to @code{--split-by-reloc} but creates a new output section for
935each input file.
936
937@kindex --split-by-reloc
938@item --split-by-reloc @var{count}
939Trys to creates extra sections in the output file so that no single
940output section in the file contains more than @var{count} relocations.
941This is useful when generating huge relocatable for downloading into
942certain real time kernels with the COFF object file format; since COFF
943cannot represent more than 65535 relocations in a single section. Note
944that this will fail to work with object file formats which do not
945support arbitrary sections. The linker will not split up individual
946input sections for redistribution, so if a single input section contains
01bc8f35
ILT
947more than @var{count} relocations one output section will contain that
948many relocations.
949
67afbcea
DE
950@kindex --stats
951@item --stats
952Compute and display statistics about the operation of the linker, such
953as execution time and memory usage.
f22eee08 954
9fde46a4 955@kindex --traditional-format
c96386c4 956@cindex traditional format
9fde46a4 957@item --traditional-format
c96386c4
ILT
958For some targets, the output of @code{ld} is different in some ways from
959the output of some existing linker. This switch requests @code{ld} to
960use the traditional format instead.
961
962@cindex dbx
963For example, on SunOS, @code{ld} combines duplicate entries in the
964symbol string table. This can reduce the size of an output file with
965full debugging information by over 30 percent. Unfortunately, the SunOS
966@code{dbx} program can not read the resulting program (@code{gdb} has no
9fde46a4 967trouble). The @samp{--traditional-format} switch tells @code{ld} to not
c96386c4
ILT
968combine duplicate entries.
969
67afbcea
DE
970@kindex -Tbss @var{org}
971@kindex -Tdata @var{org}
972@kindex -Ttext @var{org}
973@cindex segment origins, cmd line
974@item -Tbss @var{org}
975@itemx -Tdata @var{org}
976@itemx -Ttext @var{org}
977Use @var{org} as the starting address for---respectively---the
978@code{bss}, @code{data}, or the @code{text} segment of the output file.
979@var{org} must be a single hexadecimal integer;
980for compatibility with other linkers, you may omit the leading
981@samp{0x} usually associated with hexadecimal values.
f22eee08 982
2c5c0674 983@kindex -Ur
b4d4e8e3 984@cindex constructors
d4e5e3c3 985@item -Ur
b4d4e8e3 986For anything other than C++ programs, this option is equivalent to
ec40bbb8
DM
987@samp{-r}: it generates relocatable output---i.e., an output file that can in
988turn serve as input to @code{ld}. When linking C++ programs, @samp{-Ur}
1fb57a5d 989@emph{does} resolve references to constructors, unlike @samp{-r}.
3e27cc11 990It does not work to use @samp{-Ur} on files that were themselves linked
1fb57a5d 991with @samp{-Ur}; once the constructor table has been built, it cannot
3e27cc11
DM
992be added to. Use @samp{-Ur} only for the last partial link, and
993@samp{-r} for the others.
b4d4e8e3 994
01bc8f35 995@kindex --verbose
cf2e4f5f 996@cindex verbose
01bc8f35 997@item --verbose
1fb57a5d 998Display the version number for @code{ld} and list the linker emulations
cf2e4f5f
ILT
999supported. Display which input files can and cannot be opened. Display
1000the linker script if using a default builtin script.
8ddef552 1001
458fc056 1002@kindex --warn-comon
7f9ae73e
RP
1003@cindex warnings, on combining symbols
1004@cindex combining symbols, warnings on
458fc056 1005@item --warn-common
2a28d8b0
DM
1006Warn when a common symbol is combined with another common symbol or with
1007a symbol definition. Unix linkers allow this somewhat sloppy practice,
1008but linkers on some other operating systems do not. This option allows
1009you to find potential problems from combining global symbols.
1cd4cca9
DM
1010Unfortunately, some C libraries use this practice, so you may get some
1011warnings about symbols in the libraries as well as in your programs.
2a28d8b0
DM
1012
1013There are three kinds of global symbols, illustrated here by C examples:
1014
1015@table @samp
1016@item int i = 1;
1017A definition, which goes in the initialized data section of the output
1018file.
1019
1020@item extern int i;
1021An undefined reference, which does not allocate space.
1022There must be either a definition or a common symbol for the
1023variable somewhere.
1024
1025@item int i;
1026A common symbol. If there are only (one or more) common symbols for a
1027variable, it goes in the uninitialized data area of the output file.
1028The linker merges multiple common symbols for the same variable into a
1029single symbol. If they are of different sizes, it picks the largest
1030size. The linker turns a common symbol into a declaration, if there is
1031a definition of the same variable.
1032@end table
1033
458fc056
ILT
1034The @samp{--warn-common} option can produce five kinds of warnings.
1035Each warning consists of a pair of lines: the first describes the symbol
1036just encountered, and the second describes the previous symbol
1037encountered with the same name. One or both of the two symbols will be
1038a common symbol.
2a28d8b0
DM
1039
1040@enumerate
1041@item
1042Turning a common symbol into a reference, because there is already a
1043definition for the symbol.
1044@smallexample
8920addc
RP
1045@var{file}(@var{section}): warning: common of `@var{symbol}'
1046 overridden by definition
2a28d8b0
DM
1047@var{file}(@var{section}): warning: defined here
1048@end smallexample
1049
1050@item
1051Turning a common symbol into a reference, because a later definition for
1052the symbol is encountered. This is the same as the previous case,
1053except that the symbols are encountered in a different order.
1054@smallexample
8920addc
RP
1055@var{file}(@var{section}): warning: definition of `@var{symbol}'
1056 overriding common
2a28d8b0
DM
1057@var{file}(@var{section}): warning: common is here
1058@end smallexample
1059
1060@item
1061Merging a common symbol with a previous same-sized common symbol.
1062@smallexample
8920addc
RP
1063@var{file}(@var{section}): warning: multiple common
1064 of `@var{symbol}'
2a28d8b0
DM
1065@var{file}(@var{section}): warning: previous common is here
1066@end smallexample
1067
1068@item
1069Merging a common symbol with a previous larger common symbol.
1070@smallexample
8920addc
RP
1071@var{file}(@var{section}): warning: common of `@var{symbol}'
1072 overridden by larger common
2a28d8b0
DM
1073@var{file}(@var{section}): warning: larger common is here
1074@end smallexample
1075
1076@item
1077Merging a common symbol with a previous smaller common symbol. This is
1078the same as the previous case, except that the symbols are
1079encountered in a different order.
1080@smallexample
8920addc
RP
1081@var{file}(@var{section}): warning: common of `@var{symbol}'
1082 overriding smaller common
2a28d8b0
DM
1083@var{file}(@var{section}): warning: smaller common is here
1084@end smallexample
1085@end enumerate
1086
458fc056
ILT
1087@kindex --warn-constructors
1088@item --warn-constructors
0b0642d6
ILT
1089Warn if any global constructors are used. This is only useful for a few
1090object file formats. For formats like COFF or ELF, the linker can not
1091detect the use of global constructors.
1092
458fc056
ILT
1093@kindex --warn-multiple-gp
1094@item --warn-multiple-gp
4b7d2399
ILT
1095Warn if multiple global pointer values are required in the output file.
1096This is only meaningful for certain processors, such as the Alpha.
1097Specifically, some processors put large-valued constants in a special
1098section. A special register (the global pointer) points into the middle
1099of this section, so that constants can be loaded efficiently via a
1100base-register relative addressing mode. Since the offset in
1101base-register relative mode is fixed and relatively small (e.g., 16
1102bits), this limits the maximum size of the constant pool. Thus, in
1103large programs, it is often necessary to use multiple global pointer
1104values in order to be able to address all possible constants. This
1105option causes a warning to be issued whenever this case occurs.
1106
458fc056 1107@kindex --warn-once
01bc8f35
ILT
1108@cindex warnings, on undefined symbols
1109@cindex undefined symbols, warnings on
458fc056 1110@item --warn-once
01bc8f35
ILT
1111Only warn once for each undefined symbol, rather than once per module
1112which refers to it.
1113
458fc056
ILT
1114@kindex --warn-section-align
1115@cindex warnings, on section alignment
1116@cindex section alignment, warnings on
1117@item --warn-section-align
1118Warn if the address of an output section is changed because of
1119alignment. Typically, the alignment will be set by an input section.
1120The address will only be changed if it not explicitly specified; that
1121is, if the @code{SECTIONS} command does not specify a start address for
1122the section (@pxref{SECTIONS}).
1123
4551e108
ILT
1124@kindex --whole-archive
1125@cindex including an entire archive
4b7d2399 1126@item --whole-archive
3c8deccc
ILT
1127For each archive mentioned on the command line after the
1128@code{--whole-archive} option, include every object file in the archive
1129in the link, rather than searching the archive for the required object
1130files. This is normally used to turn an archive file into a shared
1131library, forcing every object to be included in the resulting shared
67afbcea 1132library. This option may be used more than once.
4551e108 1133
e3d73386
ILT
1134@kindex --wrap
1135@item --wrap @var{symbol}
1136Use a wrapper function for @var{symbol}. Any undefined reference to
1137@var{symbol} will be resolved to @code{__wrap_@var{symbol}}. Any
1138undefined reference to @code{__real_@var{symbol}} will be resolved to
1139@var{symbol}.
1140
1141This can be used to provide a wrapper for a system function. The
1142wrapper function should be called @code{__wrap_@var{symbol}}. If it
1143wishes to call the system function, it should call
1144@code{__real_@var{symbol}}.
1145
1146Here is a trivial example:
1147
1148@smallexample
1149void *
1150__wrap_malloc (int c)
1151@{
1152 printf ("malloc called with %ld\n", c);
1153 return __real_malloc (c);
1154@}
1155@end smallexample
1156
1157If you link other code with this file using @code{--wrap malloc}, then
1158all calls to @code{malloc} will call the function @code{__wrap_malloc}
1159instead. The call to @code{__real_malloc} in @code{__wrap_malloc} will
1160call the real @code{malloc} function.
1161
1162You may wish to provide a @code{__real_malloc} function as well, so that
1163links without the @code{--wrap} option will succeed. If you do this,
1164you should not put the definition of @code{__real_malloc} in the same
1165file as @code{__wrap_malloc}; if you do, the assembler may resolve the
1166call before the linker has a chance to wrap it to @code{malloc}.
1167
f22eee08 1168@end table
b4d4e8e3 1169
ec40bbb8
DM
1170@ifset UsesEnvVars
1171@node Environment
2c5c0674
RP
1172@section Environment Variables
1173
d76ae847
RP
1174You can change the behavior of @code{ld} with the environment
1175variable @code{GNUTARGET}.
2c5c0674
RP
1176
1177@kindex GNUTARGET
1178@cindex default input format
1179@code{GNUTARGET} determines the input-file object format if you don't
9fde46a4 1180use @samp{-b} (or its synonym @samp{--format}). Its value should be one
2c5c0674 1181of the BFD names for an input format (@pxref{BFD}). If there is no
246504a5 1182@code{GNUTARGET} in the environment, @code{ld} uses the natural format
9fde46a4
ILT
1183of the target. If @code{GNUTARGET} is set to @code{default} then BFD
1184attempts to discover the input format by examining binary input files;
1185this method often succeeds, but there are potential ambiguities, since
1186there is no method of ensuring that the magic number used to specify
1187object-file formats is unique. However, the configuration procedure for
1188BFD on each system places the conventional format for that system first
1189in the search-list, so ambiguities are resolved in favor of convention.
ec40bbb8 1190@end ifset
2c5c0674 1191
ec40bbb8 1192@node Commands
2c5c0674 1193@chapter Command Language
f22eee08 1194
2c5c0674 1195@cindex command files
ec40bbb8 1196The command language provides explicit control over the link process,
b4d4e8e3 1197allowing complete specification of the mapping between the linker's
ec40bbb8 1198input files and its output. It controls:
b4d4e8e3 1199@itemize @bullet
2c5c0674
RP
1200@item
1201input files
1202@item
1203file formats
1204@item
867a1b8a 1205output file layout
2c5c0674
RP
1206@item
1207addresses of sections
1208@item
1209placement of common blocks
b4d4e8e3 1210@end itemize
f22eee08 1211
2c5c0674 1212You may supply a command file (also known as a link script) to the
ec40bbb8 1213linker either explicitly through the @samp{-T} option, or implicitly as
2c5c0674 1214an ordinary file. If the linker opens a file which it cannot recognize
867a1b8a 1215as a supported object or archive format, it reports an error.
2c5c0674 1216
2c5c0674 1217@menu
2d59b2c3
RP
1218* Scripts:: Linker Scripts
1219* Expressions:: Expressions
1220* MEMORY:: MEMORY Command
1221* SECTIONS:: SECTIONS Command
c653b370 1222* PHDRS:: PHDRS Command
2d59b2c3 1223* Entry Point:: The Entry Point
867a1b8a 1224* Option Commands:: Option Commands
2c5c0674
RP
1225@end menu
1226
ec40bbb8 1227@node Scripts
b4d4e8e3 1228@section Linker Scripts
246504a5 1229The @code{ld} command language is a collection of statements; some are
ec40bbb8
DM
1230simple keywords setting a particular option, some are used to select and
1231group input files or name output files; and two statement
b4d4e8e3
RP
1232types have a fundamental and pervasive impact on the linking process.
1233
2c5c0674
RP
1234@cindex fundamental script commands
1235@cindex commands, fundamental
1236@cindex output file layout
1237@cindex layout of output file
246504a5 1238The most fundamental command of the @code{ld} command language is the
b4d4e8e3
RP
1239@code{SECTIONS} command (@pxref{SECTIONS}). Every meaningful command
1240script must have a @code{SECTIONS} command: it specifies a
1241``picture'' of the output file's layout, in varying degrees of detail.
1242No other command is required in all cases.
1243
1244The @code{MEMORY} command complements @code{SECTIONS} by describing the
2c5c0674 1245available memory in the target architecture. This command is optional;
246504a5 1246if you don't use a @code{MEMORY} command, @code{ld} assumes sufficient
2c5c0674
RP
1247memory is available in a contiguous block for all output.
1248@xref{MEMORY}.
b4d4e8e3 1249
2c5c0674
RP
1250@cindex comments
1251You may include comments in linker scripts just as in C: delimited
1252by @samp{/*} and @samp{*/}. As in C, comments are syntactically
1253equivalent to whitespace.
1254
ec40bbb8 1255@node Expressions
f22eee08 1256@section Expressions
2c5c0674
RP
1257@cindex expression syntax
1258@cindex arithmetic
b4d4e8e3
RP
1259Many useful commands involve arithmetic expressions. The syntax for
1260expressions in the command language is identical to that of C
1261expressions, with the following features:
1262@itemize @bullet
2c5c0674
RP
1263@item
1264All expressions evaluated as integers and
f22eee08 1265are of ``long'' or ``unsigned long'' type.
2c5c0674
RP
1266@item
1267All constants are integers.
1268@item
1269All of the C arithmetic operators are provided.
1270@item
1271You may reference, define, and create global variables.
1272@item
1273You may call special purpose built-in functions.
b4d4e8e3 1274@end itemize
f22eee08 1275
2c5c0674 1276@menu
2d59b2c3
RP
1277* Integers:: Integers
1278* Symbols:: Symbol Names
1279* Location Counter:: The Location Counter
1280* Operators:: Operators
1281* Evaluation:: Evaluation
1282* Assignment:: Assignment: Defining Symbols
867a1b8a 1283* Arithmetic Functions:: Built-In Functions
67afbcea 1284* Semicolons:: Semicolon Usage
2c5c0674
RP
1285@end menu
1286
ec40bbb8 1287@node Integers
f22eee08 1288@subsection Integers
2c5c0674
RP
1289@cindex integer notation
1290@cindex octal integers
f22eee08
RP
1291An octal integer is @samp{0} followed by zero or more of the octal
1292digits (@samp{01234567}).
c653b370 1293@smallexample
2c5c0674 1294_as_octal = 0157255;
c653b370 1295@end smallexample
f22eee08 1296
2c5c0674 1297@cindex decimal integers
f22eee08
RP
1298A decimal integer starts with a non-zero digit followed by zero or
1299more digits (@samp{0123456789}).
c653b370 1300@smallexample
2c5c0674 1301_as_decimal = 57005;
c653b370 1302@end smallexample
f22eee08 1303
2c5c0674
RP
1304@cindex hexadecimal integers
1305@kindex 0x
f22eee08
RP
1306A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
1307more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
c653b370 1308@smallexample
b4d4e8e3 1309_as_hex = 0xdead;
c653b370 1310@end smallexample
f22eee08 1311
2c5c0674 1312@cindex negative integers
ec40bbb8 1313To write a negative integer, use
baaaf6f2 1314the prefix operator @samp{-} (@pxref{Operators}).
c653b370 1315@smallexample
b4d4e8e3 1316_as_neg = -57005;
c653b370 1317@end smallexample
f22eee08 1318
2c5c0674
RP
1319@cindex scaled integers
1320@cindex K and M integer suffixes
1321@cindex M and K integer suffixes
1322@cindex suffixes for integers
1323@cindex integer suffixes
b4d4e8e3
RP
1324Additionally the suffixes @code{K} and @code{M} may be used to scale a
1325constant by
c8072296
RP
1326@c TEXI2ROFF-KILL
1327@ifinfo
1328@c END TEXI2ROFF-KILL
1329@code{1024} or @code{1024*1024}
1330@c TEXI2ROFF-KILL
1331@end ifinfo
f22eee08 1332@tex
b4d4e8e3 1333${\rm 1024}$ or ${\rm 1024}^2$
f22eee08 1334@end tex
c8072296 1335@c END TEXI2ROFF-KILL
ec40bbb8 1336respectively. For example, the following all refer to the same quantity:
f22eee08 1337
c653b370 1338@smallexample
2c5c0674
RP
1339 _fourk_1 = 4K;
1340 _fourk_2 = 4096;
1341 _fourk_3 = 0x1000;
c653b370 1342@end smallexample
b4d4e8e3 1343
ec40bbb8 1344@node Symbols
b4d4e8e3 1345@subsection Symbol Names
2c5c0674
RP
1346@cindex symbol names
1347@cindex names
1348@cindex quoted symbol names
1349@kindex "
1fb57a5d
RP
1350Unless quoted, symbol names start with a letter, underscore, or point
1351and may include any letters, underscores, digits, points,
1352and hyphens. Unquoted symbol names must not conflict with any
b4d4e8e3
RP
1353keywords. You can specify a symbol which contains odd characters or has
1354the same name as a keyword, by surrounding the symbol name in double quotes:
c653b370 1355@smallexample
b4d4e8e3
RP
1356 "SECTION" = 9;
1357 "with a space" = "also with a space" + 10;
c653b370 1358@end smallexample
b4d4e8e3 1359
1fb57a5d
RP
1360Since symbols can contain many non-alphabetic characters, it is safest
1361to delimit symbols with spaces. For example, @samp{A-B} is one symbol,
1362whereas @samp{A - B} is an expression involving subtraction.
1363
ec40bbb8 1364@node Location Counter
b4d4e8e3 1365@subsection The Location Counter
2c5c0674
RP
1366@kindex .
1367@cindex dot
1368@cindex location counter
1369@cindex current output location
b4d4e8e3
RP
1370The special linker variable @dfn{dot} @samp{.} always contains the
1371current output location counter. Since the @code{.} always refers to
1372a location in an output section, it must always appear in an
1373expression within a @code{SECTIONS} command. The @code{.} symbol
1374may appear anywhere that an ordinary symbol is allowed in an
1375expression, but its assignments have a side effect. Assigning a value
1376to the @code{.} symbol will cause the location counter to be moved.
2c5c0674 1377@cindex holes
b4d4e8e3
RP
1378This may be used to create holes in the output section. The location
1379counter may never be moved backwards.
c653b370 1380@smallexample
2c5c0674
RP
1381SECTIONS
1382@{
d4e5e3c3
DM
1383 output :
1384 @{
1385 file1(.text)
1386 . = . + 1000;
1387 file2(.text)
1388 . += 1000;
1389 file3(.text)
1390 @} = 0x1234;
2c5c0674 1391@}
c653b370 1392@end smallexample
2c5c0674
RP
1393@noindent
1394In the previous example, @code{file1} is located at the beginning of the
1395output section, then there is a 1000 byte gap. Then @code{file2}
1396appears, also with a 1000 byte gap following before @code{file3} is
1397loaded. The notation @samp{= 0x1234} specifies what data to write in
1398the gaps (@pxref{Section Options}).
b4d4e8e3 1399
d4e5e3c3
DM
1400@iftex
1401@vfill
1402@end iftex
1403
c653b370 1404@need 2000
ec40bbb8 1405@node Operators
f22eee08 1406@subsection Operators
2c5c0674
RP
1407@cindex Operators for arithmetic
1408@cindex arithmetic operators
1409@cindex precedence in expressions
b4d4e8e3 1410The linker recognizes the standard C set of arithmetic operators, with
f22eee08 1411the standard bindings and precedence levels:
c8072296 1412@c TEXI2ROFF-KILL
b4d4e8e3 1413@ifinfo
c8072296 1414@c END TEXI2ROFF-KILL
c653b370 1415@smallexample
c8072296 1416precedence associativity Operators Notes
b4d4e8e3 1417(highest)
c8072296
RP
14181 left ! - ~ (1)
14192 left * / %
14203 left + -
14214 left >> <<
14225 left == != > < <= >=
14236 left &
14247 left |
14258 left &&
14269 left ||
142710 right ? :
142811 right &= += -= *= /= (2)
b4d4e8e3 1429(lowest)
c653b370 1430@end smallexample
2c5c0674
RP
1431Notes:
1432(1) Prefix operators
baaaf6f2 1433(2) @xref{Assignment}.
c8072296 1434@c TEXI2ROFF-KILL
b4d4e8e3 1435@end ifinfo
f22eee08 1436@tex
2c5c0674 1437\vskip \baselineskip
feb20cfb 1438%"lispnarrowing" is the extra indent used generally for smallexample
2c5c0674 1439\hskip\lispnarrowing\vbox{\offinterlineskip
f22eee08
RP
1440\hrule
1441\halign
2c5c0674
RP
1442{\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ {\tt #}\ \hfil&\vrule#\cr
1443height2pt&\omit&&\omit&&\omit&\cr
1444&Precedence&& Associativity &&{\rm Operators}&\cr
1445height2pt&\omit&&\omit&&\omit&\cr
f22eee08 1446\noalign{\hrule}
2c5c0674 1447height2pt&\omit&&\omit&&\omit&\cr
b4d4e8e3 1448&highest&&&&&\cr
2c5c0674
RP
1449% '176 is tilde, '~' in tt font
1450&1&&left&&\qquad- \char'176\ !\qquad\dag&\cr
1451&2&&left&&* / \%&\cr
1452&3&&left&&+ -&\cr
1453&4&&left&&>> <<&\cr
1454&5&&left&&== != > < <= >=&\cr
f22eee08 1455&6&&left&&\&&\cr
f22eee08 1456&7&&left&&|&\cr
f22eee08 1457&8&&left&&{\&\&}&\cr
f22eee08 1458&9&&left&&||&\cr
2c5c0674
RP
1459&10&&right&&? :&\cr
1460&11&&right&&\qquad\&= += -= *= /=\qquad\ddag&\cr
b4d4e8e3 1461&lowest&&&&&\cr
2c5c0674 1462height2pt&\omit&&\omit&&\omit&\cr}
f22eee08
RP
1463\hrule}
1464@end tex
2c5c0674
RP
1465@iftex
1466{
1467@obeylines@parskip=0pt@parindent=0pt
1468@dag@quad Prefix operators.
1469@ddag@quad @xref{Assignment}.
1470}
1471@end iftex
c8072296 1472@c END TEXI2ROFF-KILL
f22eee08 1473
ec40bbb8 1474@node Evaluation
b4d4e8e3
RP
1475@subsection Evaluation
1476
2c5c0674
RP
1477@cindex lazy evaluation
1478@cindex expression evaluation order
b4d4e8e3
RP
1479The linker uses ``lazy evaluation'' for expressions; it only calculates
1480an expression when absolutely necessary. The linker needs the value of
1481the start address, and the lengths of memory regions, in order to do any
1482linking at all; these values are computed as soon as possible when the
1483linker reads in the command file. However, other values (such as symbol
1484values) are not known or needed until after storage allocation. Such
1485values are evaluated later, when other information (such as the sizes of
1486output sections) is available for use in the symbol assignment
1487expression.
1488
ec40bbb8 1489@node Assignment
b4d4e8e3 1490@subsection Assignment: Defining Symbols
2c5c0674
RP
1491@cindex assignment in scripts
1492@cindex symbol definition, scripts
1493@cindex variables, defining
b4d4e8e3
RP
1494You may create global symbols, and assign values (addresses) to global
1495symbols, using any of the C assignment operators:
1496
1497@table @code
1498@item @var{symbol} = @var{expression} ;
2c5c0674 1499@itemx @var{symbol} &= @var{expression} ;
b4d4e8e3
RP
1500@itemx @var{symbol} += @var{expression} ;
1501@itemx @var{symbol} -= @var{expression} ;
1502@itemx @var{symbol} *= @var{expression} ;
1503@itemx @var{symbol} /= @var{expression} ;
1504@end table
1505
246504a5 1506Two things distinguish assignment from other operators in @code{ld}
b4d4e8e3
RP
1507expressions.
1508@itemize @bullet
2c5c0674
RP
1509@item
1510Assignment may only be used at the root of an expression;
b4d4e8e3 1511@samp{a=b+3;} is allowed, but @samp{a+b=3;} is an error.
2c5c0674
RP
1512
1513@kindex ;
1514@cindex semicolon
1515@item
d76ae847
RP
1516You must place a trailing semicolon (``@key{;}'') at the end of an
1517assignment statement.
b4d4e8e3
RP
1518@end itemize
1519
1520Assignment statements may appear:
1521@itemize @bullet
2c5c0674 1522@item
246504a5 1523as commands in their own right in an @code{ld} script; or
2c5c0674
RP
1524@item
1525as independent statements within a @code{SECTIONS} command; or
1526@item
1527as part of the contents of a section definition in a
b4d4e8e3
RP
1528@code{SECTIONS} command.
1529@end itemize
1530
1531The first two cases are equivalent in effect---both define a symbol with
ec40bbb8 1532an absolute address. The last case defines a symbol whose address is
b4d4e8e3
RP
1533relative to a particular section (@pxref{SECTIONS}).
1534
2c5c0674
RP
1535@cindex absolute and relocatable symbols
1536@cindex relocatable and absolute symbols
1537@cindex symbols, relocatable and absolute
1538When a linker expression is evaluated and assigned to a variable, it is
1539given either an absolute or a relocatable type. An absolute expression
1540type is one in which the symbol contains the value that it will have in
867a1b8a 1541the output file; a relocatable expression type is one in which the
2c5c0674 1542value is expressed as a fixed offset from the base of a section.
b4d4e8e3
RP
1543
1544The type of the expression is controlled by its position in the script
2c5c0674
RP
1545file. A symbol assigned within a section definition is created relative
1546to the base of the section; a symbol assigned in any other place is
1547created as an absolute symbol. Since a symbol created within a
1548section definition is relative to the base of the section, it
1549will remain relocatable if relocatable output is requested. A symbol
1550may be created with an absolute value even when assigned to within a
1551section definition by using the absolute assignment function
1552@code{ABSOLUTE}. For example, to create an absolute symbol whose address
1553is the last byte of an output section named @code{.data}:
c653b370 1554@smallexample
2c5c0674 1555SECTIONS@{ @dots{}
d4e5e3c3
DM
1556 .data :
1557 @{
1558 *(.data)
1559 _edata = ABSOLUTE(.) ;
1560 @}
2c5c0674 1561@dots{} @}
c653b370 1562@end smallexample
b4d4e8e3 1563
2c5c0674
RP
1564The linker tries to put off the evaluation of an assignment until all
1565the terms in the source expression are known (@pxref{Evaluation}). For
ec40bbb8 1566instance, the sizes of sections cannot be known until after allocation,
2c5c0674
RP
1567so assignments dependent upon these are not performed until after
1568allocation. Some expressions, such as those depending upon the location
1569counter @dfn{dot}, @samp{.} must be evaluated during allocation. If the
1570result of an expression is required, but the value is not available,
1571then an error results. For example, a script like the following
c653b370 1572@smallexample
2c5c0674 1573SECTIONS @{ @dots{}
d4e5e3c3
DM
1574 text 9+this_isnt_constant :
1575 @{ @dots{}
1576 @}
2c5c0674 1577@dots{} @}
c653b370 1578@end smallexample
2c5c0674
RP
1579@kindex Non constant expression
1580@noindent
1581will cause the error message ``@code{Non constant expression for initial
0b3499f6
ILT
1582address}''.
1583
1584@cindex provide
1585In some cases, it is desirable for a linker script to define a symbol
1586only if it is referenced, and only if it is not defined by any object
1587included in the link. For example, traditional linkers defined the
1588symbol @samp{etext}. However, ANSI C requires that the user be able to
1589use @samp{etext} as a function name without encountering an error.
1590The @code{PROVIDE} keyword may be used to define a symbol, such as
1591@samp{etext}, only if it is referenced but not defined. The syntax is
1592@code{PROVIDE(@var{symbol} = @var{expression})}.
b4d4e8e3 1593
867a1b8a
DM
1594@node Arithmetic Functions
1595@subsection Arithmetic Functions
2c5c0674 1596@cindex functions in expression language
ec40bbb8 1597The command language includes a number of built-in
2c5c0674
RP
1598functions for use in link script expressions.
1599@table @code
2c5c0674
RP
1600@kindex ABSOLUTE(@var{exp})
1601@cindex expression, absolute
c653b370 1602@item ABSOLUTE(@var{exp})
ec40bbb8
DM
1603Return the absolute (non-relocatable, as opposed to non-negative) value
1604of the expression @var{exp}. Primarily useful to assign an absolute
1605value to a symbol within a section definition, where symbol values are
1606normally section-relative.
2c5c0674 1607
2c5c0674
RP
1608@kindex ADDR(@var{section})
1609@cindex section address
c653b370 1610@item ADDR(@var{section})
ec40bbb8 1611Return the absolute address of the named @var{section}. Your script must
b4d4e8e3 1612previously have defined the location of that section. In the following
ec40bbb8 1613example, @code{symbol_1} and @code{symbol_2} are assigned identical
b4d4e8e3 1614values:
c653b370
ILT
1615@smallexample
1616@group
2c5c0674 1617SECTIONS@{ @dots{}
d4e5e3c3
DM
1618 .output1 :
1619 @{
1620 start_of_output_1 = ABSOLUTE(.);
1621 @dots{}
1622 @}
1623 .output :
1624 @{
1625 symbol_1 = ADDR(.output1);
1626 symbol_2 = start_of_output_1;
1627 @}
2c5c0674 1628@dots{} @}
c653b370
ILT
1629@end group
1630@end smallexample
2c5c0674 1631
5735ac9e
ILT
1632@kindex LOADADDR(@var{section})
1633@cindex section load address
1634@item LOADADDR(@var{section})
1635Return the absolute load address of the named @var{section}. This is
1636normally the same as @code{ADDR}, but it may be different if the
1637@code{AT} keyword is used in the section definition (@pxref{Section
1638Options}).
1639
2c5c0674
RP
1640@kindex ALIGN(@var{exp})
1641@cindex rounding up location counter
c653b370 1642@item ALIGN(@var{exp})
ec40bbb8 1643Return the result of the current location counter (@code{.}) aligned to
2c5c0674
RP
1644the next @var{exp} boundary. @var{exp} must be an expression whose
1645value is a power of two. This is equivalent to
c653b370 1646@smallexample
cb70c872 1647(. + @var{exp} - 1) & ~(@var{exp} - 1)
c653b370 1648@end smallexample
2c5c0674
RP
1649
1650@code{ALIGN} doesn't change the value of the location counter---it just
1651does arithmetic on it. As an example, to align the output @code{.data}
1652section to the next @code{0x2000} byte boundary after the preceding
1653section and to set a variable within the section to the next
1654@code{0x8000} boundary after the input sections:
c653b370
ILT
1655@smallexample
1656@group
2c5c0674 1657SECTIONS@{ @dots{}
d4e5e3c3
DM
1658 .data ALIGN(0x2000): @{
1659 *(.data)
1660 variable = ALIGN(0x8000);
1661 @}
2c5c0674 1662@dots{} @}
c653b370
ILT
1663@end group
1664@end smallexample
2c5c0674
RP
1665@noindent
1666The first use of @code{ALIGN} in this example specifies the location of
1667a section because it is used as the optional @var{start} attribute of a
1668section definition (@pxref{Section Options}). The second use simply
1669defines the value of a variable.
1670
1671The built-in @code{NEXT} is closely related to @code{ALIGN}.
1672
2c5c0674
RP
1673@kindex DEFINED(@var{symbol})
1674@cindex symbol defaults
c653b370 1675@item DEFINED(@var{symbol})
ec40bbb8
DM
1676Return 1 if @var{symbol} is in the linker global symbol table and is
1677defined, otherwise return 0. You can use this function to provide default
1678values for symbols. For example, the following command-file fragment shows how
2c5c0674
RP
1679to set a global symbol @code{begin} to the first location in the
1680@code{.text} section---but if a symbol called @code{begin} already
1681existed, its value is preserved:
d4e5e3c3 1682
c8072296 1683@smallexample
c653b370 1684@group
2c5c0674 1685SECTIONS@{ @dots{}
d4e5e3c3
DM
1686 .text : @{
1687 begin = DEFINED(begin) ? begin : . ;
1688 @dots{}
1689 @}
2c5c0674 1690@dots{} @}
c653b370 1691@end group
c8072296 1692@end smallexample
f22eee08 1693
2c5c0674
RP
1694@kindex NEXT(@var{exp})
1695@cindex unallocated address, next
c653b370 1696@item NEXT(@var{exp})
ec40bbb8
DM
1697Return the next unallocated address that is a multiple of @var{exp}.
1698This function is closely related to @code{ALIGN(@var{exp})}; unless you
2c5c0674 1699use the @code{MEMORY} command to define discontinuous memory for the
ec40bbb8 1700output file, the two functions are equivalent.
2c5c0674 1701
2c5c0674
RP
1702@kindex SIZEOF(@var{section})
1703@cindex section size
c653b370 1704@item SIZEOF(@var{section})
ec40bbb8
DM
1705Return the size in bytes of the named @var{section}, if that section has
1706been allocated. In the following example, @code{symbol_1} and
f22eee08 1707@code{symbol_2} are assigned identical values:
ec40bbb8 1708@c What does it return if the section hasn't been allocated? 0?
c653b370
ILT
1709@smallexample
1710@group
2c5c0674 1711SECTIONS@{ @dots{}
d4e5e3c3
DM
1712 .output @{
1713 .start = . ;
1714 @dots{}
1715 .end = . ;
1716 @}
1717 symbol_1 = .end - .start ;
1718 symbol_2 = SIZEOF(.output);
2c5c0674 1719@dots{} @}
c653b370
ILT
1720@end group
1721@end smallexample
f22eee08 1722
2c5c0674
RP
1723@kindex SIZEOF_HEADERS
1724@cindex header size
2c5c0674 1725@kindex sizeof_headers
c653b370
ILT
1726@item SIZEOF_HEADERS
1727@itemx sizeof_headers
ec40bbb8 1728Return the size in bytes of the output file's headers. You can use this number
2c5c0674
RP
1729as the start address of the first section, if you choose, to facilitate
1730paging.
1731
b61364cc
ILT
1732@kindex MAX
1733@item MAX(@var{exp1}, @var{exp2})
1734Returns the maximum of @var{exp1} and @var{exp2}.
1735
1736@kindex MIN
1737@item MIN(@var{exp1}, @var{exp2})
1738Returns the minimum of @var{exp1} and @var{exp2}.
1739
2c5c0674
RP
1740@end table
1741
67afbcea
DE
1742@node Semicolons
1743@subsection Semicolons
1744
1745Semicolons (``@key{;}'') are required in the following places. In all
1746other places they can appear for aesthetic reasons but are otherwise ignored.
1747
1748@table @code
1749@item Assignment
1750Semicolons must appear at the end of assignment expressions.
1751@xref{Assignment}
1752
1753@item PHDRS
1754Semicolons must appear at the end of a @code{PHDRS} statement.
1755@xref{PHDRS}
1756@end table
1757
ec40bbb8 1758@node MEMORY
867a1b8a 1759@section Memory Layout
2c5c0674
RP
1760@kindex MEMORY
1761@cindex regions of memory
1762@cindex discontinuous memory
1763@cindex allocating memory
ec40bbb8
DM
1764The linker's default configuration permits allocation of all available memory.
1765You can override this configuration by using the @code{MEMORY} command. The
b4d4e8e3
RP
1766@code{MEMORY} command describes the location and size of blocks of
1767memory in the target. By using it carefully, you can describe which
1768memory regions may be used by the linker, and which memory regions it
1769must avoid. The linker does not shuffle sections to fit into the
1770available regions, but does move the requested sections into the correct
1771regions and issue errors when the regions become too full.
1772
867a1b8a 1773A command file may contain at most one use of the @code{MEMORY}
b4d4e8e3
RP
1774command; however, you can define as many blocks of memory within it as
1775you wish. The syntax is:
c8072296 1776
c653b370
ILT
1777@smallexample
1778@group
b4d4e8e3 1779MEMORY
d4e5e3c3
DM
1780 @{
1781 @var{name} (@var{attr}) : ORIGIN = @var{origin}, LENGTH = @var{len}
1782 @dots{}
1783 @}
c653b370
ILT
1784@end group
1785@end smallexample
f22eee08 1786@table @code
2c5c0674 1787@cindex naming memory regions
d4e5e3c3 1788@item @var{name}
f22eee08
RP
1789is a name used internally by the linker to refer to the region. Any
1790symbol name may be used. The region names are stored in a separate
ec40bbb8 1791name space, and will not conflict with symbols, file names or section
b4d4e8e3 1792names. Use distinct names to specify multiple regions.
d4e5e3c3 1793
2c5c0674 1794@cindex memory region attributes
d4e5e3c3 1795@item (@var{attr})
2c5c0674 1796is an optional list of attributes, permitted for compatibility with the
246504a5 1797AT&T linker but not used by @code{ld} beyond checking that the
2c5c0674
RP
1798attribute list is valid. Valid attribute lists must be made up of the
1799characters ``@code{LIRWX}''. If you omit the attribute list, you may
1800omit the parentheses around it as well.
d4e5e3c3 1801
cb70c872
RP
1802@kindex ORIGIN =
1803@kindex o =
1804@kindex org =
d4e5e3c3 1805@item @var{origin}
ec40bbb8
DM
1806is the start address of the region in physical memory. It is
1807an expression that must evaluate to a constant before
f22eee08 1808memory allocation is performed. The keyword @code{ORIGIN} may be
867a1b8a 1809abbreviated to @code{org} or @code{o} (but not, for example, @samp{ORG}).
d4e5e3c3 1810
cb70c872
RP
1811@kindex LENGTH =
1812@kindex len =
1813@kindex l =
d4e5e3c3 1814@item @var{len}
b4d4e8e3 1815is the size in bytes of the region (an expression).
2c5c0674 1816The keyword @code{LENGTH} may be abbreviated to @code{len} or @code{l}.
f22eee08
RP
1817@end table
1818
1819For example, to specify that memory has two regions available for
ec40bbb8 1820allocation---one starting at 0 for 256 kilobytes, and the other
2c5c0674 1821starting at @code{0x40000000} for four megabytes:
f22eee08 1822
c653b370
ILT
1823@smallexample
1824@group
b4d4e8e3 1825MEMORY
d4e5e3c3
DM
1826 @{
1827 rom : ORIGIN = 0, LENGTH = 256K
1828 ram : org = 0x40000000, l = 4M
1829 @}
c653b370
ILT
1830@end group
1831@end smallexample
f22eee08 1832
b4d4e8e3 1833Once you have defined a region of memory named @var{mem}, you can direct
2c5c0674
RP
1834specific output sections there by using a command ending in
1835@samp{>@var{mem}} within the @code{SECTIONS} command (@pxref{Section
1836Options}). If the combined output sections directed to a region are too
1837big for the region, the linker will issue an error message.
b4d4e8e3 1838
ec40bbb8 1839@node SECTIONS
867a1b8a 1840@section Specifying Output Sections
67c4333b 1841
2c5c0674 1842@kindex SECTIONS
b4d4e8e3 1843The @code{SECTIONS} command controls exactly where input sections are
867a1b8a
DM
1844placed into output sections, their order in the output file, and to
1845which output sections they are allocated.
b4d4e8e3 1846
867a1b8a 1847You may use at most one @code{SECTIONS} command in a script file,
b4d4e8e3
RP
1848but you can have as many statements within it as you wish. Statements
1849within the @code{SECTIONS} command can do one of three things:
67c4333b 1850
b4d4e8e3
RP
1851@itemize @bullet
1852@item
1853define the entry point;
67c4333b 1854
b4d4e8e3
RP
1855@item
1856assign a value to a symbol;
67c4333b 1857
b4d4e8e3 1858@item
867a1b8a
DM
1859describe the placement of a named output section, and which input
1860sections go into it.
b4d4e8e3
RP
1861@end itemize
1862
8920addc
RP
1863You can also use the first two operations---defining the entry point and
1864defining symbols---outside the @code{SECTIONS} command: @pxref{Entry
baaaf6f2 1865Point}, and @ref{Assignment}. They are permitted here as well for
8920addc
RP
1866your convenience in reading the script, so that symbols and the entry
1867point can be defined at meaningful points in your output-file layout.
f22eee08 1868
67c4333b 1869If you do not use a @code{SECTIONS} command, the linker places each input
867a1b8a
DM
1870section into an identically named output section in the order that the
1871sections are first encountered in the input files. If all input sections
1872are present in the first file, for example, the order of sections in the
1873output file will match the order in the first input file.
b4d4e8e3 1874
2c5c0674 1875@menu
2d59b2c3 1876* Section Definition:: Section Definitions
867a1b8a
DM
1877* Section Placement:: Section Placement
1878* Section Data Expressions:: Section Data Expressions
2d59b2c3 1879* Section Options:: Optional Section Attributes
b61364cc 1880* Overlays:: Overlays
2c5c0674
RP
1881@end menu
1882
ec40bbb8 1883@node Section Definition
b4d4e8e3 1884@subsection Section Definitions
2c5c0674 1885@cindex section definition
b4d4e8e3 1886The most frequently used statement in the @code{SECTIONS} command is
867a1b8a 1887the @dfn{section definition}, which specifies the
b4d4e8e3 1888properties of an output section: its location, alignment, contents,
ec40bbb8 1889fill pattern, and target memory region. Most of
b4d4e8e3
RP
1890these specifications are optional; the simplest form of a section
1891definition is
c653b370 1892@smallexample
2c5c0674 1893SECTIONS @{ @dots{}
d4e5e3c3
DM
1894 @var{secname} : @{
1895 @var{contents}
1896 @}
2c5c0674 1897@dots{} @}
c653b370 1898@end smallexample
2c5c0674 1899@cindex naming output sections
b4d4e8e3
RP
1900@noindent
1901@var{secname} is the name of the output section, and @var{contents} a
ec40bbb8 1902specification of what goes there---for example, a list of input files or
867a1b8a
DM
1903sections of input files (@pxref{Section Placement}). As you might
1904assume, the whitespace shown is optional. You do need the colon
1905@samp{:} and the braces @samp{@{@}}, however.
b4d4e8e3
RP
1906
1907@var{secname} must meet the constraints of your output format. In
1908formats which only support a limited number of sections, such as
1909@code{a.out}, the name must be one of the names supported by the format
2c5c0674
RP
1910(@code{a.out}, for example, allows only @code{.text}, @code{.data} or
1911@code{.bss}). If the output format supports any number of sections, but
1912with numbers and not names (as is the case for Oasys), the name should be
1913supplied as a quoted numeric string. A section name may consist of any
867a1b8a 1914sequence of characters, but any name which does not conform to the standard
246504a5 1915@code{ld} symbol name syntax must be quoted.
ec40bbb8 1916@xref{Symbols, , Symbol Names}.
2c5c0674 1917
cf2e4f5f
ILT
1918The special @var{secname} @samp{/DISCARD/} may be used to discard input
1919sections. Any sections which are assigned to an output section named
1920@samp{/DISCARD/} are not included in the final link output.
1921
f9d3d71a
ILT
1922The linker will not create output sections which do not have any
1923contents. This is for convenience when referring to input sections that
1924may or may not exist. For example,
c653b370
ILT
1925@smallexample
1926.foo @{ *(.foo) @}
1927@end smallexample
f9d3d71a
ILT
1928will only create a @samp{.foo} section in the output file if there is a
1929@samp{.foo} section in at least one input file.
1930
867a1b8a
DM
1931@node Section Placement
1932@subsection Section Placement
67c4333b 1933
2c5c0674 1934@cindex contents of a section
67c4333b
RP
1935In a section definition, you can specify the contents of an output
1936section by listing particular input files, by listing particular
1937input-file sections, or by a combination of the two. You can also place
1938arbitrary data in the section, and define symbols relative to the
1939beginning of the section.
b4d4e8e3
RP
1940
1941The @var{contents} of a section definition may include any of the
1942following kinds of statement. You can include as many of these as you
1943like in a single section definition, separated from one another by
86bc0974 1944whitespace.
f22eee08 1945
b4d4e8e3 1946@table @code
2c5c0674
RP
1947@kindex @var{filename}
1948@cindex input files, section defn
1949@cindex files, including in output sections
d4e5e3c3 1950@item @var{filename}
b4d4e8e3 1951You may simply name a particular input file to be placed in the current
2c5c0674 1952output section; @emph{all} sections from that file are placed in the
867a1b8a
DM
1953current section definition. If the file name has already been mentioned
1954in another section definition, with an explicit section name list, then
1955only those sections which have not yet been allocated are used.
1956
1957To specify a list of particular files by name:
c653b370 1958@smallexample
cb70c872 1959.data : @{ afile.o bfile.o cfile.o @}
c653b370 1960@end smallexample
2c5c0674
RP
1961@noindent
1962The example also illustrates that multiple statements can be included in
ec40bbb8 1963the contents of a section definition, since each file name is a separate
2c5c0674 1964statement.
f22eee08 1965
d4e5e3c3
DM
1966@kindex @var{filename}(@var{section})
1967@cindex files and sections, section defn
2c5c0674 1968@item @var{filename}( @var{section} )
4fea1383 1969@itemx @var{filename}( @var{section} , @var{section}, @dots{} )
2c5c0674 1970@itemx @var{filename}( @var{section} @var{section} @dots{} )
2c5c0674
RP
1971You can name one or more sections from your input files, for
1972insertion in the current output section. If you wish to specify a list
1973of input-file sections inside the parentheses, you may separate the
1974section names by either commas or whitespace.
1975
d4e5e3c3
DM
1976@cindex input sections to output section
1977@kindex *(@var{section})
b4d4e8e3
RP
1978@item * (@var{section})
1979@itemx * (@var{section}, @var{section}, @dots{})
836a5ee4 1980@itemx * (@var{section} @var{section} @dots{})
b4d4e8e3 1981Instead of explicitly naming particular input files in a link control
246504a5 1982script, you can refer to @emph{all} files from the @code{ld} command
ec40bbb8 1983line: use @samp{*} instead of a particular file name before the
b4d4e8e3
RP
1984parenthesized input-file section list.
1985
867a1b8a
DM
1986If you have already explicitly included some files by name, @samp{*}
1987refers to all @emph{remaining} files---those whose places in the output
1988file have not yet been defined.
1989
ec40bbb8 1990For example, to copy sections @code{1} through @code{4} from an Oasys file
b4d4e8e3
RP
1991into the @code{.text} section of an @code{a.out} file, and sections @code{13}
1992and @code{14} into the @code{.data} section:
c653b370
ILT
1993@smallexample
1994@group
2c5c0674 1995SECTIONS @{
d4e5e3c3
DM
1996 .text :@{
1997 *("1" "2" "3" "4")
1998 @}
1999
2000 .data :@{
2001 *("13" "14")
2002 @}
b4d4e8e3 2003@}
c653b370
ILT
2004@end group
2005@end smallexample
f22eee08 2006
d4e5e3c3 2007@cindex @code{[@var{section}@dots{}]}, not supported
836a5ee4
DM
2008@samp{[ @var{section} @dots{} ]} used to be accepted as an alternate way
2009to specify named sections from all unallocated input files. Because
2010some operating systems (VMS) allow brackets in file names, that notation
2011is no longer supported.
2012
2c5c0674
RP
2013@cindex uninitialized data
2014@cindex commons in output
d4e5e3c3
DM
2015@kindex *( COMMON )
2016@item @var{filename}@code{( COMMON )}
2017@itemx *( COMMON )
b4d4e8e3 2018Specify where in your output file to place uninitialized data
d76ae847 2019with this notation. @code{*(COMMON)} by itself refers to all
b4d4e8e3
RP
2020uninitialized data from all input files (so far as it is not yet
2021allocated); @var{filename}@code{(COMMON)} refers to uninitialized data
2022from a particular file. Both are special cases of the general
2023mechanisms for specifying where to place input-file sections:
246504a5 2024@code{ld} permits you to refer to uninitialized data as if it
b4d4e8e3
RP
2025were in an input-file section named @code{COMMON}, regardless of the
2026input file's format.
2027@end table
2028
86bc0974 2029In any place where you may use a specific file or section name, you may
c2ba3684
ILT
2030also use a wildcard pattern. The linker handles wildcards much as the
2031Unix shell does. A @samp{*} character matches any number of characters.
2032A @samp{?} character matches any single character. The sequence
2033@samp{[@var{chars}]} will match a single instance of any of the
86bc0974
ILT
2034@var{chars}; the @samp{-} character may be used to specify a range of
2035characters, as in @samp{[a-z]} to match any lower case letter. A
2036@samp{\} character may be used to quote the following character.
2037
c2ba3684
ILT
2038When a file name is matched with a wildcard, the wildcard characters
2039will not match a @samp{/} character (used to separate directory names on
86bc0974 2040Unix). A pattern consisting of a single @samp{*} character is an
c2ba3684
ILT
2041exception; it will always match any file name. In a section name, the
2042wildcard characters will match a @samp{/} character.
2043
2044Wildcards only match files which are explicitly specified on the command
2045line. The linker does not search directories to expand wildcards.
2046However, if you specify a simple file name---a name with no wildcard
2047characters---in a linker script, and the file name is not also specified
2048on the command line, the linker will attempt to open the file as though
2049it appeared on the command line.
86bc0974
ILT
2050
2051In the following example, the command script arranges the output file
2052into three consecutive sections, named @code{.text}, @code{.data}, and
b4d4e8e3
RP
2053@code{.bss}, taking the input for each from the correspondingly named
2054sections of all the input files:
d4e5e3c3 2055
c653b370
ILT
2056@smallexample
2057@group
2c5c0674 2058SECTIONS @{
d76ae847
RP
2059 .text : @{ *(.text) @}
2060 .data : @{ *(.data) @}
2061 .bss : @{ *(.bss) *(COMMON) @}
2c5c0674 2062@}
c653b370
ILT
2063@end group
2064@end smallexample
b4d4e8e3
RP
2065
2066The following example reads all of the sections from file @code{all.o}
2067and places them at the start of output section @code{outputa} which
2068starts at location @code{0x10000}. All of section @code{.input1} from
2069file @code{foo.o} follows immediately, in the same output section. All
2070of section @code{.input2} from @code{foo.o} goes into output section
2071@code{outputb}, followed by section @code{.input1} from @code{foo1.o}.
2072All of the remaining @code{.input1} and @code{.input2} sections from any
2073files are written to output section @code{outputc}.
2074
c653b370
ILT
2075@smallexample
2076@group
2c5c0674 2077SECTIONS @{
d4e5e3c3
DM
2078 outputa 0x10000 :
2079 @{
2080 all.o
2081 foo.o (.input1)
2082 @}
2083 outputb :
2084 @{
2085 foo.o (.input2)
2086 foo1.o (.input1)
2087 @}
2088 outputc :
2089 @{
2090 *(.input1)
2091 *(.input2)
2092 @}
2c5c0674 2093@}
c653b370
ILT
2094@end group
2095@end smallexample
b4d4e8e3 2096
86bc0974
ILT
2097This example shows how wildcard patterns might be used to partition
2098files. All @code{.text} sections are placed in @code{.text}, and all
2099@code{.bss} sections are placed in @code{.bss}. For all files beginning
2100with an upper case character, the @code{.data} section is placed into
2101@code{.DATA}; for all other files, the @code{.data} section is placed
2102into @code{.data}.
2103
2104@smallexample
2105@group
2106SECTIONS @{
2107 .text : @{ *(.text) @}
2108 .DATA : @{ [A-Z]*(.data) @}
2109 .data : @{ *(.data) @}
2110 .bss : @{ *(.bss) @}
2111@}
2112@end group
2113@end smallexample
2114
867a1b8a
DM
2115@node Section Data Expressions
2116@subsection Section Data Expressions
67c4333b 2117
867a1b8a 2118@cindex expressions in a section
67c4333b
RP
2119The foregoing statements arrange, in your output file, data originating
2120from your input files. You can also place data directly in an output
2121section from the link command script. Most of these additional
baaaf6f2 2122statements involve expressions (@pxref{Expressions}). Although these
67c4333b
RP
2123statements are shown separately here for ease of presentation, no such
2124segregation is needed within a section definition in the @code{SECTIONS}
2125command; you can intermix them freely with any of the statements we've
2126just described.
f22eee08 2127
b4d4e8e3 2128@table @code
2c5c0674
RP
2129@cindex input filename symbols
2130@cindex filename symbols
d4e5e3c3
DM
2131@kindex CREATE_OBJECT_SYMBOLS
2132@item CREATE_OBJECT_SYMBOLS
ec40bbb8
DM
2133Create a symbol for each input file
2134in the current section, set to the address of the first byte of
867a1b8a 2135data written from that input file. For instance, with @code{a.out}
b4d4e8e3
RP
2136files it is conventional to have a symbol for each input file. You can
2137accomplish this by defining the output @code{.text} section as follows:
c653b370
ILT
2138@smallexample
2139@group
b4d4e8e3 2140SECTIONS @{
d4e5e3c3
DM
2141 .text 0x2020 :
2142 @{
2143 CREATE_OBJECT_SYMBOLS
2144 *(.text)
2145 _etext = ALIGN(0x2000);
2146 @}
2147 @dots{}
2c5c0674 2148@}
c653b370
ILT
2149@end group
2150@end smallexample
b4d4e8e3 2151
867a1b8a 2152If @code{sample.ld} is a file containing this script, and @code{a.o},
b4d4e8e3
RP
2153@code{b.o}, @code{c.o}, and @code{d.o} are four input files with
2154contents like the following---
c653b370
ILT
2155@smallexample
2156@group
b4d4e8e3
RP
2157/* a.c */
2158
2c5c0674 2159afunction() @{ @}
b4d4e8e3
RP
2160int adata=1;
2161int abss;
c653b370
ILT
2162@end group
2163@end smallexample
f22eee08 2164
b4d4e8e3 2165@noindent
867a1b8a 2166@samp{ld -M -T sample.ld a.o b.o c.o d.o} would create a map like this,
b4d4e8e3 2167containing symbols matching the object file names:
c653b370 2168@smallexample
f22eee08
RP
216900000000 A __DYNAMIC
217000004020 B _abss
217100004000 D _adata
217200002020 T _afunction
217300004024 B _bbss
217400004008 D _bdata
217500002038 T _bfunction
217600004028 B _cbss
217700004010 D _cdata
217800002050 T _cfunction
21790000402c B _dbss
218000004018 D _ddata
218100002068 T _dfunction
218200004020 D _edata
218300004030 B _end
218400004000 T _etext
218500002020 t a.o
218600002038 t b.o
218700002050 t c.o
218800002068 t d.o
c653b370 2189@end smallexample
f22eee08 2190
2c5c0674 2191@kindex @var{symbol} = @var{expression} ;
2c5c0674 2192@kindex @var{symbol} @var{f}= @var{expression} ;
d4e5e3c3
DM
2193@item @var{symbol} = @var{expression} ;
2194@itemx @var{symbol} @var{f}= @var{expression} ;
2c5c0674
RP
2195@var{symbol} is any symbol name (@pxref{Symbols}). ``@var{f}=''
2196refers to any of the operators @code{&= += -= *= /=} which combine
2197arithmetic and assignment.
2198
2199@cindex assignment, in section defn
2200When you assign a value to a symbol within a particular section
2201definition, the value is relative to the beginning of the section
2202(@pxref{Assignment}). If you write
d4e5e3c3 2203
c653b370
ILT
2204@smallexample
2205@group
2c5c0674 2206SECTIONS @{
b4d4e8e3 2207 abs = 14 ;
2c5c0674 2208 @dots{}
cb70c872 2209 .data : @{ @dots{} rel = 14 ; @dots{} @}
b4d4e8e3 2210 abs2 = 14 + ADDR(.data);
2c5c0674
RP
2211 @dots{}
2212@}
c653b370
ILT
2213@end group
2214@end smallexample
d4e5e3c3 2215
2c5c0674 2216@c FIXME: Try above example!
b4d4e8e3 2217@noindent
ec40bbb8 2218@code{abs} and @code{rel} do not have the same value; @code{rel} has the
b4d4e8e3
RP
2219same value as @code{abs2}.
2220
2c5c0674 2221@kindex BYTE(@var{expression})
2c5c0674 2222@kindex SHORT(@var{expression})
2c5c0674 2223@kindex LONG(@var{expression})
c477527c 2224@kindex QUAD(@var{expression})
2c5c0674 2225@cindex direct output
d4e5e3c3
DM
2226@item BYTE(@var{expression})
2227@itemx SHORT(@var{expression})
2228@itemx LONG(@var{expression})
2229@itemx QUAD(@var{expression})
c477527c
ILT
2230By including one of these four statements in a section definition, you
2231can explicitly place one, two, four, or eight bytes (respectively) at
2232the current address of that section. @code{QUAD} is only supported when
2233using a 64 bit host or target.
ec40bbb8
DM
2234
2235@ifclear SingleFormat
2236Multiple-byte quantities are represented in whatever byte order is
2237appropriate for the output file format (@pxref{BFD}).
2238@end ifclear
b4d4e8e3 2239
2c5c0674
RP
2240@kindex FILL(@var{expression})
2241@cindex holes, filling
2242@cindex unspecified memory
c653b370 2243@item FILL(@var{expression})
867a1b8a 2244Specify the ``fill pattern'' for the current section. Any otherwise
b4d4e8e3
RP
2245unspecified regions of memory within the section (for example, regions
2246you skip over by assigning a new value to the location counter @samp{.})
2247are filled with the two least significant bytes from the
2248@var{expression} argument. A @code{FILL} statement covers memory
2249locations @emph{after} the point it occurs in the section definition; by
2250including more than one @code{FILL} statement, you can have different
2251fill patterns in different parts of an output section.
2252@end table
2253
ec40bbb8 2254@node Section Options
b4d4e8e3 2255@subsection Optional Section Attributes
2c5c0674 2256@cindex section defn, full syntax
b4d4e8e3
RP
2257Here is the full syntax of a section definition, including all the
2258optional portions:
2259
d76ae847 2260@smallexample
c653b370 2261@group
2c5c0674
RP
2262SECTIONS @{
2263@dots{}
67c4333b 2264@var{secname} @var{start} BLOCK(@var{align}) (NOLOAD) : AT ( @var{ldadr} )
c653b370 2265 @{ @var{contents} @} >@var{region} :@var{phdr} =@var{fill}
2c5c0674 2266@dots{}
b4d4e8e3 2267@}
c653b370 2268@end group
d76ae847 2269@end smallexample
b4d4e8e3
RP
2270
2271@var{secname} and @var{contents} are required. @xref{Section
baaaf6f2 2272Definition}, and @ref{Section Placement}, for details on
67c4333b
RP
2273@var{contents}. The remaining elements---@var{start},
2274@code{BLOCK(@var{align)}}, @code{(NOLOAD)}, @code{AT ( @var{ldadr} )},
c653b370
ILT
2275@code{>@var{region}}, @code{:@var{phdr}}, and @code{=@var{fill}}---are
2276all optional.
f22eee08 2277
b4d4e8e3 2278@table @code
2c5c0674
RP
2279@cindex start address, section
2280@cindex section start
2281@cindex section address
d4e5e3c3 2282@item @var{start}
b4d4e8e3
RP
2283You can force the output section to be loaded at a specified address by
2284specifying @var{start} immediately following the section name.
2285@var{start} can be represented as any expression. The following
2286example generates section @var{output} at location
2287@code{0x40000000}:
d4e5e3c3 2288
c653b370
ILT
2289@smallexample
2290@group
b4d4e8e3 2291SECTIONS @{
d4e5e3c3
DM
2292 @dots{}
2293 output 0x40000000: @{
2294 @dots{}
2295 @}
2296 @dots{}
b4d4e8e3 2297@}
c653b370
ILT
2298@end group
2299@end smallexample
f22eee08 2300
2c5c0674
RP
2301@kindex BLOCK(@var{align})
2302@cindex section alignment
2303@cindex aligning sections
d4e5e3c3 2304@item BLOCK(@var{align})
ec40bbb8 2305You can include @code{BLOCK()} specification to advance
2c5c0674
RP
2306the location counter @code{.} prior to the beginning of the section, so
2307that the section will begin at the specified alignment. @var{align} is
2308an expression.
f22eee08 2309
d76ae847
RP
2310@kindex NOLOAD
2311@cindex prevent unnecessary loading
67c4333b
RP
2312@cindex loading, preventing
2313@item (NOLOAD)
d76ae847
RP
2314Use @samp{(NOLOAD)} to prevent a section from being loaded into memory
2315each time it is accessed. For example, in the script sample below, the
2316@code{ROM} segment is addressed at memory location @samp{0} and does not
2317need to be loaded into each object file:
67c4333b 2318
c653b370
ILT
2319@smallexample
2320@group
d76ae847 2321SECTIONS @{
d4e5e3c3
DM
2322 ROM 0 (NOLOAD) : @{ @dots{} @}
2323 @dots{}
d76ae847 2324@}
c653b370
ILT
2325@end group
2326@end smallexample
d76ae847 2327
67c4333b
RP
2328@kindex AT ( @var{ldadr} )
2329@cindex specify load address
2330@cindex load address, specifying
2331@item AT ( @var{ldadr} )
2332The expression @var{ldadr} that follows the @code{AT} keyword specifies
2333the load address of the section. The default (if you do not use the
2334@code{AT} keyword) is to make the load address the same as the
2335relocation address. This feature is designed to make it easy to build a
2336ROM image. For example, this @code{SECTIONS} definition creates two
2337output sections: one called @samp{.text}, which starts at @code{0x1000},
2338and one called @samp{.mdata}, which is loaded at the end of the
2339@samp{.text} section even though its relocation address is
2340@code{0x2000}. The symbol @code{_data} is defined with the value
2341@code{0x2000}:
2342
2343@smallexample
c653b370 2344@group
67c4333b 2345SECTIONS
139c8857
RP
2346 @{
2347 .text 0x1000 : @{ *(.text) _etext = . ; @}
2348 .mdata 0x2000 :
2349 AT ( ADDR(.text) + SIZEOF ( .text ) )
2350 @{ _data = . ; *(.data); _edata = . ; @}
2351 .bss 0x3000 :
2352 @{ _bstart = . ; *(.bss) *(COMMON) ; _bend = . ;@}
67c4333b 2353@}
c653b370 2354@end group
67c4333b
RP
2355@end smallexample
2356
2357The run-time initialization code (for C programs, usually @code{crt0})
2358for use with a ROM generated this way has to include something like
2359the following, to copy the initialized data from the ROM image to its runtime
2360address:
2361
139c8857 2362@smallexample
c653b370 2363@group
67c4333b
RP
2364char *src = _etext;
2365char *dst = _data;
2366
139c8857 2367/* ROM has data at end of text; copy it. */
67c4333b 2368while (dst < _edata) @{
139c8857 2369 *dst++ = *src++;
67c4333b
RP
2370@}
2371
2372/* Zero bss */
2373for (dst = _bstart; dst< _bend; dst++)
139c8857 2374 *dst = 0;
c653b370 2375@end group
139c8857 2376@end smallexample
67c4333b 2377
f9d3d71a
ILT
2378@kindex >@var{region}
2379@cindex section, assigning to memory region
2380@cindex memory regions and sections
2381@item >@var{region}
2382Assign this section to a previously defined region of memory.
2383@xref{MEMORY}.
2384
c653b370
ILT
2385@kindex :@var{phdr}
2386@cindex section, assigning to program header
2387@cindex program headers and sections
2388@item :@var{phdr}
2389Assign this section to a segment described by a program header.
baaaf6f2 2390@xref{PHDRS}. If a section is assigned to one or more segments, then
c653b370
ILT
2391all subsequent allocated sections will be assigned to those segments as
2392well, unless they use an explicitly @code{:@var{phdr}} modifier. To
2393prevent a section from being assigned to a segment when it would
2394normally default to one, use @code{:NONE}.
2395
2c5c0674
RP
2396@kindex =@var{fill}
2397@cindex section fill pattern
2398@cindex fill pattern, entire section
d4e5e3c3
DM
2399@item =@var{fill}
2400Including @code{=@var{fill}} in a section definition specifies the
2401initial fill value for that section. You may use any expression to
2402specify @var{fill}. Any unallocated holes in the current output section
2403when written to the output file will be filled with the two least
2404significant bytes of the value, repeated as necessary. You can also
2405change the fill value with a @code{FILL} statement in the @var{contents}
2406of a section definition.
f22eee08 2407
f22eee08 2408@end table
b4d4e8e3 2409
b61364cc
ILT
2410@node Overlays
2411@subsection Overlays
2412@kindex OVERLAY
2413@cindex overlays
2414
2415The @code{OVERLAY} command provides an easy way to describe sections
2416which are to be loaded as part of a single memory image but are to be
2417run at the same memory address. At run time, some sort of overlay
2418manager will copy the overlaid sections in and out of the runtime memory
2419address as required, perhaps by simply manipulating addressing bits.
2420This approach can be useful, for example, when a certain region of
2421memory is faster than another.
2422
2423The @code{OVERLAY} command is used within a @code{SECTIONS} command. It
2424appears as follows:
2425@smallexample
2426@group
2427 OVERLAY @var{start} : [ NOCROSSREFS ] AT ( @var{ldaddr} )
2428 @{
2429 @var{secname1} @{ @var{contents} @} :@var{phdr} =@var{fill}
2430 @var{secname2} @{ @var{contents} @} :@var{phdr} =@var{fill}
2431 @dots{}
2432 @} >@var{region} :@var{phdr} =@var{fill}
2433@end group
2434@end smallexample
2435
2436Everything is optional except @code{OVERLAY} (a keyword), and each
2437section must have a name (@var{secname1} and @var{secname2} above). The
2438section definitions within the @code{OVERLAY} construct are identical to
2439those within the general @code{SECTIONS} contruct (@pxref{SECTIONS}),
2440except that no addresses and no memory regions may be defined for
2441sections within an @code{OVERLAY}.
2442
2443The sections are all defined with the same starting address. The load
2444addresses of the sections are arranged such that they are consecutive in
2445memory starting at the load address used for the @code{OVERLAY} as a
2446whole (as with normal section definitions, the load address is optional,
2447and defaults to the start address; the start address is also optional,
2448and defaults to @code{.}).
2449
2450If the @code{NOCROSSREFS} keyword is used, and there any references
2451among the sections, the linker will report an error. Since the sections
2452all run at the same address, it normally does not make sense for one
2453section to refer directly to another. @xref{Option Commands,
2454NOCROSSREFS}.
2455
2456For each section within the @code{OVERLAY}, the linker automatically
2457defines two symbols. The symbol @code{__load_start_@var{secname}} is
2458defined as the starting load address of the section. The symbol
2459@code{__load_stop_@var{secname}} is defined as the final load address of
2460the section. Any characters within @var{secname} which are not legal
2461within C identifiers are removed. C (or assembler) code may use these
2462symbols to move the overlaid sections around as necessary.
2463
2464At the end of the overlay, the value of @code{.} is set to the start
2465address of the overlay plus the size of the largest section.
2466
2467Here is an example. Remember that this would appear inside a
2468@code{SECTIONS} construct.
2469
2470@smallexample
2471@group
2472 OVERLAY 0x1000 : AT (0x4000)
2473 @{
2474 .text0 @{ o1/*.o(.text) @}
2475 .text1 @{ o2/*.o(.text) @}
2476 @}
2477@end group
2478@end smallexample
2479
2480This will define both @code{.text0} and @code{.text1} to start at
2481address 0x1000. @code{.text0} will be loaded at address 0x4000, and
2482@code{.text1} will be loaded immediately after @code{.text0}. The
2483following symbols will be defined: @code{__load_start_text0},
2484@code{__load_stop_text0}, @code{__load_start_text1},
2485@code{__load_stop_text1}.
2486
2487C code to copy overlay @code{.text1} into the overlay area might look
2488like the following.
2489
2490@smallexample
2491@group
2492 extern char __load_start_text1, __load_stop_text1;
2493 memcpy ((char *) 0x1000, &__load_start_text1,
2494 &__load_stop_text1 - &__load_start_text1);
2495@end group
2496@end smallexample
2497
2498Note that the @code{OVERLAY} command is just syntactic sugar, since
2499everything it does can be done using the more basic commands. The above
2500example could have been written identically as follows.
2501
2502@smallexample
2503@group
2504 .text0 0x1000 : AT (0x4000) @{ o1/*.o(.text) @}
2505 __load_start_text0 = LOADADDR (.text0);
2506 __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
2507 .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) @{ o2/*.o(.text) @}
2508 __load_start_text1 = LOADADDR (.text1);
2509 __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
2510 . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
2511@end group
2512@end smallexample
2513
c653b370
ILT
2514@node PHDRS
2515@section ELF Program Headers
2516@kindex PHDRS
b61364cc
ILT
2517@cindex program headers
2518@cindex ELF program headers
c653b370
ILT
2519
2520The ELF object file format uses @dfn{program headers}, which are read by
2521the system loader and describe how the program should be loaded into
2522memory. These program headers must be set correctly in order to run the
2523program on a native ELF system. The linker will create reasonable
2524program headers by default. However, in some cases, it is desirable to
2525specify the program headers more precisely; the @code{PHDRS} command may
2526be used for this purpose. When the @code{PHDRS} command is used, the
2527linker will not generate any program headers itself.
2528
2529The @code{PHDRS} command is only meaningful when generating an ELF
2530output file. It is ignored in other cases. This manual does not
2531describe the details of how the system loader interprets program
2532headers; for more information, see the ELF ABI. The program headers of
2533an ELF file may be displayed using the @samp{-p} option of the
2534@code{objdump} command.
2535
2536This is the syntax of the @code{PHDRS} command. The words @code{PHDRS},
2537@code{FILEHDR}, @code{AT}, and @code{FLAGS} are keywords.
2538
2539@smallexample
2540@group
2541PHDRS
2542@{
2543 @var{name} @var{type} [ FILEHDR ] [ PHDRS ] [ AT ( @var{address} ) ]
2544 [ FLAGS ( @var{flags} ) ] ;
2545@}
2546@end group
2547@end smallexample
2548
2549The @var{name} is used only for reference in the @code{SECTIONS} command
2550of the linker script. It does not get put into the output file.
2551
2552Certain program header types describe segments of memory which are
2553loaded from the file by the system loader. In the linker script, the
2554contents of these segments are specified by directing allocated output
2555sections to be placed in the segment. To do this, the command
2556describing the output section in the @code{SECTIONS} command should use
2557@samp{:@var{name}}, where @var{name} is the name of the program header
2558as it appears in the @code{PHDRS} command. @xref{Section Options}.
2559
2560It is normal for certain sections to appear in more than one segment.
2561This merely implies that one segment of memory contains another. This
2562is specified by repeating @samp{:@var{name}}, using it once for each
2563program header in which the section is to appear.
2564
2565If a section is placed in one or more segments using @samp{:@var{name}},
2566then all subsequent allocated sections which do not specify
2567@samp{:@var{name}} are placed in the same segments. This is for
2568convenience, since generally a whole set of contiguous sections will be
2569placed in a single segment. To prevent a section from being assigned to
2570a segment when it would normally default to one, use @code{:NONE}.
2571
2572The @code{FILEHDR} and @code{PHDRS} keywords which may appear after the
2573program header type also indicate contents of the segment of memory.
2574The @code{FILEHDR} keyword means that the segment should include the ELF
2575file header. The @code{PHDRS} keyword means that the segment should
2576include the ELF program headers themselves.
2577
2578The @var{type} may be one of the following. The numbers indicate the
2579value of the keyword.
2580
2581@table @asis
2582@item @code{PT_NULL} (0)
2583Indicates an unused program header.
2584
2585@item @code{PT_LOAD} (1)
2586Indicates that this program header describes a segment to be loaded from
2587the file.
2588
2589@item @code{PT_DYNAMIC} (2)
2590Indicates a segment where dynamic linking information can be found.
2591
2592@item @code{PT_INTERP} (3)
2593Indicates a segment where the name of the program interpreter may be
2594found.
2595
2596@item @code{PT_NOTE} (4)
2597Indicates a segment holding note information.
2598
2599@item @code{PT_SHLIB} (5)
2600A reserved program header type, defined but not specified by the ELF
2601ABI.
2602
2603@item @code{PT_PHDR} (6)
2604Indicates a segment where the program headers may be found.
2605
2606@item @var{expression}
2607An expression giving the numeric type of the program header. This may
2608be used for types not defined above.
2609@end table
2610
2611It is possible to specify that a segment should be loaded at a
2612particular address in memory. This is done using an @code{AT}
2613expression. This is identical to the @code{AT} command used in the
2614@code{SECTIONS} command (@pxref{Section Options}). Using the @code{AT}
2615command for a program header overrides any information in the
2616@code{SECTIONS} command.
2617
2618Normally the segment flags are set based on the sections. The
2619@code{FLAGS} keyword may be used to explicitly specify the segment
2620flags. The value of @var{flags} must be an integer. It is used to
2621set the @code{p_flags} field of the program header.
2622
2623Here is an example of the use of @code{PHDRS}. This shows a typical set
2624of program headers used on a native ELF system.
2625
2626@example
2627@group
2628PHDRS
2629@{
2630 headers PT_PHDR PHDRS ;
2631 interp PT_INTERP ;
2632 text PT_LOAD FILEHDR PHDRS ;
2633 data PT_LOAD ;
2634 dynamic PT_DYNAMIC ;
2635@}
2636
2637SECTIONS
2638@{
2639 . = SIZEOF_HEADERS;
2640 .interp : @{ *(.interp) @} :text :interp
2641 .text : @{ *(.text) @} :text
2642 .rodata : @{ *(.rodata) @} /* defaults to :text */
2643 @dots{}
2644 . = . + 0x1000; /* move to a new page in memory */
2645 .data : @{ *(.data) @} :data
2646 .dynamic : @{ *(.dynamic) @} :data :dynamic
2647 @dots{}
2648@}
2649@end group
2650@end example
2651
ec40bbb8 2652@node Entry Point
b4d4e8e3 2653@section The Entry Point
2c5c0674
RP
2654@kindex ENTRY(@var{symbol})
2655@cindex start of execution
2656@cindex first instruction
b4d4e8e3
RP
2657The linker command language includes a command specifically for
2658defining the first executable instruction in an output file (its
2659@dfn{entry point}). Its argument is a symbol name:
c653b370 2660@smallexample
b4d4e8e3 2661ENTRY(@var{symbol})
c653b370 2662@end smallexample
b4d4e8e3
RP
2663
2664Like symbol assignments, the @code{ENTRY} command may be placed either
2665as an independent command in the command file, or among the section
2666definitions within the @code{SECTIONS} command---whatever makes the most
2667sense for your layout.
2668
2c5c0674 2669@cindex entry point, defaults
b4d4e8e3
RP
2670@code{ENTRY} is only one of several ways of choosing the entry point.
2671You may indicate it in any of the following ways (shown in descending
2672order of priority: methods higher in the list override methods lower down).
f22eee08
RP
2673@itemize @bullet
2674@item
ec40bbb8 2675the @samp{-e} @var{entry} command-line option;
f22eee08 2676@item
8de26d62 2677the @code{ENTRY(@var{symbol})} command in a linker control script;
f22eee08 2678@item
b4d4e8e3 2679the value of the symbol @code{start}, if present;
f22eee08 2680@item
b4d4e8e3 2681the address of the first byte of the @code{.text} section, if present;
f22eee08 2682@item
b4d4e8e3 2683The address @code{0}.
f22eee08 2684@end itemize
b4d4e8e3 2685
2c5c0674
RP
2686For example, you can use these rules to generate an entry point with an
2687assignment statement: if no symbol @code{start} is defined within your
2688input files, you can simply define it, assigning it an appropriate
2689value---
d4e5e3c3 2690
c653b370 2691@smallexample
b4d4e8e3 2692start = 0x2020;
c653b370 2693@end smallexample
b4d4e8e3
RP
2694
2695@noindent
2696The example shows an absolute address, but you can use any expression.
2697For example, if your input object files use some other symbol-name
2698convention for the entry point, you can just assign the value of
2699whatever symbol contains the start address to @code{start}:
d4e5e3c3 2700
c653b370 2701@smallexample
cb70c872 2702start = other_symbol ;
c653b370 2703@end smallexample
f22eee08 2704
867a1b8a
DM
2705@node Option Commands
2706@section Option Commands
b4d4e8e3
RP
2707The command language includes a number of other commands that you can
2708use for specialized purposes. They are similar in purpose to
2709command-line options.
2710
2711@table @code
1fb57a5d
RP
2712@kindex CONSTRUCTORS
2713@cindex C++ constructors, arranging in link
2714@cindex constructors, arranging in link
2715@item CONSTRUCTORS
a1d393cf
ILT
2716When linking using the @code{a.out} object file format, the linker uses
2717an unusual set construct to support C++ global constructors and
2718destructors. When linking object file formats which do not support
2719arbitrary sections, such as @code{ECOFF} and @code{XCOFF}, the linker
2720will automatically recognize C++ global constructors and destructors by
2721name. For these object file formats, the @code{CONSTRUCTORS} command
2722tells the linker where this information should be placed. The
2723@code{CONSTRUCTORS} command is ignored for other object file formats.
2724
2725The symbol @w{@code{__CTOR_LIST__}} marks the start of the global
2726constructors, and the symbol @w{@code{__DTOR_LIST}} marks the end. The
2727first word in the list is the number of entries, followed by the address
2728of each constructor or destructor, followed by a zero word. The
2729compiler must arrange to actually run the code. For these object file
2730formats @sc{gnu} C++ calls constructors from a subroutine @code{__main};
2731a call to @code{__main} is automatically inserted into the startup code
2732for @code{main}. @sc{gnu} C++ runs destructors either by using
2733@code{atexit}, or directly from the function @code{exit}.
2734
2735For object file formats such as @code{COFF} or @code{ELF} which support
2736multiple sections, @sc{gnu} C++ will normally arrange to put the
2737addresses of global constructors and destructors into the @code{.ctors}
2738and @code{.dtors} sections. Placing the following sequence into your
2739linker script will build the sort of table which the @sc{gnu} C++
2740runtime code expects to see.
2741
2742@smallexample
2743 __CTOR_LIST__ = .;
2744 LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
2745 *(.ctors)
2746 LONG(0)
2747 __CTOR_END__ = .;
2748 __DTOR_LIST__ = .;
2749 LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
2750 *(.dtors)
2751 LONG(0)
2752 __DTOR_END__ = .;
2753@end smallexample
2754
2755Normally the compiler and linker will handle these issues automatically,
2756and you will not need to concern yourself with them. However, you may
2757need to consider this if you are using C++ and writing your own linker
2758scripts.
1fb57a5d 2759
d4e5e3c3 2760@need 1000
2c5c0674 2761@kindex FLOAT
2c5c0674 2762@kindex NOFLOAT
1fb57a5d
RP
2763@item FLOAT
2764@itemx NOFLOAT
2c5c0674 2765These keywords were used in some older linkers to request a particular
246504a5 2766math subroutine library. @code{ld} doesn't use the keywords, assuming
2c5c0674
RP
2767instead that any necessary subroutines are in libraries specified using
2768the general mechanisms for linking to archives; but to permit the use of
2769scripts that were written for the older linkers, the keywords
2770@code{FLOAT} and @code{NOFLOAT} are accepted and ignored.
2771
2c5c0674
RP
2772@kindex FORCE_COMMON_ALLOCATION
2773@cindex common allocation
1fb57a5d 2774@item FORCE_COMMON_ALLOCATION
ec40bbb8 2775This command has the same effect as the @samp{-d} command-line option:
2c5c0674 2776to make @code{ld} assign space to common symbols even if a relocatable
ec40bbb8 2777output file is specified (@samp{-r}).
b4d4e8e3 2778
2c5c0674 2779@kindex INPUT ( @var{files} )
2c5c0674 2780@cindex binary input files
1fb57a5d
RP
2781@item INPUT ( @var{file}, @var{file}, @dots{} )
2782@itemx INPUT ( @var{file} @var{file} @dots{} )
2c5c0674 2783Use this command to include binary input files in the link, without
7f9ae73e
RP
2784including them in a particular section definition.
2785Specify the full name for each @var{file}, including @samp{.a} if
2786required.
2787
2788@code{ld} searches for each @var{file} through the archive-library
2789search path, just as for files you specify on the command line.
2790See the description of @samp{-L} in @ref{Options,,Command Line
2791Options}.
b4d4e8e3 2792
01bc8f35
ILT
2793If you use @samp{-l@var{file}}, @code{ld} will transform the name to
2794@code{lib@var{file}.a} as with the command line argument @samp{-l}.
2795
0b3499f6
ILT
2796@kindex GROUP ( @var{files} )
2797@cindex grouping input files
2798@item GROUP ( @var{file}, @var{file}, @dots{} )
2799@itemx GROUP ( @var{file} @var{file} @dots{} )
2800This command is like @code{INPUT}, except that the named files should
2801all be archives, and they are searched repeatedly until no new undefined
2802references are created. See the description of @samp{-(} in
2803@ref{Options,,Command Line Options}.
2804
2c5c0674 2805@ignore
2c5c0674 2806@kindex MAP ( @var{name} )
c653b370 2807@item MAP ( @var{name} )
2c5c0674
RP
2808@c MAP(...) appears to look for an F in the arg, ignoring all other
2809@c chars; if it finds one, it sets "map_option_f" to true. But nothing
2810@c checks map_option_f. Apparently a stub for the future...
2811@end ignore
b4d4e8e3 2812
2c5c0674
RP
2813@kindex OUTPUT ( @var{filename} )
2814@cindex naming the output file
c653b370 2815@item OUTPUT ( @var{filename} )
d76ae847
RP
2816Use this command to name the link output file @var{filename}. The
2817effect of @code{OUTPUT(@var{filename})} is identical to the effect of
c477527c
ILT
2818@w{@samp{-o @var{filename}}}, which overrides it. You can use this
2819command to supply a default output-file name other than @code{a.out}.
2c5c0674 2820
ec40bbb8 2821@ifclear SingleFormat
2c5c0674
RP
2822@kindex OUTPUT_ARCH ( @var{bfdname} )
2823@cindex machine architecture, output
c653b370 2824@item OUTPUT_ARCH ( @var{bfdname} )
2c5c0674
RP
2825Specify a particular output machine architecture, with one of the names
2826used by the BFD back-end routines (@pxref{BFD}). This command is often
2827unnecessary; the architecture is most often set implicitly by either the
2828system BFD configuration or as a side effect of the @code{OUTPUT_FORMAT}
ec40bbb8 2829command.
2c5c0674 2830
2c5c0674
RP
2831@kindex OUTPUT_FORMAT ( @var{bfdname} )
2832@cindex format, output file
c653b370 2833@item OUTPUT_FORMAT ( @var{bfdname} )
1fb57a5d
RP
2834When @code{ld} is configured to support multiple object code formats,
2835you can use this command to specify a particular output format.
2836@var{bfdname} is one of the names used by the BFD back-end routines
2837(@pxref{BFD}). The effect is identical to the effect of the
9fde46a4
ILT
2838@samp{--oformat} command-line option. This selection affects only the
2839output file; the related command @code{TARGET} affects primarily input
2840files.
ec40bbb8 2841@end ifclear
2c5c0674 2842
2c5c0674
RP
2843@kindex SEARCH_DIR ( @var{path} )
2844@cindex path for libraries
2845@cindex search path, libraries
c653b370 2846@item SEARCH_DIR ( @var{path} )
246504a5 2847Add @var{path} to the list of paths where @code{ld} looks for
2c5c0674 2848archive libraries. @code{SEARCH_DIR(@var{path})} has the same
ec40bbb8 2849effect as @samp{-L@var{path}} on the command line.
2c5c0674 2850
2c5c0674
RP
2851@kindex STARTUP ( @var{filename} )
2852@cindex first input file
c653b370 2853@item STARTUP ( @var{filename} )
2c5c0674
RP
2854Ensure that @var{filename} is the first input file used in the link
2855process.
b4d4e8e3 2856
ec40bbb8 2857@ifclear SingleFormat
2c5c0674
RP
2858@cindex input file format
2859@kindex TARGET ( @var{format} )
c653b370 2860@item TARGET ( @var{format} )
1fb57a5d
RP
2861When @code{ld} is configured to support multiple object code formats,
2862you can use this command to change the input-file object code format
9fde46a4 2863(like the command-line option @samp{-b} or its synonym @samp{--format}).
1fb57a5d
RP
2864The argument @var{format} is one of the strings used by BFD to name
2865binary formats. If @code{TARGET} is specified but @code{OUTPUT_FORMAT}
2866is not, the last @code{TARGET} argument is also used as the default
2867format for the @code{ld} output file. @xref{BFD}.
2c5c0674
RP
2868
2869@kindex GNUTARGET
246504a5 2870If you don't use the @code{TARGET} command, @code{ld} uses the value of
2c5c0674 2871the environment variable @code{GNUTARGET}, if available, to select the
246504a5 2872output file format. If that variable is also absent, @code{ld} uses
2c5c0674 2873the default format configured for your machine in the BFD libraries.
ec40bbb8 2874@end ifclear
582dd77f
ILT
2875
2876@cindex cross references
2877@kindex NOCROSSREFS ( @var{sections} )
2878@item NOCROSSREFS ( @var{section} @var{section} @dots{} )
2879This command may be used to tell @code{ld} to issue an error about any
2880references among certain sections.
2881
2882In certain types of programs, particularly on embedded systems, when one
2883section is loaded into memory, another section will not be. Any direct
2884references between the two sections would be errors. For example, it
2885would be an error if code in one section called a function defined in
2886the other section.
2887
2888The @code{NOCROSSREFS} command takes a list of section names. If
2889@code{ld} detects any cross references between the sections, it reports
2890an error and returns a non-zero exit status. The @code{NOCROSSREFS}
2891command uses output section names, defined in the @code{SECTIONS}
2892command. It does not use the names of input sections.
b4d4e8e3
RP
2893@end table
2894
ec40bbb8
DM
2895@ifset GENERIC
2896@node Machine Dependent
1c48127e
RP
2897@chapter Machine Dependent Features
2898
2899@cindex machine dependencies
246504a5
RP
2900@code{ld} has additional features on some platforms; the following
2901sections describe them. Machines where @code{ld} has no additional
1c48127e
RP
2902functionality are not listed.
2903
2904@menu
246504a5
RP
2905* H8/300:: @code{ld} and the H8/300
2906* i960:: @code{ld} and the Intel 960 family
1c48127e 2907@end menu
ec40bbb8
DM
2908@end ifset
2909
7f9ae73e 2910@c FIXME! This could use @raisesections/@lowersections, but there seems to be a conflict
ec40bbb8
DM
2911@c between those and node-defaulting.
2912@ifset H8300
2913@ifclear GENERIC
7f9ae73e 2914@raisesections
ec40bbb8
DM
2915@end ifclear
2916@node H8/300
246504a5 2917@section @code{ld} and the H8/300
1c48127e
RP
2918
2919@cindex H8/300 support
246504a5 2920For the H8/300, @code{ld} can perform these global optimizations when
9fde46a4 2921you specify the @samp{--relax} command-line option.
1c48127e
RP
2922
2923@table @emph
d76ae847 2924@cindex relaxing on H8/300
c653b370 2925@item relaxing address modes
246504a5 2926@code{ld} finds all @code{jsr} and @code{jmp} instructions whose
1c48127e
RP
2927targets are within eight bits, and turns them into eight-bit
2928program-counter relative @code{bsr} and @code{bra} instructions,
2929respectively.
2930
d76ae847 2931@cindex synthesizing on H8/300
c653b370 2932@item synthesizing instructions
1c48127e 2933@c FIXME: specifically mov.b, or any mov instructions really?
246504a5 2934@code{ld} finds all @code{mov.b} instructions which use the
1c48127e
RP
2935sixteen-bit absolute address form, but refer to the top
2936page of memory, and changes them to use the eight-bit address form.
2937(That is: the linker turns @samp{mov.b @code{@@}@var{aa}:16} into
2938@samp{mov.b @code{@@}@var{aa}:8} whenever the address @var{aa} is in the
2939top page of memory).
2940@end table
ec40bbb8 2941@ifclear GENERIC
7f9ae73e 2942@lowersections
ec40bbb8
DM
2943@end ifclear
2944@end ifset
2945
f9d3d71a
ILT
2946@ifclear GENERIC
2947@ifset Hitachi
2948@c This stuff is pointless to say unless you're especially concerned
2949@c with Hitachi chips; don't enable it for generic case, please.
2950@node Hitachi
2951@chapter @code{ld} and other Hitachi chips
2952
2953@code{ld} also supports the H8/300H, the H8/500, and the Hitachi SH. No
2954special features, commands, or command-line options are required for
2955these chips.
2956@end ifset
2957@end ifclear
2958
ec40bbb8
DM
2959@ifset I960
2960@ifclear GENERIC
7f9ae73e 2961@raisesections
ec40bbb8
DM
2962@end ifclear
2963@node i960
246504a5 2964@section @code{ld} and the Intel 960 family
1c48127e
RP
2965
2966@cindex i960 support
d76ae847 2967
1c48127e
RP
2968You can use the @samp{-A@var{architecture}} command line option to
2969specify one of the two-letter names identifying members of the 960
2970family; the option specifies the desired output target, and warns of any
2971incompatible instructions in the input files. It also modifies the
2972linker's search strategy for archive libraries, to support the use of
2973libraries specific to each particular architecture, by including in the
2974search loop names suffixed with the string identifying the architecture.
2975
246504a5 2976For example, if your @code{ld} command line included @w{@samp{-ACA}} as
1c48127e 2977well as @w{@samp{-ltry}}, the linker would look (in its built-in search
ec40bbb8 2978paths, and in any paths you specify with @samp{-L}) for a library with
1c48127e 2979the names
ec40bbb8 2980
c653b370
ILT
2981@smallexample
2982@group
1c48127e
RP
2983try
2984libtry.a
2985tryca
2986libtryca.a
c653b370
ILT
2987@end group
2988@end smallexample
ec40bbb8 2989
1c48127e
RP
2990@noindent
2991The first two possibilities would be considered in any event; the last
2992two are due to the use of @w{@samp{-ACA}}.
2993
ec40bbb8 2994You can meaningfully use @samp{-A} more than once on a command line, since
1c48127e 2995the 960 architecture family allows combination of target architectures; each
ec40bbb8 2996use will add another pair of name variants to search for when @w{@samp{-l}}
1c48127e 2997specifies a library.
1fb57a5d 2998
9fde46a4 2999@cindex @code{--relax} on i960
1fb57a5d 3000@cindex relaxing on i960
9fde46a4
ILT
3001@code{ld} supports the @samp{--relax} option for the i960 family. If
3002you specify @samp{--relax}, @code{ld} finds all @code{balx} and
3003@code{calx} instructions whose targets are within 24 bits, and turns
3004them into 24-bit program-counter relative @code{bal} and @code{cal}
1fb57a5d
RP
3005instructions, respectively. @code{ld} also turns @code{cal}
3006instructions into @code{bal} instructions when it determines that the
3007target subroutine is a leaf routine (that is, the target subroutine does
3008not itself call any subroutines).
3009
ec40bbb8 3010@ifclear GENERIC
7f9ae73e 3011@lowersections
ec40bbb8
DM
3012@end ifclear
3013@end ifset
1c48127e 3014
ec40bbb8
DM
3015@ifclear SingleFormat
3016@node BFD
f22eee08
RP
3017@chapter BFD
3018
2c5c0674
RP
3019@cindex back end
3020@cindex object file management
d4e5e3c3
DM
3021@cindex object formats available
3022@kindex objdump -i
2c5c0674
RP
3023The linker accesses object and archive files using the BFD libraries.
3024These libraries allow the linker to use the same routines to operate on
3025object files whatever the object file format. A different object file
3026format can be supported simply by creating a new BFD back end and adding
d4e5e3c3
DM
3027it to the library. To conserve runtime memory, however, the linker and
3028associated tools are usually configured to support only a subset of the
3029object file formats available. You can use @code{objdump -i}
1c48127e 3030(@pxref{objdump,,objdump,binutils.info,The GNU Binary Utilities}) to
d4e5e3c3 3031list all the formats available for your configuration.
f22eee08 3032
2c5c0674
RP
3033@cindex BFD requirements
3034@cindex requirements for BFD
3035As with most implementations, BFD is a compromise between
f22eee08 3036several conflicting requirements. The major factor influencing
2c5c0674
RP
3037BFD design was efficiency: any time used converting between
3038formats is time which would not have been spent had BFD not
f22eee08 3039been involved. This is partly offset by abstraction payback; since
2c5c0674 3040BFD simplifies applications and back ends, more time and care
f22eee08
RP
3041may be spent optimizing algorithms for a greater speed.
3042
2c5c0674
RP
3043One minor artifact of the BFD solution which you should bear in
3044mind is the potential for information loss. There are two places where
ec40bbb8 3045useful information can be lost using the BFD mechanism: during
2c5c0674
RP
3046conversion and during output. @xref{BFD information loss}.
3047
3048@menu
2d59b2c3 3049* BFD outline:: How it works: an outline of BFD
2c5c0674 3050@end menu
f22eee08 3051
ec40bbb8 3052@node BFD outline
b4d4e8e3 3053@section How it works: an outline of BFD
2c5c0674 3054@cindex opening object files
3e27cc11 3055@include bfdsumm.texi
ec40bbb8 3056@end ifclear
f22eee08 3057
9fde46a4
ILT
3058@node Reporting Bugs
3059@chapter Reporting Bugs
3060@cindex bugs in @code{ld}
3061@cindex reporting bugs in @code{ld}
3062
3063Your bug reports play an essential role in making @code{ld} reliable.
3064
3065Reporting a bug may help you by bringing a solution to your problem, or
3066it may not. But in any case the principal function of a bug report is
3067to help the entire community by making the next version of @code{ld}
3068work better. Bug reports are your contribution to the maintenance of
3069@code{ld}.
3070
3071In order for a bug report to serve its purpose, you must include the
3072information that enables us to fix the bug.
3073
3074@menu
3075* Bug Criteria:: Have you found a bug?
3076* Bug Reporting:: How to report bugs
3077@end menu
3078
3079@node Bug Criteria
3080@section Have you found a bug?
3081@cindex bug criteria
3082
3083If you are not sure whether you have found a bug, here are some guidelines:
3084
3085@itemize @bullet
3086@cindex fatal signal
3087@cindex linker crash
3088@cindex crash of linker
3089@item
3090If the linker gets a fatal signal, for any input whatever, that is a
3091@code{ld} bug. Reliable linkers never crash.
3092
3093@cindex error on valid input
3094@item
3095If @code{ld} produces an error message for valid input, that is a bug.
3096
3097@cindex invalid input
3098@item
3099If @code{ld} does not produce an error message for invalid input, that
3100may be a bug. In the general case, the linker can not verify that
3101object files are correct.
3102
3103@item
3104If you are an experienced user of linkers, your suggestions for
3105improvement of @code{ld} are welcome in any case.
3106@end itemize
3107
3108@node Bug Reporting
3109@section How to report bugs
3110@cindex bug reports
3111@cindex @code{ld} bugs, reporting
3112
3113A number of companies and individuals offer support for @sc{gnu}
3114products. If you obtained @code{ld} from a support organization, we
3115recommend you contact that organization first.
3116
3117You can find contact information for many support companies and
3118individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
3119distribution.
3120
3121In any event, we also recommend that you send bug reports for @code{ld}
3122to @samp{bug-gnu-utils@@prep.ai.mit.edu}.
3123
3124The fundamental principle of reporting bugs usefully is this:
3125@strong{report all the facts}. If you are not sure whether to state a
3126fact or leave it out, state it!
3127
3128Often people omit facts because they think they know what causes the
3129problem and assume that some details do not matter. Thus, you might
3130assume that the name of a symbol you use in an example does not matter.
3131Well, probably it does not, but one cannot be sure. Perhaps the bug is
3132a stray memory reference which happens to fetch from the location where
3133that name is stored in memory; perhaps, if the name were different, the
3134contents of that location would fool the linker into doing the right
3135thing despite the bug. Play it safe and give a specific, complete
3136example. That is the easiest thing for you to do, and the most helpful.
3137
3138Keep in mind that the purpose of a bug report is to enable us to fix the bug if
3139it is new to us. Therefore, always write your bug reports on the assumption
3140that the bug has not been reported previously.
3141
3142Sometimes people give a few sketchy facts and ask, ``Does this ring a
3143bell?'' Those bug reports are useless, and we urge everyone to
3144@emph{refuse to respond to them} except to chide the sender to report
3145bugs properly.
3146
3147To enable us to fix the bug, you should include all these things:
3148
3149@itemize @bullet
3150@item
3151The version of @code{ld}. @code{ld} announces it if you start it with
3152the @samp{--version} argument.
3153
3154Without this, we will not know whether there is any point in looking for
3155the bug in the current version of @code{ld}.
3156
3157@item
3158Any patches you may have applied to the @code{ld} source, including any
3159patches made to the @code{BFD} library.
3160
3161@item
3162The type of machine you are using, and the operating system name and
3163version number.
3164
3165@item
3166What compiler (and its version) was used to compile @code{ld}---e.g.
3167``@code{gcc-2.7}''.
3168
3169@item
3170The command arguments you gave the linker to link your example and
3171observe the bug. To guarantee you will not omit something important,
3172list them all. A copy of the Makefile (or the output from make) is
3173sufficient.
3174
3175If we were to try to guess the arguments, we would probably guess wrong
3176and then we might not encounter the bug.
3177
3178@item
3179A complete input file, or set of input files, that will reproduce the
3180bug. It is generally most helpful to send the actual object files,
3181uuencoded if necessary to get them through the mail system. Making them
3182available for anonymous FTP is not as good, but may be the only
3183reasonable choice for large object files.
3184
3185If the source files were assembled using @code{gas} or compiled using
3186@code{gcc}, then it may be OK to send the source files rather than the
3187object files. In this case, be sure to say exactly what version of
3188@code{gas} or @code{gcc} was used to produce the object files. Also say
3189how @code{gas} or @code{gcc} were configured.
3190
3191@item
3192A description of what behavior you observe that you believe is
3193incorrect. For example, ``It gets a fatal signal.''
3194
3195Of course, if the bug is that @code{ld} gets a fatal signal, then we
3196will certainly notice it. But if the bug is incorrect output, we might
3197not notice unless it is glaringly wrong. You might as well not give us
3198a chance to make a mistake.
3199
3200Even if the problem you experience is a fatal signal, you should still
3201say so explicitly. Suppose something strange is going on, such as, your
3202copy of @code{ld} is out of synch, or you have encountered a bug in the
3203C library on your system. (This has happened!) Your copy might crash
3204and ours would not. If you told us to expect a crash, then when ours
3205fails to crash, we would know that the bug was not happening for us. If
3206you had not told us to expect a crash, then we would not be able to draw
3207any conclusion from our observations.
3208
3209@item
3210If you wish to suggest changes to the @code{ld} source, send us context
3211diffs, as generated by @code{diff} with the @samp{-u}, @samp{-c}, or
3212@samp{-p} option. Always send diffs from the old file to the new file.
3213If you even discuss something in the @code{ld} source, refer to it by
3214context, not by line number.
3215
3216The line numbers in our development sources will not match those in your
3217sources. Your line numbers would convey no useful information to us.
3218@end itemize
3219
3220Here are some things that are not necessary:
3221
3222@itemize @bullet
3223@item
3224A description of the envelope of the bug.
3225
3226Often people who encounter a bug spend a lot of time investigating
3227which changes to the input file will make the bug go away and which
3228changes will not affect it.
3229
3230This is often time consuming and not very useful, because the way we
3231will find the bug is by running a single example under the debugger
3232with breakpoints, not by pure deduction from a series of examples.
3233We recommend that you save your time for something else.
3234
3235Of course, if you can find a simpler example to report @emph{instead}
3236of the original one, that is a convenience for us. Errors in the
3237output will be easier to spot, running under the debugger will take
3238less time, and so on.
3239
3240However, simplification is not vital; if you do not want to do this,
3241report the bug anyway and send us the entire test case you used.
3242
3243@item
3244A patch for the bug.
3245
3246A patch for the bug does help us if it is a good one. But do not omit
3247the necessary information, such as the test case, on the assumption that
3248a patch is all we need. We might see problems with your patch and decide
3249to fix the problem another way, or we might not understand it at all.
3250
de220cbd
ILT
3251Sometimes with a program as complicated as @code{ld} it is very hard to
3252construct an example that will make the program follow a certain path
3253through the code. If you do not send us the example, we will not be
3254able to construct one, so we will not be able to verify that the bug is
3255fixed.
9fde46a4
ILT
3256
3257And if we cannot understand what bug you are trying to fix, or why your
3258patch should be an improvement, we will not install it. A test case will
3259help us to understand.
3260
3261@item
3262A guess about what the bug is or what it depends on.
3263
3264Such guesses are usually wrong. Even we cannot guess right about such
3265things without first using the debugger to find the facts.
3266@end itemize
3267
ec40bbb8 3268@node MRI
2d59b2c3
RP
3269@appendix MRI Compatible Script Files
3270@cindex MRI compatibility
3271To aid users making the transition to @sc{gnu} @code{ld} from the MRI
3272linker, @code{ld} can use MRI compatible linker scripts as an
3273alternative to the more general-purpose linker scripting language
3274described in @ref{Commands,,Command Language}. MRI compatible linker
3275scripts have a much simpler command set than the scripting language
3276otherwise used with @code{ld}. @sc{gnu} @code{ld} supports the most
3277commonly used MRI linker commands; these commands are described here.
3278
867a1b8a
DM
3279In general, MRI scripts aren't of much use with the @code{a.out} object
3280file format, since it only has three sections and MRI scripts lack some
3281features to make use of them.
3282
2d59b2c3
RP
3283You can specify a file containing an MRI-compatible script using the
3284@samp{-c} command-line option.
3285
3286Each command in an MRI-compatible script occupies its own line; each
3287command line starts with the keyword that identifies the command (though
3288blank lines are also allowed for punctuation). If a line of an
3289MRI-compatible script begins with an unrecognized keyword, @code{ld}
3290issues a warning message, but continues processing the script.
3291
3292Lines beginning with @samp{*} are comments.
3293
3294You can write these commands using all upper-case letters, or all
3295lower case; for example, @samp{chip} is the same as @samp{CHIP}.
3296The following list shows only the upper-case form of each command.
3297
3298@table @code
d4e5e3c3 3299@cindex @code{ABSOLUTE} (MRI)
2d59b2c3 3300@item ABSOLUTE @var{secname}
c653b370 3301@itemx ABSOLUTE @var{secname}, @var{secname}, @dots{} @var{secname}
2d59b2c3
RP
3302Normally, @code{ld} includes in the output file all sections from all
3303the input files. However, in an MRI-compatible script, you can use the
3304@code{ABSOLUTE} command to restrict the sections that will be present in
3305your output program. If the @code{ABSOLUTE} command is used at all in a
3306script, then only the sections named explicitly in @code{ABSOLUTE}
3307commands will appear in the linker output. You can still use other
3308input sections (whatever you select on the command line, or using
7b015547 3309@code{LOAD}) to resolve addresses in the output file.
2d59b2c3 3310
2d59b2c3 3311@cindex @code{ALIAS} (MRI)
d4e5e3c3 3312@item ALIAS @var{out-secname}, @var{in-secname}
2d59b2c3
RP
3313Use this command to place the data from input section @var{in-secname}
3314in a section called @var{out-secname} in the linker output file.
3315
3316@var{in-secname} may be an integer.
3317
e54bf1c1
ILT
3318@cindex @code{ALIGN} (MRI)
3319@item ALIGN @var{secname} = @var{expression}
3320Align the section called @var{secname} to @var{expression}. The
3321@var{expression} should be a power of two.
3322
2d59b2c3 3323@cindex @code{BASE} (MRI)
d4e5e3c3 3324@item BASE @var{expression}
2d59b2c3
RP
3325Use the value of @var{expression} as the lowest address (other than
3326absolute addresses) in the output file.
3327
d4e5e3c3 3328@cindex @code{CHIP} (MRI)
2d59b2c3
RP
3329@item CHIP @var{expression}
3330@itemx CHIP @var{expression}, @var{expression}
ec40bbb8 3331This command does nothing; it is accepted only for compatibility.
2d59b2c3 3332
2d59b2c3 3333@cindex @code{END} (MRI)
d4e5e3c3 3334@item END
2d59b2c3
RP
3335This command does nothing whatever; it's only accepted for compatibility.
3336
2d59b2c3 3337@cindex @code{FORMAT} (MRI)
d4e5e3c3 3338@item FORMAT @var{output-format}
2d59b2c3
RP
3339Similar to the @code{OUTPUT_FORMAT} command in the more general linker
3340language, but restricted to one of these output formats:
d4e5e3c3 3341
2d59b2c3
RP
3342@enumerate
3343@item
3344S-records, if @var{output-format} is @samp{S}
3345
3346@item
3347IEEE, if @var{output-format} is @samp{IEEE}
3348
3349@item
3350COFF (the @samp{coff-m68k} variant in BFD), if @var{output-format} is
3351@samp{COFF}
3352@end enumerate
3353
2d59b2c3 3354@cindex @code{LIST} (MRI)
d4e5e3c3 3355@item LIST @var{anything}@dots{}
2d59b2c3
RP
3356Print (to the standard output file) a link map, as produced by the
3357@code{ld} command-line option @samp{-M}.
3358
ec40bbb8
DM
3359The keyword @code{LIST} may be followed by anything on the
3360same line, with no change in its effect.
2d59b2c3 3361
d4e5e3c3 3362@cindex @code{LOAD} (MRI)
2d59b2c3 3363@item LOAD @var{filename}
c653b370 3364@itemx LOAD @var{filename}, @var{filename}, @dots{} @var{filename}
2d59b2c3
RP
3365Include one or more object file @var{filename} in the link; this has the
3366same effect as specifying @var{filename} directly on the @code{ld}
3367command line.
3368
2d59b2c3 3369@cindex @code{NAME} (MRI)
d4e5e3c3 3370@item NAME @var{output-name}
2d59b2c3
RP
3371@var{output-name} is the name for the program produced by @code{ld}; the
3372MRI-compatible command @code{NAME} is equivalent to the command-line
3373option @samp{-o} or the general script language command @code{OUTPUT}.
3374
d4e5e3c3 3375@cindex @code{ORDER} (MRI)
2d59b2c3
RP
3376@item ORDER @var{secname}, @var{secname}, @dots{} @var{secname}
3377@itemx ORDER @var{secname} @var{secname} @var{secname}
ec40bbb8
DM
3378Normally, @code{ld} orders the sections in its output file in the
3379order in which they first appear in the input files. In an MRI-compatible
3380script, you can override this ordering with the @code{ORDER} command. The
2d59b2c3
RP
3381sections you list with @code{ORDER} will appear first in your output
3382file, in the order specified.
3383
d4e5e3c3 3384@cindex @code{PUBLIC} (MRI)
2d59b2c3
RP
3385@item PUBLIC @var{name}=@var{expression}
3386@itemx PUBLIC @var{name},@var{expression}
3387@itemx PUBLIC @var{name} @var{expression}
ec40bbb8 3388Supply a value (@var{expression}) for external symbol
2d59b2c3
RP
3389@var{name} used in the linker input files.
3390
d4e5e3c3 3391@cindex @code{SECT} (MRI)
2d59b2c3
RP
3392@item SECT @var{secname}, @var{expression}
3393@itemx SECT @var{secname}=@var{expression}
3394@itemx SECT @var{secname} @var{expression}
2d59b2c3
RP
3395You can use any of these three forms of the @code{SECT} command to
3396specify the start address (@var{expression}) for section @var{secname}.
3397If you have more than one @code{SECT} statement for the same
3398@var{secname}, only the @emph{first} sets the start address.
3399@end table
3400
ec40bbb8 3401@node Index
2c5c0674
RP
3402@unnumbered Index
3403
3404@printindex cp
3405
3406@tex
3407% I think something like @colophon should be in texinfo. In the
3408% meantime:
3409\long\def\colophon{\hbox to0pt{}\vfill
3410\centerline{The body of this manual is set in}
3411\centerline{\fontname\tenrm,}
3412\centerline{with headings in {\bf\fontname\tenbf}}
3413\centerline{and examples in {\tt\fontname\tentt}.}
3414\centerline{{\it\fontname\tenit\/} and}
3415\centerline{{\sl\fontname\tensl\/}}
3416\centerline{are used for emphasis.}\vfill}
3417\page\colophon
c653b370 3418% Blame: doc@cygnus.com, 28mar91.
2c5c0674
RP
3419@end tex
3420
3421
b4d4e8e3 3422@contents
f22eee08
RP
3423@bye
3424
3425
This page took 0.402097 seconds and 4 git commands to generate.