diff options
Diffstat (limited to 'utils/sbtools/elftosb.c')
-rw-r--r-- | utils/sbtools/elftosb.c | 18 |
1 files changed, 16 insertions, 2 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 | |||
185 | { | 185 | { |
186 | enum cmd_inst_type_t type; | 186 | enum cmd_inst_type_t type; |
187 | char *identifier; | 187 | char *identifier; |
188 | uint32_t argument; | ||
188 | struct cmd_inst_t *next; | 189 | struct cmd_inst_t *next; |
189 | }; | 190 | }; |
190 | 191 | ||
@@ -485,6 +486,17 @@ static struct cmd_file_t *read_command_file(const char *file) | |||
485 | if(find_source_by_id(cmd_file, inst->identifier) == NULL) | 486 | if(find_source_by_id(cmd_file, inst->identifier) == NULL) |
486 | bug("invalid command file: undefined reference to source '%s'", inst->identifier); | 487 | bug("invalid command file: undefined reference to source '%s'", inst->identifier); |
487 | next(); | 488 | next(); |
489 | if((inst->type == CMD_CALL || inst->type == CMD_JUMP) && lexem.type == LEX_LPAREN) | ||
490 | { | ||
491 | next(); | ||
492 | if(lexem.type != LEX_NUMBER) | ||
493 | bug("invalid command file: expected numeral expression after ("); | ||
494 | inst->argument = lexem.num; | ||
495 | next(); | ||
496 | if(lexem.type != LEX_RPAREN) | ||
497 | bug("invalid command file: expected closing brace"); | ||
498 | next(); | ||
499 | } | ||
488 | if(lexem.type != LEX_SEMICOLON) | 500 | if(lexem.type != LEX_SEMICOLON) |
489 | bug("invalid command file: expected ';' after command"); | 501 | bug("invalid command file: expected ';' after command"); |
490 | 502 | ||
@@ -529,6 +541,7 @@ struct sb_inst_t | |||
529 | uint32_t pattern; | 541 | uint32_t pattern; |
530 | uint32_t addr; | 542 | uint32_t addr; |
531 | // </union> | 543 | // </union> |
544 | uint32_t argument; // for call and jump | ||
532 | /* for production use */ | 545 | /* for production use */ |
533 | uint32_t padding_size; | 546 | uint32_t padding_size; |
534 | uint8_t *padding; | 547 | uint8_t *padding; |
@@ -665,6 +678,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file) | |||
665 | } | 678 | } |
666 | else if(cinst->type == CMD_JUMP || cinst->type == CMD_CALL) | 679 | else if(cinst->type == CMD_JUMP || cinst->type == CMD_CALL) |
667 | { | 680 | { |
681 | sec->insts[idx].argument = cinst->argument; | ||
668 | sec->insts[idx].inst = (cinst->type == CMD_JUMP) ? SB_INST_JUMP : SB_INST_CALL; | 682 | sec->insts[idx].inst = (cinst->type == CMD_JUMP) ? SB_INST_JUMP : SB_INST_CALL; |
669 | sec->insts[idx++].addr = elf->start_addr; | 683 | sec->insts[idx++].addr = elf->start_addr; |
670 | } | 684 | } |
@@ -722,7 +736,7 @@ static void compute_sb_offsets(struct sb_file_t *sb) | |||
722 | { | 736 | { |
723 | if(g_debug) | 737 | if(g_debug) |
724 | printf("%s | addr=0x%08x | arg=0x%08x\n", | 738 | printf("%s | addr=0x%08x | arg=0x%08x\n", |
725 | inst->inst == SB_INST_CALL ? "CALL" : "JUMP", inst->addr, 0); | 739 | inst->inst == SB_INST_CALL ? "CALL" : "JUMP", inst->addr, inst->argument); |
726 | sb->image_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; | 740 | sb->image_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; |
727 | sec->sec_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; | 741 | sec->sec_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; |
728 | } | 742 | } |
@@ -844,7 +858,7 @@ void produce_sb_instruction(struct sb_inst_t *inst, | |||
844 | case SB_INST_CALL: | 858 | case SB_INST_CALL: |
845 | case SB_INST_JUMP: | 859 | case SB_INST_JUMP: |
846 | cmd->len = 0; | 860 | cmd->len = 0; |
847 | cmd->data = 0; | 861 | cmd->data = inst->argument; |
848 | break; | 862 | break; |
849 | case SB_INST_FILL: | 863 | case SB_INST_FILL: |
850 | cmd->data = inst->pattern; | 864 | cmd->data = inst->pattern; |