From abb5d8d97411b4260631f00fe3097e61e12466f1 Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 16 Feb 2016 15:27:24 +0900 Subject: Fix ildasm to be run without specifying the full path Using the fixed version of GetEntrypointExecutableAbsolutePath when the program name on the command line does not reflect an actual file on disk (case when a program is launched by finding it in the PATH). This should fix issue#3190. --- src/ildasm/unixcoreclrloader/coreclrloader.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ildasm/unixcoreclrloader/coreclrloader.cpp b/src/ildasm/unixcoreclrloader/coreclrloader.cpp index 4cb7cf367d..11c5bd4d10 100644 --- a/src/ildasm/unixcoreclrloader/coreclrloader.cpp +++ b/src/ildasm/unixcoreclrloader/coreclrloader.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include +#include #include "dlfcn.h" #include "coreclrloader.h" #include "coreruncommon.h" @@ -11,12 +12,15 @@ using namespace std; void *CoreCLRLoader::LoadFunction(const char *funcName) { void *func = nullptr; - if (coreclrLib == nullptr) { + if (coreclrLib == nullptr) + { fprintf(stderr, "Error: coreclr should be loaded before loading a function: %s\n", funcName); } - else { + else + { func = dlsym(coreclrLib, funcName); - if (func == nullptr) { + if (func == nullptr) + { fprintf(stderr, "Error: cannot find %s in coreclr\n", funcName); } } @@ -26,7 +30,12 @@ void *CoreCLRLoader::LoadFunction(const char *funcName) CoreCLRLoader* CoreCLRLoader::Create(const char *exePath) { string absolutePath, coreClrPath; - GetAbsolutePath(exePath, absolutePath); + bool success = GetAbsolutePath(exePath, absolutePath); + if (!success) + { + success = GetEntrypointExecutableAbsolutePath(absolutePath); + assert(success); + } GetDirectory(absolutePath.c_str(), coreClrPath); coreClrPath.append("/"); coreClrPath.append(coreClrDll); @@ -63,7 +72,8 @@ CoreCLRLoader* CoreCLRLoader::Create(const char *exePath) int CoreCLRLoader::Finish() { - if (hostHandle != 0) { + if (hostHandle != 0) + { shutdownCoreCLR(hostHandle, domainId); delete this; } -- cgit v1.2.3