Commit | Line | Data |
---|---|---|
b96d0a4e KB |
1 | /* Target-dependent code for the MIPS architecture running on IRIX, |
2 | for GDB, the GNU Debugger. | |
3 | ||
4 | Copyright 2002 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 2 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, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
22 | ||
23 | #include "defs.h" | |
24 | #include "osabi.h" | |
25 | ||
26 | #include "elf-bfd.h" | |
27 | ||
28 | static void | |
29 | mips_irix_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, | |
30 | void *obj) | |
31 | { | |
32 | enum gdb_osabi *os_ident_ptr = obj; | |
33 | const char *name; | |
34 | unsigned int sectsize; | |
35 | ||
36 | name = bfd_get_section_name (abfd, sect); | |
37 | sectsize = bfd_section_size (abfd, sect); | |
38 | ||
39 | if (strncmp (name, ".MIPS.", 6) == 0 && sectsize > 0) | |
40 | { | |
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; | |
44 | } | |
45 | } | |
46 | ||
47 | static enum gdb_osabi | |
48 | mips_irix_elf_osabi_sniffer (bfd *abfd) | |
49 | { | |
50 | unsigned int elfosabi; | |
51 | enum gdb_osabi osabi = GDB_OSABI_UNKNOWN; | |
52 | ||
53 | /* If the generic sniffer gets a hit, return and let other sniffers | |
54 | get a crack at it. */ | |
55 | bfd_map_over_sections (abfd, | |
56 | generic_elf_osabi_sniff_abi_tag_sections, | |
57 | &osabi); | |
58 | if (osabi != GDB_OSABI_UNKNOWN) | |
59 | return GDB_OSABI_UNKNOWN; | |
60 | ||
61 | elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI]; | |
62 | ||
63 | if (elfosabi == ELFOSABI_NONE) | |
64 | { | |
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. | |
69 | ||
70 | For IRIX, we simply look for sections named with .MIPS. as | |
71 | prefixes. */ | |
72 | bfd_map_over_sections (abfd, | |
73 | mips_irix_elf_osabi_sniff_abi_tag_sections, | |
74 | &osabi); | |
75 | } | |
76 | return osabi; | |
77 | } | |
78 | ||
79 | static void | |
80 | mips_irix_init_abi (struct gdbarch_info info, | |
81 | struct gdbarch *gdbarch) | |
82 | { | |
83 | } | |
84 | ||
85 | void | |
86 | _initialize_mips_irix_tdep (void) | |
87 | { | |
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); | |
92 | ||
05816f70 | 93 | gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_IRIX, |
b96d0a4e KB |
94 | mips_irix_init_abi); |
95 | } |