From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12527 invoked by alias); 29 Jul 2007 16:53:29 -0000 Received: (qmail 12519 invoked by uid 22791); 29 Jul 2007 16:53:28 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 29 Jul 2007 16:53:21 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.1/8.13.1) with ESMTP id l6TGrJQJ014127 for ; Sun, 29 Jul 2007 12:53:19 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l6TGrIYt021489; Sun, 29 Jul 2007 12:53:19 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.stuttgart.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id l6TGrGmj021832; Sun, 29 Jul 2007 18:53:17 +0200 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.1/8.13.8) with ESMTP id l6TGrG7n008998; Sun, 29 Jul 2007 18:53:16 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.1/8.14.1/Submit) id l6TGrFKJ008997; Sun, 29 Jul 2007 18:53:15 +0200 Date: Sun, 29 Jul 2007 18:32:00 -0000 From: Jan Kratochvil To: Roland McGrath Cc: binutils@sources.redhat.com Subject: Re: [patch] bfd: Core files with p_filesz < p_memsz (build-id) Message-ID: <20070729165314.GA8906@host0.dyn.jankratochvil.net> References: <20070728191354.GA14892@host0.dyn.jankratochvil.net> <20070728201604.AEBDB4D058D@magilla.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline In-Reply-To: <20070728201604.AEBDB4D058D@magilla.localdomain> User-Agent: Mutt/1.5.14 (2007-02-12) 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-07/txt/msg00522.txt.bz2 --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2072 On Sat, 28 Jul 2007 22:16:04 +0200, Roland McGrath wrote: > Are you sure that changing _bfd_elf_make_section_from_phdr is the right way > to fix gdb? > > It is in a certain sense accurate to split the one segment into two > sections, a leading SEC_LOAD one and a trailing one without SEC_LOAD. The core files with `p_filesz == 0' were working before. _bfd_elf_make_section_from_phdr() can create the sections as two parts, with the second problematic one emulating the former `p_filesz == 0' core segments. No new memory structure layout was introduced. [attached] Another issue would be changing the sections layout as currently the original p_memsz is still lost. Going to post later an add-on incompatible change using SEC_NEVER_LOAD so that the p_memsz is retained for the bfd library applications + across objcopy. > What does your change do to e.g. objcopy on a core file? (the previous version was stripping the `load1b' part), thanks for finding it. Best Regards, Jan Patched bfd version with the new `p_filesz == 4096' kernel core file: CVS HEAD gdb `info files': 0x0000000000400000 - 0x0000000000401000 is load1a 0x0000000000401000 - 0x0000000000401000 is load1b 0x00000000006b1000 - 0x00000000006bb000 is load2 objcopy: Section Headers: [Nr] Name Type Addr Off Size ES Flags Lk Inf Al [ 5] load1a PROGBITS 0000000000400000 00001000 00001000 0 AX 0 0 4096 [ 6] load1b PROGBITS 0000000000401000 00002000 00000000 0 AX 0 0 4096 [ 7] load2 PROGBITS 00000000006b1000 00002000 0000a000 0 WA 0 0 4096 Former bfd version with the former `p_filesz == 0' kernel core file: CVS HEAD gdb `info files': 0x0000000000400000 - 0x0000000000400000 is load1 0x00000000006b1000 - 0x00000000006bb000 is load2 objcopy: Section Headers: [ 5] load1 PROGBITS 0000000000400000 00001000 00000000 0 AX 0 0 4096 [ 6] load2 PROGBITS 00000000006b1000 00001000 0000a000 0 WA 0 0 4096 --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="bfd-dump_elf_headers.patch" Content-length: 1395 2007-07-29 Jan Kratochvil * bfd/elf.c (_bfd_elf_new_section_hook): New comment for ET_CORE files with p_filesz shorter than p_memsz. Behave for such split sections in a backward compatible way for both its parts. --- bfd/elf.c 26 Jul 2007 18:15:46 -0000 1.401 +++ bfd/elf.c 29 Jul 2007 13:46:21 -0000 @@ -2225,6 +2225,9 @@ _bfd_elf_new_section_hook (bfd *abfd, as by the difference between the two sizes. In effect, the segment is split into it's initialized and uninitialized parts. + This notion does not apply in ET_CORE files, where a shorter p_filesz means + that the data is not available in the dump. + */ bfd_boolean @@ -2286,10 +2289,20 @@ _bfd_elf_make_section_from_phdr (bfd *ab return FALSE; newsect->vma = hdr->p_vaddr + hdr->p_filesz; newsect->lma = hdr->p_paddr + hdr->p_filesz; - newsect->size = hdr->p_memsz - hdr->p_filesz; + if (abfd->format != bfd_core) + newsect->size = hdr->p_memsz - hdr->p_filesz; + else + { + newsect->size = 0; + newsect->filepos = hdr->p_offset; + newsect->flags |= SEC_HAS_CONTENTS; + newsect->alignment_power = bfd_log2 (hdr->p_align); + } if (hdr->p_type == PT_LOAD) { newsect->flags |= SEC_ALLOC; + if (abfd->format == bfd_core) + newsect->flags |= SEC_LOAD; if (hdr->p_flags & PF_X) newsect->flags |= SEC_CODE; } --dDRMvlgZJXvWKvBx--