diff options
author | jsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-17 03:24:50 +0000 |
---|---|---|
committer | jsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-17 03:24:50 +0000 |
commit | e064b2d637514779061017c4dc1a19061d1c1c69 (patch) | |
tree | 8b76cba31f1da01ca75cbd4757362900e10e882d /boehm-gc/dyn_load.c | |
parent | fccd796a15d21307aa3e51c857a661f630199f2c (diff) | |
download | linaro-gcc-e064b2d637514779061017c4dc1a19061d1c1c69.tar.gz linaro-gcc-e064b2d637514779061017c4dc1a19061d1c1c69.tar.bz2 linaro-gcc-e064b2d637514779061017c4dc1a19061d1c1c69.zip |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48086 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'boehm-gc/dyn_load.c')
-rw-r--r-- | boehm-gc/dyn_load.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/boehm-gc/dyn_load.c b/boehm-gc/dyn_load.c index 7dfe6671230..984253aa873 100644 --- a/boehm-gc/dyn_load.c +++ b/boehm-gc/dyn_load.c @@ -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() { |