Gglobal.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
  5. This file is part of libunwind.
  6. Permission is hereby granted, free of charge, to any person obtaining
  7. a copy of this software and associated documentation files (the
  8. "Software"), to deal in the Software without restriction, including
  9. without limitation the rights to use, copy, modify, merge, publish,
  10. distribute, sublicense, and/or sell copies of the Software, and to
  11. permit persons to whom the Software is furnished to do so, subject to
  12. the following conditions:
  13. The above copyright notice and this permission notice shall be
  14. included in all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  22. #include "unwind_i.h"
  23. #include "dwarf_i.h"
  24. HIDDEN pthread_mutex_t x86_64_lock = PTHREAD_MUTEX_INITIALIZER;
  25. HIDDEN int tdep_needs_initialization = 1;
  26. /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */
  27. HIDDEN uint8_t dwarf_to_unw_regnum_map[DWARF_NUM_PRESERVED_REGS] =
  28. {
  29. UNW_X86_64_RAX,
  30. UNW_X86_64_RDX,
  31. UNW_X86_64_RCX,
  32. UNW_X86_64_RBX,
  33. UNW_X86_64_RSI,
  34. UNW_X86_64_RDI,
  35. UNW_X86_64_RBP,
  36. UNW_X86_64_RSP,
  37. UNW_X86_64_R8,
  38. UNW_X86_64_R9,
  39. UNW_X86_64_R10,
  40. UNW_X86_64_R11,
  41. UNW_X86_64_R12,
  42. UNW_X86_64_R13,
  43. UNW_X86_64_R14,
  44. UNW_X86_64_R15,
  45. UNW_X86_64_RIP,
  46. #ifdef CONFIG_MSABI_SUPPORT
  47. UNW_X86_64_XMM0,
  48. UNW_X86_64_XMM1,
  49. UNW_X86_64_XMM2,
  50. UNW_X86_64_XMM3,
  51. UNW_X86_64_XMM4,
  52. UNW_X86_64_XMM5,
  53. UNW_X86_64_XMM6,
  54. UNW_X86_64_XMM7,
  55. UNW_X86_64_XMM8,
  56. UNW_X86_64_XMM9,
  57. UNW_X86_64_XMM10,
  58. UNW_X86_64_XMM11,
  59. UNW_X86_64_XMM12,
  60. UNW_X86_64_XMM13,
  61. UNW_X86_64_XMM14,
  62. UNW_X86_64_XMM15
  63. #endif
  64. };
  65. HIDDEN void
  66. tdep_init (void)
  67. {
  68. intrmask_t saved_mask;
  69. #if (!HAVE_SGX)
  70. sigfillset (&unwi_full_mask);
  71. #endif
  72. lock_acquire (&x86_64_lock, saved_mask);
  73. {
  74. if (!tdep_needs_initialization)
  75. /* another thread else beat us to it... */
  76. goto out;
  77. mi_init ();
  78. dwarf_init ();
  79. tdep_init_mem_validate ();
  80. #ifndef UNW_REMOTE_ONLY
  81. x86_64_local_addr_space_init ();
  82. #endif
  83. tdep_needs_initialization = 0; /* signal that we're initialized... */
  84. }
  85. out:
  86. lock_release (&x86_64_lock, saved_mask);
  87. }