This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

PR 6832, DW_FORM_ref_addr vs. sec_info_ptr


Hi Nick,
  In PR 6832 comment #5, you said that updating stash->sec_info_ptr
after comp_unit_find_line would be wrong.  I reckon otherwise.  :-)

sec_info_ptr is used to find the start of the .debug_info section
containing the CU that comp_unit_find_line is investigating.  What CU
is that?  Well, it's the one that parse_comp_unit operated on.  So
sec_info_ptr ought to be left as it was at the start of
parse_comp_unit.  Since comp_unit_find_line uses the output of
parse_comp_unit, ie. previously parsed debug info, rather than firing
off parse_comp_unit itself to look at a new CU, I think the following
patch is required.

	PR 6832
	* dwarf2.c (find_line): Don't update stash->sec_info_ptr until
	after comp_unit_find_line call.

Index: bfd/dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.116
diff -u -p -r1.116 dwarf2.c
--- bfd/dwarf2.c	18 Nov 2008 14:05:00 -0000	1.116
+++ bfd/dwarf2.c	21 Jan 2009 07:59:24 -0000
@@ -3189,13 +3189,6 @@ find_line (bfd *abfd,
 	    break;
 	  stash->info_ptr += length;
 
-	  if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
-	      == stash->sec->size)
-	    {
-	      stash->sec = find_debug_info (stash->bfd, stash->sec);
-	      stash->sec_info_ptr = stash->info_ptr;
-	    }
-
 	  if (stash->all_comp_units)
 	    stash->all_comp_units->prev_unit = each;
 	  else
@@ -3225,6 +3218,14 @@ find_line (bfd *abfd,
 						     functionname_ptr,
 						     linenumber_ptr,
 						     stash));
+
+	  if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
+	      == stash->sec->size)
+	    {
+	      stash->sec = find_debug_info (stash->bfd, stash->sec);
+	      stash->sec_info_ptr = stash->info_ptr;
+	    }
+
 	  if (found)
 	    goto done;
 	}

-- 
Alan Modra
Australia Development Lab, IBM


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