i386-sol2-tdep.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Target-dependent code for Solaris x86.
  2. Copyright (C) 2002-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 "value.h"
  16. #include "osabi.h"
  17. #include "sol2-tdep.h"
  18. #include "i386-tdep.h"
  19. #include "solib-svr4.h"
  20. /* From <ia32/sys/reg.h>. */
  21. static int i386_sol2_gregset_reg_offset[] =
  22. {
  23. 11 * 4, /* %eax */
  24. 10 * 4, /* %ecx */
  25. 9 * 4, /* %edx */
  26. 8 * 4, /* %ebx */
  27. 17 * 4, /* %esp */
  28. 6 * 4, /* %ebp */
  29. 5 * 4, /* %esi */
  30. 4 * 4, /* %edi */
  31. 14 * 4, /* %eip */
  32. 16 * 4, /* %eflags */
  33. 15 * 4, /* %cs */
  34. 18 * 4, /* %ss */
  35. 3 * 4, /* %ds */
  36. 2 * 4, /* %es */
  37. 1 * 4, /* %fs */
  38. 0 * 4 /* %gs */
  39. };
  40. /* Solaris doesn't have a `struct sigcontext', but it does have a
  41. `mcontext_t' that contains the saved set of machine registers. */
  42. static CORE_ADDR
  43. i386_sol2_mcontext_addr (struct frame_info *this_frame)
  44. {
  45. CORE_ADDR sp, ucontext_addr;
  46. sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
  47. ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 4);
  48. return ucontext_addr + 36;
  49. }
  50. /* Solaris 2. */
  51. static void
  52. i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  53. {
  54. i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
  55. /* Solaris is SVR4-based. */
  56. i386_svr4_init_abi (info, gdbarch);
  57. sol2_init_abi (info, gdbarch);
  58. /* Solaris reserves space for its FPU emulator in `fpregset_t'.
  59. There is also some space reserved for the registers of a Weitek
  60. math coprocessor. */
  61. tdep->gregset_reg_offset = i386_sol2_gregset_reg_offset;
  62. tdep->gregset_num_regs = ARRAY_SIZE (i386_sol2_gregset_reg_offset);
  63. tdep->sizeof_gregset = 19 * 4;
  64. tdep->sizeof_fpregset = 380;
  65. /* Signal trampolines are slightly different from SVR4. */
  66. tdep->sigtramp_p = sol2_sigtramp_p;
  67. tdep->sigcontext_addr = i386_sol2_mcontext_addr;
  68. tdep->sc_reg_offset = tdep->gregset_reg_offset;
  69. tdep->sc_num_regs = tdep->gregset_num_regs;
  70. /* Solaris has SVR4-style shared libraries. */
  71. set_solib_svr4_fetch_link_map_offsets
  72. (gdbarch, svr4_ilp32_fetch_link_map_offsets);
  73. }
  74. static enum gdb_osabi
  75. i386_sol2_osabi_sniffer (bfd *abfd)
  76. {
  77. /* If we have a section named .SUNW_version, then it is almost
  78. certainly Solaris 2. */
  79. if (bfd_get_section_by_name (abfd, ".SUNW_version"))
  80. return GDB_OSABI_SOLARIS;
  81. return GDB_OSABI_UNKNOWN;
  82. }
  83. void _initialize_i386_sol2_tdep ();
  84. void
  85. _initialize_i386_sol2_tdep ()
  86. {
  87. /* Register an ELF OS ABI sniffer for Solaris 2 binaries. */
  88. gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
  89. i386_sol2_osabi_sniffer);
  90. gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
  91. i386_sol2_init_abi);
  92. }