From: Mark Wielaard Date: Wed, 26 Aug 2020 12:27:46 +0000 (+0200) Subject: readelf: It is not an error if there are no line number statements X-Git-Tag: elfutils-0.181~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df91c6af98ac09acce5a906afef3e3fe21b24734;p=thirdparty%2Felfutils.git readelf: It is not an error if there are no line number statements 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index 2452cd400..8eb2103d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2020-08-26 Mark Wielaard + + * 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 * elfclassify.c (process_current_path): Handle fwrite failing. diff --git a/src/readelf.c b/src/readelf.c index 685d0b177..41933d953 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -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;