#include <link.h>
#include <sys/param.h>
#include <fcntl.h>
-#include <a.out.h>
+
+#ifndef SVR4_SHARED_LIBS
+ /* SunOS shared libs need the nlist structure. */
+#include <a.out.h>
+#endif
#include "symtab.h"
#include "bfd.h"
#include "symfile.h"
+#include "objfiles.h"
#include "gdbcore.h"
#include "command.h"
#include "target.h"
struct objfile *objfile; /* objfile for loaded lib */
struct section_table *sections;
struct section_table *sections_end;
+ struct section_table *textsection;
};
static struct so_list *so_list_head; /* List of known shared objects */
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
+extern int
+fdmatch PARAMS ((int, int)); /* In libiberty */
+
/* Local function prototypes */
static void
disable_break PARAMS ((void));
static void
-info_sharedlibrary_command PARAMS ((void));
+info_sharedlibrary_command PARAMS ((char *, int));
static int
symbol_add_stub PARAMS ((char *));
static CORE_ADDR
locate_base PARAMS ((void));
+static void
+solib_map_sections PARAMS ((struct so_list *));
+
+#ifdef SVR4_SHARED_LIBS
+
static int
look_for_base PARAMS ((int, CORE_ADDR));
static CORE_ADDR
bfd_lookup_symbol PARAMS ((bfd *, char *));
-static void
-solib_map_sections PARAMS ((struct so_list *));
-
-#ifndef SVR4_SHARED_LIBS
+#else
static void
solib_add_common_symbols PARAMS ((struct rtc_symb *, struct objfile *));
p -> addr += (CORE_ADDR) LM_ADDR (so);
p -> endaddr += (CORE_ADDR) LM_ADDR (so);
so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
+ if (strcmp (p -> sec_ptr -> name, ".text") == 0)
+ {
+ so -> textsection = p;
+ }
}
}
#endif /* SVR4_SHARED_LIBS */
+#ifdef SVR4_SHARED_LIBS
+
/*
LOCAL FUNCTION
if (storage_needed > 0)
{
- symbol_table = (asymbol **) bfd_xmalloc (storage_needed);
- back_to = make_cleanup (free, symbol_table);
+ symbol_table = (asymbol **) xmalloc (storage_needed);
+ back_to = make_cleanup (free, (PTR)symbol_table);
number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
for (i = 0; i < number_of_symbols; i++)
return (1);
}
+#endif
+
/*
LOCAL FUNCTION
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
- (unsigned int) LM_ADDR (so), 0, 0, 0);
+ (unsigned int) so -> textsection -> addr,
+ 0, 0, 0);
return (1);
}
if (so -> so_name[0])
{
count = so -> sections_end - so -> sections;
- bcopy (so -> sections, (char *)(target -> to_sections + old),
- (sizeof (struct section_table)) * count);
+ (void) memcpy ((char *) (target -> to_sections + old),
+ so -> sections,
+ (sizeof (struct section_table)) * count);
old += count;
}
}
*/
static void
-info_sharedlibrary_command ()
+info_sharedlibrary_command (ignore, from_tty)
+ char *ignore;
+ int from_tty;
{
register struct so_list *so = NULL; /* link map state variable */
int header_done = 0;
{
if (so_list_head -> sections)
{
- free (so_list_head -> sections);
+ free ((PTR)so_list_head -> sections);
}
if (so_list_head -> so_bfd)
{
bfd_close (so_list_head -> so_bfd);
}
next = so_list_head -> next;
- free(so_list_head);
+ free((PTR)so_list_head);
so_list_head = next;
}
debug_base = 0;
enable_break ()
{
- int j;
-
#ifndef SVR4_SHARED_LIBS
+ int j;
int in_debugger;
-
+
/* Get link_dynamic structure */
j = target_read_memory (debug_base, (char *) &dynamic_copy,
void
solib_create_inferior_hook()
{
- CORE_ADDR debug_addr;
- int in_debugger;
- CORE_ADDR in_debugger_addr;
- CORE_ADDR breakpoint_addr;
- int i, j;
if ((debug_base = locate_base ()) == 0)
{
struct so_list *so;
{
#ifndef SVR4_SHARED_LIBS
+ int j;
+
+ if (debug_addr == 0)
+ {
+ /* Get link_dynamic structure */
+
+ j = target_read_memory (debug_base, (char *) &dynamic_copy,
+ sizeof (dynamic_copy));
+ if (j)
+ {
+ /* unreadable */
+ return;
+ }
+
+ /* Calc address of debugger interface structure */
+ /* FIXME, this needs work for cross-debugging of core files
+ (byteorder, size, alignment, etc). */
+
+ debug_addr = (CORE_ADDR) dynamic_copy.ldd;
+ }
/* Read the debugger structure from the inferior, just to make sure
we have a current copy. */
- read_memory (debug_addr, (char *) &debug_copy, sizeof (debug_copy));
+ j = target_read_memory (debug_addr, (char *) &debug_copy,
+ sizeof (debug_copy));
+ if (j)
+ return; /* unreadable */
/* Get common symbol definitions for the loaded object. */