Skip to content

Commit c74c344

Browse files
author
Siva Chandra Reddy
committed
[libc] Fix alignment logic in TLS image size calculation.
1 parent d7480d0 commit c74c344

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libc/loader/linux/x86_64/start.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ void initTLS() {
3838
return;
3939

4040
// We will assume the alignment is always a power of two.
41-
uintptr_t tlsSize = (app.tls.size + app.tls.align) & -app.tls.align;
41+
uintptr_t tlsSize = app.tls.size & -app.tls.align;
42+
if (tlsSize != app.tls.size)
43+
tlsSize += app.tls.align;
4244

4345
// Per the x86_64 TLS ABI, the entry pointed to by the thread pointer is the
4446
// address of the TLS block. So, we add more size to accomodate this address

0 commit comments

Comments
 (0)