1 /* Target-dependent code for OpenBSD/i386.
3 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002,
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
25 #include "arch-utils.h"
31 #include "gdb_assert.h"
32 #include "gdb_string.h"
34 #include "i386-tdep.h"
35 #include "i387-tdep.h"
36 #include "solib-svr4.h"
38 /* From <machine/reg.h>. */
39 static int i386obsd_r_reg_offset[] =
60 i386obsd_aout_supply_regset (const struct regset *regset,
61 struct regcache *regcache, int regnum,
62 const void *regs, size_t len)
64 const struct gdbarch_tdep *tdep = regset->descr;
66 gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE);
68 i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
69 i387_supply_fsave (regcache, regnum, (char *) regs + tdep->sizeof_gregset);
72 static const struct regset *
73 i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch,
74 const char *sect_name,
77 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
79 /* OpenBSD a.out core dumps don't use seperate register sets for the
80 general-purpose and floating-point registers. */
82 if (strcmp (sect_name, ".reg") == 0
83 && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
85 if (tdep->gregset == NULL)
87 tdep->gregset = XMALLOC (struct regset);
88 tdep->gregset->descr = tdep;
89 tdep->gregset->supply_regset = i386obsd_aout_supply_regset;
98 CORE_ADDR i386obsd_sigtramp_start = 0xbfbfdf20;
99 CORE_ADDR i386obsd_sigtramp_end = 0xbfbfdff0;
101 /* From <machine/signal.h>. */
102 int i386obsd_sc_reg_offset[I386_NUM_GREGS] =
113 13 * 4, /* %eflags */
123 i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
125 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
127 /* Obviously OpenBSD is BSD-based. */
128 i386bsd_init_abi (info, gdbarch);
130 /* OpenBSD has a different `struct reg'. */
131 tdep->gregset_reg_offset = i386obsd_r_reg_offset;
132 tdep->gregset_num_regs = ARRAY_SIZE (i386obsd_r_reg_offset);
133 tdep->sizeof_gregset = 16 * 4;
135 /* OpenBSD uses -freg-struct-return by default. */
136 tdep->struct_return = reg_struct_return;
138 /* OpenBSD uses a different memory layout. */
139 tdep->sigtramp_start = i386obsd_sigtramp_start;
140 tdep->sigtramp_end = i386obsd_sigtramp_end;
142 /* OpenBSD has a `struct sigcontext' that's different from the
143 origional 4.3 BSD. */
144 tdep->sc_reg_offset = i386obsd_sc_reg_offset;
145 tdep->sc_num_regs = ARRAY_SIZE (i386obsd_sc_reg_offset);
151 i386obsd_aout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
153 i386obsd_init_abi (info, gdbarch);
155 /* OpenBSD a.out has a single register set. */
156 set_gdbarch_regset_from_core_section
157 (gdbarch, i386obsd_aout_regset_from_core_section);
163 i386obsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
165 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
167 /* It's still OpenBSD. */
168 i386obsd_init_abi (info, gdbarch);
171 i386_elf_init_abi (info, gdbarch);
173 /* OpenBSD ELF uses SVR4-style shared libraries. */
174 set_gdbarch_in_solib_call_trampoline
175 (gdbarch, generic_in_solib_call_trampoline);
176 set_solib_svr4_fetch_link_map_offsets
177 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
181 /* Provide a prototype to silence -Wmissing-prototypes. */
182 void _initialize_i386obsd_tdep (void);
185 _initialize_i386obsd_tdep (void)
187 /* FIXME: kettenis/20021020: Since OpenBSD/i386 binaries are
188 indistingushable from NetBSD/i386 a.out binaries, building a GDB
189 that should support both these targets will probably not work as
191 #define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
193 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_OPENBSD_AOUT,
194 i386obsd_aout_init_abi);
195 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_OPENBSD_ELF,
196 i386obsd_elf_init_abi);