From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27463 invoked by alias); 1 Aug 2007 16:22:15 -0000 Received: (qmail 27449 invoked by uid 22791); 1 Aug 2007 16:22:13 -0000 X-Spam-Check-By: sourceware.org Received: from pauline.vellum.cz (HELO pauline.vellum.cz) (89.250.243.234) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 01 Aug 2007 16:22:06 +0000 Received: from host0.dyn.jankratochvil.net (localhost.localdomain [127.0.0.1]) by pauline.vellum.cz (8.12.11.20060308/8.12.11) with ESMTP id l71GM262024936 for ; Wed, 1 Aug 2007 18:22:03 +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 l71GM2Zs011313 for ; Wed, 1 Aug 2007 18:22:02 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.1/8.14.1/Submit) id l71GM2ik011312 for gdb-patches@sourceware.org; Wed, 1 Aug 2007 18:22:02 +0200 Date: Wed, 01 Aug 2007 16:22:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Support core files with 0 < p_filesz < p_memsz (build-id) Message-ID: <20070801162202.GA11293@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline User-Agent: Mutt/1.5.14 (2007-02-12) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00009.txt.bz2 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2868 Hi, there is now a pending patch for Linux kernels producing core files with the first page of the ELF file for the build-id note identification (to find the original versions/builds of the binaries used to produce the core file). So far GDB handled either p_filesz == 0 or p_filesz == p_memsz. Patch handles the case 0 < p_filesz < p_memsz (p_filesz == PAGE_SIZE for the build-id case). `0 < p_filesz < p_memsz' meaning was so far undefined for the ET_CORE files. (Testsuite run verified.) The IMO more appropriate patch for BFD to flag the p_filesz..p_memsz part the same way as the former (0==p_filesz)..(p_memsz) core part has been rejected: http://sourceware.org/ml/binutils/2007-08/msg00013.html Referencing former BFD patch (where no GDB modifications were needed): http://sourceware.org/ml/binutils/2007-07/msg00520.html Regards, Jan New build-id enhanced Linux kernels produce core files: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align NOTE 0x000660 0x0000000000000000 0x0000000000000000 0x000324 0x000000 0x0 LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x001000 0x0b1000 R E 0x1000 ^^^^^^^^ ^^^^^^^^ LOAD 0x002000 0x00000000006b1000 0x0000000000000000 0x00a000 0x00a000 RW 0x1000 GDB-patched gdb `info files' 0x0000000000400000 - 0x0000000000401000 is load1a 0x00000000006b1000 - 0x00000000006bb000 is load2 0x0000000000419f00 : push %r15 0x0000000000419f02 : push %r14 BROKEN: original gdb `info files' (it sees the code sections zeroed) 0x0000000000400000 - 0x0000000000401000 is load1a 0x0000000000401000 - 0x00000000004b1000 is load1b ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0x00000000006b1000 - 0x00000000006bb000 is load2 0x0000000000419f00 : add %al,(%rax) 0x0000000000419f02 : add %al,(%rax) (as 0x419f00 >= 0x401000) Legacy kernel core files: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align NOTE 0x000660 0x0000000000000000 0x0000000000000000 0x000324 0x000000 0x0 LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x000000 0x0b1000 R E 0x1000 ^^^^^^^^ ^^^^^^^^ LOAD 0x001000 0x00000000006b1000 0x0000000000000000 0x00a000 0x00a000 RW 0x1000 original gdb `info files' # `load1' completely missing 0x00000000006b1000 - 0x00000000006bb000 is load2 0x0000000000419f00 : push %r15 0x0000000000419f02 : push %r14 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="gdb-cvs-build-id-core-load.patch" Content-length: 784 2007-08-01 Jan Kratochvil * exec.c (add_to_section_table): Ignore the BFD_CORE `loadXb' segments. --- ./gdb/exec.c 31 Jul 2007 21:49:21 -0000 1.67 +++ ./gdb/exec.c 1 Aug 2007 14:24:51 -0000 @@ -354,6 +354,13 @@ add_to_section_table (bfd *abfd, struct if (!(aflag & SEC_ALLOC)) return; + /* Core files with 0 < p_filesz < p_memsz have the p_filesz..p_memsz section + without these flags. It would be considered as .bss otherwise. It would + mask out the real EXEC_BFD loaded code by its zeroes. */ + if (bfd_get_format (abfd) == bfd_core + && !(aflag & (SEC_LOAD | SEC_HAS_CONTENTS))) + return; + (*table_pp)->bfd = abfd; (*table_pp)->the_bfd_section = asect; (*table_pp)->addr = bfd_section_vma (abfd, asect); --G4iJoqBmSsgzjUCe--