Re: [PING^2][PATCH] in_plt_section: support alternate stub section names

Maciej W. Rozycki
2013-06-21T23:32:54Z

On Fri, 21 Jun 2013, Pedro Alves wrote:

> > Well, I have focused here, perhaps mistakenly, on the intended use of the
> > call -- to determine whether the PC is in a dynamic function call
> > trampoline. Contrary to the description we currently have at
> > in_plt_section, .plt is not -- per SVR4 ABI -- a standard name of the
> > trampoline section. The name (and the presence of any such section in the
> > first place) is actually left to processor-specific ABI supplements.
> >
> > For many processors .plt has indeed been the choice, but for MIPS .plt
> > has only recently been added as an ABI extension. The original MIPS SVR4
> > processor-specific ABI supplement defined no specific section name to be
> > used for its .plt equivalent. I can't easily check what IRIX tools chose
> > for this section's name (if anything; in a final executable you can have
> > ELF segments whose contents are not mapped to any section). Binutils
> > chose .stubs long ago and more recently switched to .MIPS.stubs. This may
> > well be the same names IRIX used in different versions (compare .reginfo
> > vs .MIPS.options standard MIPS SVR4 psABI sections).
>
> Right, but extending in_plt_section torwards a general "in trampoline
> section" would imply to me hiding platform details underneath, through
> e.g., recording the section name in gdbarch, as calls in common
> code wouldn't known about such target details.

FWIW, this has been the original design of the internal API considered
here, that I excavated and quoted for the purpose of the original
submission:

http://sourceware.org/ml/gdb-patches/2013-06/msg00150.html

Not that we should repeat or maintain old mistakes, that is.

> > What I don't like is the extra call nesting for something that is otherwise
> > rather a trivial piece. I'm not that particularly fond of macros either.
> > How about this change then?
>
> static inline is fine with me. However, what I really dislike is the
> inclusion of solib-svr4.h in parts of the debugger that have nothing
> to do with SVR4, or even are implementing a different shared library
> support backend, like solib-frv.c solib-dsbt.c, solib-target.c, etc.
> That's really an abstraction violation, there bits have nothing to so
> with SVR4.

Umm, perhaps we have a file naming confusion in our sources or I am
missing something. The thing is all of the ELF stuff and its shared
library features such as the PLT are inherently SVR4 concepts. Now there
are I think two possible options -- either our solib-svr4.h stuff is not
entirely SVR4 and includes things beyond or we support some pre-SVR4
systems (SunOS perhaps?) that already included early ELF support. The
latter unfortunately I cannot comment on as I lack background information
here. So what's the story behind it?

> Clearly PLTs exist in the .plt section on multiple solib implementations,
> so I'd rather we keep in_plt_section somewhere central (leaving it in
> objfiles.h like where it is today is super fine with me).

That was actually what I implemented first before I realised this place
is too general for this stuff. While I believe all the binary formats we
support have the concept of sections, PLT is mostly if not exclusively ELF
(a.out shared libraries do not have it for sure; I can't comment on ECOFF
or XCOFF, but even if they have some PLT equivalent, its section name if
any is unlikely to be .plt).

That written, given that this patch is blocking a cascade of changes
finding the exactly right location for in_plt_section seems secondary to
me and the objfiles module is where it already resides. Moving it to
objfiles.h as a static inline function will already be some progress as it
won't be compiled in cases where it's not actually used (e.g. plain COFF).

So here's a version you've suggested. Even with this change applied we
can continue looking for a better place for in_plt_section.

> > +/* Return non-zero if PC is in the SVR4 procedure linkage table section. */
> > +static inline int
> > +in_plt_section (CORE_ADDR pc)
> > +{
> > + return pc_in_section (pc, ".plt");
> > +}
>
> ... and we can then just drop "SVR4" from its describing comment. Even
> Symbian has these.

SVR4-style perhaps then? I don't know how Symbian has been implemented
and how close to or far from a typical SVR4 system it is.

> > +/* Return non-zero if PC is in the MIPS SVR4 lazy-binding stub section. */
> > +static inline int
> > +in_mips_stubs_section (CORE_ADDR pc)
>
> GDB coding standards require an empty line between describing comment
> and function definition. (There's at least one more instance in
> the patch.)

That seems somewhat inconsistent to me where prototypes are intermixed in
a header with implementations, but I won't argue. ;)

While making this update I have noticed the NAME argument to
hppa_in_solib_call_trampoline can be removed. This argument used to be
unused already and with the change to in_plt_section being considered here
it's even more hopelessly useless (see the lone ultimate call site in
hppa_stub_unwind_sniffer).

OK to apply?

2013-06-21 Maciej W. Rozycki <macro@codesourcery.com>

gdb/
* objfiles.h (pc_in_section): New prototype.
(in_plt_section): Remove name argument, replace prototype with
static inline function.
* mips-tdep.h (in_mips_stubs_section): New function.
* hppa-tdep.h (gdbarch_tdep): Remove name argument of
in_solib_call_trampoline member.
(hppa_in_solib_call_trampoline): Remove name argument.
* objfiles.c (pc_in_section): New function.
(in_plt_section): Remove function.
* mips-linux-tdep.c (mips_linux_in_dynsym_stub): Call
in_mips_stubs_section. Remove name argument. Return 1 rather
than the low 16-bit halfword of any instruction examined.
(mips_linux_in_dynsym_resolve_code): Update
mips_linux_in_dynsym_stub call accordingly.
* mips-tdep.c (mips_stub_frame_sniffer): Use in_mips_stubs_section
rather than an equivalent hand-coded sequence.
* hppa-hpux-tdep.c (in_opd_section): Remove function.
(hppa32_hpux_in_solib_call_trampoline): Remove name argument.
(hppa64_hpux_in_solib_call_trampoline): Likewise.
(hppa64_hpux_find_global_pointer): Use pc_in_section rather than
in_opd_section.
* hppa-tdep.c (hppa_stub_unwind_sniffer): Remove name argument
on call to tdep->in_solib_call_trampoline.
(hppa_in_solib_call_trampoline): Remove name argument, update
according to in_plt_section change.
(hppa_skip_trampoline_code): Update according to in_plt_section
change.
* aarch64-tdep.c (aarch64_stub_unwind_sniffer): Likewise.
* arm-symbian-tdep.c (arm_symbian_skip_trampoline_code):
Likewise.
* arm-tdep.c (arm_stub_unwind_sniffer): Likewise.
* hppa-linux-tdep.c (hppa_linux_find_global_pointer): Likewise.
* hppabsd-tdep.c (hppabsd_find_global_pointer): Likewise.
* nios2-tdep.c (nios2_stub_frame_sniffer): Likewise.
* nto-tdep.c (nto_relocate_section_addresses): Likewise.
* s390-tdep.c (s390_stub_frame_sniffer): Likewise.
* sh-tdep.c (sh_stub_unwind_sniffer): Likewise.
* solib-dsbt.c (dsbt_in_dynsym_resolve_code): Likewise.
* solib-frv.c (frv_in_dynsym_resolve_code): Likewise.
* solib-svr4.c (svr4_in_dynsym_resolve_code): Likewise.
* solib-target.c (solib_target_in_dynsym_resolve_code): Likewise.
* sparc-tdep.c (sparc_analyze_prologue): Likewise.
* tic6x-tdep.c (tic6x_stub_unwind_sniffer): Likewise.

Maciej

gdb-mips-in-stubs-section.diff
Index: gdb-fsf-trunk-quilt/gdb/aarch64-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/aarch64-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/aarch64-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -1094,7 +1094,7 @@ aarch64_stub_unwind_sniffer (const struc
gdb_byte dummy[4];

addr_in_block = get_frame_address_in_block (this_frame);
- if (in_plt_section (addr_in_block, NULL)
+ if (in_plt_section (addr_in_block)
/* We also use the stub winder if the target memory is unreadable
to avoid having the prologue unwinder trying to read it. */
|| target_read_memory (get_frame_pc (this_frame), dummy, 4) != 0)
Index: gdb-fsf-trunk-quilt/gdb/arm-symbian-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/arm-symbian-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/arm-symbian-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -38,7 +38,7 @@ arm_symbian_skip_trampoline_code (struct
CORE_ADDR dest;
gdb_byte buf[4];

- if (!in_plt_section (pc, NULL))
+ if (!in_plt_section (pc))
return 0;

if (target_read_memory (pc, buf, 4) != 0)
Index: gdb-fsf-trunk-quilt/gdb/arm-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/arm-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/arm-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -2907,7 +2907,7 @@ arm_stub_unwind_sniffer (const struct fr
gdb_byte dummy[4];

addr_in_block = get_frame_address_in_block (this_frame);
- if (in_plt_section (addr_in_block, NULL)
+ if (in_plt_section (addr_in_block)
/* We also use the stub winder if the target memory is unreadable
to avoid having the prologue unwinder trying to read it. */
|| target_read_memory (get_frame_pc (this_frame), dummy, 4) != 0)
Index: gdb-fsf-trunk-quilt/gdb/hppa-hpux-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/hppa-hpux-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/hppa-hpux-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -65,28 +65,13 @@
extern void _initialize_hppa_hpux_tdep (void);
extern initialize_file_ftype _initialize_hppa_hpux_tdep;

-static int
-in_opd_section (CORE_ADDR pc)
-{
- 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, ".opd") == 0);
- return (retval);
-}
-
/* Return one if PC is in the call path of a trampoline, else return zero.

Note we return one for *any* call trampoline (long-call, arg-reloc), not
just shared library trampolines (import, export). */

static int
-hppa32_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
- CORE_ADDR pc, char *name)
+hppa32_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct bound_minimal_symbol minsym;
@@ -156,8 +141,7 @@ hppa32_hpux_in_solib_call_trampoline (st
}

static int
-hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
- CORE_ADDR pc, char *name)
+hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

@@ -798,7 +782,7 @@ hppa64_hpux_find_global_pointer (struct

faddr = value_as_address (function);

- if (in_opd_section (faddr))
+ if (pc_in_section (faddr, ".opd"))
{
target_read_memory (faddr, buf, sizeof (buf));
return extract_unsigned_integer (&buf[24], 8, byte_order);
Index: gdb-fsf-trunk-quilt/gdb/hppa-linux-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/hppa-linux-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/hppa-linux-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -356,7 +356,7 @@ hppa_linux_find_global_pointer (struct g
/* If the address is in the plt section, then the real function hasn't
yet been fixed up by the linker so we cannot determine the gp of
that function. */
- if (in_plt_section (faddr, NULL))
+ if (in_plt_section (faddr))
return 0;

faddr_sect = find_pc_section (faddr);
Index: gdb-fsf-trunk-quilt/gdb/hppa-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/hppa-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/hppa-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -2417,7 +2417,7 @@ hppa_stub_unwind_sniffer (const struct f

if (pc == 0
|| (tdep->in_solib_call_trampoline != NULL
- && tdep->in_solib_call_trampoline (gdbarch, pc, NULL))
+ && tdep->in_solib_call_trampoline (gdbarch, pc))
|| gdbarch_in_solib_return_trampoline (gdbarch, pc, NULL))
return 1;
return 0;
@@ -2855,13 +2855,12 @@ hppa_in_dyncall (CORE_ADDR pc)
}

int
-hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
- CORE_ADDR pc, char *name)
+hppa_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc)
{
unsigned int insn[HPPA_MAX_INSN_PATTERN_LEN];
struct unwind_table_entry *u;

- if (in_plt_section (pc, name) || hppa_in_dyncall (pc))
+ if (in_plt_section (pc) || hppa_in_dyncall (pc))
return 1;

/* The GNU toolchain produces linker stubs without unwind
@@ -2918,13 +2917,13 @@ hppa_skip_trampoline_code (struct frame_
/* fallthrough */
}

- if (in_plt_section (pc, NULL))
+ if (in_plt_section (pc))
{
pc = read_memory_typed_address (pc, func_ptr_type);

/* If the PLT slot has not yet been resolved, the target will be
the PLT stub. */
- if (in_plt_section (pc, NULL))
+ if (in_plt_section (pc))
{
/* Sanity check: are we pointing to the PLT stub? */
if (!hppa_match_insns (gdbarch, pc, hppa_plt_stub, insn))
Index: gdb-fsf-trunk-quilt/gdb/hppa-tdep.h
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/hppa-tdep.h 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/hppa-tdep.h 2013-06-21 21:35:57.141226418 +0100
@@ -90,11 +90,9 @@ struct gdbarch_tdep
CORE_ADDR (*find_global_pointer) (struct gdbarch *, struct value *);

/* For shared libraries, each call goes through a small piece of
- trampoline code in the ".plt", or equivalent, section.
- IN_SOLIB_CALL_TRAMPOLINE evaluates to nonzero if we are currently
- stopped in one of these. */
- int (*in_solib_call_trampoline) (struct gdbarch *gdbarch,
- CORE_ADDR pc, char *name);
+ trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE
+ evaluates to nonzero if we are currently stopped in one of these. */
+ int (*in_solib_call_trampoline) (struct gdbarch *gdbarch, CORE_ADDR pc);

/* For targets that support multiple spaces, we may have additional stubs
in the return path. These stubs are internal to the ABI, and users are
@@ -242,7 +240,7 @@ extern struct minimal_symbol *
extern struct hppa_objfile_private *hppa_init_objfile_priv_data (struct objfile *objfile);

extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
- CORE_ADDR pc, char *name);
+ CORE_ADDR pc);
extern CORE_ADDR hppa_skip_trampoline_code (struct frame_info *, CORE_ADDR pc);

#endif /* hppa-tdep.h */
Index: gdb-fsf-trunk-quilt/gdb/hppabsd-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/hppabsd-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/hppabsd-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -47,7 +47,7 @@ hppabsd_find_global_pointer (struct gdba
/* If the address is in the .plt section, then the real function
hasn't yet been fixed up by the linker so we cannot determine the
Global Pointer for that function. */
- if (in_plt_section (faddr, NULL))
+ if (in_plt_section (faddr))
return 0;

faddr_sec = find_pc_section (faddr);
Index: gdb-fsf-trunk-quilt/gdb/mips-linux-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-linux-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-linux-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -30,6 +30,7 @@
#include "trad-frame.h"
#include "tramp-frame.h"
#include "gdbtypes.h"
+#include "objfiles.h"
#include "solib.h"
#include "solib-svr4.h"
#include "solist.h"
@@ -666,25 +667,34 @@ mips_linux_core_read_description (struct

/* Check the code at PC for a dynamic linker lazy resolution stub.
- Because they aren't in the .plt section, we pattern-match on the
- code generated by GNU ld. They look like this:
+ GNU ld for MIPS has put lazy resolution stubs into a ".MIPS.stubs"
+ section uniformly since version 2.15. If the pc is in that section,
+ then we are in such a stub. Before that ".stub" was used in 32-bit
+ ELF binaries, however we do not bother checking for that since we
+ have never had and that case should be extremely rare these days.
+ Instead we pattern-match on the code generated by GNU ld. They look
+ like this:

lw t9,0x8010(gp)
addu t7,ra
jalr t9,ra
addiu t8,zero,INDEX

- (with the appropriate doubleword instructions for N64). Also
- return the dynamic symbol index used in the last instruction. */
+ (with the appropriate doubleword instructions for N64). As any lazy
+ resolution stubs in microMIPS binaries will always be in a
+ ".MIPS.stubs" section we only ever verify standard MIPS patterns. */

static int
-mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name)
+mips_linux_in_dynsym_stub (CORE_ADDR pc)
{
gdb_byte buf[28], *p;
ULONGEST insn, insn1;
int n64 = (mips_abi (target_gdbarch ()) == MIPS_ABI_N64);
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());

+ if (in_mips_stubs_section (pc))
+ return 1;
+
read_memory (pc - 12, buf, 28);

if (n64)
@@ -742,7 +752,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc,
return 0;
}

- return (insn & 0xffff);
+ return 1;
}

/* Return non-zero iff PC belongs to the dynamic linker resolution
@@ -756,9 +766,10 @@ mips_linux_in_dynsym_resolve_code (CORE_
if (svr4_in_dynsym_resolve_code (pc))
return 1;

- /* Pattern match for the stub. It would be nice if there were a
- more efficient way to avoid this check. */
- if (mips_linux_in_dynsym_stub (pc, NULL))
+ /* Likewise for the stubs. They live in the .MIPS.stubs section these
+ days, so we check if the PC is within, than fall back to a pattern
+ match. */
+ if (mips_linux_in_dynsym_stub (pc))
return 1;

return 0;
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -3625,15 +3625,7 @@ mips_stub_frame_sniffer (const struct fr
if (target_read_memory (get_frame_pc (this_frame), dummy, 4) != 0)
return 1;

- 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) || in_mips_stubs_section (pc))
return 1;

/* Calling a PIC function from a non-PIC function passes through a
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.h
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.h 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.h 2013-06-22 00:22:17.770414915 +0100
@@ -20,6 +20,8 @@
#ifndef MIPS_TDEP_H
#define MIPS_TDEP_H

+#include "objfiles.h"
+
struct gdbarch;

/* All the possible MIPS ABIs. */
@@ -187,4 +189,12 @@ extern void mips_write_pc (struct regcac
extern struct target_desc *mips_tdesc_gp32;
extern struct target_desc *mips_tdesc_gp64;

+/* Return non-zero if PC is in a MIPS SVR4 lazy-binding stub section. */
+
+static inline int
+in_mips_stubs_section (CORE_ADDR pc)
+{
+ return pc_in_section (pc, ".MIPS.stubs");
+}
+
#endif /* MIPS_TDEP_H */
Index: gdb-fsf-trunk-quilt/gdb/nios2-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/nios2-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/nios2-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -1324,7 +1324,7 @@ nios2_stub_frame_sniffer (const struct f
if (target_read_memory (get_frame_pc (this_frame), dummy, 4) != 0)
return 1;

- if (in_plt_section (pc, NULL))
+ if (in_plt_section (pc))
return 1;

return 0;
Index: gdb-fsf-trunk-quilt/gdb/nto-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/nto-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/nto-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -318,7 +318,7 @@ nto_relocate_section_addresses (struct s
int
nto_in_dynsym_resolve_code (CORE_ADDR pc)
{
- if (in_plt_section (pc, NULL))
+ if (in_plt_section (pc))
return 1;
return 0;
}
Index: gdb-fsf-trunk-quilt/gdb/objfiles.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/objfiles.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/objfiles.c 2013-06-21 21:35:57.141226418 +0100
@@ -1410,12 +1410,10 @@ find_pc_section (CORE_ADDR pc)
}

-/* 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. */
+/* Return non-zero if PC is in a section called NAME. */

int
-in_plt_section (CORE_ADDR pc, char *name)
+pc_in_section (CORE_ADDR pc, char *name)
{
struct obj_section *s;
int retval = 0;
@@ -1424,7 +1422,7 @@ in_plt_section (CORE_ADDR pc, char *name

retval = (s != NULL
&& s->the_bfd_section->name != NULL
- && strcmp (s->the_bfd_section->name, ".plt") == 0);
+ && strcmp (s->the_bfd_section->name, name) == 0);
return (retval);
}
\f
Index: gdb-fsf-trunk-quilt/gdb/objfiles.h
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/objfiles.h 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/objfiles.h 2013-06-22 00:20:15.760414815 +0100
@@ -495,7 +495,17 @@ extern int have_minimal_symbols (void);

extern struct obj_section *find_pc_section (CORE_ADDR pc);

-extern int in_plt_section (CORE_ADDR, char *);
+/* Return non-zero if PC is in a section called NAME. */
+extern int pc_in_section (CORE_ADDR, char *);
+
+/* Return non-zero if PC is in a SVR4-style procedure linkage table
+ section. */
+
+static inline int
+in_plt_section (CORE_ADDR pc)
+{
+ return pc_in_section (pc, ".plt");
+}

/* Keep a registry of per-objfile data-pointers required by other GDB
modules. */
Index: gdb-fsf-trunk-quilt/gdb/s390-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/s390-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/s390-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -2116,7 +2116,7 @@ s390_stub_frame_sniffer (const struct fr
have trapped due to an invalid function pointer call. We handle
the non-existing current function like a PLT stub. */
addr_in_block = get_frame_address_in_block (this_frame);
- if (in_plt_section (addr_in_block, NULL)
+ if (in_plt_section (addr_in_block)
|| s390_readinstruction (insn, get_frame_pc (this_frame)) < 0)
return 1;
return 0;
Index: gdb-fsf-trunk-quilt/gdb/sh-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/sh-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/sh-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -2036,7 +2036,7 @@ sh_stub_unwind_sniffer (const struct fra
CORE_ADDR addr_in_block;

addr_in_block = get_frame_address_in_block (this_frame);
- if (in_plt_section (addr_in_block, NULL))
+ if (in_plt_section (addr_in_block))
return 1;

return 0;
Index: gdb-fsf-trunk-quilt/gdb/solib-dsbt.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/solib-dsbt.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/solib-dsbt.c 2013-06-21 21:35:57.141226418 +0100
@@ -764,7 +764,7 @@ dsbt_in_dynsym_resolve_code (CORE_ADDR p

return ((pc >= info->interp_text_sect_low && pc < info->interp_text_sect_high)
|| (pc >= info->interp_plt_sect_low && pc < info->interp_plt_sect_high)
- || in_plt_section (pc, NULL));
+ || in_plt_section (pc));
}

/* Print a warning about being unable to set the dynamic linker
Index: gdb-fsf-trunk-quilt/gdb/solib-frv.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/solib-frv.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/solib-frv.c 2013-06-21 21:35:57.141226418 +0100
@@ -448,7 +448,7 @@ frv_in_dynsym_resolve_code (CORE_ADDR pc
{
return ((pc >= interp_text_sect_low && pc < interp_text_sect_high)
|| (pc >= interp_plt_sect_low && pc < interp_plt_sect_high)
- || in_plt_section (pc, NULL));
+ || in_plt_section (pc));
}

/* Given a loadmap and an address, return the displacement needed
Index: gdb-fsf-trunk-quilt/gdb/solib-svr4.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/solib-svr4.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/solib-svr4.c 2013-06-21 21:35:57.141226418 +0100
@@ -1532,7 +1532,7 @@ svr4_in_dynsym_resolve_code (CORE_ADDR p
&& pc < info->interp_text_sect_high)
|| (pc >= info->interp_plt_sect_low
&& pc < info->interp_plt_sect_high)
- || in_plt_section (pc, NULL)
+ || in_plt_section (pc)
|| in_gnu_ifunc_stub (pc));
}

Index: gdb-fsf-trunk-quilt/gdb/solib-target.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/solib-target.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/solib-target.c 2013-06-21 21:35:57.141226418 +0100
@@ -476,7 +476,7 @@ solib_target_in_dynsym_resolve_code (COR
/* We don't have a range of addresses for the dynamic linker; there
may not be one in the program's address space. So only report
PLT entries (which may be import stubs). */
- return in_plt_section (pc, NULL);
+ return in_plt_section (pc);
}

struct target_so_ops solib_target_so_ops;
Index: gdb-fsf-trunk-quilt/gdb/sparc-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/sparc-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/sparc-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -855,7 +855,7 @@ sparc_analyze_prologue (struct gdbarch *
dynamic linker patches up the first PLT with some code that
starts with a SAVE instruction. Patch up PC such that it points
at the start of our PLT entry. */
- if (tdep->plt_entry_size > 0 && in_plt_section (current_pc, NULL))
+ if (tdep->plt_entry_size > 0 && in_plt_section (current_pc))
pc = current_pc - ((current_pc - pc) % tdep->plt_entry_size);

insn = sparc_fetch_instruction (pc);
Index: gdb-fsf-trunk-quilt/gdb/tic6x-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/tic6x-tdep.c 2013-06-21 21:35:54.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/tic6x-tdep.c 2013-06-21 21:35:57.141226418 +0100
@@ -530,7 +530,7 @@ tic6x_stub_unwind_sniffer (const struct
CORE_ADDR addr_in_block;

addr_in_block = get_frame_address_in_block (this_frame);
- if (in_plt_section (addr_in_block, NULL))
+ if (in_plt_section (addr_in_block))
return 1;

return 0;