Module Name: src Committed By: nakayama Date: Thu Nov 21 23:06:16 UTC 2019
Modified Files: src/lib/libc/tls: tls.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/tls/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/tls/tls.c diff -u src/lib/libc/tls/tls.c:1.12 src/lib/libc/tls/tls.c:1.13 --- src/lib/libc/tls/tls.c:1.12 Thu Nov 7 22:25:21 2019 +++ src/lib/libc/tls/tls.c Thu Nov 21 23:06:15 2019 @@ -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 @@ _rtld_tls_allocate(void) uint8_t *p; if (initial_thread_tcb == NULL) { -#ifdef __HAVE_TLS_VARIANT_II - tls_allocation = roundup2(tls_size, alignof(max_align_t)); -#else +#ifdef __HAVE_TLS_VARIANT_I tls_allocation = tls_size; +#else + tls_allocation = roundup2(tls_size, alignof(max_align_t)); #endif initial_thread_tcb = p = mmap(NULL, @@ -152,7 +152,11 @@ __libc_static_tls_setup_cb(struct dl_phd 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; }