changeset 262:7de7b14ebaee

Add support for os9 module edition byte Add support for the symbol "edition" in the __os9 section which defines the module edition byte which follows immedately after the module name in the module. It defaults to not setting one.
author William Astle <lost@l-w.ca>
date Mon, 04 Feb 2013 21:03:59 -0700
parents f45b2a68c3da
children 8dd8c3bdca7c
files lwlink/link.c lwlink/lwlink.h lwlink/output.c lwlink/script.c
diffstat 4 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lwlink/link.c	Mon Feb 04 20:51:55 2013 -0700
+++ b/lwlink/link.c	Mon Feb 04 21:03:59 2013 -0700
@@ -726,6 +726,7 @@
 	int langseen;
 	int revseen;
 	int nameseen;
+	int edseen;
 };
 
 void check_os9_aux(section_t *s, void *arg)
@@ -739,6 +740,7 @@
 	// lang: module language
 	// attr: module attributes
 	// rev: module revision
+	// ed: module edition
 	//
 	// the symbols are not case sensitive
 	//
@@ -779,6 +781,11 @@
 		{
 			linkscript.stacksize += sym -> offset;
 		}
+		else if (!strcasecmp(sm, 'edition'))
+		{
+			linkscript.edition = sym -> offset;
+			st -> edseen++;
+		}
 	}
 }
 
@@ -801,10 +808,10 @@
 	
 	if (st.attrseen > 1 || st.typeseen > 1 ||
 		st.langseen > 1 || st.revseen > 1 ||
-		st.nameseen > 1
+		st.nameseen > 1 | st.edseen > 1
 	)
 	{
-		fprintf(stderr, "Warning: multiple instances of __os9 found with duplicate settings of type, lang, attr, rev, or module name.\n");
+		fprintf(stderr, "Warning: multiple instances of __os9 found with duplicate settings of type, lang, attr, rev, edition, or module name.\n");
 	}
 }
 
--- a/lwlink/lwlink.h	Mon Feb 04 20:51:55 2013 -0700
+++ b/lwlink/lwlink.h	Mon Feb 04 21:03:59 2013 -0700
@@ -170,6 +170,7 @@
 	int modlang;				// module language
 	int modattr;				// module attributes
 	int modrev;					// module revision
+	int edition;				// module edition
 	char *name;					// module name
 	char *basesympat;			// pattern for section base symbol (%s for section name)
 	char *lensympat;			// pattern for section length symbol (%s for section name)
--- a/lwlink/output.c	Mon Feb 04 20:51:55 2013 -0700
+++ b/lwlink/output.c	Mon Feb 04 21:03:59 2013 -0700
@@ -272,6 +272,8 @@
 	nameoff = codedatasize; // we'll put the name at the end
 	codedatasize += 3;	// add in CRC
 	codedatasize += strlen(linkscript.name); // add in name length
+	if (linkscript.edition >= 0)
+		codedatasize += 1;
 	
 	// output the file header
 	buf[0] = 0x87;
@@ -333,6 +335,13 @@
 	writebytes(buf, 1, 1, of);
 	os9crc(crc, buf[0]);
 	
+	if (linkscript.edition >= 0)
+	{
+		buf[0] = linkscript.edition & 0x80;
+		writebytes(buf, 1, 1, of);
+		os9crc(crc, buf[0]);
+	}
+	
 	crc[0] ^= 0xff;
 	crc[1] ^= 0xff;
 	crc[2] ^= 0xff;
--- a/lwlink/script.c	Mon Feb 04 20:51:55 2013 -0700
+++ b/lwlink/script.c	Mon Feb 04 21:03:59 2013 -0700
@@ -189,6 +189,7 @@
 		linkscript.modlang = 0x01;
 		linkscript.modattr = 0x08;
 		linkscript.modrev = 0x00;
+		linkscript.edition = -1;
 		linkscript.name = NULL;
 	}