[llvm-commits] [PATCH] Look up symbols in a specific library with DynamicLibrary

Jordy Rose jediknil at belkadan.com
Wed Aug 10 23:23:16 PDT 2011


I think that's all right; we just need to specify that DynamicLibary instances should not be created at global scope and should not be used in DllMain. And currently permanently-loaded libraries are /never/ unloaded, so this is no worse than what we've been doing. If we do ever add an unload hook, it would be in the LLVM core, since we're still planning to keep track of all libraries loaded (even by plugins).

Thanks for the tip, though.
Jordy


On Aug 10, 2011, at 22:16, David Blaikie wrote:

> Apologies if this is unrelated, but given the topic of permanently
> loading  dynamic libraries for use by clang (which itself can be used
> as a library, if I'm not mistaken), I thought this might be relevant:
> 
> http://msdn.microsoft.com/en-us/library/ms683152(v=vs.85).aspx
> 
> "It is not safe to call FreeLibrary from DllMain. For more
> information, see the Remarks section in DllMain."
> 
> (& DllMain is the entry point where global ctors and global dtors are
> run - " Before unloading a library module, the system enables the
> module to detach from the process by calling the module's DllMain
> function, if it has one, with the DLL_PROCESS_DETACH value.")
> 
> So having globally loaded libraries which you'll have to unload in the
> global dtor phase when clang's library gets unloaded would be unsafe.
> 
> Is this relevant? will you need to design around having another entry
> point where things are cleaned up, perhaps?
> 
> - David





More information about the llvm-commits mailing list