public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* dwarf2.c remove varinfo and funcinfo sec field
@ 2022-09-21  6:16 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-09-21  6:16 UTC (permalink / raw)
  To: binutils

The "sec" field in these structures is only set and used in lookup
functions.  It always starts off as NULL.  So the only possible effect
of the field is to modify the return of the lookup, which was its
purpose back in 2005 when HJ fixed PR990.  Since then we solved the
problem of relocatable object files with the fix for PR2338, so this
field is now redundant.

	* dwarf.c (struct funcinfo, struct varinfo): Remove "sec" field.
	(lookup_symbol_in_function_table): Don't set or test "sec".
	(lookup_symbol_in_variable_table): Likewise.
	(info_hash_lookup_funcinfo, info_hash_lookup_varinfo): Likewise.

diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index c55a3624367..e7c12c3e9de 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1810,8 +1810,6 @@ struct funcinfo
   bool is_linkage;
   const char *name;
   struct arange arange;
-  /* Where the symbol is defined.  */
-  asection *sec;
   /* The offset of the funcinfo from the start of the unit.  */
   uint64_t unit_offset;
 };
@@ -1848,8 +1846,6 @@ struct varinfo
   const char *name;
   /* The address of the variable.  */
   bfd_vma addr;
-  /* Where the symbol is defined.  */
-  asection *sec;
   /* Is this a stack variable?  */
   bool stack;
 };
@@ -3354,7 +3350,6 @@ lookup_symbol_in_function_table (struct comp_unit *unit,
   bfd_vma best_fit_len = 0;
   struct arange *arange;
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_asymbol_section (sym);
 
   for (each_func = unit->function_table;
        each_func;
@@ -3364,8 +3359,7 @@ lookup_symbol_in_function_table (struct comp_unit *unit,
 	   arange;
 	   arange = arange->next)
 	{
-	  if ((!each_func->sec || each_func->sec == sec)
-	      && addr >= arange->low
+	  if (addr >= arange->low
 	      && addr < arange->high
 	      && each_func->name
 	      && strcmp (name, each_func->name) == 0
@@ -3380,7 +3374,6 @@ lookup_symbol_in_function_table (struct comp_unit *unit,
 
   if (best_fit)
     {
-      best_fit->sec = sec;
       *filename_ptr = best_fit->file;
       *linenumber_ptr = best_fit->line;
       return true;
@@ -3402,7 +3395,6 @@ lookup_symbol_in_variable_table (struct comp_unit *unit,
 				 unsigned int *linenumber_ptr)
 {
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_asymbol_section (sym);
   struct varinfo* each;
 
   for (each = unit->variable_table; each; each = each->prev_var)
@@ -3410,13 +3402,11 @@ lookup_symbol_in_variable_table (struct comp_unit *unit,
 	&& each->file != NULL
 	&& each->name != NULL
 	&& each->addr == addr
-	&& (!each->sec || each->sec == sec)
 	&& strcmp (name, each->name) == 0)
       break;
 
   if (each)
     {
-      each->sec = sec;
       *filename_ptr = each->file;
       *linenumber_ptr = each->line;
       return true;
@@ -5079,7 +5069,6 @@ info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
   struct info_list_node *node;
   struct arange *arange;
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_asymbol_section (sym);
 
   for (node = lookup_info_hash_table (hash_table, name);
        node;
@@ -5090,8 +5079,7 @@ info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
 	   arange;
 	   arange = arange->next)
 	{
-	  if ((!each_func->sec || each_func->sec == sec)
-	      && addr >= arange->low
+	  if (addr >= arange->low
 	      && addr < arange->high
 	      && (!best_fit
 		  || arange->high - arange->low < best_fit_len))
@@ -5104,7 +5092,6 @@ info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
 
   if (best_fit)
     {
-      best_fit->sec = sec;
       *filename_ptr = best_fit->file;
       *linenumber_ptr = best_fit->line;
       return true;
@@ -5127,7 +5114,6 @@ info_hash_lookup_varinfo (struct info_hash_table *hash_table,
 			  unsigned int *linenumber_ptr)
 {
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_asymbol_section (sym);
   struct varinfo* each;
   struct info_list_node *node;
 
@@ -5136,10 +5122,8 @@ info_hash_lookup_varinfo (struct info_hash_table *hash_table,
        node = node->next)
     {
       each = (struct varinfo *) node->info;
-      if (each->addr == addr
-	  && (!each->sec || each->sec == sec))
+      if (each->addr == addr)
 	{
-	  each->sec = sec;
 	  *filename_ptr = each->file;
 	  *linenumber_ptr = each->line;
 	  return true;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-21  6:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21  6:16 dwarf2.c remove varinfo and funcinfo sec field Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).