[llvm] [Windows] Avoid loading shared system libraries from user directory (PR #90520)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 08:16:58 PDT 2024
================
@@ -43,6 +43,10 @@ InitLLVM::InitLLVM(int &Argc, const char **&Argv,
assert(!Initialized && "InitLLVM was already initialized!");
Initialized = true;
#endif
+#ifdef _WIN32
+ // Avoid searching the directory from which the application is loaded.
----------------
jofrn wrote:
> If removing the current directory from the search path is the desired behavior, then I'd recommend using `SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)` instead, since it's much easier to understand.
Reworked the commit to instead use `LoadLibraryExA(..., LOAD_LIBRARY_SEARCH_SYSTEM32)`. It seems `LOAD_LIBRARY_SEARCH_DEFAULT_DIRS` will search user directories, among other flags listed, which we should avoid since falling back to finding `dbghelp.dll` or `dbgcore.dll` here is still dangerous. There doesn't seem to be a flag to omit just the load directory.
https://github.com/llvm/llvm-project/pull/90520
More information about the llvm-commits
mailing list