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