|
|
00b3bd |
--- binutils.orig/bfd/dwarf2.c 2022-05-16 16:40:15.590519654 +0100
|
|
|
00b3bd |
+++ binutils-2.38/bfd/dwarf2.c 2022-05-16 16:45:31.824590450 +0100
|
|
|
00b3bd |
@@ -3291,6 +3291,36 @@ lookup_var_by_offset (bfd_uint64_t offse
|
|
|
00b3bd |
}
|
|
|
00b3bd |
|
|
|
00b3bd |
|
|
|
00b3bd |
+static struct funcinfo *
|
|
|
00b3bd |
+reverse_funcinfo_list (struct funcinfo *head)
|
|
|
00b3bd |
+{
|
|
|
00b3bd |
+ struct funcinfo *rhead;
|
|
|
00b3bd |
+ struct funcinfo *temp;
|
|
|
00b3bd |
+
|
|
|
00b3bd |
+ for (rhead = NULL; head; head = temp)
|
|
|
00b3bd |
+ {
|
|
|
00b3bd |
+ temp = head->prev_func;
|
|
|
00b3bd |
+ head->prev_func = rhead;
|
|
|
00b3bd |
+ rhead = head;
|
|
|
00b3bd |
+ }
|
|
|
00b3bd |
+ return rhead;
|
|
|
00b3bd |
+}
|
|
|
00b3bd |
+
|
|
|
00b3bd |
+static struct varinfo *
|
|
|
00b3bd |
+reverse_varinfo_list (struct varinfo *head)
|
|
|
00b3bd |
+{
|
|
|
00b3bd |
+ struct varinfo *rhead;
|
|
|
00b3bd |
+ struct varinfo *temp;
|
|
|
00b3bd |
+
|
|
|
00b3bd |
+ for (rhead = NULL; head; head = temp)
|
|
|
00b3bd |
+ {
|
|
|
00b3bd |
+ temp = head->prev_var;
|
|
|
00b3bd |
+ head->prev_var = rhead;
|
|
|
00b3bd |
+ rhead = head;
|
|
|
00b3bd |
+ }
|
|
|
00b3bd |
+ return rhead;
|
|
|
00b3bd |
+}
|
|
|
00b3bd |
+
|
|
|
00b3bd |
/* DWARF2 Compilation unit functions. */
|
|
|
00b3bd |
|
|
|
00b3bd |
/* Scan over each die in a comp. unit looking for functions to add
|
|
|
00b3bd |
@@ -3308,6 +3338,8 @@ scan_unit_for_symbols (struct comp_unit
|
|
|
00b3bd |
struct funcinfo *func;
|
|
|
00b3bd |
} *nested_funcs;
|
|
|
00b3bd |
int nested_funcs_size;
|
|
|
00b3bd |
+ struct funcinfo *last_func;
|
|
|
00b3bd |
+ struct varinfo *last_var;
|
|
|
00b3bd |
|
|
|
00b3bd |
/* Maintain a stack of in-scope functions and inlined functions, which we
|
|
|
00b3bd |
can use to set the caller_func field. */
|
|
|
00b3bd |
@@ -3442,10 +3474,16 @@ scan_unit_for_symbols (struct comp_unit
|
|
|
00b3bd |
}
|
|
|
00b3bd |
}
|
|
|
00b3bd |
|
|
|
00b3bd |
+ unit->function_table = reverse_funcinfo_list (unit->function_table);
|
|
|
00b3bd |
+ unit->variable_table = reverse_varinfo_list (unit->variable_table);
|
|
|
00b3bd |
+
|
|
|
00b3bd |
/* This is the second pass over the abbrevs. */
|
|
|
00b3bd |
info_ptr = unit->first_child_die_ptr;
|
|
|
00b3bd |
nesting_level = 0;
|
|
|
00b3bd |
|
|
|
00b3bd |
+ last_func = NULL;
|
|
|
00b3bd |
+ last_var = NULL;
|
|
|
00b3bd |
+
|
|
|
00b3bd |
while (nesting_level >= 0)
|
|
|
00b3bd |
{
|
|
|
00b3bd |
unsigned int abbrev_number, i;
|
|
|
00b3bd |
@@ -3481,16 +3519,32 @@ scan_unit_for_symbols (struct comp_unit
|
|
|
00b3bd |
|| abbrev->tag == DW_TAG_entry_point
|
|
|
00b3bd |
|| abbrev->tag == DW_TAG_inlined_subroutine)
|
|
|
00b3bd |
{
|
|
|
00b3bd |
- func = lookup_func_by_offset (current_offset, unit->function_table);
|
|
|
00b3bd |
+ if (last_func
|
|
|
00b3bd |
+ && last_func->prev_func
|
|
|
00b3bd |
+ && last_func->prev_func->unit_offset == current_offset)
|
|
|
00b3bd |
+ func = last_func->prev_func;
|
|
|
00b3bd |
+ else
|
|
|
00b3bd |
+ func = lookup_func_by_offset (current_offset, unit->function_table);
|
|
|
00b3bd |
+
|
|
|
00b3bd |
if (func == NULL)
|
|
|
00b3bd |
goto fail;
|
|
|
00b3bd |
+
|
|
|
00b3bd |
+ last_func = func;
|
|
|
00b3bd |
}
|
|
|
00b3bd |
else if (abbrev->tag == DW_TAG_variable
|
|
|
00b3bd |
|| abbrev->tag == DW_TAG_member)
|
|
|
00b3bd |
{
|
|
|
00b3bd |
- var = lookup_var_by_offset (current_offset, unit->variable_table);
|
|
|
00b3bd |
+ if (last_var
|
|
|
00b3bd |
+ && last_var->prev_var
|
|
|
00b3bd |
+ && last_var->prev_var->unit_offset == current_offset)
|
|
|
00b3bd |
+ var = last_var->prev_var;
|
|
|
00b3bd |
+ else
|
|
|
00b3bd |
+ var = lookup_var_by_offset (current_offset, unit->variable_table);
|
|
|
00b3bd |
+
|
|
|
00b3bd |
if (var == NULL)
|
|
|
00b3bd |
goto fail;
|
|
|
00b3bd |
+
|
|
|
00b3bd |
+ last_var = var;
|
|
|
00b3bd |
}
|
|
|
00b3bd |
|
|
|
00b3bd |
for (i = 0; i < abbrev->num_attrs; ++i)
|
|
|
00b3bd |
@@ -3684,6 +3738,9 @@ scan_unit_for_symbols (struct comp_unit
|
|
|
00b3bd |
}
|
|
|
00b3bd |
}
|
|
|
00b3bd |
|
|
|
00b3bd |
+ unit->function_table = reverse_funcinfo_list (unit->function_table);
|
|
|
00b3bd |
+ unit->variable_table = reverse_varinfo_list (unit->variable_table);
|
|
|
00b3bd |
+
|
|
|
00b3bd |
free (nested_funcs);
|
|
|
00b3bd |
return true;
|
|
|
00b3bd |
|
|
|
00b3bd |
@@ -4047,36 +4104,6 @@ comp_unit_find_line (struct comp_unit *u
|
|
|
00b3bd |
linenumber_ptr);
|
|
|
00b3bd |
}
|
|
|
00b3bd |
|
|
|
00b3bd |
-static struct funcinfo *
|
|
|
00b3bd |
-reverse_funcinfo_list (struct funcinfo *head)
|
|
|
00b3bd |
-{
|
|
|
00b3bd |
- struct funcinfo *rhead;
|
|
|
00b3bd |
- struct funcinfo *temp;
|
|
|
00b3bd |
-
|
|
|
00b3bd |
- for (rhead = NULL; head; head = temp)
|
|
|
00b3bd |
- {
|
|
|
00b3bd |
- temp = head->prev_func;
|
|
|
00b3bd |
- head->prev_func = rhead;
|
|
|
00b3bd |
- rhead = head;
|
|
|
00b3bd |
- }
|
|
|
00b3bd |
- return rhead;
|
|
|
00b3bd |
-}
|
|
|
00b3bd |
-
|
|
|
00b3bd |
-static struct varinfo *
|
|
|
00b3bd |
-reverse_varinfo_list (struct varinfo *head)
|
|
|
00b3bd |
-{
|
|
|
00b3bd |
- struct varinfo *rhead;
|
|
|
00b3bd |
- struct varinfo *temp;
|
|
|
00b3bd |
-
|
|
|
00b3bd |
- for (rhead = NULL; head; head = temp)
|
|
|
00b3bd |
- {
|
|
|
00b3bd |
- temp = head->prev_var;
|
|
|
00b3bd |
- head->prev_var = rhead;
|
|
|
00b3bd |
- rhead = head;
|
|
|
00b3bd |
- }
|
|
|
00b3bd |
- return rhead;
|
|
|
00b3bd |
-}
|
|
|
00b3bd |
-
|
|
|
00b3bd |
/* Extract all interesting funcinfos and varinfos of a compilation
|
|
|
00b3bd |
unit into hash tables for faster lookup. Returns TRUE if no
|
|
|
00b3bd |
errors were enountered; FALSE otherwise. */
|