shithub: scc

Download patch

ref: 88ed18b6b1014546e25583c8d2372ba8030e1bf8
parent: 6d5cccdbfa78d757b07efa64195f49a5db7e46e1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Feb 20 03:08:59 EST 2019

[libmach] Keep archive names with at least 1 letter

This fix is needed for files with names like '/' used
by some libraries for the index file.

--- a/src/cmd/nm.c
+++ b/src/cmd/nm.c
@@ -155,7 +155,7 @@
 		return;
 	}
 
-	if (objread(obj, fp) < 0 || objsyms(obj))
+	if (objread(obj, fp) < 0 || objsyms(obj) < 0)
 		goto error;
 
 	for (sym = obj->syms; sym; sym = sym->next)
--- a/src/libmach/armember.c
+++ b/src/libmach/armember.c
@@ -14,7 +14,7 @@
         memcpy(dst, hdr->ar_name, SARNAM);
         dst[SARNAM] = '\0';
 
-        for (i = SARNAM-1; i >= 0; i--) {
+        for (i = SARNAM-1; i > 0; i--) {
                 if (dst[i] != ' ' && dst[i] != '/')
                         break;
                 dst[i] = '\0';
--- a/src/libmach/coff32/coff32getsyms.c
+++ b/src/libmach/coff32/coff32getsyms.c
@@ -73,13 +73,13 @@
 		ent = &coff->ents[i];
 
 		if ((t = typeof(coff, ent)) < 0)
-			return 0;
+			return -1;
 
 		if ((s = symname(coff, ent)) == NULL)
-			return 0;
+			return -1;
 
 		if ((sym = objlookup(obj, s, 1)) == NULL)
-			return 0;
+			return -1;
 
 		sym->type = t;
 		sym->value = ent->n_value;
@@ -86,5 +86,5 @@
 		sym->size = (sym->type == 'C') ? ent->n_value : 0;
 	}
 
-	return 1;
+	return i;
 }