dyn_load.c: Define ElfW (if needed) for all targets, not just GNU/Linux.

* dyn_load.c: Define ElfW (if needed) for all targets,
	not just GNU/Linux.
	(GC_FirstDLOpenedLinkMap): Use it.
	(GC_register_dynamic_libraries_dl): Use it.
	* include/private/gcconfig.h: Define CPP_WORDSZ, ELF_CLASS
	for sparcv9.

From-SVN: r48086
This commit is contained in:
Jeff Sturm 2001-12-17 03:24:50 +00:00 committed by Jeff Sturm
parent 8d37a5c0db
commit a5b2a65b97
3 changed files with 29 additions and 19 deletions

View File

@ -1,3 +1,12 @@
2001-12-16 Jeff Sturm <jsturm@one-point.com>
* dyn_load.c: Define ElfW (if needed) for all targets,
not just GNU/Linux.
(GC_FirstDLOpenedLinkMap): Use it.
(GC_register_dynamic_libraries_dl): Use it.
* include/private/gcconfig.h: Define CPP_WORDSZ, ELF_CLASS
for sparcv9.
2001-12-16 Craig Rodrigues <rodrigc@gcc.gnu.org>
PR other/3725

View File

@ -79,6 +79,15 @@
# define l_name lm_name
#endif
/* Newer versions of GNU/Linux define this macro. We
* define it similarly for any ELF systems that don't. */
# ifndef ElfW
# if !defined(ELF_CLASS) || ELF_CLASS == ELFCLASS32
# define ElfW(type) Elf32_##type
# else
# define ElfW(type) Elf64_##type
# endif
# endif
#if defined(SUNOS5DL) && !defined(USE_PROC_FOR_LIBRARIES)
@ -89,11 +98,11 @@
static struct link_map *
GC_FirstDLOpenedLinkMap()
{
extern Elf32_Dyn _DYNAMIC;
Elf32_Dyn *dp;
extern ElfW(Dyn) _DYNAMIC;
ElfW(Dyn) *dp;
struct r_debug *r;
static struct link_map * cachedResult = 0;
static Elf32_Dyn *dynStructureAddr = 0;
static ElfW(Dyn) *dynStructureAddr = 0;
/* BTL: added to avoid Solaris 5.3 ld.so _DYNAMIC bug */
# ifdef SUNOS53_SHARED_LIB
@ -103,7 +112,7 @@ GC_FirstDLOpenedLinkMap()
/* at program startup. */
if( dynStructureAddr == 0 ) {
void* startupSyms = dlopen(0, RTLD_LAZY);
dynStructureAddr = (Elf32_Dyn*)dlsym(startupSyms, "_DYNAMIC");
dynStructureAddr = (ElfW(Dyn)*)dlsym(startupSyms, "_DYNAMIC");
}
# else
dynStructureAddr = &_DYNAMIC;
@ -114,7 +123,7 @@ GC_FirstDLOpenedLinkMap()
}
if( cachedResult == 0 ) {
int tag;
for( dp = ((Elf32_Dyn *)(&_DYNAMIC)); (tag = dp->d_tag) != 0; dp++ ) {
for( dp = ((ElfW(Dyn) *)(&_DYNAMIC)); (tag = dp->d_tag) != 0; dp++ ) {
if( tag == DT_DEBUG ) {
struct link_map *lm
= ((struct r_debug *)(dp->d_un.d_ptr))->r_map;
@ -200,14 +209,14 @@ void GC_register_dynamic_libraries()
TRUE);
# endif
# ifdef SUNOS5DL
Elf32_Ehdr * e;
Elf32_Phdr * p;
ElfW(Ehdr) * e;
ElfW(Phdr) * p;
unsigned long offset;
char * start;
register int i;
e = (Elf32_Ehdr *) lm->l_addr;
p = ((Elf32_Phdr *)(((char *)(e)) + e->e_phoff));
e = (ElfW(Ehdr) *) lm->l_addr;
p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff));
offset = ((unsigned long)(lm->l_addr));
for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) {
switch( p->p_type ) {
@ -516,16 +525,6 @@ GC_bool GC_register_dynamic_libraries_dl_iterate_phdr()
# endif
/* Newer versions of Linux/Alpha and Linux/x86 define this macro. We
* define it for those older versions that don't. */
# ifndef ElfW
# if !defined(ELF_CLASS) || ELF_CLASS == ELFCLASS32
# define ElfW(type) Elf32_##type
# else
# define ElfW(type) Elf64_##type
# endif
# endif
static struct link_map *
GC_FirstDLOpenedLinkMap()
{

View File

@ -715,6 +715,8 @@
# define MACH_TYPE "SPARC"
# if defined(__arch64__) || defined(__sparcv9)
# define ALIGNMENT 8
# define CPP_WORDSZ 64
# define ELF_CLASS ELFCLASS64
# else
# define ALIGNMENT 4 /* Required by hardware */
# endif