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