From 34b5e0b20544f6a8bfc32b4bd444e69b3b8a2b4d Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 22 Feb 2008 15:27:38 +0000 Subject: [PATCH] PR 868 *dwarf2.c: Revert previous patch. All of the allocate memory is on an obstack which will be freed at some other time. --- bfd/ChangeLog | 6 ++++ bfd/dwarf2.c | 97 ++++++++------------------------------------------- 2 files changed, 21 insertions(+), 82 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a9d7988393c..612a49017d6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2008-02-22 Nick Clifton + + PR 868 + *dwarf2.c: Revert previous patch. All of the allocate memory is + on an obstack which will be freed at some other time. + 2008-02-20 Nick Clifton PR 868 diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 830b747108a..d0b50ff9a17 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -656,16 +656,10 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash) while (abbrev) { - struct abbrev_info * a = abbrev; - - abbrev = a->next; - if (a->attrs) - free (abbrev->attrs); - free (a); + free (abbrev->attrs); + abbrev = abbrev->next; } } - - free (abbrevs); return NULL; } cur_abbrev->attrs = tmp; @@ -1129,11 +1123,9 @@ arange_add (bfd *abfd, struct arange *first_arange, bfd_vma low_pc, bfd_vma high first_arange->next = arange; } -/* Decode the line number information for UNIT. - Note: this function allocates memory. It is the caller's - responsibility to free it. */ +/* Decode the line number information for UNIT. */ -static struct line_info_table * +static struct line_info_table* decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) { bfd *abfd = unit->abfd; @@ -1255,7 +1247,6 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) if (tmp == NULL) { free (table->dirs); - free (table); return NULL; } table->dirs = tmp; @@ -1283,7 +1274,6 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) { free (table->files); free (table->dirs); - free (table); return NULL; } table->files = tmp; @@ -1380,7 +1370,6 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) { free (table->files); free (table->dirs); - free (table); free (filename); return NULL; } @@ -1404,7 +1393,6 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) free (filename); free (table->files); free (table->dirs); - free (table); return NULL; } break; @@ -1826,10 +1814,7 @@ read_rangelist (struct comp_unit *unit, struct arange *arange, bfd_uint64_t offs /* DWARF2 Compilation unit functions. */ /* Scan over each die in a comp. unit looking for functions to add - to the function table and variables to the variable table. - Returns TRUE upon success, FALSE otherwise. Allocates memory - blocks to the unit->function_table and unit->variable_table fields. - It is the caller's responsibility to free this memory. */ + to the function table and variables to the variable table. */ static bfd_boolean scan_unit_for_symbols (struct comp_unit *unit) @@ -1846,7 +1831,7 @@ scan_unit_for_symbols (struct comp_unit *unit) nested_funcs = bfd_malloc (nested_funcs_size * sizeof (struct funcinfo *)); if (nested_funcs == NULL) return FALSE; - nested_funcs[nesting_level] = NULL; + nested_funcs[nesting_level] = 0; while (nesting_level) { @@ -1883,7 +1868,6 @@ scan_unit_for_symbols (struct comp_unit *unit) || abbrev->tag == DW_TAG_inlined_subroutine) { bfd_size_type amt = sizeof (struct funcinfo); - func = bfd_zalloc (abfd, amt); func->tag = abbrev->tag; func->prev_func = unit->function_table; @@ -1905,7 +1889,6 @@ scan_unit_for_symbols (struct comp_unit *unit) if (abbrev->tag == DW_TAG_variable) { bfd_size_type amt = sizeof (struct varinfo); - var = bfd_zalloc (abfd, amt); var->tag = abbrev->tag; var->stack = 1; @@ -3218,75 +3201,25 @@ _bfd_dwarf2_cleanup_debug_info (bfd *abfd) for (each = stash->all_comp_units; each; each = each->next_unit) { - struct funcinfo * function_table = each->function_table; - struct varinfo * variable_table = each->variable_table; + struct abbrev_info **abbrevs = each->abbrevs; + size_t i; - if (each->abbrevs != NULL) + for (i = 0; i < ABBREV_HASH_SIZE; i++) { - size_t i; + struct abbrev_info *abbrev = abbrevs[i]; - for (i = 0; i < ABBREV_HASH_SIZE; i++) + while (abbrev) { - struct abbrev_info *abbrev = each->abbrevs[i]; - - while (abbrev) - { - struct abbrev_info * a = abbrev; - - abbrev = a->next; - if (a->attrs) - free (a->attrs); - free (a); - } + free (abbrev->attrs); + abbrev = abbrev->next; } - - free (each->abbrevs); - each->abbrevs = NULL; } if (each->line_table) { - /* FIXME: We should free the line_info structures as well. */ - if (each->line_table->dirs) - free (each->line_table->dirs); - - if (each->line_table->files) - free (each->line_table->files); - - free (each->line_table); - each->line_table = NULL; + free (each->line_table->dirs); + free (each->line_table->files); } - - while (function_table) - { - struct funcinfo * f = function_table; - - function_table = f->prev_func; - - if (f->file) - free (f->file); - - if (f->caller_file) - free (f->caller_file); - - free (f); - } - - each->function_table = NULL; - - while (variable_table) - { - struct varinfo * v = variable_table; - - variable_table = variable_table->prev_var; - - if (v->file) - free (v->file); - - free (v); - } - - each->variable_table = NULL; } free (stash->dwarf_abbrev_buffer); -- 2.30.2