summary refs log tree commit diff stats
path: root/cpu-target.c
diff options
context:
space:
mode:
authorBin Meng <bmeng@tinylab.org>2024-01-16 23:50:49 +0800
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-01-19 12:28:59 +0100
commit62570f1434160d356311e1c217537e24a4ac85cd (patch)
treece213c695896732f824601e24c8bf3f1d642f6d4 /cpu-target.c
parentc2d7de557d19ec76eb83b87b6bf77c8114e2f183 (diff)
downloadfocaccia-qemu-62570f1434160d356311e1c217537e24a4ac85cd.tar.gz
focaccia-qemu-62570f1434160d356311e1c217537e24a4ac85cd.zip
hw/elf_ops: Ignore loadable segments with zero size
Some ELF files really do have segments of zero size, e.g.:

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  RISCV_ATTRIBUT 0x00000000000025b8 0x0000000000000000 0x0000000000000000
                 0x000000000000003e 0x0000000000000000  R      0x1
  LOAD           0x0000000000001000 0x0000000080200000 0x0000000080200000
                 0x00000000000001d1 0x00000000000001d1  R E    0x1000
  LOAD           0x00000000000011d1 0x00000000802001d1 0x00000000802001d1
                 0x0000000000000e37 0x0000000000000e37  RW     0x1000
  LOAD           0x0000000000000120 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000         0x1000

The current logic does not check for this condition, resulting in
the incorrect assignment of 'lowaddr' as zero.

There is already a piece of codes inside the segment traversal loop
that checks for zero-sized loadable segments for not creating empty
ROM blobs. Let's move this check to the beginning of the loop to
cover both scenarios.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20240116155049.390301-1-bmeng@tinylab.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'cpu-target.c')
0 files changed, 0 insertions, 0 deletions