summaryrefslogtreecommitdiffstats
path: root/rbutil/mkamsboot
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-03-08 16:05:08 +0000
committerThomas Martitz <kugel@rockbox.org>2010-03-08 16:05:08 +0000
commitccefc95d8e768b6473f08b59316fe5e014fa4589 (patch)
tree6c3eb93b9c918762cc0d2928070ba90a9c77c749 /rbutil/mkamsboot
parent29a602cb801285bed6ef97784256d33017786397 (diff)
downloadrockbox-ccefc95d8e768b6473f08b59316fe5e014fa4589.tar.gz
rockbox-ccefc95d8e768b6473f08b59316fe5e014fa4589.tar.bz2
rockbox-ccefc95d8e768b6473f08b59316fe5e014fa4589.zip
Make bin2c ensure that the generated C arrays are 32bit aligned. Building nrv2e_d8 with the eabi toolchain breaks this assumption
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25071 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/mkamsboot')
-rw-r--r--rbutil/mkamsboot/dualboot/bin2c.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/rbutil/mkamsboot/dualboot/bin2c.c b/rbutil/mkamsboot/dualboot/bin2c.c
index 830224c35a..b02af88a4d 100644
--- a/rbutil/mkamsboot/dualboot/bin2c.c
+++ b/rbutil/mkamsboot/dualboot/bin2c.c
@@ -97,6 +97,7 @@ int main (int argc, char* argv[])
for(i=0; i < argc - 2; i++) {
unsigned char* buf;
off_t len;
+ off_t orig_len;
char *ext;
char *array = argv[2+i];
@@ -108,14 +109,20 @@ int main (int argc, char* argv[])
return 4;
}
- len = filesize(fd);
+ orig_len = filesize(fd);
+ /* pad to 32bit */
+ len = (orig_len + 3) & ~3;
buf = malloc(len);
- if (read(fd,buf,len) < len) {
+ if (read(fd,buf,orig_len) < orig_len) {
fprintf(stderr,"Short read, aborting\n");
return 5;
}
+ /* pad to 32bit with zeros */
+ if (len > orig_len)
+ memset(buf+orig_len, 0, len-orig_len);
+
/* remove file extension */
ext = strchr (array, '.');
if (ext != NULL)