|
Message-ID: <CA+RmVGwxcGU8pai0-FfvNuvcfbmiugqj1sOHHUeEFQ6_AQOxsA@mail.gmail.com> Date: Sat, 26 May 2018 10:24:43 +0200 From: Phillip Berndt <phillip.berndt@...glemail.com> To: musl@...ts.openwall.com Subject: Re: TLS issue on aarch64 2018-05-26 2:54 GMT+02:00 Szabolcs Nagy <nsz@...t70.net>: > indeed you need another alignment there, i came up with the > following fix: > > (on mips/ppc i expect it not to change anything: tp is > at a page aligned offset from the end of struct pthread, > so one alignment is enough there, but on aarch64/arm/sh4 > this makes a difference, and seems to pass my simple tests) > > diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c > index 1c5d98a0..8e70024d 100644 > --- a/src/env/__init_tls.c > +++ b/src/env/__init_tls.c > @@ -41,9 +41,12 @@ void *__copy_tls(unsigned char *mem) > #ifdef TLS_ABOVE_TP > dtv = (void **)(mem + libc.tls_size) - (libc.tls_cnt + 1); > > - mem += -((uintptr_t)mem + sizeof(struct pthread)) & (libc.tls_align-1); > + /* Ensure TP is aligned. */ > + mem += -(uintptr_t)TP_ADJ(mem) & (libc.tls_align-1); > td = (pthread_t)mem; > mem += sizeof(struct pthread); > + /* Ensure TLS is aligned after struct pthread. */ > + mem += -(uintptr_t)mem & (libc.tls_align-1); > > for (i=1, p=libc.tls_head; p; i++, p=p->next) { > dtv[i] = mem + p->offset; I took the demo from my first mail and tested your patch with all alignments up to the page size: They all seem to work fine. Awesome :) - Phillip
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.