+2000-10-30 Kevin Buettner <kevinb@redhat.com>
+
+ Changes based on analysis from Peter Schauer:
+ * solist.h (struct so_list): Remove field lmend.
+ (struct target_so_ops): Remove field lm_addr. Add field
+ relocate_section_addresses. Add comments for all fields
+ in this structure
+ (TARGET_SO_LM_ADDR): Remove.
+ (TARGET_SO_RELOCATE_SECTION_ADDRESSES): New macro.
+ * solib-svr4.c (svr4_relocate_section_addresses): New function.
+ (_initialize_svr4_solib): Remove lm_addr initialization. Add
+ initialization for relocate_section_addresses.
+ * solib.c (solib_map_sections): Invoke
+ TARGET_SO_RELOCATE_SECTION_ADDRESSES instead of using now
+ defunct TARGET_SO_LM_ADDR to relocate the section addresses.
+ Also, eliminate assignment to the lmend field since this
+ field no longer exists.
+ (symbol_add_stub): Remove machinery for determining the lowest
+ section.
+ (info_sharedlibrary_command): Print the text section starting
+ and ending addresses.
+ (solib_address): Don't use TARGET_SO_LM_ADDR, nor so->lmend to
+ determine if an address is in a shared object. Instead, scan
+ the section table and test against the starting and ending
+ addresses for each section.
+
2000-10-30 Michael Snyder <msnyder@cleaver.cygnus.com>
* config/m68k/linux.mh: Remove solib.c, solib-svr4.c from NATDEPFILES.
free (so->lm_info);
}
+static void
+svr4_relocate_section_addresses (struct so_list *so,
+ struct section_table *sec)
+{
+ sec->addr += LM_ADDR (so);
+ sec->endaddr += LM_ADDR (so);
+}
+
static struct target_so_ops svr4_so_ops;
void
_initialize_svr4_solib (void)
{
- svr4_so_ops.lm_addr = LM_ADDR;
+ svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;
svr4_so_ops.clear_solib = svr4_clear_solib;
svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
/* Relocate the section binding addresses as recorded in the shared
object's file by the base address to which the object was actually
mapped. */
- p->addr += TARGET_SO_LM_ADDR (so);
- p->endaddr += TARGET_SO_LM_ADDR (so);
- so->lmend = max (p->endaddr, so->lmend);
+ TARGET_SO_RELOCATE_SECTION_ADDRESSES (so, p);
if (STREQ (p->the_bfd_section->name, ".text"))
{
so->textsection = p;
{
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
struct section_addr_info *sap;
- CORE_ADDR lowest_addr = 0;
- int lowest_index;
- asection *lowest_sect = NULL;
/* Have we already loaded this shared object? */
ALL_OBJFILES (so->objfile)
return 1;
}
- /* Find the shared object's text segment. */
- if (so->textsection)
- {
- lowest_addr = so->textsection->addr;
- lowest_sect = bfd_get_section_by_name (so->abfd, ".text");
- lowest_index = lowest_sect->index;
- }
- else if (so->abfd != NULL)
- {
- /* If we didn't find a mapped non zero sized .text section, set
- up lowest_addr so that the relocation in symbol_file_add does
- no harm. */
- lowest_sect = bfd_get_section_by_name (so->abfd, ".text");
- if (lowest_sect == NULL)
- bfd_map_over_sections (so->abfd, find_lowest_section,
- (PTR) &lowest_sect);
- if (lowest_sect)
- {
- lowest_addr = bfd_section_vma (so->abfd, lowest_sect)
- + TARGET_SO_LM_ADDR (so);
- lowest_index = lowest_sect->index;
- }
- }
-
sap = build_section_addr_info_from_section_table (so->sections,
so->sections_end);
- sap->other[lowest_index].addr = lowest_addr;
-
so->objfile = symbol_file_add (so->so_name, so->from_tty,
sap, 0, OBJF_SHARED);
free_section_addr_info (sap);
}
printf_unfiltered ("%-*s", addr_width,
- local_hex_string_custom (
- (unsigned long) TARGET_SO_LM_ADDR (so),
- addr_fmt));
+ so->textsection != NULL
+ ? local_hex_string_custom (
+ (unsigned long) so->textsection->addr,
+ addr_fmt)
+ : "");
printf_unfiltered ("%-*s", addr_width,
- local_hex_string_custom ((unsigned long) so->lmend,
- addr_fmt));
+ so->textsection != NULL
+ ? local_hex_string_custom (
+ (unsigned long) so->textsection->endaddr,
+ addr_fmt)
+ : "");
printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
printf_unfiltered ("%s\n", so->so_name);
}
Provides a hook for other gdb routines to discover whether or
not a particular address is within the mapped address space of
- a shared library. Any address between the base mapping address
- and the first address beyond the end of the last mapping, is
- considered to be within the shared library address space, for
- our purposes.
+ a shared library.
For example, this routine is called at one point to disable
breakpoints which are in shared libraries that are not currently
for (so = so_list_head; so; so = so->next)
{
- if (TARGET_SO_LM_ADDR (so) <= address && address < so->lmend)
- return (so->so_name);
+ struct section_table *p;
+
+ for (p = so->sections; p < so->sections_end; p++)
+ {
+ if (p->addr <= address && address < p->endaddr)
+ return (so->so_name);
+ }
}
return (0);
are initialized when we actually add it to our symbol tables. */
bfd *abfd;
- CORE_ADDR lmend; /* upper addr bound of mapped object */
char symbols_loaded; /* flag: symbols read in yet? */
char from_tty; /* flag: print msgs? */
struct objfile *objfile; /* objfile for loaded lib */
struct target_so_ops
{
- CORE_ADDR (*lm_addr) (struct so_list *so);
+ /* Adjust the section binding addresses by the base address at
+ which the object was actually mapped. */
+ void (*relocate_section_addresses) (struct so_list *so,
+ struct section_table *);
+
+ /* Free the the link map info and any other private data
+ structures associated with a so_list entry. */
void (*free_so) (struct so_list *so);
+
+ /* Reset or free private data structures not associated with
+ so_list entries. */
void (*clear_solib) (void);
+
+ /* Target dependent code to run after child process fork. */
void (*solib_create_inferior_hook) (void);
+
+ /* Do additional symbol handling, lookup, etc. after symbols
+ for a shared object have been loaded. */
void (*special_symbol_handling) (void);
+
+ /* Construct a list of the currently loaded shared objects. */
struct so_list *(*current_sos) (void);
+
+ /* Find, open, and read the symbols for the main executable. */
int (*open_symbol_file_object) (void *from_ttyp);
};
/* FIXME: gdbarch needs to control this variable */
extern struct target_so_ops *current_target_so_ops;
-#define TARGET_SO_LM_ADDR (current_target_so_ops->lm_addr)
+#define TARGET_SO_RELOCATE_SECTION_ADDRESSES \
+ (current_target_so_ops->relocate_section_addresses)
#define TARGET_SO_FREE_SO (current_target_so_ops->free_so)
#define TARGET_SO_CLEAR_SOLIB (current_target_so_ops->clear_solib)
#define TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK \