]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: It is not an error if there are no line number statements
authorMark Wielaard <mark@klomp.org>
Wed, 26 Aug 2020 12:27:46 +0000 (14:27 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 26 Aug 2020 12:27:46 +0000 (14:27 +0200)
It can happen that there are no line number statements at the end of
a debug line section. So don't check that there are any more bytes
after the last file entry. And print "No line number statements."

libdw already got this corner case correct.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/readelf.c

index 2452cd400cafa0be6b74db0f0ede803efb6cec89..8eb2103d93db287e6782e90b4a16354767fb69f3 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-26  Mark Wielaard  <mark@klomp.org>
+
+       * readelf.c (print_debug_line_section): It is not an error if there
+       are no line number statements at the end of a debug line section.
+
 2020-07-19  Mark Wielaard  <mark@klomp.org>
 
        * elfclassify.c (process_current_path): Handle fwrite failing.
index 685d0b17728685db79ab58f606179dac96499c03..41933d9538d4e2f36faaa7fbbee19735e6c10f09 100644 (file)
@@ -8642,7 +8642,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
                    printf (", ");
                }
              printf ("\n");
-             if (linep >= lineendp)
+             if (linep > lineendp)
                goto invalid_unit;
            }
        }
@@ -8685,6 +8685,12 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
          ++linep;
        }
 
+      if (linep == lineendp)
+       {
+         puts (gettext ("\nNo line number statements."));
+         return;
+       }
+
       puts (gettext ("\nLine number statements:"));
       Dwarf_Word address = 0;
       unsigned int op_index = 0;