]> granicus.if.org Git - gc/commitdiff
Fix GC_FirstDLOpenedLinkMap() for NetBSD 6 release
authorTsugutomo Enami <tsugutomo.enami@jp.sony.com>
Thu, 31 May 2012 23:12:24 +0000 (03:12 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 2 Jun 2012 08:52:49 +0000 (12:52 +0400)
* dyn_load.c: Include sys/param.h and dlfcn.h on NetBSD.
* dyn_load.c (GC_FirstDLOpenedLinkMap): Obtain link map using dlinfo()
on NetBSD if RTLD_DI_LINKMAP feature present (defined).

dyn_load.c

index ce45ee2716f67d30f2eac988a5d1ea96995cad84..a543d9ebd434da9abbf2f04d4b33d78bdecce880 100644 (file)
@@ -77,6 +77,8 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0;
 #endif
 
 #if defined(NETBSD)
+#   include <sys/param.h>
+#   include <dlfcn.h>
 #   include <machine/elf_machdep.h>
 #   define ELFSIZE ARCH_ELFSIZE
 #endif
@@ -644,6 +646,11 @@ GC_FirstDLOpenedLinkMap(void)
         return(0);
     }
     if( cachedResult == 0 ) {
+#     if defined(NETBSD) && defined(RTLD_DI_LINKMAP)
+        struct link_map *lm = NULL;
+        if (!dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lm))
+            cachedResult = lm;
+#     else
         int tag;
         for( dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++ ) {
             if( tag == DT_DEBUG ) {
@@ -653,6 +660,7 @@ GC_FirstDLOpenedLinkMap(void)
                 break;
             }
         }
+#     endif /* !NETBSD || !RTLD_DI_LINKMAP */
     }
     return cachedResult;
 }