Hi Will,<br><br>I'm not sure that's right. With GNU Classpath, I also want to define my own methods and not use the ones implemented in Classpath. If we reorder things, the method defined in GNU Classpath will be used. Not mine.<div>
<br></div><div>vmkit is using RTLD_LOCAL when loading, so symbol resolution on a dlsym must provide the loaded library. If you do dlsym(SELF_HANDLE, 'mysymbol'), you'll only get symbols loaded in the j3 executable.</div>
<div><br></div><div>What is it that does not work for you?</div><div><br></div><div>Cheers,</div><div>Nicolas</div><div><br><br><div class="gmail_quote">On Tue, Nov 15, 2011 at 9:13 PM, Will Dietz <span dir="ltr"><<a href="mailto:wdietz2@illinois.edu">wdietz2@illinois.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Inlined below.<br>
<br>
As described in the commit message, the existing way incorrectly sets<br>
the 'j3' on symbols from loaded libraries, resulting in much badness<br>
when we don't invoke them properly in nativeCompile().<br>
<br>
I'm unsure if this was a bug on Mac, but regardless the reordering<br>
should work correctly on both.<br>
<br>
~Will<br>
<br>
>From 6f485d65e595a1ecd90e4e90a8bbc12b481561bc Mon Sep 17 00:00:00 2001<br>
From: Will Dietz <<a href="mailto:w@wdtz.org">w@wdtz.org</a>><br>
Date: Mon, 14 Nov 2011 09:45:35 -0600<br>
Subject: [PATCH 2/2] Fix symbol search order to fix detection of symbols from<br>
 vmkit or loaded libs<br>
<br>
dlsym(NULL, *) in linux, for example, will not only search the vmkit process,<br>
  but also all libraries we've opened.  This makes the setting of the 'j3' flag<br>
  incorrect, and this is fixed by a simple reordering.<br>
---<br>
 lib/J3/VMCore/JnjvmClassLoader.cpp |   30 +++++++++++++++++-------------<br>
 1 files changed, 17 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/lib/J3/VMCore/JnjvmClassLoader.cpp<br>
b/lib/J3/VMCore/JnjvmClassLoader.cpp<br>
index bf825a8..df206bb 100644<br>
--- a/lib/J3/VMCore/JnjvmClassLoader.cpp<br>
+++ b/lib/J3/VMCore/JnjvmClassLoader.cpp<br>
@@ -977,22 +977,26 @@ const UTF8*<br>
JnjvmClassLoader::constructArrayName(uint32 steps,<br>
 }<br>
<br>
 word_t JnjvmClassLoader::loadInLib(const char* buf, bool& j3) {<br>
-  word_t res =<br>
(word_t)TheCompiler->loadMethod(mvm::System::GetSelfHandle(), buf);<br>
-<br>
-  if (!res) {<br>
-    for (std::vector<void*>::iterator i = nativeLibs.begin(),<br>
-              e = nativeLibs.end(); i!= e; ++i) {<br>
-      res = (word_t)TheCompiler->loadMethod((*i), buf);<br>
-      if (res) break;<br>
-    }<br>
-  } else {<br>
+  word_t res;<br>
+<br>
+  // Search loaded libraries first<br>
+  for (std::vector<void*>::iterator i = nativeLibs.begin(),<br>
+      e = nativeLibs.end(); i!= e; ++i) {<br>
+    res = (word_t)TheCompiler->loadMethod((*i), buf);<br>
+    if (res) return res;<br>
+  }<br>
+<br>
+  // Check 'self'<br>
+  res = (word_t)TheCompiler->loadMethod(mvm::System::GetSelfHandle(), buf);<br>
+  if (res) {<br>
     j3 = true;<br>
+    return res;<br>
   }<br>
-<br>
-  if (!res && this != bootstrapLoader)<br>
-    res = bootstrapLoader->loadInLib(buf, j3);<br>
<br>
-  return (word_t)res;<br>
+  if (this != bootstrapLoader)<br>
+    return bootstrapLoader->loadInLib(buf, j3);<br>
+<br>
+  return 0;<br>
 }<br>
<br>
 void* JnjvmClassLoader::loadLib(const char* buf) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.5.1<br>
_______________________________________________<br>
vmkit-commits mailing list<br>
<a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits</a><br>
</font></span></blockquote></div><br></div>