NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: PR/54093 CVS commit: src
The following reply was made to PR port-sparc/54093; it has been noted by GNATS.
From: Takeshi Nakayama <nakayama%NetBSD.org@localhost>
To: joerg%bec.de@localhost
Cc: gnats-bugs%netbsd.org@localhost, martin%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
netbsd-bugs%netbsd.org@localhost, gson%gson.org@localhost
Subject: Re: PR/54093 CVS commit: src
Date: Wed, 06 Nov 2019 16:46:27 +0900 (JST)
>>> Takeshi Nakayama <nakayama%NetBSD.org@localhost> wrote
> >>> Joerg Sonnenberger <joerg%bec.de@localhost> wrote
>
> > > I think static TLS area should align with p_align in elf program
> > > header, not with sizeof(max_align_t).
> >
> > We don't support non-standard alignments of TLS. Fixing that is
> > intrusive in the dynamic linker and I have no plan to do that ATM.
>
> Should we follow p_align for static linking? Since it is now
> aligned with a value different from p_align, some atf tests fails
> on amd64 like sparc before the change. Previously, p_align and
> sizeof(void *) had the same value on amd64 by chance.
I prepared a patch that simplified my previous patch to fix for
static linking. Is it okay to commit?
The rounding logic should be correct because it does the same thing
as _rtld_tls_offset_allocate in libexec/ld.elf_so/tls.c.
https://nxr.netbsd.org/xref/src/libexec/ld.elf_so/tls.c#234
-- Takeshi Nakayama
Index: lib/libc/tls/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/tls/Makefile.inc,v
retrieving revision 1.3
diff -u -d -r1.3 Makefile.inc
--- lib/libc/tls/Makefile.inc 4 Nov 2019 12:45:10 -0000 1.3
+++ lib/libc/tls/Makefile.inc 6 Nov 2019 06:29:53 -0000
@@ -6,4 +6,4 @@
.PATH: ${.PARSEDIR} ${ARCHDIR}/tls
SRCS+= tls.c
-CPPFLAGS.tls.c+= -D_LIBC_SOURCE -std=gnu11
+CPPFLAGS.tls.c+= -D_LIBC_SOURCE
Index: lib/libc/tls/tls.c
===================================================================
RCS file: /cvsroot/src/lib/libc/tls/tls.c,v
retrieving revision 1.11
diff -u -d -r1.11 tls.c
--- lib/libc/tls/tls.c 5 Nov 2019 22:22:42 -0000 1.11
+++ lib/libc/tls/tls.c 6 Nov 2019 06:29:53 -0000
@@ -46,7 +46,6 @@
#include <link_elf.h>
#include <lwp.h>
#include <stdbool.h>
-#include <stdalign.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -85,9 +84,6 @@
uint8_t *p;
if (initial_thread_tcb == NULL) {
-#ifdef __HAVE_TLS_VARIANT_II
- tls_size = roundup2(tls_size, alignof(max_align_t));
-#endif
tls_allocation = tls_size + sizeof(*tcb);
initial_thread_tcb = p = mmap(NULL, tls_allocation,
@@ -105,7 +101,7 @@
tcb = (struct tls_tcb *)p;
p += sizeof(struct tls_tcb);
#else
- /* LINTED tls_size is rounded above */
+ /* LINTED tls_size is rounded in __libc_static_tls_setup_cb */
tcb = (struct tls_tcb *)(p + tls_size);
tcb->tcb_self = tcb;
#endif
@@ -149,7 +145,11 @@
continue;
tls_initaddr = (void *)(phdr->p_vaddr + data->dlpi_addr);
tls_initsize = phdr->p_filesz;
+#ifdef __HAVE_TLS_VARIANT_I
tls_size = phdr->p_memsz;
+#else
+ tls_size = roundup2(phdr->p_memsz, phdr->p_align);
+#endif
}
return 0;
}
Home |
Main Index |
Thread Index |
Old Index