#include "sanitizer_platform.h"
#if SANITIZER_POSIX
#include "sanitizer_common.h"
#include "sanitizer_file.h"
#include "sanitizer_flags.h"
#include "sanitizer_libc.h"
#include "sanitizer_posix.h"
#include "sanitizer_procmaps.h"
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/mman.h>
#if SANITIZER_FREEBSD
#undef MAP_NORESERVE
#define MAP_NORESERVE …
#endif
namespace __sanitizer {
uptr GetMmapGranularity() { … }
bool ErrorIsOOM(error_t err) { … }
void *MmapOrDie(uptr size, const char *mem_type, bool raw_report) { … }
void UnmapOrDie(void *addr, uptr size, bool raw_report) { … }
void *MmapOrDieOnFatalError(uptr size, const char *mem_type) { … }
void *MmapAlignedOrDieOnFatalError(uptr size, uptr alignment,
const char *mem_type) { … }
void *MmapNoReserveOrDie(uptr size, const char *mem_type) { … }
static void *MmapFixedImpl(uptr fixed_addr, uptr size, bool tolerate_enomem,
const char *name) { … }
void *MmapFixedOrDie(uptr fixed_addr, uptr size, const char *name) { … }
void *MmapFixedOrDieOnFatalError(uptr fixed_addr, uptr size, const char *name) { … }
bool MprotectNoAccess(uptr addr, uptr size) { … }
bool MprotectReadOnly(uptr addr, uptr size) { … }
bool MprotectReadWrite(uptr addr, uptr size) { … }
#if !SANITIZER_APPLE
void MprotectMallocZones(void *addr, int prot) { … }
#endif
fd_t OpenFile(const char *filename, FileAccessMode mode, error_t *errno_p) { … }
void CloseFile(fd_t fd) { … }
bool ReadFromFile(fd_t fd, void *buff, uptr buff_size, uptr *bytes_read,
error_t *error_p) { … }
bool WriteToFile(fd_t fd, const void *buff, uptr buff_size, uptr *bytes_written,
error_t *error_p) { … }
void *MapFileToMemory(const char *file_name, uptr *buff_size) { … }
void *MapWritableFileToMemory(void *addr, uptr size, fd_t fd, OFF_T offset) { … }
static inline bool IntervalsAreSeparate(uptr start1, uptr end1,
uptr start2, uptr end2) { … }
bool MemoryRangeIsAvailable(uptr range_start, uptr range_end) { … }
#if !SANITIZER_APPLE
void DumpProcessMap() { … }
#endif
const char *GetPwd() { … }
bool IsPathSeparator(const char c) { … }
bool IsAbsolutePath(const char *path) { … }
void ReportFile::Write(const char *buffer, uptr length) { … }
bool GetCodeRangeForFile(const char *module, uptr *start, uptr *end) { … }
uptr SignalContext::GetAddress() const { … }
bool SignalContext::IsMemoryAccess() const { … }
int SignalContext::GetType() const { … }
const char *SignalContext::Describe() const { … }
fd_t ReserveStandardFds(fd_t fd) { … }
bool ShouldMockFailureToOpen(const char *path) { … }
bool OpenReadsVaArgs(int oflag) { … }
# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_GO
int GetNamedMappingFd(const char *name, uptr size, int *flags) { … }
#else
int GetNamedMappingFd(const char *name, uptr size, int *flags) {
return -1;
}
#endif
#if SANITIZER_ANDROID
#define PR_SET_VMA …
#define PR_SET_VMA_ANON_NAME …
void DecorateMapping(uptr addr, uptr size, const char *name) {
if (!common_flags()->decorate_proc_maps || !name)
return;
internal_prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, addr, size, (uptr)name);
}
#else
void DecorateMapping(uptr addr, uptr size, const char *name) { … }
#endif
uptr MmapNamed(void *addr, uptr length, int prot, int flags, const char *name) { … }
}
#endif