This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: read stabs from files with no .data section
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.