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