]>
Commit | Line | Data |
---|---|---|
8201327c | 1 | /* Target-dependent code for Solaris x86. |
911bc6ee | 2 | |
1d506c26 | 3 | Copyright (C) 2002-2024 Free Software Foundation, Inc. |
8201327c MK |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
8201327c MK |
10 | (at your option) any later version. |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8201327c | 19 | |
52e9098c | 20 | #include "value.h" |
4be87837 | 21 | #include "osabi.h" |
8201327c | 22 | |
081bf9da | 23 | #include "sol2-tdep.h" |
8201327c | 24 | #include "i386-tdep.h" |
75f501b5 | 25 | #include "solib-svr4.h" |
8201327c | 26 | |
6a9756ed MK |
27 | /* From <ia32/sys/reg.h>. */ |
28 | static int i386_sol2_gregset_reg_offset[] = | |
29 | { | |
30 | 11 * 4, /* %eax */ | |
31 | 10 * 4, /* %ecx */ | |
32 | 9 * 4, /* %edx */ | |
33 | 8 * 4, /* %ebx */ | |
34 | 17 * 4, /* %esp */ | |
35 | 6 * 4, /* %ebp */ | |
36 | 5 * 4, /* %esi */ | |
37 | 4 * 4, /* %edi */ | |
38 | 14 * 4, /* %eip */ | |
39 | 16 * 4, /* %eflags */ | |
40 | 15 * 4, /* %cs */ | |
41 | 18 * 4, /* %ss */ | |
42 | 3 * 4, /* %ds */ | |
43 | 2 * 4, /* %es */ | |
44 | 1 * 4, /* %fs */ | |
45 | 0 * 4 /* %gs */ | |
46 | }; | |
47 | ||
8349554d MK |
48 | /* Solaris doesn't have a `struct sigcontext', but it does have a |
49 | `mcontext_t' that contains the saved set of machine registers. */ | |
50 | ||
51 | static CORE_ADDR | |
8480a37e | 52 | i386_sol2_mcontext_addr (const frame_info_ptr &this_frame) |
8349554d MK |
53 | { |
54 | CORE_ADDR sp, ucontext_addr; | |
55 | ||
10458914 DJ |
56 | sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); |
57 | ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 4); | |
8349554d MK |
58 | |
59 | return ucontext_addr + 36; | |
60 | } | |
61 | ||
8201327c MK |
62 | /* Solaris 2. */ |
63 | ||
64 | static void | |
65 | i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
66 | { | |
08106042 | 67 | i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch); |
8201327c MK |
68 | |
69 | /* Solaris is SVR4-based. */ | |
70 | i386_svr4_init_abi (info, gdbarch); | |
71 | ||
d412e696 | 72 | sol2_init_abi (info, gdbarch); |
149ad273 | 73 | |
6a9756ed MK |
74 | /* Solaris reserves space for its FPU emulator in `fpregset_t'. |
75 | There is also some space reserved for the registers of a Weitek | |
76 | math coprocessor. */ | |
77 | tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset; | |
78 | tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset); | |
79 | tdep->sizeof_gregset = 19 * 4; | |
80 | tdep->sizeof_fpregset = 380; | |
81 | ||
911bc6ee | 82 | /* Signal trampolines are slightly different from SVR4. */ |
d412e696 | 83 | tdep->sigtramp_p = sol2_sigtramp_p; |
8349554d MK |
84 | tdep->sigcontext_addr = i386_sol2_mcontext_addr; |
85 | tdep->sc_reg_offset = tdep->gregset_reg_offset; | |
86 | tdep->sc_num_regs = tdep->gregset_num_regs; | |
75f501b5 | 87 | |
081bf9da | 88 | /* Solaris has SVR4-style shared libraries. */ |
75f501b5 MK |
89 | set_solib_svr4_fetch_link_map_offsets |
90 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
8201327c MK |
91 | } |
92 | \f | |
93 | ||
6e157172 MK |
94 | static enum gdb_osabi |
95 | i386_sol2_osabi_sniffer (bfd *abfd) | |
96 | { | |
97 | /* If we have a section named .SUNW_version, then it is almost | |
98 | certainly Solaris 2. */ | |
99 | if (bfd_get_section_by_name (abfd, ".SUNW_version")) | |
100 | return GDB_OSABI_SOLARIS; | |
101 | ||
102 | return GDB_OSABI_UNKNOWN; | |
103 | } | |
104 | ||
6c265988 | 105 | void _initialize_i386_sol2_tdep (); |
8201327c | 106 | void |
6c265988 | 107 | _initialize_i386_sol2_tdep () |
8201327c | 108 | { |
0c52bd59 | 109 | /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */ |
6e157172 MK |
110 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour, |
111 | i386_sol2_osabi_sniffer); | |
112 | ||
05816f70 | 113 | gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS, |
8201327c MK |
114 | i386_sol2_init_abi); |
115 | } |