From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31976 invoked by alias); 17 Nov 2006 00:47:34 -0000 Received: (qmail 31935 invoked from network); 17 Nov 2006 00:47:16 -0000 Received: from unknown (195.23.133.213) by sourceware.org with QMTP; 17 Nov 2006 00:47:16 -0000 Received: (qmail 6573 invoked from network); 17 Nov 2006 00:47:16 -0000 Received: from unknown (HELO mailfrt08.isp.novis.pt) ([195.23.133.200]) (envelope-sender ) by mailrly03.isp.novis.pt with compressed SMTP; 17 Nov 2006 00:47:16 -0000 Received: (qmail 13568 invoked from network); 17 Nov 2006 00:47:15 -0000 Received: from unknown (HELO [192.168.0.35]) ([195.23.225.143]) (envelope-sender ) by mailfrt08.isp.novis.pt with SMTP; 17 Nov 2006 00:47:15 -0000 Message-ID: <455D068D.4070507@portugalmail.pt> Date: Fri, 17 Nov 2006 00:47:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Thunderbird/1.5.0.8 Mnenhy/0.7.4.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: Crash in write_exp_msymbol for coff targets. References: <455CCFAD.6060407@portugalmail.pt> <20061116210236.GA25020@nevyn.them.org> <455CF6BA.2030306@portugalmail.pt> <20061116235909.GA32450@nevyn.them.org> In-Reply-To: <20061116235909.GA32450@nevyn.them.org> Content-Type: multipart/mixed; boundary="------------050008040602040607070707" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00157.txt.bz2 This is a multi-part message in MIME format. --------------050008040602040607070707 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1342 Daniel Jacobowitz wrote: > On Thu, Nov 16, 2006 at 11:39:38PM +0000, Pedro Alves wrote: > >> Like in the attached patch1.diff? >> >> Or, it isn't safe to index the objfile->sections by section index, >> and we have to look them up linearly? That is what patch2.diff does. >> In that version, I've repeated the search on coffread.c, caching the last >> section looked up. Only slightly tested, but I got around around 50% cache >> hit on a few exes. (Premature optimization?) >> > > I'm somewhat worried about the numbering :-( It looks like "int section" > is only useful for ANOFFSET / struct section_offsets. And that > suggests there's no useful way to get from those numbers to the > bfd_section or vice versa. What an awful mess. > > I see. What about this? (Attached) 2006-11-16 Pedro Alves * coffread.c (cs_to_bfd_section): New function. (coff_symtab_read): Use cs_to_bfd_section. cs_to_section could be then converted to bfd_section_to_section. > I suppose the only way to fix this will be to overhaul the associated > code and reduce the number of numberings in use. But in the mean time, > we should use your original patch that checked for non-NULL. Sorry > for the runaround. > > No prob. > Shall I commit it for you? > > Yes please, no write access. Cheers, Pedro Alves --------------050008040602040607070707 Content-Type: text/plain; name="patch3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch3.diff" Content-length: 1295 Index: coffread.c =================================================================== RCS file: /cvs/src/src/gdb/coffread.c,v retrieving revision 1.63 diff -u -p -r1.63 coffread.c --- coffread.c 17 Dec 2005 22:33:59 -0000 1.63 +++ coffread.c 17 Nov 2006 00:45:46 -0000 @@ -284,6 +284,19 @@ cs_to_section (struct coff_symbol *cs, s return off; } +/* Return the bfd_section that CS points to. */ +static struct bfd_section* +cs_to_bfd_section (struct coff_symbol *cs, struct objfile *objfile) +{ + asection *sect = NULL; + struct find_targ_sec_arg args; + + args.targ_index = cs->c_secnum; + args.resultp = § + bfd_map_over_sections (objfile->obfd, find_targ_sec, &args); + return sect; +} + /* Return the address of the section of a COFF symbol. */ static CORE_ADDR cs_section_address (struct coff_symbol *, bfd *); @@ -926,9 +939,10 @@ coff_symtab_read (long symtab_offset, un if (cs->c_name[0] != '@' /* Skip tdesc symbols */ ) { struct minimal_symbol *msym; + struct bfd_section *bfd_section = cs_to_bfd_section (cs, objfile); msym = prim_record_minimal_symbol_and_info (cs->c_name, tmpaddr, ms_type, NULL, - sec, NULL, objfile); + sec, bfd_section, objfile); if (msym) COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym); } --------------050008040602040607070707--