Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/tls Fix PR/54074 and PR/54093 completely.



details:   https://anonhg.NetBSD.org/src/rev/357ec83d6e73
branches:  trunk
changeset: 461295:357ec83d6e73
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Thu Nov 21 23:06:15 2019 +0000

description:
Fix PR/54074 and PR/54093 completely.

More similar to the ld.elf_so logic, it is necessary to align with
p_align first.  Also, invert the #ifdef condition for consistency.

Should fix regression for static linking binaries:
http://releng.netbsd.org/b5reports/sparc/commits-2019.11.html#2019.11.10.23.39.03
http://releng.netbsd.org/b5reports/sparc64/commits-2019.11.html#2019.11.16.04.10.33

diffstat:

 lib/libc/tls/tls.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 8ee8b2ff7f0a -r 357ec83d6e73 lib/libc/tls/tls.c
--- a/lib/libc/tls/tls.c        Thu Nov 21 22:29:03 2019 +0000
+++ b/lib/libc/tls/tls.c        Thu Nov 21 23:06:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tls.c,v 1.12 2019/11/07 22:25:21 joerg Exp $   */
+/*     $NetBSD: tls.c,v 1.13 2019/11/21 23:06:15 nakayama Exp $        */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.12 2019/11/07 22:25:21 joerg Exp $");
+__RCSID("$NetBSD: tls.c,v 1.13 2019/11/21 23:06:15 nakayama Exp $");
 
 #include "namespace.h"
 
@@ -85,10 +85,10 @@
        uint8_t *p;
 
        if (initial_thread_tcb == NULL) {
-#ifdef __HAVE_TLS_VARIANT_II
+#ifdef __HAVE_TLS_VARIANT_I
+               tls_allocation = tls_size;
+#else
                tls_allocation = roundup2(tls_size, alignof(max_align_t));
-#else
-               tls_allocation = tls_size;
 #endif
 
                initial_thread_tcb = p = mmap(NULL,
@@ -152,7 +152,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