summaryrefslogtreecommitdiff
path: root/utils/sbtools/elftosb.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/sbtools/elftosb.c')
-rw-r--r--utils/sbtools/elftosb.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/sbtools/elftosb.c b/utils/sbtools/elftosb.c
index 88c784734a..f791a4cca0 100644
--- a/utils/sbtools/elftosb.c
+++ b/utils/sbtools/elftosb.c
@@ -111,6 +111,8 @@ static key_array_t read_keys(const char *key_file, int *num_keys)
111 bugp("reading key file"); 111 bugp("reading key file");
112 close(fd); 112 close(fd);
113 113
114 if(g_debug)
115 printf("Parsing key file '%s'...\n", key_file);
114 *num_keys = size ? 1 : 0; 116 *num_keys = size ? 1 : 0;
115 char *ptr = buf; 117 char *ptr = buf;
116 /* allow trailing newline at the end (but no space after it) */ 118 /* allow trailing newline at the end (but no space after it) */
@@ -137,6 +139,13 @@ static key_array_t read_keys(const char *key_file, int *num_keys)
137 bugp(" invalid key, it should be a 128-bit key written in hexadecimal\n"); 139 bugp(" invalid key, it should be a 128-bit key written in hexadecimal\n");
138 keys[i][j] = (a << 4) | b; 140 keys[i][j] = (a << 4) | b;
139 } 141 }
142 if(g_debug)
143 {
144 printf("Add key: ");
145 for(int j = 0; j < 16; j++)
146 printf("%02x", keys[i][j]);
147 printf("\n");
148 }
140 pos += 32; 149 pos += 32;
141 } 150 }
142 free(buf); 151 free(buf);
@@ -376,6 +385,8 @@ static struct cmd_file_t *read_command_file(const char *file)
376 bugp("reading command file"); 385 bugp("reading command file");
377 close(fd); 386 close(fd);
378 387
388 if(g_debug)
389 printf("Parsing command file '%s'...\n", file);
379 struct cmd_file_t *cmd_file = xmalloc(sizeof(struct cmd_file_t)); 390 struct cmd_file_t *cmd_file = xmalloc(sizeof(struct cmd_file_t));
380 memset(cmd_file, 0, sizeof(struct cmd_file_t)); 391 memset(cmd_file, 0, sizeof(struct cmd_file_t));
381 392
@@ -397,6 +408,7 @@ static struct cmd_file_t *read_command_file(const char *file)
397 if(lexem.type == LEX_RBRACE) 408 if(lexem.type == LEX_RBRACE)
398 break; 409 break;
399 struct cmd_source_t *src = xmalloc(sizeof(struct cmd_source_t)); 410 struct cmd_source_t *src = xmalloc(sizeof(struct cmd_source_t));
411 memset(src, 0, sizeof(struct cmd_source_t));
400 src->next = cmd_file->source_list; 412 src->next = cmd_file->source_list;
401 if(lexem.type != LEX_IDENTIFIER) 413 if(lexem.type != LEX_IDENTIFIER)
402 bug("invalid command file: identifier expected in sources"); 414 bug("invalid command file: identifier expected in sources");
@@ -562,6 +574,8 @@ static void load_elf_by_id(struct cmd_file_t *cmd_file, const char *id)
562 int fd = open(src->filename, O_RDONLY); 574 int fd = open(src->filename, O_RDONLY);
563 if(fd < 0) 575 if(fd < 0)
564 bug("cannot open '%s' (id '%s')\n", src->filename, id); 576 bug("cannot open '%s' (id '%s')\n", src->filename, id);
577 if(g_debug)
578 printf("Loading ELF file '%s'...\n", src->filename);
565 elf_init(&src->elf); 579 elf_init(&src->elf);
566 src->elf_loaded = elf_read_file(&src->elf, elf_read, elf_printf, &fd); 580 src->elf_loaded = elf_read_file(&src->elf, elf_read, elf_printf, &fd);
567 close(fd); 581 close(fd);
@@ -573,6 +587,9 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
573{ 587{
574 struct sb_file_t *sb = xmalloc(sizeof(struct sb_file_t)); 588 struct sb_file_t *sb = xmalloc(sizeof(struct sb_file_t));
575 memset(sb, 0, sizeof(struct sb_file_t)); 589 memset(sb, 0, sizeof(struct sb_file_t));
590
591 if(g_debug)
592 printf("Applying command file...\n");
576 /* count sections */ 593 /* count sections */
577 struct cmd_section_t *csec = cmd_file->section_list; 594 struct cmd_section_t *csec = cmd_file->section_list;
578 while(csec) 595 while(csec)