changeset 236:ce1fdc8d6568

Added ability to add padding after a section when linking. Added the ability for lwlink to automatically append padding bytes to the end of a section (once the section instances are merged). This behaviour is controlled by the link script. See the updated documentation for more information.
author William Astle <lost@l-w.ca>
date Sat, 11 Aug 2012 23:29:57 -0600
parents e3741cf53e00
children d4cf2e139e4a
files docs/manual.docbook.sgml docs/manual/c858.html docs/manual/c867.html docs/manual/c920.html docs/manual/c929.html docs/manual/index.html docs/manual/manual.html docs/manual/manual.pdf docs/manual/x37.html docs/manual/x795.html docs/manual/x843.html docs/manual/x852.html lwlink/link.c lwlink/lwlink.h lwlink/main.c lwlink/readfiles.c lwlink/script.c
diffstat 17 files changed, 1168 insertions(+), 897 deletions(-) [+]
line wrap: on
line diff
--- a/docs/manual.docbook.sgml	Sat Aug 11 15:18:58 2012 -0600
+++ b/docs/manual.docbook.sgml	Sat Aug 11 23:29:57 2012 -0600
@@ -1984,6 +1984,30 @@
 <variablelist>
 
 <varlistentry>
+<term>sectopt <parameter>section</parameter> padafter <parameter>byte,...</parameter></term>
+<listitem>
+
+<para>
+
+This will cause the linker to append the specified list of byte values
+(specified in hexadecimal separated by commas) to the end of the named
+section.  This is done once all instances of the specified section are
+collected together.  This has no effect if the specified section does not
+appear anywhere in any of the objects specified for linking. 
+
+</para>
+
+<para>
+
+If code depends on the presence of this padding somewhere, it is sufficient
+to include an empty section of the specified name in the object that depends
+on it.
+
+</para>
+
+</listitem>
+
+<varlistentry>
 <term>define basesympat <parameter>string</parameter></term>
 <listitem>
 
@@ -1996,6 +2020,18 @@
 section have been collapsed together.
 
 </para>
+
+<para>
+
+It should be noted that if none of the objects to be linked contains a
+particular section name, there will be no base symbol defined for it, even
+if it is listed explicitly in the link script.  If code depends on the
+presence of these symbols, it is sufficient to include an empty section of
+the specified name in the object that depends on it.
+
+</para>
+
+
 <para>  If the pattern resolves to the same string for multiple
 sections, the results are undefined.
 
@@ -2015,6 +2051,18 @@
 collapsed together.
 
 </para>
+
+<para>
+
+It should be noted that if none of the objects to be linked contains a
+particular section name, there will be no length symbol defined for it, even
+if it is listed explicitly in the link script.  If code depends on the
+presence of these symbols, it is sufficient to include an empty section of
+the specified name in the object that depends on it.
+
+</para>
+
+
 <para>
 If the pattern resolves to the same string for multiple
 sections, the results are undefined.
--- a/docs/manual/c858.html	Sat Aug 11 15:18:58 2012 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,270 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
-<HTML
-><HEAD
-><TITLE
->Libraries and LWAR</TITLE
-><META
-NAME="GENERATOR"
-CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
-REL="HOME"
-TITLE="LW Tool Chain"
-HREF="index.html"><LINK
-REL="PREVIOUS"
-TITLE="Format Specific Linking Notes"
-HREF="x843.html"><LINK
-REL="NEXT"
-TITLE="Object Files"
-HREF="c920.html"></HEAD
-><BODY
-CLASS="CHAPTER"
-BGCOLOR="#FFFFFF"
-TEXT="#000000"
-LINK="#0000FF"
-VLINK="#840084"
-ALINK="#0000FF"
-><DIV
-CLASS="NAVHEADER"
-><TABLE
-SUMMARY="Header navigation table"
-WIDTH="100%"
-BORDER="0"
-CELLPADDING="0"
-CELLSPACING="0"
-><TR
-><TH
-COLSPAN="3"
-ALIGN="center"
->LW Tool Chain</TH
-></TR
-><TR
-><TD
-WIDTH="10%"
-ALIGN="left"
-VALIGN="bottom"
-><A
-HREF="x843.html"
-ACCESSKEY="P"
->Prev</A
-></TD
-><TD
-WIDTH="80%"
-ALIGN="center"
-VALIGN="bottom"
-></TD
-><TD
-WIDTH="10%"
-ALIGN="right"
-VALIGN="bottom"
-><A
-HREF="c920.html"
-ACCESSKEY="N"
->Next</A
-></TD
-></TR
-></TABLE
-><HR
-ALIGN="LEFT"
-WIDTH="100%"></DIV
-><DIV
-CLASS="CHAPTER"
-><H1
-><A
-NAME="AEN858"
-></A
->Chapter 5. Libraries and LWAR</H1
-><P
->LWTOOLS also includes a tool for managing libraries. These are analogous to
-the static libraries created with the "ar" tool on POSIX systems. Each library
-file contains one or more object files. The linker will treat the object
-files within a library as though they had been specified individually on
-the command line except when resolving external references. External references
-are looked up first within the object files within the library and then, if
-not found, the usual lookup based on the order the files are specified on
-the command line occurs.</P
-><P
->The tool for creating these libary files is called LWAR.</P
-><DIV
-CLASS="SECTION"
-><H1
-CLASS="SECTION"
-><A
-NAME="AEN862"
->5.1. Command Line Options</A
-></H1
-><P
->The binary for LWAR is called "lwar". Note that the binary is in lower
-case. The options lwar understands are listed below. For archive manipulation
-options, the first non-option argument is the name of the archive. All other
-non-option arguments are the names of files to operate on.</P
-><P
-></P
-><DIV
-CLASS="VARIABLELIST"
-><DL
-><DT
-><CODE
-CLASS="OPTION"
->--add</CODE
->, <CODE
-CLASS="OPTION"
->-a</CODE
-></DT
-><DD
-><P
->This option specifies that an archive is going to have files added to it.
-If the archive does not already exist, it is created. New files are added
-to the end of the archive.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--create</CODE
->, <CODE
-CLASS="OPTION"
->-c</CODE
-></DT
-><DD
-><P
->This option specifies that an archive is going to be created and have files
-added to it. If the archive already exists, it is truncated.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--merge</CODE
->, <CODE
-CLASS="OPTION"
->-m</CODE
-></DT
-><DD
-><P
->If specified, any files specified to be added to an archive will be checked
-to see if they are archives themselves. If so, their constituent members are
-added to the archive. This is useful for avoiding archives containing archives.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--list</CODE
->, <CODE
-CLASS="OPTION"
->-l</CODE
-></DT
-><DD
-><P
->This will display a list of the files contained in the archive.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--debug</CODE
->, <CODE
-CLASS="OPTION"
->-d</CODE
-></DT
-><DD
-><P
->This option increases the debugging level. It is only useful for LWTOOLS
-developers.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--help</CODE
->, <CODE
-CLASS="OPTION"
->-?</CODE
-></DT
-><DD
-><P
->This provides a listing of command line options and a brief description
-of each.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--usage</CODE
-></DT
-><DD
-><P
->This will display a usage summary
-of each command line option.</P
-></DD
-><DT
-><CODE
-CLASS="OPTION"
->--version</CODE
->, <CODE
-CLASS="OPTION"
->-V</CODE
-></DT
-><DD
-><P
->This will display the version of LWLINK.
-of each.</P
-></DD
-></DL
-></DIV
-></DIV
-></DIV
-><DIV
-CLASS="NAVFOOTER"
-><HR
-ALIGN="LEFT"
-WIDTH="100%"><TABLE
-SUMMARY="Footer navigation table"
-WIDTH="100%"
-BORDER="0"
-CELLPADDING="0"
-CELLSPACING="0"
-><TR
-><TD
-WIDTH="33%"
-ALIGN="left"
-VALIGN="top"
-><A
-HREF="x843.html"
-ACCESSKEY="P"
->Prev</A
-></TD
-><TD
-WIDTH="34%"
-ALIGN="center"
-VALIGN="top"
-><A
-HREF="index.html"
-ACCESSKEY="H"
->Home</A
-></TD
-><TD
-WIDTH="33%"
-ALIGN="right"
-VALIGN="top"
-><A
-HREF="c920.html"
-ACCESSKEY="N"
->Next</A
-></TD
-></TR
-><TR
-><TD
-WIDTH="33%"
-ALIGN="left"
-VALIGN="top"
->Format Specific Linking Notes</TD
-><TD
-WIDTH="34%"
-ALIGN="center"
-VALIGN="top"
->&nbsp;</TD
-><TD
-WIDTH="33%"
-ALIGN="right"
-VALIGN="top"
->Object Files</TD
-></TR
-></TABLE
-></DIV
-></BODY
-></HTML
->
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/manual/c867.html	Sat Aug 11 23:29:57 2012 -0600
@@ -0,0 +1,270 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
+<HTML
+><HEAD
+><TITLE
+>Libraries and LWAR</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
+REL="HOME"
+TITLE="LW Tool Chain"
+HREF="index.html"><LINK
+REL="PREVIOUS"
+TITLE="Format Specific Linking Notes"
+HREF="x852.html"><LINK
+REL="NEXT"
+TITLE="Object Files"
+HREF="c929.html"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFFFFF"
+TEXT="#000000"
+LINK="#0000FF"
+VLINK="#840084"
+ALINK="#0000FF"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+SUMMARY="Header navigation table"
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>LW Tool Chain</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="x852.html"
+ACCESSKEY="P"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="c929.html"
+ACCESSKEY="N"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="AEN867"
+></A
+>Chapter 5. Libraries and LWAR</H1
+><P
+>LWTOOLS also includes a tool for managing libraries. These are analogous to
+the static libraries created with the "ar" tool on POSIX systems. Each library
+file contains one or more object files. The linker will treat the object
+files within a library as though they had been specified individually on
+the command line except when resolving external references. External references
+are looked up first within the object files within the library and then, if
+not found, the usual lookup based on the order the files are specified on
+the command line occurs.</P
+><P
+>The tool for creating these libary files is called LWAR.</P
+><DIV
+CLASS="SECTION"
+><H1
+CLASS="SECTION"
+><A
+NAME="AEN871"
+>5.1. Command Line Options</A
+></H1
+><P
+>The binary for LWAR is called "lwar". Note that the binary is in lower
+case. The options lwar understands are listed below. For archive manipulation
+options, the first non-option argument is the name of the archive. All other
+non-option arguments are the names of files to operate on.</P
+><P
+></P
+><DIV
+CLASS="VARIABLELIST"
+><DL
+><DT
+><CODE
+CLASS="OPTION"
+>--add</CODE
+>, <CODE
+CLASS="OPTION"
+>-a</CODE
+></DT
+><DD
+><P
+>This option specifies that an archive is going to have files added to it.
+If the archive does not already exist, it is created. New files are added
+to the end of the archive.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--create</CODE
+>, <CODE
+CLASS="OPTION"
+>-c</CODE
+></DT
+><DD
+><P
+>This option specifies that an archive is going to be created and have files
+added to it. If the archive already exists, it is truncated.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--merge</CODE
+>, <CODE
+CLASS="OPTION"
+>-m</CODE
+></DT
+><DD
+><P
+>If specified, any files specified to be added to an archive will be checked
+to see if they are archives themselves. If so, their constituent members are
+added to the archive. This is useful for avoiding archives containing archives.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--list</CODE
+>, <CODE
+CLASS="OPTION"
+>-l</CODE
+></DT
+><DD
+><P
+>This will display a list of the files contained in the archive.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--debug</CODE
+>, <CODE
+CLASS="OPTION"
+>-d</CODE
+></DT
+><DD
+><P
+>This option increases the debugging level. It is only useful for LWTOOLS
+developers.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--help</CODE
+>, <CODE
+CLASS="OPTION"
+>-?</CODE
+></DT
+><DD
+><P
+>This provides a listing of command line options and a brief description
+of each.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--usage</CODE
+></DT
+><DD
+><P
+>This will display a usage summary
+of each command line option.</P
+></DD
+><DT
+><CODE
+CLASS="OPTION"
+>--version</CODE
+>, <CODE
+CLASS="OPTION"
+>-V</CODE
+></DT
+><DD
+><P
+>This will display the version of LWLINK.
+of each.</P
+></DD
+></DL
+></DIV
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+SUMMARY="Footer navigation table"
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="x852.html"
+ACCESSKEY="P"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+ACCESSKEY="H"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="c929.html"
+ACCESSKEY="N"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Format Specific Linking Notes</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Object Files</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- a/docs/manual/c920.html	Sat Aug 11 15:18:58 2012 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,376 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
-<HTML
-><HEAD
-><TITLE
->Object Files</TITLE
-><META
-NAME="GENERATOR"
-CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
-REL="HOME"
-TITLE="LW Tool Chain"
-HREF="index.html"><LINK
-REL="PREVIOUS"
-TITLE="Libraries and LWAR"
-HREF="c858.html"></HEAD
-><BODY
-CLASS="CHAPTER"
-BGCOLOR="#FFFFFF"
-TEXT="#000000"
-LINK="#0000FF"
-VLINK="#840084"
-ALINK="#0000FF"
-><DIV
-CLASS="NAVHEADER"
-><TABLE
-SUMMARY="Header navigation table"
-WIDTH="100%"
-BORDER="0"
-CELLPADDING="0"
-CELLSPACING="0"
-><TR
-><TH
-COLSPAN="3"
-ALIGN="center"
->LW Tool Chain</TH
-></TR
-><TR
-><TD
-WIDTH="10%"
-ALIGN="left"
-VALIGN="bottom"
-><A
-HREF="c858.html"
-ACCESSKEY="P"
->Prev</A
-></TD
-><TD
-WIDTH="80%"
-ALIGN="center"
-VALIGN="bottom"
-></TD
-><TD
-WIDTH="10%"
-ALIGN="right"
-VALIGN="bottom"
->&nbsp;</TD
-></TR
-></TABLE
-><HR
-ALIGN="LEFT"
-WIDTH="100%"></DIV
-><DIV
-CLASS="CHAPTER"
-><H1
-><A
-NAME="OBJCHAP"
-></A
->Chapter 6. Object Files</H1
-><P
->LWTOOLS uses a proprietary object file format. It is proprietary in the sense
-that it is specific to LWTOOLS, not that it is a hidden format. It would be
-hard to keep it hidden in an open source tool chain anyway. This chapter
-documents the object file format.</P
-><P
->An object file consists of a series of sections each of which contains a
-list of exported symbols, a list of incomplete references, and a list of
-"local" symbols which may be used in calculating incomplete references. Each
-section will obviously also contain the object code.</P
-><P
->Exported symbols must be completely resolved to an address within the
-section it is exported from. That is, an exported symbol must be a constant
-rather than defined in terms of other symbols.</P
-><P
->Each object file starts with a magic number and version number. The magic
-number is the string "LWOBJ16" for this 16 bit object file format. The only
-defined version number is currently 0. Thus, the first 8 bytes of the object
-file are <FONT
-COLOR="RED"
->4C574F424A313600</FONT
-></P
-><P
->Each section has the following items in order:</P
-><P
-></P
-><UL
-><LI
-><P
->section name</P
-></LI
-><LI
-><P
->flags</P
-></LI
-><LI
-><P
->list of local symbols (and addresses within the section)</P
-></LI
-><LI
-><P
->list of exported symbols (and addresses within the section)</P
-></LI
-><LI
-><P
->list of incomplete references along with the expressions to calculate them</P
-></LI
-><LI
-><P
->the actual object code (for non-BSS sections)</P
-></LI
-></UL
-><P
->The section starts with the name of the section with a NUL termination
-followed by a series of flag bytes terminated by NUL. There are only two
-flag bytes defined. A NUL (0) indicates no more flags and a value of 1
-indicates the section is a BSS section. For a BSS section, no actual
-code is included in the object file.</P
-><P
->Either a NULL section name or end of file indicate the presence of no more
-sections.</P
-><P
->Each entry in the exported and local symbols table consists of the symbol
-(NUL terminated) followed by two bytes which contain the value in big endian
-order. The end of a symbol table is indicated by a NULL symbol name.</P
-><P
->Each entry in the incomplete references table consists of an expression
-followed by a 16 bit offset where the reference goes. Expressions are
-defined as a series of terms up to an "end of expression" term. Each term
-consists of a single byte which identifies the type of term (see below)
-followed by any data required by the term. Then end of the list is flagged
-by a NULL expression (only an end of expression term).</P
-><DIV
-CLASS="TABLE"
-><A
-NAME="AEN945"
-></A
-><P
-><B
->Table 6-1. Object File Term Types</B
-></P
-><TABLE
-BORDER="1"
-FRAME="border"
-CLASS="CALSTABLE"
-><COL><COL><THEAD
-><TR
-><TH
->TERMTYPE</TH
-><TH
->Meaning</TH
-></TR
-></THEAD
-><TBODY
-><TR
-><TD
->00</TD
-><TD
->end of expression</TD
-></TR
-><TR
-><TD
->01</TD
-><TD
->integer (16 bit in big endian order follows)</TD
-></TR
-><TR
-><TD
->02</TD
-><TD
->	external symbol reference (NUL terminated symbol name follows)</TD
-></TR
-><TR
-><TD
->03</TD
-><TD
->local symbol reference (NUL terminated symbol name follows)</TD
-></TR
-><TR
-><TD
->04</TD
-><TD
->operator (1 byte operator number)</TD
-></TR
-><TR
-><TD
->05</TD
-><TD
->section base address reference</TD
-></TR
-><TR
-><TD
->FF</TD
-><TD
->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
-></TR
-></TBODY
-></TABLE
-></DIV
-><P
->External references are resolved using other object files while local
-references are resolved using the local symbol table(s) from this file. This
-allows local symbols that are not exported to have the same names as
-exported symbols or external references.</P
-><DIV
-CLASS="TABLE"
-><A
-NAME="AEN975"
-></A
-><P
-><B
->Table 6-2. Object File Operator Numbers</B
-></P
-><TABLE
-BORDER="1"
-FRAME="border"
-CLASS="CALSTABLE"
-><COL><COL><THEAD
-><TR
-><TH
->Number</TH
-><TH
->Operator</TH
-></TR
-></THEAD
-><TBODY
-><TR
-><TD
->01</TD
-><TD
->addition (+)</TD
-></TR
-><TR
-><TD
->02</TD
-><TD
->subtraction (-)</TD
-></TR
-><TR
-><TD
->03</TD
-><TD
->multiplication (*)</TD
-></TR
-><TR
-><TD
->04</TD
-><TD
->division (/)</TD
-></TR
-><TR
-><TD
->05</TD
-><TD
->modulus (%)</TD
-></TR
-><TR
-><TD
->06</TD
-><TD
->integer division (\) (same as division)</TD
-></TR
-><TR
-><TD
->07</TD
-><TD
->bitwise and</TD
-></TR
-><TR
-><TD
->08</TD
-><TD
->bitwise or</TD
-></TR
-><TR
-><TD
->09</TD
-><TD
->bitwise xor</TD
-></TR
-><TR
-><TD
->0A</TD
-><TD
->boolean and</TD
-></TR
-><TR
-><TD
->0B</TD
-><TD
->boolean or</TD
-></TR
-><TR
-><TD
->0C</TD
-><TD
->unary negation, 2's complement (-)</TD
-></TR
-><TR
-><TD
->0D</TD
-><TD
->unary 1's complement (^)</TD
-></TR
-></TBODY
-></TABLE
-></DIV
-><P
->An expression is represented in a postfix manner with both operands for
-binary operators preceding the operator and the single operand for unary
-operators preceding the operator.</P
-></DIV
-><DIV
-CLASS="NAVFOOTER"
-><HR
-ALIGN="LEFT"
-WIDTH="100%"><TABLE
-SUMMARY="Footer navigation table"
-WIDTH="100%"
-BORDER="0"
-CELLPADDING="0"
-CELLSPACING="0"
-><TR
-><TD
-WIDTH="33%"
-ALIGN="left"
-VALIGN="top"
-><A
-HREF="c858.html"
-ACCESSKEY="P"
->Prev</A
-></TD
-><TD
-WIDTH="34%"
-ALIGN="center"
-VALIGN="top"
-><A
-HREF="index.html"
-ACCESSKEY="H"
->Home</A
-></TD
-><TD
-WIDTH="33%"
-ALIGN="right"
-VALIGN="top"
->&nbsp;</TD
-></TR
-><TR
-><TD
-WIDTH="33%"
-ALIGN="left"
-VALIGN="top"
->Libraries and LWAR</TD
-><TD
-WIDTH="34%"
-ALIGN="center"
-VALIGN="top"
->&nbsp;</TD
-><TD
-WIDTH="33%"
-ALIGN="right"
-VALIGN="top"
->&nbsp;</TD
-></TR
-></TABLE
-></DIV
-></BODY
-></HTML
->
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/manual/c929.html	Sat Aug 11 23:29:57 2012 -0600
@@ -0,0 +1,376 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
+<HTML
+><HEAD
+><TITLE
+>Object Files</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
+REL="HOME"
+TITLE="LW Tool Chain"
+HREF="index.html"><LINK
+REL="PREVIOUS"
+TITLE="Libraries and LWAR"
+HREF="c867.html"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFFFFF"
+TEXT="#000000"
+LINK="#0000FF"
+VLINK="#840084"
+ALINK="#0000FF"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+SUMMARY="Header navigation table"
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>LW Tool Chain</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="c867.html"
+ACCESSKEY="P"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+>&nbsp;</TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="OBJCHAP"
+></A
+>Chapter 6. Object Files</H1
+><P
+>LWTOOLS uses a proprietary object file format. It is proprietary in the sense
+that it is specific to LWTOOLS, not that it is a hidden format. It would be
+hard to keep it hidden in an open source tool chain anyway. This chapter
+documents the object file format.</P
+><P
+>An object file consists of a series of sections each of which contains a
+list of exported symbols, a list of incomplete references, and a list of
+"local" symbols which may be used in calculating incomplete references. Each
+section will obviously also contain the object code.</P
+><P
+>Exported symbols must be completely resolved to an address within the
+section it is exported from. That is, an exported symbol must be a constant
+rather than defined in terms of other symbols.</P
+><P
+>Each object file starts with a magic number and version number. The magic
+number is the string "LWOBJ16" for this 16 bit object file format. The only
+defined version number is currently 0. Thus, the first 8 bytes of the object
+file are <FONT
+COLOR="RED"
+>4C574F424A313600</FONT
+></P
+><P
+>Each section has the following items in order:</P
+><P
+></P
+><UL
+><LI
+><P
+>section name</P
+></LI
+><LI
+><P
+>flags</P
+></LI
+><LI
+><P
+>list of local symbols (and addresses within the section)</P
+></LI
+><LI
+><P
+>list of exported symbols (and addresses within the section)</P
+></LI
+><LI
+><P
+>list of incomplete references along with the expressions to calculate them</P
+></LI
+><LI
+><P
+>the actual object code (for non-BSS sections)</P
+></LI
+></UL
+><P
+>The section starts with the name of the section with a NUL termination
+followed by a series of flag bytes terminated by NUL. There are only two
+flag bytes defined. A NUL (0) indicates no more flags and a value of 1
+indicates the section is a BSS section. For a BSS section, no actual
+code is included in the object file.</P
+><P
+>Either a NULL section name or end of file indicate the presence of no more
+sections.</P
+><P
+>Each entry in the exported and local symbols table consists of the symbol
+(NUL terminated) followed by two bytes which contain the value in big endian
+order. The end of a symbol table is indicated by a NULL symbol name.</P
+><P
+>Each entry in the incomplete references table consists of an expression
+followed by a 16 bit offset where the reference goes. Expressions are
+defined as a series of terms up to an "end of expression" term. Each term
+consists of a single byte which identifies the type of term (see below)
+followed by any data required by the term. Then end of the list is flagged
+by a NULL expression (only an end of expression term).</P
+><DIV
+CLASS="TABLE"
+><A
+NAME="AEN954"
+></A
+><P
+><B
+>Table 6-1. Object File Term Types</B
+></P
+><TABLE
+BORDER="1"
+FRAME="border"
+CLASS="CALSTABLE"
+><COL><COL><THEAD
+><TR
+><TH
+>TERMTYPE</TH
+><TH
+>Meaning</TH
+></TR
+></THEAD
+><TBODY
+><TR
+><TD
+>00</TD
+><TD
+>end of expression</TD
+></TR
+><TR
+><TD
+>01</TD
+><TD
+>integer (16 bit in big endian order follows)</TD
+></TR
+><TR
+><TD
+>02</TD
+><TD
+>	external symbol reference (NUL terminated symbol name follows)</TD
+></TR
+><TR
+><TD
+>03</TD
+><TD
+>local symbol reference (NUL terminated symbol name follows)</TD
+></TR
+><TR
+><TD
+>04</TD
+><TD
+>operator (1 byte operator number)</TD
+></TR
+><TR
+><TD
+>05</TD
+><TD
+>section base address reference</TD
+></TR
+><TR
+><TD
+>FF</TD
+><TD
+>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
+></TR
+></TBODY
+></TABLE
+></DIV
+><P
+>External references are resolved using other object files while local
+references are resolved using the local symbol table(s) from this file. This
+allows local symbols that are not exported to have the same names as
+exported symbols or external references.</P
+><DIV
+CLASS="TABLE"
+><A
+NAME="AEN984"
+></A
+><P
+><B
+>Table 6-2. Object File Operator Numbers</B
+></P
+><TABLE
+BORDER="1"
+FRAME="border"
+CLASS="CALSTABLE"
+><COL><COL><THEAD
+><TR
+><TH
+>Number</TH
+><TH
+>Operator</TH
+></TR
+></THEAD
+><TBODY
+><TR
+><TD
+>01</TD
+><TD
+>addition (+)</TD
+></TR
+><TR
+><TD
+>02</TD
+><TD
+>subtraction (-)</TD
+></TR
+><TR
+><TD
+>03</TD
+><TD
+>multiplication (*)</TD
+></TR
+><TR
+><TD
+>04</TD
+><TD
+>division (/)</TD
+></TR
+><TR
+><TD
+>05</TD
+><TD
+>modulus (%)</TD
+></TR
+><TR
+><TD
+>06</TD
+><TD
+>integer division (\) (same as division)</TD
+></TR
+><TR
+><TD
+>07</TD
+><TD
+>bitwise and</TD
+></TR
+><TR
+><TD
+>08</TD
+><TD
+>bitwise or</TD
+></TR
+><TR
+><TD
+>09</TD
+><TD
+>bitwise xor</TD
+></TR
+><TR
+><TD
+>0A</TD
+><TD
+>boolean and</TD
+></TR
+><TR
+><TD
+>0B</TD
+><TD
+>boolean or</TD
+></TR
+><TR
+><TD
+>0C</TD
+><TD
+>unary negation, 2's complement (-)</TD
+></TR
+><TR
+><TD
+>0D</TD
+><TD
+>unary 1's complement (^)</TD
+></TR
+></TBODY
+></TABLE
+></DIV
+><P
+>An expression is represented in a postfix manner with both operands for
+binary operators preceding the operator and the single operand for unary
+operators preceding the operator.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+SUMMARY="Footer navigation table"
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="c867.html"
+ACCESSKEY="P"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+ACCESSKEY="H"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>&nbsp;</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Libraries and LWAR</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>&nbsp;</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- a/docs/manual/index.html	Sat Aug 11 15:18:58 2012 -0600
+++ b/docs/manual/index.html	Sat Aug 11 23:29:57 2012 -0600
@@ -201,14 +201,14 @@
 ></DT
 ><DT
 >4.4. <A
-HREF="x843.html"
+HREF="x852.html"
 >Format Specific Linking Notes</A
 ></DT
 ><DD
 ><DL
 ><DT
 >4.4.1. <A
-HREF="x843.html#AEN846"
+HREF="x852.html#AEN855"
 >OS9 Modules</A
 ></DT
 ></DL
@@ -217,21 +217,21 @@
 ></DD
 ><DT
 >5. <A
-HREF="c858.html"
+HREF="c867.html"
 >Libraries and LWAR</A
 ></DT
 ><DD
 ><DL
 ><DT
 >5.1. <A
-HREF="c858.html#AEN862"
+HREF="c867.html#AEN871"
 >Command Line Options</A
 ></DT
 ></DL
 ></DD
 ><DT
 >6. <A
-HREF="c920.html"
+HREF="c929.html"
 >Object Files</A
 ></DT
 ></DL
@@ -246,12 +246,12 @@
 ></DT
 ><DT
 >6-1. <A
-HREF="c920.html#AEN945"
+HREF="c929.html#AEN954"
 >Object File Term Types</A
 ></DT
 ><DT
 >6-2. <A
-HREF="c920.html#AEN975"
+HREF="c929.html#AEN984"
 >Object File Operator Numbers</A
 ></DT
 ></DL
--- a/docs/manual/manual.html	Sat Aug 11 15:18:58 2012 -0600
+++ b/docs/manual/manual.html	Sat Aug 11 23:29:57 2012 -0600
@@ -198,14 +198,14 @@
 ></DT
 ><DT
 >4.4. <A
-HREF="#AEN843"
+HREF="#AEN852"
 >Format Specific Linking Notes</A
 ></DT
 ><DD
 ><DL
 ><DT
 >4.4.1. <A
-HREF="#AEN846"
+HREF="#AEN855"
 >OS9 Modules</A
 ></DT
 ></DL
@@ -214,14 +214,14 @@
 ></DD
 ><DT
 >5. <A
-HREF="#AEN858"
+HREF="#AEN867"
 >Libraries and LWAR</A
 ></DT
 ><DD
 ><DL
 ><DT
 >5.1. <A
-HREF="#AEN862"
+HREF="#AEN871"
 >Command Line Options</A
 ></DT
 ></DL
@@ -243,12 +243,12 @@
 ></DT
 ><DT
 >6-1. <A
-HREF="#AEN945"
+HREF="#AEN954"
 >Object File Term Types</A
 ></DT
 ><DT
 >6-2. <A
-HREF="#AEN975"
+HREF="#AEN984"
 >Object File Operator Numbers</A
 ></DT
 ></DL
@@ -2520,6 +2520,26 @@
 CLASS="VARIABLELIST"
 ><DL
 ><DT
+>sectopt <CODE
+CLASS="PARAMETER"
+>section</CODE
+> padafter <CODE
+CLASS="PARAMETER"
+>byte,...</CODE
+></DT
+><DD
+><P
+>&#13;This will cause the linker to append the specified list of byte values
+(specified in hexadecimal separated by commas) to the end of the named
+section.  This is done once all instances of the specified section are
+collected together.  This has no effect if the specified section does not
+appear anywhere in any of the objects specified for linking. &#13;</P
+><P
+>&#13;If code depends on the presence of this padding somewhere, it is sufficient
+to include an empty section of the specified name in the object that depends
+on it.&#13;</P
+></DD
+><DT
 >define basesympat <CODE
 CLASS="PARAMETER"
 >string</CODE
@@ -2535,6 +2555,12 @@
 section name.  The base address is calculated after all instances of each
 section have been collapsed together.&#13;</P
 ><P
+>&#13;It should be noted that if none of the objects to be linked contains a
+particular section name, there will be no base symbol defined for it, even
+if it is listed explicitly in the link script.  If code depends on the
+presence of these symbols, it is sufficient to include an empty section of
+the specified name in the object that depends on it.&#13;</P
+><P
 >  If the pattern resolves to the same string for multiple
 sections, the results are undefined.&#13;</P
 ></DD
@@ -2554,6 +2580,12 @@
 name.  The length is calculated after all instances of a section have been
 collapsed together.&#13;</P
 ><P
+>&#13;It should be noted that if none of the objects to be linked contains a
+particular section name, there will be no length symbol defined for it, even
+if it is listed explicitly in the link script.  If code depends on the
+presence of these symbols, it is sufficient to include an empty section of
+the specified name in the object that depends on it.&#13;</P
+><P
 >If the pattern resolves to the same string for multiple
 sections, the results are undefined.&#13;</P
 ></DD
@@ -2635,7 +2667,7 @@
 ><HR><H2
 CLASS="SECTION"
 ><A
-NAME="AEN843"
+NAME="AEN852"
 >4.4. Format Specific Linking Notes</A
 ></H2
 ><P
@@ -2648,7 +2680,7 @@
 ><HR><H3
 CLASS="SECTION"
 ><A
-NAME="AEN846"
+NAME="AEN855"
 >4.4.1. OS9 Modules</A
 ></H3
 ><P
@@ -2724,7 +2756,7 @@
 CLASS="CHAPTER"
 ><HR><H1
 ><A
-NAME="AEN858"
+NAME="AEN867"
 ></A
 >Chapter 5. Libraries and LWAR</H1
 ><P
@@ -2743,7 +2775,7 @@
 ><HR><H2
 CLASS="SECTION"
 ><A
-NAME="AEN862"
+NAME="AEN871"
 >5.1. Command Line Options</A
 ></H2
 ><P
@@ -2944,7 +2976,7 @@
 ><DIV
 CLASS="TABLE"
 ><A
-NAME="AEN945"
+NAME="AEN954"
 ></A
 ><P
 ><B
@@ -3016,7 +3048,7 @@
 ><DIV
 CLASS="TABLE"
 ><A
-NAME="AEN975"
+NAME="AEN984"
 ></A
 ><P
 ><B
Binary file docs/manual/manual.pdf has changed
--- a/docs/manual/x37.html	Sat Aug 11 15:18:58 2012 -0600
+++ b/docs/manual/x37.html	Sat Aug 11 23:29:57 2012 -0600
@@ -79,7 +79,7 @@
 ><P
 >LWASM supports generating a proprietary object file format which is
 described in <A
-HREF="c920.html"
+HREF="c929.html"
 >Chapter 6</A
 >. LWLINK is then used to link these
 object files into a final binary in any of LWLINK's supported binary
--- a/docs/manual/x795.html	Sat Aug 11 15:18:58 2012 -0600
+++ b/docs/manual/x795.html	Sat Aug 11 23:29:57 2012 -0600
@@ -17,7 +17,7 @@
 HREF="x781.html"><LINK
 REL="NEXT"
 TITLE="Format Specific Linking Notes"
-HREF="x843.html"></HEAD
+HREF="x852.html"></HEAD
 ><BODY
 CLASS="SECTION"
 BGCOLOR="#FFFFFF"
@@ -59,7 +59,7 @@
 ALIGN="right"
 VALIGN="bottom"
 ><A
-HREF="x843.html"
+HREF="x852.html"
 ACCESSKEY="N"
 >Next</A
 ></TD
@@ -104,6 +104,26 @@
 CLASS="VARIABLELIST"
 ><DL
 ><DT
+>sectopt <CODE
+CLASS="PARAMETER"
+>section</CODE
+> padafter <CODE
+CLASS="PARAMETER"
+>byte,...</CODE
+></DT
+><DD
+><P
+>&#13;This will cause the linker to append the specified list of byte values
+(specified in hexadecimal separated by commas) to the end of the named
+section.  This is done once all instances of the specified section are
+collected together.  This has no effect if the specified section does not
+appear anywhere in any of the objects specified for linking. &#13;</P
+><P
+>&#13;If code depends on the presence of this padding somewhere, it is sufficient
+to include an empty section of the specified name in the object that depends
+on it.&#13;</P
+></DD
+><DT
 >define basesympat <CODE
 CLASS="PARAMETER"
 >string</CODE
@@ -119,6 +139,12 @@
 section name.  The base address is calculated after all instances of each
 section have been collapsed together.&#13;</P
 ><P
+>&#13;It should be noted that if none of the objects to be linked contains a
+particular section name, there will be no base symbol defined for it, even
+if it is listed explicitly in the link script.  If code depends on the
+presence of these symbols, it is sufficient to include an empty section of
+the specified name in the object that depends on it.&#13;</P
+><P
 >  If the pattern resolves to the same string for multiple
 sections, the results are undefined.&#13;</P
 ></DD
@@ -138,6 +164,12 @@
 name.  The length is calculated after all instances of a section have been
 collapsed together.&#13;</P
 ><P
+>&#13;It should be noted that if none of the objects to be linked contains a
+particular section name, there will be no length symbol defined for it, even
+if it is listed explicitly in the link script.  If code depends on the
+presence of these symbols, it is sufficient to include an empty section of
+the specified name in the object that depends on it.&#13;</P
+><P
 >If the pattern resolves to the same string for multiple
 sections, the results are undefined.&#13;</P
 ></DD
@@ -248,7 +280,7 @@
 ALIGN="right"
 VALIGN="top"
 ><A
-HREF="x843.html"
+HREF="x852.html"
 ACCESSKEY="N"
 >Next</A
 ></TD
--- a/docs/manual/x843.html	Sat Aug 11 15:18:58 2012 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
-<HTML
-><HEAD
-><TITLE
->Format Specific Linking Notes</TITLE
-><META
-NAME="GENERATOR"
-CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
-REL="HOME"
-TITLE="LW Tool Chain"
-HREF="index.html"><LINK
-REL="UP"
-TITLE="LWLINK"
-HREF="c681.html"><LINK
-REL="PREVIOUS"
-TITLE="Linking Scripts"
-HREF="x795.html"><LINK
-REL="NEXT"
-TITLE="Libraries and LWAR"
-HREF="c858.html"></HEAD
-><BODY
-CLASS="SECTION"
-BGCOLOR="#FFFFFF"
-TEXT="#000000"
-LINK="#0000FF"
-VLINK="#840084"
-ALINK="#0000FF"
-><DIV
-CLASS="NAVHEADER"
-><TABLE
-SUMMARY="Header navigation table"
-WIDTH="100%"
-BORDER="0"
-CELLPADDING="0"
-CELLSPACING="0"
-><TR
-><TH
-COLSPAN="3"
-ALIGN="center"
->LW Tool Chain</TH
-></TR
-><TR
-><TD
-WIDTH="10%"
-ALIGN="left"
-VALIGN="bottom"
-><A
-HREF="x795.html"
-ACCESSKEY="P"
->Prev</A
-></TD
-><TD
-WIDTH="80%"
-ALIGN="center"
-VALIGN="bottom"
->Chapter 4. LWLINK</TD
-><TD
-WIDTH="10%"
-ALIGN="right"
-VALIGN="bottom"
-><A
-HREF="c858.html"
-ACCESSKEY="N"
->Next</A
-></TD
-></TR
-></TABLE
-><HR
-ALIGN="LEFT"
-WIDTH="100%"></DIV
-><DIV
-CLASS="SECTION"
-><H1
-CLASS="SECTION"
-><A
-NAME="AEN843"
->4.4. Format Specific Linking Notes</A
-></H1
-><P
->Some formats require special information to be able to generate actual
-binaries.  If the specific format you are interested in is not listed in
-this section, then there is nothing special you need to know about to create
-a final binary.</P
-><DIV
-CLASS="SECTION"
-><H2
-CLASS="SECTION"
-><A
-NAME="AEN846"
->4.4.1. OS9 Modules</A
-></H2
-><P
->OS9 modules need to embed several items into the module header. These
-items are the type of module, the langauge of the module, the module
-attributes, the module revision number, the data size (bss), and the
-execution offset.  These are all either calculated or default to reasonable
-values.</P
-><P
->The data size is calcuated as the sum of all sections named "bss" or
-".bss" in all object files that are linked together.</P
-><P
->The execution offset is calculated from the address of the special
-symbol "__start" which must be an exported (external) symbol in one of the
-objects to be linked.</P
-><P
->The type defaults to "Prgrm" or "Program module". The language
-defaults to "Objct" or "6809 object code".  Attributes default to enabling
-the re-entrant flag.  And finally, the revision defaults to zero.</P
-><P
->The embedded module name is the output filename. If the output
-filename includes more than just the filename, this will probably not be
-what you want.</P
-><P
->The type, language, attributes, revision, and module name can all be
-overridden by providing a special section in exactly one of the object files
-to be linked.  This section is called "__os9" (note the two underscores). 
-To override the type, language, attributes, or revision values, define a
-non-exported symbol in this section called "type", "lang", "attr", or "rev"
-respectively.  Any other symbols defined are ignored.  To override the
-module name, include as the only actual code in the section a NUL terminated
-string (the FCN directive is useful for this).  If there is no code in the
-section or it beings with a NUL, the default name will be used.  Any of the
-preceeding that are not defined in the special section will retain their
-default values.</P
-><P
->The built-in link script for OS9 modules will place the following
-sections, in order, in the module: "code", ".text", "data", ".data".  It
-will merge all sections with the name "bss" or ".bss" into the "data"
-section.  All other section names are ignored.  What this means is that you
-must define your data variables in the a section called "bss" or ".bss" even
-though you will be refencing them all as offsets from U.  This does have the
-unpleasant side effect that all BSS references will end up being 16 bit
-offsets because the assembler cannot know what the offset will be once the
-linker is finished its work.  Thus, if the tightest possible code is
-required, having LWASM directly output the module is a better choice.</P
-><P
->While the built-in link script is probably sufficient for most
-purposes, you can provide your own script.  If you provide a custom link
-script, you must start your code and data sections at location 000D to
-accommodate the module header.  Otherwise, you will have an incorrect
-location for the execution offset.  You must use the ENTRY directive in the
-script to define the entry point for the module.</P
-><P
->It should also be obvious from the above that you cannot mix the bss
-(rmb) definitions with the module code when linking separately.  Those
-familiar with typical module creation will probably find this an unpleasant
-difference but it is unavoidable.</P
-><P
->It should also be noted that direct page references should also be
-avoided because you cannot know ahead of time whether the linker is going to
-end up putting a particular variable in the first 256 bytes of the module's
-data space.  If, however, you know for certain you will have less than 256
-bytes of defined data space across all of the object files that will be
-linked, you can instead use forced DP addressing for your data addresses
-instead of the ,u notation.  When linking with 3rd party libraries, this
-practice should be avoided.  Also, when creating libraries, always use the
-offset from U technique.</P
-></DIV
-></DIV
-><DIV
-CLASS="NAVFOOTER"
-><HR
-ALIGN="LEFT"
-WIDTH="100%"><TABLE
-SUMMARY="Footer navigation table"
-WIDTH="100%"
-BORDER="0"
-CELLPADDING="0"
-CELLSPACING="0"
-><TR
-><TD
-WIDTH="33%"
-ALIGN="left"
-VALIGN="top"
-><A
-HREF="x795.html"
-ACCESSKEY="P"
->Prev</A
-></TD
-><TD
-WIDTH="34%"
-ALIGN="center"
-VALIGN="top"
-><A
-HREF="index.html"
-ACCESSKEY="H"
->Home</A
-></TD
-><TD
-WIDTH="33%"
-ALIGN="right"
-VALIGN="top"
-><A
-HREF="c858.html"
-ACCESSKEY="N"
->Next</A
-></TD
-></TR
-><TR
-><TD
-WIDTH="33%"
-ALIGN="left"
-VALIGN="top"
->Linking Scripts</TD
-><TD
-WIDTH="34%"
-ALIGN="center"
-VALIGN="top"
-><A
-HREF="c681.html"
-ACCESSKEY="U"
->Up</A
-></TD
-><TD
-WIDTH="33%"
-ALIGN="right"
-VALIGN="top"
->Libraries and LWAR</TD
-></TR
-></TABLE
-></DIV
-></BODY
-></HTML
->
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/manual/x852.html	Sat Aug 11 23:29:57 2012 -0600
@@ -0,0 +1,224 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
+<HTML
+><HEAD
+><TITLE
+>Format Specific Linking Notes</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
+REL="HOME"
+TITLE="LW Tool Chain"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="LWLINK"
+HREF="c681.html"><LINK
+REL="PREVIOUS"
+TITLE="Linking Scripts"
+HREF="x795.html"><LINK
+REL="NEXT"
+TITLE="Libraries and LWAR"
+HREF="c867.html"></HEAD
+><BODY
+CLASS="SECTION"
+BGCOLOR="#FFFFFF"
+TEXT="#000000"
+LINK="#0000FF"
+VLINK="#840084"
+ALINK="#0000FF"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+SUMMARY="Header navigation table"
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>LW Tool Chain</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="x795.html"
+ACCESSKEY="P"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 4. LWLINK</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="c867.html"
+ACCESSKEY="N"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECTION"
+><H1
+CLASS="SECTION"
+><A
+NAME="AEN852"
+>4.4. Format Specific Linking Notes</A
+></H1
+><P
+>Some formats require special information to be able to generate actual
+binaries.  If the specific format you are interested in is not listed in
+this section, then there is nothing special you need to know about to create
+a final binary.</P
+><DIV
+CLASS="SECTION"
+><H2
+CLASS="SECTION"
+><A
+NAME="AEN855"
+>4.4.1. OS9 Modules</A
+></H2
+><P
+>OS9 modules need to embed several items into the module header. These
+items are the type of module, the langauge of the module, the module
+attributes, the module revision number, the data size (bss), and the
+execution offset.  These are all either calculated or default to reasonable
+values.</P
+><P
+>The data size is calcuated as the sum of all sections named "bss" or
+".bss" in all object files that are linked together.</P
+><P
+>The execution offset is calculated from the address of the special
+symbol "__start" which must be an exported (external) symbol in one of the
+objects to be linked.</P
+><P
+>The type defaults to "Prgrm" or "Program module". The language
+defaults to "Objct" or "6809 object code".  Attributes default to enabling
+the re-entrant flag.  And finally, the revision defaults to zero.</P
+><P
+>The embedded module name is the output filename. If the output
+filename includes more than just the filename, this will probably not be
+what you want.</P
+><P
+>The type, language, attributes, revision, and module name can all be
+overridden by providing a special section in exactly one of the object files
+to be linked.  This section is called "__os9" (note the two underscores). 
+To override the type, language, attributes, or revision values, define a
+non-exported symbol in this section called "type", "lang", "attr", or "rev"
+respectively.  Any other symbols defined are ignored.  To override the
+module name, include as the only actual code in the section a NUL terminated
+string (the FCN directive is useful for this).  If there is no code in the
+section or it beings with a NUL, the default name will be used.  Any of the
+preceeding that are not defined in the special section will retain their
+default values.</P
+><P
+>The built-in link script for OS9 modules will place the following
+sections, in order, in the module: "code", ".text", "data", ".data".  It
+will merge all sections with the name "bss" or ".bss" into the "data"
+section.  All other section names are ignored.  What this means is that you
+must define your data variables in the a section called "bss" or ".bss" even
+though you will be refencing them all as offsets from U.  This does have the
+unpleasant side effect that all BSS references will end up being 16 bit
+offsets because the assembler cannot know what the offset will be once the
+linker is finished its work.  Thus, if the tightest possible code is
+required, having LWASM directly output the module is a better choice.</P
+><P
+>While the built-in link script is probably sufficient for most
+purposes, you can provide your own script.  If you provide a custom link
+script, you must start your code and data sections at location 000D to
+accommodate the module header.  Otherwise, you will have an incorrect
+location for the execution offset.  You must use the ENTRY directive in the
+script to define the entry point for the module.</P
+><P
+>It should also be obvious from the above that you cannot mix the bss
+(rmb) definitions with the module code when linking separately.  Those
+familiar with typical module creation will probably find this an unpleasant
+difference but it is unavoidable.</P
+><P
+>It should also be noted that direct page references should also be
+avoided because you cannot know ahead of time whether the linker is going to
+end up putting a particular variable in the first 256 bytes of the module's
+data space.  If, however, you know for certain you will have less than 256
+bytes of defined data space across all of the object files that will be
+linked, you can instead use forced DP addressing for your data addresses
+instead of the ,u notation.  When linking with 3rd party libraries, this
+practice should be avoided.  Also, when creating libraries, always use the
+offset from U technique.</P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+SUMMARY="Footer navigation table"
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="x795.html"
+ACCESSKEY="P"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+ACCESSKEY="H"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="c867.html"
+ACCESSKEY="N"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Linking Scripts</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="c681.html"
+ACCESSKEY="U"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Libraries and LWAR</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- a/lwlink/link.c	Sat Aug 11 15:18:58 2012 -0600
+++ b/lwlink/link.c	Sat Aug 11 23:29:57 2012 -0600
@@ -42,10 +42,11 @@
 
 symlist_t *symlist = NULL;
 
+sectopt_t *section_opts = NULL;
+
 void check_section_name(char *name, int *base, fileinfo_t *fn)
 {
 	int sn;
-
 //	fprintf(stderr, "Considering sections in %s (%d) for %s\n", fn -> filename, fn -> forced, name);
 	if (fn -> forced == 0)
 		return;
@@ -79,6 +80,7 @@
 void check_section_flags(int yesflags, int noflags, int *base, fileinfo_t *fn)
 {
 	int sn;
+	sectopt_t *so;
 
 //	fprintf(stderr, "Considering sections in %s (%d) for %x/%x\n", fn -> filename, fn -> forced, yesflags, noflags);
 
@@ -103,6 +105,20 @@
 		// we have a match - now collect *all* sections of the same name!
 //		fprintf(stderr, "    Found\n");
 		add_matching_sections((char *)(fn -> sections[sn].name), 0, 0, base);
+
+		/* handle "after padding" */
+		for (so = section_opts; so; so = so -> next)
+			if (!strcmp(so -> name, (char *)(fn -> sections[sn].name)))
+				break;
+		if (so)
+		{
+			if (so -> aftersize)
+			{
+				sectlist[nsects - 1].ptr -> afterbytes = so -> afterbytes;
+				sectlist[nsects - 1].ptr -> aftersize = so -> aftersize;
+				*base += so -> aftersize;
+			}
+		}
 		
 		// and then continue looking for sections
 	}
@@ -146,15 +162,31 @@
 {
 	int laddr = 0;
 	int ln, sn, fn;
+	sectopt_t *so;
 	
 	for (ln = 0; ln < linkscript.nlines; ln++)
 	{
 		if (linkscript.lines[ln].loadat >= 0)
 			laddr = linkscript.lines[ln].loadat;
+		fprintf(stderr, "Adding section %s\n", linkscript.lines[ln].sectname);
 		add_matching_sections(linkscript.lines[ln].sectname, linkscript.lines[ln].yesflags, linkscript.lines[ln].noflags, &laddr);
 		
 		if (linkscript.lines[ln].sectname)
 		{
+			char *sname = linkscript.lines[ln].sectname;
+			/* handle "after padding" */
+			for (so = section_opts; so; so = so -> next)
+				if (!strcmp(so -> name, sname))
+					break;
+			if (so)
+			{
+				if (so -> aftersize)
+				{
+					sectlist[nsects - 1].ptr -> afterbytes = so -> afterbytes;
+					sectlist[nsects - 1].ptr -> aftersize = so -> aftersize;
+					laddr += so -> aftersize;
+				}
+			}
 		}
 		else
 		{
@@ -184,6 +216,7 @@
 					if (inputfiles[fn0] -> sections[sn0].processed == 0)
 					{
 						sname = (char *)(inputfiles[fn0] -> sections[sn0].name);
+						fprintf(stderr, "Adding sectoin %s\n", sname);
 						for (fn = 0; fn < ninputfiles; fn++)
 						{
 							for (sn = 0; sn < inputfiles[fn] -> nsections; sn++)
@@ -720,3 +753,22 @@
 	linkscript.modrev &= 15;
 	linkscript.modattr &= 15;
 }
+
+void resolve_padding(void)
+{
+	int sn;
+	
+	for (sn = 0; sn < nsects; sn++)
+	{
+		if (sectlist[sn].ptr -> afterbytes)
+		{
+			unsigned char *t;
+			
+			t = lw_alloc(sectlist[sn].ptr -> codesize + sectlist[sn].ptr -> aftersize);
+			memmove(t, sectlist[sn].ptr -> code, sectlist[sn].ptr -> codesize);
+			sectlist[sn].ptr -> code = t;
+			memmove(sectlist[sn].ptr -> code + sectlist[sn].ptr -> codesize, sectlist[sn].ptr -> afterbytes, sectlist[sn].ptr -> aftersize);
+			sectlist[sn].ptr -> codesize += sectlist[sn].ptr -> aftersize;
+		}
+	}
+}
--- a/lwlink/lwlink.h	Sat Aug 11 15:18:58 2012 -0600
+++ b/lwlink/lwlink.h	Sat Aug 11 23:29:57 2012 -0600
@@ -70,6 +70,9 @@
 	reloc_t *incompletes;	// table of incomplete references
 	
 	fileinfo_t *file;		// the file we are in
+	
+	int aftersize;			// add this many bytes after section on output
+	unsigned char *afterbytes;	// add these bytes after section on output
 } section_t;
 
 struct fileinfo_s
@@ -95,9 +98,20 @@
 	int forceaddr;		// was this force to an address by the link script?
 };
 
+
+typedef struct sectopt_s sectopt_t;
+struct sectopt_s
+{
+	char *name;					// section name
+	int aftersize;				// number of bytes to append to section
+	unsigned char *afterbytes;	// the bytes to store after the section
+	sectopt_t *next;			// next section option
+};
+
 #ifndef __link_c_seen__
 extern struct section_list *sectlist;
 extern int nsects;
+extern sectopt_t *section_opts;
 #endif
 
 
--- a/lwlink/main.c	Sat Aug 11 15:18:58 2012 -0600
+++ b/lwlink/main.c	Sat Aug 11 23:29:57 2012 -0600
@@ -167,6 +167,7 @@
 extern void resolve_sections(void);
 extern void generate_symbols(void);
 extern void resolve_references(void);
+extern void resolve_padding(void);
 extern void do_output(void);
 extern void display_map(void);
 
@@ -203,6 +204,9 @@
 	
 	// resolve incomplete references
 	resolve_references();
+
+	// resolve section padding bits
+	resolve_padding();
 	
 	// do the actual output
 	do_output();
--- a/lwlink/readfiles.c	Sat Aug 11 15:18:58 2012 -0600
+++ b/lwlink/readfiles.c	Sat Aug 11 23:29:57 2012 -0600
@@ -198,6 +198,8 @@
 		s -> incompletes = NULL;
 		s -> processed = 0;
 		s -> file = fn;
+		s -> afterbytes = NULL;
+		s -> aftersize = 0;
 		
 		// read flags
 		while (CURBYTE())
--- a/lwlink/script.c	Sat Aug 11 15:18:58 2012 -0600
+++ b/lwlink/script.c	Sat Aug 11 23:29:57 2012 -0600
@@ -70,6 +70,8 @@
 static char *lwex0_script =
 	"define basesympat s_%s\n"
 	"define lensympat l_%s\n"
+	"sectopt .ctors padafter 00,00\n"
+	"sectopt .dtors padafter 00,00\n"
 	"section init load 0100\n"
 	"section .text\n"
 	"section .data\n"
@@ -226,7 +228,94 @@
 		for ( ; *ptr && isspace(*ptr); ptr++)
 			/* do nothing */ ;
 		
-		if (!strcmp(line, "define"))
+		if (!strcmp(line, "sectopt"))
+		{
+			char *sn;
+			char *ptr3;
+			sectopt_t *so;
+			
+			for (ptr2 = ptr; *ptr && !isspace(*ptr2); ptr2++)
+				/* do nothing */ ;
+			
+			if (*ptr2)
+				*ptr2++ = '\0';
+			
+			while (*ptr2 && isspace(*ptr2))
+				ptr2++;
+			
+			// section name is at ptr
+			// ptr2 is the option type
+			sn = ptr;
+
+			// now ptr2 points to the section option name
+			for (ptr3 = ptr2; *ptr3 && !isspace(*ptr3); ptr3++)
+				/* do nothing */ ;
+			
+			if (*ptr3)
+				*ptr3++ = 0;
+			
+			while (*ptr3 && isspace(*ptr3))
+				ptr3++;
+			
+			// now ptr3 points to option value
+			for (so = section_opts; so; so = so -> next)
+			{
+				if (!strcmp(so -> name, sn))
+					break;
+			}
+			
+			if (!so)
+			{
+				so = lw_alloc(sizeof(sectopt_t));
+				so -> name = lw_strdup(sn);
+				so -> aftersize = 0;
+				so -> afterbytes = NULL;
+				so -> next = section_opts;
+				section_opts = so;
+			}
+			
+			if (!strcmp(ptr2, "padafter"))
+			{
+				if (so -> afterbytes)
+					lw_free(so -> afterbytes);
+				so -> aftersize = 0;
+				
+				for (;;)
+				{
+					int v;
+					char *ptr4;
+
+					while (*ptr3 && isspace(*ptr3))
+						ptr3++;
+					
+					if (!ptr3)
+						break;
+					
+					v = strtoul(ptr3, &ptr4, 16);
+					if (ptr3 == ptr4)
+						break;
+					
+					
+					so -> afterbytes = lw_realloc(so -> afterbytes, so -> aftersize + 1);
+					so -> afterbytes[so -> aftersize] = v;
+					so -> aftersize++;
+					ptr3 = ptr4;
+					while (*ptr3 && isspace(*ptr3))
+						ptr3++;
+
+					if (*ptr3 != ',')
+						break;
+
+					ptr3++;
+				}
+			}
+			else
+			{
+				fprintf(stderr, "%s: bad script line: %s %s\n", scriptfile, line, ptr2);
+				exit(1);
+			}
+		}
+		else if (!strcmp(line, "define"))
 		{
 			// parse out the definition type
 			for (ptr2 = ptr; *ptr2 && !isspace(*ptr2); ptr2++)
@@ -253,8 +342,6 @@
 			}
 			else
 			{
-				fprintf(stderr, "%s: bad script line: %s\n", scriptfile, line);
-				exit(1);
 			}
 		}
 		else if (!strcmp(line, "pad"))