1 /* Target-dependent code for the MIPS architecture running on IRIX,
2 for GDB, the GNU Debugger.
4 Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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/>. */
23 #include "gdb_string.h"
25 #include "solib-irix.h"
30 mips_irix_elf_osabi_sniff_abi_tag_sections (bfd
*abfd
, asection
*sect
,
33 enum gdb_osabi
*os_ident_ptr
= obj
;
35 unsigned int sectsize
;
37 name
= bfd_get_section_name (abfd
, sect
);
38 sectsize
= bfd_section_size (abfd
, sect
);
40 if (strncmp (name
, ".MIPS.", 6) == 0 && sectsize
> 0)
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
;
49 mips_irix_elf_osabi_sniffer (bfd
*abfd
)
51 unsigned int elfosabi
;
52 enum gdb_osabi osabi
= GDB_OSABI_UNKNOWN
;
54 /* If the generic sniffer gets a hit, return and let other sniffers
56 bfd_map_over_sections (abfd
,
57 generic_elf_osabi_sniff_abi_tag_sections
,
59 if (osabi
!= GDB_OSABI_UNKNOWN
)
60 return GDB_OSABI_UNKNOWN
;
62 elfosabi
= elf_elfheader (abfd
)->e_ident
[EI_OSABI
];
64 if (elfosabi
== ELFOSABI_NONE
)
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.
71 For IRIX, we simply look for sections named with .MIPS. as
73 bfd_map_over_sections (abfd
,
74 mips_irix_elf_osabi_sniff_abi_tag_sections
,
81 mips_irix_init_abi (struct gdbarch_info info
,
82 struct gdbarch
*gdbarch
)
84 set_solib_ops (gdbarch
, &irix_so_ops
);
88 _initialize_mips_irix_tdep (void)
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
);
95 gdbarch_register_osabi (bfd_arch_mips
, 0, GDB_OSABI_IRIX
,