Sort includes for files gdb/[a-f]*.[chyl].
[deliverable/binutils-gdb.git] / gdb / arm-obsd-tdep.c
1 /* Target-dependent code for OpenBSD/arm.
2
3 Copyright (C) 2006-2019 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21
22 /* Local non-gdb includes. */
23 #include "arm-tdep.h"
24 #include "obsd-tdep.h"
25 #include "osabi.h"
26 #include "solib-svr4.h"
27 #include "trad-frame.h"
28 #include "tramp-frame.h"
29
30 /* Signal trampolines. */
31
32 static void
33 armobsd_sigframe_init (const struct tramp_frame *self,
34 struct frame_info *this_frame,
35 struct trad_frame_cache *cache,
36 CORE_ADDR func)
37 {
38 CORE_ADDR sp, sigcontext_addr, addr;
39 int regnum;
40
41 /* We find the appropriate instance of `struct sigcontext' at a
42 fixed offset in the signal frame. */
43 sp = get_frame_register_signed (this_frame, ARM_SP_REGNUM);
44 sigcontext_addr = sp + 16;
45
46 /* PC. */
47 trad_frame_set_reg_addr (cache, ARM_PC_REGNUM, sigcontext_addr + 76);
48
49 /* GPRs. */
50 for (regnum = ARM_A1_REGNUM, addr = sigcontext_addr + 12;
51 regnum <= ARM_LR_REGNUM; regnum++, addr += 4)
52 trad_frame_set_reg_addr (cache, regnum, addr);
53
54 trad_frame_set_id (cache, frame_id_build (sp, func));
55 }
56
57 static const struct tramp_frame armobsd_sigframe =
58 {
59 SIGTRAMP_FRAME,
60 4,
61 {
62 { 0xe28d0010, ULONGEST_MAX }, /* add r0, sp, #16 */
63 { 0xef000067, ULONGEST_MAX }, /* swi SYS_sigreturn */
64 { 0xef000001, ULONGEST_MAX }, /* swi SYS_exit */
65 { 0xeafffffc, ULONGEST_MAX }, /* b . - 8 */
66 { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
67 },
68 armobsd_sigframe_init
69 };
70 \f
71
72 /* Override default thumb breakpoints. */
73 static const gdb_byte arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf};
74 static const gdb_byte arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe};
75
76 static void
77 armobsd_init_abi (struct gdbarch_info info,
78 struct gdbarch *gdbarch)
79 {
80 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
81
82 if (tdep->fp_model == ARM_FLOAT_AUTO)
83 tdep->fp_model = ARM_FLOAT_SOFT_VFP;
84
85 tramp_frame_prepend_unwinder (gdbarch, &armobsd_sigframe);
86
87 /* OpenBSD/arm uses SVR4-style shared libraries. */
88 set_solib_svr4_fetch_link_map_offsets
89 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
90 set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);
91
92 tdep->jb_pc = 24;
93 tdep->jb_elt_size = 4;
94
95 set_gdbarch_iterate_over_regset_sections
96 (gdbarch, armbsd_iterate_over_regset_sections);
97
98 /* OpenBSD/arm uses -fpcc-struct-return by default. */
99 tdep->struct_return = pcc_struct_return;
100
101 /* Single stepping. */
102 set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
103
104 /* Breakpoints. */
105 switch (info.byte_order)
106 {
107 case BFD_ENDIAN_BIG:
108 tdep->thumb_breakpoint = arm_obsd_thumb_be_breakpoint;
109 tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_be_breakpoint);
110 break;
111
112 case BFD_ENDIAN_LITTLE:
113 tdep->thumb_breakpoint = arm_obsd_thumb_le_breakpoint;
114 tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_le_breakpoint);
115 break;
116 }
117 }
118
119 void
120 _initialize_armobsd_tdep (void)
121 {
122 gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_OPENBSD,
123 armobsd_init_abi);
124 }
This page took 0.035726 seconds and 4 git commands to generate.