diff options
author | Nick Clifton <nickc@redhat.com> | 2020-05-05 16:16:03 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-05-05 16:16:03 +0100 |
commit | 546cb2d85eddba4f56dfbcb0288db68243e3a0fd (patch) | |
tree | 35769bf0625cb16c6d8bd6ec734a8648ccfd2bc4 /binutils/dwarf.c | |
parent | 7d0bd4874453d781a0e6e998b47422f968907bdb (diff) | |
download | gdb-546cb2d85eddba4f56dfbcb0288db68243e3a0fd.zip gdb-546cb2d85eddba4f56dfbcb0288db68243e3a0fd.tar.gz gdb-546cb2d85eddba4f56dfbcb0288db68243e3a0fd.tar.bz2 |
Restore readelf's warnings that describe real problems with the file being examined. Fix bug displaying empty file name tables.
binutils* dwarf.c (do_checks): New global variable.
(display_formatted_table): Warn about an unexpected number of
columns in the table, if checks are enabled. Do not complain
about the lack of data following the number of entries in the
table if the table is empty.
(display_debug_lines_decoded): Only warn about an unexpected
number of columns in a table if checks are enabled.
* dwarf.h (do_checks): Add a prototype.
* elfcomm.c (error): Remove weak attribute.
(warn): Likewise.
* readelf.c (do_checks): Delete.
(warn): Delete.
(process_section_headers): Only warn about empty sections if
checks are enabled.
gas * dwarf2dbg.c (out_dir_and_file_list): Add comments describing the
construction of a DWARF-5 directory name table.
* testsuite/gas/elf/pr25917.d: Update expected output.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r-- | binutils/dwarf.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 61373bf..7b5f7af 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -98,6 +98,7 @@ int do_debug_cu_index; int do_wide; int do_debug_links; int do_follow_links; +bfd_boolean do_checks; int dwarf_cutoff_level = -1; unsigned long dwarf_start_die; @@ -3739,6 +3740,10 @@ display_formatted_table (unsigned char * data, const char * table_name = is_dir ? N_("Directory Table") : N_("File Name Table"); SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); + if (do_checks && format_count > 5) + warn (_("Unexpectedly large number of columns in the %s (%u)\n"), + table_name, format_count); + format_start = data; for (formati = 0; formati < format_count; formati++) { @@ -3752,17 +3757,18 @@ display_formatted_table (unsigned char * data, } READ_ULEB (data_count, data, end); - if (data == end) + if (data_count == 0) { - warn (_("%s: Corrupt entry count\n"), table_name); + printf (_("\n The %s is empty.\n"), table_name); return data; } - - if (data_count == 0) + else if (data == end) { - printf (_("\n The %s is empty.\n"), table_name); + warn (_("%s: Corrupt entry count - expected %s but none found\n"), + table_name, dwarf_vmatoa ("x", data_count)); return data; } + else if (format_count == 0) { warn (_("%s: format count is zero, but the table is not empty\n"), @@ -4343,8 +4349,9 @@ display_debug_lines_decoded (struct dwarf_section * section, /* Skip directories format. */ SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); - if (format_count > 1) - warn ("Unexpectedly large number of columns in the directory name table (%u)\n", format_count); + if (do_checks && format_count > 1) + warn (_("Unexpectedly large number of columns in the directory name table (%u)\n"), + format_count); format_start = data; for (formati = 0; formati < format_count; formati++) { @@ -4416,9 +4423,9 @@ display_debug_lines_decoded (struct dwarf_section * section, /* Skip files format. */ SAFE_BYTE_GET_AND_INC (format_count, data, 1, end); - if (format_count > 5) - warn ("Unexpectedly large number of columns in the file name table (%u)\n", format_count); - format_count = 2; + if (do_checks && format_count > 5) + warn (_("Unexpectedly large number of columns in the file name table (%u)\n"), + format_count); format_start = data; for (formati = 0; formati < format_count; formati++) { |