changeset 173:0395e6fd67e9

Fixed stupid errors with changes for archive handling
author lost
date Mon, 02 Mar 2009 04:13:49 +0000
parents 47427342e41d
children cc41ccee8f64
files lwlink/link.c lwlink/readfiles.c
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lwlink/link.c	Sun Mar 01 22:59:52 2009 +0000
+++ b/lwlink/link.c	Mon Mar 02 04:13:49 2009 +0000
@@ -52,7 +52,7 @@
 			nsects++;
 		}
 	}
-	for (sn = 0; sn < fn -> nsubs; fn++)
+	for (sn = 0; sn < fn -> nsubs; sn++)
 	{
 		check_section_name(name, base, fn -> subs[sn]);
 	}
@@ -79,7 +79,7 @@
 		
 		// and then continue looking for sections
 	}
-	for (sn = 0; sn < fn -> nsubs; fn++)
+	for (sn = 0; sn < fn -> nsubs; sn++)
 	{
 		check_section_flags(yesflags, noflags, base, fn -> subs[sn]);
 	}
@@ -273,11 +273,14 @@
 	{
 		// external symbol
 		// read all files in order until found (or not found)
-		for (fp = sect -> file; fp; fp = fp -> parent)
+		if (sect)
 		{
-			s = find_external_sym_recurse(sym, fp);
-			if (s)
-				return s;
+			for (fp = sect -> file; fp; fp = fp -> parent)
+			{
+				s = find_external_sym_recurse(sym, fp);
+				if (s)
+					return s;
+			}
 		}
 
 		for (fn = 0; fn < ninputfiles; fn++)
--- a/lwlink/readfiles.c	Sun Mar 01 22:59:52 2009 +0000
+++ b/lwlink/readfiles.c	Mon Mar 02 04:13:49 2009 +0000
@@ -340,9 +340,11 @@
 		if (cc >= fn -> filesize || !(fn -> filedata[cc]))
 			return;
 
-		for (l = cc; cc < fn -> filesize && fn -> filedata[cc]; l++)
+		for (l = cc; cc < fn -> filesize && fn -> filedata[cc]; cc++)
 			/* do nothing */ ;
 
+		cc++;
+
 		if (cc >= fn -> filesize)
 		{
 			fprintf(stderr, "Malformed archive file %s.\n", fn -> filename);
@@ -352,8 +354,10 @@
 		if (cc + 4 > fn -> filesize)
 			return;
 
-		flen = (fn -> filedata[cc++] << 24) | (fn -> filedata[cc++] << 16)
-			| (fn -> filedata[cc++] << 8) | (fn -> filedata[cc]);
+		flen = (fn -> filedata[cc++] << 24);
+		flen |= (fn -> filedata[cc++] << 16);
+		flen |= (fn -> filedata[cc++] << 8);
+		flen |= (fn -> filedata[cc++]);
 
 		if (flen == 0)
 			return;
@@ -372,7 +376,9 @@
 		fn -> subs[fn -> nsubs] -> filesize = flen;
 		fn -> subs[fn -> nsubs] -> filename = lw_strdup(fn -> filedata + l);
 		fn -> subs[fn -> nsubs] -> parent = fn;
+		
 		read_file(fn -> subs[fn -> nsubs]);
 		fn -> nsubs++;
+		cc += flen;
 	}
 }