Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/dlfcn Compute relocbase correctly for static PIE. A...
details: https://anonhg.NetBSD.org/src/rev/41d01f10d037
branches: trunk
changeset: 991433:41d01f10d037
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Jul 13 19:49:47 2018 +0000
description:
Compute relocbase correctly for static PIE. AT_BASE is not usable in
this case.
diffstat:
lib/libc/dlfcn/dlfcn_elf.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diffs (36 lines):
diff -r 14f3fee3dcdc -r 41d01f10d037 lib/libc/dlfcn/dlfcn_elf.c
--- a/lib/libc/dlfcn/dlfcn_elf.c Fri Jul 13 19:44:08 2018 +0000
+++ b/lib/libc/dlfcn/dlfcn_elf.c Fri Jul 13 19:49:47 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dlfcn_elf.c,v 1.15 2018/01/05 19:29:44 kamil Exp $ */
+/* $NetBSD: dlfcn_elf.c,v 1.16 2018/07/13 19:49:47 joerg Exp $ */
/*
* Copyright (c) 2000 Takuya SHIOZAKI
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dlfcn_elf.c,v 1.15 2018/01/05 19:29:44 kamil Exp $");
+__RCSID("$NetBSD: dlfcn_elf.c,v 1.16 2018/07/13 19:49:47 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -176,6 +176,17 @@
break;
}
}
+
+ if (!dlpi_phdr)
+ return;
+
+ const Elf_Phdr *phdr = (const Elf_Phdr *)dlpi_phdr;
+ const Elf_Phdr *phlimit = phdr + dlpi_phnum;
+
+ for (; phdr < phlimit; ++phdr) {
+ if (phdr->p_type == PT_PHDR)
+ dlpi_addr = (uintptr_t)phdr - phdr->p_vaddr;
+ }
}
/*ARGSUSED*/
Home |
Main Index |
Thread Index |
Old Index