Libraries updates and cleanup
* Updating common/lib * Updating lib/csu * Updating lib/libc * Updating libexec/ld.elf_so * Corrected test on __minix in featuretest to actually follow the meaning of the comment. * Cleaned up _REENTRANT-related defintions. * Disabled -D_REENTRANT for libfetch * Removing some unneeded __NBSD_LIBC defines and tests Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $ */
|
||||
/* $NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Takuya SHIOZAKI
|
||||
@@ -27,10 +27,16 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $");
|
||||
__RCSID("$NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/atomic.h>
|
||||
#include <assert.h>
|
||||
#include <elf.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#undef dlopen
|
||||
#undef dlclose
|
||||
@@ -42,6 +48,7 @@ __RCSID("$NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $");
|
||||
#define dlopen ___dlopen
|
||||
#define dlclose ___dlclose
|
||||
#define dlsym ___dlsym
|
||||
#define dlvsym ___dlvsym
|
||||
#define dlerror ___dlerror
|
||||
#define dladdr ___dladdr
|
||||
#define dlinfo ___dlinfo
|
||||
@@ -54,6 +61,7 @@ __RCSID("$NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $");
|
||||
__weak_alias(dlopen,___dlopen)
|
||||
__weak_alias(dlclose,___dlclose)
|
||||
__weak_alias(dlsym,___dlsym)
|
||||
__weak_alias(dlvsym,___dlvsym)
|
||||
__weak_alias(dlerror,___dlerror)
|
||||
__weak_alias(dladdr,___dladdr)
|
||||
__weak_alias(dlinfo,___dlinfo)
|
||||
@@ -62,6 +70,7 @@ __weak_alias(dl_iterate_phdr,___dl_iterate_phdr)
|
||||
__weak_alias(__dlopen,___dlopen)
|
||||
__weak_alias(__dlclose,___dlclose)
|
||||
__weak_alias(__dlsym,___dlsym)
|
||||
__weak_alias(__dlvsym,___dlvsym)
|
||||
__weak_alias(__dlerror,___dlerror)
|
||||
__weak_alias(__dladdr,___dladdr)
|
||||
__weak_alias(__dlinfo,___dlinfo)
|
||||
@@ -104,9 +113,17 @@ dlsym(void *handle, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void *
|
||||
dlvsym(void *handle, const char *name, const char *version)
|
||||
{
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
__aconst char *
|
||||
dlerror()
|
||||
dlerror(void)
|
||||
{
|
||||
|
||||
return dlfcn_error;
|
||||
@@ -128,11 +145,61 @@ dlinfo(void *handle, int req, void *v)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *dlpi_name;
|
||||
static Elf_Addr dlpi_addr;
|
||||
static const Elf_Phdr *dlpi_phdr;
|
||||
static Elf_Half dlpi_phnum;
|
||||
|
||||
static void
|
||||
dl_iterate_phdr_setup(void)
|
||||
{
|
||||
const AuxInfo *aux;
|
||||
|
||||
_DIAGASSERT(_dlauxinfo() != NULL);
|
||||
|
||||
for (aux = _dlauxinfo(); aux->a_type != AT_NULL; ++aux) {
|
||||
switch (aux->a_type) {
|
||||
case AT_BASE:
|
||||
dlpi_addr = aux->a_v;
|
||||
break;
|
||||
case AT_PHDR:
|
||||
dlpi_phdr = (void *)aux->a_v;
|
||||
break;
|
||||
case AT_PHNUM:
|
||||
_DIAGASSERT(__type_fit(Elf_Half, aux->a_v));
|
||||
dlpi_phnum = (Elf_Half)aux->a_v;
|
||||
break;
|
||||
case AT_SUN_EXECNAME:
|
||||
dlpi_name = (void *)aux->a_v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
|
||||
void *data)
|
||||
{
|
||||
static bool setup_done;
|
||||
struct dl_phdr_info phdr_info;
|
||||
|
||||
return 0;
|
||||
if (!setup_done) {
|
||||
/*
|
||||
* This can race on the first call to dl_iterate_phdr.
|
||||
* dl_iterate_phdr_setup only touches field of pointer size
|
||||
* and smaller and such stores are atomic.
|
||||
*/
|
||||
dl_iterate_phdr_setup();
|
||||
membar_producer();
|
||||
setup_done = true;
|
||||
}
|
||||
|
||||
memset(&phdr_info, 0, sizeof(phdr_info));
|
||||
phdr_info.dlpi_addr = dlpi_addr;
|
||||
phdr_info.dlpi_phdr = dlpi_phdr;
|
||||
phdr_info.dlpi_phnum = dlpi_phnum;
|
||||
phdr_info.dlpi_name = dlpi_name;
|
||||
|
||||
return callback(&phdr_info, sizeof(phdr_info), data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user