This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: solib: select symbols based on section flags
- From: Jim Blandy <jimb at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: 12 Jun 2003 16:19:45 -0500
- Subject: RFA: solib: select symbols based on section flags
2003-06-11 Jim Blandy <jimb@redhat.com>
* solib-svr4.c (bfd_lookup_symbol): New SECT_FLAGS argument.
(enable_break): Pass SEC_CODE as the SECT_FLAGS argument to
bfd_lookup_symbol, since we only want symbols in code sections.
(look_for_base): Pass zero as the SECT_FLAGS argument to
bfd_lookup_symbol, since we're not concerned about which section
the symbol is in.
Index: gdb/solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.33
diff -c -r1.33 solib-svr4.c
*** gdb/solib-svr4.c 1 Jun 2003 23:00:55 -0000 1.33
--- gdb/solib-svr4.c 11 Jun 2003 08:44:51 -0000
***************
*** 166,172 ****
static int match_main (char *);
! static CORE_ADDR bfd_lookup_symbol (bfd *, char *);
/*
--- 166,172 ----
static int match_main (char *);
! static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword);
/*
***************
*** 176,182 ****
SYNOPSIS
! CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname)
DESCRIPTION
--- 176,182 ----
SYNOPSIS
! CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags)
DESCRIPTION
***************
*** 185,196 ****
shared library support to find the address of the debugger
interface structures in the shared library.
Note that 0 is specifically allowed as an error return (no
such symbol).
*/
static CORE_ADDR
! bfd_lookup_symbol (bfd *abfd, char *symname)
{
long storage_needed;
asymbol *sym;
--- 185,199 ----
shared library support to find the address of the debugger
interface structures in the shared library.
+ If SECT_FLAGS is non-zero, only match symbols in sections whose
+ flags include all those in SECT_FLAGS.
+
Note that 0 is specifically allowed as an error return (no
such symbol).
*/
static CORE_ADDR
! bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags)
{
long storage_needed;
asymbol *sym;
***************
*** 211,217 ****
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
! if (STREQ (sym->name, symname))
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
--- 214,221 ----
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
! if (STREQ (sym->name, symname)
! && (sym->section->flags & sect_flags) == sect_flags)
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
***************
*** 238,244 ****
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
! if (STREQ (sym->name, symname))
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
--- 242,250 ----
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
!
! if (STREQ (sym->name, symname)
! && (sym->section->flags & sect_flags) == sect_flags)
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
***************
*** 344,350 ****
for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++)
{
! address = bfd_lookup_symbol (interp_bfd, *symbolp);
if (address != 0)
{
break;
--- 350,356 ----
for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++)
{
! address = bfd_lookup_symbol (interp_bfd, *symbolp, 0);
if (address != 0)
{
break;
***************
*** 1049,1055 ****
/* Now try to set a breakpoint in the dynamic linker. */
for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
{
! sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep);
if (sym_addr != 0)
break;
}
--- 1055,1070 ----
/* Now try to set a breakpoint in the dynamic linker. */
for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
{
! /* On ABI's that use function descriptors, there are usually
! two linker symbols associated with each C function: one
! pointing at the actual entry point of the machine code,
! and one pointing at the function's descriptor. The
! latter symbol has the same name as the C function.
!
! What we're looking for here is the machine code entry
! point, so we are only interested in symbols in code
! sections. */
! sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep, SEC_CODE);
if (sym_addr != 0)
break;
}