Ejemplo n.º 1
0
int elf32_extract(FILE *in, binfile_imgcb_t cb, void *user_data)
{
	struct elf32_info info;
	int i;
	int ret = 0;

	if (read_all(&info, in) < 0)
		return -1;

	if (load_strings(&info, in,
			 &info.file_shdrs[info.file_ehdr.e_shstrndx]) < 0) {
		printc_err("elf32: warning: can't load section string "
			   "table\n");
		info.string_tab = NULL;
	}

	for (i = 0; i < info.file_ehdr.e_shnum; i++) {
		Elf32_Shdr *s = &info.file_shdrs[i];

		if (s->sh_type == SHT_PROGBITS && s->sh_flags & SHF_ALLOC &&
		    feed_section(&info, in, s, cb, user_data) < 0) {
			ret = -1;
			break;
		}
	}

	if (info.string_tab)
		free(info.string_tab);

	return ret;
}
Ejemplo n.º 2
0
int elf32_extract(FILE *in, binfile_imgcb_t cb, void *user_data)
{
	struct elf32_info info;
	int i;

	if (read_all(&info, in) < 0)
		return -1;

	for (i = 0; i < info.file_ehdr.e_shnum; i++) {
		GElf_Shdr *s = &info.file_shdrs[i];

		if (s->sh_type == SHT_PROGBITS && s->sh_flags & SHF_ALLOC &&
		    feed_section(&info, in, s->sh_offset, s->sh_size,
				 cb, user_data) < 0)
			return -1;
	}

	return 0;
}