Module Name:    src
Committed By:   snj
Date:           Thu Jul 26 23:45:09 UTC 2018

Modified Files:
        src/libexec/ld.elf_so [netbsd-8]: headers.c

Log Message:
Pull up following revision(s) (requested by joerg in ticket #940):
        libexec/ld.elf_so/headers.c: revision 1.64
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.61.8.1 -r1.61.8.2 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.61.8.1 src/libexec/ld.elf_so/headers.c:1.61.8.2
--- src/libexec/ld.elf_so/headers.c:1.61.8.1	Fri Jun 30 06:28:54 2017
+++ src/libexec/ld.elf_so/headers.c	Thu Jul 26 23:45:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: headers.c,v 1.61.8.1 2017/06/30 06:28:54 snj Exp $	 */
+/*	$NetBSD: headers.c,v 1.61.8.2 2018/07/26 23:45:09 snj Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.61.8.1 2017/06/30 06:28:54 snj Exp $");
+__RCSID("$NetBSD: headers.c,v 1.61.8.2 2018/07/26 23:45:09 snj 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