Adding a new section to an ELF file aborts with Assertion `shdr != NULL'

Alexander Egorenkov egorenar-dev@posteo.net
Sat Sep 4 08:38:51 GMT 2021


Hi all,

i'm facing an issue with libelf when i try to add a new section to an
ELF file.

How to reproduce the issue:
1. Create a simple ELF file with libelf containing only 2 sections, NULL and
a string table
2. Close ELF file
3. Reopen the new ELF file in RW mode with libelf
4. Add new section with elf_newscn()
5. Update ELF with elf_update()
6. Assertion appears

The weird thing is that if i add only a new program segment then
everything goes well. But as soon as i add a new section, it fails.

Error message:

test: elf32_updatenull.c:214: __elf64_updatenull_wrlock: Assertion `shdr
!= NULL' failed.

Any hint what i'm doing wrong ? 

Thank you
Regards
Alex


More information about the Elfutils-devel mailing list