This is the mail archive of the gdb@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]

Re: Trunk GDB dumps core in solib.c:symbol_add_stub



Ah, sorry about that. Thanks for catching it.
I am afraid then that other solib type files may have the same problem.
I'll take a look.


 > 
 > The patch below gets rid of the core dump, but I am not sure if it
 > does the right thing (don't we have to consider the lowest section ?).
 > 
 > --- gdb/solib.c.orig	Thu Apr 20 17:36:56 2000
 > +++ gdb/solib.c	Sun Apr 30 12:14:52 2000
 > @@ -1188,11 +1188,15 @@ symbol_add_stub (arg)
 >  
 >    /* 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;
 > +  if (text_section != NULL)
 > +    {
 > +      for (i = 0; i < MAX_SECTIONS && sap->other[i].name; i++)
 > +	if (sap->other[i].sectindex == text_section->index)
 > +	  break;
 > +
 > +      if (i < MAX_SECTIONS)
 > +	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);
 > 

You are right. If lowest_sect is not .text that won't work.  How about
this? All we really need to do is keep track of the index of the
lowest section, and change the offset address for that section only,
right?  The real problem is that I don't quite understand what
syms_from_objfile does with lower_offset. The comments in there are
confusing.

Elena

Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.11
diff -c -r1.11 solib.c
*** solib.c	2000/04/17 16:09:04	1.11
--- solib.c	2000/05/02 15:55:07
***************
*** 1153,1162 ****
       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;
  
    /* Have we already loaded this shared object?  */
    ALL_OBJFILES (so->objfile)
--- 1153,1162 ----
       PTR arg;
  {
    register struct so_list *so = (struct so_list *) arg;  /* catch_errs bogon */
    struct section_addr_info *sap;
!   CORE_ADDR lowest_addr = 0;
!   int lowest_index;
!   asection *lowest_sect = NULL;
  
    /* Have we already loaded this shared object?  */
    ALL_OBJFILES (so->objfile)
***************
*** 1167,1198 ****
  
    /* Find the shared object's text segment.  */
    if (so->textsection)
!     text_addr = so->textsection->addr;
    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.  */
        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);
      }
  
    sap = build_section_addr_info_from_section_table (so->sections,
                                                      so->sections_end);
  
-   /* 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);
--- 1167,1199 ----
  
    /* Find the shared object's text segment.  */
    if (so->textsection)
!     {
!       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)
      {
!       /* 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)
! 	{
! 	  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;
  
    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]