@@ -60,22 +60,26 @@ void initialize_thunks(const sanitizer_thunk *begin,
60
60
// ------------------ Weak symbol registration macros ---------------------- //
61
61
// Use .WEAK segment to register function pointers that are iterated over during
62
62
// startup that will replace sanitizer_export with local_function
63
+ #ifdef __clang__
64
+ # define REGISTER_WEAK_OPTNONE __attribute__ ((optnone))
65
+ #else
66
+ # define REGISTER_WEAK_OPTNONE
67
+ #endif
63
68
64
- #define REGISTER_WEAK_FUNCTION (local_function ) \
65
- extern " C" void local_function (); \
66
- extern " C" void WEAK_EXPORT_NAME (local_function)(); \
67
- WIN_WEAK_IMPORT_DEF (local_function) \
68
- __attribute__((optnone)) static int register_weak_##local_function() { \
69
- if ((uintptr_t ) & local_function != (uintptr_t ) & \
70
- WEAK_EXPORT_NAME (local_function)) { \
71
- return __sanitizer::register_weak ( \
72
- SANITIZER_STRINGIFY (WEAK_EXPORT_NAME (local_function)), \
73
- reinterpret_cast <__sanitizer::uptr>(local_function)); \
74
- } \
75
- return 0 ; \
76
- } \
77
- __pragma (section(" .WEAK$M" , long , read)) __declspec(allocate( \
78
- " .WEAK$M" )) int (*__sanitizer_register_weak_##local_function)() = \
69
+ #define REGISTER_WEAK_FUNCTION (local_function ) \
70
+ extern " C" void local_function (); \
71
+ extern " C" void WEAK_EXPORT_NAME (local_function)(); \
72
+ WIN_WEAK_IMPORT_DEF (local_function) \
73
+ REGISTER_WEAK_OPTNONE static int register_weak_##local_function() { \
74
+ if ((uintptr_t ) & local_function != (uintptr_t ) & \
75
+ WEAK_EXPORT_NAME (local_function)) { \
76
+ return __sanitizer::register_weak ( \
77
+ SANITIZER_STRINGIFY (WEAK_EXPORT_NAME (local_function)), \
78
+ reinterpret_cast <__sanitizer::uptr>(local_function)); \
79
+ } \
80
+ return 0 ; \
81
+ } \
82
+ __pragma (section(" .WEAK$M" , long , read)) __declspec(allocate( \
83
+ " .WEAK$M" )) int (*__sanitizer_register_weak_##local_function)() = \
79
84
register_weak_##local_function;
80
-
81
85
#endif // SANITIZER_WIN_STATIC_RUNTIME_THUNK_H
0 commit comments