mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
hw/elf_ops: clear uninitialized segment space
When the mem_size of the segment is bigger than the file_size,
and if this space doesn't overlap another segment, it needs
to be cleared.
This bug is very similar to the one we had for linux-user,
22d113b52f
("linux-user: Fix loading of BSS segments"),
where .bss section is encoded as an extension of the the data
one by setting the segment p_memsz > p_filesz.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
[PMD: Use recently added address_space_set()]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220115203725.3834712-3-laurent@vivier.eu>
This commit is contained in:
parent
75f01c68b5
commit
b4c4c1f112
2 changed files with 17 additions and 0 deletions
|
@ -1164,9 +1164,13 @@ static void rom_reset(void *unused)
|
|||
if (rom->mr) {
|
||||
void *host = memory_region_get_ram_ptr(rom->mr);
|
||||
memcpy(host, rom->data, rom->datasize);
|
||||
memset(host + rom->datasize, 0, rom->romsize - rom->datasize);
|
||||
} else {
|
||||
address_space_write_rom(rom->as, rom->addr, MEMTXATTRS_UNSPECIFIED,
|
||||
rom->data, rom->datasize);
|
||||
address_space_set(rom->as, rom->addr + rom->datasize, 0,
|
||||
rom->romsize - rom->datasize,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
}
|
||||
if (rom->isrom) {
|
||||
/* rom needs to be written only once */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue