This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: Regression caused by elfread.c patch
- To: Todd Whitesel <toddpw at windriver dot com>, kingdon at redhat dot com (Jim Kingdon)
- Subject: Re: Regression caused by elfread.c patch
- From: "Amit S. Kale" <akale at veritas dot com>
- Date: Tue, 15 Feb 2000 13:56:11 +0530
- Cc: akale at veritas dot com, kettenis at wins dot uva dot nl, gdb at sourceware dot cygnus dot com, gdb-patches at sourceware dot cygnus dot com
- Organization: Veritas Software (India)
- References: <200002150800.AAA07477@alabama.wrs.com>
Hi,
On Tue, 15 Feb 2000, Jim Kingdon wrote:
> > That was because Jim didn't checkin my patch correctly.
> > He has fixed it now.
>
> No, this is a different problem.
Apolgies to Jim, because the problem was not his fault as said by me.
> I don't see how your patch could work at all - sym->section->index is
> a very different number than a SECT_OFF_* code. The SECT_OFF_* code
> (which gets fed to ANOFFSET) isn't computed until later in the
> function (via the call to record_minimal_symbol_and_info).
The patch I sent is working in some configurations. I have been using it for
debugging linux kernel. This patch was needed to load module object files using
'add-symbol-file' after loading kernel object file using 'symbol-file'.
I guess gdb first prepares text, data, bss segments and following code
bfd/section.c:bfd_make_section_anyway():
newsect->index = abfd->section_count++;
indicates that section->index contains SECT_OFF_* codes when segments are
loaded. This may not have been designed this way, but it seems to be that way.
Using sym->section->index is not right for segments that are not text or data
segments. Using sym->section->index should be all right for data segments.
I suggest following patch. I have verified that the vfprintf problem reported
by Mark does not appear with this patch. I haven't tested it with test suite.
--- elfread.c Tue Feb 15 13:54:52 2000
+++ ../../../utils/src/gdb/elfread.c Tue Feb 15 10:56:30 2000
@@ -293,14 +293,11 @@ elf_symtab_read (objfile, dynamic)
if (number_of_symbols < 0)
error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
+ /* FIXME: Should use section specific offset, not SECT_OFF_TEXT. */
+ offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
for (i = 0; i < number_of_symbols; i++)
{
sym = symbol_table[i];
- if (sym->section->flags & SEC_DATA) {
- offset = ANOFFSET (objfile->section_offsets, sym->section->index);
- } else {
- offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
- }
if (sym->name == NULL || *sym->name == '\0')
{
/* Skip names that don't exist (shouldn't happen), or names
On Tue, 15 Feb 2000, Todd Whitesel wrote:
> [snip]
> However, so few configurations (read: vxWorks and ??) actually use different
> offsets for, say, SECT_OFF_TEXT and SECT_OFF_DATA, that no one notices the
> problems with it. (We read relocatable .o files too, which is also rare.)
It won'd be rare when gdb will be used by more people to debug linux kernel
modules.
> [snip]
--
Amit Kale
Veritas Software ( http://www.veritas.com )