shithub: scc

Download patch

ref: 81b6d6367c1c9c957ca910e5f8b5fb70adfa9c21
parent: ee085377700470e44b9c93c387f4eeac615700f8
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Nov 27 11:54:04 EST 2017

[lib/scc] Fix myro write implementation

--- a/inc/myro.h
+++ b/inc/myro.h
@@ -1,7 +1,7 @@
 
-#define MYROHDR_SIZ    52
+#define MYROHDR_SIZ    48
 #define MYROSECT_SIZ   24
-#define MYROSYM_SIZ    24
+#define MYROSYM_SIZ    26
 #define MYROREL_SIZ    20
 
 #define MYROMAGIC_SIZ   4
--- a/lib/scc/Makefile
+++ b/lib/scc/Makefile
@@ -7,6 +7,8 @@
 all: libscc.a
 
 $(LIB-OBJ): ../../inc/scc.h
+$(LIBDIR)/wmyro.o: ../../inc/myro.h
+$(LIBDIR)/rmyro.o: ../../inc/myro.h
 
 libscc.a: $(LIB-OBJ)
 	ar $(ARFLAGS) $@ $?
--- a/lib/scc/lpack.c
+++ b/lib/scc/lpack.c
@@ -48,5 +48,5 @@
 	}
 	va_end(va);
 
-	return dst - bp;
+	return bp - dst;
 }
--- a/lib/scc/wmyro.c
+++ b/lib/scc/wmyro.c
@@ -13,8 +13,9 @@
 	unsigned char buf[MYROHDR_SIZ];
 	int len;
 
-	strncpy(buf, hdr->magic, MYROMAGIC_SIZ);
-	len = lpack(buf + MYROMAGIC_SIZ, "lqqqqq",
+	len = lpack(buf, "cccclqqqqq",
+	            hdr->magic[0], hdr->magic[1],
+	            hdr->magic[2], hdr->magic[3],
 	            hdr->format,
 	            hdr->entry,
 	            hdr->strsize,
@@ -21,7 +22,6 @@
 	            hdr->secsize,
 	            hdr->symsize,
 	            hdr->relsize);
-	len += MYROMAGIC_SIZ;
 	assert(MYROHDR_SIZ == len);
 	fwrite(buf, len, 1, fp);