From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25151 invoked by alias); 19 Feb 2010 06:22:19 -0000 Received: (qmail 25124 invoked by uid 22791); 19 Feb 2010 06:22:18 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,FAKE_REPLY_C,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Feb 2010 06:22:13 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1J6Lof5031771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Feb 2010 01:21:50 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1J6LlrY012260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Feb 2010 01:21:49 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o1J6Lljj002897; Fri, 19 Feb 2010 07:21:47 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o1J6LkrN002895; Fri, 19 Feb 2010 07:21:46 +0100 Date: Fri, 19 Feb 2010 06:22:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org, Joel Brobecker Subject: Re: [patch] Fix crash on stale addrinfo->sectindex Message-ID: <20100219062146.GA2862@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2010-02/txt/msg00477.txt.bz2 On Fri, 19 Feb 2010 04:01:05 +0100, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil writes: > I think you ought to move this comment as well. > It appears to just be hanging at the end of a block after the patch. Yes; forgot. > This is ok with that change. Thanks. Checked-in. On Fri, 19 Feb 2010 04:10:30 +0100, Tom Tromey wrote: > Oh, by the way, I think this is reasonable for 7.1. It is > straightforward and fixes a reported crash. If Joel agrees, please put > it on the branch. Thanks. OK for the branch? Thanks, Jan http://sourceware.org/ml/gdb-cvs/2010-02/msg00162.html --- src/gdb/ChangeLog 2010/02/19 00:35:53 1.11380 +++ src/gdb/ChangeLog 2010/02/19 06:19:44 1.11381 @@ -1,3 +1,10 @@ +2010-02-19 Jan Kratochvil + + * symfile.c (addr_info_make_relative): Extend comment. Move SECT to + a more inner block. Initialize ADDR by LOWER_OFFSET only if it was + found by bfd_get_section_by_name. + * symfile.h (struct section_addr_info) : New comment. + 2010-02-19 Joel Brobecker * NEWS: Add new "[...] since 7.1" section. Rename the "[...] since --- src/gdb/symfile.c 2010/02/18 19:17:00 1.272 +++ src/gdb/symfile.c 2010/02/19 06:19:45 1.273 @@ -562,13 +562,13 @@ } /* Relativize absolute addresses in ADDRS into offsets based on ABFD. Fill-in - also SECTINDEXes there. */ + also SECTINDEXes specific to ABFD there. This function can be used to + rebase ADDRS to start referencing different BFD than before. */ void addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd) { asection *lower_sect; - asection *sect; CORE_ADDR lower_offset; int i; @@ -597,25 +597,29 @@ for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++) { - if (addrs->other[i].addr != 0) + asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name); + + if (sect) { - sect = bfd_get_section_by_name (abfd, addrs->other[i].name); - if (sect) + /* This is the index used by BFD. */ + addrs->other[i].sectindex = sect->index; + + if (addrs->other[i].addr != 0) { addrs->other[i].addr -= bfd_section_vma (abfd, sect); lower_offset = addrs->other[i].addr; - /* This is the index used by BFD. */ - addrs->other[i].sectindex = sect->index; } else - { - warning (_("section %s not found in %s"), addrs->other[i].name, - bfd_get_filename (abfd)); - addrs->other[i].addr = 0; - } + addrs->other[i].addr = lower_offset; } else - addrs->other[i].addr = lower_offset; + { + warning (_("section %s not found in %s"), addrs->other[i].name, + bfd_get_filename (abfd)); + addrs->other[i].addr = 0; + + /* SECTINDEX is invalid if ADDR is zero. */ + } } } --- src/gdb/symfile.h 2010/02/03 14:13:16 1.64 +++ src/gdb/symfile.h 2010/02/19 06:19:45 1.65 @@ -80,6 +80,8 @@ { CORE_ADDR addr; char *name; + + /* SECTINDEX must be valid for associated BFD if ADDR is not zero. */ int sectindex; } other[1]; };