summaryrefslogtreecommitdiff
path: root/gdb/dicos-tdep.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-02-17 17:56:50 +0000
committerPedro Alves <palves@redhat.com>2009-02-17 17:56:50 +0000
commit4c1d29734e9ca4e8921c9962e0f342bcc9e95c16 (patch)
treeeb32db580082ecd49a7734cd89cfd5ecc8fa017e /gdb/dicos-tdep.c
parent1903f0e64bb6f600388af42a7af7aff02e70bdef (diff)
downloadbinutils-gdb-4c1d29734e9ca4e8921c9962e0f342bcc9e95c16.tar.gz
* Makefile.in (ALL_64_TARGET_OBS): Add amd64-dicos-tdep.o.
(ALL_TARGET_OBS): Add dicos-tdep.o. (ALLDEPFILES): Add amd64-dicos-tdep.c and dicos-tdep.c. * configure.tgt (i[34567]86-*-dicos*): Add dicos-tdep.o to gdb_target_obs. (x86_64-*-dicos*): Add dicos-tdep.o and amd64-dicos-tdep.o to gdb_target_obs. * dicos-tdep.h, dicos-tdep.c: New. * amd64-dicos-tdep.c: New. * i386-dicos-tdep.c: Don't include solib.h, solib-target.h or inferior.h. Include dicos-tdep.h. (i386_dicos_init_abi): Call dicos_init_abi. (i386_dicos_bfd_has_symbol_p): Delete. (i386_dicos_osabi_sniffer): Use dicos_load_module_p. * NEWS: Mention x86-64 DICOS target support.
Diffstat (limited to 'gdb/dicos-tdep.c')
-rw-r--r--gdb/dicos-tdep.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c
new file mode 100644
index 00000000000..d64efe56aaf
--- /dev/null
+++ b/gdb/dicos-tdep.c
@@ -0,0 +1,113 @@
+/* Target-dependent, architecture-independent code for DICOS, for GDB.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+#include "osabi.h"
+#include "gdb_string.h"
+#include "solib.h"
+#include "solib-target.h"
+#include "inferior.h"
+#include "dicos-tdep.h"
+
+void
+dicos_init_abi (struct gdbarch *gdbarch)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ set_solib_ops (gdbarch, &solib_target_so_ops);
+
+ /* Every process, although has its own address space, sees the same
+ list of shared libraries. */
+ set_gdbarch_has_global_solist (gdbarch, 1);
+
+ /* There's no (standard definition of) entry point or a guaranteed
+ text location with a symbol where to place the call dummy, so we
+ put it on the stack. */
+ set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+
+ /* DICOS rewinds the PC itself. */
+ set_gdbarch_decr_pc_after_break (gdbarch, 0);
+}
+
+/* Return true if ABFD is a dicos load module. HEADER_SIZE is the
+ expected size of the "header" section in bytes. */
+
+int
+dicos_load_module_p (bfd *abfd, int header_size)
+{
+ long storage_needed;
+ int ret = 0;
+ asymbol **symbol_table = NULL;
+ const char *symname = "Dicos_loadModuleInfo";
+ asection *section;
+
+ /* DICOS files don't have a .note.ABI-tag marker or something
+ similar. We do know there's always a "header" section of
+ HEADER_SIZE bytes (size depends on architecture), and there's
+ always a "Dicos_loadModuleInfo" symbol defined. Look for the
+ section first, as that should be cheaper. */
+
+ section = bfd_get_section_by_name (abfd, "header");
+ if (!section)
+ return 0;
+
+ if (bfd_section_size (abfd, section) != header_size)
+ return 0;
+
+ /* Dicos LMs always have a "Dicos_loadModuleInfo" symbol
+ defined. Look for it. */
+
+ storage_needed = bfd_get_symtab_upper_bound (abfd);
+ if (storage_needed < 0)
+ {
+ warning (_("Can't read elf symbols from %s: %s"), bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
+ return 0;
+ }
+
+ if (storage_needed > 0)
+ {
+ long i, symcount;
+
+ symbol_table = xmalloc (storage_needed);
+ symcount = bfd_canonicalize_symtab (abfd, symbol_table);
+
+ if (symcount < 0)
+ warning (_("Can't read elf symbols from %s: %s"),
+ bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
+ else
+ {
+ for (i = 0; i < symcount; i++)
+ {
+ asymbol *sym = symbol_table[i];
+ if (sym->name != NULL
+ && symname[0] == sym->name[0]
+ && strcmp (symname + 1, sym->name + 1) == 0)
+ {
+ ret = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ xfree (symbol_table);
+ return ret;
+}