annotate lwlink/trunk/doc/scripts.txt @ 113:f4a489ebd44a

Added some basic documentation of the linker
author lost
date Sat, 17 Jan 2009 20:54:20 +0000
parents
children 2ece9adb4e4b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
1 LWLINK linker scripts
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
2
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
3 A linker script is used to instruct the linker about how to assemble the
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
4 various sections into a completed binary. It consists of a series of
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
5 directives which are considered in the order they are encountered. Any
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
6 section not referenced by a directive is assumed to be loaded after the
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
7 final section explicitly referenced.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
8
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
9 A section may only be referenced once. Any subsequent references will have
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
10 no effect.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
11
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
12 section <name> load at <addr>
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
13
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
14 This causes the section <name> to load at <addr>. For raw target, only one
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
15 "load at" entry is allowed for non-bss sections and it must be the first
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
16 one. For raw targets, it affects the addresses the linker assigns to symbols
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
17 but has no other affect on the output. bss sections may all have separate
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
18 load addresses but since they will not appear in the binary anyway, this is
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
19 okay.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
20
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
21 For the DECB target, each "load at" entry will cause a new "block" to be
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
22 output to the binary which will contain the load address. It is legal for
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
23 sections to overlap in this manner - the linker assumes the loader will sort
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
24 everything out.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
25
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
26 section <name> load after <name2>
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
27
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
28 This will cause the section <name> to load after <name2>. This has the
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
29 effect of essentially gluing <name> onto the end of <name2>. If multiple
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
30 sections are specified to load after a particular section, they will load in
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
31 the order specified.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
32
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
33 pad to <size>
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
34
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
35 This will cause the output file to be padded with NUL bytes to be exactly
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
36 <size> bytes in length. This only makes sense for a raw target.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
37
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
38
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
39 If <name> is "*", then any section not already matched by the script will be
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
40 matched. For format *,<flags> can be used to select sections which have
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
41 particular flags set (or not set). For instance:
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
42
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
43 *,!bss This would match all sections that do not have the bss flag set
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
44 *,bss this would match all sections that do have the bss flag set
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
45
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
46