arm-obsd-tdep.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Target-dependent code for OpenBSD/arm.
  2. Copyright (C) 2006-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "osabi.h"
  16. #include "trad-frame.h"
  17. #include "tramp-frame.h"
  18. #include "obsd-tdep.h"
  19. #include "arm-tdep.h"
  20. #include "solib-svr4.h"
  21. /* Signal trampolines. */
  22. static void
  23. armobsd_sigframe_init (const struct tramp_frame *self,
  24. struct frame_info *this_frame,
  25. struct trad_frame_cache *cache,
  26. CORE_ADDR func)
  27. {
  28. CORE_ADDR sp, sigcontext_addr, addr;
  29. int regnum;
  30. /* We find the appropriate instance of `struct sigcontext' at a
  31. fixed offset in the signal frame. */
  32. sp = get_frame_register_signed (this_frame, ARM_SP_REGNUM);
  33. sigcontext_addr = sp + 16;
  34. /* PC. */
  35. trad_frame_set_reg_addr (cache, ARM_PC_REGNUM, sigcontext_addr + 76);
  36. /* GPRs. */
  37. for (regnum = ARM_A1_REGNUM, addr = sigcontext_addr + 12;
  38. regnum <= ARM_LR_REGNUM; regnum++, addr += 4)
  39. trad_frame_set_reg_addr (cache, regnum, addr);
  40. trad_frame_set_id (cache, frame_id_build (sp, func));
  41. }
  42. static const struct tramp_frame armobsd_sigframe =
  43. {
  44. SIGTRAMP_FRAME,
  45. 4,
  46. {
  47. { 0xe28d0010, ULONGEST_MAX }, /* add r0, sp, #16 */
  48. { 0xef000067, ULONGEST_MAX }, /* swi SYS_sigreturn */
  49. { 0xef000001, ULONGEST_MAX }, /* swi SYS_exit */
  50. { 0xeafffffc, ULONGEST_MAX }, /* b . - 8 */
  51. { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
  52. },
  53. armobsd_sigframe_init
  54. };
  55. /* Override default thumb breakpoints. */
  56. static const gdb_byte arm_obsd_thumb_le_breakpoint[] = {0xfe, 0xdf};
  57. static const gdb_byte arm_obsd_thumb_be_breakpoint[] = {0xdf, 0xfe};
  58. static void
  59. armobsd_init_abi (struct gdbarch_info info,
  60. struct gdbarch *gdbarch)
  61. {
  62. arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch);
  63. if (tdep->fp_model == ARM_FLOAT_AUTO)
  64. tdep->fp_model = ARM_FLOAT_SOFT_VFP;
  65. tramp_frame_prepend_unwinder (gdbarch, &armobsd_sigframe);
  66. /* OpenBSD/arm uses SVR4-style shared libraries. */
  67. set_solib_svr4_fetch_link_map_offsets
  68. (gdbarch, svr4_ilp32_fetch_link_map_offsets);
  69. set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);
  70. tdep->jb_pc = 24;
  71. tdep->jb_elt_size = 4;
  72. set_gdbarch_iterate_over_regset_sections
  73. (gdbarch, armbsd_iterate_over_regset_sections);
  74. /* OpenBSD/arm uses -fpcc-struct-return by default. */
  75. tdep->struct_return = pcc_struct_return;
  76. /* Single stepping. */
  77. set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
  78. /* Breakpoints. */
  79. switch (info.byte_order)
  80. {
  81. case BFD_ENDIAN_BIG:
  82. tdep->thumb_breakpoint = arm_obsd_thumb_be_breakpoint;
  83. tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_be_breakpoint);
  84. break;
  85. case BFD_ENDIAN_LITTLE:
  86. tdep->thumb_breakpoint = arm_obsd_thumb_le_breakpoint;
  87. tdep->thumb_breakpoint_size = sizeof (arm_obsd_thumb_le_breakpoint);
  88. break;
  89. }
  90. }
  91. void _initialize_armobsd_tdep ();
  92. void
  93. _initialize_armobsd_tdep ()
  94. {
  95. gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_OPENBSD,
  96. armobsd_init_abi);
  97. }