]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/dicos-tdep.c
Add markers for release 2.26
[thirdparty/binutils-gdb.git] / gdb / dicos-tdep.c
CommitLineData
4c1d2973
PA
1/* Target-dependent, architecture-independent code for DICOS, for GDB.
2
32d0add0 3 Copyright (C) 2009-2015 Free Software Foundation, Inc.
4c1d2973
PA
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"
4c1d2973
PA
22#include "solib.h"
23#include "solib-target.h"
24#include "inferior.h"
25#include "dicos-tdep.h"
26
27void
28dicos_init_abi (struct gdbarch *gdbarch)
29{
30 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
31
32 set_solib_ops (gdbarch, &solib_target_so_ops);
33
34 /* Every process, although has its own address space, sees the same
2567c7d9
PA
35 list of shared libraries. There's no "main executable" in DICOS,
36 so this accounts for all code. */
4c1d2973
PA
37 set_gdbarch_has_global_solist (gdbarch, 1);
38
2567c7d9
PA
39 /* The DICOS breakpoint API takes care of magically making
40 breakpoints visible to all inferiors. */
41 set_gdbarch_has_global_breakpoints (gdbarch, 1);
42
4c1d2973
PA
43 /* There's no (standard definition of) entry point or a guaranteed
44 text location with a symbol where to place the call dummy, so we
a9b8d892
JK
45 need it on the stack. Rely on i386_gdbarch_init used also for
46 amd64 to set up ON_STACK inferior calls. */
4c1d2973
PA
47
48 /* DICOS rewinds the PC itself. */
49 set_gdbarch_decr_pc_after_break (gdbarch, 0);
50}
51
52/* Return true if ABFD is a dicos load module. HEADER_SIZE is the
53 expected size of the "header" section in bytes. */
54
55int
56dicos_load_module_p (bfd *abfd, int header_size)
57{
58 long storage_needed;
59 int ret = 0;
60 asymbol **symbol_table = NULL;
61 const char *symname = "Dicos_loadModuleInfo";
62 asection *section;
63
64 /* DICOS files don't have a .note.ABI-tag marker or something
65 similar. We do know there's always a "header" section of
66 HEADER_SIZE bytes (size depends on architecture), and there's
67 always a "Dicos_loadModuleInfo" symbol defined. Look for the
68 section first, as that should be cheaper. */
69
70 section = bfd_get_section_by_name (abfd, "header");
71 if (!section)
72 return 0;
73
74 if (bfd_section_size (abfd, section) != header_size)
75 return 0;
76
77 /* Dicos LMs always have a "Dicos_loadModuleInfo" symbol
78 defined. Look for it. */
79
80 storage_needed = bfd_get_symtab_upper_bound (abfd);
81 if (storage_needed < 0)
82 {
0963b4bd
MS
83 warning (_("Can't read elf symbols from %s: %s"),
84 bfd_get_filename (abfd),
4c1d2973
PA
85 bfd_errmsg (bfd_get_error ()));
86 return 0;
87 }
88
89 if (storage_needed > 0)
90 {
91 long i, symcount;
92
224c3ddb 93 symbol_table = (asymbol **) xmalloc (storage_needed);
4c1d2973
PA
94 symcount = bfd_canonicalize_symtab (abfd, symbol_table);
95
96 if (symcount < 0)
97 warning (_("Can't read elf symbols from %s: %s"),
98 bfd_get_filename (abfd),
99 bfd_errmsg (bfd_get_error ()));
100 else
101 {
102 for (i = 0; i < symcount; i++)
103 {
104 asymbol *sym = symbol_table[i];
105 if (sym->name != NULL
106 && symname[0] == sym->name[0]
107 && strcmp (symname + 1, sym->name + 1) == 0)
108 {
109 ret = 1;
110 break;
111 }
112 }
113 }
114 }
115
116 xfree (symbol_table);
117 return ret;
118}