This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] solib.c, symbol_add_stub()



This patch gets rid of a core dump (reported by Peter Schauer) if
there is no .text section in a shared library.

Will commit tomorrow if there are no objections.


2000-05-09  Elena Zannoni  <ezannoni@kwikemart.cygnus.com>

	* solib.c (symbol_add_stub): Remember the index and the name of
 	the section with the lowest address. Use this data (instead of
 	data from .text) to pass info into symbol_file_add.

Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.12
diff -p -u -r1.12 solib.c
--- solib.c	2000/05/05 18:14:27	1.12
+++ solib.c	2000/05/09 22:19:37
@@ -1165,10 +1165,10 @@ symbol_add_stub (arg)
      PTR arg;
 {
   register struct so_list *so = (struct so_list *) arg;  /* catch_errs bogon */
-  CORE_ADDR text_addr = 0;
   struct section_addr_info *sap;
-  int i;
-  asection *text_section;
+  CORE_ADDR lowest_addr = 0;
+  int lowest_index;
+  asection *lowest_sect = NULL;
 
   /* Have we already loaded this shared object?  */
   ALL_OBJFILES (so->objfile)
@@ -1179,32 +1179,33 @@ symbol_add_stub (arg)
 
   /* Find the shared object's text segment.  */
   if (so->textsection)
-    text_addr = so->textsection->addr;
+    {
+      lowest_addr = so->textsection->addr;
+      lowest_sect = bfd_get_section_by_name (so->abfd, ".text");
+      lowest_index = lowest_sect->index;
+    }
   else if (so->abfd != NULL)
     {
-      asection *lowest_sect;
-
-      /* If we didn't find a mapped non zero sized .text section, set up
-         text_addr so that the relocation in symbol_file_add does no harm.  */
+      /* If we didn't find a mapped non zero sized .text section, set
+         up lowest_addr so that the relocation in symbol_file_add does
+         no harm.  */
       lowest_sect = bfd_get_section_by_name (so->abfd, ".text");
       if (lowest_sect == NULL)
 	bfd_map_over_sections (so->abfd, find_lowest_section,
 			       (PTR) &lowest_sect);
       if (lowest_sect)
-	text_addr = bfd_section_vma (so->abfd, lowest_sect)
-	  + LM_ADDR (so);
+	{
+	  lowest_addr = bfd_section_vma (so->abfd, lowest_sect)
+	    + LM_ADDR (so);
+	  lowest_index = lowest_sect->index;
+	}
     }
 
   sap = build_section_addr_info_from_section_table (so->sections,
                                                     so->sections_end);
+
+  sap->other[lowest_index].addr = lowest_addr;
 
-  /* Look for the index for the .text section in the sap structure. */
-  text_section = bfd_get_section_by_name (so->abfd, ".text");
-  for (i = 0; i < MAX_SECTIONS && sap->other[i].name; i++)
-    if (sap->other[i].sectindex == text_section->index)
-      break;
-  
-  sap->other[i].addr = text_addr;
   so->objfile = symbol_file_add (so->so_name, so->from_tty,
 				 sap, 0, OBJF_SHARED);
   free_section_addr_info (sap);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]