loader: Handle memory-mapped ELFs
This patch allows handling an ELF memory-mapped, taking care the reference count of the GMappedFile* passed through rom_add_elf_program(). In this case, the 'data' pointer is not heap-allocated, so we cannot free it. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-Id: <20190724143105.307042-2-sgarzare@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b896c4b50d
commit
fef28891aa
3 changed files with 34 additions and 11 deletions
|
|
@ -525,7 +525,7 @@ static int glue(load_elf, SZ)(const char *name, int fd,
|
|||
snprintf(label, sizeof(label), "phdr #%d: %s", i, name);
|
||||
|
||||
/* rom_add_elf_program() seize the ownership of 'data' */
|
||||
rom_add_elf_program(label, data, file_size, mem_size,
|
||||
rom_add_elf_program(label, NULL, data, file_size, mem_size,
|
||||
addr, as);
|
||||
} else {
|
||||
address_space_write(as ? as : &address_space_memory,
|
||||
|
|
|
|||
|
|
@ -258,8 +258,9 @@ MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
|
|||
FWCfgCallback fw_callback,
|
||||
void *callback_opaque, AddressSpace *as,
|
||||
bool read_only);
|
||||
int rom_add_elf_program(const char *name, void *data, size_t datasize,
|
||||
size_t romsize, hwaddr addr, AddressSpace *as);
|
||||
int rom_add_elf_program(const char *name, GMappedFile *mapped_file, void *data,
|
||||
size_t datasize, size_t romsize, hwaddr addr,
|
||||
AddressSpace *as);
|
||||
int rom_check_and_register_reset(void);
|
||||
void rom_set_fw(FWCfgState *f);
|
||||
void rom_set_order_override(int order);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue