SOLIB_BKPT_NAME, /* Prefer configured name if it exists. */
#endif
"_start",
+ "__start",
"main",
NULL
};
if (inferior_sos)
{
/* Connected to a running target. Update our shared library table. */
- solib_add (NULL, 0, NULL);
+ solib_add (NULL, 0, NULL, auto_solib_add);
}
while (inferior_sos)
{
displacement = pc - bfd_get_start_address (exec_bfd);
changed = 0;
- new_offsets = xcalloc (sizeof (struct section_offsets),
- symfile_objfile->num_sections);
+ new_offsets = xcalloc (symfile_objfile->num_sections,
+ sizeof (struct section_offsets));
old_chain = make_cleanup (xfree, new_offsets);
for (i = 0; i < symfile_objfile->num_sections; i++)
xfree (so->lm_info);
}
+
+/* Clear any bits of ADDR that wouldn't fit in a target-format
+ data pointer. "Data pointer" here refers to whatever sort of
+ address the dynamic linker uses to manage its sections. At the
+ moment, we don't support shared libraries on any processors where
+ code and data pointers are different sizes.
+
+ This isn't really the right solution. What we really need here is
+ a way to do arithmetic on CORE_ADDR values that respects the
+ natural pointer/address correspondence. (For example, on the MIPS,
+ converting a 32-bit pointer to a 64-bit CORE_ADDR requires you to
+ sign-extend the value. There, simply truncating the bits above
+ TARGET_PTR_BIT, as we do below, is no good.) This should probably
+ be a new gdbarch method or something. */
+static CORE_ADDR
+svr4_truncate_ptr (CORE_ADDR addr)
+{
+ if (TARGET_PTR_BIT == sizeof (CORE_ADDR) * 8)
+ /* We don't need to truncate anything, and the bit twiddling below
+ will fail due to overflow problems. */
+ return addr;
+ else
+ return addr & (((CORE_ADDR) 1 << TARGET_PTR_BIT) - 1);
+}
+
+
static void
svr4_relocate_section_addresses (struct so_list *so,
struct section_table *sec)
{
- sec->addr += LM_ADDR (so);
- sec->endaddr += LM_ADDR (so);
+ sec->addr = svr4_truncate_ptr (sec->addr + LM_ADDR (so));
+ sec->endaddr = svr4_truncate_ptr (sec->endaddr + LM_ADDR (so));
}
+
/* Fetch a link_map_offsets structure for native targets using struct
definitions from link.h. See solib-legacy.c for the function
which does the actual work.
svr4_fetch_link_map_offsets (void)
{
struct link_map_offsets *(*flmo)(void) =
- gdbarch_data (fetch_link_map_offsets_gdbarch_data);
+ gdbarch_data (current_gdbarch, fetch_link_map_offsets_gdbarch_data);
if (flmo == NULL)
{
set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
}
-/* Initialize the architecture specific link_map_offsets fetcher.
- This is called after <arch>_gdbarch_init() has set up its struct
- gdbarch for the new architecture, so care must be taken to use the
- value set by set_solib_svr4_fetch_link_map_offsets(), above. We
- do, however, attempt to provide a reasonable alternative (for
- native targets anyway) if the <arch>_gdbarch_init() fails to call
+/* Initialize the architecture-specific link_map_offsets fetcher.
+ This is called after <arch>_gdbarch_init() has set up its `struct
+ gdbarch' for the new architecture, and is only called if the
+ link_map_offsets fetcher isn't already initialized (which is
+ usually done by calling set_solib_svr4_fetch_link_map_offsets()
+ above in <arch>_gdbarch_init()). Therefore we attempt to provide a
+ reasonable alternative (for native targets anyway) if the
+ <arch>_gdbarch_init() fails to call
set_solib_svr4_fetch_link_map_offsets(). */
static void *
init_fetch_link_map_offsets (struct gdbarch *gdbarch)
{
- struct link_map_offsets *(*flmo) =
- gdbarch_data (fetch_link_map_offsets_gdbarch_data);
-
- if (flmo == NULL)
- return legacy_fetch_link_map_offsets;
- else
- return flmo;
+ return legacy_fetch_link_map_offsets;
}
static struct target_so_ops svr4_so_ops;