On Thu, Jun 23, 2016 at 05:31:59PM +0200, John Ogness wrote:
The situation occurs when adding sections to an existing ELF file
has none. You can see that in:
When an ELF file is opened with ELF_C_RDWR or ELF_C_RDWR_MMAP, scnmax is
set to 1. That leads to the first section being placed on the second
section list when elf_newscn() is called.
Below is a relatively simple program to demonstrate this.
Thanks. None of our existing tests cover this. So I adapted one of them
and created a testcase that fails before your fix and succeeds after.
It does the same test for all combinations of ELF class 32/64 and
ELF_C_RDWR[_MMAP] to make sure all different code paths are hit.
I also added a ChangeLog entry.