Commit | Line | Data |
---|---|---|
8201327c | 1 | /* Target-dependent code for Solaris x86. |
911bc6ee | 2 | |
ecd75fc8 | 3 | Copyright (C) 2002-2014 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 MK |
19 | |
20 | #include "defs.h" | |
52e9098c | 21 | #include "value.h" |
4be87837 | 22 | #include "osabi.h" |
8201327c | 23 | |
081bf9da | 24 | #include "sol2-tdep.h" |
8201327c | 25 | #include "i386-tdep.h" |
75f501b5 | 26 | #include "solib-svr4.h" |
8201327c | 27 | |
6a9756ed MK |
28 | /* From <ia32/sys/reg.h>. */ |
29 | static int i386_sol2_gregset_reg_offset[] = | |
30 | { | |
31 | 11 * 4, /* %eax */ | |
32 | 10 * 4, /* %ecx */ | |
33 | 9 * 4, /* %edx */ | |
34 | 8 * 4, /* %ebx */ | |
35 | 17 * 4, /* %esp */ | |
36 | 6 * 4, /* %ebp */ | |
37 | 5 * 4, /* %esi */ | |
38 | 4 * 4, /* %edi */ | |
39 | 14 * 4, /* %eip */ | |
40 | 16 * 4, /* %eflags */ | |
41 | 15 * 4, /* %cs */ | |
42 | 18 * 4, /* %ss */ | |
43 | 3 * 4, /* %ds */ | |
44 | 2 * 4, /* %es */ | |
45 | 1 * 4, /* %fs */ | |
46 | 0 * 4 /* %gs */ | |
47 | }; | |
48 | ||
10458914 DJ |
49 | /* Return whether THIS_FRAME corresponds to a Solaris sigtramp |
50 | routine. */ | |
d9f8c85b | 51 | |
8201327c | 52 | static int |
10458914 | 53 | i386_sol2_sigtramp_p (struct frame_info *this_frame) |
8201327c | 54 | { |
10458914 | 55 | CORE_ADDR pc = get_frame_pc (this_frame); |
2c02bd72 | 56 | const char *name; |
911bc6ee | 57 | |
d9f8c85b MK |
58 | find_pc_partial_function (pc, &name, NULL, NULL); |
59 | return (name && (strcmp ("sigacthandler", name) == 0 | |
60 | || strcmp (name, "ucbsigvechandler") == 0)); | |
8201327c MK |
61 | } |
62 | ||
8349554d MK |
63 | /* Solaris doesn't have a `struct sigcontext', but it does have a |
64 | `mcontext_t' that contains the saved set of machine registers. */ | |
65 | ||
66 | static CORE_ADDR | |
10458914 | 67 | i386_sol2_mcontext_addr (struct frame_info *this_frame) |
8349554d MK |
68 | { |
69 | CORE_ADDR sp, ucontext_addr; | |
70 | ||
10458914 DJ |
71 | sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM); |
72 | ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 4); | |
8349554d MK |
73 | |
74 | return ucontext_addr + 36; | |
75 | } | |
76 | ||
149ad273 UW |
77 | /* SunPRO encodes the static variables. This is not related to C++ |
78 | mangling, it is done for C too. */ | |
79 | ||
0d5cff50 DE |
80 | static const char * |
81 | i386_sol2_static_transform_name (const char *name) | |
149ad273 UW |
82 | { |
83 | char *p; | |
84 | if (name[0] == '.') | |
85 | { | |
86 | /* For file-local statics there will be a period, a bunch of | |
87 | junk (the contents of which match a string given in the | |
88 | N_OPT), a period and the name. For function-local statics | |
89 | there will be a bunch of junk (which seems to change the | |
90 | second character from 'A' to 'B'), a period, the name of the | |
91 | function, and the name. So just skip everything before the | |
92 | last period. */ | |
93 | p = strrchr (name, '.'); | |
94 | if (p != NULL) | |
95 | name = p + 1; | |
96 | } | |
97 | return name; | |
98 | } | |
99 | ||
8201327c MK |
100 | /* Solaris 2. */ |
101 | ||
102 | static void | |
103 | i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
104 | { | |
105 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
106 | ||
107 | /* Solaris is SVR4-based. */ | |
108 | i386_svr4_init_abi (info, gdbarch); | |
109 | ||
203c3895 UW |
110 | /* The SunPRO compiler puts out 0 instead of the address in N_SO symbols, |
111 | and for SunPRO 3.0, N_FUN symbols too. */ | |
112 | set_gdbarch_sofun_address_maybe_missing (gdbarch, 1); | |
113 | ||
149ad273 UW |
114 | /* Handle SunPRO encoding of static symbols. */ |
115 | set_gdbarch_static_transform_name (gdbarch, i386_sol2_static_transform_name); | |
116 | ||
6a9756ed MK |
117 | /* Solaris reserves space for its FPU emulator in `fpregset_t'. |
118 | There is also some space reserved for the registers of a Weitek | |
119 | math coprocessor. */ | |
120 | tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset; | |
121 | tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset); | |
122 | tdep->sizeof_gregset = 19 * 4; | |
123 | tdep->sizeof_fpregset = 380; | |
124 | ||
911bc6ee MK |
125 | /* Signal trampolines are slightly different from SVR4. */ |
126 | tdep->sigtramp_p = i386_sol2_sigtramp_p; | |
8349554d MK |
127 | tdep->sigcontext_addr = i386_sol2_mcontext_addr; |
128 | tdep->sc_reg_offset = tdep->gregset_reg_offset; | |
129 | tdep->sc_num_regs = tdep->gregset_num_regs; | |
75f501b5 | 130 | |
081bf9da MK |
131 | /* Solaris has SVR4-style shared libraries. */ |
132 | set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver); | |
75f501b5 MK |
133 | set_solib_svr4_fetch_link_map_offsets |
134 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
959b8724 | 135 | |
28439f5e PA |
136 | /* How to print LWP PTIDs from core files. */ |
137 | set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str); | |
8201327c MK |
138 | } |
139 | \f | |
140 | ||
6e157172 MK |
141 | static enum gdb_osabi |
142 | i386_sol2_osabi_sniffer (bfd *abfd) | |
143 | { | |
144 | /* If we have a section named .SUNW_version, then it is almost | |
145 | certainly Solaris 2. */ | |
146 | if (bfd_get_section_by_name (abfd, ".SUNW_version")) | |
147 | return GDB_OSABI_SOLARIS; | |
148 | ||
149 | return GDB_OSABI_UNKNOWN; | |
150 | } | |
151 | ||
8201327c MK |
152 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
153 | void _initialize_i386_sol2_tdep (void); | |
154 | ||
155 | void | |
156 | _initialize_i386_sol2_tdep (void) | |
157 | { | |
0c52bd59 | 158 | /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */ |
6e157172 MK |
159 | gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour, |
160 | i386_sol2_osabi_sniffer); | |
161 | ||
05816f70 | 162 | gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS, |
8201327c MK |
163 | i386_sol2_init_abi); |
164 | } |