# HG changeset patch # User William Astle # Date 1652554670 21600 # Node ID 543b5d1341d229ae0c0f3f53d8a4b0b0f5839b89 # Parent b8e9ac01dedabd7a78993bf1fd5b4595f4ded22a Add note to manual about numeric entry addresses in scripts Link scripts require a numeric entry address to begin with a digit. Make a note about that in the manual since hex addresses starting with letters could be mistaken for symbols. diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual.docbook.sgml --- a/docs/manual.docbook.sgml Sat May 14 12:28:44 2022 -0600 +++ b/docs/manual.docbook.sgml Sat May 14 12:57:50 2022 -0600 @@ -2605,6 +2605,9 @@ that support this directive automatically starts at the beginning of the first section (usually "init" or "code") that is emitted in the binary. + +Note that if you use a numeric value here, you will need to ensure +it starts with a digit. That may mean adding a leading zero. diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/c1023.html --- a/docs/manual/c1023.html Sat May 14 12:28:44 2022 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ - -Libraries and LWAR
LW Tool Chain
PrevNext

Chapter 5. Libraries and LWAR

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.

The tool for creating these libary files is called LWAR.

5.1. Command Line Options

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.

--add, -a

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.

--create, -c

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.

--merge, -m

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.

--list, -l

This will display a list of the files contained in the archive.

--debug, -d

This option increases the debugging level. It is only useful for LWTOOLS -developers.

--help, -?

This provides a listing of command line options and a brief description -of each.

--usage

This will display a usage summary -of each command line option.

--version, -V

This will display the version of LWLINK. -of each.


PrevHomeNext
Format Specific Linking Notes Object Files
\ No newline at end of file diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/c1024.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/manual/c1024.html Sat May 14 12:57:50 2022 -0600 @@ -0,0 +1,270 @@ + +Libraries and LWAR
LW Tool Chain
PrevNext

Chapter 5. Libraries and LWAR

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.

The tool for creating these libary files is called LWAR.

5.1. Command Line Options

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.

--add, -a

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.

--create, -c

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.

--merge, -m

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.

--list, -l

This will display a list of the files contained in the archive.

--debug, -d

This option increases the debugging level. It is only useful for LWTOOLS +developers.

--help, -?

This provides a listing of command line options and a brief description +of each.

--usage

This will display a usage summary +of each command line option.

--version, -V

This will display the version of LWLINK. +of each.


PrevHomeNext
Format Specific Linking Notes Object Files
\ No newline at end of file diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/c1085.html --- a/docs/manual/c1085.html Sat May 14 12:28:44 2022 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,376 +0,0 @@ - -Object Files
LW Tool Chain
Prev 

Chapter 6. Object Files

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.

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.

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.

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 4C574F424A313600

Each section has the following items in order:

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.

Either a NULL section name or end of file indicate the presence of no more -sections.

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.

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).

Table 6-1. Object File Term Types

TERMTYPEMeaning
00end of expression
01integer (16 bit in big endian order follows)
02 external symbol reference (NUL terminated symbol name follows)
03local symbol reference (NUL terminated symbol name follows)
04operator (1 byte operator number)
05section base address reference
FFThis 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).

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.

Table 6-2. Object File Operator Numbers

NumberOperator
01addition (+)
02subtraction (-)
03multiplication (*)
04division (/)
05modulus (%)
06integer division (\) (same as division)
07bitwise and
08bitwise or
09bitwise xor
0Aboolean and
0Bboolean or
0Cunary negation, 2's complement (-)
0Dunary 1's complement (^)

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.


PrevHome 
Libraries and LWAR  
\ No newline at end of file diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/c1086.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/manual/c1086.html Sat May 14 12:57:50 2022 -0600 @@ -0,0 +1,376 @@ + +Object Files
LW Tool Chain
Prev 

Chapter 6. Object Files

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.

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.

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.

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 4C574F424A313600

Each section has the following items in order:

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.

Either a NULL section name or end of file indicate the presence of no more +sections.

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.

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).

Table 6-1. Object File Term Types

TERMTYPEMeaning
00end of expression
01integer (16 bit in big endian order follows)
02 external symbol reference (NUL terminated symbol name follows)
03local symbol reference (NUL terminated symbol name follows)
04operator (1 byte operator number)
05section base address reference
FFThis 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).

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.

Table 6-2. Object File Operator Numbers

NumberOperator
01addition (+)
02subtraction (-)
03multiplication (*)
04division (/)
05modulus (%)
06integer division (\) (same as division)
07bitwise and
08bitwise or
09bitwise xor
0Aboolean and
0Bboolean or
0Cunary negation, 2's complement (-)
0Dunary 1's complement (^)

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.


PrevHome 
Libraries and LWAR  
\ No newline at end of file diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/index.html --- a/docs/manual/index.html Sat May 14 12:28:44 2022 -0600 +++ b/docs/manual/index.html Sat May 14 12:57:50 2022 -0600 @@ -232,14 +232,14 @@ >
4.4. Format Specific Linking Notes
4.4.1. OS9 Modules
5. Libraries and LWAR
5.1. Command Line Options
6. Object Files
6-1. Object File Term Types
6-2. Object File Operator Numbers
4.4. Format Specific Linking Notes
4.4.1. OS9 Modules
5. Libraries and LWAR
5.1. Command Line Options
6-1. Object File Term Types
6-2. Object File Operator Numbers

Note that if you use a numeric value here, you will need to ensure +it starts with a digit. That may mean adding a leading zero.

pad

4.4. Format Specific Linking Notes


4.4.1. OS9 Modules


Chapter 5. Libraries and LWAR


5.1. Command Line Options

-Format Specific Linking Notes

LW Tool Chain
PrevChapter 4. LWLINKNext

4.4. Format Specific Linking Notes

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.

4.4.1. OS9 Modules

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.

The data size is calcuated as the sum of all sections named "bss" or -".bss" in all object files that are linked together.

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.

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.

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.

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.

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.

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.

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.

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.


PrevHomeNext
Linking ScriptsUpLibraries and LWAR
\ No newline at end of file diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/x1009.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/manual/x1009.html Sat May 14 12:57:50 2022 -0600 @@ -0,0 +1,224 @@ + +Format Specific Linking Notes
LW Tool Chain
PrevChapter 4. LWLINKNext

4.4. Format Specific Linking Notes

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.

4.4.1. OS9 Modules

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.

The data size is calcuated as the sum of all sections named "bss" or +".bss" in all object files that are linked together.

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.

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.

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.

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.

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.

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.

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.

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.


PrevHomeNext
Linking ScriptsUpLibraries and LWAR
\ No newline at end of file diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/x54.html --- a/docs/manual/x54.html Sat May 14 12:28:44 2022 -0600 +++ b/docs/manual/x54.html Sat May 14 12:57:50 2022 -0600 @@ -79,7 +79,7 @@ >

LWASM supports generating a proprietary object file format which is described in Chapter 6. LWLINK is then used to link these object files into a final binary in any of LWLINK's supported binary diff -r b8e9ac01deda -r 543b5d1341d2 docs/manual/x942.html --- a/docs/manual/x942.html Sat May 14 12:28:44 2022 -0600 +++ b/docs/manual/x942.html Sat May 14 12:57:50 2022 -0600 @@ -17,7 +17,7 @@ HREF="x928.html">Next

Note that if you use a numeric value here, you will need to ensure +it starts with a digit. That may mean adding a leading zero.

pad Next