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] (try #2) cleanup section_addr_info struct



Same as http://sourceware.cygnus.com/ml/gdb-patches/2000-04/msg00280.html

except for a change in symfile.c

Elena

2000-04-13  Elena Zannoni  <ezannoni@kwikemart.cygnus.com>

        * symfile.h (struct section_addr_info ): Remove fields for special
        treatment of .text, .data and .bss sections.

        * solib.c (symbol_add_stub): The special field text_addr is not
        available anymore. Search for the .text field the hard way.

        * symfile.c (build_section_addr_info_from_section_table): Don't
        fill in {text, data, bss}_addr any more.
        (default_symfile_offsets): Don't use {text, data, bss}_addr fields
        to fill in section_offsets for objfile.
        (syms_from_objfile): Don't deal with {text, data, bss}_addr as a
        special case anymore.
        (add_symbol_file_command): Ditto.


Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.2
diff -c -u -p -r1.2 symfile.h
cvs server: conflicting specifications of output style
--- symfile.h   2000/03/21 22:37:42     1.2
+++ symfile.h   2000/04/13 21:43:18
@@ -64,10 +64,6 @@ struct psymbol_allocation_list
 #define MAX_SECTIONS 40
 struct section_addr_info 
 {
-  /* Sections whose names are always known to gdb. */
-  CORE_ADDR text_addr;
-  CORE_ADDR data_addr;
-  CORE_ADDR bss_addr;
   /* Sections whose names are file format dependant. */
   struct other_sections
   {


Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.10
diff -c -u -p -r1.10 solib.c
cvs server: conflicting specifications of output style
--- solib.c     2000/04/05 20:40:22     1.10
+++ solib.c     2000/04/13 21:46:32
@@ -1155,6 +1155,8 @@ symbol_add_stub (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)
@@ -1183,7 +1185,14 @@ symbol_add_stub (arg)
 
   sap = build_section_addr_info_from_section_table (so->sections,
                                                     so->sections_end);
-  sap->text_addr = text_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);


symfile.c
---------

--- symfile.patch1.5.c	Thu Apr 13 20:51:11 2000
+++ symfile.c	Fri Apr 14 12:01:23 2000
@@ -478,13 +478,6 @@ build_section_addr_info_from_section_tab
 
   for (stp = start, oidx = 0; stp != end; stp++)
     {
-      if (strcmp (stp->the_bfd_section->name, ".text") == 0)
-	sap->text_addr = stp->addr;
-      else if (strcmp (stp->the_bfd_section->name, ".data") == 0)
-	sap->data_addr = stp->addr;
-      else if (strcmp (stp->the_bfd_section->name, ".bss") == 0)
-	sap->bss_addr = stp->addr;
-
       if (stp->the_bfd_section->flags & (SEC_ALLOC | SEC_LOAD)
 	  && oidx < MAX_SECTIONS)
 	{
@@ -531,15 +524,6 @@ default_symfile_offsets (objfile, addrs)
     obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
   memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS);
 
-  /* If user explicitly specified values for data and bss, set them here. */
-  
-  if (addrs->text_addr)
-    ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT) = addrs->text_addr;
-  if (addrs->data_addr)
-    ANOFFSET (objfile->section_offsets, SECT_OFF_DATA) = addrs->data_addr;
-  if (addrs->bss_addr)
-    ANOFFSET (objfile->section_offsets, SECT_OFF_BSS)  = addrs->bss_addr;
-    
   /* Now calculate offsets for other sections. */
   for (i = 0; i < MAX_SECTIONS && addrs->other[i].name; i++)
     {
@@ -635,14 +619,7 @@ syms_from_objfile (objfile, addrs, mainl
 
      We no longer warn if the lowest section is not a text segment (as
      happens for the PA64 port.  */
-  if (mainline)
-    {
-      /* No offset from objfile addresses.  */
-      addrs -> text_addr = 0;
-      addrs -> data_addr = 0;
-      addrs -> bss_addr = 0;
-    }
-  else
+  if (!mainline)
     {
       /* Find lowest loadable section to be used as starting point for 
          continguous sections. FIXME!! won't work without call to find
@@ -675,57 +652,17 @@ syms_from_objfile (objfile, addrs, mainl
  	 (the loadable section directly below it in memory).
  	 this_offset = lower_offset = lower_addr - lower_orig_addr */
 
-      /* FIXME: These sections will not need special treatment because ALL
-	 sections are in the other sections table */
- 
-      if (addrs->text_addr != 0)
- 	{
- 	  sect = bfd_get_section_by_name (objfile->obfd, ".text");
- 	  if (sect)
- 	    {
- 	      addrs->text_addr -= bfd_section_vma (objfile->obfd, sect);
- 	      lower_offset = addrs->text_addr;
- 	    }
- 	}
-      else 
- 	/* ??? who's below me? */
-	addrs->text_addr = lower_offset;
- 
-      if (addrs->data_addr != 0)
-	{
-	  sect = bfd_get_section_by_name (objfile->obfd, ".data");
-	  if (sect)
- 	    {
-	      addrs->data_addr -= bfd_section_vma (objfile->obfd, sect);
- 	      lower_offset = addrs->data_addr;
- 	    }
-	}
-      else
-	addrs->data_addr = lower_offset;
- 
-      if (addrs->bss_addr != 0)
-	{
-	  sect = bfd_get_section_by_name (objfile->obfd, ".bss");
-	  if (sect)
- 	    {
-	      addrs->bss_addr -= bfd_section_vma (objfile->obfd, sect);
- 	      lower_offset = addrs->bss_addr;
- 	    }
-	}
-      else
-	addrs->bss_addr = lower_offset;
-  
-       /* Now calculate offsets for other sections. */
+       /* Calculate offsets for sections. */
       for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++)
 	{
-	 
- 	  if (addrs->other[i].addr != 0)
+	  if (addrs->other[i].addr != 0)
  	    {
- 	      sect=bfd_get_section_by_name(objfile->obfd, addrs->other[i].name);
+ 	      sect = bfd_get_section_by_name (objfile->obfd, addrs->other[i].name);
  	      if (sect)
  		{
  		  addrs->other[i].addr -= bfd_section_vma (objfile->obfd, sect);
  		  lower_offset = addrs->other[i].addr;
+		  /* This is the index used by BFD. */
 		  addrs->other[i].sectindex = sect->index ;
  		}
  	      else
@@ -782,13 +719,6 @@ syms_from_objfile (objfile, addrs, mainl
 	  CORE_ADDR s_addr = 0;
 	  int i;
 
- 	  if (strcmp (s->the_bfd_section->name, ".text") == 0)
- 	    s_addr = addrs->text_addr;
- 	  else if (strcmp (s->the_bfd_section->name, ".data") == 0)
- 	    s_addr = addrs->data_addr;
- 	  else if (strcmp (s->the_bfd_section->name, ".bss") == 0)
- 	    s_addr = addrs->bss_addr;
- 	  else 
  	    for (i = 0; 
 	         !s_addr && i < MAX_SECTIONS && addrs->other[i].name;
 		 i++)
@@ -1617,15 +1547,6 @@ add_symbol_file_command (args, from_tty)
 	addr = strtoul (val+2, NULL, 16);
       else
 	addr = strtoul (val, NULL, 10);
-
-      if (strcmp (sec, ".text") == 0)
-	section_addrs.text_addr = addr;
-      else 
-	if (strcmp (sec, ".data") == 0)
-	  section_addrs.data_addr = addr;
-	else 
-	  if (strcmp (sec, ".bss") == 0)
-	    section_addrs.bss_addr = addr;
 
       /* Here we store the section offsets in the order they were
          entered on the command line. */

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