Skip to content

Commit 175b65b

Browse files
CmiTLS: Round segment sizes up to alignment for each shared object
1 parent e192cf0 commit 175b65b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/util/cmitls.C

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ static int count_tls_sizes(struct dl_phdr_info* info, size_t size, void* data)
106106
const ElfW(Phdr) * hdr = &info->dlpi_phdr[i];
107107
if (hdr->p_type == PT_TLS)
108108
{
109-
t->size += hdr->p_memsz;
110-
if (t->align < hdr->p_align)
111-
t->align = hdr->p_align;
109+
const size_t align = hdr->p_align;
110+
t->size += CMIALIGN(hdr->p_memsz, align);
111+
if (t->align < align)
112+
t->align = align;
112113
}
113114
}
114115

@@ -331,8 +332,8 @@ static void populateTLSSegStats(tlsseg_t * t)
331332
Phdr* phdr = getTLSPhdrEntry();
332333
if (phdr != NULL)
333334
{
334-
t->align = phdr->p_align;
335-
t->size = phdr->p_memsz;
335+
const size_t align = t->align = phdr->p_align;
336+
t->size = CMIALIGN(phdr->p_memsz, align);
336337
}
337338
else
338339
{
@@ -383,7 +384,6 @@ void allocNewTLSSeg(tlsseg_t* t, CthThread th)
383384

384385
if (t->size > 0)
385386
{
386-
t->size = CMIALIGN(t->size, t->align);
387387
t->memseg = (Addr)CmiIsomallocMallocAlignForThread(th, t->align, t->size);
388388
memcpy((void*)t->memseg, (char *)getTLS() - t->size, t->size);
389389
t->memseg = (Addr)( ((char *)(t->memseg)) + t->size );

0 commit comments

Comments
 (0)