@@ -85,13 +85,6 @@ int find_dynamic_unwind_sections(uintptr_t addr,
85
85
typedef int (*unw_find_dynamic_unwind_sections)(
86
86
uintptr_t addr, struct unw_dynamic_unwind_sections * info);
87
87
88
- void removeFindDynamicUnwindSections () {
89
- if (auto * unw_remove_find_dynamic_unwind_sections = (int (*)(
90
- unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
91
- dlsym (RTLD_DEFAULT, " __unw_remove_find_dynamic_unwind_sections" ))
92
- unw_remove_find_dynamic_unwind_sections (find_dynamic_unwind_sections);
93
- }
94
-
95
88
#endif // __APPLE__
96
89
97
90
namespace Cpp {
@@ -109,7 +102,10 @@ namespace Cpp {
109
102
struct InterpDeleter {
110
103
~InterpDeleter () {
111
104
#ifdef __APPLE__
112
- removeFindDynamicUnwindSections ();
105
+ if (auto * unw_remove_find_dynamic_unwind_sections = (int (*)(
106
+ unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
107
+ dlsym (RTLD_DEFAULT, " __unw_remove_find_dynamic_unwind_sections" ))
108
+ unw_remove_find_dynamic_unwind_sections (find_dynamic_unwind_sections);
113
109
#endif
114
110
sInterpreter .release ();
115
111
}
@@ -2652,6 +2648,14 @@ namespace Cpp {
2652
2648
// FIXME: Enable this assert once we figure out how to fix the multiple
2653
2649
// calls to CreateInterpreter.
2654
2650
// assert(!sInterpreter && "Interpreter already set.");
2651
+ #ifdef __APPLE__
2652
+ // Add a handler to support exceptions from interpreted code.
2653
+ // See llvm/llvm-project#49036
2654
+ if (auto * unw_add_find_dynamic_unwind_sections = (int (*)(
2655
+ unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
2656
+ dlsym (RTLD_DEFAULT, " __unw_add_find_dynamic_unwind_sections" ))
2657
+ unw_add_find_dynamic_unwind_sections (find_dynamic_unwind_sections);
2658
+ #endif // __APPLE__
2655
2659
sInterpreter .reset (I);
2656
2660
return I;
2657
2661
}
0 commit comments