Files
2024-02-19 00:21:47 -05:00

188 lines
6.6 KiB
HTML

<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52
from ../texi/ld.texinfo on 7 November 1998 -->
<TITLE>Using LD, the GNU linker - MRI Compatible Script Files</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="ld_1.html">first</A>, <A HREF="ld_6.html">previous</A>, <A HREF="ld_8.html">next</A>, <A HREF="ld_8.html">last</A> section, <A HREF="ld_toc.html">table of contents</A>.
<P><HR><P>
<H1><A NAME="SEC37" HREF="ld_toc.html#TOC37">MRI Compatible Script Files</A></H1>
<P>
<A NAME="IDX385"></A>
To aid users making the transition to GNU <CODE>ld</CODE> from the MRI
linker, <CODE>ld</CODE> can use MRI compatible linker scripts as an
alternative to the more general-purpose linker scripting language
described in section <A HREF="ld_3.html#SEC5">Command Language</A>. MRI compatible linker
scripts have a much simpler command set than the scripting language
otherwise used with <CODE>ld</CODE>. GNU <CODE>ld</CODE> supports the most
commonly used MRI linker commands; these commands are described here.
</P>
<P>
In general, MRI scripts aren't of much use with the <CODE>a.out</CODE> object
file format, since it only has three sections and MRI scripts lack some
features to make use of them.
</P>
<P>
You can specify a file containing an MRI-compatible script using the
<SAMP>`-c'</SAMP> command-line option.
</P>
<P>
Each command in an MRI-compatible script occupies its own line; each
command line starts with the keyword that identifies the command (though
blank lines are also allowed for punctuation). If a line of an
MRI-compatible script begins with an unrecognized keyword, <CODE>ld</CODE>
issues a warning message, but continues processing the script.
</P>
<P>
Lines beginning with <SAMP>`*'</SAMP> are comments.
</P>
<P>
You can write these commands using all upper-case letters, or all
lower case; for example, <SAMP>`chip'</SAMP> is the same as <SAMP>`CHIP'</SAMP>.
The following list shows only the upper-case form of each command.
</P>
<DL COMPACT>
<DT><CODE>ABSOLUTE <VAR>secname</VAR></CODE>
<DD>
<A NAME="IDX386"></A>
<DT><CODE>ABSOLUTE <VAR>secname</VAR>, <VAR>secname</VAR>, ... <VAR>secname</VAR></CODE>
<DD>
Normally, <CODE>ld</CODE> includes in the output file all sections from all
the input files. However, in an MRI-compatible script, you can use the
<CODE>ABSOLUTE</CODE> command to restrict the sections that will be present in
your output program. If the <CODE>ABSOLUTE</CODE> command is used at all in a
script, then only the sections named explicitly in <CODE>ABSOLUTE</CODE>
commands will appear in the linker output. You can still use other
input sections (whatever you select on the command line, or using
<CODE>LOAD</CODE>) to resolve addresses in the output file.
<A NAME="IDX387"></A>
<DT><CODE>ALIAS <VAR>out-secname</VAR>, <VAR>in-secname</VAR></CODE>
<DD>
Use this command to place the data from input section <VAR>in-secname</VAR>
in a section called <VAR>out-secname</VAR> in the linker output file.
<VAR>in-secname</VAR> may be an integer.
<A NAME="IDX388"></A>
<DT><CODE>ALIGN <VAR>secname</VAR> = <VAR>expression</VAR></CODE>
<DD>
Align the section called <VAR>secname</VAR> to <VAR>expression</VAR>. The
<VAR>expression</VAR> should be a power of two.
<A NAME="IDX389"></A>
<DT><CODE>BASE <VAR>expression</VAR></CODE>
<DD>
Use the value of <VAR>expression</VAR> as the lowest address (other than
absolute addresses) in the output file.
<A NAME="IDX390"></A>
<DT><CODE>CHIP <VAR>expression</VAR></CODE>
<DD>
<DT><CODE>CHIP <VAR>expression</VAR>, <VAR>expression</VAR></CODE>
<DD>
This command does nothing; it is accepted only for compatibility.
<A NAME="IDX391"></A>
<DT><CODE>END</CODE>
<DD>
This command does nothing whatever; it's only accepted for compatibility.
<A NAME="IDX392"></A>
<DT><CODE>FORMAT <VAR>output-format</VAR></CODE>
<DD>
Similar to the <CODE>OUTPUT_FORMAT</CODE> command in the more general linker
language, but restricted to one of these output formats:
<OL>
<LI>
S-records, if <VAR>output-format</VAR> is <SAMP>`S'</SAMP>
<LI>
IEEE, if <VAR>output-format</VAR> is <SAMP>`IEEE'</SAMP>
<LI>
COFF (the <SAMP>`coff-m68k'</SAMP> variant in BFD), if <VAR>output-format</VAR> is
<SAMP>`COFF'</SAMP>
</OL>
<A NAME="IDX393"></A>
<DT><CODE>LIST <VAR>anything</VAR>...</CODE>
<DD>
Print (to the standard output file) a link map, as produced by the
<CODE>ld</CODE> command-line option <SAMP>`-M'</SAMP>.
The keyword <CODE>LIST</CODE> may be followed by anything on the
same line, with no change in its effect.
<A NAME="IDX394"></A>
<DT><CODE>LOAD <VAR>filename</VAR></CODE>
<DD>
<DT><CODE>LOAD <VAR>filename</VAR>, <VAR>filename</VAR>, ... <VAR>filename</VAR></CODE>
<DD>
Include one or more object file <VAR>filename</VAR> in the link; this has the
same effect as specifying <VAR>filename</VAR> directly on the <CODE>ld</CODE>
command line.
<A NAME="IDX395"></A>
<DT><CODE>NAME <VAR>output-name</VAR></CODE>
<DD>
<VAR>output-name</VAR> is the name for the program produced by <CODE>ld</CODE>; the
MRI-compatible command <CODE>NAME</CODE> is equivalent to the command-line
option <SAMP>`-o'</SAMP> or the general script language command <CODE>OUTPUT</CODE>.
<A NAME="IDX396"></A>
<DT><CODE>ORDER <VAR>secname</VAR>, <VAR>secname</VAR>, ... <VAR>secname</VAR></CODE>
<DD>
<DT><CODE>ORDER <VAR>secname</VAR> <VAR>secname</VAR> <VAR>secname</VAR></CODE>
<DD>
Normally, <CODE>ld</CODE> orders the sections in its output file in the
order in which they first appear in the input files. In an MRI-compatible
script, you can override this ordering with the <CODE>ORDER</CODE> command. The
sections you list with <CODE>ORDER</CODE> will appear first in your output
file, in the order specified.
<A NAME="IDX397"></A>
<DT><CODE>PUBLIC <VAR>name</VAR>=<VAR>expression</VAR></CODE>
<DD>
<DT><CODE>PUBLIC <VAR>name</VAR>,<VAR>expression</VAR></CODE>
<DD>
<DT><CODE>PUBLIC <VAR>name</VAR> <VAR>expression</VAR></CODE>
<DD>
Supply a value (<VAR>expression</VAR>) for external symbol
<VAR>name</VAR> used in the linker input files.
<A NAME="IDX398"></A>
<DT><CODE>SECT <VAR>secname</VAR>, <VAR>expression</VAR></CODE>
<DD>
<DT><CODE>SECT <VAR>secname</VAR>=<VAR>expression</VAR></CODE>
<DD>
<DT><CODE>SECT <VAR>secname</VAR> <VAR>expression</VAR></CODE>
<DD>
You can use any of these three forms of the <CODE>SECT</CODE> command to
specify the start address (<VAR>expression</VAR>) for section <VAR>secname</VAR>.
If you have more than one <CODE>SECT</CODE> statement for the same
<VAR>secname</VAR>, only the <EM>first</EM> sets the start address.
</DL>
<P><HR><P>
Go to the <A HREF="ld_1.html">first</A>, <A HREF="ld_6.html">previous</A>, <A HREF="ld_8.html">next</A>, <A HREF="ld_8.html">last</A> section, <A HREF="ld_toc.html">table of contents</A>.
</BODY>
</HTML>