]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: Mark shdr_flags dirty if offset or size changes during update.
authorMark Wielaard <mark@klomp.org>
Sat, 11 May 2019 22:37:45 +0000 (00:37 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 16 May 2019 15:57:41 +0000 (17:57 +0200)
commitd7193bd7c9dc2a979352eee7fc446dacd3e97779
tree3fbc54875c7c3a378d096a2689f4a19436e0bd2d
parenta117891a00507d188fdab415bd25554ace9ed7ba
libelf: Mark shdr_flags dirty if offset or size changes during update.

We forgot to mark the shdr_flags dirty when only the sh_size or
sh_offset changed during elf_update (). This meant that if there were
no other shdr changes we only wrote out the section data, but didn't
write out the shdr table to the file.

Add a testcase that puts some sections in the reverse order and then
writes out the resulting file again without doing any other
updates. This would show the issue after write out of the
(re-reversed) ELF file (the .shstrtab section offset would be wrong
causing all section names to be garbage). Also run a self test.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/ChangeLog
libelf/elf32_updatenull.c
tests/ChangeLog
tests/Makefile.am
tests/elfcopy.c
tests/elfrdwrnop.c [new file with mode: 0644]
tests/run-reverse-sections-self.sh [new file with mode: 0755]
tests/run-reverse-sections.sh [new file with mode: 0755]