From ccefc95d8e768b6473f08b59316fe5e014fa4589 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 8 Mar 2010 16:05:08 +0000 Subject: [PATCH] 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 --- rbutil/mkamsboot/dualboot/bin2c.c | 11 +++++++++-- 1 file 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)