* README: Mention gdbserver/README.
[deliverable/binutils-gdb.git] / gdb / mips-irix-tdep.c
1 /* Target-dependent code for the MIPS architecture running on IRIX,
2 for GDB, the GNU Debugger.
3
4 Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 #include "defs.h"
22 #include "osabi.h"
23 #include "gdb_string.h"
24 #include "solib.h"
25 #include "solib-irix.h"
26
27 #include "elf-bfd.h"
28
29 static void
30 mips_irix_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
31 void *obj)
32 {
33 enum gdb_osabi *os_ident_ptr = obj;
34 const char *name;
35 unsigned int sectsize;
36
37 name = bfd_get_section_name (abfd, sect);
38 sectsize = bfd_section_size (abfd, sect);
39
40 if (strncmp (name, ".MIPS.", 6) == 0 && sectsize > 0)
41 {
42 /* The presence of a section named with a ".MIPS." prefix is
43 indicative of an IRIX binary. */
44 *os_ident_ptr = GDB_OSABI_IRIX;
45 }
46 }
47
48 static enum gdb_osabi
49 mips_irix_elf_osabi_sniffer (bfd *abfd)
50 {
51 unsigned int elfosabi;
52 enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
53
54 /* If the generic sniffer gets a hit, return and let other sniffers
55 get a crack at it. */
56 bfd_map_over_sections (abfd,
57 generic_elf_osabi_sniff_abi_tag_sections,
58 &osabi);
59 if (osabi != GDB_OSABI_UNKNOWN)
60 return GDB_OSABI_UNKNOWN;
61
62 elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
63
64 if (elfosabi == ELFOSABI_NONE)
65 {
66 /* When elfosabi is ELFOSABI_NONE (0), then the ELF structures in the
67 file are conforming to the base specification for that machine
68 (there are no OS-specific extensions). In order to determine the
69 real OS in use we must look for OS notes that have been added.
70
71 For IRIX, we simply look for sections named with .MIPS. as
72 prefixes. */
73 bfd_map_over_sections (abfd,
74 mips_irix_elf_osabi_sniff_abi_tag_sections,
75 &osabi);
76 }
77 return osabi;
78 }
79
80 static void
81 mips_irix_init_abi (struct gdbarch_info info,
82 struct gdbarch *gdbarch)
83 {
84 set_solib_ops (gdbarch, &irix_so_ops);
85 }
86
87 void
88 _initialize_mips_irix_tdep (void)
89 {
90 /* Register an ELF OS ABI sniffer for IRIX binaries. */
91 gdbarch_register_osabi_sniffer (bfd_arch_mips,
92 bfd_target_elf_flavour,
93 mips_irix_elf_osabi_sniffer);
94
95 gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_IRIX,
96 mips_irix_init_abi);
97 }
This page took 0.034223 seconds and 4 git commands to generate.