Mercurial > hg > index.cgi
comparison docs/manual/x952.html @ 565:fc072f6cde09
Update documentation to reflect includebin offset/length feature
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 21 Dec 2023 22:16:12 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
564:87f904e2b304 | 565:fc072f6cde09 |
---|---|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> | |
2 <HTML | |
3 ><HEAD | |
4 ><TITLE | |
5 >Linking Scripts</TITLE | |
6 ><META | |
7 NAME="GENERATOR" | |
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK | |
9 REL="HOME" | |
10 TITLE="LW Tool Chain" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="LWLINK" | |
14 HREF="c838.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="Linker Operation" | |
17 HREF="x938.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="Format Specific Linking Notes" | |
20 HREF="x1019.html"></HEAD | |
21 ><BODY | |
22 CLASS="SECTION" | |
23 BGCOLOR="#FFFFFF" | |
24 TEXT="#000000" | |
25 LINK="#0000FF" | |
26 VLINK="#840084" | |
27 ALINK="#0000FF" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 SUMMARY="Header navigation table" | |
32 WIDTH="100%" | |
33 BORDER="0" | |
34 CELLPADDING="0" | |
35 CELLSPACING="0" | |
36 ><TR | |
37 ><TH | |
38 COLSPAN="3" | |
39 ALIGN="center" | |
40 >LW Tool Chain</TH | |
41 ></TR | |
42 ><TR | |
43 ><TD | |
44 WIDTH="10%" | |
45 ALIGN="left" | |
46 VALIGN="bottom" | |
47 ><A | |
48 HREF="x938.html" | |
49 ACCESSKEY="P" | |
50 >Prev</A | |
51 ></TD | |
52 ><TD | |
53 WIDTH="80%" | |
54 ALIGN="center" | |
55 VALIGN="bottom" | |
56 >Chapter 4. LWLINK</TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="x1019.html" | |
63 ACCESSKEY="N" | |
64 >Next</A | |
65 ></TD | |
66 ></TR | |
67 ></TABLE | |
68 ><HR | |
69 ALIGN="LEFT" | |
70 WIDTH="100%"></DIV | |
71 ><DIV | |
72 CLASS="SECTION" | |
73 ><H1 | |
74 CLASS="SECTION" | |
75 ><A | |
76 NAME="AEN952" | |
77 >4.3. Linking Scripts</A | |
78 ></H1 | |
79 ><P | |
80 >A linker script is used to instruct the linker about how to assemble the | |
81 various sections into a completed binary. It consists of a series of | |
82 directives which are considered in the order they are encountered.</P | |
83 ><P | |
84 >The sections will appear in the resulting binary in the order they are | |
85 specified in the script file. If a referenced section is not found, the linker will behave as though the | |
86 section did exist but had a zero size, no relocations, and no exports. | |
87 A section should only be referenced once. Any subsequent references will have | |
88 an undefined effect.</P | |
89 ><P | |
90 >All numbers are in linking scripts are specified in hexadecimal. All directives | |
91 are case sensitive although the hexadecimal numbers are not.</P | |
92 ><P | |
93 >A section name can be specified as a "*", then any section not | |
94 already matched by the script will be matched. The "*" can be followed | |
95 by a comma and a flag to narrow the section down slightly, also. | |
96 If the flag is "!bss", then any section that is not flagged as a bss section | |
97 will be matched. If the flag is "bss", then any section that is flagged as | |
98 bss will be matched.</P | |
99 ><P | |
100 >The following directives are understood in a linker script.</P | |
101 ><P | |
102 ></P | |
103 ><DIV | |
104 CLASS="VARIABLELIST" | |
105 ><DL | |
106 ><DT | |
107 >sectopt <CODE | |
108 CLASS="PARAMETER" | |
109 >section</CODE | |
110 > padafter <CODE | |
111 CLASS="PARAMETER" | |
112 >byte,...</CODE | |
113 ></DT | |
114 ><DD | |
115 ><P | |
116 > This will cause the linker to append the specified list of byte values | |
117 (specified in hexadecimal separated by commas) to the end of the named | |
118 section. This is done once all instances of the specified section are | |
119 collected together. This has no effect if the specified section does not | |
120 appear anywhere in any of the objects specified for linking. </P | |
121 ><P | |
122 > If code depends on the presence of this padding somewhere, it is sufficient | |
123 to include an empty section of the specified name in the object that depends | |
124 on it. </P | |
125 ></DD | |
126 ><DT | |
127 >define basesympat <CODE | |
128 CLASS="PARAMETER" | |
129 >string</CODE | |
130 ></DT | |
131 ><DD | |
132 ><P | |
133 > This causes the linker to define a symbol for the ultimate base address of | |
134 each section using the pattern specified by <CODE | |
135 CLASS="PARAMETER" | |
136 >string</CODE | |
137 >. | |
138 In the string, %s can appear exactly once and will be replaced with the | |
139 section name. The base address is calculated after all instances of each | |
140 section have been collapsed together. </P | |
141 ><P | |
142 > It should be noted that if none of the objects to be linked contains a | |
143 particular section name, there will be no base symbol defined for it, even | |
144 if it is listed explicitly in the link script. If code depends on the | |
145 presence of these symbols, it is sufficient to include an empty section of | |
146 the specified name in the object that depends on it. </P | |
147 ><P | |
148 > If the pattern resolves to the same string for multiple | |
149 sections, the results are undefined. </P | |
150 ></DD | |
151 ><DT | |
152 >define lensympat <CODE | |
153 CLASS="PARAMETER" | |
154 >string</CODE | |
155 ></DT | |
156 ><DD | |
157 ><P | |
158 > This causes the linker to define a symbol for the ultimate length of each | |
159 section using the pattern specified by <CODE | |
160 CLASS="PARAMETER" | |
161 >string</CODE | |
162 >. In | |
163 the string, %s can appear exactly once and will be replaced with the section | |
164 name. The length is calculated after all instances of a section have been | |
165 collapsed together. </P | |
166 ><P | |
167 > It should be noted that if none of the objects to be linked contains a | |
168 particular section name, there will be no length symbol defined for it, even | |
169 if it is listed explicitly in the link script. If code depends on the | |
170 presence of these symbols, it is sufficient to include an empty section of | |
171 the specified name in the object that depends on it. </P | |
172 ><P | |
173 >If the pattern resolves to the same string for multiple | |
174 sections, the results are undefined. </P | |
175 ></DD | |
176 ><DT | |
177 >section <CODE | |
178 CLASS="PARAMETER" | |
179 >name</CODE | |
180 > load <CODE | |
181 CLASS="PARAMETER" | |
182 >addr</CODE | |
183 ></DT | |
184 ><DD | |
185 ><P | |
186 > This causes the section <CODE | |
187 CLASS="PARAMETER" | |
188 >name</CODE | |
189 > to load at | |
190 <CODE | |
191 CLASS="PARAMETER" | |
192 >addr</CODE | |
193 >. For the raw target, only one "load at" entry is | |
194 allowed for non-bss sections and it must be the first one. For raw targets, | |
195 it affects the addresses the linker assigns to symbols but has no other | |
196 affect on the output. bss sections may all have separate load addresses but | |
197 since they will not appear in the binary anyway, this is okay.</P | |
198 ><P | |
199 >For the decb target, each "load" entry will cause a new "block" to be | |
200 output to the binary which will contain the load address. It is legal for | |
201 sections to overlap in this manner - the linker assumes the loader will sort | |
202 everything out.</P | |
203 ></DD | |
204 ><DT | |
205 >section <CODE | |
206 CLASS="PARAMETER" | |
207 >name</CODE | |
208 > high <CODE | |
209 CLASS="PARAMETER" | |
210 >addr</CODE | |
211 ></DT | |
212 ><DD | |
213 ><P | |
214 > This causes the section <CODE | |
215 CLASS="PARAMETER" | |
216 >name</CODE | |
217 > to load with its end | |
218 address just below <CODE | |
219 CLASS="PARAMETER" | |
220 >addr</CODE | |
221 >. Subsequent sections are | |
222 loaded at progressively lower addresses. This may lead to inefficient file | |
223 encoding for some targets. As of this writing, it will also almost | |
224 certainly do the wrong thing for a raw target. </P | |
225 ><P | |
226 > This is useful for aligning a block of code with high memory. As an | |
227 example, if the total size of a section is $100 bytes and a high address of | |
228 $FE00 is specified, the section will actually load at $FD00. </P | |
229 ></DD | |
230 ><DT | |
231 >section <CODE | |
232 CLASS="PARAMETER" | |
233 >name</CODE | |
234 ></DT | |
235 ><DD | |
236 ><P | |
237 > This will cause the section <CODE | |
238 CLASS="PARAMETER" | |
239 >name</CODE | |
240 > to load after the previously listed | |
241 section.</P | |
242 ></DD | |
243 ><DT | |
244 >entry <CODE | |
245 CLASS="PARAMETER" | |
246 >addr or sym</CODE | |
247 ></DT | |
248 ><DD | |
249 ><P | |
250 >This will cause the execution address (entry point) to be the address | |
251 specified (in hex) or the specified symbol name. The symbol name must | |
252 match a symbol that is exported by one of the object files being linked. | |
253 This has no effect for targets that do not encode the entry point into the | |
254 resulting file. If not specified, the entry point is assumed to be address 0 | |
255 which is probably not what you want. The default link scripts for targets | |
256 that support this directive automatically starts at the beginning of the | |
257 first section (usually "init" or "code") that is emitted in the binary.</P | |
258 ><P | |
259 >Note that if you use a numeric value here, you will need to ensure | |
260 it starts with a digit. That may mean adding a leading zero.</P | |
261 ></DD | |
262 ><DT | |
263 >pad <CODE | |
264 CLASS="PARAMETER" | |
265 >size</CODE | |
266 ></DT | |
267 ><DD | |
268 ><P | |
269 >This will cause the output file to be padded with NUL bytes to be exactly | |
270 <CODE | |
271 CLASS="PARAMETER" | |
272 >size</CODE | |
273 > bytes in length. This only makes sense for a raw target.</P | |
274 ></DD | |
275 ></DL | |
276 ></DIV | |
277 ></DIV | |
278 ><DIV | |
279 CLASS="NAVFOOTER" | |
280 ><HR | |
281 ALIGN="LEFT" | |
282 WIDTH="100%"><TABLE | |
283 SUMMARY="Footer navigation table" | |
284 WIDTH="100%" | |
285 BORDER="0" | |
286 CELLPADDING="0" | |
287 CELLSPACING="0" | |
288 ><TR | |
289 ><TD | |
290 WIDTH="33%" | |
291 ALIGN="left" | |
292 VALIGN="top" | |
293 ><A | |
294 HREF="x938.html" | |
295 ACCESSKEY="P" | |
296 >Prev</A | |
297 ></TD | |
298 ><TD | |
299 WIDTH="34%" | |
300 ALIGN="center" | |
301 VALIGN="top" | |
302 ><A | |
303 HREF="index.html" | |
304 ACCESSKEY="H" | |
305 >Home</A | |
306 ></TD | |
307 ><TD | |
308 WIDTH="33%" | |
309 ALIGN="right" | |
310 VALIGN="top" | |
311 ><A | |
312 HREF="x1019.html" | |
313 ACCESSKEY="N" | |
314 >Next</A | |
315 ></TD | |
316 ></TR | |
317 ><TR | |
318 ><TD | |
319 WIDTH="33%" | |
320 ALIGN="left" | |
321 VALIGN="top" | |
322 >Linker Operation</TD | |
323 ><TD | |
324 WIDTH="34%" | |
325 ALIGN="center" | |
326 VALIGN="top" | |
327 ><A | |
328 HREF="c838.html" | |
329 ACCESSKEY="U" | |
330 >Up</A | |
331 ></TD | |
332 ><TD | |
333 WIDTH="33%" | |
334 ALIGN="right" | |
335 VALIGN="top" | |
336 >Format Specific Linking Notes</TD | |
337 ></TR | |
338 ></TABLE | |
339 ></DIV | |
340 ></BODY | |
341 ></HTML | |
342 > |