]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/sanitizer_common/sanitizer_tls_get_addr.h
Remove support for alternative Solaris 11.4 ld -V output
[thirdparty/gcc.git] / libsanitizer / sanitizer_common / sanitizer_tls_get_addr.h
CommitLineData
7d752f28 1//===-- sanitizer_tls_get_addr.h --------------------------------*- C++ -*-===//
2//
3// This file is distributed under the University of Illinois Open Source
4// License. See LICENSE.TXT for details.
5//
6//===----------------------------------------------------------------------===//
7//
8// Handle the __tls_get_addr call.
9//
10// All this magic is specific to glibc and is required to workaround
11// the lack of interface that would tell us about the Dynamic TLS (DTLS).
12// https://sourceware.org/bugzilla/show_bug.cgi?id=16291
13//
14// The matters get worse because the glibc implementation changed between
15// 2.18 and 2.19:
16// https://groups.google.com/forum/#!topic/address-sanitizer/BfwYD8HMxTM
17//
18// Before 2.19, every DTLS chunk is allocated with __libc_memalign,
19// which we intercept and thus know where is the DTLS.
20// Since 2.19, DTLS chunks are allocated with __signal_safe_memalign,
21// which is an internal function that wraps a mmap call, neither of which
22// we can intercept. Luckily, __signal_safe_memalign has a simple parseable
23// header which we can use.
24//
25//===----------------------------------------------------------------------===//
26
27#ifndef SANITIZER_TLS_GET_ADDR_H
28#define SANITIZER_TLS_GET_ADDR_H
29
30#include "sanitizer_common.h"
31
32namespace __sanitizer {
33
34struct DTLS {
35 // Array of DTLS chunks for the current Thread.
36 // If beg == 0, the chunk is unused.
37 struct DTV {
38 uptr beg, size;
39 };
40
41 uptr dtv_size;
42 DTV *dtv; // dtv_size elements, allocated by MmapOrDie.
43
44 // Auxiliary fields, don't access them outside sanitizer_tls_get_addr.cc
45 uptr last_memalign_size;
46 uptr last_memalign_ptr;
47};
48
a9586c9c 49// Returns pointer and size of a linker-allocated TLS block.
50// Each block is returned exactly once.
5645a48f 51DTLS::DTV *DTLS_on_tls_get_addr(void *arg, void *res, uptr static_tls_begin,
52 uptr static_tls_end);
7d752f28 53void DTLS_on_libc_memalign(void *ptr, uptr size);
54DTLS *DTLS_Get();
55void DTLS_Destroy(); // Make sure to call this before the thread is destroyed.
36093749 56// Returns true if DTLS of suspended thread is in destruction process.
57bool DTLSInDestruction(DTLS *dtls);
7d752f28 58
59} // namespace __sanitizer
60
61#endif // SANITIZER_TLS_GET_ADDR_H