From ead291d4c3651415005fa289491c30e0526a4601 Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Sat, 2 Oct 1993 23:09:51 +0000 Subject: [PATCH] * Makefile.in, coff-solib.c, coff-solib.h, i386lynx.mt, tm-i386lynx.h: Add support for SVR3 COFF shared libraries. --- gdb/.Sanitize | 2 + gdb/ChangeLog | 5 ++ gdb/Makefile.in | 13 ++-- gdb/coff-solib.c | 119 ++++++++++++++++++++++++++++++++++ gdb/coff-solib.h | 60 +++++++++++++++++ gdb/config/i386/i386lynx.mt | 2 +- gdb/config/i386/tm-i386lynx.h | 2 + 7 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 gdb/coff-solib.c create mode 100644 gdb/coff-solib.h diff --git a/gdb/.Sanitize b/gdb/.Sanitize index e312dca42c..52cdcb084f 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -63,6 +63,8 @@ ch-lang.c ch-lang.h ch-typeprint.c ch-valprint.c +coff-solib.c +coff-solib.h coffread.c command.c command.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8d2c0d2aa4..c103c50d7d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +Sat Oct 2 16:05:22 1993 Stu Grossman (grossman at cygnus.com) + + * Makefile.in, coff-solib.c, coff-solib.h, i386lynx.mt, + tm-i386lynx.h: Add support for SVR3 COFF shared libraries. + Sat Oct 2 15:50:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com) * m88k-nat.c (store_inferior_registers): When writing all registers, diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 5825936071..5bec5ff52c 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -387,7 +387,7 @@ POSSLIBS = regex.c regex.h # Subdirectories of gdb, which should be included in their entirety in # gdb-xxx.tar.Z: -TARDIRS = doc sparclite +TARDIRS = doc gdbserver sparclite # {X,T,NAT}DEPFILES are something of a pain in that it's hard to # default their values the way we do for SER_HARDWIRE; in the future @@ -803,14 +803,15 @@ unexport CHILLFLAGS CHILL_LIB CHILL_FOR_TARGET : ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \ a29k-pinsn.c a29k-tdep.c a68v-nat.c altos-xdep.c arm-convert.s \ - arm-pinsn.c arm-tdep.c arm-xdep.c convex-pinsn.c convex-tdep.c \ + arm-pinsn.c arm-tdep.c arm-xdep.c coff-solib.c convex-pinsn.c + convex-tdep.c \ convex-xdep.c core-svr4.c coredep.c corelow.c dcache.c delta68-nat.c \ dpx2-nat.c exec.c fork-child.c \ go32-xdep.c gould-pinsn.c gould-xdep.c h8300-tdep.c h8500-tdep.c \ hp300ux-nat.c hppa-pinsn.c hppa-tdep.c hppab-nat.c hppah-nat.c \ i386-pinsn.c i386-tdep.c i386b-nat.c i386mach-nat.c i386v-nat.c \ - i386aix-nat.c i386v4-nat.c i386lynx-nat.c i387-tdep.c i960-pinsn.c \ - i960-tdep.c \ + i386aix-nat.c i386v4-nat.c i386lynx-nat.c i386lynx-tdep.c i387-tdep.c \ + i960-pinsn.c i960-tdep.c \ infptrace.c inftarg.c irix4-nat.c isi-xdep.c m68k-pinsn.c m68k-tdep.c \ m88k-nat.c m88k-pinsn.c m88k-tdep.c mips-nat.c mips-pinsn.c \ mips-tdep.c news-xdep.c nindy-share/Onindy.c nindy-share/nindy.c \ @@ -987,6 +988,8 @@ ch-typeprint.o: ch-typeprint.c ch-lang.h $(defs_h) $(expression_h) \ ch-valprint.o: ch-valprint.c $(defs_h) $(expression_h) $(gdbtypes_h) \ language.h $(symtab_h) valprint.h $(value_h) +coff-solib.o: coff-solib.c $(defs_h) + coffread.o: coffread.c $(bfd_h) $(breakpoint_h) buildsym.h \ complaints.h $(defs_h) $(expression_h) $(gdbtypes_h) objfiles.h \ symfile.h $(symtab_h) @@ -1082,6 +1085,8 @@ hppah-nat.o: hppah-nat.c $(bfd_h) $(defs_h) $(inferior_h) target.h i386-pinsn.o: i386-pinsn.c $(bfd_h) $(dis-asm_h) $(defs_h) i386-tdep.o: i386-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) target.h i386b-nat.o: i386b-nat.c $(defs_h) +i386lynx-nat.o: i386lynx-nat.c $(defs_h) $(frame_h) $(inferior_h) target.h +i386lynx-tdep.o: i386lynx-tdep.c $(defs_h) $(inferior_h) target.h i386mach-nat.o: i386mach-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) i386v-nat.o: i386v-nat.c $(ieee-float_h) $(defs_h) $(gdbcore_h) \ diff --git a/gdb/coff-solib.c b/gdb/coff-solib.c new file mode 100644 index 0000000000..d6ea6455ac --- /dev/null +++ b/gdb/coff-solib.c @@ -0,0 +1,119 @@ +/* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger. + Copyright 1993 Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +#include "defs.h" + +#include "bfd.h" +#include "gdbcore.h" +#include "symtab.h" + +/* + +GLOBAL FUNCTION + + coff_solib_add -- add a shared library files to the symtab list. We + examine the `.lib' section of the exec file and determine the names of + the shared libraries. + + This function is responsible for discovering those names and + addresses, and saving sufficient information about them to allow + their symbols to be read at a later time. + +SYNOPSIS + + void coff_solib_add (char *arg_string, int from_tty, + struct target_ops *target) + +DESCRIPTION + +*/ + +void +coff_solib_add (arg_string, from_tty, target) + char *arg_string; + int from_tty; + struct target_ops *target; +{ + asection *libsect; + + libsect = bfd_get_section_by_name (exec_bfd, ".lib"); + + if (libsect) + { + int libsize; + unsigned char *lib; + struct libent + { + long len; + long unk; + char filename[1]; + }; + + libsize = bfd_section_size (exec_bfd, libsect); + + lib = alloca (libsize); + + bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize); + + while (libsize > 0) + { + struct libent *ent; + struct objfile *objfile; + + ent = (struct libent *)lib; + + if (ent->len <= 0) + break; + + objfile = symbol_file_add (ent->filename, from_tty, + 0, /* addr */ + 0, /* not mainline */ + 0, /* not mapped */ + 0); /* Not readnow */ + libsize -= ent->len * 4; + lib += ent->len * 4; + } + } +} + +/* + +GLOBAL FUNCTION + + coff_solib_create_inferior_hook -- shared library startup support + +SYNOPSIS + + void coff_solib_create_inferior_hook() + +DESCRIPTION + + When gdb starts up the inferior, the kernel maps in the shared + libraries. We get here with the target stopped at it's first + instruction, and the libraries already mapped. At this point, this + function gets called via expansion of the macro + SOLIB_CREATE_INFERIOR_HOOK. + */ + +void +coff_solib_create_inferior_hook() +{ + coff_solib_add ((char *) 0, 0, (struct target_ops *) 0); +} diff --git a/gdb/coff-solib.h b/gdb/coff-solib.h new file mode 100644 index 0000000000..5aaf71ff25 --- /dev/null +++ b/gdb/coff-solib.h @@ -0,0 +1,60 @@ +/* COFF (SVR3) Shared library declarations for GDB, the GNU Debugger. + Copyright (C) 1992 Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef __STDC__ /* Forward decl's for prototypes */ +struct target_ops; +#endif + +/* Called when we free all symtabs, to free the shared library information + as well. */ + +#if 0 +#define CLEAR_SOLIB coff_clear_solib + +extern void +coff_clear_solib PARAMS ((void)); +#endif + +/* Called to add symbols from a shared library to gdb's symbol table. */ + +#define SOLIB_ADD(filename, from_tty, targ) \ + coff_solib_add (filename, from_tty, targ) + +extern void +coff_solib_add PARAMS ((char *, int, struct target_ops *)); + +/* Function to be called when the inferior starts up, to discover the names + of shared libraries that are dynamically linked, the base addresses to + which they are linked, and sufficient information to read in their symbols + at a later time. */ + +#define SOLIB_CREATE_INFERIOR_HOOK(PID) coff_solib_create_inferior_hook() + +extern void +coff_solib_create_inferior_hook PARAMS((void)); /* solib.c */ + +/* If we can't set a breakpoint, and it's in a shared library, just + disable it. */ + +#if 0 +#define DISABLE_UNSETTABLE_BREAK(addr) coff_solib_address(addr) + +extern int +solib_address PARAMS ((CORE_ADDR)); /* solib.c */ +#endif diff --git a/gdb/config/i386/i386lynx.mt b/gdb/config/i386/i386lynx.mt index 2b83ad9f6c..17b24d2b55 100644 --- a/gdb/config/i386/i386lynx.mt +++ b/gdb/config/i386/i386lynx.mt @@ -1,3 +1,3 @@ # Target: Intel 386 running Lynx -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o i386lynx-tdep.o +TDEPFILES= exec.o coff-solib.o i386-tdep.o i386-pinsn.o i386lynx-tdep.o TM_FILE= tm-i386lynx.h diff --git a/gdb/config/i386/tm-i386lynx.h b/gdb/config/i386/tm-i386lynx.h index d5db133848..1385c9629c 100644 --- a/gdb/config/i386/tm-i386lynx.h +++ b/gdb/config/i386/tm-i386lynx.h @@ -31,4 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define SAVED_PC_AFTER_CALL i386lynx_saved_pc_after_call CORE_ADDR i386lynx_saved_pc_after_call (); +#include "coff-solib.h" /* COFF shared library support */ + #endif /* TM_I386LYNX_H */ -- 2.34.1