unwind.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Header file for the ARM EABI unwinder
  2. Copyright (C) 2003-2017 Free Software Foundation, Inc.
  3. Contributed by Paul Brook
  4. This file is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 3, or (at your option) any
  7. later version.
  8. This file is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. /* Language-independent unwinder header public defines. This contains both
  20. ABI defined objects, and GNU support routines. */
  21. #ifndef UNWIND_ARM_H
  22. #define UNWIND_ARM_H
  23. #include "unwind-arm-common.h"
  24. #define UNWIND_STACK_REG 13
  25. /* Use IP as a scratch register within the personality routine. */
  26. #define UNWIND_POINTER_REG 12
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Decode an R_ARM_TARGET2 relocation. */
  31. static inline _Unwind_Word
  32. _Unwind_decode_typeinfo_ptr (_Unwind_Word base __attribute__ ((unused)),
  33. _Unwind_Word ptr)
  34. {
  35. _Unwind_Word tmp;
  36. tmp = *(_Unwind_Word *) ptr;
  37. /* Zero values are always NULL. */
  38. if (!tmp)
  39. return 0;
  40. #if (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__) \
  41. || defined(__FreeBSD__) || defined(__fuchsia__)
  42. /* Pc-relative indirect. */
  43. #define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_pcrel | DW_EH_PE_indirect)
  44. tmp += ptr;
  45. tmp = *(_Unwind_Word *) tmp;
  46. #elif defined(__symbian__) || defined(__uClinux__)
  47. #define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_absptr)
  48. /* Absolute pointer. Nothing more to do. */
  49. #else
  50. #define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_pcrel)
  51. /* Pc-relative pointer. */
  52. tmp += ptr;
  53. #endif
  54. return tmp;
  55. }
  56. static inline _Unwind_Reason_Code
  57. __gnu_unwind_24bit (_Unwind_Context * context __attribute__ ((unused)),
  58. _uw data __attribute__ ((unused)),
  59. int compact __attribute__ ((unused)))
  60. {
  61. return _URC_FAILURE;
  62. }
  63. #ifndef __FreeBSD__
  64. /* Return the address of the instruction, not the actual IP value. */
  65. #define _Unwind_GetIP(context) \
  66. (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
  67. #define _Unwind_SetIP(context, val) \
  68. _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
  69. #else
  70. #undef _Unwind_GetIPInfo
  71. _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
  72. _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
  73. void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
  74. #endif
  75. #ifdef __cplusplus
  76. } /* extern "C" */
  77. #endif
  78. #endif /* defined UNWIND_ARM_H */