summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-06-30 21:30:06 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-06-30 21:30:06 +0000
commit143d4514036243f223e7b7023784f57fca08318d (patch)
tree0b6e1e1e7aaa001aee564091bb393c18a270567f /utils
parent1a1ac92f453410b6f81ce6092b18162c1903af35 (diff)
downloadrockbox-143d4514036243f223e7b7023784f57fca08318d.tar.gz
rockbox-143d4514036243f223e7b7023784f57fca08318d.tar.bz2
rockbox-143d4514036243f223e7b7023784f57fca08318d.zip
elftosb: add support for jumps/calls with one argument
sbtoelf: remove sb version check and print it in the basic info Thanks TheLemonMan ! git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30106 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/sbtools/elftosb.c18
-rw-r--r--utils/sbtools/sbtoelf.c10
2 files changed, 21 insertions, 7 deletions
diff --git a/utils/sbtools/elftosb.c b/utils/sbtools/elftosb.c
index 3d53fb76d5..58665da16d 100644
--- a/utils/sbtools/elftosb.c
+++ b/utils/sbtools/elftosb.c
@@ -185,6 +185,7 @@ struct cmd_inst_t
{
enum cmd_inst_type_t type;
char *identifier;
+ uint32_t argument;
struct cmd_inst_t *next;
};
@@ -485,6 +486,17 @@ static struct cmd_file_t *read_command_file(const char *file)
if(find_source_by_id(cmd_file, inst->identifier) == NULL)
bug("invalid command file: undefined reference to source '%s'", inst->identifier);
next();
+ if((inst->type == CMD_CALL || inst->type == CMD_JUMP) && lexem.type == LEX_LPAREN)
+ {
+ next();
+ if(lexem.type != LEX_NUMBER)
+ bug("invalid command file: expected numeral expression after (");
+ inst->argument = lexem.num;
+ next();
+ if(lexem.type != LEX_RPAREN)
+ bug("invalid command file: expected closing brace");
+ next();
+ }
if(lexem.type != LEX_SEMICOLON)
bug("invalid command file: expected ';' after command");
@@ -529,6 +541,7 @@ struct sb_inst_t
uint32_t pattern;
uint32_t addr;
// </union>
+ uint32_t argument; // for call and jump
/* for production use */
uint32_t padding_size;
uint8_t *padding;
@@ -665,6 +678,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
}
else if(cinst->type == CMD_JUMP || cinst->type == CMD_CALL)
{
+ sec->insts[idx].argument = cinst->argument;
sec->insts[idx].inst = (cinst->type == CMD_JUMP) ? SB_INST_JUMP : SB_INST_CALL;
sec->insts[idx++].addr = elf->start_addr;
}
@@ -722,7 +736,7 @@ static void compute_sb_offsets(struct sb_file_t *sb)
{
if(g_debug)
printf("%s | addr=0x%08x | arg=0x%08x\n",
- inst->inst == SB_INST_CALL ? "CALL" : "JUMP", inst->addr, 0);
+ inst->inst == SB_INST_CALL ? "CALL" : "JUMP", inst->addr, inst->argument);
sb->image_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE;
sec->sec_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE;
}
@@ -844,7 +858,7 @@ void produce_sb_instruction(struct sb_inst_t *inst,
case SB_INST_CALL:
case SB_INST_JUMP:
cmd->len = 0;
- cmd->data = 0;
+ cmd->data = inst->argument;
break;
case SB_INST_FILL:
cmd->data = inst->pattern;
diff --git a/utils/sbtools/sbtoelf.c b/utils/sbtools/sbtoelf.c
index 7e6b77055b..851189f05e 100644
--- a/utils/sbtools/sbtoelf.c
+++ b/utils/sbtools/sbtoelf.c
@@ -355,15 +355,16 @@ static void extract(unsigned long filesize)
bugp("File size mismatch");
if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t))
bugp("Bad header size");
- if((sb_header->major_ver != IMAGE_MAJOR_VERSION ||
- sb_header->minor_ver != IMAGE_MINOR_VERSION) && strcasecmp(s_getenv("SB_IGNORE_VER"), "YES"))
- bugp("Bad file format version");
if(sb_header->sec_hdr_size * BLOCK_SIZE != sizeof(struct sb_section_header_t))
bugp("Bad section header size");
-
+
color(BLUE);
printf("Basic info:\n");
color(GREEN);
+ printf(" SB version: ");
+ color(YELLOW);
+ printf("%d.%d\n", sb_header->major_ver, sb_header->minor_ver);
+ color(GREEN);
printf(" Header SHA-1: ");
byte *hdr_sha1 = sb_header->sha1_header;
color(YELLOW);
@@ -716,7 +717,6 @@ int main(int argc, const char **argv)
{
printf("Usage: %s <firmware> <key file> [<out prefix>]\n",*argv);
printf("To use raw command mode, set environment variable SB_RAW_CMD to YES\n");
- printf("To ignore the file version check, set environment variable SB_IGNORE_VER to YES\n");
return 1;
}