Module Name:    src
Committed By:   joerg
Date:           Sun May 22 19:28:39 UTC 2016

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

Log Message:
obj->phdr must be the absolute address, not the virtual offset from the
main binary. Historically, this has been the same. For PIE though,
relocbase can be pretty much anywhere. Fixes PR toolchain/51159.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 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.59 src/libexec/ld.elf_so/headers.c:1.60
--- src/libexec/ld.elf_so/headers.c:1.59	Tue Aug 26 21:20:05 2014
+++ src/libexec/ld.elf_so/headers.c	Sun May 22 19:28:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: headers.c,v 1.59 2014/08/26 21:20:05 joerg Exp $	 */
+/*	$NetBSD: headers.c,v 1.60 2016/05/22 19:28:39 joerg Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.59 2014/08/26 21:20:05 joerg Exp $");
+__RCSID("$NetBSD: headers.c,v 1.60 2016/05/22 19:28:39 joerg Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -389,9 +389,9 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, 
 		if (ph->p_type != PT_PHDR)
 			continue;
 
-		obj->phdr = (void *)(uintptr_t)ph->p_vaddr;
-		obj->phsize = ph->p_memsz;
 		obj->relocbase = (caddr_t)((uintptr_t)phdr - (uintptr_t)ph->p_vaddr);
+		obj->phdr = phdr; /* Equivalent to relocbase + p_vaddr. */
+		obj->phsize = ph->p_memsz;
 		dbg(("headers: phdr %p (%p) phsize %zu relocbase %p",
 		    obj->phdr, phdr, obj->phsize, obj->relocbase));
 		break;

Reply via email to