summaryrefslogtreecommitdiff
path: root/utils/sbtools/sbtoelf.c
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-10-23 17:43:52 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-10-23 17:43:52 +0000
commitb93e15c404cda96397ba2b98e49359a81d34c957 (patch)
treec01fa91dad56a1b51b4f448835de4465ab1cc265 /utils/sbtools/sbtoelf.c
parent94c573f3eca59347cd397d6b68159997bb674246 (diff)
downloadrockbox-b93e15c404cda96397ba2b98e49359a81d34c957.tar.gz
rockbox-b93e15c404cda96397ba2b98e49359a81d34c957.zip
sbtools: fix sbtoelf to support NOP, add alignment support to elftosb
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30832 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/sbtools/sbtoelf.c')
-rw-r--r--utils/sbtools/sbtoelf.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/utils/sbtools/sbtoelf.c b/utils/sbtools/sbtoelf.c
index 9a06eade79..4878c73faf 100644
--- a/utils/sbtools/sbtoelf.c
+++ b/utils/sbtools/sbtoelf.c
@@ -260,8 +260,6 @@ static void extract_section(int data_sec, char name[5], byte *buf, int size, con
260 &buf[pos + sizeof(struct sb_instruction_load_t)]); 260 &buf[pos + sizeof(struct sb_instruction_load_t)]);
261 261
262 pos += load->len + sizeof(struct sb_instruction_load_t); 262 pos += load->len + sizeof(struct sb_instruction_load_t);
263 // unsure about rounding
264 pos = ROUND_UP(pos, 16);
265 } 263 }
266 else if(hdr->opcode == SB_INST_FILL) 264 else if(hdr->opcode == SB_INST_FILL)
267 { 265 {
@@ -283,8 +281,6 @@ static void extract_section(int data_sec, char name[5], byte *buf, int size, con
283 elf_add_fill_section(&elf, fill->addr, fill->len, fill->pattern); 281 elf_add_fill_section(&elf, fill->addr, fill->len, fill->pattern);
284 282
285 pos += sizeof(struct sb_instruction_fill_t); 283 pos += sizeof(struct sb_instruction_fill_t);
286 // fixme: useless as pos is a multiple of 16 and fill struct is 4-bytes wide ?
287 pos = ROUND_UP(pos, 16);
288 } 284 }
289 else if(hdr->opcode == SB_INST_CALL || 285 else if(hdr->opcode == SB_INST_CALL ||
290 hdr->opcode == SB_INST_JUMP) 286 hdr->opcode == SB_INST_JUMP)
@@ -311,8 +307,6 @@ static void extract_section(int data_sec, char name[5], byte *buf, int size, con
311 elf_init(&elf); 307 elf_init(&elf);
312 308
313 pos += sizeof(struct sb_instruction_call_t); 309 pos += sizeof(struct sb_instruction_call_t);
314 // fixme: useless as pos is a multiple of 16 and call struct is 4-bytes wide ?
315 pos = ROUND_UP(pos, 16);
316 } 310 }
317 else if(hdr->opcode == SB_INST_MODE) 311 else if(hdr->opcode == SB_INST_MODE)
318 { 312 {
@@ -325,12 +319,20 @@ static void extract_section(int data_sec, char name[5], byte *buf, int size, con
325 color(OFF); 319 color(OFF);
326 pos += sizeof(struct sb_instruction_mode_t); 320 pos += sizeof(struct sb_instruction_mode_t);
327 } 321 }
322 else if(hdr->opcode == SB_INST_NOP)
323 {
324 color(RED);
325 printf("NOOP\n");
326 pos += sizeof(struct sb_instruction_mode_t);
327 }
328 else 328 else
329 { 329 {
330 color(RED); 330 color(RED);
331 printf("Unknown instruction %d at address 0x%08lx\n", hdr->opcode, (unsigned long)pos); 331 printf("Unknown instruction %d at address 0x%08lx\n", hdr->opcode, (unsigned long)pos);
332 break; 332 break;
333 } 333 }
334
335 pos = ROUND_UP(pos, BLOCK_SIZE);
334 } 336 }
335 337
336 if(!elf_is_empty(&elf)) 338 if(!elf_is_empty(&elf))
@@ -609,7 +611,7 @@ static void extract(unsigned long filesize)
609 const char *indent = " "; 611 const char *indent = " ";
610 while(true) 612 while(true)
611 { 613 {
612 byte cmd[16]; 614 byte cmd[BLOCK_SIZE];
613 if(sb_header->nr_keys > 0) 615 if(sb_header->nr_keys > 0)
614 cbc_mac(g_buf + offset, cmd, 1, real_key, iv, &iv, 0); 616 cbc_mac(g_buf + offset, cmd, 1, real_key, iv, &iv, 0);
615 else 617 else
@@ -620,7 +622,7 @@ static void extract(unsigned long filesize)
620 if(checksum != hdr->checksum) 622 if(checksum != hdr->checksum)
621 { 623 {
622 color(GREY); 624 color(GREY);
623 printf("[Bad checksum]"); 625 printf("[Bad checksum']");
624 } 626 }
625 627
626 if(hdr->opcode == SB_INST_NOP) 628 if(hdr->opcode == SB_INST_NOP)
@@ -628,6 +630,8 @@ static void extract(unsigned long filesize)
628 color(RED); 630 color(RED);
629 printf("NOOP\n"); 631 printf("NOOP\n");
630 offset += BLOCK_SIZE; 632 offset += BLOCK_SIZE;
633 /* restart with IV */
634 memcpy(iv, g_buf, 16);
631 } 635 }
632 else if(hdr->opcode == SB_INST_TAG) 636 else if(hdr->opcode == SB_INST_TAG)
633 { 637 {