changeset 70:ceab04fd2969

Fixed premature installation of external reference under UNDEFEXTERN pragma; should not resolve to external references until after the initial parsing pass
author lost@l-w.ca
date Sun, 10 Apr 2011 13:15:12 -0600
parents 87026ec7e1c2
children 6dafb4f0fa56
files lwasm/lwasm.c lwasm/lwasm.h lwasm/main.c
diffstat 3 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.c	Sat Apr 09 01:45:48 2011 -0600
+++ b/lwasm/lwasm.c	Sun Apr 10 13:15:12 2011 -0600
@@ -70,7 +70,7 @@
 	}
 	
 	// check for "undefined" to import automatically
-	if (!im && CURPRAGMA(as -> cl, PRAGMA_UNDEFEXTERN))
+	if ((as -> passno != 0) && !im && CURPRAGMA(as -> cl, PRAGMA_UNDEFEXTERN))
 	{
 		im = lw_alloc(sizeof(importlist_t));
 		im -> symbol = lw_strdup(var);
--- a/lwasm/lwasm.h	Sat Apr 09 01:45:48 2011 -0600
+++ b/lwasm/lwasm.h	Sun Apr 10 13:15:12 2011 -0600
@@ -284,6 +284,7 @@
 	structtab_t *cstruct;				// current structure
 	lw_expr_t savedaddr;				// old address counter before struct started	
 	int exportcheck;					// set if we need to collapse out the section base to 0
+	int passno;							// set to the current pass number
 };
 
 #ifndef ___symbol_c_seen___
--- a/lwasm/main.c	Sat Apr 09 01:45:48 2011 -0600
+++ b/lwasm/main.c	Sun Apr 10 13:15:12 2011 -0600
@@ -232,6 +232,7 @@
 	{
 		if ((asmstate.flags & FLAG_DEPEND) && passlist[passnum].fordep == 0)
 			continue;
+		asmstate.passno = passnum;
 		debug_message(&asmstate, 50, "Doing pass %d (%s)\n", passnum, passlist[passnum].passname);
 		(passlist[passnum].fn)(&asmstate);
 		debug_message(&asmstate, 50, "After pass %d (%s)\n", passnum, passlist[passnum].passname);