* Adding a new section to an ELF file aborts with Assertion `shdr != NULL'
@ 2021-09-04 8:38 Alexander Egorenkov
2021-09-04 9:13 ` Alexander Egorenkov
2021-09-08 21:29 ` Mark Wielaard
0 siblings, 2 replies; 3+ messages in thread
From: Alexander Egorenkov @ 2021-09-04 8:38 UTC (permalink / raw)
To: elfutils-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Adding a new section to an ELF file aborts with Assertion `shdr != NULL'
2021-09-04 8:38 Adding a new section to an ELF file aborts with Assertion `shdr != NULL' Alexander Egorenkov
@ 2021-09-04 9:13 ` Alexander Egorenkov
2021-09-08 21:29 ` Mark Wielaard
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Egorenkov @ 2021-09-04 9:13 UTC (permalink / raw)
To: Alexander Egorenkov, elfutils-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Adding a new section to an ELF file aborts with Assertion `shdr != NULL'
2021-09-04 8:38 Adding a new section to an ELF file aborts with Assertion `shdr != NULL' Alexander Egorenkov
2021-09-04 9:13 ` Alexander Egorenkov
@ 2021-09-08 21:29 ` Mark Wielaard
1 sibling, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2021-09-08 21:29 UTC (permalink / raw)
To: Alexander Egorenkov; +Cc: elfutils-devel
Hi Alex,
On Sat, Sep 04, 2021 at 08:38:51AM +0000, Alexander Egorenkov via Elfutils-devel wrote:
> 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 ?
I don't immediately know. Could you post the code you are using and/or
the generated file after step 2? That might make it a bit easier to
see exactly what is going on.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-08 21:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04 8:38 Adding a new section to an ELF file aborts with Assertion `shdr != NULL' Alexander Egorenkov
2021-09-04 9:13 ` Alexander Egorenkov
2021-09-08 21:29 ` Mark Wielaard
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).