Exemplo n.º 1
0
static struct elf_file_t *elf_file_create_from_allocated_buffer(void *buffer, int size, char *path)
{
	struct elf_file_t *elf_file;

	/* Create buffer */
	elf_debug("**\n** Loading ELF file\n** %s\n**\n\n", path);
	elf_file = calloc(1, sizeof(struct elf_file_t));
	if (!elf_file)
		fatal("%s: out of memory", __FUNCTION__);

	/* Duplicate path string */
	elf_file->path = strdup(path ? path : "");
	if (!elf_file->path)
		fatal("%s: out of memory", __FUNCTION__);

	/* Initialize buffer */
	elf_file->buffer.ptr = buffer;
	elf_file->buffer.size = size;
	elf_file->buffer.pos = 0;

	/* Read ELF file contents */
	elf_file_read_elf_header(elf_file);
	elf_file_read_section_headers(elf_file);
	elf_file_read_program_headers(elf_file);
	elf_file_read_symbol_table(elf_file);

	/* Return */
	elf_debug("\n\n\n");
	return elf_file;
}
Exemplo n.º 2
0
static struct elf_file_t *elf_file_create_from_allocated_buffer(void *buffer, int size, char *path)
{
	struct elf_file_t *elf_file;

	/* Create buffer */
	elf_file = xcalloc(1, sizeof(struct elf_file_t));

	/* Initialize buffer */
	elf_file->path = xstrdup(path ? path : "");
	elf_file->buffer.ptr = buffer;
	elf_file->buffer.size = size;
	elf_file->buffer.pos = 0;

	/* Read ELF file contents */
	elf_file_read_elf_header(elf_file);
	elf_file_read_section_headers(elf_file);
	elf_file_read_program_headers(elf_file);
	elf_file_read_symbol_table(elf_file);

	/* Return */
	return elf_file;
}