Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so Apply relocbase for tlsinit of the executa...



details:   https://anonhg.NetBSD.org/src/rev/37eaef011b3d
branches:  trunk
changeset: 991650:37eaef011b3d
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Jul 24 13:48:48 2018 +0000

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

PR bin/53465

diffstat:

 libexec/ld.elf_so/headers.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 12469e083fe0 -r 37eaef011b3d libexec/ld.elf_so/headers.c
--- a/libexec/ld.elf_so/headers.c       Tue Jul 24 12:59:15 2018 +0000
+++ b/libexec/ld.elf_so/headers.c       Tue Jul 24 13:48:48 2018 +0000
@@ -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 @@
                        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));



Home | Main Index | Thread Index | Old Index