On Wed, 5 Aug 2009, Josh Hursey wrote:

On Aug 5, 2009, at 11:35 AM, Brian W. Barrett wrote:

Josh -

Just in case it wasn't clear -- if you're only looking for a symbol in the executable (which you know is there), you do *NOT* have to dlopen() the executable first (you do with libtool to support the "i don't have dynamic library support" mode of operatoin). You only have to dlsym() with RTLD_DEFAULT, as the symbol is already in the process space.

So is it wrong to dlopen() before dlsym()? The patch I just committed in r21766 does this, since I was following the man page for dlopen() to make sure I was using it correctly.

I don't know that it's "wrong", it's just not necessary.  I believe that:

  handle = dlopen(NULL, RTLD_LOCAL|RTLD_LAZY);
  sym = dlsym(handle, "foo");
  dlclose(handle)l

and

  sym = dlsym(RTLD_DEFAULT, "foo");

are functionally equivalent, but the second one means no handle to pass around :).

Brian

Reply via email to