#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
SANITIZER_SOLARIS
# include <dlfcn.h>
# include <fcntl.h>
# include <limits.h>
# include <pthread.h>
# include <stdio.h>
# include <sys/mman.h>
# include <sys/resource.h>
# include <sys/syscall.h>
# include <sys/time.h>
# include <sys/types.h>
# include <unistd.h>
# include <unwind.h>
# include "asan_interceptors.h"
# include "asan_internal.h"
# include "asan_premap_shadow.h"
# include "asan_thread.h"
# include "sanitizer_common/sanitizer_flags.h"
# include "sanitizer_common/sanitizer_hash.h"
# include "sanitizer_common/sanitizer_libc.h"
# include "sanitizer_common/sanitizer_procmaps.h"
# if SANITIZER_FREEBSD
# include <sys/link_elf.h>
# endif
# if SANITIZER_SOLARIS
# include <link.h>
# endif
# if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
# include <ucontext.h>
# elif SANITIZER_NETBSD
# include <link_elf.h>
# include <ucontext.h>
# else
# include <link.h>
# include <sys/ucontext.h>
# endif
asan_rt_version_t;
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
asan_rt_version_t __asan_rt_version;
}
namespace __asan {
void InitializePlatformInterceptors() { … }
void InitializePlatformExceptionHandlers() { … }
bool IsSystemHeapAddress(uptr addr) { … }
# if ASAN_PREMAP_SHADOW
uptr FindPremappedShadowStart(uptr shadow_size_bytes) {
uptr granularity = GetMmapGranularity();
uptr shadow_start = reinterpret_cast<uptr>(&__asan_shadow);
uptr premap_shadow_size = PremapShadowSize();
uptr shadow_size = RoundUpTo(shadow_size_bytes, granularity);
UnmapFromTo(shadow_start + shadow_size, shadow_start + premap_shadow_size);
return shadow_start;
}
# endif
uptr FindDynamicShadowStart() { … }
void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { … }
void FlushUnneededASanShadowMemory(uptr p, uptr size) { … }
# if SANITIZER_ANDROID
void AsanCheckDynamicRTPrereqs() {}
void AsanCheckIncompatibleRT() {}
# else
static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size,
void *data) { … }
static bool IsDynamicRTName(const char *libname) { … }
static void ReportIncompatibleRT() { … }
void AsanCheckDynamicRTPrereqs() { … }
void AsanCheckIncompatibleRT() { … }
# endif
# if ASAN_INTERCEPT_SWAPCONTEXT
constexpr u32 kAsanContextStackFlagsMagic = …;
static int HashContextStack(const ucontext_t &ucp) { … }
void SignContextStack(void *context) { … }
void ReadContextStack(void *context, uptr *stack, uptr *ssize) { … }
# endif
void *AsanDlSymNext(const char *sym) { … }
bool HandleDlopenInit() { … }
}
#endif