[lldb-dev] dlsym() and RTLD_FIRST

Greg Clayton gclayton at apple.com
Thu Aug 21 16:08:59 PDT 2014

> On Aug 21, 2014, at 3:31 PM, Zachary Turner <zturner at google.com> wrote:
> Can someone explain this flag to me?

It says "only look in this binary, don't look in any others. We are looking for a plug-in initialization function and we don't want to get one back from another dylib.

As Enrico said, the email from a while back details this:


>  I've read the documentation, but it's still not clear to me.  If you ask dlsym() to search some module X, why would it ever search modules other than X?

I don't know but it does.

> The reason I ask about this is that llvm support library already has a DynamicLibrary class whose purpose almost exactly matches what we're using the Host::DynamicLibrary related functions for.  However, it doesn't use the RTLD_FIRST flag, and so I'm not sure what the implications are of us using it and deleting our own DynamicLibrary code.

It would be nice if we could specify this flag so we either find the symbol from libx.dylib or we don't. We don't want to find the symbol in liby.dylib and call it in our case. 

More information about the lldb-dev mailing list