import gdb-1999-07-07 post reformat
[deliverable/binutils-gdb.git] / gdb / coff-solib.c
1 /* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger.
2 Copyright 1993 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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. */
20
21
22 #include "defs.h"
23
24 #include "frame.h"
25 #include "bfd.h"
26 #include "gdbcore.h"
27 #include "symtab.h"
28
29 /*
30
31 GLOBAL FUNCTION
32
33 coff_solib_add -- add a shared library files to the symtab list. We
34 examine the `.lib' section of the exec file and determine the names of
35 the shared libraries.
36
37 This function is responsible for discovering those names and
38 addresses, and saving sufficient information about them to allow
39 their symbols to be read at a later time.
40
41 SYNOPSIS
42
43 void coff_solib_add (char *arg_string, int from_tty,
44 struct target_ops *target)
45
46 DESCRIPTION
47
48 */
49
50 void
51 coff_solib_add (arg_string, from_tty, target)
52 char *arg_string;
53 int from_tty;
54 struct target_ops *target;
55 {
56 asection *libsect;
57
58 libsect = bfd_get_section_by_name (exec_bfd, ".lib");
59
60 if (libsect)
61 {
62 int libsize;
63 unsigned char *lib;
64 struct libent
65 {
66 bfd_byte len[4];
67 bfd_byte nameoffset[4];
68 };
69
70 libsize = bfd_section_size (exec_bfd, libsect);
71
72 lib = (unsigned char *) alloca (libsize);
73
74 bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize);
75
76 while (libsize > 0)
77 {
78 struct libent *ent;
79 struct objfile *objfile;
80 int len, nameoffset;
81 char *filename;
82
83 ent = (struct libent *) lib;
84
85 len = bfd_get_32 (exec_bfd, ent->len);
86
87 nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset);
88
89 if (len <= 0)
90 break;
91
92 filename = (char *) ent + nameoffset * 4;
93
94 objfile = symbol_file_add (filename, from_tty,
95 0, /* addr */
96 0, /* not mainline */
97 0, /* not mapped */
98 0, /* Not readnow */
99 0, /* Not user loaded */
100 1); /* Is a solib */
101
102 libsize -= len * 4;
103 lib += len * 4;
104 }
105
106 /* Getting new symbols may change our opinion about what is
107 frameless. */
108 reinit_frame_cache ();
109 }
110 }
111
112 /*
113
114 GLOBAL FUNCTION
115
116 coff_solib_create_inferior_hook -- shared library startup support
117
118 SYNOPSIS
119
120 void coff_solib_create_inferior_hook()
121
122 DESCRIPTION
123
124 When gdb starts up the inferior, the kernel maps in the shared
125 libraries. We get here with the target stopped at it's first
126 instruction, and the libraries already mapped. At this point, this
127 function gets called via expansion of the macro
128 SOLIB_CREATE_INFERIOR_HOOK.
129 */
130
131 void
132 coff_solib_create_inferior_hook ()
133 {
134 coff_solib_add ((char *) 0, 0, (struct target_ops *) 0);
135 }
This page took 0.031496 seconds and 4 git commands to generate.