Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro_alves@portugalmail.pt>
To: Pedro Alves <pedro_alves@portugalmail.pt>
Cc: gdb-patches@sourceware.org
Subject: Re: Crash in write_exp_msymbol for coff targets.
Date: Fri, 17 Nov 2006 01:14:00 -0000	[thread overview]
Message-ID: <455D0CA9.5040901@portugalmail.pt> (raw)
In-Reply-To: <455D068D.4070507@portugalmail.pt>

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

Pedro Alves wrote: 
> I see. What about this? (Attached)
>
> 2006-11-16 Pedro Alves <pedro_alves@portugalmail.pt>
>
> * 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.

Humm, not complete. This should be:

2006-11-16 Pedro Alves <pedro_alves@portugalmail.pt>

* symtab.h (prim_record_minimal_symbol_and_bfd_section): Declare.
* minsyms.c (prim_record_minimal_symbol_and_bfd_section): Rename from 
prim_record_minimal_symbol
and add bfd_section parameter.
(prim_record_minimal_symbol): New version; wraps 
prim_record_minimal_symbol_and_bfd_section.
* coffread.c (cs_to_bfd_section): New function.
(coff_symtab_read): Use cs_to_bfd_section.

Cheers,
Pedro Alves


[-- Attachment #2: patch4.diff --]
[-- Type: text/plain, Size: 4526 bytes --]

Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.98
diff -u -p -r1.98 symtab.h
--- symtab.h	17 Oct 2006 20:17:45 -0000	1.98
+++ symtab.h	17 Nov 2006 01:12:14 -0000
@@ -1147,6 +1147,12 @@ extern struct minimal_symbol *prim_recor
    enum minimal_symbol_type,
    char *info, int section, asection * bfd_section, struct objfile *);
 
+extern void prim_record_minimal_symbol_and_bfd_section
+  (const char *name, CORE_ADDR address,
+   enum minimal_symbol_type ms_type,
+   asection *bfd_section,
+   struct objfile *objfile);
+
 extern unsigned int msymbol_hash_iw (const char *);
 
 extern unsigned int msymbol_hash (const char *);
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.47
diff -u -p -r1.47 minsyms.c
--- minsyms.c	17 Oct 2006 20:17:44 -0000	1.47
+++ minsyms.c	17 Nov 2006 01:12:15 -0000
@@ -605,8 +605,9 @@ init_minimal_symbol_collection (void)
 }
 
 void
-prim_record_minimal_symbol (const char *name, CORE_ADDR address,
+prim_record_minimal_symbol_and_bfd_section (const char *name, CORE_ADDR address,
 			    enum minimal_symbol_type ms_type,
+			    asection *bfd_section,
 			    struct objfile *objfile)
 {
   int section;
@@ -631,9 +632,18 @@ prim_record_minimal_symbol (const char *
     }
 
   prim_record_minimal_symbol_and_info (name, address, ms_type,
-				       NULL, section, NULL, objfile);
+				       NULL, section, bfd_section, objfile);
 }
 
+void
+prim_record_minimal_symbol (const char *name, CORE_ADDR address,
+                                        enum minimal_symbol_type ms_type,
+                                        struct objfile *objfile)
+{
+    prim_record_minimal_symbol_and_bfd_section (name, address, ms_type, NULL, objfile);
+}
+
+
 /* Record a minimal symbol in the msym bunches.  Returns the symbol
    newly created.  */
 
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 01:12:18 -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 = &sect;
+  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 *);
@@ -410,13 +423,14 @@ coff_end_symtab (struct objfile *objfile
 \f
 static void
 record_minimal_symbol (char *name, CORE_ADDR address,
-		       enum minimal_symbol_type type, struct objfile *objfile)
+		       enum minimal_symbol_type type, asection *bfd_section, 
+		       struct objfile *objfile)
 {
   /* We don't want TDESC entry points in the minimal symbol table */
   if (name[0] == '@')
     return;
 
-  prim_record_minimal_symbol (name, address, type, objfile);
+  prim_record_minimal_symbol_and_bfd_section (name, address, type, bfd_section, objfile);
 }
 \f
 /* coff_symfile_init ()
@@ -761,9 +775,11 @@ coff_symtab_read (long symtab_offset, un
       /* Typedefs should not be treated as symbol definitions.  */
       if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF)
 	{
+	  struct bfd_section *bfd_section = cs_to_bfd_section (cs, objfile);
+
 	  /* Record all functions -- external and static -- in minsyms. */
 	  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->c_name, tmpaddr, mst_text, bfd_section, objfile);
 
 	  fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
 	  fcn_start_addr = tmpaddr;
@@ -926,9 +942,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);
 	      }

  reply	other threads:[~2006-11-17  1:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-16 20:53 Pedro Alves
2006-11-16 21:02 ` Daniel Jacobowitz
2006-11-16 23:40   ` Pedro Alves
2006-11-16 23:59     ` Daniel Jacobowitz
2006-11-17  0:47       ` Pedro Alves
2006-11-17  1:14         ` Pedro Alves [this message]
2006-11-18  1:15           ` Pedro Alves
2006-11-18 23:50           ` Daniel Jacobowitz
2006-11-19  4:05             ` Pedro Alves
2006-11-28 17:07               ` Daniel Jacobowitz
2006-11-18 23:54 ` Daniel Jacobowitz
2006-11-22  0:06   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=455D0CA9.5040901@portugalmail.pt \
    --to=pedro_alves@portugalmail.pt \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox