- Change the strong dlfcn names in libc to ___name, and make the __name

versions used by others in libc weak, so that we have:
	name: weak
	__name: weak
	___name: strong
- Add __name strong aliases of the dlfcn names in ld.elf_so, so that we have:
	name: strong
	__name: strong

This allows ld.elf_so to self-resolve both the name and __name variants
of the dlfcn functions, the former being required for dlfcn support in
applications, the latter being required for dlfcn support in libc.

Fixes the problem described in:

    http://mail-index.netbsd.org/tech-toolchain/2004/07/17/0000.html

Reviewed by Nick.
This commit is contained in:
thorpej 2004-07-18 17:26:19 +00:00
parent 9b54aaafc2
commit 2a63e04007
3 changed files with 45 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dlfcn_elf.c,v 1.4 2003/08/12 09:18:43 skrll Exp $ */
/* $NetBSD: dlfcn_elf.c,v 1.5 2004/07/18 17:26:19 thorpej Exp $ */
/*
* Copyright (c) 2000 Takuya SHIOZAKI
@ -27,20 +27,38 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: dlfcn_elf.c,v 1.4 2003/08/12 09:18:43 skrll Exp $");
__RCSID("$NetBSD: dlfcn_elf.c,v 1.5 2004/07/18 17:26:19 thorpej Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#undef dlopen
#undef dlclose
#undef dlsym
#undef dlerror
#undef dladdr
#define dlopen ___dlopen
#define dlclose ___dlclose
#define dlsym ___dlsym
#define dlerror ___dlerror
#define dladdr ___dladdr
#define ELFSIZE ARCH_ELFSIZE
#include "rtld.h"
#ifdef __weak_alias
__weak_alias(dlopen,__dlopen)
__weak_alias(dlclose,__dlclose)
__weak_alias(dlsym,__dlsym)
__weak_alias(dlerror,__dlerror)
__weak_alias(dladdr,__dladdr)
__weak_alias(dlopen,___dlopen)
__weak_alias(dlclose,___dlclose)
__weak_alias(dlsym,___dlsym)
__weak_alias(dlerror,___dlerror)
__weak_alias(dladdr,___dladdr)
__weak_alias(__dlopen,___dlopen)
__weak_alias(__dlclose,___dlclose)
__weak_alias(__dlsym,___dlsym)
__weak_alias(__dlerror,___dlerror)
__weak_alias(__dladdr,___dladdr)
#endif
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld.c,v 1.105 2004/05/17 13:16:02 skrll Exp $ */
/* $NetBSD: rtld.c,v 1.106 2004/07/18 17:26:19 thorpej Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -580,6 +580,7 @@ _rtld_unref_dag(Obj_Entry *root)
}
}
__strong_alias(__dlclose,dlclose)
int
dlclose(void *handle)
{
@ -600,6 +601,7 @@ dlclose(void *handle)
return 0;
}
__strong_alias(__dlerror,dlerror)
char *
dlerror(void)
{
@ -609,6 +611,7 @@ dlerror(void)
return msg;
}
__strong_alias(__dlopen,dlopen)
void *
dlopen(const char *name, int mode)
{
@ -666,6 +669,7 @@ _rtld_objmain_sym(const char *name)
return(NULL);
}
__strong_alias(__dlsym,dlsym)
void *
dlsym(void *handle, const char *name)
{
@ -752,6 +756,7 @@ dlsym(void *handle, const char *name)
return NULL;
}
__strong_alias(__dladdr,dladdr)
int
dladdr(const void *addr, Dl_info *info)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: symbol.c,v 1.35 2003/12/07 09:36:06 mrauch Exp $ */
/* $NetBSD: symbol.c,v 1.36 2004/07/18 17:26:19 thorpej Exp $ */
/*
* Copyright 1996 John D. Polstra.
@ -62,6 +62,19 @@ _rtld_is_exported(const Elf_Sym *def)
(Elf_Addr)dlsym,
(Elf_Addr)dlerror,
(Elf_Addr)dladdr,
#if 0
/*
* Don't need to list these since they are aliases of the
* above symbols, and thus have the same value.
*/
(Elf_Addr)__dlopen,
(Elf_Addr)__dlclose,
(Elf_Addr)__dlsym,
(Elf_Addr)__dlerror,
(Elf_Addr)__dladdr,
#endif
0
};
int i;