summaryrefslogtreecommitdiff
path: root/gdb/solib-svr4.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r--gdb/solib-svr4.c94
1 files changed, 50 insertions, 44 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index b5cf617115d..d4335349790 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -79,9 +79,19 @@ static char *solib_break_names[] =
"r_debug_state",
"_r_debug_state",
"_dl_debug_state",
- "._dl_debug_state",
"rtld_db_dlactivity",
"_rtld_debug_state",
+
+ /* On the 64-bit PowerPC, the linker symbol with the same name as
+ the C function points to a function descriptor, not to the entry
+ point. The linker symbol whose name is the C function name
+ prefixed with a '.' points to the function's entry point. So
+ when we look through this table, we ignore symbols that point
+ into the data section (thus skipping the descriptor's symbol),
+ and eventually try this one, giving us the real entry point
+ address. */
+ "._dl_debug_state",
+
NULL
};
@@ -106,14 +116,16 @@ static char *main_name_list[] =
NULL
};
-/* Macro to extract an address from a solib structure.
- When GDB is configured for some 32-bit targets (e.g. Solaris 2.7
- sparc), BFD is configured to handle 64-bit targets, so CORE_ADDR is
- 64 bits. We have to extract only the significant bits of addresses
- to get the right address when accessing the core file BFD. */
+/* Macro to extract an address from a solib structure. When GDB is
+ configured for some 32-bit targets (e.g. Solaris 2.7 sparc), BFD is
+ configured to handle 64-bit targets, so CORE_ADDR is 64 bits. We
+ have to extract only the significant bits of addresses to get the
+ right address when accessing the core file BFD.
+
+ Assume that the address is unsigned. */
#define SOLIB_EXTRACT_ADDRESS(MEMBER) \
- extract_address (&(MEMBER), sizeof (MEMBER))
+ extract_unsigned_integer (&(MEMBER), sizeof (MEMBER))
/* local data declarations */
@@ -133,7 +145,9 @@ LM_NEXT (struct so_list *so)
{
struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
- return extract_address (so->lm_info->lm + lmo->l_next_offset, lmo->l_next_size);
+ /* Assume that the address is unsigned. */
+ return extract_unsigned_integer (so->lm_info->lm + lmo->l_next_offset,
+ lmo->l_next_size);
}
static CORE_ADDR
@@ -141,7 +155,9 @@ LM_NAME (struct so_list *so)
{
struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
- return extract_address (so->lm_info->lm + lmo->l_name_offset, lmo->l_name_size);
+ /* Assume that the address is unsigned. */
+ return extract_unsigned_integer (so->lm_info->lm + lmo->l_name_offset,
+ lmo->l_name_size);
}
static int
@@ -149,8 +165,9 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
{
struct link_map_offsets *lmo = SVR4_FETCH_LINK_MAP_OFFSETS ();
- return extract_address (so->lm_info->lm + lmo->l_prev_offset,
- lmo->l_prev_size) == 0;
+ /* Assume that the address is unsigned. */
+ return extract_unsigned_integer (so->lm_info->lm + lmo->l_prev_offset,
+ lmo->l_prev_size) == 0;
}
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
@@ -160,7 +177,7 @@ static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
static int match_main (char *);
-static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword);
+static CORE_ADDR bfd_lookup_symbol (bfd *, char *);
/*
@@ -170,7 +187,7 @@ static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword);
SYNOPSIS
- CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags)
+ CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname)
DESCRIPTION
@@ -179,15 +196,12 @@ static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword);
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)
+bfd_lookup_symbol (bfd *abfd, char *symname)
{
long storage_needed;
asymbol *sym;
@@ -208,8 +222,7 @@ bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags)
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
- if (STREQ (sym->name, symname)
- && (sym->section->flags & sect_flags) == sect_flags)
+ if (STREQ (sym->name, symname))
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
@@ -236,9 +249,7 @@ bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags)
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
-
- if (STREQ (sym->name, symname)
- && (sym->section->flags & sect_flags) == sect_flags)
+ if (STREQ (sym->name, symname))
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
@@ -344,7 +355,7 @@ look_for_base (int fd, CORE_ADDR baseaddr)
for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++)
{
- address = bfd_lookup_symbol (interp_bfd, *symbolp, 0);
+ address = bfd_lookup_symbol (interp_bfd, *symbolp);
if (address != 0)
{
break;
@@ -594,7 +605,8 @@ first_link_map_member (void)
read_memory (debug_base + lmo->r_map_offset, r_map_buf, lmo->r_map_size);
- lm = extract_address (r_map_buf, lmo->r_map_size);
+ /* Assume that the address is unsigned. */
+ lm = extract_unsigned_integer (r_map_buf, lmo->r_map_size);
/* FIXME: Perhaps we should validate the info somehow, perhaps by
checking r_version for a known version number, or r_state for
@@ -652,8 +664,9 @@ open_symbol_file_object (void *from_ttyp)
/* Read address of name from target memory to GDB. */
read_memory (lm + lmo->l_name_offset, l_name_buf, lmo->l_name_size);
- /* Convert the address to host format. */
- l_name = extract_address (l_name_buf, lmo->l_name_size);
+ /* Convert the address to host format. Assume that the address is
+ unsigned. */
+ l_name = extract_unsigned_integer (l_name_buf, lmo->l_name_size);
/* Free l_name_buf. */
do_cleanups (cleanups);
@@ -827,9 +840,9 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
/* Read address of name from target memory to GDB. */
read_memory (lm + lmo->l_name_offset, l_name_buf, lmo->l_name_size);
- /* Extract this object's name. */
- name_address = extract_address (l_name_buf,
- lmo->l_name_size);
+ /* Extract this object's name. Assume that the address is
+ unsigned. */
+ name_address = extract_unsigned_integer (l_name_buf, lmo->l_name_size);
target_read_string (name_address, &buffer,
SO_NAME_MAX_PATH_SIZE - 1, &errcode);
make_cleanup (xfree, buffer);
@@ -850,9 +863,10 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
return lm;
}
}
- /* Not the file we wanted, continue checking. */
- lm = extract_address (objfile_lm_info.lm + lmo->l_next_offset,
- lmo->l_next_size);
+ /* Not the file we wanted, continue checking. Assume that the
+ address is unsigned. */
+ lm = extract_unsigned_integer (objfile_lm_info.lm + lmo->l_next_offset,
+ lmo->l_next_size);
do_cleanups (old_chain);
}
return 0;
@@ -1022,8 +1036,7 @@ enable_break (void)
the current pc (which should point at the entry point for the
dynamic linker) and subtracting the offset of the entry point. */
if (!load_addr_found)
- load_addr = (read_pc ()
- - gdbarch_bfd_entry_point (current_gdbarch, tmp_bfd));
+ load_addr = read_pc () - tmp_bfd->start_address;
/* Record the relocated start and end address of the dynamic linker
text and plt section for svr4_in_dynsym_resolve_code. */
@@ -1047,16 +1060,7 @@ enable_break (void)
/* 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);
+ sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep);
if (sym_addr != 0)
break;
}
@@ -1462,6 +1466,8 @@ init_fetch_link_map_offsets (struct gdbarch *gdbarch)
static struct target_so_ops svr4_so_ops;
+extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */
+
void
_initialize_svr4_solib (void)
{