Sometimes ELF files have segments in them which are marked as loadable,
but which actually have zero size in memory. When setting up a memory
image we should drop those to avoid confusing other code which tries
to find the footprint of a memory image. No part of these segments,
including their starting address or ending address, need to actually
land on top of memory since they don't actually contain any data.
Change-Id: If8b61d10db139e0f688b6ceabcb8e6a898557469
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35156
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
{
auto name = std::to_string(seg_num);
+ if (phdr.p_memsz == 0) {
+ warn("Ignoring empty loadable segment %s", name);
+ return;
+ }
+
image.addSegment({ name, phdr.p_paddr, imageData,
phdr.p_offset, phdr.p_filesz });
Addr uninitialized = phdr.p_memsz - phdr.p_filesz;