diff lwasm/pseudo.c @ 198:6ddc861a07d4

Allow export to import undefined symbols
author lost
date Sun, 22 Mar 2009 18:26:59 +0000
parents bfd0fb0a85c2
children 188037f0397c
line wrap: on
line diff
--- a/lwasm/pseudo.c	Sun Mar 22 18:01:30 2009 +0000
+++ b/lwasm/pseudo.c	Sun Mar 22 18:26:59 2009 +0000
@@ -1082,6 +1082,17 @@
 	// the symbol better be defined at this point (pass 2)
 	// local symbols cannot be exported nor can "global" symbols
 	se = lwasm_find_symbol(as, l -> sym, -1);
+	if (!se && (as -> pragmas & PRAGMA_IMPORTUNDEFEXPORT))
+	{
+		// import the symbol
+		if (as -> csect)
+		{
+			register_error(as, l, 1, "Cannot declare external symbols within a section");
+			return;
+		}
+	
+		lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN);
+	}
 	if (!se)
 	{
 		register_error(as, l, 2, "Exported symbols must be fully defined within a section");