This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[8/10] RFC: remove the bfd_section argument from minsym creation


Now that we know that a minsym's section and its obj_section are
equivalent, we can dispense with the obj_section argument to minsym
creation.  This patch removes the argument and updates all the users.

Tom

	* coffread.c (record_minimal_symbol): Update.
	* dbxread.c (record_minimal_symbol): Update.
	* elfread.c (record_minimal_symbol): Update.
	* machoread.c (macho_symtab_add_minsym): Update.
	* mdebugread.c (record_minimal_symbol, parse_partial_symbols):
	Update.
	* minsyms.c (prim_record_minimal_symbol): Update.
	(prim_record_minimal_symbol_full): Remove 'bfd_section'
	argument.
	(prim_record_minimal_symbol_and_info): Likewise.
	* minsyms.h (prim_record_minimal_symbol_full)
	(prim_record_minimal_symbol_and_info): Update.
	* symtab.c (allocate_symbol, initialize_symbol)
	(allocate_template_symbol): Initialize SYMBOL_SECTION.
	* xcoffread.c (record_minimal_symbol, scan_xcoff_symtab):
	Update.
---
 gdb/coffread.c   |    6 +-----
 gdb/dbxread.c    |   13 +------------
 gdb/elfread.c    |    2 +-
 gdb/machoread.c  |    2 +-
 gdb/mdebugread.c |   21 ++-------------------
 gdb/minsyms.c    |   19 +++----------------
 gdb/minsyms.h    |    6 +-----
 gdb/somread.c    |    1 -
 gdb/xcoffread.c  |   10 ++--------
 9 files changed, 12 insertions(+), 68 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index f4bafb2..8992ddb 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -423,16 +423,12 @@ 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 (cs->c_name[0] == '@')
     return NULL;
 
-  bfd_section = cs_to_bfd_section (cs, objfile);
   return prim_record_minimal_symbol_and_info (cs->c_name, address,
-					      type, section,
-					      bfd_section, objfile);
+					      type, section, objfile);
 }
 
 /* coff_symfile_init ()
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 09b46a0..ff15484 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -440,35 +440,29 @@ record_minimal_symbol (char *name, CORE_ADDR address, int type,
 {
   enum minimal_symbol_type ms_type;
   int section;
-  asection *bfd_section;
 
   switch (type)
     {
     case N_TEXT | N_EXT:
       ms_type = mst_text;
       section = SECT_OFF_TEXT (objfile);
-      bfd_section = DBX_TEXT_SECTION (objfile);
       break;
     case N_DATA | N_EXT:
       ms_type = mst_data;
       section = SECT_OFF_DATA (objfile);
-      bfd_section = DBX_DATA_SECTION (objfile);
       break;
     case N_BSS | N_EXT:
       ms_type = mst_bss;
       section = SECT_OFF_BSS (objfile);
-      bfd_section = DBX_BSS_SECTION (objfile);
       break;
     case N_ABS | N_EXT:
       ms_type = mst_abs;
       section = -1;
-      bfd_section = NULL;
       break;
 #ifdef N_SETV
     case N_SETV | N_EXT:
       ms_type = mst_data;
       section = SECT_OFF_DATA (objfile);
-      bfd_section = DBX_DATA_SECTION (objfile);
       break;
     case N_SETV:
       /* I don't think this type actually exists; since a N_SETV is the result
@@ -476,7 +470,6 @@ record_minimal_symbol (char *name, CORE_ADDR address, int type,
          file local.  */
       ms_type = mst_file_data;
       section = SECT_OFF_DATA (objfile);
-      bfd_section = DBX_DATA_SECTION (objfile);
       break;
 #endif
     case N_TEXT:
@@ -485,7 +478,6 @@ record_minimal_symbol (char *name, CORE_ADDR address, int type,
     case N_FN_SEQ:
       ms_type = mst_file_text;
       section = SECT_OFF_TEXT (objfile);
-      bfd_section = DBX_TEXT_SECTION (objfile);
       break;
     case N_DATA:
       ms_type = mst_file_data;
@@ -507,17 +499,14 @@ record_minimal_symbol (char *name, CORE_ADDR address, int type,
 	  ms_type = mst_data;
       }
       section = SECT_OFF_DATA (objfile);
-      bfd_section = DBX_DATA_SECTION (objfile);
       break;
     case N_BSS:
       ms_type = mst_file_bss;
       section = SECT_OFF_BSS (objfile);
-      bfd_section = DBX_BSS_SECTION (objfile);
       break;
     default:
       ms_type = mst_unknown;
       section = -1;
-      bfd_section = NULL;
       break;
     }
 
@@ -526,7 +515,7 @@ record_minimal_symbol (char *name, CORE_ADDR address, int type,
     lowest_text_address = address;
 
   prim_record_minimal_symbol_and_info
-    (name, address, ms_type, section, bfd_section, objfile);
+    (name, address, ms_type, section, objfile);
 }
 
 /* Scan and build partial symbols for a symbol file.
diff --git a/gdb/elfread.c b/gdb/elfread.c
index dde21ef..c47b849 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -211,7 +211,7 @@ record_minimal_symbol (const char *name, int name_len, int copy_name,
 					  ms_type,
 					  gdb_bfd_section_index (objfile->obfd,
 								 bfd_section),
-					  bfd_section, objfile);
+					  objfile);
 }
 
 /* Read the symbol table of an ELF file.
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 8385484..41fc5ca 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -167,7 +167,7 @@ macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym)
       prim_record_minimal_symbol_and_info
         (sym->name, symaddr, ms_type,
 	 gdb_bfd_section_index (objfile->obfd, sym->section),
-	 sym->section, objfile);
+	 objfile);
     }
 }
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index e284942..705e742 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2256,74 +2256,59 @@ record_minimal_symbol (const char *name, const CORE_ADDR address,
                        struct objfile *objfile)
 {
   int section;
-  asection *bfd_section;
 
   switch (storage_class)
     {
       case scText:
         section = SECT_OFF_TEXT (objfile);
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".text");
         break;
       case scData:
         section = SECT_OFF_DATA (objfile);
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".data");
         break;
       case scBss:
         section = SECT_OFF_BSS (objfile);
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".bss");
         break;
       case scSData:
         section = get_section_index (objfile, ".sdata");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".sdata");
         break;
       case scSBss:
         section = get_section_index (objfile, ".sbss");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".sbss");
         break;
       case scRData:
         section = get_section_index (objfile, ".rdata");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".rdata");
         break;
       case scInit:
         section = get_section_index (objfile, ".init");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".init");
         break;
       case scXData:
         section = get_section_index (objfile, ".xdata");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".xdata");
         break;
       case scPData:
         section = get_section_index (objfile, ".pdata");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".pdata");
         break;
       case scFini:
         section = get_section_index (objfile, ".fini");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".fini");
         break;
       case scRConst:
         section = get_section_index (objfile, ".rconst");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".rconst");
         break;
 #ifdef scTlsData
       case scTlsData:
         section = get_section_index (objfile, ".tlsdata");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsdata");
         break;
 #endif
 #ifdef scTlsBss
       case scTlsBss:
         section = get_section_index (objfile, ".tlsbss");
-        bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsbss");
         break;
 #endif
       default:
         /* This kind of symbol is not associated to a section.  */
         section = -1;
-        bfd_section = NULL;
     }
 
   prim_record_minimal_symbol_and_info (name, address, ms_type,
-                                       section, bfd_section, objfile);
+                                       section, objfile);
 }
 
 /* Master parsing procedure for first-pass reading of file symbols
@@ -3510,7 +3495,7 @@ parse_partial_symbols (struct objfile *objfile)
 		  prim_record_minimal_symbol_and_info (name, sh.value,
 						       mst_file_text,
 						       SECT_OFF_TEXT (objfile),
-						       NULL, objfile);
+						       objfile);
 
 		  /* FALLTHROUGH */
 
@@ -3596,13 +3581,11 @@ parse_partial_symbols (struct objfile *objfile)
 		    prim_record_minimal_symbol_and_info (name, sh.value,
 							 mst_file_data,
 							 SECT_OFF_DATA (objfile),
-							 NULL,
 							 objfile);
 		  else
 		    prim_record_minimal_symbol_and_info (name, sh.value,
 							 mst_file_bss,
 							 SECT_OFF_BSS (objfile),
-							 NULL,
 							 objfile);
 		  class = LOC_STATIC;
 		  break;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 8f91d9d..3d16a97 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -892,7 +892,7 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
     }
 
   prim_record_minimal_symbol_and_info (name, address, ms_type,
-				       section, NULL, objfile);
+				       section, objfile);
 }
 
 /* See minsyms.h.  */
@@ -902,7 +902,6 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
 				 CORE_ADDR address,
 				 enum minimal_symbol_type ms_type,
 				 int section,
-				 asection *bfd_section,
 				 struct objfile *objfile)
 {
   struct obj_section *obj_section;
@@ -945,17 +944,6 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
   SYMBOL_SECTION (msymbol) = section;
   SYMBOL_OBJ_SECTION (msymbol) = NULL;
 
-  /* Find obj_section corresponding to bfd_section.  */
-  if (bfd_section)
-    {
-      /* This is written in a funny way due to some code in
-	 elfread.c.  */
-      gdb_assert (objfile->sections[section].the_bfd_section == bfd_section
-		  || (objfile->separate_debug_objfile_backlink != NULL
-		      && objfile->separate_debug_objfile_backlink->sections[section].the_bfd_section == bfd_section));
-      SYMBOL_OBJ_SECTION (msymbol) = &objfile->sections[section];
-    }
-
   MSYMBOL_TYPE (msymbol) = ms_type;
   MSYMBOL_TARGET_FLAG_1 (msymbol) = 0;
   MSYMBOL_TARGET_FLAG_2 (msymbol) = 0;
@@ -980,12 +968,11 @@ struct minimal_symbol *
 prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
 				     enum minimal_symbol_type ms_type,
 				     int section,
-				     asection *bfd_section,
 				     struct objfile *objfile)
 {
   return prim_record_minimal_symbol_full (name, strlen (name), 1,
-					  address, ms_type, section,
-					  bfd_section, objfile);
+					  address, ms_type,
+					  section, objfile);
 }
 
 /* Compare two minimal symbols by address and return a signed result based
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 71670e3..4d48477 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -88,7 +88,6 @@ struct cleanup *make_cleanup_discard_minimal_symbols (void);
    ADDRESS - the address of the symbol
    MS_TYPE - the type of the symbol
    SECTION - the symbol's section
-   BFD_SECTION - the symbol's BFD section; used to find the
    appropriate obj_section for the minimal symbol.  This can be NULL.
    OBJFILE - the objfile associated with the minimal symbol.  */
 
@@ -99,14 +98,12 @@ struct minimal_symbol *prim_record_minimal_symbol_full
      CORE_ADDR address,
      enum minimal_symbol_type ms_type,
      int section,
-     asection *bfd_section,
      struct objfile *objfile);
 
 /* Like prim_record_minimal_symbol_full, but:
    - uses strlen to compute NAME_LEN,
    - passes COPY_NAME = 0,
-   - passes SECTION = 0,
-   - and passes BFD_SECTION = NULL.
+   - and passes a default SECTION, depending on the type
    
    This variant does not return the new symbol.  */
 
@@ -123,7 +120,6 @@ struct minimal_symbol *prim_record_minimal_symbol_and_info
      CORE_ADDR,
      enum minimal_symbol_type,
      int section,
-     asection *bfd_section,
      struct objfile *);
 
 /* Install the minimal symbols that have been collected into the given
diff --git a/gdb/somread.c b/gdb/somread.c
index 858574f..8a2254d 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -314,7 +314,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile,
       prim_record_minimal_symbol_and_info (symname, symbol_value, ms_type,
 					   gdb_bfd_section_index (objfile->obfd,
 								  section),
-					   section,
 					   objfile);
     }
 }
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 45ed799..4fcfdf8 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -922,15 +922,12 @@ record_minimal_symbol (const char *name, CORE_ADDR address,
 		       int n_scnum,
 		       struct objfile *objfile)
 {
-  int secnum;
-  asection *bfd_sect;
-
   if (name[0] == '.')
     ++name;
 
-  xcoff_secnum_to_sections (n_scnum, objfile, &bfd_sect, &secnum);
   prim_record_minimal_symbol_and_info (name, address, ms_type,
-				       secnum, bfd_sect, objfile);
+				       secnum_to_section (n_scnum, objfile),
+				       objfile);
 }
 
 /* xcoff has static blocks marked in `.bs', `.es' pairs.  They cannot be
@@ -2346,7 +2343,6 @@ scan_xcoff_symtab (struct objfile *objfile)
 			(namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_data : mst_data,
 			 secnum_to_section (symbol.n_scnum, objfile),
-			 secnum_to_bfd_section (symbol.n_scnum, objfile),
 			 objfile);
 		    break;
 
@@ -2424,7 +2420,6 @@ scan_xcoff_symtab (struct objfile *objfile)
 			(namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_data : mst_data,
 			 secnum_to_section (symbol.n_scnum, objfile),
-			 secnum_to_bfd_section (symbol.n_scnum, objfile),
 			 objfile);
 		    break;
 		  }
@@ -2442,7 +2437,6 @@ scan_xcoff_symtab (struct objfile *objfile)
 			(namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_bss : mst_bss,
 			 secnum_to_section (symbol.n_scnum, objfile),
-			 secnum_to_bfd_section (symbol.n_scnum, objfile),
 			 objfile);
 		    break;
 		  }
-- 
1.7.7.6


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