annotate libsanitizer/sanitizer_common/sanitizer_tls_get_addr.h @ 113:bdf41c9fa0b7

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