[vmkit-commits] [PATCH] Fix symbol search order to fix detection of symbols from vmkit or loaded libs

Nicolas Geoffray nicolas.geoffray at gmail.com
Tue Nov 15 12:24:18 PST 2011


Hi Will,

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.

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.

What is it that does not work for you?

Cheers,
Nicolas


On Tue, Nov 15, 2011 at 9:13 PM, Will Dietz <wdietz2 at illinois.edu> wrote:

> Inlined below.
>
> As described in the commit message, the existing way incorrectly sets
> the 'j3' on symbols from loaded libraries, resulting in much badness
> when we don't invoke them properly in nativeCompile().
>
> I'm unsure if this was a bug on Mac, but regardless the reordering
> should work correctly on both.
>
> ~Will
>
> >From 6f485d65e595a1ecd90e4e90a8bbc12b481561bc Mon Sep 17 00:00:00 2001
> From: Will Dietz <w at wdtz.org>
> Date: Mon, 14 Nov 2011 09:45:35 -0600
> Subject: [PATCH 2/2] Fix symbol search order to fix detection of symbols
> from
>  vmkit or loaded libs
>
> dlsym(NULL, *) in linux, for example, will not only search the vmkit
> process,
>  but also all libraries we've opened.  This makes the setting of the 'j3'
> flag
>  incorrect, and this is fixed by a simple reordering.
> ---
>  lib/J3/VMCore/JnjvmClassLoader.cpp |   30 +++++++++++++++++-------------
>  1 files changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/lib/J3/VMCore/JnjvmClassLoader.cpp
> b/lib/J3/VMCore/JnjvmClassLoader.cpp
> index bf825a8..df206bb 100644
> --- a/lib/J3/VMCore/JnjvmClassLoader.cpp
> +++ b/lib/J3/VMCore/JnjvmClassLoader.cpp
> @@ -977,22 +977,26 @@ const UTF8*
> JnjvmClassLoader::constructArrayName(uint32 steps,
>  }
>
>  word_t JnjvmClassLoader::loadInLib(const char* buf, bool& j3) {
> -  word_t res =
> (word_t)TheCompiler->loadMethod(mvm::System::GetSelfHandle(), buf);
> -
> -  if (!res) {
> -    for (std::vector<void*>::iterator i = nativeLibs.begin(),
> -              e = nativeLibs.end(); i!= e; ++i) {
> -      res = (word_t)TheCompiler->loadMethod((*i), buf);
> -      if (res) break;
> -    }
> -  } else {
> +  word_t res;
> +
> +  // Search loaded libraries first
> +  for (std::vector<void*>::iterator i = nativeLibs.begin(),
> +      e = nativeLibs.end(); i!= e; ++i) {
> +    res = (word_t)TheCompiler->loadMethod((*i), buf);
> +    if (res) return res;
> +  }
> +
> +  // Check 'self'
> +  res = (word_t)TheCompiler->loadMethod(mvm::System::GetSelfHandle(),
> buf);
> +  if (res) {
>     j3 = true;
> +    return res;
>   }
> -
> -  if (!res && this != bootstrapLoader)
> -    res = bootstrapLoader->loadInLib(buf, j3);
>
> -  return (word_t)res;
> +  if (this != bootstrapLoader)
> +    return bootstrapLoader->loadInLib(buf, j3);
> +
> +  return 0;
>  }
>
>  void* JnjvmClassLoader::loadLib(const char* buf) {
> --
> 1.7.5.1
> _______________________________________________
> vmkit-commits mailing list
> vmkit-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/vmkit-commits/attachments/20111115/a010809c/attachment.html>


More information about the vmkit-commits mailing list