comparison docs/manual/c1073.html @ 478:a71206ed966c lwtools-4.16

Update manual in preparation for release
author William Astle <lost@l-w.ca>
date Wed, 12 Dec 2018 20:00:59 -0700
parents
children
comparison
equal deleted inserted replaced
477:221b8964662a 478:a71206ed966c
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 >Object Files</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="PREVIOUS"
13 TITLE="Libraries and LWAR"
14 HREF="c1011.html"></HEAD
15 ><BODY
16 CLASS="CHAPTER"
17 BGCOLOR="#FFFFFF"
18 TEXT="#000000"
19 LINK="#0000FF"
20 VLINK="#840084"
21 ALINK="#0000FF"
22 ><DIV
23 CLASS="NAVHEADER"
24 ><TABLE
25 SUMMARY="Header navigation table"
26 WIDTH="100%"
27 BORDER="0"
28 CELLPADDING="0"
29 CELLSPACING="0"
30 ><TR
31 ><TH
32 COLSPAN="3"
33 ALIGN="center"
34 >LW Tool Chain</TH
35 ></TR
36 ><TR
37 ><TD
38 WIDTH="10%"
39 ALIGN="left"
40 VALIGN="bottom"
41 ><A
42 HREF="c1011.html"
43 ACCESSKEY="P"
44 >Prev</A
45 ></TD
46 ><TD
47 WIDTH="80%"
48 ALIGN="center"
49 VALIGN="bottom"
50 ></TD
51 ><TD
52 WIDTH="10%"
53 ALIGN="right"
54 VALIGN="bottom"
55 >&nbsp;</TD
56 ></TR
57 ></TABLE
58 ><HR
59 ALIGN="LEFT"
60 WIDTH="100%"></DIV
61 ><DIV
62 CLASS="CHAPTER"
63 ><H1
64 ><A
65 NAME="OBJCHAP"
66 ></A
67 >Chapter 6. Object Files</H1
68 ><P
69 >LWTOOLS uses a proprietary object file format. It is proprietary in the sense
70 that it is specific to LWTOOLS, not that it is a hidden format. It would be
71 hard to keep it hidden in an open source tool chain anyway. This chapter
72 documents the object file format.</P
73 ><P
74 >An object file consists of a series of sections each of which contains a
75 list of exported symbols, a list of incomplete references, and a list of
76 "local" symbols which may be used in calculating incomplete references. Each
77 section will obviously also contain the object code.</P
78 ><P
79 >Exported symbols must be completely resolved to an address within the
80 section it is exported from. That is, an exported symbol must be a constant
81 rather than defined in terms of other symbols.</P
82 ><P
83 >Each object file starts with a magic number and version number. The magic
84 number is the string "LWOBJ16" for this 16 bit object file format. The only
85 defined version number is currently 0. Thus, the first 8 bytes of the object
86 file are <FONT
87 COLOR="RED"
88 >4C574F424A313600</FONT
89 ></P
90 ><P
91 >Each section has the following items in order:</P
92 ><P
93 ></P
94 ><UL
95 ><LI
96 ><P
97 >section name</P
98 ></LI
99 ><LI
100 ><P
101 >flags</P
102 ></LI
103 ><LI
104 ><P
105 >list of local symbols (and addresses within the section)</P
106 ></LI
107 ><LI
108 ><P
109 >list of exported symbols (and addresses within the section)</P
110 ></LI
111 ><LI
112 ><P
113 >list of incomplete references along with the expressions to calculate them</P
114 ></LI
115 ><LI
116 ><P
117 >the actual object code (for non-BSS sections)</P
118 ></LI
119 ></UL
120 ><P
121 >The section starts with the name of the section with a NUL termination
122 followed by a series of flag bytes terminated by NUL. There are only two
123 flag bytes defined. A NUL (0) indicates no more flags and a value of 1
124 indicates the section is a BSS section. For a BSS section, no actual
125 code is included in the object file.</P
126 ><P
127 >Either a NULL section name or end of file indicate the presence of no more
128 sections.</P
129 ><P
130 >Each entry in the exported and local symbols table consists of the symbol
131 (NUL terminated) followed by two bytes which contain the value in big endian
132 order. The end of a symbol table is indicated by a NULL symbol name.</P
133 ><P
134 >Each entry in the incomplete references table consists of an expression
135 followed by a 16 bit offset where the reference goes. Expressions are
136 defined as a series of terms up to an "end of expression" term. Each term
137 consists of a single byte which identifies the type of term (see below)
138 followed by any data required by the term. Then end of the list is flagged
139 by a NULL expression (only an end of expression term).</P
140 ><DIV
141 CLASS="TABLE"
142 ><A
143 NAME="AEN1098"
144 ></A
145 ><P
146 ><B
147 >Table 6-1. Object File Term Types</B
148 ></P
149 ><TABLE
150 BORDER="1"
151 FRAME="border"
152 CLASS="CALSTABLE"
153 ><COL><COL><THEAD
154 ><TR
155 ><TH
156 >TERMTYPE</TH
157 ><TH
158 >Meaning</TH
159 ></TR
160 ></THEAD
161 ><TBODY
162 ><TR
163 ><TD
164 >00</TD
165 ><TD
166 >end of expression</TD
167 ></TR
168 ><TR
169 ><TD
170 >01</TD
171 ><TD
172 >integer (16 bit in big endian order follows)</TD
173 ></TR
174 ><TR
175 ><TD
176 >02</TD
177 ><TD
178 > external symbol reference (NUL terminated symbol name follows)</TD
179 ></TR
180 ><TR
181 ><TD
182 >03</TD
183 ><TD
184 >local symbol reference (NUL terminated symbol name follows)</TD
185 ></TR
186 ><TR
187 ><TD
188 >04</TD
189 ><TD
190 >operator (1 byte operator number)</TD
191 ></TR
192 ><TR
193 ><TD
194 >05</TD
195 ><TD
196 >section base address reference</TD
197 ></TR
198 ><TR
199 ><TD
200 >FF</TD
201 ><TD
202 >This term will set flags for the expression. Each one of these terms will set a single flag. All of them should be specified first in an expression. If they are not, the behaviour is undefined. The byte following is the flag. Flag 01 indicates an 8 bit relocation. Flag 02 indicates a zero-width relocation (see the EXTDEP pseudo op in LWASM).</TD
203 ></TR
204 ></TBODY
205 ></TABLE
206 ></DIV
207 ><P
208 >External references are resolved using other object files while local
209 references are resolved using the local symbol table(s) from this file. This
210 allows local symbols that are not exported to have the same names as
211 exported symbols or external references.</P
212 ><DIV
213 CLASS="TABLE"
214 ><A
215 NAME="AEN1128"
216 ></A
217 ><P
218 ><B
219 >Table 6-2. Object File Operator Numbers</B
220 ></P
221 ><TABLE
222 BORDER="1"
223 FRAME="border"
224 CLASS="CALSTABLE"
225 ><COL><COL><THEAD
226 ><TR
227 ><TH
228 >Number</TH
229 ><TH
230 >Operator</TH
231 ></TR
232 ></THEAD
233 ><TBODY
234 ><TR
235 ><TD
236 >01</TD
237 ><TD
238 >addition (+)</TD
239 ></TR
240 ><TR
241 ><TD
242 >02</TD
243 ><TD
244 >subtraction (-)</TD
245 ></TR
246 ><TR
247 ><TD
248 >03</TD
249 ><TD
250 >multiplication (*)</TD
251 ></TR
252 ><TR
253 ><TD
254 >04</TD
255 ><TD
256 >division (/)</TD
257 ></TR
258 ><TR
259 ><TD
260 >05</TD
261 ><TD
262 >modulus (%)</TD
263 ></TR
264 ><TR
265 ><TD
266 >06</TD
267 ><TD
268 >integer division (\) (same as division)</TD
269 ></TR
270 ><TR
271 ><TD
272 >07</TD
273 ><TD
274 >bitwise and</TD
275 ></TR
276 ><TR
277 ><TD
278 >08</TD
279 ><TD
280 >bitwise or</TD
281 ></TR
282 ><TR
283 ><TD
284 >09</TD
285 ><TD
286 >bitwise xor</TD
287 ></TR
288 ><TR
289 ><TD
290 >0A</TD
291 ><TD
292 >boolean and</TD
293 ></TR
294 ><TR
295 ><TD
296 >0B</TD
297 ><TD
298 >boolean or</TD
299 ></TR
300 ><TR
301 ><TD
302 >0C</TD
303 ><TD
304 >unary negation, 2's complement (-)</TD
305 ></TR
306 ><TR
307 ><TD
308 >0D</TD
309 ><TD
310 >unary 1's complement (^)</TD
311 ></TR
312 ></TBODY
313 ></TABLE
314 ></DIV
315 ><P
316 >An expression is represented in a postfix manner with both operands for
317 binary operators preceding the operator and the single operand for unary
318 operators preceding the operator.</P
319 ></DIV
320 ><DIV
321 CLASS="NAVFOOTER"
322 ><HR
323 ALIGN="LEFT"
324 WIDTH="100%"><TABLE
325 SUMMARY="Footer navigation table"
326 WIDTH="100%"
327 BORDER="0"
328 CELLPADDING="0"
329 CELLSPACING="0"
330 ><TR
331 ><TD
332 WIDTH="33%"
333 ALIGN="left"
334 VALIGN="top"
335 ><A
336 HREF="c1011.html"
337 ACCESSKEY="P"
338 >Prev</A
339 ></TD
340 ><TD
341 WIDTH="34%"
342 ALIGN="center"
343 VALIGN="top"
344 ><A
345 HREF="index.html"
346 ACCESSKEY="H"
347 >Home</A
348 ></TD
349 ><TD
350 WIDTH="33%"
351 ALIGN="right"
352 VALIGN="top"
353 >&nbsp;</TD
354 ></TR
355 ><TR
356 ><TD
357 WIDTH="33%"
358 ALIGN="left"
359 VALIGN="top"
360 >Libraries and LWAR</TD
361 ><TD
362 WIDTH="34%"
363 ALIGN="center"
364 VALIGN="top"
365 >&nbsp;</TD
366 ><TD
367 WIDTH="33%"
368 ALIGN="right"
369 VALIGN="top"
370 >&nbsp;</TD
371 ></TR
372 ></TABLE
373 ></DIV
374 ></BODY
375 ></HTML
376 >