forked from len0rd/rockbox
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
This commit is contained in:
parent
1a1ac92f45
commit
143d451403
2 changed files with 21 additions and 7 deletions
|
|
@ -185,6 +185,7 @@ struct cmd_inst_t
|
||||||
{
|
{
|
||||||
enum cmd_inst_type_t type;
|
enum cmd_inst_type_t type;
|
||||||
char *identifier;
|
char *identifier;
|
||||||
|
uint32_t argument;
|
||||||
struct cmd_inst_t *next;
|
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)
|
if(find_source_by_id(cmd_file, inst->identifier) == NULL)
|
||||||
bug("invalid command file: undefined reference to source '%s'", inst->identifier);
|
bug("invalid command file: undefined reference to source '%s'", inst->identifier);
|
||||||
next();
|
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)
|
if(lexem.type != LEX_SEMICOLON)
|
||||||
bug("invalid command file: expected ';' after command");
|
bug("invalid command file: expected ';' after command");
|
||||||
|
|
||||||
|
|
@ -529,6 +541,7 @@ struct sb_inst_t
|
||||||
uint32_t pattern;
|
uint32_t pattern;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
// </union>
|
// </union>
|
||||||
|
uint32_t argument; // for call and jump
|
||||||
/* for production use */
|
/* for production use */
|
||||||
uint32_t padding_size;
|
uint32_t padding_size;
|
||||||
uint8_t *padding;
|
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)
|
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].inst = (cinst->type == CMD_JUMP) ? SB_INST_JUMP : SB_INST_CALL;
|
||||||
sec->insts[idx++].addr = elf->start_addr;
|
sec->insts[idx++].addr = elf->start_addr;
|
||||||
}
|
}
|
||||||
|
|
@ -722,7 +736,7 @@ static void compute_sb_offsets(struct sb_file_t *sb)
|
||||||
{
|
{
|
||||||
if(g_debug)
|
if(g_debug)
|
||||||
printf("%s | addr=0x%08x | arg=0x%08x\n",
|
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;
|
sb->image_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE;
|
||||||
sec->sec_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_CALL:
|
||||||
case SB_INST_JUMP:
|
case SB_INST_JUMP:
|
||||||
cmd->len = 0;
|
cmd->len = 0;
|
||||||
cmd->data = 0;
|
cmd->data = inst->argument;
|
||||||
break;
|
break;
|
||||||
case SB_INST_FILL:
|
case SB_INST_FILL:
|
||||||
cmd->data = inst->pattern;
|
cmd->data = inst->pattern;
|
||||||
|
|
|
||||||
|
|
@ -355,15 +355,16 @@ static void extract(unsigned long filesize)
|
||||||
bugp("File size mismatch");
|
bugp("File size mismatch");
|
||||||
if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t))
|
if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t))
|
||||||
bugp("Bad header size");
|
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))
|
if(sb_header->sec_hdr_size * BLOCK_SIZE != sizeof(struct sb_section_header_t))
|
||||||
bugp("Bad section header size");
|
bugp("Bad section header size");
|
||||||
|
|
||||||
color(BLUE);
|
color(BLUE);
|
||||||
printf("Basic info:\n");
|
printf("Basic info:\n");
|
||||||
color(GREEN);
|
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: ");
|
printf(" Header SHA-1: ");
|
||||||
byte *hdr_sha1 = sb_header->sha1_header;
|
byte *hdr_sha1 = sb_header->sha1_header;
|
||||||
color(YELLOW);
|
color(YELLOW);
|
||||||
|
|
@ -716,7 +717,6 @@ int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
printf("Usage: %s <firmware> <key file> [<out prefix>]\n",*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 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue