]>
Commit | Line | Data |
---|---|---|
a58dc200 MK |
1 | /* Target-dependent code for OpenBSD/arm. |
2 | ||
7b6bb8da JB |
3 | Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 |
4 | Free Software Foundation, Inc. | |
a58dc200 MK |
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 | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
a58dc200 MK |
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 | |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
a58dc200 MK |
20 | |
21 | #include "defs.h" | |
22 | #include "osabi.h" | |
e3ac4a1e MK |
23 | #include "trad-frame.h" |
24 | #include "tramp-frame.h" | |
a58dc200 | 25 | |
47ccd048 MK |
26 | #include "gdb_string.h" |
27 | ||
aa88762a | 28 | #include "obsd-tdep.h" |
a58dc200 MK |
29 | #include "arm-tdep.h" |
30 | #include "solib-svr4.h" | |
31 | ||
e3ac4a1e MK |
32 | /* Signal trampolines. */ |
33 | ||
34 | static void | |
35 | armobsd_sigframe_init (const struct tramp_frame *self, | |
a262aec2 | 36 | struct frame_info *this_frame, |
e3ac4a1e MK |
37 | struct trad_frame_cache *cache, |
38 | CORE_ADDR func) | |
39 | { | |
40 | CORE_ADDR sp, sigcontext_addr, addr; | |
41 | int regnum; | |
42 | ||
43 | /* We find the appropriate instance of `struct sigcontext' at a | |
44 | fixed offset in the signal frame. */ | |
a262aec2 | 45 | sp = get_frame_register_signed (this_frame, ARM_SP_REGNUM); |
e3ac4a1e MK |
46 | sigcontext_addr = sp + 16; |
47 | ||
48 | /* PC. */ | |
49 | trad_frame_set_reg_addr (cache, ARM_PC_REGNUM, sigcontext_addr + 76); | |
50 | ||
51 | /* GPRs. */ | |
52 | for (regnum = ARM_A1_REGNUM, addr = sigcontext_addr + 12; | |
53 | regnum <= ARM_LR_REGNUM; regnum++, addr += 4) | |
54 | trad_frame_set_reg_addr (cache, regnum, addr); | |
55 | ||
56 | trad_frame_set_id (cache, frame_id_build (sp, func)); | |
57 | } | |
58 | ||
59 | static const struct tramp_frame armobsd_sigframe = | |
60 | { | |
61 | SIGTRAMP_FRAME, | |
62 | 4, | |
63 | { | |
64 | { 0xe28d0010, -1 }, /* add r0, sp, #16 */ | |
65 | { 0xef000067, -1 }, /* swi SYS_sigreturn */ | |
66 | { 0xef000001, -1 }, /* swi SYS_exit */ | |
67 | { 0xeafffffc, -1 }, /* b . - 8 */ | |
68 | { TRAMP_SENTINEL_INSN, -1 } | |
69 | }, | |
70 | armobsd_sigframe_init | |
71 | }; | |
72 | \f | |
73 | ||
190dce09 UW |
74 | /* Override default thumb breakpoints. */ |
75 | static const char arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf}; | |
76 | static const char arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe}; | |
77 | ||
a58dc200 MK |
78 | static void |
79 | armobsd_init_abi (struct gdbarch_info info, | |
80 | struct gdbarch *gdbarch) | |
81 | { | |
82 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
83 | ||
84 | if (tdep->fp_model == ARM_FLOAT_AUTO) | |
85 | tdep->fp_model = ARM_FLOAT_SOFT_VFP; | |
86 | ||
e3ac4a1e MK |
87 | tramp_frame_prepend_unwinder (gdbarch, &armobsd_sigframe); |
88 | ||
a58dc200 MK |
89 | /* OpenBSD/arm uses SVR4-style shared libraries. */ |
90 | set_solib_svr4_fetch_link_map_offsets | |
91 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
aa88762a | 92 | set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver); |
a58dc200 MK |
93 | |
94 | tdep->jb_pc = 24; | |
95 | tdep->jb_elt_size = 4; | |
7c00367c | 96 | |
47ccd048 MK |
97 | set_gdbarch_regset_from_core_section |
98 | (gdbarch, armbsd_regset_from_core_section); | |
99 | ||
7c00367c MK |
100 | /* OpenBSD/arm uses -fpcc-struct-return by default. */ |
101 | tdep->struct_return = pcc_struct_return; | |
190dce09 UW |
102 | |
103 | /* Single stepping. */ | |
104 | set_gdbarch_software_single_step (gdbarch, arm_software_single_step); | |
105 | ||
106 | /* Breakpoints. */ | |
107 | switch (info.byte_order) | |
108 | { | |
109 | case BFD_ENDIAN_BIG: | |
110 | tdep->thumb_breakpoint = arm_obsd_thumb_be_breakpoint; | |
111 | tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_be_breakpoint); | |
112 | break; | |
113 | ||
114 | case BFD_ENDIAN_LITTLE: | |
115 | tdep->thumb_breakpoint = arm_obsd_thumb_le_breakpoint; | |
116 | tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_le_breakpoint); | |
117 | break; | |
118 | } | |
a58dc200 | 119 | } |
47ccd048 MK |
120 | \f |
121 | ||
122 | static enum gdb_osabi | |
123 | armobsd_core_osabi_sniffer (bfd *abfd) | |
124 | { | |
125 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
126 | return GDB_OSABI_OPENBSD_ELF; | |
127 | ||
128 | return GDB_OSABI_UNKNOWN; | |
129 | } | |
a58dc200 | 130 | |
63807e1d PA |
131 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
132 | extern initialize_file_ftype _initialize_armobsd_tdep; | |
133 | ||
a58dc200 MK |
134 | void |
135 | _initialize_armobsd_tdep (void) | |
136 | { | |
47ccd048 MK |
137 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ |
138 | gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_unknown_flavour, | |
139 | armobsd_core_osabi_sniffer); | |
140 | ||
a58dc200 MK |
141 | gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_OPENBSD_ELF, |
142 | armobsd_init_abi); | |
143 | } |