Commit | Line | Data |
---|---|---|
ead291d4 SG |
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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | ||
21 | #include "defs.h" | |
22 | ||
23 | #include "bfd.h" | |
24 | #include "gdbcore.h" | |
25 | #include "symtab.h" | |
26 | ||
27 | /* | |
28 | ||
29 | GLOBAL FUNCTION | |
30 | ||
31 | coff_solib_add -- add a shared library files to the symtab list. We | |
32 | examine the `.lib' section of the exec file and determine the names of | |
33 | the shared libraries. | |
34 | ||
35 | This function is responsible for discovering those names and | |
36 | addresses, and saving sufficient information about them to allow | |
37 | their symbols to be read at a later time. | |
38 | ||
39 | SYNOPSIS | |
40 | ||
41 | void coff_solib_add (char *arg_string, int from_tty, | |
42 | struct target_ops *target) | |
43 | ||
44 | DESCRIPTION | |
45 | ||
46 | */ | |
47 | ||
48 | void | |
49 | coff_solib_add (arg_string, from_tty, target) | |
50 | char *arg_string; | |
51 | int from_tty; | |
52 | struct target_ops *target; | |
53 | { | |
54 | asection *libsect; | |
55 | ||
56 | libsect = bfd_get_section_by_name (exec_bfd, ".lib"); | |
57 | ||
58 | if (libsect) | |
59 | { | |
60 | int libsize; | |
61 | unsigned char *lib; | |
62 | struct libent | |
63 | { | |
64 | long len; | |
65 | long unk; | |
66 | char filename[1]; | |
67 | }; | |
68 | ||
69 | libsize = bfd_section_size (exec_bfd, libsect); | |
70 | ||
71 | lib = alloca (libsize); | |
72 | ||
73 | bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize); | |
74 | ||
75 | while (libsize > 0) | |
76 | { | |
77 | struct libent *ent; | |
78 | struct objfile *objfile; | |
79 | ||
80 | ent = (struct libent *)lib; | |
81 | ||
82 | if (ent->len <= 0) | |
83 | break; | |
84 | ||
85 | objfile = symbol_file_add (ent->filename, from_tty, | |
86 | 0, /* addr */ | |
87 | 0, /* not mainline */ | |
88 | 0, /* not mapped */ | |
89 | 0); /* Not readnow */ | |
90 | libsize -= ent->len * 4; | |
91 | lib += ent->len * 4; | |
92 | } | |
93 | } | |
94 | } | |
95 | ||
96 | /* | |
97 | ||
98 | GLOBAL FUNCTION | |
99 | ||
100 | coff_solib_create_inferior_hook -- shared library startup support | |
101 | ||
102 | SYNOPSIS | |
103 | ||
104 | void coff_solib_create_inferior_hook() | |
105 | ||
106 | DESCRIPTION | |
107 | ||
108 | When gdb starts up the inferior, the kernel maps in the shared | |
109 | libraries. We get here with the target stopped at it's first | |
110 | instruction, and the libraries already mapped. At this point, this | |
111 | function gets called via expansion of the macro | |
112 | SOLIB_CREATE_INFERIOR_HOOK. | |
113 | */ | |
114 | ||
115 | void | |
116 | coff_solib_create_inferior_hook() | |
117 | { | |
118 | coff_solib_add ((char *) 0, 0, (struct target_ops *) 0); | |
119 | } |