From df91c6af98ac09acce5a906afef3e3fe21b24734 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 26 Aug 2020 14:27:46 +0200 Subject: 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 --- src/readelf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/readelf.c') diff --git a/src/readelf.c b/src/readelf.c index 685d0b17..41933d95 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; -- cgit v1.2.1