diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2005-09-02 13:36:33 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2005-09-02 13:36:33 +0000 |
commit | a841cf65e983ff1c5a8481578a49680f12ba0148 (patch) | |
tree | 4008e7bb729fd939102901db5a0e3e7fa6a2a882 | |
parent | 8f06b2d82f0fa8d84dc92db3747ca44462e969b0 (diff) | |
download | gdb-a841cf65e983ff1c5a8481578a49680f12ba0148.zip gdb-a841cf65e983ff1c5a8481578a49680f12ba0148.tar.gz gdb-a841cf65e983ff1c5a8481578a49680f12ba0148.tar.bz2 |
2005-09-02 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (debug_abbrev_contents): New.
(debug_abbrev_size): Likewise.
(load_debug_abbrev): Likewise.
(free_debug_abbrev): Likewise.
(process_debug_info): Use them.
-rw-r--r-- | binutils/ChangeLog | 8 | ||||
-rw-r--r-- | binutils/readelf.c | 71 |
2 files changed, 56 insertions, 23 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index e23cdad..a3f9b0e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,11 @@ +2005-09-02 H.J. Lu <hongjiu.lu@intel.com> + + * readelf.c (debug_abbrev_contents): New. + (debug_abbrev_size): Likewise. + (load_debug_abbrev): Likewise. + (free_debug_abbrev): Likewise. + (process_debug_info): Use them. + 2005-08-17 H.J. Lu <hongjiu.lu@intel.com> PR binutils/1179 diff --git a/binutils/readelf.c b/binutils/readelf.c index 57a6047..4f865b0 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -7658,6 +7658,41 @@ free_debug_range (void) debug_range_size = 0; } +static unsigned char *debug_abbrev_contents; +static unsigned long debug_abbrev_size; + +static void +load_debug_abbrev (FILE *file) +{ + Elf_Internal_Shdr *sec; + + /* If it is already loaded, do nothing. */ + if (debug_abbrev_contents != NULL) + return; + + /* Locate the .debug_ranges section. */ + sec = find_section (".debug_abbrev"); + if (sec == NULL) + return; + + debug_abbrev_size = sec->sh_size; + + debug_abbrev_contents = get_data (NULL, file, sec->sh_offset, 1, + sec->sh_size, + _("debug_abbrev section data")); +} + +static void +free_debug_abbrev (void) +{ + if (debug_abbrev_contents == NULL) + return; + + free ((char *) debug_abbrev_contents); + debug_abbrev_contents = NULL; + debug_abbrev_size = 0; +} + /* Apply addends of RELA relocations. */ static int @@ -9051,6 +9086,13 @@ process_debug_info (Elf_Internal_Shdr *section, unsigned char *start, load_debug_range (file); } + load_debug_abbrev (file); + if (debug_abbrev_contents == NULL) + { + warn (_("Unable to locate .debug_abbrev section!\n")); + return 0; + } + for (section_begin = start, unit = 0; start < end; unit++) { DWARF2_Internal_CompUnit compunit; @@ -9132,29 +9174,10 @@ process_debug_info (Elf_Internal_Shdr *section, unsigned char *start, free_abbrevs (); - /* Read in the abbrevs used by this compilation unit. */ - { - Elf_Internal_Shdr *sec; - unsigned char *begin; - - /* Locate the .debug_abbrev section and process it. */ - sec = find_section (".debug_abbrev"); - if (sec == NULL) - { - warn (_("Unable to locate .debug_abbrev section!\n")); - return 0; - } - - begin = get_data (NULL, file, sec->sh_offset, 1, sec->sh_size, - _("debug_abbrev section data")); - if (!begin) - return 0; - - process_abbrev_section (begin + compunit.cu_abbrev_offset, - begin + sec->sh_size); - - free (begin); - } + /* Process the abbrevs used by this compilation unit. */ + process_abbrev_section + (debug_abbrev_contents + compunit.cu_abbrev_offset, + debug_abbrev_contents + debug_abbrev_size); level = 0; while (tags < start) @@ -9228,6 +9251,8 @@ process_debug_info (Elf_Internal_Shdr *section, unsigned char *start, } } + free_debug_abbrev (); + /* Set num_debug_info_entries here so that it can be used to check if we need to process .debug_loc and .debug_ranges sections. */ if ((do_loc || do_debug_loc || do_debug_ranges) |