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