summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-10-09 17:10:40 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-10-09 17:10:40 +0000
commit239a9a9c6888a0c342f18803191d66fac05b74e1 (patch)
tree803f43e3a41c82b84696b51ff871c916b3f86d1f
parent53d1dc331dbf75f1d3b3a3758ec711362b3f1578 (diff)
Pad the ECOFF output file to a 512 bytes boundary; older AViiON firmware will
reject non-padded files with an irrelevant error message, and newer firmware won't mind the extra bytes.
-rw-r--r--sys/arch/aviion/stand/a2coff/a2coff.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/arch/aviion/stand/a2coff/a2coff.c b/sys/arch/aviion/stand/a2coff/a2coff.c
index 7abad536334..5c6fa2033a2 100644
--- a/sys/arch/aviion/stand/a2coff/a2coff.c
+++ b/sys/arch/aviion/stand/a2coff/a2coff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: a2coff.c,v 1.3 2008/01/29 13:02:31 krw Exp $ */
+/* $OpenBSD: a2coff.c,v 1.4 2011/10/09 17:10:39 miod Exp $ */
/*
* Copyright (c) 2006, Miodrag Vallat
*
@@ -48,6 +48,8 @@
#define __LDPGSZ 0x1000
#endif /* m88k */
+#define ECOFF_ALIGN 0x200
+
/*
* We can't use the standard ecoff defines, first, because the system
* we are building this tool on might not have ecoff support at all (thus
@@ -129,6 +131,8 @@ main(int argc, char *argv[])
struct ecoff_exechdr ehead;
struct ecoff_scnhdr escn[3];
int infd, outfd;
+ off_t outpos;
+ uint32_t chunk;
int n;
if (argc != 3)
@@ -248,8 +252,10 @@ main(int argc, char *argv[])
escn[1].s_name, N_DATOFF(head), escn[1].s_scnptr, head.a_data);
#endif
lseek(outfd, escn[1].s_scnptr, SEEK_SET);
+ outpos = escn[1].s_scnptr;
lseek(infd, N_DATOFF(head), SEEK_SET);
copybits(infd, outfd, head.a_data);
+ outpos += head.a_data;
/*
* ``Copy'' bss section
@@ -259,7 +265,17 @@ main(int argc, char *argv[])
printf("copying %s: size %lx\n",
escn[2].s_name, round(head.a_data + head.a_bss, 8) - head.a_data);
#endif
- zerobits(outfd, round(head.a_data + head.a_bss, 8) - head.a_data);
+ chunk = round(head.a_data + head.a_bss, 8) - head.a_data;
+ zerobits(outfd, chunk);
+ outpos += chunk;
+
+ /*
+ * Round file to a multiple of 512 bytes, since older PROM
+ * (at least rev 1.20 on AV530) will reject files not being
+ * properly rounded.
+ */
+ if ((outpos % ECOFF_ALIGN) != 0)
+ zerobits(outfd, ECOFF_ALIGN - (outpos % ECOFF_ALIGN));
close(infd);
close(outfd);