forked from OSchip/llvm-project
[NFC][sanitizer] Remove unnececary HOOK macros
This commit is contained in:
parent
f8a38500e3
commit
b84673b3f4
|
@ -597,7 +597,9 @@ struct Allocator {
|
|||
CHECK_LE(alloc_beg + sizeof(LargeChunkHeader), chunk_beg);
|
||||
reinterpret_cast<LargeChunkHeader *>(alloc_beg)->Set(m);
|
||||
}
|
||||
ASAN_MALLOC_HOOK(res, size);
|
||||
if (&__sanitizer_malloc_hook)
|
||||
__sanitizer_malloc_hook(res, size);
|
||||
RunMallocHooks(res, size);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -678,7 +680,9 @@ struct Allocator {
|
|||
return;
|
||||
}
|
||||
|
||||
ASAN_FREE_HOOK(ptr);
|
||||
if (&__sanitizer_free_hook)
|
||||
__sanitizer_free_hook(ptr);
|
||||
RunFreeHooks(ptr);
|
||||
|
||||
// Must mark the chunk as quarantined before any changes to its metadata.
|
||||
// Do not quarantine given chunk if we failed to set CHUNK_QUARANTINE flag.
|
||||
|
|
|
@ -125,22 +125,6 @@ bool HandleDlopenInit();
|
|||
|
||||
void InstallAtExitCheckLeaks();
|
||||
|
||||
// Add convenient macro for interface functions that may be represented as
|
||||
// weak hooks.
|
||||
#define ASAN_MALLOC_HOOK(ptr, size) \
|
||||
do { \
|
||||
if (&__sanitizer_malloc_hook) \
|
||||
__sanitizer_malloc_hook(ptr, size); \
|
||||
RunMallocHooks(ptr, size); \
|
||||
} while (false)
|
||||
|
||||
#define ASAN_FREE_HOOK(ptr) \
|
||||
do { \
|
||||
if (&__sanitizer_free_hook) \
|
||||
__sanitizer_free_hook(ptr); \
|
||||
RunFreeHooks(ptr); \
|
||||
} while (false)
|
||||
|
||||
#define ASAN_ON_ERROR() \
|
||||
if (&__asan_on_error) \
|
||||
__asan_on_error()
|
||||
|
|
|
@ -172,22 +172,6 @@ void HwasanTagMismatch(uptr addr, uptr access_info, uptr *registers_frame,
|
|||
|
||||
} // namespace __hwasan
|
||||
|
||||
#define HWASAN_MALLOC_HOOK(ptr, size) \
|
||||
do { \
|
||||
if (&__sanitizer_malloc_hook) { \
|
||||
__sanitizer_malloc_hook(ptr, size); \
|
||||
} \
|
||||
RunMallocHooks(ptr, size); \
|
||||
} while (false)
|
||||
|
||||
#define HWASAN_FREE_HOOK(ptr) \
|
||||
do { \
|
||||
if (&__sanitizer_free_hook) { \
|
||||
__sanitizer_free_hook(ptr); \
|
||||
} \
|
||||
RunFreeHooks(ptr); \
|
||||
} while (false)
|
||||
|
||||
#if HWASAN_WITH_INTERCEPTORS
|
||||
// For both bionic and glibc __sigset_t is an unsigned long.
|
||||
typedef unsigned long __hw_sigset_t;
|
||||
|
|
|
@ -199,7 +199,9 @@ static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment,
|
|||
}
|
||||
}
|
||||
|
||||
HWASAN_MALLOC_HOOK(user_ptr, size);
|
||||
if (&__sanitizer_malloc_hook)
|
||||
__sanitizer_malloc_hook(user_ptr, size);
|
||||
RunMallocHooks(user_ptr, size);
|
||||
return user_ptr;
|
||||
}
|
||||
|
||||
|
@ -226,7 +228,9 @@ static bool CheckInvalidFree(StackTrace *stack, void *untagged_ptr,
|
|||
|
||||
static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
|
||||
CHECK(tagged_ptr);
|
||||
HWASAN_FREE_HOOK(tagged_ptr);
|
||||
if (&__sanitizer_free_hook)
|
||||
__sanitizer_free_hook(tagged_ptr);
|
||||
RunFreeHooks(tagged_ptr);
|
||||
|
||||
bool in_taggable_region =
|
||||
InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr));
|
||||
|
|
|
@ -430,7 +430,9 @@ struct Allocator {
|
|||
CHECK_LE(alloc_beg + sizeof(LargeChunkHeader), chunk_beg);
|
||||
reinterpret_cast<LargeChunkHeader *>(alloc_beg)->Set(m);
|
||||
}
|
||||
MEMPROF_MALLOC_HOOK(res, size);
|
||||
if (&__sanitizer_malloc_hook)
|
||||
__sanitizer_malloc_hook(res, size);
|
||||
RunMallocHooks(res, size);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -440,7 +442,9 @@ struct Allocator {
|
|||
if (p == 0)
|
||||
return;
|
||||
|
||||
MEMPROF_FREE_HOOK(ptr);
|
||||
if (&__sanitizer_free_hook)
|
||||
__sanitizer_free_hook(ptr);
|
||||
RunFreeHooks(ptr);
|
||||
|
||||
uptr chunk_beg = p - kChunkHeaderSize;
|
||||
MemprofChunk *m = reinterpret_cast<MemprofChunk *>(chunk_beg);
|
||||
|
|
|
@ -76,22 +76,6 @@ void PlatformTSDDtor(void *tsd);
|
|||
|
||||
void *MemprofDlSymNext(const char *sym);
|
||||
|
||||
// Add convenient macro for interface functions that may be represented as
|
||||
// weak hooks.
|
||||
#define MEMPROF_MALLOC_HOOK(ptr, size) \
|
||||
do { \
|
||||
if (&__sanitizer_malloc_hook) \
|
||||
__sanitizer_malloc_hook(ptr, size); \
|
||||
RunMallocHooks(ptr, size); \
|
||||
} while (false)
|
||||
|
||||
#define MEMPROF_FREE_HOOK(ptr) \
|
||||
do { \
|
||||
if (&__sanitizer_free_hook) \
|
||||
__sanitizer_free_hook(ptr); \
|
||||
RunFreeHooks(ptr); \
|
||||
} while (false)
|
||||
|
||||
extern int memprof_inited;
|
||||
extern int memprof_timestamp_inited;
|
||||
extern int memprof_init_done;
|
||||
|
|
|
@ -375,21 +375,4 @@ void MsanTSDDtor(void *tsd);
|
|||
|
||||
} // namespace __msan
|
||||
|
||||
#define MSAN_MALLOC_HOOK(ptr, size) \
|
||||
do { \
|
||||
if (&__sanitizer_malloc_hook) { \
|
||||
UnpoisonParam(2); \
|
||||
__sanitizer_malloc_hook(ptr, size); \
|
||||
} \
|
||||
RunMallocHooks(ptr, size); \
|
||||
} while (false)
|
||||
#define MSAN_FREE_HOOK(ptr) \
|
||||
do { \
|
||||
if (&__sanitizer_free_hook) { \
|
||||
UnpoisonParam(1); \
|
||||
__sanitizer_free_hook(ptr); \
|
||||
} \
|
||||
RunFreeHooks(ptr); \
|
||||
} while (false)
|
||||
|
||||
#endif // MSAN_H
|
||||
|
|
|
@ -194,13 +194,22 @@ static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment,
|
|||
__msan_set_origin(allocated, size, o.raw_id());
|
||||
}
|
||||
}
|
||||
MSAN_MALLOC_HOOK(allocated, size);
|
||||
if (&__sanitizer_malloc_hook) {
|
||||
UnpoisonParam(2);
|
||||
__sanitizer_malloc_hook(allocated, size);
|
||||
}
|
||||
RunMallocHooks(allocated, size);
|
||||
return allocated;
|
||||
}
|
||||
|
||||
void MsanDeallocate(StackTrace *stack, void *p) {
|
||||
CHECK(p);
|
||||
MSAN_FREE_HOOK(p);
|
||||
if (&__sanitizer_free_hook) {
|
||||
UnpoisonParam(1);
|
||||
__sanitizer_free_hook(p);
|
||||
}
|
||||
RunFreeHooks(p);
|
||||
|
||||
Metadata *meta = reinterpret_cast<Metadata *>(allocator.GetMetaData(p));
|
||||
uptr size = meta->requested_size;
|
||||
meta->requested_size = 0;
|
||||
|
|
Loading…
Reference in New Issue