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

dyn_load.c

index 193f307ff8f11256d053cc1d577fd22a20c26e69..e76c88807da3d2688d8a10d92b7e2ad91156eb44 100644 (file)
@@ -74,6 +74,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
@@ -642,6 +644,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 ) {
@@ -651,6 +658,7 @@ GC_FirstDLOpenedLinkMap(void)
                 break;
             }
         }
+#     endif /* !NETBSD || !RTLD_DI_LINKMAP */
     }
     return cachedResult;
 }