diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-03-08 16:05:08 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-03-08 16:05:08 +0000 |
commit | ccefc95d8e768b6473f08b59316fe5e014fa4589 (patch) | |
tree | 6c3eb93b9c918762cc0d2928070ba90a9c77c749 /rbutil/mkamsboot | |
parent | 29a602cb801285bed6ef97784256d33017786397 (diff) |
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.c | 11 |
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) |