]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/armnbsd-tdep.c
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / gdb / armnbsd-tdep.c
1 /* Target-dependent code for NetBSD/arm.
2
3 Copyright (C) 2002-2015 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 #include "osabi.h"
22
23 #include "arm-tdep.h"
24 #include "solib-svr4.h"
25
26 /* Description of the longjmp buffer. */
27 #define ARM_NBSD_JB_PC 24
28 #define ARM_NBSD_JB_ELEMENT_SIZE INT_REGISTER_SIZE
29
30 /* For compatibility with previous implemenations of GDB on arm/NetBSD,
31 override the default little-endian breakpoint. */
32 static const gdb_byte arm_nbsd_arm_le_breakpoint[] = {0x11, 0x00, 0x00, 0xe6};
33 static const gdb_byte arm_nbsd_arm_be_breakpoint[] = {0xe6, 0x00, 0x00, 0x11};
34 static const gdb_byte arm_nbsd_thumb_le_breakpoint[] = {0xfe, 0xde};
35 static const gdb_byte arm_nbsd_thumb_be_breakpoint[] = {0xde, 0xfe};
36
37 static void
38 arm_netbsd_init_abi_common (struct gdbarch_info info,
39 struct gdbarch *gdbarch)
40 {
41 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
42
43 tdep->lowest_pc = 0x8000;
44 switch (info.byte_order)
45 {
46 case BFD_ENDIAN_LITTLE:
47 tdep->arm_breakpoint = arm_nbsd_arm_le_breakpoint;
48 tdep->thumb_breakpoint = arm_nbsd_thumb_le_breakpoint;
49 tdep->arm_breakpoint_size = sizeof (arm_nbsd_arm_le_breakpoint);
50 tdep->thumb_breakpoint_size = sizeof (arm_nbsd_thumb_le_breakpoint);
51 break;
52
53 case BFD_ENDIAN_BIG:
54 tdep->arm_breakpoint = arm_nbsd_arm_be_breakpoint;
55 tdep->thumb_breakpoint = arm_nbsd_thumb_be_breakpoint;
56 tdep->arm_breakpoint_size = sizeof (arm_nbsd_arm_be_breakpoint);
57 tdep->thumb_breakpoint_size = sizeof (arm_nbsd_thumb_be_breakpoint);
58 break;
59
60 default:
61 internal_error (__FILE__, __LINE__,
62 _("arm_gdbarch_init: bad byte order for float format"));
63 }
64
65 tdep->jb_pc = ARM_NBSD_JB_PC;
66 tdep->jb_elt_size = ARM_NBSD_JB_ELEMENT_SIZE;
67
68 /* Single stepping. */
69 set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
70 }
71
72 static void
73 arm_netbsd_aout_init_abi (struct gdbarch_info info,
74 struct gdbarch *gdbarch)
75 {
76 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
77
78 arm_netbsd_init_abi_common (info, gdbarch);
79 if (tdep->fp_model == ARM_FLOAT_AUTO)
80 tdep->fp_model = ARM_FLOAT_SOFT_FPA;
81 }
82
83 static void
84 arm_netbsd_elf_init_abi (struct gdbarch_info info,
85 struct gdbarch *gdbarch)
86 {
87 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
88
89 arm_netbsd_init_abi_common (info, gdbarch);
90 if (tdep->fp_model == ARM_FLOAT_AUTO)
91 tdep->fp_model = ARM_FLOAT_SOFT_VFP;
92
93 /* NetBSD ELF uses SVR4-style shared libraries. */
94 set_solib_svr4_fetch_link_map_offsets
95 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
96 }
97
98 static enum gdb_osabi
99 arm_netbsd_aout_osabi_sniffer (bfd *abfd)
100 {
101 if (strcmp (bfd_get_target (abfd), "a.out-arm-netbsd") == 0)
102 return GDB_OSABI_NETBSD_AOUT;
103
104 return GDB_OSABI_UNKNOWN;
105 }
106
107 /* Provide a prototype to silence -Wmissing-prototypes. */
108 extern initialize_file_ftype _initialize_arm_netbsd_tdep;
109
110 void
111 _initialize_arm_netbsd_tdep (void)
112 {
113 gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_aout_flavour,
114 arm_netbsd_aout_osabi_sniffer);
115
116 gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD_AOUT,
117 arm_netbsd_aout_init_abi);
118 gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD_ELF,
119 arm_netbsd_elf_init_abi);
120 }