Module Name:    src
Committed By:   joerg
Date:           Tue Jul 24 13:48:48 UTC 2018

Modified Files:
        src/libexec/ld.elf_so: headers.c

Log Message:
Apply relocbase for tlsinit of the executable itself. Fixes PIE where
relocbase typically is not zero.

PR bin/53465


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/libexec/ld.elf_so/headers.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ld.elf_so/headers.c
diff -u src/libexec/ld.elf_so/headers.c:1.63 src/libexec/ld.elf_so/headers.c:1.64
--- src/libexec/ld.elf_so/headers.c:1.63	Thu May 24 17:05:54 2018
+++ src/libexec/ld.elf_so/headers.c	Tue Jul 24 13:48:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: headers.c,v 1.63 2018/05/24 17:05:54 christos Exp $	 */
+/*	$NetBSD: headers.c,v 1.64 2018/07/24 13:48:48 joerg Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.63 2018/05/24 17:05:54 christos Exp $");
+__RCSID("$NetBSD: headers.c,v 1.64 2018/07/24 13:48:48 joerg Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -449,7 +449,8 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, 
 			obj->tlssize = ph->p_memsz;
 			obj->tlsalign = ph->p_align;
 			obj->tlsinitsize = ph->p_filesz;
-			obj->tlsinit = (void *)(uintptr_t)ph->p_vaddr;
+			obj->tlsinit = (void *)(obj->relocbase +
+			    (uintptr_t)ph->p_vaddr);
 			dbg(("headers: %s %p phsize %" PRImemsz,
 			    "PT_TLS", (void *)(uintptr_t)vaddr,
 			     ph->p_memsz));

Reply via email to