changeset 184:220a760ec654

Make lwlink display all undefined references instead of bailing after the first one
author lost
date Sat, 21 Mar 2009 17:39:45 +0000
parents 302b8db5fd89
children b89adfb0d174
files ChangeLog lwlink/link.c lwlink/lwlink.c lwlink/lwlink.h
diffstat 4 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 21 17:03:42 2009 +0000
+++ b/ChangeLog	Sat Mar 21 17:39:45 2009 +0000
@@ -21,7 +21,8 @@
 [ ] DECB output of LWLINK now collapses contiguous output blocks into single
     single blocks in the output file; this eliminates the explosion of
     preambles that previously occurred
-
+[ ] LWLINK now displays *all* undefined symbols and references instead of
+    bailing out after the first one
 
 Version 2.2
 
--- a/lwlink/link.c	Sat Mar 21 17:03:42 2009 +0000
+++ b/lwlink/link.c	Sat Mar 21 17:39:45 2009 +0000
@@ -266,8 +266,9 @@
 			}
 		}
 		// not found
+		symerr = 1;
 		fprintf(stderr, "Local symbol %s not found in %s:%s\n", sym, sect -> file -> filename, sect -> name);
-		exit(1);
+		goto outerr;
 	}
 	else
 	{
@@ -297,7 +298,8 @@
 		{
 			fprintf(stderr, "External symbol %s not found\n", sym);
 		}
-		exit(1);
+		symerr = 1;
+		goto outerr;
 	}
 	fprintf(stderr, "Shouldn't ever get here!!!\n");
 	exit(88);
@@ -307,6 +309,8 @@
 	lw_expr_stack_push(s, term);
 	lw_expr_term_free(term);
 	return s;
+outerr:
+	return NULL;
 }
 
 void resolve_references(void)
@@ -337,14 +341,19 @@
 			// is it constant? error out if not
 			if (rval != 0 || !lw_expr_is_constant(rl -> expr))
 			{
-				fprintf(stderr, "Incomplete reference at %s:%s:%02X\n", sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> name, rl -> offset);
-				exit(1);
+				fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> name, rl -> offset);
+				symerr = 1;
 			}
-			
-			// put the value into the relocation address
-			rval = lw_expr_get_value(rl -> expr);
-			sectlist[sn].ptr -> code[rl -> offset] = (rval >> 8) & 0xff;
-			sectlist[sn].ptr -> code[rl -> offset + 1] = rval & 0xff;
+			else
+			{
+				// put the value into the relocation address
+				rval = lw_expr_get_value(rl -> expr);
+				sectlist[sn].ptr -> code[rl -> offset] = (rval >> 8) & 0xff;
+				sectlist[sn].ptr -> code[rl -> offset + 1] = rval & 0xff;
+			}
 		}
 	}
+	
+	if (symerr)
+		exit(1);
 }
--- a/lwlink/lwlink.c	Sat Mar 21 17:03:42 2009 +0000
+++ b/lwlink/lwlink.c	Sat Mar 21 17:39:45 2009 +0000
@@ -40,6 +40,7 @@
 int outformat = OUTPUT_DECB;
 char *outfile = NULL;
 char *scriptfile = NULL;
+int symerr = 0;
 
 fileinfo_t **inputfiles = NULL;
 int ninputfiles = 0;
--- a/lwlink/lwlink.h	Sat Mar 21 17:03:42 2009 +0000
+++ b/lwlink/lwlink.h	Sat Mar 21 17:39:45 2009 +0000
@@ -108,6 +108,8 @@
 extern int nscriptls;
 extern char **scriptls;
 
+extern int symerr;
+
 #define __lwlink_E__ extern
 #else
 #define __lwlink_E__