view doc/scripts.txt @ 295:7a3d66e72a4c

Added some basic documentation of the linker
author lost
date Sat, 17 Jan 2009 20:54:20 +0000
parents
children 9c6462b3a288
line wrap: on
line source

LWLINK linker scripts

A linker script is used to instruct the linker about how to assemble the
various sections into a completed binary. It consists of a series of
directives which are considered in the order they are encountered. Any
section not referenced by a directive is assumed to be loaded after the
final section explicitly referenced.

A section may only be referenced once. Any subsequent references will have
no effect.

section <name> load at <addr>

This causes the section <name> to load at <addr>. For raw target, only one
"load at" entry is allowed for non-bss sections and it must be the first
one. For raw targets, it affects the addresses the linker assigns to symbols
but has no other affect on the output. bss sections may all have separate
load addresses but since they will not appear in the binary anyway, this is
okay.

For the DECB target, each "load at" entry will cause a new "block" to be
output to the binary which will contain the load address. It is legal for
sections to overlap in this manner - the linker assumes the loader will sort
everything out.

section <name> load after <name2>

This will cause the section <name> to load after <name2>. This has the
effect of essentially gluing <name> onto the end of <name2>. If multiple
sections are specified to load after a particular section, they will load in
the order specified.

pad to <size>

This will cause the output file to be padded with NUL bytes to be exactly
<size> bytes in length. This only makes sense for a raw target.


If <name> is "*", then any section not already matched by the script will be
matched. For format *,<flags> can be used to select sections which have
particular flags set (or not set). For instance:

*,!bss		This would match all sections that do not have the bss flag set
*,bss		this would match all sections that do have the bss flag set