annotate lwlink/tags/1.0/doc/scripts.txt @ 136:72d8c84a8734

Release 1.0
author lost
date Tue, 27 Jan 2009 05:54:10 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
1 LWLINK linker scripts
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
2
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
3 A linker script is used to instruct the linker about how to assemble the
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
4 various sections into a completed binary. It consists of a series of
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
5 directives which are considered in the order they are encountered. Any
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
6 section not referenced by a directive is assumed to be loaded after the
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
7 final section explicitly referenced.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
8
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
9 The sections will appear in the resulting binary in the order they are
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
10 specified in the script file.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
11
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
12 If a referenced section is not found, the linker will behave as though the
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
13 section did exist but had a zero size, no relocations, and no exports.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
14
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
15 A section may only be referenced once. Any subsequent references will have
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
16 no effect.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
17
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
18 All numbers are hexadecimal.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
19
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
20 section <name> load <addr>
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
21
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
22 This causes the section <name> to load at <addr>. For raw target, only one
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
23 "load at" entry is allowed for non-bss sections and it must be the first
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
24 one. For raw targets, it affects the addresses the linker assigns to symbols
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
25 but has no other affect on the output. bss sections may all have separate
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
26 load addresses but since they will not appear in the binary anyway, this is
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
27 okay.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
28
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
29 For the DECB target, each "load" entry will cause a new "block" to be
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
30 output to the binary which will contain the load address. It is legal for
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
31 sections to overlap in this manner - the linker assumes the loader will sort
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
32 everything out.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
33
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
34 section <name>
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
35
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
36 This will cause the section <name> to load after the previously listed
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
37 section.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
38
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
39 exec <addr or sym>
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
40
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
41 This will cause the execution address (entry point) to be the address
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
42 specified (in hex) *or* the specified symbol name. The symbol name must
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
43 match a symbol that is exported by one of the object files being linked.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
44 This has no effect for targets that do not encode the entry point into the
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
45 resulting file. If not specified, the entry point is assumed to be address 0
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
46 which is probably not what you want. The default link scripts for targets
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
47 that support this directive automatically starts at the beginning of the
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
48 first section (usually "init" or "code") that is emitted in the binary.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
49
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
50 pad <size>
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
51
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
52 This will cause the output file to be padded with NUL bytes to be exactly
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
53 <size> bytes in length. This only makes sense for a raw target.
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
54
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
55
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
56 If <name> is "*", then any section not already matched by the script will be
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
57 matched. For format *,<flags> can be used to select sections which have
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
58 particular flags set (or not set). For instance:
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
59
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
60 *,!bss This would match all sections that do not have the bss flag set
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
61 *,bss this would match all sections that do have the bss flag set
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
62
72d8c84a8734 Release 1.0
lost
parents:
diff changeset
63