未验证 提交 b06e4cfd 编写于 作者: O openharmony_ci 提交者: Gitee

!374 解决 编译asan 版本时找不到 符号的问题

Merge pull request !374 from shuxinyiA/OpenHarmony-3.1-Release
......@@ -27,8 +27,10 @@ enum EnumHookMode {
STEP_HOOK_MODE,
};
#ifdef HOOK_ENABLE
extern void* function_of_shared_lib[];
extern volatile atomic_llong ohos_malloc_hook_shared_liibrary;
#endif
#ifdef __cplusplus
extern "C" {
......@@ -37,13 +39,18 @@ extern "C" {
__attribute__((always_inline))
inline bool __get_global_hook_flag()
{
#ifdef HOOK_ENABLE
volatile bool g_flag = atomic_load_explicit(&__hook_enable_hook_flag, memory_order_acquire);
return g_flag;
#else
return false;
#endif
}
__attribute__((always_inline))
inline bool __get_hook_flag()
{
#ifdef HOOK_ENABLE
volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire);
if (impl_handle == NULL) {
return false;
......@@ -56,11 +63,15 @@ inline bool __get_hook_flag()
bool flag = get_hook_func_ptr();
return flag;
}
#else
return false;
#endif
}
__attribute__((always_inline))
inline bool __set_hook_flag(bool flag)
{
#ifdef HOOK_ENABLE
volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire);
if (impl_handle == NULL) {
return false;
......@@ -72,11 +83,15 @@ inline bool __set_hook_flag(bool flag)
SetHookFlagType set_hook_func_ptr = (SetHookFlagType)(function_of_shared_lib[SET_HOOK_FLAG_FUNCTION]);
return set_hook_func_ptr(flag);
}
#else
return false;
#endif
}
__attribute__((always_inline))
inline volatile const struct MallocDispatchType* get_current_dispatch_table()
{
#ifdef HOOK_ENABLE
volatile const struct MallocDispatchType* ret = (struct MallocDispatchType *)atomic_load_explicit(&__musl_libc_globals.current_dispatch_table, memory_order_acquire);
if (ret != NULL) {
if (!__get_global_hook_flag()) {
......@@ -87,6 +102,9 @@ inline volatile const struct MallocDispatchType* get_current_dispatch_table()
}
}
return ret;
#else
return NULL;
#endif
}
#define MUSL_HOOK_PARAM_NAME "libc.hook_mode"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册