This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PING^2][PATCH] in_plt_section: support alternate stub section names
- From: Pedro Alves <palves at redhat dot com>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, Richard Sandiford <rdsandiford at googlemail dot com>, Catherine Moore <clm at codesourcery dot com>, binutils at sourceware dot org, gdb-patches at sourceware dot org
- Date: Thu, 20 Jun 2013 17:45:36 +0100
- Subject: Re: [PING^2][PATCH] in_plt_section: support alternate stub section names
- References: <alpine dot DEB dot 1 dot 10 dot 1302072108300 dot 6762 at tp dot orcam dot me dot uk> <87wqu19y1x dot fsf at fleche dot redhat dot com> <alpine dot DEB dot 1 dot 10 dot 1306201712420 dot 16287 at tp dot orcam dot me dot uk>
On 06/20/2013 05:19 PM, Maciej W. Rozycki wrote:
>
> return 0;
> Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c 2013-06-19 16:54:49.000000000 +0100
> +++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c 2013-06-19 16:55:00.280199593 +0100
> @@ -3628,12 +3628,7 @@ mips_stub_frame_sniffer (const struct fr
> if (in_plt_section (pc, NULL))
> return 1;
>
> - /* Binutils for MIPS puts lazy resolution stubs into .MIPS.stubs. */
> - s = find_pc_section (pc);
> -
> - if (s != NULL
> - && strcmp (bfd_get_section_name (s->objfile->obfd, s->the_bfd_section),
> - ".MIPS.stubs") == 0)
> + if (in_plt_section (pc, ".MIPS.stubs"))
> return 1;
Quite honestly, this looks like an odd API to me. If all
MIPS callers will have to pass in ".MIPS.stubs", then it just
looks like in_plt_section becomes a convenience for "is
pc in section.
It'd make more sense to me to refactor in_plt_section to
something like this, somewhere:
int
pc_in_section (CORE_ADDR pc, const char *name)
{
struct obj_section *s;
int retval = 0;
s = find_pc_section (pc);
retval = (s != NULL
&& s->the_bfd_section->name != NULL
&& strcmp (s->the_bfd_section->name, name) == 0);
return (retval);
}
And then:
/* In SVR4, we recognize a trampoline by it's section name.
That is, if the pc is in a section named ".plt" then we are in
a trampoline. */
int
in_plt_section (CORE_ADDR pc)
{
return pc_in_section (pc, ".plt");
}
And then MIPS would have somewhere, mips-tdep.c perhaps,
something like:
int
in_mips_stubs_section (CORE_ADDR pc)
{
return pc_in_section (pc, ".MIPS.stubs");
}
Or
#define MIPS_STUBS_SECTION ".MIPS.stubs"
pc_in_section (pc, MIPS_STUBS_SECTION);
As bonus, you end up with just one place that
can typo the section name.
Perhaps missed the plan to make in_plt_section fetch the
section name from elsewhere, instead of taking it as argument,
so callers in common code don't care?
--
Pedro Alves