diff options
author | Aditya Mandaleeka <adityamandaleeka@users.noreply.github.com> | 2015-10-21 15:26:49 -0700 |
---|---|---|
committer | Aditya Mandaleeka <adityamandaleeka@users.noreply.github.com> | 2015-10-21 15:26:49 -0700 |
commit | 2fadd657a3d3826e32638a6bdde1f7c9394531dc (patch) | |
tree | 3b848c834d20693d1bece623ced388cb242cf8b6 /src/pal/src/loader | |
parent | 65b55ab02eba5fc71daadb0db9f4d4a424906dba (diff) | |
parent | c9a6067831b40b739e5a4a908b66a8b7b84e565f (diff) | |
download | coreclr-2fadd657a3d3826e32638a6bdde1f7c9394531dc.tar.gz coreclr-2fadd657a3d3826e32638a6bdde1f7c9394531dc.tar.bz2 coreclr-2fadd657a3d3826e32638a6bdde1f7c9394531dc.zip |
Merge pull request #1780 from adityamandaleeka/librarySearchPaths
Fix DllImport search logic with respect to prefixes/suffixes
Diffstat (limited to 'src/pal/src/loader')
-rw-r--r-- | src/pal/src/loader/module.cpp | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/src/pal/src/loader/module.cpp b/src/pal/src/loader/module.cpp index 5dbe6cc979..3a48183e17 100644 --- a/src/pal/src/loader/module.cpp +++ b/src/pal/src/loader/module.cpp @@ -1611,8 +1611,6 @@ Return value : --*/ static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic) { - CHAR * fullLibraryName; - PathCharString fullLibraryNamePS; HMODULE module = NULL; HMODULE dl_handle = NULL; @@ -1637,40 +1635,9 @@ static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic) // See if file can be dlopen()ed; this should work even if it's already loaded { // See GetProcAddress for an explanation why we leave the PAL. - PAL_LeaveHolder holder; - - // P/Invokes are often declared with variations on the actual library name. - // For example, it's common to leave off the extension/suffix of the library - // even if it has one, or to leave off a prefix like "lib" even if it has one - // (both of these are done typically to smooth over cross-platform differences). - // We try to dlopen with such variations on the original. - const char* const formatStrings[4] = // used with args: PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX - { - "%s%s%s", // prefix+name+suffix - "%.0s%s%.0s", // name - "%.0s%s%s", // name+suffix - "%s%s%.0s", // prefix+name - }; - const int skipPrefixing = strchr(shortAsciiName, '/') != NULL; // skip prefixing if the name is actually a path - for (int i = 0; i < 4; i++) - { - if (skipPrefixing && (i == 0 || i == 3)) // 0th and 3rd strings include prefixes - continue; + PAL_LeaveHolder holder; - _ASSERTE(dl_handle == nullptr); - fullLibraryName = fullLibraryNamePS.OpenStringBuffer(strlen(PAL_SHLIB_PREFIX)+strlen(shortAsciiName)+strlen(PAL_SHLIB_SUFFIX)); - int size = snprintf(fullLibraryName, fullLibraryNamePS.GetSizeOf(), formatStrings[i], PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX); - if (size < fullLibraryNamePS.GetSizeOf()) - { - fullLibraryNamePS.CloseBuffer(size); - dl_handle = LOADLoadLibraryDirect(fullLibraryName, false /* setLastError */); - if (dl_handle != nullptr) - { - shortAsciiName = fullLibraryName; - break; - } - } - } + dl_handle = LOADLoadLibraryDirect(shortAsciiName, false /* setLastError */); } if (!dl_handle) |