Replace an assertion in the dwarf code with a warning message.
authorNick Clifton <nickc@redhat.com>
Tue, 11 Apr 2023 16:24:09 +0000 (17:24 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 11 Apr 2023 16:24:09 +0000 (17:24 +0100)
  PR 30327
  * dwarf.c (read_and_display_attr_value): Warn if the number of views is greater than the number of locations.

binutils/ChangeLog
binutils/dwarf.c

index 59ab08a26e657046fbbafebd0b4ce60ed5e4f40a..3b6f045e78ac17149d897960aaa693039ef8d5e3 100644 (file)
@@ -1,5 +1,9 @@
 2023-04-11  Nick Clifton  <nickc@redhat.com>
 
+       PR 30327
+       * dwarf.c (read_and_display_attr_value): Warn if the number of
+       views is greater than the number of locations.
+
        PR 30313
        * dwarf.c (display_debug_lines_decoded): Check for an overlarge
        number of files or directories.
index f6ff238d3cb847f4d36dbb6a4b60d25fd5c44f7d..87ce1541d1ce6e960c9ad8aef536b14e93de13e5 100644 (file)
@@ -2927,8 +2927,14 @@ read_and_display_attr_value (unsigned long attribute,
                }
              else
                {
-                 assert (debug_info_p->num_loc_views <= num);
-                 num = debug_info_p->num_loc_views;
+                 if (debug_info_p->num_loc_views > num)
+                   {
+                     warn (_("The number of views (%u) is greater than the number of locations (%u)\n"),
+                           debug_info_p->num_loc_views, num);
+                     debug_info_p->num_loc_views = num;
+                   }
+                 else
+                   num = debug_info_p->num_loc_views;
                  if (num > debug_info_p->num_loc_offsets)
                    warn (_("More DW_AT_GNU_locview attributes than location offset attributes\n"));
                  else