#include "sanitizer_tls_get_addr.h"
#include "sanitizer_allocator_interface.h"
#include "sanitizer_atomic.h"
#include "sanitizer_flags.h"
#include "sanitizer_platform_interceptors.h"
namespace __sanitizer {
#if SANITIZER_INTERCEPT_TLS_GET_ADDR
struct TlsGetAddrParam { … };
__attribute__((tls_model("initial-exec")))
static __thread DTLS dtls;
static atomic_uintptr_t number_of_live_dtls;
static const uptr kDestroyedThread = …;
static void DTLS_Deallocate(DTLS::DTVBlock *block) { … }
static DTLS::DTVBlock *DTLS_NextBlock(atomic_uintptr_t *cur) { … }
static DTLS::DTV *DTLS_Find(uptr id) { … }
void DTLS_Destroy() { … }
#if defined(__powerpc64__) || defined(__mips__)
static const uptr kDtvOffset = 0x8000;
#elif defined(__riscv)
static const uptr kDtvOffset = 0x800;
#else
static const uptr kDtvOffset = …;
#endif
extern "C" {
SANITIZER_WEAK_ATTRIBUTE
uptr __sanitizer_get_allocated_size(const void *p);
SANITIZER_WEAK_ATTRIBUTE
const void *__sanitizer_get_allocated_begin(const void *p);
}
SANITIZER_INTERFACE_WEAK_DEF(uptr, __sanitizer_get_dtls_size,
const void *tls_begin) { … }
DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
uptr static_tls_begin, uptr static_tls_end) { … }
DTLS *DTLS_Get() { … }
bool DTLSInDestruction(DTLS *dtls) { … }
#else
SANITIZER_INTERFACE_WEAK_DEF(uptr, __sanitizer_get_dtls_size, const void *) {
return 0;
}
DTLS::DTV *DTLS_on_tls_get_addr(void *arg, void *res,
unsigned long, unsigned long) { return 0; }
DTLS *DTLS_Get() { return 0; }
void DTLS_Destroy() {}
bool DTLSInDestruction(DTLS *dtls) {
UNREACHABLE("dtls is unsupported on this platform!");
}
#endif
}