Skip to content

Commit ee92645

Browse files
authored
[sanitizer] Change GetDTLSRange (#108345)
We only need to change size, tls_beg should be unchanged.
1 parent 2d47a0b commit ee92645

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ SANITIZER_WEAK_ATTRIBUTE
110110
const void *__sanitizer_get_allocated_begin(const void *p);
111111
}
112112

113-
static bool GetDTLSRange(uptr &tls_beg, uptr &tls_size) {
113+
static uptr GetDTLSRange(uptr tls_beg) {
114114
const void *start = __sanitizer_get_allocated_begin((void *)tls_beg);
115115
if (!start)
116-
return false;
117-
tls_beg = (uptr)start;
118-
tls_size = __sanitizer_get_allocated_size(start);
116+
return 0;
117+
CHECK_EQ(start, (void *)tls_beg);
118+
uptr tls_size = __sanitizer_get_allocated_size(start);
119119
VReport(2, "__tls_get_addr: glibc DTLS suspected; tls={%p,0x%zx}\n",
120120
(void *)tls_beg, tls_size);
121-
return true;
121+
return tls_size;
122122
}
123123

124124
DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
@@ -142,10 +142,12 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
142142
// creation.
143143
VReport(2, "__tls_get_addr: static tls: %p\n", (void *)tls_beg);
144144
tls_size = 0;
145-
} else if (!GetDTLSRange(tls_beg, tls_size)) {
146-
VReport(2, "__tls_get_addr: Can't guess glibc version\n");
147-
// This may happen inside the DTOR of main thread, so just ignore it.
148-
tls_size = 0;
145+
} else {
146+
tls_size = GetDTLSRange(tls_beg);
147+
if (tls_size) {
148+
VReport(2, "__tls_get_addr: Can't guess glibc version\n");
149+
// This may happen inside the DTOR of main thread, so just ignore it.
150+
}
149151
}
150152
dtv->beg = tls_beg;
151153
dtv->size = tls_size;

0 commit comments

Comments
 (0)