Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: Tom Tromey <tromey@redhat.com>,
	       Richard Sandiford <rdsandiford@googlemail.com>,
	       Catherine Moore <clm@codesourcery.com>,
	binutils@sourceware.org,        gdb-patches@sourceware.org
Subject: Re: [PING^2][PATCH] in_plt_section: support alternate stub section names
Date: Thu, 20 Jun 2013 16:50:00 -0000	[thread overview]
Message-ID: <51C331B0.1010502@redhat.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1306201712420.16287@tp.orcam.me.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


  reply	other threads:[~2013-06-20 16:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19 20:44 [PATCH 1/2] MIPS: Compressed PLT/stubs support Maciej W. Rozycki
2013-02-19 20:45 ` [PATCH 2/2] MIPS: Compressed PLT/stubs support test cases Maciej W. Rozycki
2013-02-20 21:53 ` [PATCH 1/2] MIPS: Compressed PLT/stubs support Richard Sandiford
2013-03-09  4:04   ` Maciej W. Rozycki
2013-03-09  9:58     ` Richard Sandiford
2013-06-08  0:22       ` Maciej W. Rozycki
2013-06-08 16:04         ` Richard Sandiford
2013-06-10 17:13           ` Maciej W. Rozycki
2013-06-10 18:08             ` Richard Sandiford
2013-06-10 19:34               ` Maciej W. Rozycki
2013-06-25  0:40                 ` Maciej W. Rozycki
2013-03-11 13:53     ` Joel Brobecker
2013-06-26 15:02       ` Maciej W. Rozycki
2013-02-21 21:06 ` Tom Tromey
2013-02-22  0:58   ` Alan Modra
2013-02-22  6:06     ` Alan Modra
2013-02-22 20:09       ` Tom Tromey
2013-03-09  4:06         ` Maciej W. Rozycki
2013-06-20 16:20   ` [PING^2][PATCH] in_plt_section: support alternate stub section names (was: [PATCH 1/2] MIPS: Compressed PLT/stubs support) Maciej W. Rozycki
2013-06-20 16:50     ` Pedro Alves [this message]
2013-06-21 11:43       ` [PING^2][PATCH] in_plt_section: support alternate stub section names Maciej W. Rozycki
2013-06-21 15:34         ` Pedro Alves
2013-06-22  2:24           ` Maciej W. Rozycki
2013-06-24 12:40             ` Pedro Alves
2013-06-24 23:34               ` Maciej W. Rozycki
2013-06-25  9:57                 ` Pedro Alves
2013-06-07 13:25 ` [PATCH] in_plt_section: support alternate stub section names (was: [PATCH 1/2] MIPS: Compressed PLT/stubs support) Maciej W. Rozycki
2013-06-13 12:43   ` [PING][PATCH] " Maciej W. Rozycki

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=51C331B0.1010502@redhat.com \
    --to=palves@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=clm@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@codesourcery.com \
    --cc=rdsandiford@googlemail.com \
    --cc=tromey@redhat.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