Use section name in warnings in display_debug_loc
authorTom Tromey <tromey@adacore.com>
Wed, 3 Nov 2021 13:33:24 +0000 (07:33 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 3 Nov 2021 13:33:24 +0000 (07:33 -0600)
While looking at an apparently malformed executable with
"readelf --debug-dump=loc", I got this warning:

    readelf: ./main: Warning: There is a hole [0x89 - 0x95] in .debug_loc section.

However, the executable only has a .debug_loclists section.

This patch fixes the warning messages in display_debug_loc to use the
name of the section that is being processed.

binutils/ChangeLog
2021-11-03  Tom Tromey  <tromey@adacore.com>

* dwarf.c (display_debug_loc): Use section name in warnings.

binutils/ChangeLog
binutils/dwarf.c

index efde928b3f092da6d2a7311e37045fc9ad73af4e..3935b30a8dc69d02f32a65cc685d8928243e6467 100644 (file)
@@ -1,3 +1,7 @@
+2021-11-03  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf.c (display_debug_loc): Use section name in warnings.
+
 2021-10-25  Nick Alcock  <nick.alcock@oracle.com>
 
        * objdump.c (usage): --ctf now has an optional argument.
index a118c5b794ea7e30746109e5168aa25a12915b5b..9fed11383a84343a7e3bd189f83ca7d2b063a651 100644 (file)
@@ -7022,28 +7022,32 @@ display_debug_loc (struct dwarf_section *section, void *file)
          else
            {
              if (start < next)
-               warn (_("There is a hole [0x%lx - 0x%lx] in .debug_loc section.\n"),
+               warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
                      (unsigned long) (start - section_begin),
-                     (unsigned long) offset);
+                     (unsigned long) offset,
+                     section->name);
              else if (start > next)
-               warn (_("There is an overlap [0x%lx - 0x%lx] in .debug_loc section.\n"),
+               warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
                      (unsigned long) (start - section_begin),
-                     (unsigned long) offset);
+                     (unsigned long) offset,
+                     section->name);
            }
          start = next;
          vstart = vnext;
 
          if (offset >= bytes)
            {
-             warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
-                   (unsigned long) offset);
+             warn (_("Offset 0x%lx is bigger than %s section size.\n"),
+                   (unsigned long) offset,
+                   section->name);
              continue;
            }
 
          if (vnext && voffset >= bytes)
            {
-             warn (_("View Offset 0x%lx is bigger than .debug_loc section size.\n"),
-                   (unsigned long) voffset);
+             warn (_("View Offset 0x%lx is bigger than %s section size.\n"),
+                   (unsigned long) voffset,
+                   section->name);
              continue;
            }