From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6130 invoked by alias); 19 Nov 2006 04:05:52 -0000 Received: (qmail 6110 invoked from network); 19 Nov 2006 04:05:37 -0000 Received: from unknown (195.23.133.213) by sourceware.org with QMTP; 19 Nov 2006 04:05:37 -0000 Received: (qmail 23670 invoked from network); 19 Nov 2006 04:05:36 -0000 Received: from unknown (HELO mailfrt09.isp.novis.pt) ([195.23.133.201]) (envelope-sender ) by mailrly03.isp.novis.pt with compressed SMTP; 19 Nov 2006 04:05:36 -0000 Received: (qmail 502 invoked from network); 19 Nov 2006 04:05:35 -0000 Received: from unknown (HELO [127.0.0.1]) ([195.23.225.206]) (envelope-sender ) by mailfrt09.isp.novis.pt with SMTP; 19 Nov 2006 04:05:35 -0000 Message-ID: <455FD80D.4000006@portugalmail.pt> Date: Sun, 19 Nov 2006 04:05: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> <455D068D.4070507@portugalmail.pt> <455D0CA9.5040901@portugalmail.pt> <20061118235017.GA28256@nevyn.them.org> In-Reply-To: <20061118235017.GA28256@nevyn.them.org> Content-Type: multipart/mixed; boundary="------------070905000502070202060407" X-Antivirus: avast! (VPS 0649-1, 18-11-2006), Outbound message X-Antivirus-Status: Clean 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/msg00207.txt.bz2 This is a multi-part message in MIME format. --------------070905000502070202060407 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1586 Daniel Jacobowitz escreveu: > On Fri, Nov 17, 2006 at 01:13:14AM +0000, Pedro Alves wrote: > >> * symtab.h (prim_record_minimal_symbol_and_bfd_section): Declare. >> > > I don't think you need yet another variant of this function. Can't you > use prim_record_minimal_symbol_and_info? You're getting the section > from the cs, and there's cs_to_section, so you ought to have the > "section" integer available too. > > > You are right. My thinking was that prim_record_minimal_symbol will only pass .text .data or .bss section to prim_record_minimal_symbol_and_info, and the way you say, and in the patch attached, we are passing a wider range of values. I didn't want to change more than needed, but looking again, I don't think it harms in this case. The attached patch does that, and also, I took the opportunity to a little extra cleanup on coffread.c by making all minimal symbol creations through record_minimal_symbol. Cheers, Pedro Alves --- 2006-11-19 Pedro Alves * coffread.c (cs_to_bfd_section): New function. (cs_to_section): Use cs_to_bfd_section. (record_minimal_symbol): Take the coff_symbol* parameter instead of the symbol's name as a char*. Add 'int section' parameter. Call prim_record_minimal_symbol_and_info instead of prim_record_minimal_symbol_and_info. Change return type to struct minimal_symbol *. (coff_symtab_read): Adapt to new record_minimal_symbol's signature. Make all minimal symbol creations go through record_minimal_symbol. --------------070905000502070202060407 Content-Type: text/plain; name="patch6.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch6.diff" Content-length: 3341 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 19 Nov 2006 04:00:59 -0000 @@ -259,17 +259,25 @@ find_targ_sec (bfd *abfd, asection *sect *args->resultp = sect; } -/* Return the section number (SECT_OFF_*) that CS points to. */ -static int -cs_to_section (struct coff_symbol *cs, struct objfile *objfile) +/* 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; - int off = SECT_OFF_TEXT (objfile); args.targ_index = cs->c_secnum; args.resultp = § bfd_map_over_sections (objfile->obfd, find_targ_sec, &args); + return sect; +} + +/* Return the section number (SECT_OFF_*) that CS points to. */ +static int +cs_to_section (struct coff_symbol *cs, struct objfile *objfile) +{ + asection *sect = cs_to_bfd_section (cs, objfile); + int off = SECT_OFF_TEXT (objfile); if (sect != NULL) { /* This is the section. Figure out what SECT_OFF_* code it is. */ @@ -408,15 +416,19 @@ coff_end_symtab (struct objfile *objfile last_source_file = NULL; } -static void -record_minimal_symbol (char *name, CORE_ADDR address, - enum minimal_symbol_type type, struct objfile *objfile) +static struct minimal_symbol * +record_minimal_symbol (struct coff_symbol* cs, CORE_ADDR address, + enum minimal_symbol_type type, int section, + struct objfile *objfile) { + struct bfd_section *bfd_section; /* We don't want TDESC entry points in the minimal symbol table */ - if (name[0] == '@') - return; + if (cs->c_name[0] == '@') + return NULL; - prim_record_minimal_symbol (name, address, type, objfile); + bfd_section = cs_to_bfd_section (cs, objfile); + return prim_record_minimal_symbol_and_info (cs->c_name, address, type, + NULL, section, bfd_section, objfile); } /* coff_symfile_init () @@ -762,8 +774,9 @@ coff_symtab_read (long symtab_offset, un if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF) { /* Record all functions -- external and static -- in minsyms. */ + int section = cs_to_section (cs, objfile); tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); - record_minimal_symbol (cs->c_name, tmpaddr, mst_text, objfile); + record_minimal_symbol (cs, tmpaddr, mst_text, section, objfile); fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; fcn_start_addr = tmpaddr; @@ -923,15 +936,13 @@ coff_symtab_read (long symtab_offset, un ms_type = mst_unknown; } - if (cs->c_name[0] != '@' /* Skip tdesc symbols */ ) - { - struct minimal_symbol *msym; - msym = prim_record_minimal_symbol_and_info - (cs->c_name, tmpaddr, ms_type, NULL, - sec, NULL, objfile); - if (msym) - COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym); - } + { + struct minimal_symbol *msym; + msym = record_minimal_symbol (cs, tmpaddr, ms_type, sec, objfile); + if (msym) + COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym); + } + if (SDB_TYPE (cs->c_type)) { struct symbol *sym; --------------070905000502070202060407--