This is the mail archive of the mailing list for the GDB 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]

[RFC] Propagate `has_section_at_zero' flag...

While working on mep-elf, I found that GDB behaved poorly when attempting
to use debug info contained in a separate (debug info only) file.  The
most obvious outward manifestation of this problem is that GDB frequently
(and repeatedly) outputs the following warning / error messages:

  warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)

I found that dwarf2_get_pc_bounds() was not correctly determining
the objfile bounds.  This was due to the fact that
dwarf2_per_objfile->has_section_at_zero was not being set correctly.

The `has_section_at_zero' flag is set in dwarf2_locate_sections():

  if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD)
      && bfd_section_vma (abfd, sectp) == 0)
    dwarf2_per_objfile->has_section_at_zero = 1;

The problem with the debug-info-only file is that it contains no
SEC_LOAD sections thus forcing that particular conjunct to always be
false.  Thus, the `has_section_at_zero' flag will *never* be set for
such a file.  (That is, a debug-info-only file.)  The sections which
would cause this flag to be set reside in the corresponding objfile
containing code and data which must be loaded for the program to

The most obvious place to (try to) fix this problem is in
dwarf2_has_info().  However, this turns out to be difficult since the
associations between the debug-info-only objfile and the corresponding
executable objfiles do not yet exist.  Moreover, it is not easy to
put these associations in place in time for the call to dwarf2_has_info().

I wound up modifying dwarf2_psymtab_to_symtab() so that when dealing
with a psymtab constructed from a debug-info-only objfile, the backlink
(to the stripped objfile) is followed.  The `has_section_at_zero' flag
is copied from that backlink to the objfile data associated with the
debug-info-only objfile.



	* dwarf2read.c (dwarf2_psymtab_to_symtab): Propagate
	`has_section_at_zero' flag from stripped objfile to separate,
	debug info only, objfile.

Index: dwarf2read.c
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.306
diff -u -p -r1.306 dwarf2read.c
--- dwarf2read.c	4 Jun 2009 12:28:39 -0000	1.306
+++ dwarf2read.c	5 Jun 2009 18:57:45 -0000
@@ -2541,6 +2541,19 @@ dwarf2_psymtab_to_symtab (struct partial
 	  dwarf2_per_objfile = objfile_data (pst->objfile,
+	  /* If this psymtab is constructed from a debug-only objfile, the
+	     has_section_at_zero flag will not necessarily be correct.  We
+	     can get the correct value for this flag by looking at the data
+	     associated with the (presumably stripped) associated objfile.  */
+	  if (pst->objfile->separate_debug_objfile_backlink)
+	    {
+	      struct dwarf2_per_objfile *dpo_backlink
+	        = objfile_data (pst->objfile->separate_debug_objfile_backlink,
+		                dwarf2_objfile_data_key);
+	      dwarf2_per_objfile->has_section_at_zero
+		= dpo_backlink->has_section_at_zero;
+	    }
 	  psymtab_to_symtab_1 (pst);
 	  /* Finish up the debug error message.  */

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