1 /* Target-dependent code for the MIPS architecture running on IRIX,
2 for GDB, the GNU Debugger.
4 Copyright (C) 2002, 2007 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 2 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, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
29 mips_irix_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
32 enum gdb_osabi *os_ident_ptr = obj;
34 unsigned int sectsize;
36 name = bfd_get_section_name (abfd, sect);
37 sectsize = bfd_section_size (abfd, sect);
39 if (strncmp (name, ".MIPS.", 6) == 0 && sectsize > 0)
41 /* The presence of a section named with a ".MIPS." prefix is
42 indicative of an IRIX binary. */
43 *os_ident_ptr = GDB_OSABI_IRIX;
48 mips_irix_elf_osabi_sniffer (bfd *abfd)
50 unsigned int elfosabi;
51 enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
53 /* If the generic sniffer gets a hit, return and let other sniffers
55 bfd_map_over_sections (abfd,
56 generic_elf_osabi_sniff_abi_tag_sections,
58 if (osabi != GDB_OSABI_UNKNOWN)
59 return GDB_OSABI_UNKNOWN;
61 elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
63 if (elfosabi == ELFOSABI_NONE)
65 /* When elfosabi is ELFOSABI_NONE (0), then the ELF structures in the
66 file are conforming to the base specification for that machine
67 (there are no OS-specific extensions). In order to determine the
68 real OS in use we must look for OS notes that have been added.
70 For IRIX, we simply look for sections named with .MIPS. as
72 bfd_map_over_sections (abfd,
73 mips_irix_elf_osabi_sniff_abi_tag_sections,
80 mips_irix_init_abi (struct gdbarch_info info,
81 struct gdbarch *gdbarch)
86 _initialize_mips_irix_tdep (void)
88 /* Register an ELF OS ABI sniffer for IRIX binaries. */
89 gdbarch_register_osabi_sniffer (bfd_arch_mips,
90 bfd_target_elf_flavour,
91 mips_irix_elf_osabi_sniffer);
93 gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_IRIX,