Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* PATCH: read stabs from files with no .data section
@ 2003-09-08 19:28 Jim Blandy
  2003-09-09  3:30 ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2003-09-08 19:28 UTC (permalink / raw)
  To: gdb-patches


This fixes gdb/291, symtab/1241, and gdb/644.

2003-07-10  Jim Blandy  <jimb@redhat.com>

	* Makefile.in (dbxread.o): Note new dependency on $(gdb_assert_h).
	* dbxread.c: #include "gdb_assert.h".
	(read_dbx_symtab): If the objfile has no .data section, use the
	section index for the .bss section instead.

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.403
diff -c -r1.403 Makefile.in
*** gdb/Makefile.in	13 Jun 2003 15:28:29 -0000	1.403
--- gdb/Makefile.in	18 Jun 2003 06:18:15 -0000
***************
*** 1661,1667 ****
  	$(gdb_stat_h) $(symtab_h) $(breakpoint_h) $(target_h) $(gdbcore_h) \
  	$(libaout_h) $(symfile_h) $(objfiles_h) $(buildsym_h) $(stabsread_h) \
  	$(gdb_stabs_h) $(demangle_h) $(language_h) $(complaints_h) \
! 	$(cp_abi_h) $(aout_aout64_h) $(aout_stab_gnu_h)
  dcache.o: dcache.c $(defs_h) $(dcache_h) $(gdbcmd_h) $(gdb_string_h) \
  	$(gdbcore_h) $(target_h)
  delta68-nat.o: delta68-nat.c $(defs_h)
--- 1661,1667 ----
  	$(gdb_stat_h) $(symtab_h) $(breakpoint_h) $(target_h) $(gdbcore_h) \
  	$(libaout_h) $(symfile_h) $(objfiles_h) $(buildsym_h) $(stabsread_h) \
  	$(gdb_stabs_h) $(demangle_h) $(language_h) $(complaints_h) \
! 	$(cp_abi_h) $(aout_aout64_h) $(aout_stab_gnu_h) $(gdb_assert_h)
  dcache.o: dcache.c $(defs_h) $(dcache_h) $(gdbcmd_h) $(gdb_string_h) \
  	$(gdbcore_h) $(target_h)
  delta68-nat.o: delta68-nat.c $(defs_h)
Index: gdb/dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.48
diff -c -r1.48 dbxread.c
*** gdb/dbxread.c	11 Jun 2003 22:27:10 -0000	1.48
--- gdb/dbxread.c	18 Jun 2003 06:18:17 -0000
***************
*** 58,63 ****
--- 58,64 ----
  #include "language.h"		/* Needed for local_hex_string */
  #include "complaints.h"
  #include "cp-abi.h"
+ #include "gdb_assert.h"
  
  #include "aout/aout64.h"
  #include "aout/stab_gnu.h"	/* We always use GNU stabs, not native, now */
***************
*** 1304,1309 ****
--- 1305,1311 ----
    struct cleanup *back_to;
    bfd *abfd;
    int textlow_not_set;
+   int data_sect_index;
  
    /* Current partial symtab */
    struct partial_symtab *pst;
***************
*** 1355,1360 ****
--- 1357,1368 ----
    textlow_not_set = 1;
    has_line_numbers = 0;
  
+   /* If the objfile has no .data section, try using the .bss section.  */
+   data_sect_index = objfile->sect_index_data;
+   if (data_sect_index == -1)
+     data_sect_index = SECT_OFF_BSS (objfile);
+   gdb_assert (data_sect_index != -1);
+ 
    for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
      {
        /* Get the symbol for this run and pull out some info */
***************
*** 1401,1407 ****
  
  	  case N_DATA | N_EXT:
  	  case N_NBDATA | N_EXT:
! 	  nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
  	  goto record_it;
  
  	  case N_BSS:
--- 1409,1415 ----
  
  	  case N_DATA | N_EXT:
  	  case N_NBDATA | N_EXT:
! 	  nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
  	  goto record_it;
  
  	  case N_BSS:
***************
*** 1468,1474 ****
  	  continue;
  
  	  case N_DATA:
! 	  nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
  	  goto record_it;
  
  	  case N_UNDF | N_EXT:
--- 1476,1482 ----
  	  continue;
  
  	  case N_DATA:
! 	  nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
  	  goto record_it;
  
  	  case N_UNDF | N_EXT:
***************
*** 1757,1763 ****
  	  switch (p[1])
  	  {
  	  case 'S':
! 	    nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
  #ifdef STATIC_TRANSFORM_NAME
  	    namestring = STATIC_TRANSFORM_NAME (namestring);
  #endif
--- 1765,1771 ----
  	  switch (p[1])
  	  {
  	  case 'S':
! 	    nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
  #ifdef STATIC_TRANSFORM_NAME
  	    namestring = STATIC_TRANSFORM_NAME (namestring);
  #endif
***************
*** 1768,1774 ****
  				 psymtab_language, objfile);
  	    continue;
  	  case 'G':
! 	    nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
  	    /* The addresses in these entries are reported to be
  	       wrong.  See the code that reads 'G's for symtabs. */
  	    add_psymbol_to_list (namestring, p - namestring,
--- 1776,1782 ----
  				 psymtab_language, objfile);
  	    continue;
  	  case 'G':
! 	    nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
  	    /* The addresses in these entries are reported to be
  	       wrong.  See the code that reads 'G's for symtabs. */
  	    add_psymbol_to_list (namestring, p - namestring,


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: read stabs from files with no .data section
  2003-09-08 19:28 PATCH: read stabs from files with no .data section Jim Blandy
@ 2003-09-09  3:30 ` Andrew Cagney
  2003-09-09 17:47   ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-09-09  3:30 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

> +   /* If the objfile has no .data section, try using the .bss section.  */
> +   data_sect_index = objfile->sect_index_data;
> +   if (data_sect_index == -1)
> +     data_sect_index = SECT_OFF_BSS (objfile);
> +   gdb_assert (data_sect_index != -1);
> + 

So what happens if there is no .data and no .bss?

Andrew



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: read stabs from files with no .data section
  2003-09-09  3:30 ` Andrew Cagney
@ 2003-09-09 17:47   ` Jim Blandy
  2003-09-09 18:22     ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2003-09-09 17:47 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney <ac131313@redhat.com> writes:

> > +   /* If the objfile has no .data section, try using the .bss section.  */
> > +   data_sect_index = objfile->sect_index_data;
> > +   if (data_sect_index == -1)
> > +     data_sect_index = SECT_OFF_BSS (objfile);
> > +   gdb_assert (data_sect_index != -1);
> > +
> 
> So what happens if there is no .data and no .bss?

We lose.  Maybe this should fall through the .rodata, and then .text
section offsets, but I think it's still papering over the real
problem, which I don't know how to solve.

I think the correct behavior is to use the offset of the section
containing the variable.  Many of the old references to

  ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile))

that this patch changes were wrong, for this reason.

But to do the right thing, we'd need to look up the section by the
variable's unrelocated address, as with find_pc_section.  This would
be needed for every top-level variable, static and global, in the
speed-critical partial symtab construction pass.  I'm not sure that
kind of overhead would be welcome.

I'm certainly open to suggestions.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: read stabs from files with no .data section
  2003-09-09 17:47   ` Jim Blandy
@ 2003-09-09 18:22     ` Andrew Cagney
  2003-09-09 20:03       ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-09-09 18:22 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

> Andrew Cagney <ac131313@redhat.com> writes:
> 
> 
>> > +   /* If the objfile has no .data section, try using the .bss section.  */
>> > +   data_sect_index = objfile->sect_index_data;
>> > +   if (data_sect_index == -1)
>> > +     data_sect_index = SECT_OFF_BSS (objfile);
>> > +   gdb_assert (data_sect_index != -1);
>> > +
> 
>> 
>> So what happens if there is no .data and no .bss?
> 
> 
> We lose.  Maybe this should fall through the .rodata, and then .text
> section offsets, but I think it's still papering over the real
> problem, which I don't know how to solve.
> 
> I think the correct behavior is to use the offset of the section
> containing the variable.  Many of the old references to
> 
>   ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile))
> 
> that this patch changes were wrong, for this reason.
> 
> But to do the right thing, we'd need to look up the section by the
> variable's unrelocated address, as with find_pc_section.  This would
> be needed for every top-level variable, static and global, in the
> speed-critical partial symtab construction pass.  I'm not sure that
> kind of overhead would be welcome.

Ah.  Suggest adding a fixme describing this real problem to the code, 
and filing a bug report.

enjoy,
Andrew



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: read stabs from files with no .data section
  2003-09-09 18:22     ` Andrew Cagney
@ 2003-09-09 20:03       ` Jim Blandy
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Blandy @ 2003-09-09 20:03 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney <ac131313@redhat.com> writes:

> > Andrew Cagney <ac131313@redhat.com> writes:
> >
> >> > +   /* If the objfile has no .data section, try using the .bss section.  */
> >> > +   data_sect_index = objfile->sect_index_data;
> >> > +   if (data_sect_index == -1)
> >> > +     data_sect_index = SECT_OFF_BSS (objfile);
> >> > +   gdb_assert (data_sect_index != -1);
> >> > +
> >
> >> So what happens if there is no .data and no .bss?
> > We lose.  Maybe this should fall through the .rodata, and then .text
> > section offsets, but I think it's still papering over the real
> > problem, which I don't know how to solve.
> > I think the correct behavior is to use the offset of the section
> > containing the variable.  Many of the old references to
> >   ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile))
> > that this patch changes were wrong, for this reason.
> > But to do the right thing, we'd need to look up the section by the
> > variable's unrelocated address, as with find_pc_section.  This would
> > be needed for every top-level variable, static and global, in the
> > speed-critical partial symtab construction pass.  I'm not sure that
> > kind of overhead would be welcome.
> 
> Ah.  Suggest adding a fixme describing this real problem to the code,
> and filing a bug report.

Okay, will do.

The code should also try sect_index_rodata too, before giving up.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-09-09 20:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-08 19:28 PATCH: read stabs from files with no .data section Jim Blandy
2003-09-09  3:30 ` Andrew Cagney
2003-09-09 17:47   ` Jim Blandy
2003-09-09 18:22     ` Andrew Cagney
2003-09-09 20:03       ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox