gc/0004-Fix-GC_FirstDLOpenedLinkMap-for-NetBSD-6-release.patch
Rex Dieter 16efc896b0 7.2b-2
- backport patches from gc-7_2-hotfix-2 branch in lieu of 7.2c release
- gc 7.2 final abi broken when changing several symbols to hidden (#825473)
- gc: malloc() and calloc() overflows (CVE-2012-2673, #828881)
2012-06-15 13:54:19 -05:00

49 lines
1.4 KiB
Diff

From e9688bbf5ebecc950eb3e274ff19b3c2cf6ac288 Mon Sep 17 00:00:00 2001
From: Tsugutomo Enami <tsugutomo.enami@jp.sony.com>
Date: Fri, 1 Jun 2012 03:12:24 +0400
Subject: [PATCH 4/9] Fix GC_FirstDLOpenedLinkMap() for NetBSD 6 release
* 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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dyn_load.c b/dyn_load.c
index ce45ee2..a543d9e 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -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;
}
--
1.7.10.2