comparison doc/lwlink.txt @ 139:106c2fe3c9d9

repo reorg
author lost
date Wed, 28 Jan 2009 05:59:14 +0000
parents lwlink-old/trunk/doc/lwlink.txt@050864a47b38
children
comparison
equal deleted inserted replaced
138:050864a47b38 139:106c2fe3c9d9
1 This is the companion linker to LWASM. It reads object files generated by
2 LWASM and combines them into an actual binary.
3
4 During linking, each file is read into memory. A list of externally
5 referenced symbols is made along with where these symbols are referenced.
6 Each external reference is checked against all previously loaded files (in
7 order of loading) and if a match is found, a note of that fact is made and a
8 link between the previously loaded file and the current reference.
9
10 Once all files are loaded, the symbol table is checked for any symbols which
11 are still unresolved. If any are found, the linking process complains and
12 bails out.
13
14 Once all the object files have been read, the linker follows a
15 pre-determined script for the specified target or a script supplied by the
16 user to lay out the binary. The instructions from the script are followed
17 blindly as it is assumed the user knows what he is doing.
18
19 For each defined section, the linker begins constructing the section data by
20 resolving each instance of that section in the order it was encountered. All
21 symbols defined by that section (local or exported) are assigned addresses.
22 The exact offset into the final section data is recorded for any incomplete
23 references in that section. All section base address references are resolved
24 to actual addresses at this stage.
25
26 Once all sections have been laid out and addresses assigned to all symbols,
27 all incomplete references are resolved and the resulting value placed into
28 the appropriate data stream. If any references cannot be resolved at this
29 stage, the linker will complain and bail out.
30
31 Once all sections, symbols, and incomplete references have been resolved,
32 the binary will output as appropriate for the specified target.
33
34 See the file "scripts.txt" for information about linker scripts and the
35 restrictions based on the output target.
36
37 The following output targets are supported:
38
39 Raw: this is a raw binary with no header information, etc. Suitable for ROM
40 images, etc. By default, the raw target starts the binary at address 0, puts
41 any section named "init" first, then "code", then all other non-bss
42 sections, then all bss sections. Note that any "bss" type section that
43 exists anywhere but at the end of the binary (i.e. is between or before one
44 or more non-bss sections) will be included as a series of NUL bytes.
45
46 DECB: this creates a LOADM style binary according to the linker script. By
47 default, this target places the sections in the same order as the raw target
48 but implements a load address of $2000. bss sections will not be included in
49 the actual output. If a bss section appears between two non-bss sections, a
50 new output block will be created in the output file.
51