From: Alexander Egorenkov <egorenar@posteo.net>
To: Alexander Egorenkov <egorenar-dev@posteo.net>,
elfutils-devel@sourceware.org
Subject: Re: Adding a new section to an ELF file aborts with Assertion `shdr != NULL'
Date: Sat, 04 Sep 2021 09:13:33 +0000 [thread overview]
Message-ID: <871r64snya.fsf@posteo.net> (raw)
In-Reply-To: <87tuj020ro.fsf@posteo.net>
Hi all,
Alexander Egorenkov <egorenar-dev@posteo.net> writes:
> 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 ?
>
One workaround i found is this:
scn = elf_getscn(elf, 0);
shdr = elf64_getshdr(scn);
It seems that __elf64_updatenull_wrlock() tries to access the section
header of the NULL section.
Regards
Alex
next prev parent reply other threads:[~2021-09-04 9:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-04 8:38 Alexander Egorenkov
2021-09-04 9:13 ` Alexander Egorenkov [this message]
2021-09-08 21:29 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871r64snya.fsf@posteo.net \
--to=egorenar@posteo.net \
--cc=egorenar-dev@posteo.net \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).