# HG changeset patch # User William Astle # Date 1360037039 25200 # Node ID 7de7b14ebaee403f7486dbf3a33c795df325291f # Parent f45b2a68c3da80bd864b931acc5968979659ab83 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. diff -r f45b2a68c3da -r 7de7b14ebaee lwlink/link.c --- 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"); } } diff -r f45b2a68c3da -r 7de7b14ebaee lwlink/lwlink.h --- 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) diff -r f45b2a68c3da -r 7de7b14ebaee lwlink/output.c --- 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; diff -r f45b2a68c3da -r 7de7b14ebaee lwlink/script.c --- 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; }