core_xfer_shared_libraries and core_xfer_shared_libraries_aix returns ULONGEST
[deliverable/binutils-gdb.git] / gdb / bfd-target.c
CommitLineData
bba2d28d
AC
1/* Very simple "bfd" target, for GDB, the GNU debugger.
2
ecd75fc8 3 Copyright (C) 2003-2014 Free Software Foundation, Inc.
bba2d28d
AC
4
5 This file is part of GDB.
6
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
bba2d28d
AC
10 (at your option) any later version.
11
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
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
bba2d28d
AC
19
20#include "defs.h"
21#include "target.h"
22#include "bfd-target.h"
348f8c02 23#include "exec.h"
cbb099e8 24#include "gdb_bfd.h"
bba2d28d 25
891e7584
PA
26/* The object that is stored in the target_ops->to_data field has this
27 type. */
28struct target_bfd_data
29{
30 /* The BFD we're wrapping. */
31 struct bfd *bfd;
32
33 /* The section table build from the ALLOC sections in BFD. Note
34 that we can't rely on extracting the BFD from a random section in
35 the table, since the table can be legitimately empty. */
36 struct target_section_table table;
37};
38
2c0b251b 39static LONGEST
bba2d28d
AC
40target_bfd_xfer_partial (struct target_ops *ops,
41 enum target_object object,
961cb7b5
MK
42 const char *annex, gdb_byte *readbuf,
43 const gdb_byte *writebuf,
b55e14c7 44 ULONGEST offset, ULONGEST len)
bba2d28d
AC
45{
46 switch (object)
47 {
48 case TARGET_OBJECT_MEMORY:
07b82ea5 49 {
891e7584
PA
50 struct target_bfd_data *data = ops->to_data;
51 return section_table_xfer_memory_partial (readbuf, writebuf,
52 offset, len,
53 data->table.sections,
54 data->table.sections_end,
07b82ea5
PA
55 NULL);
56 }
bba2d28d
AC
57 default:
58 return -1;
59 }
60}
61
07b82ea5
PA
62static struct target_section_table *
63target_bfd_get_section_table (struct target_ops *ops)
64{
891e7584
PA
65 struct target_bfd_data *data = ops->to_data;
66 return &data->table;
07b82ea5
PA
67}
68
2c0b251b 69static void
460014f5 70target_bfd_xclose (struct target_ops *t)
bba2d28d 71{
891e7584
PA
72 struct target_bfd_data *data = t->to_data;
73
cbb099e8 74 gdb_bfd_unref (data->bfd);
891e7584
PA
75 xfree (data->table.sections);
76 xfree (data);
bba2d28d
AC
77 xfree (t);
78}
79
80struct target_ops *
ad13d8df 81target_bfd_reopen (struct bfd *abfd)
bba2d28d 82{
07b82ea5 83 struct target_ops *t;
891e7584 84 struct target_bfd_data *data;
07b82ea5 85
41bf6aca 86 data = XCNEW (struct target_bfd_data);
520b0001
TT
87 data->bfd = abfd;
88 gdb_bfd_ref (abfd);
ad13d8df 89 build_section_table (abfd, &data->table.sections, &data->table.sections_end);
07b82ea5 90
41bf6aca 91 t = XCNEW (struct target_ops);
bba2d28d 92 t->to_shortname = "bfd";
3d263c1d
BI
93 t->to_longname = _("BFD backed target");
94 t->to_doc = _("You should never see this");
07b82ea5 95 t->to_get_section_table = target_bfd_get_section_table;
bba2d28d
AC
96 t->to_xfer_partial = target_bfd_xfer_partial;
97 t->to_xclose = target_bfd_xclose;
891e7584 98 t->to_data = data;
7fdc1521 99 t->to_magic = OPS_MAGIC;
348f8c02 100
bba2d28d
AC
101 return t;
102}
This page took 0.71614 seconds and 4 git commands to generate.