This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA]: Fix bfd/dwarf2.c when compilation unit has no die


When using AS option -gdwarf2 and objdump option -S together, I found a
problem in bfd/dwarf2.c.  The .debug_info section generated by AS contains
one compilation unit and no die.  When we use _bfd_dwarf2_find_nearest_line(), 
the compilation unit is parsed and then the die it contains are parsed by

The problem is that the die are parsed even if there are none.  This results
in a random behavior because what follows the AS compilation unit can be anything.

The patch below fixes this problem by making sure we do not parse the die
when we reached the end of the compilation unit.

Can you approve this patch ?


2001-09-30  Stephane Carrez  <>

	* dwarf2.c (comp_unit_find_nearest_line): Check for end of
	compilation unit.
Index: dwarf2.c
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision
diff -u -p -r1.18.2.2 dwarf2.c
--- dwarf2.c	2001/06/11 10:04:08
+++ dwarf2.c	2001/09/30 09:26:29
@@ -1431,7 +1431,8 @@ comp_unit_find_nearest_line (unit, addr,
 	  return false;
-      if (! scan_unit_for_functions (unit))
+      if (unit->first_child_die_ptr < unit->end_ptr
+          && ! scan_unit_for_functions (unit))
 	  unit->error = 1;
 	  return false;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]