From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 0E65E3858CDB; Thu, 13 Jul 2023 21:58:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E65E3858CDB 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: by gnu.wildebeest.org (Postfix, from userid 1000) id BD24B30003A9; Thu, 13 Jul 2023 23:58:08 +0200 (CEST) Date: Thu, 13 Jul 2023 23:58:08 +0200 From: Mark Wielaard To: Alan Modra Cc: Simon Marchi , "H.J. Lu" , binutils@sourceware.org, Florian Weimer , Kaylee Blake , "gdb-patches@sourceware.org" , Ryan Goldberg , Matthias Klose , nickc@redhat.com Subject: Re: [PATCH v4 3/7] bfd: Improve nm and objdump without section header Message-ID: <20230713215808.GA11829@gnu.wildebeest.org> References: <20230606175846.399377-1-hjl.tools@gmail.com> <20230606175846.399377-4-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-3029.4 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, On Thu, Jul 13, 2023 at 02:32:25PM +0930, Alan Modra via Binutils wrote: > > So, the program header of the .debug file describes the segments of the > > main binary, not sure if that's expected. > > No, that's not expected. Program headers in a .debug file ought to > describe the contents of the debug file. You'll typically see many > with p_filesz zero. eu-strip appears to be broken in this respect. It is by design that eu-strip -f copies over the program headers of the main file into the .debug file. It would be nice to tag .debug files as such, to prevent issues like this. There is a binutils bug about it: https://sourceware.org/bugzilla/show_bug.cgi?id=22136 > There is another problem with the code added to elf_object_p: > _bfd_elf_get_dynamic_symbols is told that it can access up to e_phnum > program headers, but they very likely haven't all been swapped in. > > I'm going to apply the following patch. > > ---- > > elf_object_p load of dynamic symbols > > This fixes an uninitialised memory access on a fuzzed file: > 0 0xf22e9b in offset_from_vma /src/binutils-gdb/bfd/elf.c:1899:2 > 1 0xf1e90f in _bfd_elf_get_dynamic_symbols /src/binutils-gdb/bfd/elf.c:2099:13 > 2 0x10e6a54 in bfd_elf32_object_p /src/binutils-gdb/bfd/elfcode.h:851:9 > > Hopefully it will also stop any attempt to load dynamic symbols from > eu-strip debug files. > > * elfcode.h (elf_object_p): Do not attempt to load dynamic > symbols for a file with no section headers until all the > program headers are swapped in. Do not fail on eu-strip debug > files. Thanks! This does resolves an elfutils/debuginfod issue Ryan and I were tracking down on debian-testing with using binutils objcopy extracting sections from a .debug file. Debian testing ships with binutils 2.40.90.20230705. If possible could this go into 2.41 (and in an update for Debian testing)? Thanks, Mark