From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31169 invoked by alias); 3 Aug 2007 00:13:17 -0000 Received: (qmail 31149 invoked by uid 22791); 3 Aug 2007 00:13:12 -0000 X-Spam-Check-By: sourceware.org Received: from omta03sl.mx.bigpond.com (HELO omta03sl.mx.bigpond.com) (144.140.92.155) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 03 Aug 2007 00:13:05 +0000 Received: from oaamta03sl.mx.bigpond.com ([58.174.193.87]) by omta03sl.mx.bigpond.com with ESMTP id <20070803001302.HBVY12810.omta03sl.mx.bigpond.com@oaamta03sl.mx.bigpond.com>; Fri, 3 Aug 2007 00:13:02 +0000 Received: from bubble.grove.modra.org ([58.174.193.87]) by oaamta03sl.mx.bigpond.com with ESMTP id <20070803001301.DTNC24129.oaamta03sl.mx.bigpond.com@bubble.grove.modra.org>; Fri, 3 Aug 2007 00:13:01 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 8AF692A37AC; Fri, 3 Aug 2007 09:43:01 +0930 (CST) Date: Fri, 03 Aug 2007 00:13:00 -0000 From: Alan Modra To: Jan Kratochvil , Roland McGrath , binutils@sources.redhat.com Subject: Re: [patch] bfd: Core files with p_filesz < p_memsz (build-id) Message-ID: <20070803001259.GA11213@bubble.grove.modra.org> Mail-Followup-To: Jan Kratochvil , Roland McGrath , binutils@sources.redhat.com References: <20070728191354.GA14892@host0.dyn.jankratochvil.net> <20070728201604.AEBDB4D058D@magilla.localdomain> <20070729165314.GA8906@host0.dyn.jankratochvil.net> <20070801130547.GN23966@bubble.grove.modra.org> <20070802200249.GA7696@caradoc.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070802200249.GA7696@caradoc.them.org> User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00044.txt.bz2 On Thu, Aug 02, 2007 at 04:02:49PM -0400, Daniel Jacobowitz wrote: > On Wed, Aug 01, 2007 at 10:35:47PM +0930, Alan Modra wrote: > > I think BFD is still doing the right thing. Please fix this in gdb. > > Could you elaborate? Consider a core with these headers: [snip] > So we report the BSS portion of an entirely BSS PT_LOAD as having size > zero (plus contents flag, bizarre). But the BSS portion of a partially > filled PT_LOAD is shown with size equal to its memory size. I don't > see why they should be inconsistent, and it makes handling this in GDB > a little awkward. Oh, I see. I was just looking at the split case. I'd say the non-split behaviour is a bug. A program header with p_filesz zero and p_memsz non-zero really ought to create a bfd section with size equal to p_memsz, without SEC_HAS_CONTENTS and SEC_LOAD. So I think we should apply the following, and possibly on top of this do something special for core files. Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.404 diff -u -p -w -r1.404 elf.c --- bfd/elf.c 1 Aug 2007 19:55:10 -0000 1.404 +++ bfd/elf.c 2 Aug 2007 23:58:56 -0000 @@ -2223,7 +2223,7 @@ _bfd_elf_new_section_hook (bfd *abfd, as for the single program segment. The first has the length specified by the file size of the segment, and the second has the length specified by the difference between the two sizes. In effect, the segment is split - into it's initialized and uninitialized parts. + into its initialized and uninitialized parts. */ @@ -2242,6 +2242,9 @@ _bfd_elf_make_section_from_phdr (bfd *ab split = ((hdr->p_memsz > 0) && (hdr->p_filesz > 0) && (hdr->p_memsz > hdr->p_filesz)); + + if (hdr->p_filesz > 0) + { sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : ""); len = strlen (namebuf) + 1; name = bfd_alloc (abfd, len); @@ -2272,10 +2275,11 @@ _bfd_elf_make_section_from_phdr (bfd *ab { newsect->flags |= SEC_READONLY; } + } - if (split) + if (hdr->p_memsz > hdr->p_filesz) { - sprintf (namebuf, "%s%db", typename, index); + sprintf (namebuf, "%s%d%s", typename, index, split ? "b" : ""); len = strlen (namebuf) + 1; name = bfd_alloc (abfd, len); if (!name) -- Alan Modra Australia Development Lab, IBM