commit dbf3b13007e75ee9c262775c84a3cf2a6b964c21
parent 0132bb719cb965b4d9899bb41cfa1cef6b94f4cd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 27 Nov 2017 16:54:04 +0000
[lib/scc] Fix myro write implementation
Diffstat:
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git 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
diff --git a/lib/scc/Makefile b/lib/scc/Makefile
@@ -7,6 +7,8 @@ include libdep.mk
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) $@ $?
diff --git a/lib/scc/lpack.c b/lib/scc/lpack.c
@@ -48,5 +48,5 @@ lpack(unsigned char *dst, char *fmt, ...)
}
va_end(va);
- return dst - bp;
+ return bp - dst;
}
diff --git a/lib/scc/wmyro.c b/lib/scc/wmyro.c
@@ -13,15 +13,15 @@ wrmyrohdr(FILE *fp, struct myrohdr *hdr)
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,
hdr->secsize,
hdr->symsize,
hdr->relsize);
- len += MYROMAGIC_SIZ;
assert(MYROHDR_SIZ == len);
fwrite(buf, len, 1, fp);