cxx_exception_stubs.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #include <cstdlib>
  2. #include <cstdio>
  3. #include <exception>
  4. #include <bits/functexcept.h>
  5. #include <sdkconfig.h>
  6. #ifndef CONFIG_COMPILER_CXX_EXCEPTIONS
  7. extern "C" void abort_expect_void(const void *context)
  8. {
  9. abort();
  10. }
  11. extern "C" void *abort_expect_void_and_return(const void *context)
  12. {
  13. abort();
  14. return nullptr;
  15. }
  16. extern "C" void *forward_abort_uw_ctx(struct _Unwind_Context *context)
  17. {
  18. return abort_expect_void_and_return((void*) context);
  19. }
  20. template<typename T>
  21. static T abort_return()
  22. {
  23. abort();
  24. return static_cast<T>(0);
  25. }
  26. // unwind-dw2-fde.o
  27. extern "C" void __wrap__Unwind_SetEnableExceptionFdeSorting(unsigned char enable)
  28. {
  29. abort();
  30. }
  31. extern "C" void __wrap___register_frame_info_bases (const void *begin, struct object *ob, void *tbase, void *dbase)
  32. {
  33. abort();
  34. }
  35. extern "C" void __wrap___register_frame_info (const void *begin, struct object *ob)
  36. {
  37. abort();
  38. }
  39. extern "C" void __wrap___register_frame_info_table_bases (void *begin, struct object *ob, void *tbase, void *dbase)
  40. {
  41. abort();
  42. }
  43. extern "C" void __wrap___register_frame_info_table (void *begin, struct object *ob)
  44. {
  45. abort();
  46. }
  47. extern "C" void __wrap___register_frame (void *begin)
  48. __attribute__((alias("abort_expect_void")));
  49. extern "C" void __wrap___register_frame_table (void *begin)
  50. __attribute__((alias("abort_expect_void")));
  51. extern "C" void *__wrap___deregister_frame_info_bases (const void *begin)
  52. __attribute__((alias("abort_expect_void_and_return")));
  53. extern "C" void *__wrap___deregister_frame_info (const void *begin)
  54. __attribute__((alias("abort_expect_void_and_return")));
  55. extern "C" void __wrap___deregister_frame (void *begin)
  56. __attribute__((alias("abort_expect_void")));
  57. typedef void* fde;
  58. extern "C" const fde * __wrap__Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
  59. {
  60. return abort_return<fde*>();
  61. }
  62. // unwind-dw2.o (riscv), unwind-dw2-xtensa.o (xtensa)
  63. typedef void* _Unwind_Ptr;
  64. typedef int _Unwind_Word;
  65. extern "C" _Unwind_Word __wrap__Unwind_GetGR (struct _Unwind_Context *context, int index)
  66. {
  67. return abort_return<_Unwind_Word>();
  68. }
  69. extern "C" _Unwind_Word __wrap__Unwind_GetCFA (struct _Unwind_Context *context)
  70. {
  71. return abort_return<_Unwind_Word>();
  72. }
  73. extern "C" void __wrap__Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr val)
  74. {
  75. abort();
  76. }
  77. extern "C" void __wrap__Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
  78. {
  79. abort();
  80. }
  81. extern "C" _Unwind_Ptr __wrap__Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
  82. {
  83. return abort_return<_Unwind_Ptr>();
  84. }
  85. extern "C" _Unwind_Ptr __wrap__Unwind_GetIP (struct _Unwind_Context *context)
  86. __attribute__((alias("forward_abort_uw_ctx")));
  87. extern "C" _Unwind_Ptr __wrap__Unwind_GetRegionStart (struct _Unwind_Context *context)
  88. __attribute__((alias("forward_abort_uw_ctx")));
  89. extern "C" _Unwind_Ptr __wrap__Unwind_GetDataRelBase (struct _Unwind_Context *context)
  90. __attribute__((alias("forward_abort_uw_ctx")));
  91. extern "C" _Unwind_Ptr __wrap__Unwind_GetTextRelBase (struct _Unwind_Context *context)
  92. __attribute__((alias("forward_abort_uw_ctx")));
  93. extern "C" void *__wrap__Unwind_GetLanguageSpecificData (struct _Unwind_Context *context)
  94. __attribute__((alias("forward_abort_uw_ctx")));
  95. extern "C" void *__wrap__Unwind_FindEnclosingFunction (void *pc)
  96. __attribute__((alias("abort_expect_void_and_return")));
  97. struct frame_state *__frame_state_for (void *pc_target, struct frame_state *state_in)
  98. {
  99. return abort_return<struct frame_state *>();
  100. }
  101. // unwind.inc
  102. typedef int _Unwind_Reason_Code;
  103. typedef int _Unwind_Action;
  104. typedef int _Unwind_Exception_Class;
  105. typedef int* _Unwind_Trace_Fn;
  106. typedef int* _Unwind_Stop_Fn;
  107. extern "C" void __wrap__Unwind_Resume (struct _Unwind_Exception *exc)
  108. {
  109. abort();
  110. }
  111. extern "C" void __wrap__Unwind_DeleteException (struct _Unwind_Exception *exc)
  112. {
  113. abort();
  114. }
  115. extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException(struct _Unwind_Exception *exc)
  116. {
  117. return abort_return<_Unwind_Reason_Code>();
  118. }
  119. extern "C" _Unwind_Reason_Code __wrap__Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc)
  120. __attribute__((alias("__wrap__Unwind_RaiseException")));
  121. extern "C" _Unwind_Reason_Code __wrap__Unwind_ForcedUnwind (struct _Unwind_Exception *exc,
  122. _Unwind_Stop_Fn stop, void * stop_argument)
  123. {
  124. return abort_return<_Unwind_Reason_Code>();
  125. }
  126. extern "C" _Unwind_Reason_Code __wrap__Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
  127. {
  128. return abort_return<_Unwind_Reason_Code>();
  129. }
  130. // eh_personality.o
  131. extern "C" void __wrap___cxa_call_unexpected (void *exc_obj_in)
  132. __attribute__((alias("abort_expect_void")));
  133. extern "C" _Unwind_Reason_Code __wrap___gxx_personality_v0 (int version,
  134. _Unwind_Action actions,
  135. _Unwind_Exception_Class exception_class,
  136. struct _Unwind_Exception *ue_header,
  137. struct _Unwind_Context *context)
  138. {
  139. return abort_return<_Unwind_Reason_Code>();
  140. }
  141. #endif // CONFIG_COMPILER_CXX_EXCEPTIONS