* Makefile.in (ALL_64_TARGET_OBS): Add amd64-dicos-tdep.o.
[deliverable/binutils-gdb.git] / gdb / dicos-tdep.c
1 /* Target-dependent, architecture-independent code for DICOS, for GDB.
2
3 Copyright (C) 2009 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 3 of the License, or
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
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "osabi.h"
22 #include "gdb_string.h"
23 #include "solib.h"
24 #include "solib-target.h"
25 #include "inferior.h"
26 #include "dicos-tdep.h"
27
28 void
29 dicos_init_abi (struct gdbarch *gdbarch)
30 {
31 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
32
33 set_solib_ops (gdbarch, &solib_target_so_ops);
34
35 /* Every process, although has its own address space, sees the same
36 list of shared libraries. */
37 set_gdbarch_has_global_solist (gdbarch, 1);
38
39 /* There's no (standard definition of) entry point or a guaranteed
40 text location with a symbol where to place the call dummy, so we
41 put it on the stack. */
42 set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
43
44 /* DICOS rewinds the PC itself. */
45 set_gdbarch_decr_pc_after_break (gdbarch, 0);
46 }
47
48 /* Return true if ABFD is a dicos load module. HEADER_SIZE is the
49 expected size of the "header" section in bytes. */
50
51 int
52 dicos_load_module_p (bfd *abfd, int header_size)
53 {
54 long storage_needed;
55 int ret = 0;
56 asymbol **symbol_table = NULL;
57 const char *symname = "Dicos_loadModuleInfo";
58 asection *section;
59
60 /* DICOS files don't have a .note.ABI-tag marker or something
61 similar. We do know there's always a "header" section of
62 HEADER_SIZE bytes (size depends on architecture), and there's
63 always a "Dicos_loadModuleInfo" symbol defined. Look for the
64 section first, as that should be cheaper. */
65
66 section = bfd_get_section_by_name (abfd, "header");
67 if (!section)
68 return 0;
69
70 if (bfd_section_size (abfd, section) != header_size)
71 return 0;
72
73 /* Dicos LMs always have a "Dicos_loadModuleInfo" symbol
74 defined. Look for it. */
75
76 storage_needed = bfd_get_symtab_upper_bound (abfd);
77 if (storage_needed < 0)
78 {
79 warning (_("Can't read elf symbols from %s: %s"), bfd_get_filename (abfd),
80 bfd_errmsg (bfd_get_error ()));
81 return 0;
82 }
83
84 if (storage_needed > 0)
85 {
86 long i, symcount;
87
88 symbol_table = xmalloc (storage_needed);
89 symcount = bfd_canonicalize_symtab (abfd, symbol_table);
90
91 if (symcount < 0)
92 warning (_("Can't read elf symbols from %s: %s"),
93 bfd_get_filename (abfd),
94 bfd_errmsg (bfd_get_error ()));
95 else
96 {
97 for (i = 0; i < symcount; i++)
98 {
99 asymbol *sym = symbol_table[i];
100 if (sym->name != NULL
101 && symname[0] == sym->name[0]
102 && strcmp (symname + 1, sym->name + 1) == 0)
103 {
104 ret = 1;
105 break;
106 }
107 }
108 }
109 }
110
111 xfree (symbol_table);
112 return ret;
113 }
This page took 0.086626 seconds and 5 git commands to generate.