aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-05-04 13:50:05 +0100
committerNick Clifton <nickc@redhat.com>2020-05-04 13:50:05 +0100
commit070b775f03ebdab6d0d007787fe19b916af4439c (patch)
tree92c9989fde303f3bfc75f68cc049f9535a3c2e8f /binutils
parentfe05f369f0df7cad0a6500b79879addaad2e364d (diff)
downloadgdb-070b775f03ebdab6d0d007787fe19b916af4439c.zip
gdb-070b775f03ebdab6d0d007787fe19b916af4439c.tar.gz
gdb-070b775f03ebdab6d0d007787fe19b916af4439c.tar.bz2
GAS: Do not create an entry for the default directory if the directory table is empty. Improve readelf's decoding of empty directory and file name tables.
PR 25917 * dwarf.c (display_debug_lines_decoded): Warn if encountering a supicious number of entries for DWARF-5 format directory and file name tables. Do not display file name table header if the table is empty. Do not allocate space for empty tables.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/dwarf.c28
2 files changed, 29 insertions, 7 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 7b0d1a0..7cc692b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-04 Nick Clifton <nickc@redhat.com>
+
+ PR 25917
+ * dwarf.c (display_debug_lines_decoded): Warn if encountering a
+ supicious number of entries for DWARF-5 format directory and file
+ name tables. Do not display file name table header if the table
+ is empty. Do not allocate space for empty tables.
+
2020-05-04 Alan Modra <amodra@gmail.com>
* readelf.c (process_nds32_specific): Check size of .nds32_e_flags
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index eb053ce..61373bf 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -4343,6 +4343,8 @@ 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);
format_start = data;
for (formati = 0; formati < format_count; formati++)
{
@@ -4357,8 +4359,11 @@ display_debug_lines_decoded (struct dwarf_section * section,
break;
}
- directory_table = (unsigned char **)
- xmalloc (n_directories * sizeof (unsigned char *));
+ if (n_directories == 0)
+ directory_table = NULL;
+ else
+ directory_table = (unsigned char **)
+ xmalloc (n_directories * sizeof (unsigned char *));
for (entryi = 0; entryi < n_directories; entryi++)
{
@@ -4411,6 +4416,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;
format_start = data;
for (formati = 0; formati < format_count; formati++)
{
@@ -4419,14 +4427,17 @@ display_debug_lines_decoded (struct dwarf_section * section,
}
READ_ULEB (n_files, data, end);
- if (data == end)
+ if (data == end && n_files > 0)
{
warn (_("Corrupt file name list\n"));
break;
}
- file_table = (File_Entry *) xcalloc (1, n_files
- * sizeof (File_Entry));
+ if (n_files == 0)
+ file_table = NULL;
+ else
+ file_table = (File_Entry *) xcalloc (1, n_files
+ * sizeof (File_Entry));
for (entryi = 0; entryi < n_files; entryi++)
{
@@ -4582,7 +4593,7 @@ display_debug_lines_decoded (struct dwarf_section * section,
/* Print the Compilation Unit's name and a header. */
if (file_table == NULL)
- ;
+ printf (_("CU: No directory table\n"));
else if (directory_table == NULL)
printf (_("CU: %s:\n"), file_table[0].name);
else
@@ -4610,7 +4621,10 @@ display_debug_lines_decoded (struct dwarf_section * section,
printf ("%s:\n", file_table[0].name);
}
- printf (_("File name Line number Starting address View Stmt\n"));
+ if (n_files > 0)
+ printf (_("File name Line number Starting address View Stmt\n"));
+ else
+ printf (_("CU: Empty file name table\n"));
saved_linfo = linfo;
}