llvm/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp

//===-- sanitizer_common_libcdep.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries.
//===----------------------------------------------------------------------===//

#include "sanitizer_allocator.h"
#include "sanitizer_allocator_interface.h"
#include "sanitizer_common.h"
#include "sanitizer_flags.h"
#include "sanitizer_interface_internal.h"
#include "sanitizer_procmaps.h"
#include "sanitizer_stackdepot.h"

namespace __sanitizer {

#if (SANITIZER_LINUX || SANITIZER_NETBSD) && !SANITIZER_GO
// Weak default implementation for when sanitizer_stackdepot is not linked in.
SANITIZER_WEAK_ATTRIBUTE StackDepotStats StackDepotGetStats() {}

void *BackgroundThread(void *arg) {}

void MaybeStartBackgroudThread() {}

#  if !SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL
#    ifdef __clang__
#    pragma clang diagnostic push
// We avoid global-constructors to be sure that globals are ready when
// sanitizers need them. This can happend before global constructors executed.
// Here we don't mind if thread is started on later stages.
#    pragma clang diagnostic ignored "-Wglobal-constructors"
#    endif
static struct BackgroudThreadStarted {} background_thread_strarter UNUSED;
#    ifdef __clang__
#    pragma clang diagnostic pop
#    endif
#  endif
#else
void MaybeStartBackgroudThread() {}
#endif

void WriteToSyslog(const char *msg) {}

static void (*sandboxing_callback)();
void SetSandboxingCallback(void (*f)()) {}

uptr ReservedAddressRange::InitAligned(uptr size, uptr align,
                                       const char *name) {}

#if !SANITIZER_FUCHSIA

// Reserve memory range [beg, end].
// We need to use inclusive range because end+1 may not be representable.
void ReserveShadowMemoryRange(uptr beg, uptr end, const char *name,
                              bool madvise_shadow) {}

void ProtectGap(uptr addr, uptr size, uptr zero_base_shadow_start,
                uptr zero_base_max_shadow_start) {}

#endif  // !SANITIZER_FUCHSIA

#if !SANITIZER_WINDOWS && !SANITIZER_GO
// Weak default implementation for when sanitizer_stackdepot is not linked in.
SANITIZER_WEAK_ATTRIBUTE void StackDepotStopBackgroundThread() {}
static void StopStackDepotBackgroundThread() {}
#else
// SANITIZER_WEAK_ATTRIBUTE is unsupported.
static void StopStackDepotBackgroundThread() {}
#endif

}  // namespace __sanitizer

SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_sandbox_on_notify,
                             __sanitizer_sandbox_arguments *args) {}