X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=libgc%2Fdyn_load.c;h=5db3503aacbaf3b68ce53ddc427cb1069cccce04;hb=HEAD;hp=a6e33163dfdf2cb9bf09fcf1d7067d199949ba8b;hpb=538d3bb80572334c18ae117ea7703406a4a22872;p=mono.git diff --git a/libgc/dyn_load.c b/libgc/dyn_load.c index a6e33163dfd..5db3503aacb 100644 --- a/libgc/dyn_load.c +++ b/libgc/dyn_load.c @@ -26,7 +26,7 @@ * None of this is safe with dlclose and incremental collection. * But then not much of anything is safe in the presence of dlclose. */ -#if defined(__linux__) && !defined(_GNU_SOURCE) +#if (defined(__linux__) || defined(__GLIBC__) || defined(__native_client__)) && !defined(_GNU_SOURCE) /* Can't test LINUX, since this must be define before other includes */ # define _GNU_SOURCE #endif @@ -54,9 +54,10 @@ #if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \ !defined(MSWIN32) && !defined(MSWINCE) && \ !(defined(ALPHA) && defined(OSF1)) && \ - !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \ + !defined(HPUX) && !((defined(LINUX) || defined(NACL)) && defined(__ELF__)) && \ !defined(RS6000) && !defined(SCO_ELF) && !defined(DGUX) && \ !(defined(FREEBSD) && defined(__ELF__)) && \ + !(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) && \ !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \ !defined(DARWIN) --> We only know how to find data segments of dynamic libraries for the @@ -90,11 +91,14 @@ # define ELFSIZE ARCH_ELFSIZE #endif -#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ +#if (defined(LINUX) || defined(NACL)) && defined(__ELF__) || defined(SCO_ELF) || \ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ + (defined(OPENBSD) && defined(__ELF__)) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) # include +# if !defined(OPENBSD) # include +# endif # include #endif @@ -250,7 +254,10 @@ void GC_register_dynamic_libraries() char * start; register int i; - e = (ElfW(Ehdr) *) lm->l_addr; + e = (ElfW(Ehdr) *) lm->l_addr; + if (e == NULL) + continue; + p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff)); offset = ((unsigned long)(lm->l_addr)); for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) { @@ -290,8 +297,9 @@ void GC_register_dynamic_libraries() # endif /* !USE_PROC ... */ # endif /* SUNOS */ -#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ +#if (defined(LINUX) || defined(NACL)) && defined(__ELF__) || defined(SCO_ELF) || \ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ + (defined(OPENBSD) && defined(__ELF__)) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) @@ -386,7 +394,7 @@ GC_bool GC_register_main_static_data() /* For glibc 2.2.4+. Unfortunately, it doesn't work for older */ /* versions. Thanks to Jakub Jelinek for most of the code. */ -# if defined(LINUX) /* Are others OK here, too? */ \ +# if (defined(LINUX) || defined (__GLIBC__) || defined(NACL)) /* Are others OK here, too? */ \ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) @@ -470,8 +478,10 @@ GC_bool GC_register_main_static_data() /* This doesn't necessarily work in all cases, e.g. with preloaded * dynamic libraries. */ -#if defined(NETBSD) +#if defined(NETBSD) || defined(OPENBSD) +# if !defined(OPENBSD) # include +# endif /* for compatibility with 1.4.x */ # ifndef DT_DEBUG # define DT_DEBUG 21 @@ -544,7 +554,10 @@ void GC_register_dynamic_libraries() char * start; register int i; - e = (ElfW(Ehdr) *) lm->l_addr; + e = (ElfW(Ehdr) *) lm->l_addr; + if (e == NULL) + continue; + p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff)); offset = ((unsigned long)(lm->l_addr)); for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) {