Skip to content

Commit 7de7751

Browse files
committed
[hwasan] Provide aliases for c allocation functions for Fuchsia
"Interceptors" in this file aren't like the traditional interceptors used by other sanitizers like asan. They're simply aliases to the equivalent __sanitizer_* functions. This also removes the WRAP(FN) declaration since it just creates declarations for __interceptor_* functions but they seem to be unused. Differential Revision: https://reviews.llvm.org/D145718
1 parent 368cb42 commit 7de7751

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include "sanitizer_common/sanitizer_allocator_interface.h"
1919
#include "sanitizer_common/sanitizer_tls_get_addr.h"
2020

21-
#if !SANITIZER_FUCHSIA
22-
2321
using namespace __hwasan;
2422

2523
struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
@@ -106,6 +104,7 @@ uptr __sanitizer_malloc_usable_size(const void *ptr) {
106104
return __sanitizer_get_allocated_size(ptr);
107105
}
108106

107+
#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
109108
SANITIZER_INTERFACE_ATTRIBUTE
110109
struct __sanitizer_struct_mallinfo __sanitizer_mallinfo() {
111110
__sanitizer_struct_mallinfo sret;
@@ -115,6 +114,7 @@ struct __sanitizer_struct_mallinfo __sanitizer_mallinfo() {
115114

116115
SANITIZER_INTERFACE_ATTRIBUTE
117116
int __sanitizer_mallopt(int cmd, int value) { return 0; }
117+
#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
118118

119119
SANITIZER_INTERFACE_ATTRIBUTE
120120
void __sanitizer_malloc_stats(void) {
@@ -155,12 +155,9 @@ void *__sanitizer_malloc(uptr size) {
155155

156156
} // extern "C"
157157

158-
#if HWASAN_WITH_INTERCEPTORS
159-
# define INTERCEPTOR_ALIAS(RET, FN, ARGS...) \
160-
extern "C" SANITIZER_INTERFACE_ATTRIBUTE RET WRAP(FN)(ARGS) \
161-
ALIAS("__sanitizer_" #FN); \
162-
extern "C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE RET FN( \
163-
ARGS) ALIAS("__sanitizer_" #FN)
158+
#define INTERCEPTOR_ALIAS(RET, FN, ARGS...) \
159+
extern "C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE RET FN( \
160+
ARGS) ALIAS("__sanitizer_" #FN)
164161

165162
INTERCEPTOR_ALIAS(int, posix_memalign, void **memptr, SIZE_T alignment,
166163
SIZE_T size);
@@ -178,10 +175,9 @@ INTERCEPTOR_ALIAS(void *, malloc, SIZE_T size);
178175
INTERCEPTOR_ALIAS(void *, memalign, SIZE_T alignment, SIZE_T size);
179176
INTERCEPTOR_ALIAS(void *, pvalloc, SIZE_T size);
180177
INTERCEPTOR_ALIAS(void, cfree, void *ptr);
178+
#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
181179
INTERCEPTOR_ALIAS(__sanitizer_struct_mallinfo, mallinfo);
182180
INTERCEPTOR_ALIAS(int, mallopt, int cmd, int value);
181+
#endif
183182
INTERCEPTOR_ALIAS(void, malloc_stats, void);
184183
# endif
185-
#endif // #if HWASAN_WITH_INTERCEPTORS
186-
187-
#endif // SANITIZER_FUCHSIA

0 commit comments

Comments
 (0)