* cris/crisv32f.c (MY (deliver_interrupt)): Set CCS to new_ccs.
[deliverable/binutils-gdb.git] / gdb / sparc-linux-tdep.c
CommitLineData
386c036b
MK
1/* Target-dependent code for GNU/Linux SPARC.
2
197e01b6 3 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
386c036b
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
9 the Free Software Foundation; either version 2 of the License, or
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
18 along with this program; if not, write to the Free Software
197e01b6
EZ
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
386c036b
MK
21
22#include "defs.h"
faea95b1 23#include "dwarf2-frame.h"
386c036b
MK
24#include "floatformat.h"
25#include "frame.h"
26#include "frame-unwind.h"
27#include "gdbarch.h"
28#include "gdbcore.h"
29#include "osabi.h"
30#include "regcache.h"
31#include "solib-svr4.h"
32#include "symtab.h"
33#include "trad-frame.h"
70f1dc74 34#include "tramp-frame.h"
386c036b 35
386c036b
MK
36#include "sparc-tdep.h"
37
81f726ab 38/* Signal trampoline support. */
386c036b 39
70f1dc74
MK
40static void sparc32_linux_sigframe_init (const struct tramp_frame *self,
41 struct frame_info *next_frame,
42 struct trad_frame_cache *this_cache,
43 CORE_ADDR func);
44
386c036b
MK
45/* GNU/Linux has two flavors of signals. Normal signal handlers, and
46 "realtime" (RT) signals. The RT signals can provide additional
47 information to the signal handler if the SA_SIGINFO flag is set
48 when establishing a signal handler using `sigaction'. It is not
49 unlikely that future versions of GNU/Linux will support SA_SIGINFO
50 for normal signals too. */
51
52/* When the sparc Linux kernel calls a signal handler and the
53 SA_RESTORER flag isn't set, the return address points to a bit of
70f1dc74
MK
54 code on the stack. This code checks whether the PC appears to be
55 within this bit of code.
386c036b 56
70f1dc74 57 The instruction sequence for normal signals is encoded below.
386c036b
MK
58 Checking for the code sequence should be somewhat reliable, because
59 the effect is to call the system call sigreturn. This is unlikely
70f1dc74 60 to occur anywhere other than a signal trampoline. */
386c036b 61
70f1dc74
MK
62static const struct tramp_frame sparc32_linux_sigframe =
63{
81f726ab
DM
64 SIGTRAMP_FRAME,
65 4,
66 {
70f1dc74
MK
67 { 0x821020d8, -1 }, /* mov __NR_sugreturn, %g1 */
68 { 0x91d02010, -1 }, /* ta 0x10 */
81f726ab
DM
69 { TRAMP_SENTINEL_INSN, -1 }
70 },
71 sparc32_linux_sigframe_init
72};
386c036b 73
70f1dc74
MK
74/* The instruction sequence for RT signals is slightly different. The
75 effect is to call the system call rt_sigreturn. */
76
77static const struct tramp_frame sparc32_linux_rt_sigframe =
78{
81f726ab
DM
79 SIGTRAMP_FRAME,
80 4,
81 {
70f1dc74
MK
82 { 0x82102065, -1 }, /* mov __NR_rt_sigreturn, %g1 */
83 { 0x91d02010, -1 }, /* ta 0x10 */
81f726ab
DM
84 { TRAMP_SENTINEL_INSN, -1 }
85 },
86 sparc32_linux_sigframe_init
87};
386c036b 88
81f726ab
DM
89static void
90sparc32_linux_sigframe_init (const struct tramp_frame *self,
91 struct frame_info *next_frame,
92 struct trad_frame_cache *this_cache,
93 CORE_ADDR func)
386c036b 94{
80f9e3aa 95 CORE_ADDR base, addr, sp_addr;
386c036b
MK
96 int regnum;
97
81f726ab
DM
98 base = frame_unwind_register_unsigned (next_frame, SPARC_O1_REGNUM);
99 if (self == &sparc32_linux_rt_sigframe)
100 base += 128;
386c036b 101
70f1dc74 102 /* Offsets from <bits/sigcontext.h>. */
78a0fd57 103
70f1dc74
MK
104 trad_frame_set_reg_addr (this_cache, SPARC32_PSR_REGNUM, base + 0);
105 trad_frame_set_reg_addr (this_cache, SPARC32_PC_REGNUM, base + 4);
106 trad_frame_set_reg_addr (this_cache, SPARC32_NPC_REGNUM, base + 8);
107 trad_frame_set_reg_addr (this_cache, SPARC32_Y_REGNUM, base + 12);
386c036b
MK
108
109 /* Since %g0 is always zero, keep the identity encoding. */
70f1dc74 110 addr = base + 20;
80f9e3aa 111 sp_addr = base + 16 + ((SPARC_SP_REGNUM - SPARC_G0_REGNUM) * 4);
81f726ab
DM
112 for (regnum = SPARC_G1_REGNUM; regnum <= SPARC_O7_REGNUM; regnum++)
113 {
114 trad_frame_set_reg_addr (this_cache, regnum, addr);
115 addr += 4;
116 }
386c036b 117
80f9e3aa
DM
118 base = frame_unwind_register_unsigned (next_frame, SPARC_SP_REGNUM);
119 addr = get_frame_memory_unsigned (next_frame, sp_addr, 4);
120
81f726ab
DM
121 for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
122 {
123 trad_frame_set_reg_addr (this_cache, regnum, addr);
124 addr += 4;
125 }
126 trad_frame_set_id (this_cache, frame_id_build (base, func));
386c036b 127}
386c036b
MK
128\f
129
386c036b
MK
130static void
131sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
132{
a33e488c
MK
133 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
134
81f726ab
DM
135 tramp_frame_prepend_unwinder (gdbarch, &sparc32_linux_sigframe);
136 tramp_frame_prepend_unwinder (gdbarch, &sparc32_linux_rt_sigframe);
137
a33e488c
MK
138 /* GNU/Linux has SVR4-style shared libraries... */
139 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
140 set_solib_svr4_fetch_link_map_offsets
141 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
386c036b 142
a33e488c
MK
143 /* ...which means that we need some special handling when doing
144 prologue analysis. */
145 tdep->plt_entry_size = 12;
386c036b
MK
146
147 /* GNU/Linux doesn't support the 128-bit `long double' from the psABI. */
148 set_gdbarch_long_double_bit (gdbarch, 64);
149 set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
150
b2756930
KB
151 /* Enable TLS support. */
152 set_gdbarch_fetch_tls_load_module_address (gdbarch,
153 svr4_fetch_objfile_link_map);
faea95b1
DM
154
155 /* Hook in the DWARF CFI frame unwinder. */
156 frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
386c036b
MK
157}
158
159/* Provide a prototype to silence -Wmissing-prototypes. */
160extern void _initialize_sparc_linux_tdep (void);
161
162void
163_initialize_sparc_linux_tdep (void)
164{
165 gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_LINUX,
166 sparc32_linux_init_abi);
167}
This page took 0.306888 seconds and 4 git commands to generate.