[binutils-gdb] Fix CU overrun in scan_unit_for_symbols

Tom Tromey tromey@sourceware.org
Thu Aug 15 13:38:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=05192282ca19f8f5c201f630caed68b1632e2619

commit 05192282ca19f8f5c201f630caed68b1632e2619
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Aug 14 14:01:57 2019 -0600

    Fix CU overrun in scan_unit_for_symbols
    
    A customer program had a DWARF CU that consisted of just a CU DIE,
    without any children.  In this situation, scan_unit_for_symbols will
    try to read past the end of the current CU, and will take use the
    first bytes of the next CU as an abbrev, printing an error message.
    
    This patch fixes the bug by changing scan_unit_for_symbols to stop at
    the end of the CU rather than the end of the .debug_info section.
    
    bfd/ChangeLog
    2019-08-15  Tom Tromey  <tromey@adacore.com>
    
    	* dwarf2.c (scan_unit_for_symbols): Check for end of CU, not end
    	of section.

Diff:
---
 bfd/ChangeLog | 5 +++++
 bfd/dwarf2.c  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8a028cf..ad750bc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2019-08-15  Tom Tromey  <tromey@adacore.com>
+
+	* dwarf2.c (scan_unit_for_symbols): Check for end of CU, not end
+	of section.
+
 2019-08-14  Alan Modra  <amodra@gmail.com>
 
 	PR 24623
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 057fd91..d56244b 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -3072,7 +3072,7 @@ scan_unit_for_symbols (struct comp_unit *unit)
 {
   bfd *abfd = unit->abfd;
   bfd_byte *info_ptr = unit->first_child_die_ptr;
-  bfd_byte *info_ptr_end = unit->stash->info_ptr_end;
+  bfd_byte *info_ptr_end = unit->end_ptr;
   int nesting_level = 0;
   struct nest_funcinfo {
     struct funcinfo *func;



More information about the Binutils-cvs mailing list