summaryrefslogtreecommitdiff
path: root/utils/imxtools/sbtools/elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/imxtools/sbtools/elf.c')
-rw-r--r--utils/imxtools/sbtools/elf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/utils/imxtools/sbtools/elf.c b/utils/imxtools/sbtools/elf.c
index c41fc27fdd..5626c0f58c 100644
--- a/utils/imxtools/sbtools/elf.c
+++ b/utils/imxtools/sbtools/elf.c
@@ -208,9 +208,9 @@ void elf_add_fill_section(struct elf_params_t *params,
208 printf("oops, non-zero filling, ignore fill section\n"); 208 printf("oops, non-zero filling, ignore fill section\n");
209 return; 209 return;
210 } 210 }
211 211
212 struct elf_section_t *sec = elf_add_section(params); 212 struct elf_section_t *sec = elf_add_section(params);
213 213
214 sec->type = EST_FILL; 214 sec->type = EST_FILL;
215 sec->addr = fill_addr; 215 sec->addr = fill_addr;
216 sec->size = size; 216 sec->size = size;
@@ -239,7 +239,7 @@ void elf_simplify(struct elf_params_t *params)
239 nr_sections++; 239 nr_sections++;
240 cur_sec = cur_sec->next; 240 cur_sec = cur_sec->next;
241 } 241 }
242 242
243 /* put all sections in an array and free list */ 243 /* put all sections in an array and free list */
244 struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections); 244 struct elf_section_t *sections = malloc(sizeof(struct elf_section_t) * nr_sections);
245 cur_sec = params->first_section; 245 cur_sec = params->first_section;
@@ -371,7 +371,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
371 elf_printf_fn_t printf, void *user) 371 elf_printf_fn_t printf, void *user)
372{ 372{
373 (void) printf; 373 (void) printf;
374 374
375 Elf32_Ehdr ehdr; 375 Elf32_Ehdr ehdr;
376 uint32_t phnum = 0; 376 uint32_t phnum = 0;
377 struct elf_section_t *sec = params->first_section; 377 struct elf_section_t *sec = params->first_section;
@@ -391,7 +391,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
391 { 391 {
392 sec->offset = 0; 392 sec->offset = 0;
393 } 393 }
394 394
395 phnum++; 395 phnum++;
396 sec = sec->next; 396 sec = sec->next;
397 } 397 }
@@ -431,7 +431,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
431 * - one name ".shstrtab\0" */ 431 * - one name ".shstrtab\0" */
432 char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 + 432 char *strtbl_content = malloc(1 + strlen(".shstrtab") + 1 +
433 phnum * (strlen(".textXXXX") + 1)); 433 phnum * (strlen(".textXXXX") + 1));
434 434
435 strtbl_content[0] = '\0'; 435 strtbl_content[0] = '\0';
436 strcpy(&strtbl_content[1], ".shstrtab"); 436 strcpy(&strtbl_content[1], ".shstrtab");
437 uint32_t strtbl_index = 1 + strlen(".shstrtab") + 1; 437 uint32_t strtbl_index = 1 + strlen(".shstrtab") + 1;
@@ -444,7 +444,7 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
444 while(sec) 444 while(sec)
445 { 445 {
446 sec->offset += data_offset; 446 sec->offset += data_offset;
447 447
448 phdr.p_type = PT_LOAD; 448 phdr.p_type = PT_LOAD;
449 if(sec->type == EST_LOAD) 449 if(sec->type == EST_LOAD)
450 phdr.p_offset = sec->offset; 450 phdr.p_offset = sec->offset;
@@ -549,7 +549,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
549 elf_printf_fn_t printf, void *user) 549 elf_printf_fn_t printf, void *user)
550{ 550{
551 #define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;}) 551 #define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;})
552 552
553 /* read header */ 553 /* read header */
554 Elf32_Ehdr ehdr; 554 Elf32_Ehdr ehdr;
555 if(!read(user, 0, &ehdr, sizeof(ehdr))) 555 if(!read(user, 0, &ehdr, sizeof(ehdr)))
@@ -626,7 +626,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
626 if(strtab) 626 if(strtab)
627 printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type); 627 printf(user, false, "filter out %s\n", &strtab[shdr.sh_name], shdr.sh_type);
628 } 628 }
629 629
630 } 630 }
631 free(strtab); 631 free(strtab);
632 /* run through segments */ 632 /* run through segments */
@@ -647,7 +647,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
647 printf(user, false, "create segment [%#x,+%#x[ -> [%#x,+%#x[\n", 647 printf(user, false, "create segment [%#x,+%#x[ -> [%#x,+%#x[\n",
648 seg->vaddr, seg->vsize, seg->paddr, seg->psize); 648 seg->vaddr, seg->vsize, seg->paddr, seg->psize);
649 } 649 }
650 650
651 return true; 651 return true;
652} 652}
653 653