From: Mark Kettenis <kettenis@wins.uva.nl>
To: jimb@zwingli.cygnus.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PING][RFA] Fall back on dynamic symtab in solib.c:bdf_lookup_symbol
Date: Mon, 07 Aug 2000 03:59:00 -0000 [thread overview]
Message-ID: <200008071059.e77AxPb00589@delius.kettenis.local> (raw)
In-Reply-To: <npog3ikmuy.fsf@zwingli.cygnus.com>
From: Jim Blandy <jimb@zwingli.cygnus.com>
Date: 28 Jul 2000 15:42:45 -0500
> I'm still looking for approval of the following patch:
>
> http://sources.redhat.com/ml/gdb-patches/2000-05/msg00318.html
>
> Mark
Sorry about the delay. If this causes no test suite failures, then
it's fine to commit it.
Checked in now.
Mark
From taylor@cygnus.com Mon Aug 07 07:26:00 2000
From: David Taylor <taylor@cygnus.com>
To: gdb-patches@sourceware.cygnus.com
Subject: [PATCH] bug in build_parse (parse.c)
Date: Mon, 07 Aug 2000 07:26:00 -0000
Message-id: <200008071425.KAA05946@texas.cygnus.com>
X-SW-Source: 2000-08/msg00138.html
Content-length: 2968
In build_parse, you'll find the lines:
num_std_regs = 0;
#ifdef PC_REGNUM
if (PC_REGNUM >= 0)
num_std_regs++;
#endif
#ifdef FP_REGNUM
if (FP_REGNUM >= 0)
num_std_regs++;
#endif
#ifdef SP_REGNUM
if (SP_REGNUM >= 0)
num_std_regs++;
#endif
#ifdef PS_REGNUM
if (PS_REGNUM >= 0)
num_std_regs++;
#endif
Notice how num_std_regs only gets incremented if {PC_REGNUM,
FP_REGNUM, SP_REGNUM, PS_REGNUM} is *BOTH* defined and >= 0.
/* create an empty table */
std_regs = xmalloc ((num_std_regs + 1) * sizeof *std_regs);
But notice how it gets filled in if it's defined, regardless of
whether it is >= 0 or not:
i = 0;
/* fill it in */
#ifdef PC_REGNUM
std_regs[i].name = "pc";
std_regs[i].regnum = PC_REGNUM;
i++;
#endif
#ifdef FP_REGNUM
std_regs[i].name = "fp";
std_regs[i].regnum = FP_REGNUM;
i++;
#endif
#ifdef SP_REGNUM
std_regs[i].name = "sp";
std_regs[i].regnum = SP_REGNUM;
i++;
#endif
#ifdef PS_REGNUM
std_regs[i].name = "ps";
std_regs[i].regnum = PS_REGNUM;
i++;
#endif
Thus, if one of more of them is defined (possibly because other parts
of GDB won't compile if it's not defined), but is defined as -1
(because the processor doesn't support it of there is no ABI or...),
then build_parse will write off the end of the std_regs array.
Ooops. Here's a patch to fix it:
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.8
diff -c -r1.8 parse.c
*** parse.c 2000/07/30 01:48:26 1.8
--- parse.c 2000/08/07 14:20:31
***************
*** 1331,1354 ****
i = 0;
/* fill it in */
#ifdef PC_REGNUM
! std_regs[i].name = "pc";
! std_regs[i].regnum = PC_REGNUM;
! i++;
#endif
#ifdef FP_REGNUM
! std_regs[i].name = "fp";
! std_regs[i].regnum = FP_REGNUM;
! i++;
#endif
#ifdef SP_REGNUM
! std_regs[i].name = "sp";
! std_regs[i].regnum = SP_REGNUM;
! i++;
#endif
#ifdef PS_REGNUM
! std_regs[i].name = "ps";
! std_regs[i].regnum = PS_REGNUM;
! i++;
#endif
memset (&std_regs[i], 0, sizeof (std_regs[i]));
}
--- 1331,1366 ----
i = 0;
/* fill it in */
#ifdef PC_REGNUM
! if (PC_REGNUM >= 0)
! {
! std_regs[i].name = "pc";
! std_regs[i].regnum = PC_REGNUM;
! i++;
! }
#endif
#ifdef FP_REGNUM
! if (FP_REGNUM >= 0)
! {
! std_regs[i].name = "fp";
! std_regs[i].regnum = FP_REGNUM;
! i++;
! }
#endif
#ifdef SP_REGNUM
! if (SP_REGNUM >= 0)
! {
! std_regs[i].name = "sp";
! std_regs[i].regnum = SP_REGNUM;
! i++;
! }
#endif
#ifdef PS_REGNUM
! if (PS_REGNUM >= 0)
! {
! std_regs[i].name = "ps";
! std_regs[i].regnum = PS_REGNUM;
! i++;
! }
#endif
memset (&std_regs[i], 0, sizeof (std_regs[i]));
}
From ezannoni@cygnus.com Mon Aug 07 08:03:00 2000
From: Elena Zannoni <ezannoni@cygnus.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Fix problem with missing .bss
Date: Mon, 07 Aug 2000 08:03:00 -0000
Message-id: <14734.53102.598696.678240@kwikemart.cygnus.com>
X-SW-Source: 2000-08/msg00139.html
Content-length: 8197
On Cygwin, sometimes the objfiles may not have a .bss section. In
this case, the sect_index_bss would be not valid (== -1) and the
SECT_OFF_BSS macro would trigger an internal error.
This patch fixes that problem. I am committing it now.
Elena
2000-08-07 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* objfiles.h (SECT_OFF_BSS): Don't detect invalid sect_index_bss
here, let the users of the macro do it.
* symtab.h (ANOFFSET): Detect here if the section index is not
initialized.
* xcoffread.c (find_targ_sec): Don't treat .bss as special,
because some objfiles may not have that section at all.
* coffread.c (cs_to_section): Ditto.
* elfread.c (elf_symtab_read): Detect an uninitialized index
value.
(elfstab_offset_sections): The macro ANOFFSET cannot be used as an
lvalue anymore.
* remote.c (get_offsets, remote_cisco_objfile_relocate): Don't use
ANOFFSET as an lvalue.
* objfiles.c (objfile_relocate, objfile_relocate): Don't use
ANOFFSET as an lvalue.
* symfile.c (default_symfile_offsets): Don't use ANOFFSET as an
lvalue.
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.10
diff -c -u -p -r1.10 coffread.c
--- coffread.c 2000/07/30 01:48:24 1.10
+++ coffread.c 2000/08/07 14:47:34
@@ -347,7 +347,8 @@ cs_to_section (struct coff_symbol *cs, s
else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
off = SECT_OFF_DATA (objfile);
else
- off = SECT_OFF_BSS (objfile);
+ /* Just return the bfd section index. */
+ off = sect->index;
}
return off;
}
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.10
diff -c -u -p -r1.10 elfread.c
--- elfread.c 2000/07/30 01:48:25 1.10
+++ elfread.c 2000/08/07 14:47:34
@@ -474,11 +474,16 @@ elf_symtab_read (struct objfile *objfile
(char *) filesym->name;
}
}
- if (sectinfo->sections[index] != 0)
- {
- complain (§ion_info_dup_complaint,
- sectinfo->filename);
+ if (index != -1)
+ {
+ if (sectinfo->sections[index] != 0)
+ {
+ complain (§ion_info_dup_complaint,
+ sectinfo->filename);
+ }
}
+ else
+ internal_error ("Section index uninitialized.");
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
/* Relocate non-absolute symbols by the section offset. */
@@ -486,7 +491,10 @@ elf_symtab_read (struct objfile *objfile
{
symaddr += offset;
}
- sectinfo->sections[index] = symaddr;
+ if (index != -1)
+ sectinfo->sections[index] = symaddr;
+ else
+ internal_error ("Section index uninitialized.");
/* The special local symbols don't go in the
minimal symbol table, so ignore this one. */
continue;
@@ -790,7 +798,7 @@ elfstab_offset_sections (struct objfile
pst->section_offsets = (struct section_offsets *)
obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
for (i = 0; i < SECT_OFF_MAX; i++)
- ANOFFSET (pst->section_offsets, i) = maybe->sections[i];
+ (pst->section_offsets)->offsets[i] = maybe->sections[i];
return;
}
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.8
diff -c -u -p -r1.8 objfiles.c
--- objfiles.c 2000/08/04 23:13:49 1.8
+++ objfiles.c 2000/08/07 14:47:35
@@ -520,7 +520,7 @@ objfile_relocate (struct objfile *objfil
int something_changed = 0;
for (i = 0; i < objfile->num_sections; ++i)
{
- ANOFFSET (delta, i) =
+ delta->offsets[i] =
ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i);
if (ANOFFSET (delta, i) != 0)
something_changed = 1;
@@ -639,7 +639,7 @@ objfile_relocate (struct objfile *objfil
{
int i;
for (i = 0; i < objfile->num_sections; ++i)
- ANOFFSET (objfile->section_offsets, i) = ANOFFSET (new_offsets, i);
+ (objfile->section_offsets)->offsets[i] = ANOFFSET (new_offsets, i);
}
{
Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.5
diff -c -u -p -r1.5 objfiles.h
--- objfiles.h 2000/05/28 01:12:28 1.5
+++ objfiles.h 2000/08/07 14:47:35
@@ -597,8 +597,9 @@ extern int is_in_import_list (char *, st
((objfile->sect_index_text == -1) ? \
(internal_error ("sect_index_text not initialized"), -1) : objfile->sect_index_text)
-#define SECT_OFF_BSS(objfile) \
- ((objfile->sect_index_bss == -1) ? \
- (internal_error ("sect_index_bss not initialized"), -1) : objfile->sect_index_bss)
+/* 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) */
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.18
diff -c -u -p -r1.18 remote.c
--- remote.c 2000/08/04 09:32:19 1.18
+++ remote.c 2000/08/07 14:47:36
@@ -1835,14 +1835,14 @@ get_offsets (void)
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_addr;
+ offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
/* This is a temporary kludge to force data and bss to use the same offsets
because that's what nlmconv does now. The real solution requires changes
to the stub and remote.c that I don't have time to do right now. */
- ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_addr;
- ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = data_addr;
+ offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr;
+ offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr;
objfile_relocate (symfile_objfile, offs);
}
@@ -1948,9 +1948,9 @@ remote_cisco_objfile_relocate (bfd_signe
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_off;
- ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_off;
- ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = bss_off;
+ offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_off;
+ offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_off;
+ offs->offsets[SECT_OFF_BSS (symfile_objfile)] = bss_off;
/* First call the standard objfile_relocate. */
objfile_relocate (symfile_objfile, offs);
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.16
diff -c -u -p -r1.16 symfile.c
--- symfile.c 2000/07/30 01:48:27 1.16
+++ symfile.c 2000/08/07 14:47:37
@@ -521,7 +521,7 @@ default_symfile_offsets (struct objfile
/* Record all sections in offsets */
/* The section_offsets in the objfile are here filled in using
the BFD index. */
- ANOFFSET (objfile->section_offsets, osp->sectindex) = osp->addr;
+ (objfile->section_offsets)->offsets[osp->sectindex] = osp->addr;
}
/* Remember the bfd indexes for the .text, .data, .bss and
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.12
diff -c -u -p -r1.12 symtab.h
--- symtab.h 2000/08/04 23:13:50 1.12
+++ symtab.h 2000/08/07 14:47:38
@@ -829,7 +829,9 @@ struct section_offsets
CORE_ADDR offsets[1]; /* As many as needed. */
};
-#define ANOFFSET(secoff, whichone) (secoff->offsets[whichone])
+#define ANOFFSET(secoff, whichone) \
+ ((whichone == -1) ? \
+ (internal_error ("Section index is uninitialized"), -1) : secoff->offsets[whichone])
/* The maximum possible size of a section_offsets table. */
prev parent reply other threads:[~2000-08-07 3:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200007270710.e6R7AjS00711@delius.kettenis.local>
2000-08-04 14:43 ` Jim Blandy
2000-08-07 3:59 ` Mark Kettenis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200008071059.e77AxPb00589@delius.kettenis.local \
--to=kettenis@wins.uva.nl \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@zwingli.cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox