]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/arm-obsd-tdep.c
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / arm-obsd-tdep.c
CommitLineData
a58dc200
MK
1/* Target-dependent code for OpenBSD/arm.
2
1d506c26 3 Copyright (C) 2006-2024 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 19
d55e5aa6 20#include "osabi.h"
d55e5aa6
TT
21#include "trad-frame.h"
22#include "tramp-frame.h"
a58dc200 23
4de283e4
TT
24#include "obsd-tdep.h"
25#include "arm-tdep.h"
26#include "solib-svr4.h"
27
e3ac4a1e
MK
28/* Signal trampolines. */
29
30static void
31armobsd_sigframe_init (const struct tramp_frame *self,
8480a37e 32 const frame_info_ptr &this_frame,
e3ac4a1e
MK
33 struct trad_frame_cache *cache,
34 CORE_ADDR func)
35{
36 CORE_ADDR sp, sigcontext_addr, addr;
37 int regnum;
38
39 /* We find the appropriate instance of `struct sigcontext' at a
40 fixed offset in the signal frame. */
a262aec2 41 sp = get_frame_register_signed (this_frame, ARM_SP_REGNUM);
e3ac4a1e
MK
42 sigcontext_addr = sp + 16;
43
44 /* PC. */
45 trad_frame_set_reg_addr (cache, ARM_PC_REGNUM, sigcontext_addr + 76);
46
47 /* GPRs. */
48 for (regnum = ARM_A1_REGNUM, addr = sigcontext_addr + 12;
49 regnum <= ARM_LR_REGNUM; regnum++, addr += 4)
50 trad_frame_set_reg_addr (cache, regnum, addr);
51
52 trad_frame_set_id (cache, frame_id_build (sp, func));
53}
54
55static const struct tramp_frame armobsd_sigframe =
56{
57 SIGTRAMP_FRAME,
58 4,
59 {
7bc02706
TT
60 { 0xe28d0010, ULONGEST_MAX }, /* add r0, sp, #16 */
61 { 0xef000067, ULONGEST_MAX }, /* swi SYS_sigreturn */
62 { 0xef000001, ULONGEST_MAX }, /* swi SYS_exit */
63 { 0xeafffffc, ULONGEST_MAX }, /* b . - 8 */
64 { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
e3ac4a1e
MK
65 },
66 armobsd_sigframe_init
67};
68\f
69
190dce09 70/* Override default thumb breakpoints. */
948f8e3d
PA
71static const gdb_byte arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf};
72static const gdb_byte arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe};
190dce09 73
a58dc200
MK
74static void
75armobsd_init_abi (struct gdbarch_info info,
76 struct gdbarch *gdbarch)
77{
08106042 78 arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
a58dc200
MK
79
80 if (tdep->fp_model == ARM_FLOAT_AUTO)
81 tdep->fp_model = ARM_FLOAT_SOFT_VFP;
82
e3ac4a1e
MK
83 tramp_frame_prepend_unwinder (gdbarch, &armobsd_sigframe);
84
a58dc200
MK
85 /* OpenBSD/arm uses SVR4-style shared libraries. */
86 set_solib_svr4_fetch_link_map_offsets
87 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
aa88762a 88 set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);
a58dc200
MK
89
90 tdep->jb_pc = 24;
91 tdep->jb_elt_size = 4;
7c00367c 92
ed09174e
AA
93 set_gdbarch_iterate_over_regset_sections
94 (gdbarch, armbsd_iterate_over_regset_sections);
47ccd048 95
7c00367c
MK
96 /* OpenBSD/arm uses -fpcc-struct-return by default. */
97 tdep->struct_return = pcc_struct_return;
190dce09
UW
98
99 /* Single stepping. */
100 set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
101
102 /* Breakpoints. */
103 switch (info.byte_order)
104 {
105 case BFD_ENDIAN_BIG:
106 tdep->thumb_breakpoint = arm_obsd_thumb_be_breakpoint;
107 tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_be_breakpoint);
108 break;
109
110 case BFD_ENDIAN_LITTLE:
111 tdep->thumb_breakpoint = arm_obsd_thumb_le_breakpoint;
112 tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_le_breakpoint);
113 break;
114 }
a58dc200 115}
63807e1d 116
6c265988 117void _initialize_armobsd_tdep ();
a58dc200 118void
6c265988 119_initialize_armobsd_tdep ()
a58dc200 120{
1736a7bd 121 gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_OPENBSD,
a58dc200
MK
122 armobsd_init_abi);
123}