2021-02-01 11:33:13 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_INTRIN_ASAN_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_INTRIN_ASAN_H_
|
2021-05-14 12:36:58 +00:00
|
|
|
#include "libc/calls/struct/iovec.h"
|
2022-03-16 20:33:13 +00:00
|
|
|
#include "libc/intrin/asancodes.h"
|
2021-10-14 00:27:13 +00:00
|
|
|
#include "libc/macros.internal.h"
|
2022-03-16 20:33:13 +00:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
2021-10-14 00:27:13 +00:00
|
|
|
|
|
|
|
#define SHADOW(x) ((signed char *)(((intptr_t)(x) >> kAsanScale) + kAsanMagic))
|
|
|
|
#define UNSHADOW(x) ((void *)(MAX(0, (intptr_t)(x)-kAsanMagic) << kAsanScale))
|
|
|
|
|
|
|
|
typedef void __asan_die_f(void);
|
2021-02-01 11:33:13 +00:00
|
|
|
|
2021-09-28 05:58:51 +00:00
|
|
|
struct AsanFault {
|
2021-10-14 00:27:13 +00:00
|
|
|
signed char kind;
|
2022-03-16 20:33:13 +00:00
|
|
|
const signed char *shadow;
|
2021-09-28 05:58:51 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 23:41:29 +00:00
|
|
|
void __asan_unpoison(void *, long);
|
|
|
|
void __asan_poison(void *, long, signed char);
|
2021-09-28 05:58:51 +00:00
|
|
|
void __asan_verify(const void *, size_t);
|
2022-11-02 05:36:03 +00:00
|
|
|
void __asan_verify_str(const char *);
|
2021-02-01 11:33:13 +00:00
|
|
|
void __asan_map_shadow(uintptr_t, size_t);
|
2021-10-14 00:27:13 +00:00
|
|
|
bool __asan_is_valid(const void *, long) nosideeffect;
|
2022-11-02 05:36:03 +00:00
|
|
|
bool __asan_is_valid_str(const char *) nosideeffect;
|
|
|
|
bool __asan_is_valid_strlist(char *const *) nosideeffect;
|
2021-10-14 00:27:13 +00:00
|
|
|
bool __asan_is_valid_iov(const struct iovec *, int) nosideeffect;
|
|
|
|
struct AsanFault __asan_check(const void *, long) nosideeffect;
|
2022-11-02 05:36:03 +00:00
|
|
|
struct AsanFault __asan_check_str(const char *) nosideeffect;
|
2021-10-14 00:27:13 +00:00
|
|
|
|
2021-09-28 05:58:51 +00:00
|
|
|
void __asan_free(void *);
|
|
|
|
void *__asan_malloc(size_t);
|
2022-09-11 18:02:07 +00:00
|
|
|
int __asan_is_leaky(void *);
|
2021-10-14 00:27:13 +00:00
|
|
|
int __asan_malloc_trim(size_t);
|
|
|
|
int __asan_print_trace(void *);
|
2021-09-28 05:58:51 +00:00
|
|
|
void *__asan_calloc(size_t, size_t);
|
|
|
|
void *__asan_realloc(void *, size_t);
|
2021-10-14 00:27:13 +00:00
|
|
|
void *__asan_memalign(size_t, size_t);
|
|
|
|
size_t __asan_get_heap_size(const void *);
|
2021-09-28 05:58:51 +00:00
|
|
|
void *__asan_realloc_in_place(void *, size_t);
|
2021-02-01 11:33:13 +00:00
|
|
|
|
2022-03-16 20:33:13 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
2021-02-01 11:33:13 +00:00
|
|
|
#endif /* COSMOPOLITAN_LIBC_INTRIN_ASAN_H_ */
|