]> Git Repo - qemu.git/commit - linux-user/elfload.c
linux-user: Fix loading of BSS segments
authorGiuseppe Musacchio <[email protected]>
Thu, 17 Dec 2020 10:17:40 +0000 (11:17 +0100)
committerLaurent Vivier <[email protected]>
Sat, 13 Feb 2021 21:50:49 +0000 (22:50 +0100)
commit22d113b52f410d345c3a50a00d2eafa64138e427
tree78b5d779be24a65456845042bc319252de3d7f03
parent78721301138114cf37fb179a6cf73a27c1b3a927
linux-user: Fix loading of BSS segments

Some ELF binaries encode the .bss section as an extension of the data
ones by setting the segment p_memsz > p_filesz. Some other binaries take
a different route and encode it as a stand-alone PT_LOAD segment with
p_filesz = 0 and p_memsz > 0.

Both the encodings are actually correct per ELF specification but the
ELF loader had some troubles in handling the former: with the old logic
it was very likely to get Qemu to crash in zero_bss when trying to
access unmapped memory.

zero_bss isn't meant to allocate whole zero-filled segments but to
"complete" a previously mapped segment with the needed zero bits.

The fix is pretty simple, if the segment is completely zero-filled we
simply allocate one or more pages (according to p_memsz) and avoid
calling zero_bss altogether.

Signed-off-by: Giuseppe Musacchio <[email protected]>
Message-Id: <c9106487-dc4d-120a-bd48-665b3c617287@gmail.com>
Signed-off-by: Laurent Vivier <[email protected]>
linux-user/elfload.c
This page took 0.02502 seconds and 4 git commands to generate.