Compute relocbase correctly for static PIE. AT_BASE is not usable in

this case.
This commit is contained in:
joerg 2018-07-13 19:49:47 +00:00
parent cead564c24
commit bf395f73c9
1 changed files with 13 additions and 2 deletions

View File

@ -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 @@ dl_iterate_phdr_setup(void)
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*/