version 1.11, 2019/11/05 22:22:42 |
version 1.12, 2019/11/07 22:25:21 |
Line 86 _rtld_tls_allocate(void) |
|
Line 86 _rtld_tls_allocate(void) |
|
|
|
if (initial_thread_tcb == NULL) { |
if (initial_thread_tcb == NULL) { |
#ifdef __HAVE_TLS_VARIANT_II |
#ifdef __HAVE_TLS_VARIANT_II |
tls_size = roundup2(tls_size, alignof(max_align_t)); |
tls_allocation = roundup2(tls_size, alignof(max_align_t)); |
|
#else |
|
tls_allocation = tls_size; |
#endif |
#endif |
tls_allocation = tls_size + sizeof(*tcb); |
|
|
|
initial_thread_tcb = p = mmap(NULL, tls_allocation, |
initial_thread_tcb = p = mmap(NULL, |
PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); |
tls_allocation + sizeof(*tcb), PROT_READ | PROT_WRITE, |
|
MAP_ANON, -1, 0); |
} else { |
} else { |
p = calloc(1, tls_allocation); |
p = calloc(1, tls_allocation + sizeof(*tcb)); |
} |
} |
if (p == NULL) { |
if (p == NULL) { |
static const char msg[] = "TLS allocation failed, terminating\n"; |
static const char msg[] = "TLS allocation failed, terminating\n"; |
Line 106 _rtld_tls_allocate(void) |
|
Line 108 _rtld_tls_allocate(void) |
|
p += sizeof(struct tls_tcb); |
p += sizeof(struct tls_tcb); |
#else |
#else |
/* LINTED tls_size is rounded above */ |
/* LINTED tls_size is rounded above */ |
tcb = (struct tls_tcb *)(p + tls_size); |
tcb = (struct tls_tcb *)(p + tls_allocation); |
|
p = (uint8_t *)tcb - tls_size; |
tcb->tcb_self = tcb; |
tcb->tcb_self = tcb; |
#endif |
#endif |
memcpy(p, tls_initaddr, tls_initsize); |
memcpy(p, tls_initaddr, tls_initsize); |
Line 126 _rtld_tls_free(struct tls_tcb *tcb) |
|
Line 129 _rtld_tls_free(struct tls_tcb *tcb) |
|
p = (uint8_t *)tcb; |
p = (uint8_t *)tcb; |
#else |
#else |
/* LINTED */ |
/* LINTED */ |
p = (uint8_t *)tcb - tls_size; |
p = (uint8_t *)tcb - tls_allocation; |
#endif |
#endif |
if (p == initial_thread_tcb) |
if (p == initial_thread_tcb) |
munmap(p, tls_allocation); |
munmap(p, tls_allocation + sizeof(*tcb)); |
else |
else |
free(p); |
free(p); |
} |
} |