[PATCH] [lsan] [mips] adding support of lsan for mips64/mips64el arch
Sagar.Thakur at imgtec.com
Wed Jan 14 23:06:04 PST 2015
As per my understanding of the TLS memory layout and the TLS part required for sanitizers, we need to get the range of static TLS area in GetTls ().
X86_64 uses tls variant 2 and `TLS_TCB_AT_TP` is set to 1 in tls.h. So the size we get from `__dl_tls_get_static_info ()` includes the thread descriptor size along with size of static TLS area as per the following code in elf/dl-tls.c:
223 GL(dl_tls_static_used) = offset;
224 GL(dl_tls_static_size) = (roundup (offset + TLS_STATIC_SURPLUS, max_align)
225 + TLS_TCB_SIZE);
Therefore we need the Thread Descriptor Size, so that we can exclude it from the size we get from `__dl_tls_get_static_info ()`.
But MIPS uses TLS variant 1 and `TLS_DTV_AT_TP` is set to 1 in tls.h. So the size we get from `__dl_tls_get_static_info ()` is only the size of static TLS area and does not include the thread descriptor size as per the following code in elf/dl-tls.c:
267 GL(dl_tls_static_used) = offset;
268 GL(dl_tls_static_size) = roundup (offset + TLS_STATIC_SURPLUS,
Also when we read from hardware register $29 and subtract 0x7000 from it we reach to the start of static TLS (which is also end of TCB for TLS variant 1).
Therefore we already have the start address and size of static TLS area so we don't require TlsPreTcbSize () and ThreadDescriptorSize () at all for MIPS.
Documents refered :
More information about the llvm-commits