This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFD] objfiles.h, symfile.c, mdebugread.c: Fixes for Digital Unix.
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFD] objfiles.h, symfile.c, mdebugread.c: Fixes for Digital Unix.
- From: "Peter.Schauer" <Peter dot Schauer at regent dot e-technik dot tu-muenchen dot de>
- Date: Sun, 5 Nov 2000 13:29:27 MET
I failed miserably when trying to run the testsuite on Digital Unix, due
to numerous internal GDB errors with uninitialized section indices.
We could hack symfile.c to account for the `small' sections being present
on ECOFF systems, or we could try to get it right in mdebugread.c,
with help from objfiles.h and symfile.c.
Below are patches for both approaches.
I am not sure if adding to sect_index_* and SECT_OFF_* is the way to go in
the general version, hiding those in obj_private might be feasible.
Comments, suggestions ?
Approach #1 (hack symfile.c):
*** ./symfile.c.orig Wed Oct 25 16:13:12 2000
--- ./symfile.c Thu Nov 2 17:14:16 2000
***************
*** 548,553 ****
--- 548,580 ----
if (sect)
objfile->sect_index_rodata = sect->index;
+ /* When using ECOFF, the linker puts out symbols like _end
+ with references to the .bss section and then removes the section,
+ because it is empty.
+ And the stabs reader is currently not aware of the presence of `small'
+ sections and fails if the `large' sections are optimized out by the
+ linker.
+ Work around the problem by trying to use the `small' versions of the
+ section indices in this case. */
+ if (objfile->sect_index_data < 0)
+ {
+ sect = bfd_get_section_by_name (objfile->obfd, ".sdata");
+ if (sect)
+ objfile->sect_index_data = sect->index;
+ else
+ {
+ /* Use .pdata for _fpdata symbol if .data and .sdata are missing. */
+ sect = bfd_get_section_by_name (objfile->obfd, ".pdata");
+ if (sect)
+ objfile->sect_index_data = sect->index;
+ }
+ }
+ if (objfile->sect_index_bss < 0)
+ {
+ sect = bfd_get_section_by_name (objfile->obfd, ".sbss");
+ if (sect)
+ objfile->sect_index_bss = sect->index;
+ }
}
/* Process a symbol file, as either the main file or as a dynamically
Approach #2 (more general solution):
*** ./mdebugread.c.orig Wed Oct 25 16:12:52 2000
--- ./mdebugread.c Wed Nov 1 11:57:29 2000
***************
*** 533,538 ****
--- 533,603 ----
/* Local utilities */
+ /* Get section index in section_offsets for section SC in objfile OBJFILE. */
+
+ int
+ sect_index_for_sc (struct objfile *objfile, unsigned int sc)
+ {
+ /* Unfortunately the linker puts out symbols like _end
+ with references to the .bss section and then removes the section,
+ because it is empty.
+ And the stabs reader is currently not aware of the presence of `small'
+ sections and fails if the `large' sections are optimized out by the
+ linker.
+ Work around the problem by trying to use the `small' versions of the
+ section indices in this case. */
+
+ switch (sc)
+ {
+ case scText:
+ return SECT_OFF_TEXT (objfile);
+ case scRConst:
+ return SECT_OFF_RCONST (objfile);
+ case scInit:
+ return SECT_OFF_INIT (objfile);
+ case scFini:
+ return SECT_OFF_FINI (objfile);
+ case scData:
+ if (objfile->sect_index_data < 0)
+ objfile->sect_index_data = objfile->sect_index_sdata;
+ return SECT_OFF_DATA (objfile);
+ case scPData:
+ return SECT_OFF_PDATA (objfile);
+ case scRData:
+ return SECT_OFF_RDATA (objfile);
+ case scSData:
+ return SECT_OFF_SDATA (objfile);
+ case scXData:
+ return SECT_OFF_XDATA (objfile);
+ case scBss:
+ if (objfile->sect_index_bss < 0)
+ objfile->sect_index_bss = objfile->sect_index_sbss;
+ return SECT_OFF_BSS (objfile);
+ case scSBss:
+ return SECT_OFF_SBSS (objfile);
+ case scAbs:
+ return -1;
+ }
+ internal_error ("mdebugread: unhandled section index %d", sc);
+ return -1;
+ }
+
+ /* Get offset for section SC from SECTION_OFFSETS in objfile OBJFILE. */
+
+ static CORE_ADDR
+ offset_for_sc (struct section_offsets *section_offsets,
+ struct objfile *objfile, unsigned int sc, char *name)
+ {
+ int sindex = sect_index_for_sc (objfile, sc);
+
+ if (sindex >= 0)
+ return ANOFFSET (section_offsets, sindex);
+
+ internal_error ("mdebugread: uninitialized section index %d for %s",
+ sc, name);
+ return 0;
+ }
+
/* Map of FDR indexes to partial symtabs */
struct pst_map
***************
*** 706,711 ****
--- 771,778 ----
{
case scText:
case scRConst:
+ case scInit:
+ case scFini:
/* Do not relocate relative values.
The value of a stEnd symbol is the displacement from the
corresponding start symbol value.
***************
*** 712,718 ****
The value of a stBlock symbol is the displacement from the
procedure address. */
if (sh->st != stEnd && sh->st != stBlock)
! sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
--- 779,785 ----
The value of a stBlock symbol is the displacement from the
procedure address. */
if (sh->st != stEnd && sh->st != stBlock)
! sh->value += offset_for_sc (section_offsets, objfile, sh->sc, name);
break;
case scData:
case scSData:
***************
*** 719,729 ****
case scRData:
case scPData:
case scXData:
- sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
- break;
case scBss:
case scSBss:
! sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
break;
}
--- 786,794 ----
case scRData:
case scPData:
case scXData:
case scBss:
case scSBss:
! sh->value += offset_for_sc (section_offsets, objfile, sh->sc, name);
break;
}
***************
*** 2408,2419 ****
{
case stProc:
/* Beginnning of Procedure */
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case stStaticProc:
/* Load time only static procs */
ms_type = mst_file_text;
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case stGlobal:
/* External symbol */
--- 2473,2486 ----
{
case stProc:
/* Beginnning of Procedure */
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
break;
case stStaticProc:
/* Load time only static procs */
ms_type = mst_file_text;
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
break;
case stGlobal:
/* External symbol */
***************
*** 2426,2437 ****
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_data;
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_bss;
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
}
else
ms_type = mst_abs;
--- 2493,2506 ----
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_data;
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_bss;
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
}
else
ms_type = mst_abs;
***************
*** 2441,2457 ****
if (SC_IS_TEXT (ext_in->asym.sc))
{
ms_type = mst_file_text;
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
}
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_file_data;
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_file_bss;
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
}
else
ms_type = mst_abs;
--- 2510,2529 ----
if (SC_IS_TEXT (ext_in->asym.sc))
{
ms_type = mst_file_text;
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
}
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_file_data;
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_file_bss;
! svalue += offset_for_sc (objfile->section_offsets, objfile,
! ext_in->asym.sc, name);
}
else
ms_type = mst_abs;
***************
*** 2471,2477 ****
complain (&unknown_ext_complaint, name);
}
if (!ECOFF_IN_ELF (cur_bfd))
! prim_record_minimal_symbol (name, svalue, ms_type, objfile);
}
/* Pass 3 over files, over local syms: fill in static symbols */
--- 2543,2551 ----
complain (&unknown_ext_complaint, name);
}
if (!ECOFF_IN_ELF (cur_bfd))
! prim_record_minimal_symbol_and_info (name, svalue, ms_type, NULL,
! sect_index_for_sc (objfile, ext_in->asym.sc),
! NULL, objfile);
}
/* Pass 3 over files, over local syms: fill in static symbols */
***************
*** 2583,2597 ****
CORE_ADDR procaddr;
long isym;
! sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (sh.st == stStaticProc)
{
- namestring = debug_info->ss + fh->issBase + sh.iss;
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_text,
NULL,
! SECT_OFF_TEXT (objfile),
NULL,
objfile);
}
--- 2657,2672 ----
CORE_ADDR procaddr;
long isym;
! namestring = debug_info->ss + fh->issBase + sh.iss;
! sh.value += offset_for_sc (objfile->section_offsets,
! objfile, sh.sc, namestring);
if (sh.st == stStaticProc)
{
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_text,
NULL,
! sect_index_for_sc (objfile, sh.sc),
NULL,
objfile);
}
***************
*** 2634,2659 ****
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
! sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_data,
NULL,
! SECT_OFF_DATA (objfile),
NULL,
objfile);
break;
! default:
! /* FIXME! Shouldn't this use cases for bss,
! then have the default be abs? */
namestring = debug_info->ss + fh->issBase + sh.iss;
! sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_bss,
NULL,
! SECT_OFF_BSS (objfile),
NULL,
objfile);
break;
--- 2709,2737 ----
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
! sh.value += offset_for_sc (objfile->section_offsets,
! objfile, sh.sc,
! namestring);
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_data,
NULL,
! sect_index_for_sc (objfile, sh.sc),
NULL,
objfile);
break;
! case scBss:
! case scSBss:
namestring = debug_info->ss + fh->issBase + sh.iss;
! sh.value += offset_for_sc (objfile->section_offsets,
! objfile, sh.sc,
! namestring);
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_bss,
NULL,
! sect_index_for_sc (objfile, sh.sc),
NULL,
objfile);
break;
***************
*** 2749,2758 ****
{
case scText:
case scRConst:
/* The value of a stEnd symbol is the displacement from the
corresponding start symbol value, do not relocate it. */
if (sh.st != stEnd)
! sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
--- 2827,2839 ----
{
case scText:
case scRConst:
+ case scInit:
+ case scFini:
/* The value of a stEnd symbol is the displacement from the
corresponding start symbol value, do not relocate it. */
if (sh.st != stEnd)
! sh.value += offset_for_sc (objfile->section_offsets,
! objfile, sh.sc, name);
break;
case scData:
case scSData:
***************
*** 2759,2769 ****
case scRData:
case scPData:
case scXData:
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
- break;
case scBss:
case scSBss:
! sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
break;
}
--- 2840,2849 ----
case scRData:
case scPData:
case scXData:
case scBss:
case scSBss:
! sh.value += offset_for_sc (objfile->section_offsets,
! objfile, sh.sc, name);
break;
}
***************
*** 2776,2782 ****
case stStaticProc:
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_text, NULL,
! SECT_OFF_TEXT (objfile), NULL,
objfile);
/* FALLTHROUGH */
--- 2856,2863 ----
case stStaticProc:
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_text, NULL,
! sect_index_for_sc (objfile, sh.sc),
! NULL,
objfile);
/* FALLTHROUGH */
***************
*** 2849,2861 ****
if (SC_IS_DATA (sh.sc))
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_data, NULL,
! SECT_OFF_DATA (objfile),
NULL,
objfile);
! else
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_bss, NULL,
! SECT_OFF_BSS (objfile),
NULL,
objfile);
class = LOC_STATIC;
--- 2930,2942 ----
if (SC_IS_DATA (sh.sc))
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_data, NULL,
! sect_index_for_sc (objfile, sh.sc),
NULL,
objfile);
! else if (SC_IS_BSS (sh.sc))
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_bss, NULL,
! sect_index_for_sc (objfile, sh.sc),
NULL,
objfile);
class = LOC_STATIC;
***************
*** 2956,2977 ****
continue;
svalue = psh->value;
switch (psh->sc)
{
case scText:
case scRConst:
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
- break;
case scBss:
case scSBss:
! svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
break;
}
--- 3037,3058 ----
continue;
svalue = psh->value;
+ name = debug_info->ssext + psh->iss;
switch (psh->sc)
{
case scText:
case scRConst:
! case scInit:
! case scFini:
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
case scBss:
case scSBss:
! svalue += offset_for_sc (objfile->section_offsets,
! objfile, psh->sc, name);
break;
}
***************
*** 3003,3009 ****
class = LOC_STATIC;
break;
}
- name = debug_info->ssext + psh->iss;
add_psymbol_to_list (name, strlen (name),
VAR_NAMESPACE, class,
&objfile->global_psymbols,
--- 3084,3089 ----
*** ./objfiles.h.orig Fri Sep 15 21:27:22 2000
--- ./objfiles.h Sat Oct 28 21:34:01 2000
***************
*** 380,388 ****
SOM version. */
int sect_index_text;
int sect_index_data;
! int sect_index_bss;
int sect_index_rodata;
/* These pointers are used to locate the section table, which
among other things, is used to map pc addresses into sections.
--- 380,396 ----
SOM version. */
int sect_index_text;
+ int sect_index_rconst;
+ int sect_index_init;
+ int sect_index_fini;
int sect_index_data;
! int sect_index_pdata;
! int sect_index_rdata;
int sect_index_rodata;
+ int sect_index_sdata;
+ int sect_index_xdata;
+ int sect_index_bss;
+ int sect_index_sbss;
/* These pointers are used to locate the section table, which
among other things, is used to map pc addresses into sections.
***************
*** 585,605 ****
ALL_OBJFILES (objfile) \
ALL_OBJFILE_OSECTIONS (objfile, osect)
#define SECT_OFF_DATA(objfile) \
((objfile->sect_index_data == -1) ? \
(internal_error ("sect_index_data not initialized"), -1) : objfile->sect_index_data)
#define SECT_OFF_RODATA(objfile) \
((objfile->sect_index_rodata == -1) ? \
(internal_error ("sect_index_rodata not initialized"), -1) : objfile->sect_index_rodata)
! #define SECT_OFF_TEXT(objfile) \
! ((objfile->sect_index_text == -1) ? \
! (internal_error ("sect_index_text not initialized"), -1) : objfile->sect_index_text)
/* Sometimes the .bss section is missing from the objfile, so we don't
want to die here. Let the users of SECT_OFF_BSS deal with an
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
#endif /* !defined (OBJFILES_H) */
--- 593,645 ----
ALL_OBJFILES (objfile) \
ALL_OBJFILE_OSECTIONS (objfile, osect)
+ #define SECT_OFF_TEXT(objfile) \
+ ((objfile->sect_index_text == -1) ? \
+ (internal_error ("sect_index_text not initialized"), -1) : objfile->sect_index_text)
+
+ #define SECT_OFF_RCONST(objfile) \
+ ((objfile->sect_index_rconst == -1) ? \
+ (internal_error ("sect_index_rconst not initialized"), -1) : objfile->sect_index_rconst)
+
+ #define SECT_OFF_INIT(objfile) \
+ ((objfile->sect_index_init == -1) ? \
+ (internal_error ("sect_index_init not initialized"), -1) : objfile->sect_index_init)
+
+ #define SECT_OFF_FINI(objfile) \
+ ((objfile->sect_index_fini == -1) ? \
+ (internal_error ("sect_index_fini not initialized"), -1) : objfile->sect_index_fini)
+
#define SECT_OFF_DATA(objfile) \
((objfile->sect_index_data == -1) ? \
(internal_error ("sect_index_data not initialized"), -1) : objfile->sect_index_data)
+ #define SECT_OFF_PDATA(objfile) \
+ ((objfile->sect_index_pdata == -1) ? \
+ (internal_error ("sect_index_pdata not initialized"), -1) : objfile->sect_index_pdata)
+
+ #define SECT_OFF_RDATA(objfile) \
+ ((objfile->sect_index_rdata == -1) ? \
+ (internal_error ("sect_index_rdata not initialized"), -1) : objfile->sect_index_rdata)
+
#define SECT_OFF_RODATA(objfile) \
((objfile->sect_index_rodata == -1) ? \
(internal_error ("sect_index_rodata not initialized"), -1) : objfile->sect_index_rodata)
! #define SECT_OFF_SDATA(objfile) \
! ((objfile->sect_index_sdata == -1) ? \
! (internal_error ("sect_index_sdata not initialized"), -1) : objfile->sect_index_sdata)
+ #define SECT_OFF_XDATA(objfile) \
+ ((objfile->sect_index_xdata == -1) ? \
+ (internal_error ("sect_index_xdata not initialized"), -1) : objfile->sect_index_xdata)
+
/* Sometimes the .bss section is missing from the objfile, so we don't
want to die here. Let the users of SECT_OFF_BSS deal with an
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
+ #define SECT_OFF_SBSS(objfile) \
+ ((objfile->sect_index_sbss == -1) ? \
+ (internal_error ("sect_index_sbss not initialized"), -1) : objfile->sect_index_sbss)
+
#endif /* !defined (OBJFILES_H) */
*** ./symfile.c.orig Wed Oct 25 16:13:12 2000
--- ./symfile.c Sat Oct 28 21:34:48 2000
***************
*** 535,552 ****
sect = bfd_get_section_by_name (objfile->obfd, ".text");
if (sect)
objfile->sect_index_text = sect->index;
sect = bfd_get_section_by_name (objfile->obfd, ".data");
if (sect)
objfile->sect_index_data = sect->index;
sect = bfd_get_section_by_name (objfile->obfd, ".bss");
if (sect)
objfile->sect_index_bss = sect->index;
!
! sect = bfd_get_section_by_name (objfile->obfd, ".rodata");
if (sect)
! objfile->sect_index_rodata = sect->index;
}
--- 535,575 ----
sect = bfd_get_section_by_name (objfile->obfd, ".text");
if (sect)
objfile->sect_index_text = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".rconst");
+ if (sect)
+ objfile->sect_index_rconst = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".init");
+ if (sect)
+ objfile->sect_index_init = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".fini");
+ if (sect)
+ objfile->sect_index_fini = sect->index;
sect = bfd_get_section_by_name (objfile->obfd, ".data");
if (sect)
objfile->sect_index_data = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".pdata");
+ if (sect)
+ objfile->sect_index_pdata = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".rdata");
+ if (sect)
+ objfile->sect_index_rdata = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".rodata");
+ if (sect)
+ objfile->sect_index_rodata = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".sdata");
+ if (sect)
+ objfile->sect_index_sdata = sect->index;
+ sect = bfd_get_section_by_name (objfile->obfd, ".xdata");
+ if (sect)
+ objfile->sect_index_xdata = sect->index;
sect = bfd_get_section_by_name (objfile->obfd, ".bss");
if (sect)
objfile->sect_index_bss = sect->index;
! sect = bfd_get_section_by_name (objfile->obfd, ".sbss");
if (sect)
! objfile->sect_index_sbss = sect->index;
}
--
Peter Schauer pes@regent.e-technik.tu-muenchen.de