This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[RFC] Boehm GC changes for uClibc.
- From: David Daney <ddaney at avtrex dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: uclibc at uclibc dot org, Hans Boehm <hans_boehm at hp dot com>
- Date: Mon, 17 Apr 2006 11:39:24 -0700
- Subject: [RFC] Boehm GC changes for uClibc.
I am trying to get libgcj running under uClibc. This patch is necessary
to get a simple 'Hello World' program to run. Other patches will be
needed for full functionality, but this one is a good start.
The problem is the the Boehm GC is expecting to be able to find the
link_map via the DT_DEBUG dynamic tag. The uClibc dynamic loader does
not initialize DT_DEBUG (at least for MIPS) because doing so would dirty
the page where it resides.
The patch gains access the link_map via the global symbol
_dl_debug_addr. Without the patch there is a SIGSEGV dereferencing the
zero valued DT_DEBUG tag while doing _Jv_CreateJavaVM().
If this seems like a good approach, I will test/commit the patch on the
trunk.
This version is against GCC-4.1.0
David Daney
boehm-gc/
2006-04-17 David Daney <ddaney@avtrex.com>
* dyn_load.c (GC_FirstDLOpenedLinkMap): Remove unused variable r,
use _dl_debug_addr instead of DT_DEBUG for uClibc.
--- boehm-gc/dyn_load.c.orig 2005-02-26 07:40:07.000000000 -0800
+++ boehm-gc/dyn_load.c 2006-04-17 11:10:47.000000000 -0700
@@ -485,13 +485,18 @@ static struct link_map *
GC_FirstDLOpenedLinkMap()
{
ElfW(Dyn) *dp;
- struct r_debug *r;
static struct link_map *cachedResult = 0;
if( _DYNAMIC == 0) {
return(0);
}
if( cachedResult == 0 ) {
+#ifdef __UCLIBC__
+ /* uClibc Does not seem so set the DT_DEBUG tag. */
+ extern struct r_debug *_dl_debug_addr;
+ if ((_dl_debug_addr != 0) && (_dl_debug_addr->r_map != 0))
+ cachedResult = _dl_debug_addr->r_map->l_next; /* might be NIL */
+#else
int tag;
for( dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++ ) {
if( tag == DT_DEBUG ) {
@@ -501,6 +506,7 @@ GC_FirstDLOpenedLinkMap()
break;
}
}
+#endif
}
return cachedResult;
}