From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 480F33857817 for ; Wed, 8 Sep 2021 21:29:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 480F33857817 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x11.wildebeest.org [172.31.17.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 3D7C8300BC88; Wed, 8 Sep 2021 23:29:33 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id C9A302E811C5; Wed, 8 Sep 2021 23:29:33 +0200 (CEST) Date: Wed, 8 Sep 2021 23:29:33 +0200 From: Mark Wielaard To: Alexander Egorenkov Cc: elfutils-devel@sourceware.org Subject: Re: Adding a new section to an ELF file aborts with Assertion `shdr != NULL' Message-ID: References: <87tuj020ro.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tuj020ro.fsf@posteo.net> X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2021 21:29:36 -0000 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