To aid users making the transition to gnu ld from the MRI linker, ld can use MRI compatible linker scripts as an alternative to the more general-purpose linker scripting language described in Scripts. MRI compatible linker scripts have a much simpler command set than the scripting language otherwise used with ld. gnu ld supports the most commonly used MRI linker commands; these commands are described here.
In general, MRI scripts aren't of much use with the a.out
object
file format, since it only has three sections and MRI scripts lack some
features to make use of them.
You can specify a file containing an MRI-compatible script using the -c command-line option.
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, ld issues a warning message, but continues processing the script.
Lines beginning with * are comments.
You can write these commands using all upper-case letters, or all lower case; for example, chip is the same as CHIP. The following list shows only the upper-case form of each command.
ABSOLUTE
secnameABSOLUTE
secname,
secname, ...
secnameABSOLUTE
command to restrict the sections that will be present in
your output program. If the ABSOLUTE
command is used at all in a
script, then only the sections named explicitly in ABSOLUTE
commands will appear in the linker output. You can still use other
input sections (whatever you select on the command line, or using
LOAD
) to resolve addresses in the output file.
ALIAS
out-secname,
in-secnamein-secname may be an integer.
ALIGN
secname =
expressionBASE
expressionCHIP
expressionCHIP
expression,
expressionEND
FORMAT
output-formatOUTPUT_FORMAT
command in the more general linker
language, but restricted to one of these output formats:
LIST
anything...
The keyword LIST
may be followed by anything on the
same line, with no change in its effect.
LOAD
filenameLOAD
filename,
filename, ...
filenameNAME
output-nameNAME
is equivalent to the command-line
option -o or the general script language command OUTPUT
.
ORDER
secname,
secname, ...
secnameORDER
secname secname secnameORDER
command. The
sections you list with ORDER
will appear first in your output
file, in the order specified.
PUBLIC
name=
expressionPUBLIC
name,
expressionPUBLIC
name expressionSECT
secname,
expressionSECT
secname=
expressionSECT
secname expressionSECT
command to
specify the start address (expression) for section secname.
If you have more than one SECT
statement for the same
secname, only the first sets the start address.