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