Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/tls Determine dynamic binaries by presence of PT_IN...
details: https://anonhg.NetBSD.org/src/rev/44c85395ec52
branches: trunk
changeset: 991434:44c85395ec52
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Jul 13 19:50:21 2018 +0000
description:
Determine dynamic binaries by presence of PT_INTERP. Static PIE has
_DYNAMIC.
diffstat:
lib/libc/tls/tls.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diffs (68 lines):
diff -r 41d01f10d037 -r 44c85395ec52 lib/libc/tls/tls.c
--- a/lib/libc/tls/tls.c Fri Jul 13 19:49:47 2018 +0000
+++ b/lib/libc/tls/tls.c Fri Jul 13 19:50:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tls.c,v 1.8 2014/12/14 23:49:17 chs Exp $ */
+/* $NetBSD: tls.c,v 1.9 2018/07/13 19:50:21 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.8 2014/12/14 23:49:17 chs Exp $");
+__RCSID("$NetBSD: tls.c,v 1.9 2018/07/13 19:50:21 joerg Exp $");
#include "namespace.h"
@@ -45,6 +45,7 @@
#include <sys/mman.h>
#include <link_elf.h>
#include <lwp.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -52,6 +53,7 @@
__dso_hidden void __libc_static_tls_setup(void);
+static bool is_dynamic;
static const void *tls_initaddr;
static size_t tls_initsize;
static size_t tls_size;
@@ -131,8 +133,6 @@
free(p);
}
-__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
-
static int __section(".text.startup")
__libc_static_tls_setup_cb(struct dl_phdr_info *data, size_t len, void *cookie)
{
@@ -140,6 +140,10 @@
const Elf_Phdr *phlimit = data->dlpi_phdr + data->dlpi_phnum;
for (; phdr < phlimit; ++phdr) {
+ if (phdr->p_type == PT_INTERP) {
+ is_dynamic = true;
+ return -1;
+ }
if (phdr->p_type != PT_TLS)
continue;
tls_initaddr = (void *)(phdr->p_vaddr + data->dlpi_addr);
@@ -154,11 +158,9 @@
{
struct tls_tcb *tcb;
- if (&rtld_DYNAMIC != NULL) {
+ dl_iterate_phdr(__libc_static_tls_setup_cb, NULL);
+ if (is_dynamic)
return;
- }
-
- dl_iterate_phdr(__libc_static_tls_setup_cb, NULL);
tcb = _rtld_tls_allocate();
#ifdef __HAVE___LWP_SETTCB
Home |
Main Index |
Thread Index |
Old Index