]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger. |
2 | Copyright 1993 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" | |
28 | ||
29 | /* | |
30 | ||
c5aa993b | 31 | GLOBAL FUNCTION |
c906108c | 32 | |
c5aa993b JM |
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. | |
c906108c | 36 | |
c5aa993b JM |
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. | |
c906108c | 40 | |
c5aa993b | 41 | SYNOPSIS |
c906108c | 42 | |
c5aa993b JM |
43 | void coff_solib_add (char *arg_string, int from_tty, |
44 | struct target_ops *target) | |
c906108c | 45 | |
c5aa993b | 46 | DESCRIPTION |
c906108c | 47 | |
c5aa993b | 48 | */ |
c906108c SS |
49 | |
50 | void | |
fba45db2 | 51 | coff_solib_add (char *arg_string, int from_tty, struct target_ops *target) |
c5aa993b | 52 | { |
c906108c SS |
53 | asection *libsect; |
54 | ||
55 | libsect = bfd_get_section_by_name (exec_bfd, ".lib"); | |
56 | ||
57 | if (libsect) | |
58 | { | |
59 | int libsize; | |
60 | unsigned char *lib; | |
61 | struct libent | |
62 | { | |
63 | bfd_byte len[4]; | |
64 | bfd_byte nameoffset[4]; | |
65 | }; | |
66 | ||
67 | libsize = bfd_section_size (exec_bfd, libsect); | |
68 | ||
69 | lib = (unsigned char *) alloca (libsize); | |
70 | ||
71 | bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize); | |
72 | ||
73 | while (libsize > 0) | |
74 | { | |
75 | struct libent *ent; | |
76 | struct objfile *objfile; | |
77 | int len, nameoffset; | |
78 | char *filename; | |
79 | ||
c5aa993b | 80 | ent = (struct libent *) lib; |
c906108c SS |
81 | |
82 | len = bfd_get_32 (exec_bfd, ent->len); | |
83 | ||
84 | nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset); | |
85 | ||
86 | if (len <= 0) | |
87 | break; | |
88 | ||
c5aa993b | 89 | filename = (char *) ent + nameoffset * 4; |
c906108c SS |
90 | |
91 | objfile = symbol_file_add (filename, from_tty, | |
2acceee2 | 92 | NULL, /* no offsets */ |
c5aa993b | 93 | 0, /* not mainline */ |
2df3850c | 94 | OBJF_SHARED); /* flags */ |
c906108c SS |
95 | |
96 | libsize -= len * 4; | |
97 | lib += len * 4; | |
98 | } | |
99 | ||
100 | /* Getting new symbols may change our opinion about what is | |
c5aa993b | 101 | frameless. */ |
c906108c SS |
102 | reinit_frame_cache (); |
103 | } | |
104 | } | |
105 | ||
106 | /* | |
c5aa993b JM |
107 | |
108 | GLOBAL FUNCTION | |
109 | ||
110 | coff_solib_create_inferior_hook -- shared library startup support | |
111 | ||
112 | SYNOPSIS | |
113 | ||
114 | void coff_solib_create_inferior_hook() | |
115 | ||
116 | DESCRIPTION | |
117 | ||
118 | When gdb starts up the inferior, the kernel maps in the shared | |
119 | libraries. We get here with the target stopped at it's first | |
120 | instruction, and the libraries already mapped. At this point, this | |
121 | function gets called via expansion of the macro | |
122 | SOLIB_CREATE_INFERIOR_HOOK. | |
123 | */ | |
124 | ||
125 | void | |
fba45db2 | 126 | coff_solib_create_inferior_hook (void) |
c906108c SS |
127 | { |
128 | coff_solib_add ((char *) 0, 0, (struct target_ops *) 0); | |
129 | } |