From 1febe64d9616c501f59099727efb718273259859 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 14 Jan 2008 12:26:57 +0000 Subject: [PATCH] * dwarf.c (process_debug_info): Include the CU offset and corrupt version value when reporting unrecognised DWARF version numbers. (load_debug_info): Remember a failed attempt to load and parse the .debug_info section and do not repeat such attempts. (display_debug_lines): Check the return value from load_debug_info and return whilst displaying a warning message if the load failed. (display_debug_loc): Likewise. (display_debug_ranges): Likewise. --- binutils/ChangeLog | 11 +++++++++++ binutils/dwarf.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index c74bc0fe8a6..94330ded047 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2008-01-14 Nick Clifton + + * dwarf.c (process_debug_info): Include the CU offset and corrupt + version value when reporting unrecognised DWARF version numbers. + (load_debug_info): Remember a failed attempt to load and parse the + .debug_info section and do not repeat such attempts. + (display_debug_lines): Check the return value from load_debug_info + and return whilst displaying a warning message if the load failed. + (display_debug_loc): Likewise. + (display_debug_ranges): Likewise. + 2008-01-10 Andreas Schwab * readelf.c (is_64bit_abs_reloc): Handle R_S390_64. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 093832d5e5b..bac80bc8bd0 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -1841,7 +1841,8 @@ process_debug_info (struct dwarf_section *section, void *file, if (compunit.cu_version != 2 && compunit.cu_version != 3) { - warn (_("Only version 2 and 3 DWARF debug information is currently supported.\n")); + warn (_("CU at offset %lx contains corrupt or unsupported version number: %d.\n"), + cu_offset, compunit.cu_version); continue; } @@ -1985,6 +1986,11 @@ load_debug_info (void * file) last_pointer_size = 0; warned_about_missing_comp_units = FALSE; + /* If we have already tried and failed to load the .debug_info + section then do not bother to repear the task. */ + if (num_debug_info_entries == (unsigned) -1) + return 0; + /* If we already have the information there is nothing else to do. */ if (num_debug_info_entries > 0) return num_debug_info_entries; @@ -1992,8 +1998,9 @@ load_debug_info (void * file) if (load_debug_section (info, file) && process_debug_info (&debug_displays [info].section, file, 1)) return num_debug_info_entries; - else - return 0; + + num_debug_info_entries = (unsigned) -1; + return 0; } static int @@ -2006,7 +2013,12 @@ display_debug_lines (struct dwarf_section *section, void *file) printf (_("\nDump of debug contents of section %s:\n\n"), section->name); - load_debug_info (file); + if (load_debug_info (file) == 0) + { + warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), + section->name); + return 0; + } while (data < end) { @@ -2501,7 +2513,12 @@ display_debug_loc (struct dwarf_section *section, void *file) return 0; } - load_debug_info (file); + if (load_debug_info (file) == 0) + { + warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), + section->name); + return 0; + } /* Check the order of location list in .debug_info section. If offsets of location lists are in the ascending order, we can @@ -2876,7 +2893,12 @@ display_debug_ranges (struct dwarf_section *section, return 0; } - load_debug_info (file); + if (load_debug_info (file) == 0) + { + warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"), + section->name); + return 0; + } /* Check the order of range list in .debug_info section. If offsets of range lists are in the ascending order, we can -- 2.30.2