Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/ldd Pull up following revision(s) (requested by n...
details: https://anonhg.NetBSD.org/src/rev/e95a05f133d0
branches: netbsd-9
changeset: 963329:e95a05f133d0
user: martin <martin%NetBSD.org@localhost>
date: Tue Nov 26 08:12:26 2019 +0000
description:
Pull up following revision(s) (requested by nakayama in ticket #469):
lib/libc/tls/tls.c: revision 1.10
lib/libc/tls/tls.c: revision 1.11
lib/libc/tls/tls.c: revision 1.12
lib/libc/tls/tls.c: revision 1.13
libexec/ld.elf_so/tls.c: revision 1.13
libexec/ld.elf_so/tls.c: revision 1.14
libexec/ld.elf_so/Makefile: revision 1.142
lib/libc/tls/Makefile.inc: revision 1.3
usr.bin/ldd/Makefile.elf: revision 1.6
PR 54093: Align static TLS area to max_align_t.
Use alignof and not size_t for platforms with non-natural base
alignments.
Mirror the ld.elf_so logic for handling aligning the TLS size.
Most noticable, recompute the start of the TLS area for variant I
relative to the TCB. This makes a difference when the segment size and
base alignment don't agree.
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/Makefile.inc | 4 ++--
lib/libc/tls/tls.c | 30 +++++++++++++++++++-----------
libexec/ld.elf_so/Makefile | 3 ++-
libexec/ld.elf_so/tls.c | 8 +++++---
usr.bin/ldd/Makefile.elf | 4 +++-
5 files changed, 31 insertions(+), 18 deletions(-)
diffs (166 lines):
diff -r 18638bfaa2ee -r e95a05f133d0 lib/libc/tls/Makefile.inc
--- a/lib/libc/tls/Makefile.inc Mon Nov 25 20:47:24 2019 +0000
+++ b/lib/libc/tls/Makefile.inc Tue Nov 26 08:12:26 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.2 2011/03/12 07:55:09 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2.46.1 2019/11/26 08:12:26 martin Exp $
.include <bsd.own.mk>
@@ -6,4 +6,4 @@
.PATH: ${.PARSEDIR} ${ARCHDIR}/tls
SRCS+= tls.c
-CPPFLAGS.tls.c+= -D_LIBC_SOURCE
+CPPFLAGS.tls.c+= -D_LIBC_SOURCE -std=gnu11
diff -r 18638bfaa2ee -r e95a05f133d0 lib/libc/tls/tls.c
--- a/lib/libc/tls/tls.c Mon Nov 25 20:47:24 2019 +0000
+++ b/lib/libc/tls/tls.c Tue Nov 26 08:12:26 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tls.c,v 1.9 2018/07/13 19:50:21 joerg Exp $ */
+/* $NetBSD: tls.c,v 1.9.2.1 2019/11/26 08:12:26 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.9 2018/07/13 19:50:21 joerg Exp $");
+__RCSID("$NetBSD: tls.c,v 1.9.2.1 2019/11/26 08:12:26 martin Exp $");
#include "namespace.h"
@@ -46,6 +46,7 @@
#include <link_elf.h>
#include <lwp.h>
#include <stdbool.h>
+#include <stdalign.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -84,15 +85,17 @@
uint8_t *p;
if (initial_thread_tcb == NULL) {
-#ifdef __HAVE_TLS_VARIANT_II
- tls_size = roundup2(tls_size, sizeof(void *));
+#ifdef __HAVE_TLS_VARIANT_I
+ tls_allocation = tls_size;
+#else
+ tls_allocation = roundup2(tls_size, alignof(max_align_t));
#endif
- tls_allocation = tls_size + sizeof(*tcb);
- initial_thread_tcb = p = mmap(NULL, tls_allocation,
- PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
+ initial_thread_tcb = p = mmap(NULL,
+ tls_allocation + sizeof(*tcb), PROT_READ | PROT_WRITE,
+ MAP_ANON, -1, 0);
} else {
- p = calloc(1, tls_allocation);
+ p = calloc(1, tls_allocation + sizeof(*tcb));
}
if (p == NULL) {
static const char msg[] = "TLS allocation failed, terminating\n";
@@ -105,7 +108,8 @@
p += sizeof(struct tls_tcb);
#else
/* LINTED tls_size is rounded above */
- tcb = (struct tls_tcb *)(p + tls_size);
+ tcb = (struct tls_tcb *)(p + tls_allocation);
+ p = (uint8_t *)tcb - tls_size;
tcb->tcb_self = tcb;
#endif
memcpy(p, tls_initaddr, tls_initsize);
@@ -125,10 +129,10 @@
p = (uint8_t *)tcb;
#else
/* LINTED */
- p = (uint8_t *)tcb - tls_size;
+ p = (uint8_t *)tcb - tls_allocation;
#endif
if (p == initial_thread_tcb)
- munmap(p, tls_allocation);
+ munmap(p, tls_allocation + sizeof(*tcb));
else
free(p);
}
@@ -148,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;
}
diff -r 18638bfaa2ee -r e95a05f133d0 libexec/ld.elf_so/Makefile
--- a/libexec/ld.elf_so/Makefile Mon Nov 25 20:47:24 2019 +0000
+++ b/libexec/ld.elf_so/Makefile Tue Nov 26 08:12:26 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.141 2019/04/03 21:37:58 christos Exp $
+# $NetBSD: Makefile,v 1.141.2.1 2019/11/26 08:12:26 martin Exp $
#
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
@@ -92,6 +92,7 @@
BINDIR= ${SHLINKINSTALLDIR}
+CPPFLAGS.tls.c+= -std=gnu11
CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
CPPFLAGS+= -I${.CURDIR} -I. -D_KERNTYPES
CPPFLAGS+= -DRTLD_LOADER
diff -r 18638bfaa2ee -r e95a05f133d0 libexec/ld.elf_so/tls.c
--- a/libexec/ld.elf_so/tls.c Mon Nov 25 20:47:24 2019 +0000
+++ b/libexec/ld.elf_so/tls.c Tue Nov 26 08:12:26 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tls.c,v 1.12 2019/04/13 00:23:32 rin Exp $ */
+/* $NetBSD: tls.c,v 1.12.2.1 2019/11/26 08:12:26 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,11 +29,13 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.12 2019/04/13 00:23:32 rin Exp $");
+__RCSID("$NetBSD: tls.c,v 1.12.2.1 2019/11/26 08:12:26 martin Exp $");
#include <sys/param.h>
#include <sys/ucontext.h>
#include <lwp.h>
+#include <stdalign.h>
+#include <stddef.h>
#include <string.h>
#include "debug.h"
#include "rtld.h"
@@ -99,7 +101,7 @@
#ifndef __HAVE_TLS_VARIANT_I
_rtld_tls_static_space = roundup2(_rtld_tls_static_space,
- sizeof(void *));
+ alignof(max_align_t));
#endif
dbg(("_rtld_tls_static_space %zu", _rtld_tls_static_space));
diff -r 18638bfaa2ee -r e95a05f133d0 usr.bin/ldd/Makefile.elf
--- a/usr.bin/ldd/Makefile.elf Mon Nov 25 20:47:24 2019 +0000
+++ b/usr.bin/ldd/Makefile.elf Tue Nov 26 08:12:26 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.elf,v 1.5 2013/05/07 13:00:35 christos Exp $
+# $NetBSD: Makefile.elf,v 1.5.30.1 2019/11/26 08:12:27 martin Exp $
# Makefile fragment to build a (32 or 64 bit) libldd_elfxx.a.
# Expects CPPFLAGS to have ELFSIZE set, and LIB to be set.
@@ -7,4 +7,6 @@
SRCS+= xmalloc.c debug.c expand.c map_object.c load.c search.c \
headers.c paths.c tls.c symver.c
+CPPFLAGS.tls.c+= -std=gnu11
+
.include "Makefile.common"
Home |
Main Index |
Thread Index |
Old Index