]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: Don't extend ELF file size with SHT_NOBITS sh_offset.
authorMark Wielaard <mjw@redhat.com>
Mon, 23 Mar 2015 21:19:12 +0000 (22:19 +0100)
committerMark Wielaard <mjw@redhat.com>
Fri, 27 Mar 2015 22:04:34 +0000 (23:04 +0100)
commit5370bb0a6492cb4669c8375e53748a4303997ed7
treee476cc098d83be0417850ed8ac0bfb384d143e32
parentd4852fab1c8ed9ce1780815616abc596b19ac7d8
libelf: Don't extend ELF file size with SHT_NOBITS sh_offset.

Don't explicitly extend the file size for SHT_NOBITS sections. Since
that could cause a size beyond any actual file content it will cause
issues when the underlying ELF file has been mmapped or will extend
the file size to increase (writing fill bytes) when not mmapped. The
sh_offset value is essentially meaningless for SHT_NOBITS. gabi says
that a NOBITS section sh_offset member locates the "conceptual
placement" in the file. But it doesn't say this cannot be beyond the
enf of the file. When ELF_F_LAYOUT is set we should trust sh_offset
as given is what is wanted for an SHT_NOBITS section without extending
the file size.

https://bugzilla.redhat.com/show_bug.cgi?id=1020842

Buggy binutils ld could generate files where SHT_NOBITS sections have
sh_offset outside the file.
https://sourceware.org/bugzilla/show_bug.cgi?id=12921

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/elf32_updatenull.c