static void extract_elf_section(struct elf_params_t *elf, int count, uint32_t id) { char name[5]; char *filename = xmalloc(strlen(g_out_prefix) + 32); sb_fill_section_name(name, id); sprintf(filename, "%s%s.%d.elf", g_out_prefix, name, count); if(g_debug) printf("Write boot section %s to %s\n", name, filename); FILE *fd = fopen(filename, "wb"); free(filename); if(fd == NULL) return ; elf_write_file(elf, elf_write, elf_printf, fd); fclose(fd); }
static void extract_elf(struct elf_params_t *elf, int count) { char *filename = xmalloc(strlen(g_out_prefix) + 32); sprintf(filename, "%s%d.elf", g_out_prefix, count); if(g_debug) printf("Write boot content to %s\n", filename); FILE *fd = fopen(filename, "wb"); free(filename); if(fd == NULL) return; if(g_elf_simplify) elf_simplify(elf); elf_write_file(elf, elf_std_write, generic_std_printf, fd); fclose(fd); }