Apply relocbase for tlsinit of the executable itself. Fixes PIE where

relocbase typically is not zero.

PR bin/53465
This commit is contained in:
joerg 2018-07-24 13:48:48 +00:00
parent 0a4d729958
commit da0b29937f

View File

@ -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, int phnum, caddr_t entry)
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));