annotate doc/scripts.txt @ 140:8d65ef71fc01

repo reorg
author lost
date Wed, 28 Jan 2009 06:00:48 +0000
parents 106c2fe3c9d9
children
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
122
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
9 The sections will appear in the resulting binary in the order they are
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
10 specified in the script file.
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
11
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
12 If a referenced section is not found, the linker will behave as though the
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
13 section did exist but had a zero size, no relocations, and no exports.
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
14
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
15 A section may only be referenced once. Any subsequent references will have
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
16 no effect.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
17
122
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
18 All numbers are hexadecimal.
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
19
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
20 section <name> load <addr>
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
21
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
22 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
23 "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
24 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
25 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
26 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
27 okay.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
28
122
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
29 For the DECB target, each "load" entry will cause a new "block" to be
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
30 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
31 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
32 everything out.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
33
122
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
34 section <name>
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
35
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
36 This will cause the section <name> to load after the previously listed
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
37 section.
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
38
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
39 exec <addr or sym>
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
40
122
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
41 This will cause the execution address (entry point) to be the address
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
42 specified (in hex) *or* the specified symbol name. The symbol name must
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
43 match a symbol that is exported by one of the object files being linked.
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
44 This has no effect for targets that do not encode the entry point into the
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
45 resulting file. If not specified, the entry point is assumed to be address 0
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
46 which is probably not what you want. The default link scripts for targets
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
47 that support this directive automatically starts at the beginning of the
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
48 first section (usually "init" or "code") that is emitted in the binary.
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
49
122
2ece9adb4e4b Documented the "exec" directive in linker scripts
lost
parents: 113
diff changeset
50 pad <size>
113
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
51
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
52 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
53 <size> bytes in length. This only makes sense for a raw target.
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
54
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
55
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
56 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
57 matched. For format *,<flags> can be used to select sections which have
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
58 particular flags set (or not set). For instance:
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
59
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
60 *,!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
61 *,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
62
f4a489ebd44a Added some basic documentation of the linker
lost
parents:
diff changeset
63