10 * Ld: (ld). The GNU linker.
16 This file documents the GNU linker LD.
18 Copyright (C) 1991, 1992 Free Software Foundation, Inc.
20 Permission is granted to make and distribute verbatim copies of
21 this manual provided the copyright notice and this permission notice
22 are preserved on all copies.
25 Permission is granted to process this file through Tex and print the
26 results, provided the printed document carries copying permission
27 notice identical to this one except for the removal of this paragraph
28 (this paragraph not being relevant to the printed manual).
31 Permission is granted to copy and distribute modified versions of this
32 manual under the conditions for verbatim copying, provided also that the
33 section entitled ``GNU General Public License'' is included exactly as
34 in the original, and provided that the entire resulting derived work is
35 distributed under the terms of a permission notice identical to this
38 Permission is granted to copy and distribute translations of this manual
39 into another language, under the above conditions for modified versions,
40 except that the section entitled ``GNU General Public License'' may be
41 included in a translation approved by the author instead of in the
46 @setchapternewpage odd
47 @settitle Using LD, the GNU linker
50 @subtitle The GNU linker
52 @subtitle @code{ld} version 2
54 @author Steve Chamberlain and Roland Pesch
55 @author Cygnus Support
59 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
60 \xdef\manvers{\$Revision$} % For use in headers, footers too
62 \hfill Cygnus Support\par
63 \hfill steve\@cygnus.com, pesch\@cygnus.com\par
64 \hfill {\it Using LD, the GNU linker}, \manvers\par
65 \hfill \TeX{}info \texinfoversion\par
67 \global\parindent=0pt % Steve likes it this way.
70 @vskip 0pt plus 1filll
71 Copyright @copyright{} 1991, 1992 Free Software Foundation, Inc.
73 Permission is granted to make and distribute verbatim copies of
74 this manual provided the copyright notice and this permission notice
75 are preserved on all copies.
77 Permission is granted to copy and distribute modified versions of this
78 manual under the conditions for verbatim copying, provided also that
79 the entire resulting derived work is distributed under the terms of a
80 permission notice identical to this one.
82 Permission is granted to copy and distribute translations of this manual
83 into another language, under the above conditions for modified versions.
86 @c FIXME: Talk about importance of *order* of args, cmds to linker!
88 @node Top, Overview, (dir), (dir)
90 This file documents the GNU linker ld.
95 * Invocation:: Invocation
96 * Commands:: Command Language
97 * Machine Dependent:: Machine Dependent Features
99 * MRI:: MRI Compatible Script Files
102 --- The Detailed Node Listing ---
106 * Options:: Command Line Options
107 * Environment:: Environment Variables
111 * Scripts:: Linker Scripts
112 * Expressions:: Expressions
113 * MEMORY:: MEMORY Command
114 * SECTIONS:: SECTIONS Command
115 * Entry Point:: The Entry Point
116 * Other Commands:: Other Commands
120 * Integers:: Integers
121 * Symbols:: Symbol Names
122 * Location Counter:: The Location Counter
123 * Operators:: Operators
124 * Evaluation:: Evaluation
125 * Assignment:: Assignment: Defining Symbols
126 * Built-ins:: Built-In Functions
130 * Section Definition:: Section Definitions
131 * Section Contents:: Section Contents
132 * Section Options:: Optional Section Attributes
134 Machine Dependent Features
136 * H8/300:: @code{ld} and the H8/300
137 * i960:: @code{ld} and the Intel 960 family
138 * m68k:: @code{ld} and the Motorola 68000 family
139 * m88k:: @code{ld} and the Motorola 880x0 family
141 @code{ld} and the Intel 960 family
143 * i960-arch:: Linking for a Specific i960 Architecture
144 * i960-emulation:: Emulating Other i960 Linkers
145 * i960-commands:: Command Language Extensions for i960
149 * BFD outline:: How it works: an outline of BFD
150 * BFD information loss:: Information Loss
151 * Mechanism:: Mechanism
154 @node Overview, Invocation, Top, Top
158 @cindex what is this?
159 @code{ld} combines a number of object and archive files, relocates
160 their data and ties up symbol references. Often the last step in
161 building a new compiled program to run is a call to @code{ld}.
163 @code{ld} accepts Linker Command Language files written in
164 a superset of AT&T's Link Editor Command Language syntax,
165 to provide explicit and total control over the linking process.
167 This version of @code{ld} uses the general purpose BFD libraries
168 to operate on object files. This allows @code{ld} to read, combine, and
169 write object files in many different formats---for example, COFF or
170 @code{a.out}. Different formats may be linked together to produce any
171 available kind of object file. @xref{BFD} for a list of formats
172 supported on various architectures.
174 Aside from its flexibility, the GNU linker is more helpful than other
175 linkers in providing diagnostic information. Many linkers abandon
176 execution immediately upon encountering an error; whenever possible,
177 @code{ld} continues executing, allowing you to identify other errors
178 (or, in some cases, to get an output file in spite of the error).
180 @node Invocation, Commands, Overview, Top
183 The GNU linker @code{ld} is meant to cover a broad range of situations,
184 and to be as compatible as possible with other linkers. As a result,
185 you have many choices to control its behavior through the command line,
186 and through environment variables.
189 * Options:: Command Line Options
190 * Environment:: Environment Variables
193 @node Options, Environment, Invocation, Invocation
194 @section Command Line Options
198 Here is a sketch of the options you can use on the @code{ld} command
202 ld [-o @var{output} ] @var{objfiles}@dots{}
203 [ -A@var{architecture} ] [ -b @var{input-format} ] [ -Bstatic ]
204 [ -c @var{MRI-commandfile} ] [ -d | -dc | -dp ]
205 [ -defsym @var{symbol} = @var{expression} ]
206 [ -e @var{entry} ] [ -F ] [ -F @var{format} ]
207 [ -format @var{input-format} ] [ -g ] [ -i ]
208 [ -l@var{ar} ] [ -L@var{searchdir} ] [ -M | -m ]
209 [ -n | -N ] [ -noinhibit-exec ] [ -R @var{filename} ] [ -relax ]
210 [ -r | -Ur ] [ -S ] [ -s ] [ -T @var{commandfile} ]
211 [ -Ttext @var{textorg} ] [ -Tdata @var{dataorg} ] [ -Tbss @var{bssorg} ]
212 [ -t ] [ -u @var{sym}] [-v] [ -X ] [ -x ]
213 [ @{ @var{script} @} ]
216 This plethora of command-line options may seem intimidating, but in
217 actual practice few of them are used in any particular context.
218 @cindex standard Unix system
219 For instance, a frequent use of @code{ld} is to link standard Unix
220 object files on a standard, supported Unix system. On such a system, to
221 link a file @code{hello.o}:
223 $ ld -o output /lib/crt0.o hello.o -lc
225 This tells @code{ld} to produce a file called @code{output} as the
226 result of linking the file @code{/lib/crt0.o} with @code{hello.o} and
227 the library @code{libc.a} which will come from the standard search
230 The command-line options to @code{ld} may be specified in any order, and
231 may be repeated at will. For the most part, repeating an option with a
232 different argument will either have no further effect, or override prior
233 occurrences (those further to the left on the command line) of an
236 The exceptions---which may meaningfully be used more than once---are
237 @code{-A}, @code{-b} (or its synonym @code{-format}), @code{-defsym},
238 @code{-L}, @code{-l}, @code{-R}, and @code{-u}.
241 The list of object files to be linked together, shown as @var{objfiles},
242 may follow, precede, or be mixed in with command-line options; save that
243 an @var{objfiles} argument may not be placed between an option flag and
246 Usually the linker is invoked with at least one object file, but other
247 forms of binary input files can also be specified with @code{-l},
248 @code{-R}, and the script command language. If @emph{no} binary input
249 files at all are specified, the linker does not produce any output, and
250 issues the message @samp{No input files}.
252 Option arguments must either follow the option letter without intervening
253 whitespace, or be given as separate arguments immediately following the
254 option that requires them.
257 @item @var{objfiles}@dots{}
258 The object files @var{objfiles} to be linked.
260 @cindex architectures
262 @item -A@var{architecture}
263 In the current release of @code{ld}, this option is useful only for the
264 Intel 960 family of architectures. In that @code{ld} configuration, the
265 @var{architecture} argument identifies the particular architecture in
266 the 960 family, enabling some safeguards and modifying the
267 archive-library search path. @xref{i960-arch,,,Linking for a Specific
268 i960 Architecture}, for details.
270 Future releases of @code{ld} may support similar functionality for
271 other architecture families.
273 @cindex binary input format
274 @kindex -b @var{format}
276 @item -b @var{input-format}
278 Specify the binary format for input object files that follow this option
279 on the command line. You don't usually need to specify this, as
280 @code{ld} is configured to expect as a default input format the most
281 usual format on each machine. @var{input-format} is a text string, the
282 name of a particular format supported by the BFD libraries. @xref{BFD}.
283 @code{-format @var{input-format}} has the same effect.@refill
285 You may want to use this option if you are linking files with an unusual
286 binary format. You can also use @code{-b} to switch formats explicitly (when
287 linking object files of different formats), by including
288 @code{-b @var{input-format}} before each group of object files in a
291 The default format is taken from the environment variable
292 @code{GNUTARGET}. @xref{Environment}. You can also define the input
293 format from a script, using the command @code{TARGET}.
297 This flag is accepted for command-line compatibility with the SunOS linker,
298 but has no effect on @code{ld}.
300 @kindex -c @var{MRI-cmdfile}
301 @cindex compatibility, MRI
302 @item -c @var{MRI-commandfile}
303 For compatibility with linkers produced by MRI, @code{ld} accepts script
304 files written in an alternate, restricted command language, described in
305 @ref{MRI,,MRI Compatible Script Files}. Introduce such script files
306 with the option flag @samp{-c}.
308 Use the @samp{-T} option to run linker scripts written in the general-purpose
309 @code{ld} scripting language.
311 @cindex common allocation
318 These three options are equivalent; multiple forms are supported for
319 compatibility with other linkers. Use any of them to make @code{ld}
320 assign space to common symbols even if a relocatable output file is
321 specified (@code{-r}). The script command
322 @code{FORCE_COMMON_ALLOCATION} has the same effect.
324 @cindex symbols, from command line
325 @kindex -defsym @var{symbol} = @var{exp}
326 @item -defsym @var{symbol} = @var{expression}
327 Create a global symbol in the output file, containing the absolute
328 address given by @var{expression}. You may use this option as many
329 times as necessary to define multiple symbols in the command line. A
330 limited form of arithmetic is supported for the @var{expression} in this
331 context: you may give a hexadecimal constant or the name of an existing
332 symbol, or use @code{+} and @code{-} to add or subtract hexadecimal
333 constants or symbols. If you need more elaborate expressions, consider
334 using the linker command language from a script.
336 @cindex entry point, from command line
337 @kindex -e @var{entry}
339 Use @var{entry} as the explicit symbol for beginning execution of your
340 program, rather than the default entry point. @xref{Entry Point}, for a
341 discussion of defaults and other ways of specifying the
345 @cindex fill, from command line
346 @kindex -f @var{fill}
347 @c -f in older GNU linker, not in new
349 Sets the default fill pattern for ``holes'' in the output file to
350 the lowest two bytes of the expression specified. Holes are created
351 when you advance the location counter (@xref{Location Counter}), or when
352 there is a gap between explicitly specified section addresses
353 (@xref{Section Options}).
358 @itemx -F@var{format}
359 Some older linkers used this option throughout a compilation toolchain
360 for specifying object-file format for both input and output object
361 files. @code{ld}'s mechanisms (the @code{-b} or @code{-format} options
362 for input files, the @code{TARGET} command in linker scripts for output
363 files, the @code{GNUTARGET} environment variable) are more flexible, but
364 but it accepts (and ignores) the @code{-F} option flag for compatibility
365 with scripts written to call the old linker.
368 @item -format @var{input-format}
369 Synonym for @code{-b} @var{input-format}.
373 Accepted, but ignored; provided for compatibility with other tools.
376 @cindex incremental link
378 Perform an incremental link (same as option @code{-r}).
380 @cindex archive files, from cmd line
383 Add an archive file @var{ar} to the list of files to link. This
384 option may be used any number of times. @code{ld} will search its
385 path-list for occurrences of @code{lib@var{ar}.a} for every @var{ar}
388 @cindex search directory, from cmd line
390 @item -L@var{searchdir}
391 This command adds path @var{searchdir} to the list of paths that
392 @code{ld} will search for archive libraries. You may use this option
395 The default set of paths searched (without being specified with
396 @code{-L}) depends on what emulation mode @code{ld} is using, and in
397 some cases also on how it was configured. @xref{Environment}. The
398 paths can also be specified in a link script with the @code{SEARCH_DIR}
406 Print (to the standard output file) a link map---diagnostic information
407 about where symbols are mapped by @code{ld}, and information on global
408 common storage allocation.
411 @cindex read/write from cmd line
414 specifies readable and writable @code{text} and @code{data} sections. If
415 the output format supports Unix style magic numbers, the output is
416 marked as @code{OMAGIC}.
418 When you use the @samp{-N} option, the linker does not page-align the
423 @cindex read-only text
425 sets the text segment to be read only, and @code{NMAGIC} is written
428 @item -noinhibit-exec
429 @cindex output file after errors
430 @kindex -noinhibit-exec
431 Normally, the linker will not produce an output file if it encounters
432 errors during the link process. With this flag, you can specify that
433 you wish the output file retained even after non-fatal errors.
435 @item -o @var{output}
436 @kindex -o @var{output}
437 @cindex naming the output file
438 @var{output} is a name for the program produced by @code{ld}; if this
439 option is not specified, the name @samp{a.out} is used by default. The
440 script command @code{OUTPUT} can also specify the output file name.
442 @item -R @var{filename}
443 @kindex -R @var{file}
444 @cindex symbol-only input
445 Read symbol names and their addresses from @var{filename}, but do not
446 relocate it or include it in the output. This allows your output file
447 to refer symbolically to absolute locations of memory defined in other
452 @cindex synthesizing linker
453 @cindex relaxing addressing modes
454 An option with machine dependent effects. Currently this option is only
455 supported on the H8/300; see @ref{H8/300,,@code{ld} and the H8/300}.
457 On some platforms, use this option to perform global optimizations that
458 become possible when the linker resolves addressing in your program, such
459 as relaxing address modes and synthesizing new instructions in the
462 On platforms where this is not supported, @samp{-relax} is accepted, but
467 @cindex relocatable output
469 Generates relocatable output---i.e., generate an output file that can in
470 turn serve as input to @code{ld}. This is often called @dfn{partial
471 linking}. As a side effect, in environments that support standard Unix
472 magic numbers, this option also sets the output file's magic number to
475 If this option is not specified, an absolute file is produced. When
476 linking C++ programs, this option @emph{will not} resolve references to
477 constructors; @code{-Ur} is an alternative. @refill
479 This option does the same as @code{-i}.
483 @cindex strip debugger symbols
484 Omits debugger symbol information (but not all symbols) from the output file.
488 @cindex strip all symbols
489 Omits all symbol information from the output file.
491 @item @{ @var{script} @}
492 @kindex @{ @var{script} @}
493 @cindex scripts on command line
494 You can, if you wish, include a script of linker commands directly in
495 the command line instead of referring to it via an input file. When the
496 character @samp{@{} occurs on the command line, the linker switches to
497 interpreting the command language until the end of the list of commands
498 is reached---flagged with a closing brace @samp{@}}. Other command-line
499 options will not be recognized while parsing the script.
500 @xref{Commands} for a description of the command language.
502 @item -Tbss @var{org}
503 @kindex -Tbss @var{org}
504 @itemx -Tdata @var{org}
505 @kindex -Tdata @var{org}
506 @itemx -Ttext @var{org}
507 @kindex -Ttext @var{org}
508 @cindex segment origins, cmd line
509 Use @var{org} as the starting address for---respectively---the
510 @code{bss}, @code{data}, or the @code{text} segment of the output file.
511 @var{textorg} must be a hexadecimal integer.
513 @item -T @var{commandfile}
514 @itemx -T@var{commandfile}
515 @kindex -T @var{script}
517 Directs @code{ld} to read link commands from the file
518 @var{commandfile}. These commands will completely override @code{ld}'s
519 default link format (rather than adding to it); @var{commandfile} must
520 specify everything necessary to describe the target format.
523 You may also include a script of link commands directly in the command
524 line by bracketing it between @samp{@{} and @samp{@}} characters.
529 @cindex input files, displaying
530 Prints names of input files as @code{ld} processes them.
534 @cindex undefined symbol
535 Forces @var{sym} to be entered in the output file as an undefined symbol.
536 This may, for example, trigger linking of additional modules from
537 standard libraries. @code{-u} may be repeated with different option
538 arguments to enter additional undefined symbols.
539 @c Nice idea, but no such command: This option is equivalent
540 @c to the @code{EXTERN} linker command.
545 For anything other than C++ programs, this option is equivalent to
546 @code{-r}: it generates relocatable output---i.e., an output file that can in
547 turn serve as input to @code{ld}. When linking C++ programs, @code{-Ur}
548 @emph{will} resolve references to constructors, unlike @code{-r}.
553 Display the version number for @code{ld}.
557 @cindex local symbols, deleting
558 @cindex L, deleting symbols beginning
559 If @code{-s} or @code{-S} is also specified, delete only local symbols
560 beginning with @samp{L}.
564 @cindex deleting local symbols
565 If @code{-s} or @code{-S} is also specified, delete all local symbols,
566 not just those beginning with @samp{L}.
569 @c -z in older GNU linker, not in new
572 @cindex read-only text
573 Specifies a read-only, demand pageable, and shared @code{text} segment.
574 If the output format supports Unix-style magic numbers, @code{-z} also
575 marks the output as @code{ZMAGIC}, the default.
577 @c why was following here?. Is it useful to say '-z -r' for
578 @c instance, or is this just a ref to other ways of setting
580 Specifying a relocatable output file (@code{-r}) will also set the magic
581 number to @code{OMAGIC}.
583 See description of @code{-N}.
588 @node Environment, , Options, Invocation
589 @section Environment Variables
591 You can change the behavior of @code{ld} with two environment
592 variables: @code{GNUTARGET} and @code{LDEMULATION}. Depending on the
593 setting of the latter, other environment variables may be used as well.
596 @cindex default input format
597 @code{GNUTARGET} determines the input-file object format if you don't
598 use @code{-b} (or its synonym @code{-format}). Its value should be one
599 of the BFD names for an input format (@pxref{BFD}). If there is no
600 @code{GNUTARGET} in the environment, @code{ld} uses the natural format
601 of the host. If @code{GNUTARGET} is set to @code{default} then BFD attempts to discover the
602 input format by examining binary input files; this method often
603 succeeds, but there are potential ambiguities, since there is no method
604 of ensuring that the magic number used to flag object-file formats is
605 unique. However, the configuration procedure for BFD on each system
606 places the conventional format for that system first in the search-list,
607 so ambiguities are resolved in favor of convention.
611 @cindex environment vars
612 @code{LDEMULATION} controls some aspects of @code{ld}'s dominant
613 personality. Although @code{ld} is flexible enough to permit its use
614 in many contexts regardless of configuration, you can use this variable
615 to make it act more like one or another older linker by default.
618 @cindex library paths, default
619 In particular, the value of @code{LDEMULATION} controls what default
620 linker script is used (thereby controlling the default input and output
621 formats; @pxref{BFD}); what default paths are searched for
622 archive libraries; and in some cases whether additional linker script
623 commands are available.
625 Here is the current set of emulations available:
628 @item LDEMULATION=gld
630 @cindex emulating old GNU linker
631 Emulate the older GNU linker. When this emulation is selected, the
632 default library search paths are
639 The default output format is set to @code{a.out-generic-big}, and the
640 default machine is the system's configured BFD default.
642 @item LDEMULATION=gld68k
645 A variant of the @code{gld} emulation; only differs in specifically
646 setting the default BFD machine as @code{m68k}.
648 @item LDEMULATION=gld960
649 @itemx LDEMULATION=lnk960
650 Emulate older linkers for the i960 family; see @ref{i960,,@code{ld} and
651 the Intel 960 family}, for details.
653 @item LDEMULATION=gldm88kbcs
654 Configure the linker for the Motorola 88K family.
655 @xref{m88k,,@code{gld} and the Motorola 880x0 family}, for details.
657 @item LDEMULATION=vanilla
659 @cindex emulation, disabling
660 @cindex disabling emulation
661 This is the least specific setting for @code{ld}. You can set
662 @code{LDEMULATION=vanilla} to disable emulation of other linkers. This
663 setting makes @code{ld} take the default machine from the BFD
664 configuration on your system; @code{a.out-generic-big} is the default
665 target. No other defaults are specified.
668 @node Commands, Machine Dependent, Invocation, Top
669 @chapter Command Language
671 @cindex command files
672 The command language allows explicit control over the link process,
673 allowing complete specification of the mapping between the linker's
674 input files and its output. This includes:
683 addresses of sections
685 placement of common blocks
688 You may supply a command file (also known as a link script) to the
689 linker either explicitly through the @code{-T} option, or implicitly as
690 an ordinary file. If the linker opens a file which it cannot recognize
691 as a supported object or archive format, it tries to interpret the file
694 You can also include a script directly on the @code{ld} command line,
695 delimited by the characters @samp{@{} and @samp{@}}.
698 * Scripts:: Linker Scripts
699 * Expressions:: Expressions
700 * MEMORY:: MEMORY Command
701 * SECTIONS:: SECTIONS Command
702 * Entry Point:: The Entry Point
703 * Other Commands:: Other Commands
706 @node Scripts, Expressions, Commands, Commands
707 @section Linker Scripts
708 The @code{ld} command language is a collection of statements; some are
709 simple keywords setting a particular flag, some are used to select and
710 group input files or name output files; and two particular statement
711 types have a fundamental and pervasive impact on the linking process.
713 @cindex fundamental script commands
714 @cindex commands, fundamental
715 @cindex output file layout
716 @cindex layout of output file
717 The most fundamental command of the @code{ld} command language is the
718 @code{SECTIONS} command (@pxref{SECTIONS}). Every meaningful command
719 script must have a @code{SECTIONS} command: it specifies a
720 ``picture'' of the output file's layout, in varying degrees of detail.
721 No other command is required in all cases.
723 The @code{MEMORY} command complements @code{SECTIONS} by describing the
724 available memory in the target architecture. This command is optional;
725 if you don't use a @code{MEMORY} command, @code{ld} assumes sufficient
726 memory is available in a contiguous block for all output.
730 You may include comments in linker scripts just as in C: delimited
731 by @samp{/*} and @samp{*/}. As in C, comments are syntactically
732 equivalent to whitespace.
734 @node Expressions, MEMORY, Scripts, Commands
736 @cindex expression syntax
738 Many useful commands involve arithmetic expressions. The syntax for
739 expressions in the command language is identical to that of C
740 expressions, with the following features:
743 All expressions evaluated as integers and
744 are of ``long'' or ``unsigned long'' type.
746 All constants are integers.
748 All of the C arithmetic operators are provided.
750 You may reference, define, and create global variables.
752 You may call special purpose built-in functions.
756 * Integers:: Integers
757 * Symbols:: Symbol Names
758 * Location Counter:: The Location Counter
759 * Operators:: Operators
760 * Evaluation:: Evaluation
761 * Assignment:: Assignment: Defining Symbols
762 * Built-ins:: Built-In Functions
765 @node Integers, Symbols, Expressions, Expressions
767 @cindex integer notation
768 @cindex octal integers
769 An octal integer is @samp{0} followed by zero or more of the octal
770 digits (@samp{01234567}).
775 @cindex decimal integers
776 A decimal integer starts with a non-zero digit followed by zero or
777 more digits (@samp{0123456789}).
782 @cindex hexadecimal integers
784 A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or
785 more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}.
790 @cindex negative integers
791 Decimal integers have the usual values. To write a negative integer, use
792 the prefix operator @samp{-}; @pxref{Operators}.
797 @cindex scaled integers
798 @cindex K and M integer suffixes
799 @cindex M and K integer suffixes
800 @cindex suffixes for integers
801 @cindex integer suffixes
802 Additionally the suffixes @code{K} and @code{M} may be used to scale a
806 @c END TEXI2ROFF-KILL
807 @code{1024} or @code{1024*1024}
811 ${\rm 1024}$ or ${\rm 1024}^2$
813 @c END TEXI2ROFF-KILL
814 respectively. For example, the following all refer to the same quantity:@refill
822 @node Symbols, Location Counter, Integers, Expressions
823 @subsection Symbol Names
826 @cindex quoted symbol names
828 Unless quoted, symbol names start with a letter, underscore, point or
829 hyphen and may include any letters, underscores, digits, points,
830 and minus signs. Unquoted symbol names must not conflict with any
831 keywords. You can specify a symbol which contains odd characters or has
832 the same name as a keyword, by surrounding the symbol name in double quotes:
835 "with a space" = "also with a space" + 10;
838 @node Location Counter, Operators, Symbols, Expressions
839 @subsection The Location Counter
842 @cindex location counter
843 @cindex current output location
844 The special linker variable @dfn{dot} @samp{.} always contains the
845 current output location counter. Since the @code{.} always refers to
846 a location in an output section, it must always appear in an
847 expression within a @code{SECTIONS} command. The @code{.} symbol
848 may appear anywhere that an ordinary symbol is allowed in an
849 expression, but its assignments have a side effect. Assigning a value
850 to the @code{.} symbol will cause the location counter to be moved.
852 This may be used to create holes in the output section. The location
853 counter may never be moved backwards.
868 In the previous example, @code{file1} is located at the beginning of the
869 output section, then there is a 1000 byte gap. Then @code{file2}
870 appears, also with a 1000 byte gap following before @code{file3} is
871 loaded. The notation @samp{= 0x1234} specifies what data to write in
872 the gaps (@pxref{Section Options}).
874 @node Operators, Evaluation, Location Counter, Expressions
875 @subsection Operators
876 @cindex Operators for arithmetic
877 @cindex arithmetic operators
878 @cindex precedence in expressions
879 The linker recognizes the standard C set of arithmetic operators, with
880 the standard bindings and precedence levels:
883 @c END TEXI2ROFF-KILL
885 precedence associativity Operators Notes
891 5 left == != > < <= >=
897 11 right &= += -= *= /= (2)
902 (2) @xref{Assignment}
907 %"lispnarrowing" is the extra indent used generally for @example
908 \hskip\lispnarrowing\vbox{\offinterlineskip
911 {\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ {\tt #}\ \hfil&\vrule#\cr
912 height2pt&\omit&&\omit&&\omit&\cr
913 &Precedence&& Associativity &&{\rm Operators}&\cr
914 height2pt&\omit&&\omit&&\omit&\cr
916 height2pt&\omit&&\omit&&\omit&\cr
918 % '176 is tilde, '~' in tt font
919 &1&&left&&\qquad- \char'176\ !\qquad\dag&\cr
923 &5&&left&&== != > < <= >=&\cr
929 &11&&right&&\qquad\&= += -= *= /=\qquad\ddag&\cr
931 height2pt&\omit&&\omit&&\omit&\cr}
936 @obeylines@parskip=0pt@parindent=0pt
937 @dag@quad Prefix operators.
938 @ddag@quad @xref{Assignment}.
941 @c END TEXI2ROFF-KILL
943 @node Evaluation, Assignment, Operators, Expressions
944 @subsection Evaluation
946 @cindex lazy evaluation
947 @cindex expression evaluation order
948 The linker uses ``lazy evaluation'' for expressions; it only calculates
949 an expression when absolutely necessary. The linker needs the value of
950 the start address, and the lengths of memory regions, in order to do any
951 linking at all; these values are computed as soon as possible when the
952 linker reads in the command file. However, other values (such as symbol
953 values) are not known or needed until after storage allocation. Such
954 values are evaluated later, when other information (such as the sizes of
955 output sections) is available for use in the symbol assignment
958 @node Assignment, Built-ins, Evaluation, Expressions
959 @subsection Assignment: Defining Symbols
960 @cindex assignment in scripts
961 @cindex symbol definition, scripts
962 @cindex variables, defining
963 You may create global symbols, and assign values (addresses) to global
964 symbols, using any of the C assignment operators:
967 @item @var{symbol} = @var{expression} ;
968 @itemx @var{symbol} &= @var{expression} ;
969 @itemx @var{symbol} += @var{expression} ;
970 @itemx @var{symbol} -= @var{expression} ;
971 @itemx @var{symbol} *= @var{expression} ;
972 @itemx @var{symbol} /= @var{expression} ;
975 Two things distinguish assignment from other operators in @code{ld}
979 Assignment may only be used at the root of an expression;
980 @samp{a=b+3;} is allowed, but @samp{a+b=3;} is an error.
985 A trailing semicolon is required at the end of an assignment
989 Assignment statements may appear:
992 as commands in their own right in an @code{ld} script; or
994 as independent statements within a @code{SECTIONS} command; or
996 as part of the contents of a section definition in a
997 @code{SECTIONS} command.
1000 The first two cases are equivalent in effect---both define a symbol with
1001 an absolute address; the last case defines a symbol whose address is
1002 relative to a particular section (@pxref{SECTIONS}).
1004 @cindex absolute and relocatable symbols
1005 @cindex relocatable and absolute symbols
1006 @cindex symbols, relocatable and absolute
1007 When a linker expression is evaluated and assigned to a variable, it is
1008 given either an absolute or a relocatable type. An absolute expression
1009 type is one in which the symbol contains the value that it will have in
1010 the output file, a relocateable expression type is one in which the
1011 value is expressed as a fixed offset from the base of a section.
1013 The type of the expression is controlled by its position in the script
1014 file. A symbol assigned within a section definition is created relative
1015 to the base of the section; a symbol assigned in any other place is
1016 created as an absolute symbol. Since a symbol created within a
1017 section definition is relative to the base of the section, it
1018 will remain relocatable if relocatable output is requested. A symbol
1019 may be created with an absolute value even when assigned to within a
1020 section definition by using the absolute assignment function
1021 @code{ABSOLUTE}. For example, to create an absolute symbol whose address
1022 is the last byte of an output section named @code{.data}:
1028 _edata = ABSOLUTE(.) ;
1033 The linker tries to put off the evaluation of an assignment until all
1034 the terms in the source expression are known (@pxref{Evaluation}). For
1035 instance the sizes of sections cannot be known until after allocation,
1036 so assignments dependent upon these are not performed until after
1037 allocation. Some expressions, such as those depending upon the location
1038 counter @dfn{dot}, @samp{.} must be evaluated during allocation. If the
1039 result of an expression is required, but the value is not available,
1040 then an error results. For example, a script like the following
1043 text 9+this_isnt_constant :
1048 @kindex Non constant expression
1050 will cause the error message ``@code{Non constant expression for initial
1053 @node Built-ins, , Assignment, Expressions
1054 @subsection Built-In Functions
1055 @cindex functions in expression language
1056 The command language includes a number of special purpose built-in
1057 functions for use in link script expressions.
1059 @item ABSOLUTE(@var{exp})
1060 @kindex ABSOLUTE(@var{exp})
1061 @cindex expression, absolute
1062 returns the absolute value of the expression @var{exp}. Primarily
1063 useful to assign an absolute value to a symbol within a section
1064 definition, where symbol values are normally section-relative.
1066 @item ADDR(@var{section})
1067 @kindex ADDR(@var{section})
1068 @cindex section address
1069 returns the absolute address of the named @var{section}. Your script must
1070 previously have defined the location of that section. In the following
1071 example the @code{symbol_1} and @code{symbol_2} are assigned identical
1077 start_of_output_1 = ABSOLUTE(.);
1082 symbol_1 = ADDR(.output1);
1083 symbol_2 = start_of_output_1;
1088 @item ALIGN(@var{exp})
1089 @kindex ALIGN(@var{exp})
1090 @cindex rounding up location counter
1091 returns the result of the current location counter (@code{.}) aligned to
1092 the next @var{exp} boundary. @var{exp} must be an expression whose
1093 value is a power of two. This is equivalent to
1095 (. + @var{exp} - 1) & ~(@var{exp} - 1)
1098 @code{ALIGN} doesn't change the value of the location counter---it just
1099 does arithmetic on it. As an example, to align the output @code{.data}
1100 section to the next @code{0x2000} byte boundary after the preceding
1101 section and to set a variable within the section to the next
1102 @code{0x8000} boundary after the input sections:
1105 .data ALIGN(0x2000): @{
1107 variable = ALIGN(0x8000);
1112 The first use of @code{ALIGN} in this example specifies the location of
1113 a section because it is used as the optional @var{start} attribute of a
1114 section definition (@pxref{Section Options}). The second use simply
1115 defines the value of a variable.
1117 The built-in @code{NEXT} is closely related to @code{ALIGN}.
1119 @item DEFINED(@var{symbol})
1120 @kindex DEFINED(@var{symbol})
1121 @cindex symbol defaults
1122 Returns @code{1} if @var{symbol} is in the linker global symbol table and is
1123 defined, otherwise it returns @code{0}. You can use this to provide default
1124 values for symbols. For example, this command-file fragment shows how
1125 to set a global symbol @code{begin} to the first location in the
1126 @code{.text} section---but if a symbol called @code{begin} already
1127 existed, its value is preserved:
1131 begin = DEFINED(begin) ? begin : . ;
1137 @item NEXT(@var{exp})
1138 @kindex NEXT(@var{exp})
1139 @cindex unallocated address, next
1140 Returns the next unallocated address that is a multiple of @var{exp}.
1141 This command is closely related to @code{ALIGN(@var{exp})}; unless you
1142 use the @code{MEMORY} command to define discontinuous memory for the
1143 output file, the two commands are equivalent.
1145 @item SIZEOF(@var{section})
1146 @kindex SIZEOF(@var{section})
1147 @cindex section size
1148 returns the size in bytes of the named @var{section}, if the section has
1149 been allocated. In the following example the @code{symbol_1} and
1150 @code{symbol_2} are assigned identical values:
1158 symbol_1 = .end - .start ;
1159 symbol_2 = SIZEOF(.output);
1164 @item SIZEOF_HEADERS
1165 @kindex SIZEOF_HEADERS
1167 @itemx sizeof_headers
1168 @kindex sizeof_headers
1169 the size in bytes of the output file's headers. You can use this number
1170 as the start address of the first section, if you choose, to facilitate
1175 @node MEMORY, SECTIONS, Expressions, Commands
1176 @section MEMORY Command
1178 @cindex regions of memory
1179 @cindex discontinuous memory
1180 @cindex allocating memory
1181 The linker's default configuration permits allocation of all memory.
1182 You can override this by using the @code{MEMORY} command. The
1183 @code{MEMORY} command describes the location and size of blocks of
1184 memory in the target. By using it carefully, you can describe which
1185 memory regions may be used by the linker, and which memory regions it
1186 must avoid. The linker does not shuffle sections to fit into the
1187 available regions, but does move the requested sections into the correct
1188 regions and issue errors when the regions become too full.
1190 Command files may contain at most one use of the @code{MEMORY}
1191 command; however, you can define as many blocks of memory within it as
1192 you wish. The syntax is:
1197 @var{name} (@var{attr}) : ORIGIN = @var{origin}, LENGTH = @var{len}
1203 @cindex naming memory regions
1204 is a name used internally by the linker to refer to the region. Any
1205 symbol name may be used. The region names are stored in a separate
1206 name space, and will not conflict with symbols, filenames or section
1207 names. Use distinct names to specify multiple regions.
1209 @cindex memory region attributes
1210 is an optional list of attributes, permitted for compatibility with the
1211 AT&T linker but not used by @code{ld} beyond checking that the
1212 attribute list is valid. Valid attribute lists must be made up of the
1213 characters ``@code{LIRWX}''. If you omit the attribute list, you may
1214 omit the parentheses around it as well.
1219 is the start address of the region in physical memory. It is expressed as
1220 an expression, which must evaluate to a constant before
1221 memory allocation is performed. The keyword @code{ORIGIN} may be
1222 abbreviated to @code{org} or @code{o}.
1227 is the size in bytes of the region (an expression).
1228 The keyword @code{LENGTH} may be abbreviated to @code{len} or @code{l}.
1231 For example, to specify that memory has two regions available for
1232 allocation---one starting at @code{0} for 256 kilobytes, and the other
1233 starting at @code{0x40000000} for four megabytes:
1238 rom : ORIGIN = 0, LENGTH = 256K
1239 ram : org = 0x40000000, l = 4M
1243 Once you have defined a region of memory named @var{mem}, you can direct
1244 specific output sections there by using a command ending in
1245 @samp{>@var{mem}} within the @code{SECTIONS} command (@pxref{Section
1246 Options}). If the combined output sections directed to a region are too
1247 big for the region, the linker will issue an error message.
1249 @node SECTIONS, Entry Point, MEMORY, Commands
1250 @section SECTIONS Command
1252 The @code{SECTIONS} command controls exactly where input sections are
1253 placed into output sections, their order and to which output sections
1256 You may use at most one @code{SECTIONS} command in a commands file,
1257 but you can have as many statements within it as you wish. Statements
1258 within the @code{SECTIONS} command can do one of three things:
1261 define the entry point;
1263 assign a value to a symbol;
1265 describe the placement of a named output section, and what input
1266 sections make it up.
1269 The first two possibilities---defining the entry point, and defining
1270 symbols---can also be done outside the @code{SECTIONS} command:
1271 @pxref{Entry Point}, @pxref{Assignment}. They are permitted here as
1272 well for your convenience in reading the script, so that symbols or the
1273 entry point can be defined at meaningful points in your output-file
1276 When no @code{SECTIONS} command is specified, the default action
1277 of the linker is to place each input section into an identically named
1278 output section in the order that the sections are first encountered in
1279 the input files; if all input sections are present in the first file,
1280 for example, the order of sections in the output file will match the
1281 order in the first input file.
1284 * Section Definition:: Section Definitions
1285 * Section Contents:: Section Contents
1286 * Section Options:: Optional Section Attributes
1289 @node Section Definition, Section Contents, SECTIONS, SECTIONS
1290 @subsection Section Definitions
1291 @cindex section definition
1292 The most frequently used statement in the @code{SECTIONS} command is
1293 the @dfn{section definition}, which you can use to specify the
1294 properties of an output section: its location, alignment, contents,
1295 fill pattern, and target memory region can all be specified. Most of
1296 these specifications are optional; the simplest form of a section
1305 @cindex naming output sections
1307 @var{secname} is the name of the output section, and @var{contents} a
1308 specification of what goes there---for example a list of input files or
1309 sections of input files. As you might assume, the whitespace shown is
1310 optional; you do need the colon @samp{:} and the braces @samp{@{@}},
1313 @var{secname} must meet the constraints of your output format. In
1314 formats which only support a limited number of sections, such as
1315 @code{a.out}, the name must be one of the names supported by the format
1316 (@code{a.out}, for example, allows only @code{.text}, @code{.data} or
1317 @code{.bss}). If the output format supports any number of sections, but
1318 with numbers and not names (as is the case for Oasys), the name should be
1319 supplied as a quoted numeric string. A section name may consist of any
1320 sequence characters, but any name which does not conform to the standard
1321 @code{ld} symbol name syntax must be quoted.
1323 @node Section Contents, Section Options, Section Definition, SECTIONS
1324 @subsection Section Contents
1325 @cindex contents of a section
1326 In a section definition, you can specify the contents of an output section by
1327 listing particular object files; by listing particular input-file
1328 sections; or a combination of the two. You can also place arbitrary
1329 data in the section, and define symbols relative to the beginning of the
1332 The @var{contents} of a section definition may include any of the
1333 following kinds of statement. You can include as many of these as you
1334 like in a single section definition, separated from one another by
1338 @item @var{filename}
1339 @kindex @var{filename}
1340 @cindex input files, section defn
1341 @cindex files, including in output sections
1342 You may simply name a particular input file to be placed in the current
1343 output section; @emph{all} sections from that file are placed in the
1344 current section definition. To specify a list of particular files by
1347 .data : @{ afile.o bfile.o cfile.o @}
1350 The example also illustrates that multiple statements can be included in
1351 the contents of a section definition, since each filename is a separate
1354 If the file name has already been mentioned in another section
1355 definition, with an explicit section name list, then only those sections
1356 which have not yet been allocated are used.
1358 @item @var{filename}( @var{section} )
1359 @itemx @var{filename}( @var{section}, @var{section}, @dots{} )
1360 @itemx @var{filename}( @var{section} @var{section} @dots{} )
1361 @kindex @var{filename}(@var{section})
1362 @cindex files and sections, section defn
1363 You can name one or more sections from your input files, for
1364 insertion in the current output section. If you wish to specify a list
1365 of input-file sections inside the parentheses, you may separate the
1366 section names by either commas or whitespace.
1368 @item * (@var{section})
1369 @itemx * (@var{section}, @var{section}, @dots{})
1370 @itemx * (@var{section} @var{section} @dots{}
1371 @cindex input sections to output section
1372 @kindex *(@var{section})
1373 Instead of explicitly naming particular input files in a link control
1374 script, you can refer to @emph{all} files from the @code{ld} command
1375 line: use @samp{*} instead of a particular filename before the
1376 parenthesized input-file section list.
1378 For example, to copy sections @code{1} through @code{4} from a Oasys file
1379 into the @code{.text} section of an @code{a.out} file, and sections @code{13}
1380 and @code{14} into the @code{.data} section:
1393 If you have already explicitly included some files by name, @samp{*}
1394 refers to all @emph{remaining} files---those whose places in the output
1395 file have not yet been defined.
1397 @item [ @var{section} ]
1398 @itemx [ @var{section}, @var{section}, @dots{} ]
1399 @itemx [ @var{section} @var{section} @dots{} ]
1400 @kindex [ @var{sections} ]
1401 This is an alternate notation to specify named sections from all
1402 unallocated input files; its effect is exactly the same as that of
1403 @samp{* (@var{section}@dots{})}
1405 @item @var{filename}@code{( COMMON )}
1408 @cindex uninitialized data
1409 @cindex commons in output
1410 Specify where in your output file to place uninitialized data
1411 with this notation. @code{[COMMON]} by itself refers to all
1412 uninitialized data from all input files (so far as it is not yet
1413 allocated); @var{filename}@code{(COMMON)} refers to uninitialized data
1414 from a particular file. Both are special cases of the general
1415 mechanisms for specifying where to place input-file sections:
1416 @code{ld} permits you to refer to uninitialized data as if it
1417 were in an input-file section named @code{COMMON}, regardless of the
1418 input file's format.
1421 For example, the following command script arranges the output file into
1422 three consecutive sections, named @code{.text}, @code{.data}, and
1423 @code{.bss}, taking the input for each from the correspondingly named
1424 sections of all the input files:
1427 .text: @{ *(.text) @}
1428 .data: @{ *(.data) @}
1429 .bss: @{ *(.bss) [COMMON] @}
1433 The following example reads all of the sections from file @code{all.o}
1434 and places them at the start of output section @code{outputa} which
1435 starts at location @code{0x10000}. All of section @code{.input1} from
1436 file @code{foo.o} follows immediately, in the same output section. All
1437 of section @code{.input2} from @code{foo.o} goes into output section
1438 @code{outputb}, followed by section @code{.input1} from @code{foo1.o}.
1439 All of the remaining @code{.input1} and @code{.input2} sections from any
1440 files are written to output section @code{outputc}.
1462 There are still more kinds of statements permitted in the contents of
1463 output section definitions. The foregoing statements permitted you to
1464 arrange, in your output file, data originating from your input files.
1465 You can also place data directly in an output section from the link
1466 command script. Most of these additional statements involve
1467 expressions; @pxref{Expressions}. Although these statements are shown
1468 separately here for ease of presentation, no such segregation is needed
1469 within a section definition in the @code{SECTIONS} command; you can
1470 intermix them freely with any of the statements we've just described.
1473 @item CREATE_OBJECT_SYMBOLS
1474 @kindex CREATE_OBJECT_SYMBOLS
1475 @cindex input filename symbols
1476 @cindex filename symbols
1477 instructs the linker to create a symbol for each input file
1478 in the current section, set with the address of the first byte of
1479 data written from the input file. For instance, with @code{a.out}
1480 files it is conventional to have a symbol for each input file. You can
1481 accomplish this by defining the output @code{.text} section as follows:
1486 CREATE_OBJECT_SYMBOLS
1488 _etext = ALIGN(0x2000);
1494 If @code{objsym} is a file containing this script, and @code{a.o},
1495 @code{b.o}, @code{c.o}, and @code{d.o} are four input files with
1496 contents like the following---
1506 @samp{ld -M sample a.o b.o c.o d.o} would create a map like this,
1507 containing symbols matching the object file names:
1509 00000000 A __DYNAMIC
1512 00002020 T _afunction
1515 00002038 T _bfunction
1518 00002050 T _cfunction
1521 00002068 T _dfunction
1531 @item @var{symbol} = @var{expression} ;
1532 @kindex @var{symbol} = @var{expression} ;
1533 @itemx @var{symbol} @var{f}= @var{expression} ;
1534 @kindex @var{symbol} @var{f}= @var{expression} ;
1535 @var{symbol} is any symbol name (@pxref{Symbols}). ``@var{f}=''
1536 refers to any of the operators @code{&= += -= *= /=} which combine
1537 arithmetic and assignment.
1539 @cindex assignment, in section defn
1540 When you assign a value to a symbol within a particular section
1541 definition, the value is relative to the beginning of the section
1542 (@pxref{Assignment}). If you write
1547 .data : @{ @dots{} rel = 14 ; @dots{} @}
1548 abs2 = 14 + ADDR(.data);
1552 @c FIXME: Try above example!
1554 @code{abs} and @var{rel} do not have the same value; @code{rel} has the
1555 same value as @code{abs2}.
1557 @item BYTE(@var{expression})
1558 @kindex BYTE(@var{expression})
1559 @itemx SHORT(@var{expression})
1560 @kindex SHORT(@var{expression})
1561 @itemx LONG(@var{expression})
1562 @kindex LONG(@var{expression})
1563 @cindex direct output
1564 By including one of these three statements in a section definition, you
1565 can explicitly place one, two, or four bytes (respectively) at the
1566 current address of that section. Multiple-byte quantities are
1567 represented in whatever byte order is appropriate for the output file
1568 format (@pxref{BFD}).
1570 @item FILL(@var{expression})
1571 @kindex FILL(@var{expression})
1572 @cindex holes, filling
1573 @cindex unspecified memory
1574 Specifies the ``fill pattern'' for the current section. Any otherwise
1575 unspecified regions of memory within the section (for example, regions
1576 you skip over by assigning a new value to the location counter @samp{.})
1577 are filled with the two least significant bytes from the
1578 @var{expression} argument. A @code{FILL} statement covers memory
1579 locations @emph{after} the point it occurs in the section definition; by
1580 including more than one @code{FILL} statement, you can have different
1581 fill patterns in different parts of an output section.
1584 @node Section Options, , Section Contents, SECTIONS
1585 @subsection Optional Section Attributes
1586 @cindex section defn, full syntax
1587 Here is the full syntax of a section definition, including all the
1593 @var{secname} @var{start} BLOCK(@var{align}) : @{ @var{contents} @} =@var{fill} >@var{region}
1598 @var{secname} and @var{contents} are required. @xref{Section
1599 Definition}, and @pxref{Section Contents} for details on @var{contents}.
1600 The remaining elements---@var{start}, @code{BLOCK(@var{align)}},
1601 @code{=@var{fill}}, and @code{>@var{region}}---are all optional.
1605 @cindex start address, section
1606 @cindex section start
1607 @cindex section address
1608 You can force the output section to be loaded at a specified address by
1609 specifying @var{start} immediately following the section name.
1610 @var{start} can be represented as any expression. The following
1611 example generates section @var{output} at location
1616 output 0x40000000: @{
1623 @item BLOCK(@var{align})
1624 @kindex BLOCK(@var{align})
1625 @cindex section alignment
1626 @cindex aligning sections
1627 You can include @code{BLOCK()} specification to advance the location of
1628 the location counter @code{.} prior to the beginning of the section, so
1629 that the section will begin at the specified alignment. @var{align} is
1634 @cindex section fill pattern
1635 @cindex fill pattern, entire section
1636 You may use any expression to specify @var{fill}. Including
1637 @code{=@var{fill}} in a section definition specifies the initial fill
1638 value for that section. Any unallocated holes in the current output
1639 section when written to the output file will be filled with the two
1640 least significant bytes of the value, repeated as necessary. You can
1641 also change the fill value with a @code{FILL} statement in the
1642 @var{contents} of a section definition.
1645 @kindex >@var{region}
1646 @cindex section, assigning to memory region
1647 @cindex memory regions and sections
1648 Assign this section to a previously defined region of memory.
1653 @node Entry Point, Other Commands, SECTIONS, Commands
1654 @section The Entry Point
1655 @kindex ENTRY(@var{symbol})
1656 @cindex start of execution
1657 @cindex first instruction
1658 The linker command language includes a command specifically for
1659 defining the first executable instruction in an output file (its
1660 @dfn{entry point}). Its argument is a symbol name:
1665 Like symbol assignments, the @code{ENTRY} command may be placed either
1666 as an independent command in the command file, or among the section
1667 definitions within the @code{SECTIONS} command---whatever makes the most
1668 sense for your layout.
1670 @cindex entry point, defaults
1671 @code{ENTRY} is only one of several ways of choosing the entry point.
1672 You may indicate it in any of the following ways (shown in descending
1673 order of priority: methods higher in the list override methods lower down).
1676 the @code{-e} @var{entry} command-line option;
1678 the @code{ENTRY(@var{symbol}} command in a linker control script;
1680 the value of the symbol @code{start}, if present;
1682 the value of the symbol @code{_main}, if present;
1684 the address of the first byte of the @code{.text} section, if present;
1686 The address @code{0}.
1689 For example, you can use these rules to generate an entry point with an
1690 assignment statement: if no symbol @code{start} is defined within your
1691 input files, you can simply define it, assigning it an appropriate
1698 The example shows an absolute address, but you can use any expression.
1699 For example, if your input object files use some other symbol-name
1700 convention for the entry point, you can just assign the value of
1701 whatever symbol contains the start address to @code{start}:
1703 start = other_symbol ;
1706 @node Other Commands, , Entry Point, Commands
1707 @section Other Commands
1708 The command language includes a number of other commands that you can
1709 use for specialized purposes. They are similar in purpose to
1710 command-line options.
1717 These keywords were used in some older linkers to request a particular
1718 math subroutine library. @code{ld} doesn't use the keywords, assuming
1719 instead that any necessary subroutines are in libraries specified using
1720 the general mechanisms for linking to archives; but to permit the use of
1721 scripts that were written for the older linkers, the keywords
1722 @code{FLOAT} and @code{NOFLOAT} are accepted and ignored.
1724 @item FORCE_COMMON_ALLOCATION
1725 @kindex FORCE_COMMON_ALLOCATION
1726 @cindex common allocation
1727 This command has the same effect as the @code{-d} command-line option:
1728 to make @code{ld} assign space to common symbols even if a relocatable
1729 output file is specified (@code{-r}).
1731 @item INPUT ( @var{file}, @var{file}, @dots{} )
1732 @kindex INPUT ( @var{files} )
1733 @itemx INPUT ( @var{file} @var{file} @dots{} )
1734 @cindex binary input files
1735 Use this command to include binary input files in the link, without
1736 including them in a particular section definition. Files specified this
1737 way are treated identically to object files listed on the command line.
1740 @item MAP ( @var{name} )
1741 @kindex MAP ( @var{name} )
1742 @c MAP(...) appears to look for an F in the arg, ignoring all other
1743 @c chars; if it finds one, it sets "map_option_f" to true. But nothing
1744 @c checks map_option_f. Apparently a stub for the future...
1747 @item OUTPUT ( @var{filename} )
1748 @kindex OUTPUT ( @var{filename} )
1749 @cindex naming the output file
1750 Name the link output file @var{filename}. The effect of
1751 @code{OUTPUT(@var{filename})} is identical to the effect of
1752 @w{@code{-o @var{filename}}}, and whichever is encountered last will
1753 control the name actually used to name the output file. In particular,
1754 you can use this command to supply a default output-file name other than
1757 @item OUTPUT_ARCH ( @var{bfdname} )
1758 @kindex OUTPUT_ARCH ( @var{bfdname} )
1759 @cindex machine architecture, output
1760 Specify a particular output machine architecture, with one of the names
1761 used by the BFD back-end routines (@pxref{BFD}). This command is often
1762 unnecessary; the architecture is most often set implicitly by either the
1763 system BFD configuration or as a side effect of the @code{OUTPUT_FORMAT}
1766 @item OUTPUT_FORMAT ( @var{bfdname} )
1767 @kindex OUTPUT_FORMAT ( @var{bfdname} )
1768 @cindex format, output file
1769 Specify a particular output format, with one of the names used by the
1770 BFD back-end routines (@pxref{BFD}). This selection will only affect
1771 the output file; the related command @code{TARGET} affects primarily
1774 @item SEARCH_DIR ( @var{path} )
1775 @kindex SEARCH_DIR ( @var{path} )
1776 @cindex path for libraries
1777 @cindex search path, libraries
1778 Add @var{path} to the list of paths where @code{ld} looks for
1779 archive libraries. @code{SEARCH_DIR(@var{path})} has the same
1780 effect as @code{-L@var{path})} on the command line.
1782 @item STARTUP ( @var{filename} )
1783 @kindex STARTUP ( @var{filename} )
1784 @cindex first input file
1785 Ensure that @var{filename} is the first input file used in the link
1788 @item TARGET ( @var{format} )
1789 @cindex input file format
1790 @kindex TARGET ( @var{format} )
1791 Change the input-file object code format (like the command-line option
1792 @code{-b} or its synonym @code{-format}). The argument @var{format} is
1793 one of the strings used by BFD to name binary formats. In the current
1794 @code{ld} implementation, if @code{TARGET} is specified but
1795 @code{OUTPUT_FORMAT} is not, the last @code{TARGET} argument is also
1796 used as the default format for the @code{ld} output file.
1800 If you don't use the @code{TARGET} command, @code{ld} uses the value of
1801 the environment variable @code{GNUTARGET}, if available, to select the
1802 output file format. If that variable is also absent, @code{ld} uses
1803 the default format configured for your machine in the BFD libraries.
1807 @node Machine Dependent, BFD, Commands, Top
1808 @chapter Machine Dependent Features
1810 @cindex machine dependencies
1811 @code{ld} has additional features on some platforms; the following
1812 sections describe them. Machines where @code{ld} has no additional
1813 functionality are not listed.
1816 * H8/300:: @code{ld} and the H8/300
1817 * i960:: @code{ld} and the Intel 960 family
1818 * m68k:: @code{ld} and the Motorola 68000 family
1819 * m88k:: @code{ld} and the Motorola 880x0 family
1822 @node H8/300, i960, Machine Dependent, Machine Dependent
1823 @section @code{ld} and the H8/300
1825 @cindex H8/300 support
1826 For the H8/300, @code{ld} can perform these global optimizations when
1827 you specify the @samp{-relax} command-line option.
1830 @item relaxing address modes
1831 @cindex relaxing on i960
1832 @code{ld} finds all @code{jsr} and @code{jmp} instructions whose
1833 targets are within eight bits, and turns them into eight-bit
1834 program-counter relative @code{bsr} and @code{bra} instructions,
1837 @item synthesizing instructions
1838 @cindex synthesizing on i960
1839 @c FIXME: specifically mov.b, or any mov instructions really?
1840 @code{ld} finds all @code{mov.b} instructions which use the
1841 sixteen-bit absolute address form, but refer to the top
1842 page of memory, and changes them to use the eight-bit address form.
1843 (That is: the linker turns @samp{mov.b @code{@@}@var{aa}:16} into
1844 @samp{mov.b @code{@@}@var{aa}:8} whenever the address @var{aa} is in the
1845 top page of memory).
1848 @node i960, m68k, H8/300, Machine Dependent
1849 @section @code{ld} and the Intel 960 family
1851 @cindex i960 support
1853 * i960-arch:: Linking for a Specific i960 Architecture
1854 * i960-emulation:: Emulating Other i960 Linkers
1855 * i960-commands:: Command Language Extensions for i960
1858 @node i960-arch, i960-emulation, i960, i960
1859 @subsection Linking for a Specific i960 Architecture
1860 You can use the @samp{-A@var{architecture}} command line option to
1861 specify one of the two-letter names identifying members of the 960
1862 family; the option specifies the desired output target, and warns of any
1863 incompatible instructions in the input files. It also modifies the
1864 linker's search strategy for archive libraries, to support the use of
1865 libraries specific to each particular architecture, by including in the
1866 search loop names suffixed with the string identifying the architecture.
1868 For example, if your @code{ld} command line included @w{@samp{-ACA}} as
1869 well as @w{@samp{-ltry}}, the linker would look (in its built-in search
1870 paths, and in any paths you specify with @code{-L}) for a library with
1879 The first two possibilities would be considered in any event; the last
1880 two are due to the use of @w{@samp{-ACA}}.
1882 You can meaningfully use @code{-A} more than once on a command line, since
1883 the 960 architecture family allows combination of target architectures; each
1884 use will add another pair of name variants to search for when @w{@code{-l}}
1885 specifies a library.
1887 @node i960-emulation, i960-commands, i960-arch, i960
1888 @subsection Emulating Other i960 Linkers
1889 You can set the @code{LDEMULATION} environment variable
1890 (@pxref{Environment,,Environment Variables}) to make
1891 @code{ld} more compatible with two older Intel 960 linkers:
1894 @item LDEMULATION=gld960
1899 Emulate the Intel port of the older @code{gld} for the i960
1900 architectures. The default library search paths are taken from two
1901 other environment variables, @code{G960LIB} and @code{G960BASE}. The
1902 default architecture is @code{i960}. The default output format is set
1903 to @code{b.out.big}, and in fact the default output file name (if
1904 @code{-o} is not specified) is @code{b.out}, to reflect this variant
1905 format, for this emulation.
1908 This emulation can behave slightly differently depending on the setting
1909 of the @code{ld} compile-time switch @code{GNU960}. If @code{ld} is
1910 compiled with @code{GNU960} defined, then an additional environment
1911 variable---@code{GNUTARGET}---is available; its value, if available,
1912 specifies some other default output format than @code{b.out.big}.
1914 @item LDEMULATION=lnk960
1917 @cindex Architectures, i960 family
1918 Emulate the Intel linker @code{lnk960}. The default output format is
1919 @code{coff-Intel-big}. With this emulation, @code{ld}
1920 supports the additional script commands @code{HLL} and @code{SYSLIB} for
1921 specification of library archives. This is the only emulation with
1922 extensive support for the @code{-A} (architecture) command-line option.
1923 By default, the architecture @code{CORE} is assumed, but you can choose
1924 additional features from the i960 architecture family by using one of
1925 the following with @code{-A} (or by using the @code{OUTPUT_ARCH} command
1938 The default libraries are chosen with some attention to the architecture
1939 selected; the core library @file{cg} is always included, but the library
1940 @code{fpg} is also used if you've specified any of the architectures
1941 @code{KA}, @code{SA}, or @code{CA}.
1944 Like @code{gld960}, this emulation uses additional environment variables
1945 to set the default library search paths. Also like @code{gld960}, the
1946 behavior of this emulation is slightly different depending on whether
1947 @code{ld} itself was compiled with @code{GNU960} defined.
1952 If your @code{ld} was compiled with @code{GNU960} defined, the default
1953 paths are taken from all three of @code{G960LIB}, @code{G960BASE}, and
1954 @code{I960BASE}. For the first two, paths you supply are automatically
1955 suffixed with @samp{/lib/libcoff}; for the last, your path is
1956 automatically suffixed with @samp{/lib}.
1958 If your @code{ld} was @emph{not} compiled with @code{GNU960} defined,
1959 the default paths are taken from @code{I960BASE}, and @code{G960BASE} is
1960 only consulted if @code{I960BASE} is undefined. In this case
1961 @code{G960LIB} is not used at all.
1964 @node i960-commands, , i960-emulation, i960
1965 @subsection Command Language Extensions for i960
1967 @code{ld} understands the following additional commands when
1968 @code{LDEMULATION} is set to @samp{lnk960}:
1971 @item HLL ( @var{file}, @var{file}, @dots{} )
1972 @itemx HLL ( @var{file} @var{file} @dots{} )
1974 @kindex HLL ( @var{files} )
1975 Include ``high-level libraries'' or archives as input files in the link.
1976 Using @code{HLL(@var{file}} in a linker script is equivalent to
1977 including @code{-l}@var{file} on the command line.
1979 @cindex @code{lnk960} command @code{HLL}
1980 The @code{HLL} command is only supported when @code{ld} emulates
1981 @code{lnk960}, as specified by the @code{LDEMULATION} environment
1984 @item SYSLIB ( @var{file}, @var{file}, @dots{} )
1985 @itemx SYSLIB ( @var{file} @var{file} @dots{} )
1986 @kindex SYSLIB ( @var{file}, @var{file}, @dots{} )
1987 Use the named @var{file}s as binary input files, searching for them in
1988 the same list of paths as archives.
1990 @cindex @code{lnk960} command @code{SYSLIB}
1991 The @code{SYSLIB} command is only supported when @code{ld} emulates
1992 @code{lnk960}, as specified by the @code{LDEMULATION} environment
1997 @node m68k, m88k, i960, Machine Dependent
1998 @section @code{ld} and the Motorola 680x0 family
2000 @cindex m68k support
2001 You can set the environment variable @code{LDEMULATION} to @samp{gld68k}
2002 for closer compatibility with the older GNU linker on Motorola 680x0
2003 platforms. This emulation is a variant of the @code{gld} emulation; it
2004 only differs in specifically setting the default BFD machine as
2005 @code{m68k}. @xref{Environment,,Environment Variables}.
2007 @node m88k, , m68k, Machine Dependent
2008 @section @code{ld} and the Motorola 880x0 family
2010 @cindex m88k support
2012 You can configure the linker to conform to the Motorola 88K BCS by
2013 setting the environment variable @code{LDEMULATION} to @samp{gldm88kbcs}.
2014 This sets the output format to @code{m88kbcs} and the architecture to
2015 @code{m88k}. Default library search paths are
2022 For other settings of @code{LDEMULATION}, consult
2023 @ref{Environment,,Environment Variables}.
2025 @node BFD, MRI, Machine Dependent, Top
2029 @cindex object file management
2030 The linker accesses object and archive files using the BFD libraries.
2031 These libraries allow the linker to use the same routines to operate on
2032 object files whatever the object file format. A different object file
2033 format can be supported simply by creating a new BFD back end and adding
2034 it to the library. You can use @code{objdump -i}
2035 (@pxref{objdump,,objdump,binutils.info,The GNU Binary Utilities}) to
2036 list all the formats available for each architecture under BFD. This
2037 was the list of formats, and of architectures supported for each format,
2038 as of the time this manual was prepared:
2039 @cindex formats available
2040 @cindex architectures available
2042 BFD header file version 0.18
2044 (header big endian, data big endian)
2050 (header big endian, data big endian)
2056 (header big endian, data little endian)
2059 (header little endian, data little endian)
2062 (header big endian, data big endian)
2065 (header big endian, data big endian)
2068 (header little endian, data little endian)
2071 (header big endian, data little endian)
2074 (header little endian, data little endian)
2077 (header big endian, data big endian)
2080 (header big endian, data big endian)
2083 (header big endian, data big endian)
2086 (header little endian, data little endian)
2089 (header big endian, data big endian)
2101 (header little endian, data little endian)
2113 (header big endian, data big endian)
2125 (header big endian, data big endian)
2138 @cindex BFD requirements
2139 @cindex requirements for BFD
2140 As with most implementations, BFD is a compromise between
2141 several conflicting requirements. The major factor influencing
2142 BFD design was efficiency: any time used converting between
2143 formats is time which would not have been spent had BFD not
2144 been involved. This is partly offset by abstraction payback; since
2145 BFD simplifies applications and back ends, more time and care
2146 may be spent optimizing algorithms for a greater speed.
2148 One minor artifact of the BFD solution which you should bear in
2149 mind is the potential for information loss. There are two places where
2150 useful information can be lost using the BFD mechanism; during
2151 conversion and during output. @xref{BFD information loss}.
2154 * BFD outline:: How it works: an outline of BFD
2155 * BFD information loss:: Information Loss
2156 * Mechanism:: Mechanism
2159 @node BFD outline, BFD information loss, BFD, BFD
2160 @section How it works: an outline of BFD
2161 @cindex opening object files
2162 When an object file is opened, BFD subroutines automatically
2163 determine the format of the input object file, and build a descriptor in
2164 memory with pointers to routines that will be used to access elements of
2165 the object file's data structures.
2167 As different information from the the object files is required
2168 BFD reads from different sections of the file and processes them.
2169 For example a very common operation for the linker is processing symbol
2170 tables. Each BFD back end provides a routine for converting
2171 between the object file's representation of symbols and an internal
2172 canonical format. When the linker asks for the symbol table of an object
2173 file, it calls through the memory pointer to the relevant BFD
2174 back end routine which reads and converts the table into a canonical
2175 form. The linker then operates upon the common form. When the link is
2176 finished and the linker writes the symbol table of the output file,
2177 another BFD back end routine is called which takes the newly
2178 created symbol table and converts it into the chosen output format.
2180 @node BFD information loss, Mechanism, BFD outline, BFD
2181 @section Information Loss
2182 @emph{Information can be lost during output.} The output formats
2183 supported by BFD do not provide identical facilities, and
2184 information which may be described in one form has nowhere to go in
2185 another format. One example of this is alignment information in
2186 @code{b.out}. There is nowhere in an @code{a.out} format file to store
2187 alignment information on the contained data, so when a file is linked
2188 from @code{b.out} and an @code{a.out} image is produced, alignment
2189 information will not propagate to the output file. (The linker will
2190 still use the alignment information internally, so the link is performed
2193 Another example is COFF section names. COFF files may contain an
2194 unlimited number of sections, each one with a textual section name. If
2195 the target of the link is a format which does not have many sections (eg
2196 @code{a.out}) or has sections without names (eg the Oasys format) the
2197 link cannot be done simply. You can circumvent this problem by
2198 describing the desired input-to-output section mapping with the command
2201 @emph{Information can be lost during canonicalization.} The BFD
2202 internal canonical form of the external formats is not exhaustive; there
2203 are structures in input formats for which there is no direct
2204 representation internally. This means that the BFD back ends
2205 cannot maintain all possible data richness through the transformation
2206 between external to internal and back to external formats.
2208 This limitation is only a problem when using the linker to read one
2209 format and write another. Each BFD back end is responsible for
2210 maintaining as much data as possible, and the internal BFD
2211 canonical form has structures which are opaque to the BFD core,
2212 and exported only to the back ends. When a file is read in one format,
2213 the canonical form is generated for BFD and the linker. At the
2214 same time, the back end saves away any information which may otherwise
2215 be lost. If the data is then written back in the same format, the back
2216 end routine will be able to use the canonical form provided by the
2217 BFD core as well as the information it prepared earlier. Since
2218 there is a great deal of commonality between back ends, this mechanism
2219 is very useful. There is no information lost for this reason when
2220 linking big endian COFF to little endian COFF, or from @code{a.out} to
2221 @code{b.out}. When a mixture of formats is linked, the information is
2222 only lost from the files whose format differs from the destination.
2224 @node Mechanism, , BFD information loss, BFD
2226 The greatest potential for loss of information is when there is least
2227 overlap between the information provided by the source format, that
2228 stored by the canonical format, and the information needed by the
2229 destination format. A brief description of the canonical form may help
2230 you appreciate what kinds of data you can count on preserving across
2232 @cindex BFD canonical format
2233 @cindex internal object-file format
2237 Information on target machine architecture, particular implementation
2238 and format type are stored on a per-file basis. Other information
2239 includes a demand pageable bit and a write protected bit. Note that
2240 information like Unix magic numbers is not stored here---only the magic
2241 numbers' meaning, so a @code{ZMAGIC} file would have both the demand pageable
2242 bit and the write protected text bit set.
2244 The byte order of the target is stored on a per-file basis, so that big-
2245 and little-endian object files may be linked with one another.
2248 Each section in the input file contains the name of the section, the
2249 original address in the object file, various flags, size and alignment
2250 information and pointers into other BFD data structures.
2253 Each symbol contains a pointer to the object file which originally
2254 defined it, its name, its value, and various flag bits. When a
2255 BFD back end reads in a symbol table, the back end relocates all
2256 symbols to make them relative to the base of the section where they were
2257 defined. This ensures that each symbol points to its containing
2258 section. Each symbol also has a varying amount of hidden data to contain
2259 private data for the BFD back end. Since the symbol points to the
2260 original file, the private data format for that symbol is accessible.
2261 @code{ld} can operate on a collection of symbols of wildly different
2262 formats without problems.
2264 Normal global and simple local symbols are maintained on output, so an
2265 output file (no matter its format) will retain symbols pointing to
2266 functions and to global, static, and common variables. Some symbol
2267 information is not worth retaining; in @code{a.out} type information is
2268 stored in the symbol table as long symbol names. This information would
2269 be useless to most COFF debuggers and may be thrown away with
2270 appropriate command line switches. (The GNU debugger @code{gdb} does
2271 support @code{a.out} style debugging information in COFF).
2273 There is one word of type information within the symbol, so if the
2274 format supports symbol type information within symbols (for example COFF,
2275 IEEE, Oasys) and the type is simple enough to fit within one word
2276 (nearly everything but aggregates) the information will be preserved.
2278 @item relocation level
2279 Each canonical BFD relocation record contains a pointer to the symbol to
2280 relocate to, the offset of the data to relocate, the section the data
2281 is in and a pointer to a relocation type descriptor. Relocation is
2282 performed effectively by message passing through the relocation type
2283 descriptor and symbol pointer. It allows relocations to be performed
2284 on output data using a relocation method only available in one of the
2285 input formats. For instance, Oasys provides a byte relocation format.
2286 A relocation record requesting this relocation type would point
2287 indirectly to a routine to perform this, so the relocation may be
2288 performed on a byte being written to a COFF file, even though 68k COFF
2289 has no such relocation type.
2290 @c FIXME why specific reference to 68K above?
2293 Object formats can contain, for debugging purposes, some form of mapping
2294 between symbols, source line numbers, and addresses in the output file.
2295 These addresses have to be relocated along with the symbol information.
2296 Each symbol with an associated list of line number records points to the
2297 first record of the list. The head of a line number list consists of a
2298 pointer to the symbol, which allows divination of the address of the
2299 function whose line number is being described. The rest of the list is
2300 made up of pairs: offsets into the section and line numbers. Any format
2301 which can simply derive this information can pass it successfully
2302 between formats (COFF, IEEE and Oasys).
2305 @node MRI, Index, BFD, Top
2306 @appendix MRI Compatible Script Files
2307 @cindex MRI compatibility
2308 To aid users making the transition to @sc{gnu} @code{ld} from the MRI
2309 linker, @code{ld} can use MRI compatible linker scripts as an
2310 alternative to the more general-purpose linker scripting language
2311 described in @ref{Commands,,Command Language}. MRI compatible linker
2312 scripts have a much simpler command set than the scripting language
2313 otherwise used with @code{ld}. @sc{gnu} @code{ld} supports the most
2314 commonly used MRI linker commands; these commands are described here.
2316 You can specify a file containing an MRI-compatible script using the
2317 @samp{-c} command-line option.
2319 Each command in an MRI-compatible script occupies its own line; each
2320 command line starts with the keyword that identifies the command (though
2321 blank lines are also allowed for punctuation). If a line of an
2322 MRI-compatible script begins with an unrecognized keyword, @code{ld}
2323 issues a warning message, but continues processing the script.
2325 Lines beginning with @samp{*} are comments.
2327 You can write these commands using all upper-case letters, or all
2328 lower case; for example, @samp{chip} is the same as @samp{CHIP}.
2329 The following list shows only the upper-case form of each command.
2332 @item ABSOLUTE @var{secname}
2333 @item ABSOLUTE @var{secname}, @var{secname}, @dots{} @var{secname}
2334 @cindex @code{ABSOLUTE} (MRI)
2335 Normally, @code{ld} includes in the output file all sections from all
2336 the input files. However, in an MRI-compatible script, you can use the
2337 @code{ABSOLUTE} command to restrict the sections that will be present in
2338 your output program. If the @code{ABSOLUTE} command is used at all in a
2339 script, then only the sections named explicitly in @code{ABSOLUTE}
2340 commands will appear in the linker output. You can still use other
2341 input sections (whatever you select on the command line, or using
2342 @code{LOAD}) to resolve addresses in the output file.
2344 @item ALIAS @var{out-secname}, @var{in-secname}
2345 @cindex @code{ALIAS} (MRI)
2346 Use this command to place the data from input section @var{in-secname}
2347 in a section called @var{out-secname} in the linker output file.
2349 @var{in-secname} may be an integer.
2351 @item BASE @var{expression}
2352 @cindex @code{BASE} (MRI)
2353 Use the value of @var{expression} as the lowest address (other than
2354 absolute addresses) in the output file.
2356 @item CHIP @var{expression}
2357 @itemx CHIP @var{expression}, @var{expression}
2358 @cindex @code{CHIP} (MRI)
2359 This command does nothing whatever; it's only accepted for compatibility.
2362 @cindex @code{END} (MRI)
2363 This command does nothing whatever; it's only accepted for compatibility.
2365 @item FORMAT @var{output-format}
2366 @cindex @code{FORMAT} (MRI)
2367 Similar to the @code{OUTPUT_FORMAT} command in the more general linker
2368 language, but restricted to one of these output formats:
2371 S-records, if @var{output-format} is @samp{S}
2374 IEEE, if @var{output-format} is @samp{IEEE}
2377 COFF (the @samp{coff-m68k} variant in BFD), if @var{output-format} is
2381 @item LIST @var{@dots{}}
2382 @cindex @code{LIST} (MRI)
2383 Print (to the standard output file) a link map, as produced by the
2384 @code{ld} command-line option @samp{-M}.
2386 (The keyword @code{LIST} may be followed by anything whatsoever on the
2387 same line, with no change in its effect.)
2389 @item LOAD @var{filename}
2390 @item LOAD @var{filename}, @var{filename}, @dots{} @var{filename}
2391 @cindex @code{LOAD} (MRI)
2392 Include one or more object file @var{filename} in the link; this has the
2393 same effect as specifying @var{filename} directly on the @code{ld}
2396 @item NAME @var{output-name}
2397 @cindex @code{NAME} (MRI)
2398 @var{output-name} is the name for the program produced by @code{ld}; the
2399 MRI-compatible command @code{NAME} is equivalent to the command-line
2400 option @samp{-o} or the general script language command @code{OUTPUT}.
2402 @item ORDER @var{secname}, @var{secname}, @dots{} @var{secname}
2403 @itemx ORDER @var{secname} @var{secname} @var{secname}
2404 @cindex @code{ORDER} (MRI)
2405 Normally, @code{ld} orders the sections in its output file in whatever
2406 order they first appear in the input files. In an MRI-compatible
2407 script, you can override this with the @code{ORDER} command. The
2408 sections you list with @code{ORDER} will appear first in your output
2409 file, in the order specified.
2411 @item PUBLIC @var{name}=@var{expression}
2412 @itemx PUBLIC @var{name},@var{expression}
2413 @itemx PUBLIC @var{name} @var{expression}
2414 @cindex @code{PUBLIC} (MRI)
2415 This command supplies a value (@var{expression}) for an external symbol
2416 @var{name} used in the linker input files.
2418 @item SECT @var{secname}, @var{expression}
2419 @itemx SECT @var{secname}=@var{expression}
2420 @itemx SECT @var{secname} @var{expression}
2421 @cindex @code{SECT} (MRI)
2422 You can use any of these three forms of the @code{SECT} command to
2423 specify the start address (@var{expression}) for section @var{secname}.
2424 If you have more than one @code{SECT} statement for the same
2425 @var{secname}, only the @emph{first} sets the start address.
2429 @node Index, , MRI, Top
2435 % I think something like @colophon should be in texinfo. In the
2437 \long\def\colophon{\hbox to0pt{}\vfill
2438 \centerline{The body of this manual is set in}
2439 \centerline{\fontname\tenrm,}
2440 \centerline{with headings in {\bf\fontname\tenbf}}
2441 \centerline{and examples in {\tt\fontname\tentt}.}
2442 \centerline{{\it\fontname\tenit\/} and}
2443 \centerline{{\sl\fontname\tensl\/}}
2444 \centerline{are used for emphasis.}\vfill}