changeset 243:f9f01a499525 2.x

Added zero-width external references
author lost
date Tue, 15 Sep 2009 03:16:17 +0000
parents 848d55b181f0
children c8bcc396ec59
files ChangeLog configure.ac lwasm/instab.c lwasm/lwasm.h lwasm/output.c lwasm/pass1.c lwasm/pseudo.c lwlink/link.c lwlink/lwlink.h lwlink/objdump.c lwlink/readfiles.c
diffstat 11 files changed, 75 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 16 18:34:13 2009 +0000
+++ b/ChangeLog	Tue Sep 15 03:16:17 2009 +0000
@@ -11,6 +11,14 @@
 
 Also, the software affected may follow in [].
 
+Version 2.6
+
+[+] Added "EXTDEP" pseudo op to force a dependency on an external symbol
+    without an actual external reference - a zero-width external reference
+    so to speak [LWASM,LWLINK]
+[+] Decode known incomplete expression flags [LWOBJDUMP]
+[b] Treat incomplete reference flags as specified in docs [LWLINK]
+
 Version 2.5
 
 [!] Fixed error in the fix for invalid operands included in 2.4 [LWASM]
--- a/configure.ac	Sun Aug 16 18:34:13 2009 +0000
+++ b/configure.ac	Tue Sep 15 03:16:17 2009 +0000
@@ -1,4 +1,4 @@
-AC_INIT([LWTOOLS], [2.5-pre], [lost@l-w.ca])
+AC_INIT([LWTOOLS], [2.6-pre], [lost@l-w.ca])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_PROG_CC
 gl_EARLY
--- a/lwasm/instab.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwasm/instab.c	Tue Sep 15 03:16:17 2009 +0000
@@ -84,6 +84,7 @@
 extern OPFUNC(pseudo_ifndef);
 extern OPFUNC(pseudo_noop);
 extern OPFUNC(pseudo_includebin);
+extern OPFUNC(pseudo_extdep);
 
 extern OPFUNC(pseudo_os9);
 extern OPFUNC(pseudo_mod);
@@ -356,6 +357,7 @@
 	{ "import",	{ -1, -1, -1, -1 },	pseudo_extern,	0,	0,	1 },
 	{ "export",	{ -1, -1, -1, -1 },	pseudo_export,	0,	0,	1 },
 
+	{ "extdep",	{ -1, -1, -1, -1 }, pseudo_extdep, 0, 0, 1 },
 
 	{ "rmb", 	{ -1, -1, -1, -1 }, pseudo_rmb },
 	{ "rmd", 	{ -1, -1, -1, -1 }, pseudo_rmd },
--- a/lwasm/lwasm.h	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwasm/lwasm.h	Tue Sep 15 03:16:17 2009 +0000
@@ -189,6 +189,9 @@
 	// for os9 mode
 	int inmod;					// in a module?
 	unsigned char crc[3];			// running crc count
+	
+	int nextdeps;				// number forced external deps
+	char **extdeps;				// external dependencies
 } asmstate_t;
 
 // do not rewrite XXX,r to ,r if XXX evaluates to 0
--- a/lwasm/output.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwasm/output.c	Tue Sep 15 03:16:17 2009 +0000
@@ -352,6 +352,16 @@
 		
 		// now output the "incomplete references"
 		// this being the most complex bit
+		for (i = 0; i < as -> nextdeps; i++)
+		{
+			// flag 0-width reference
+			writebytes("\xFF\x02", 2, 1, of);
+			// write external symbol ref
+			writebytes("\x02", 1, 1, of);
+			writebytes(as -> extdeps[i], strlen(as -> extdeps[i]) + 1, 1, of);
+			// flag end of expr & offset 0 - the 3 is not an error
+			writebytes("\0\0", 3, 1, of);
+		}
 		for (re = s -> rl; re; re = re -> next)
 		{
 			if (re -> expr == NULL)
--- a/lwasm/pass1.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwasm/pass1.c	Tue Sep 15 03:16:17 2009 +0000
@@ -166,6 +166,9 @@
 	as -> nextcontext = 1;
 
 	as -> inmod = 0;
+
+	as -> extdeps = NULL;
+	as -> nextdeps = 0;
 	
 	debug_message(1, "Entering pass 1");
 	if (lwasm_read_file(as, as -> infile) < 0)
--- a/lwasm/pseudo.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwasm/pseudo.c	Tue Sep 15 03:16:17 2009 +0000
@@ -1211,6 +1211,26 @@
 		register_error(as, l, 1, "Bad import list");
 }
 
+OPFUNC(pseudo_extdep)
+{
+	if (as -> passnum != 1)
+		return;
+
+	if (as -> outformat != OUTPUT_OBJ)
+	{
+		register_error(as, l, 1, "External references only supported for obj target");
+		return;
+	}
+	
+	if (l -> sym)
+	{
+		// add symbol to the "ext dep" list
+		as -> extdeps = lwasm_realloc(as -> extdeps, sizeof(char *) * (as -> nextdeps + 1));
+		as -> extdeps[as -> nextdeps++] = lwasm_strdup(l -> sym);
+		return;
+	}
+}
+
 OPFUNC(pseudo_export)
 {
 	lwasm_symbol_ent_t *se;
--- a/lwlink/link.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwlink/link.c	Tue Sep 15 03:16:17 2009 +0000
@@ -373,6 +373,9 @@
 			}
 			else
 			{
+				// is it a zero-width link?
+				if (rl -> flags & RELOC_0BIT)
+					continue;
 				// put the value into the relocation address
 				rval = lw_expr_get_value(rl -> expr);
 				if (rl -> flags & RELOC_8BIT)
--- a/lwlink/lwlink.h	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwlink/lwlink.h	Tue Sep 15 03:16:17 2009 +0000
@@ -41,6 +41,7 @@
 
 #define RELOC_NORM	0		// all default (16 bit)
 #define RELOC_8BIT	1		// only use the low 8 bits for the reloc
+#define RELOC_0BIT	2		// don't actual stuff a reloc anywhere!
 typedef struct reloc_s reloc_t;
 struct reloc_s
 {
--- a/lwlink/objdump.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwlink/objdump.c	Tue Sep 15 03:16:17 2009 +0000
@@ -262,7 +262,18 @@
 				
 				case 0xFF:
 					// section flags
-					printf(" FLAGS=%02X", CURBYTE());
+					printf(" FLAGS=");
+					switch(CURBYTE())
+					{
+					case 0x01:
+						printf("8BIT");
+						break;
+					case 0x02:
+						printf("0BIT");
+						break;
+					default:
+						printf("%02X", CURBYTE());
+					}
 					NEXTBYTE();
 					break;
 					
--- a/lwlink/readfiles.c	Sun Aug 16 18:34:13 2009 +0000
+++ b/lwlink/readfiles.c	Tue Sep 15 03:16:17 2009 +0000
@@ -277,6 +277,18 @@
 				case 0xFF:
 					// a flag specifier
 					tt = CURBYTE();
+					switch (tt)
+					{
+					case 0x01:
+						rp -> flags |= RELOC_8BIT;
+						break;
+					case 0x02:
+						rp -> flags |= RELOC_0BIT;
+						break;
+					default:
+						fprintf(stderr, "%s (%s): unknown relocation flag (%02X)\n", fn -> filename, s -> name, tt);
+						exit(1);
+					}
 					rp -> flags = tt;
 					NEXTBYTE();
 					term = NULL;