*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / coff-solib.c
CommitLineData
c906108c 1/* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger.
b6ba6518 2 Copyright 1993, 1994, 1998, 1999, 2000 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
c906108c 10
c5aa993b
JM
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
c906108c
SS
20
21
22#include "defs.h"
23
24#include "frame.h"
25#include "bfd.h"
26#include "gdbcore.h"
27#include "symtab.h"
399371f6
AC
28#include "symfile.h"
29#include "objfiles.h"
c906108c
SS
30
31/*
32
c5aa993b 33 GLOBAL FUNCTION
c906108c 34
c5aa993b
JM
35 coff_solib_add -- add a shared library files to the symtab list. We
36 examine the `.lib' section of the exec file and determine the names of
37 the shared libraries.
c906108c 38
c5aa993b
JM
39 This function is responsible for discovering those names and
40 addresses, and saving sufficient information about them to allow
41 their symbols to be read at a later time.
c906108c 42
c5aa993b 43 SYNOPSIS
c906108c 44
c5aa993b 45 void coff_solib_add (char *arg_string, int from_tty,
990f9fe3 46 struct target_ops *target, int readsyms)
c906108c 47
c5aa993b 48 DESCRIPTION
c906108c 49
c5aa993b 50 */
c906108c
SS
51
52void
990f9fe3 53coff_solib_add (char *arg_string, int from_tty, struct target_ops *target, int readsyms)
c5aa993b 54{
c906108c
SS
55 asection *libsect;
56
990f9fe3
FF
57 if (!readsyms)
58 return;
59
c906108c
SS
60 libsect = bfd_get_section_by_name (exec_bfd, ".lib");
61
62 if (libsect)
63 {
64 int libsize;
65 unsigned char *lib;
66 struct libent
67 {
68 bfd_byte len[4];
69 bfd_byte nameoffset[4];
70 };
71
72 libsize = bfd_section_size (exec_bfd, libsect);
73
74 lib = (unsigned char *) alloca (libsize);
75
76 bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize);
77
78 while (libsize > 0)
79 {
80 struct libent *ent;
81 struct objfile *objfile;
82 int len, nameoffset;
83 char *filename;
84
c5aa993b 85 ent = (struct libent *) lib;
c906108c
SS
86
87 len = bfd_get_32 (exec_bfd, ent->len);
88
89 nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset);
90
91 if (len <= 0)
92 break;
93
c5aa993b 94 filename = (char *) ent + nameoffset * 4;
c906108c
SS
95
96 objfile = symbol_file_add (filename, from_tty,
2acceee2 97 NULL, /* no offsets */
c5aa993b 98 0, /* not mainline */
2df3850c 99 OBJF_SHARED); /* flags */
c906108c
SS
100
101 libsize -= len * 4;
102 lib += len * 4;
103 }
104
105 /* Getting new symbols may change our opinion about what is
c5aa993b 106 frameless. */
c906108c
SS
107 reinit_frame_cache ();
108 }
109}
110
111/*
c5aa993b
JM
112
113 GLOBAL FUNCTION
114
115 coff_solib_create_inferior_hook -- shared library startup support
116
117 SYNOPSIS
118
9b5c5aad 119 void coff_solib_create_inferior_hook ()
c5aa993b
JM
120
121 DESCRIPTION
122
123 When gdb starts up the inferior, the kernel maps in the shared
124 libraries. We get here with the target stopped at it's first
125 instruction, and the libraries already mapped. At this point, this
126 function gets called via expansion of the macro
127 SOLIB_CREATE_INFERIOR_HOOK.
128 */
129
130void
fba45db2 131coff_solib_create_inferior_hook (void)
c906108c 132{
990f9fe3 133 coff_solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
c906108c 134}
This page took 0.404931 seconds and 4 git commands to generate.