solib.c relocation improvements
This commit is contained in:
parent
0cf9d59bcb
commit
749499cbc4
4 changed files with 75 additions and 47 deletions
|
@ -1,3 +1,29 @@
|
||||||
|
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>
|
2000-10-30 Michael Snyder <msnyder@cleaver.cygnus.com>
|
||||||
|
|
||||||
* config/m68k/linux.mh: Remove solib.c, solib-svr4.c from NATDEPFILES.
|
* config/m68k/linux.mh: Remove solib.c, solib-svr4.c from NATDEPFILES.
|
||||||
|
|
|
@ -1567,12 +1567,20 @@ svr4_free_so (struct so_list *so)
|
||||||
free (so->lm_info);
|
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;
|
static struct target_so_ops svr4_so_ops;
|
||||||
|
|
||||||
void
|
void
|
||||||
_initialize_svr4_solib (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.free_so = svr4_free_so;
|
||||||
svr4_so_ops.clear_solib = svr4_clear_solib;
|
svr4_so_ops.clear_solib = svr4_clear_solib;
|
||||||
svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
|
svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
|
||||||
|
|
62
gdb/solib.c
62
gdb/solib.c
|
@ -180,9 +180,7 @@ solib_map_sections (PTR arg)
|
||||||
/* Relocate the section binding addresses as recorded in the shared
|
/* Relocate the section binding addresses as recorded in the shared
|
||||||
object's file by the base address to which the object was actually
|
object's file by the base address to which the object was actually
|
||||||
mapped. */
|
mapped. */
|
||||||
p->addr += TARGET_SO_LM_ADDR (so);
|
TARGET_SO_RELOCATE_SECTION_ADDRESSES (so, p);
|
||||||
p->endaddr += TARGET_SO_LM_ADDR (so);
|
|
||||||
so->lmend = max (p->endaddr, so->lmend);
|
|
||||||
if (STREQ (p->the_bfd_section->name, ".text"))
|
if (STREQ (p->the_bfd_section->name, ".text"))
|
||||||
{
|
{
|
||||||
so->textsection = p;
|
so->textsection = p;
|
||||||
|
@ -248,9 +246,6 @@ symbol_add_stub (PTR arg)
|
||||||
{
|
{
|
||||||
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
|
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
|
||||||
struct section_addr_info *sap;
|
struct section_addr_info *sap;
|
||||||
CORE_ADDR lowest_addr = 0;
|
|
||||||
int lowest_index;
|
|
||||||
asection *lowest_sect = NULL;
|
|
||||||
|
|
||||||
/* Have we already loaded this shared object? */
|
/* Have we already loaded this shared object? */
|
||||||
ALL_OBJFILES (so->objfile)
|
ALL_OBJFILES (so->objfile)
|
||||||
|
@ -259,35 +254,9 @@ symbol_add_stub (PTR arg)
|
||||||
return 1;
|
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,
|
sap = build_section_addr_info_from_section_table (so->sections,
|
||||||
so->sections_end);
|
so->sections_end);
|
||||||
|
|
||||||
sap->other[lowest_index].addr = lowest_addr;
|
|
||||||
|
|
||||||
so->objfile = symbol_file_add (so->so_name, so->from_tty,
|
so->objfile = symbol_file_add (so->so_name, so->from_tty,
|
||||||
sap, 0, OBJF_SHARED);
|
sap, 0, OBJF_SHARED);
|
||||||
free_section_addr_info (sap);
|
free_section_addr_info (sap);
|
||||||
|
@ -610,12 +579,17 @@ info_sharedlibrary_command (char *ignore, int from_tty)
|
||||||
}
|
}
|
||||||
|
|
||||||
printf_unfiltered ("%-*s", addr_width,
|
printf_unfiltered ("%-*s", addr_width,
|
||||||
local_hex_string_custom (
|
so->textsection != NULL
|
||||||
(unsigned long) TARGET_SO_LM_ADDR (so),
|
? local_hex_string_custom (
|
||||||
addr_fmt));
|
(unsigned long) so->textsection->addr,
|
||||||
|
addr_fmt)
|
||||||
|
: "");
|
||||||
printf_unfiltered ("%-*s", addr_width,
|
printf_unfiltered ("%-*s", addr_width,
|
||||||
local_hex_string_custom ((unsigned long) so->lmend,
|
so->textsection != NULL
|
||||||
addr_fmt));
|
? local_hex_string_custom (
|
||||||
|
(unsigned long) so->textsection->endaddr,
|
||||||
|
addr_fmt)
|
||||||
|
: "");
|
||||||
printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
|
printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
|
||||||
printf_unfiltered ("%s\n", so->so_name);
|
printf_unfiltered ("%s\n", so->so_name);
|
||||||
}
|
}
|
||||||
|
@ -640,10 +614,7 @@ info_sharedlibrary_command (char *ignore, int from_tty)
|
||||||
|
|
||||||
Provides a hook for other gdb routines to discover whether or
|
Provides a hook for other gdb routines to discover whether or
|
||||||
not a particular address is within the mapped address space of
|
not a particular address is within the mapped address space of
|
||||||
a shared library. Any address between the base mapping address
|
a shared library.
|
||||||
and the first address beyond the end of the last mapping, is
|
|
||||||
considered to be within the shared library address space, for
|
|
||||||
our purposes.
|
|
||||||
|
|
||||||
For example, this routine is called at one point to disable
|
For example, this routine is called at one point to disable
|
||||||
breakpoints which are in shared libraries that are not currently
|
breakpoints which are in shared libraries that are not currently
|
||||||
|
@ -657,8 +628,13 @@ solib_address (CORE_ADDR address)
|
||||||
|
|
||||||
for (so = so_list_head; so; so = so->next)
|
for (so = so_list_head; so; so = so->next)
|
||||||
{
|
{
|
||||||
if (TARGET_SO_LM_ADDR (so) <= address && address < so->lmend)
|
struct section_table *p;
|
||||||
return (so->so_name);
|
|
||||||
|
for (p = so->sections; p < so->sections_end; p++)
|
||||||
|
{
|
||||||
|
if (p->addr <= address && address < p->endaddr)
|
||||||
|
return (so->so_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
24
gdb/solist.h
24
gdb/solist.h
|
@ -54,7 +54,6 @@ struct so_list
|
||||||
are initialized when we actually add it to our symbol tables. */
|
are initialized when we actually add it to our symbol tables. */
|
||||||
|
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
CORE_ADDR lmend; /* upper addr bound of mapped object */
|
|
||||||
char symbols_loaded; /* flag: symbols read in yet? */
|
char symbols_loaded; /* flag: symbols read in yet? */
|
||||||
char from_tty; /* flag: print msgs? */
|
char from_tty; /* flag: print msgs? */
|
||||||
struct objfile *objfile; /* objfile for loaded lib */
|
struct objfile *objfile; /* objfile for loaded lib */
|
||||||
|
@ -65,12 +64,30 @@ struct so_list
|
||||||
|
|
||||||
struct target_so_ops
|
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);
|
void (*free_so) (struct so_list *so);
|
||||||
|
|
||||||
|
/* Reset or free private data structures not associated with
|
||||||
|
so_list entries. */
|
||||||
void (*clear_solib) (void);
|
void (*clear_solib) (void);
|
||||||
|
|
||||||
|
/* Target dependent code to run after child process fork. */
|
||||||
void (*solib_create_inferior_hook) (void);
|
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);
|
void (*special_symbol_handling) (void);
|
||||||
|
|
||||||
|
/* Construct a list of the currently loaded shared objects. */
|
||||||
struct so_list *(*current_sos) (void);
|
struct so_list *(*current_sos) (void);
|
||||||
|
|
||||||
|
/* Find, open, and read the symbols for the main executable. */
|
||||||
int (*open_symbol_file_object) (void *from_ttyp);
|
int (*open_symbol_file_object) (void *from_ttyp);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +96,8 @@ void free_so (struct so_list *so);
|
||||||
/* FIXME: gdbarch needs to control this variable */
|
/* FIXME: gdbarch needs to control this variable */
|
||||||
extern struct target_so_ops *current_target_so_ops;
|
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_FREE_SO (current_target_so_ops->free_so)
|
||||||
#define TARGET_SO_CLEAR_SOLIB (current_target_so_ops->clear_solib)
|
#define TARGET_SO_CLEAR_SOLIB (current_target_so_ops->clear_solib)
|
||||||
#define TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK \
|
#define TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK \
|
||||||
|
|
Loading…
Reference in a new issue