On Wed, 2018-09-12 at 15:02 +0200, Mark Wielaard wrote: > When ELF_C_RDWR_MMAP is used libelf might have to write overlapping memory > when moving the section data or headers. Make sure to use memmove, not > memcpy. Also the size of the underlying file might have to change. That > means we will have to also extend the mmap region with mremap. Since we > are using direct pointers into the mmapped area we cannot move the mmap, > only extend it. This might still fail if there is not enough free memory > available to extend the mmap region. > > Two new test programs have been added. elfcopy which copies a whole elf > file (using either ELF_C_WRITE or ELF_C_WRITE_MMAP). And addsections which > adds new sections to an existing ELF file (using either ELF_C_RDWR or > ELF_C_RDWR_MMAP). The newly added test will fail under valgrind without > the fixes.
Pushed to master.