Fix ildasm to be run without specifying the full path
authorManu <manu-silicon@users.noreply.github.com>
Tue, 16 Feb 2016 06:27:24 +0000 (15:27 +0900)
committerManu <manu-silicon@users.noreply.github.com>
Thu, 18 Feb 2016 01:40:34 +0000 (10:40 +0900)
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

index 4cb7cf3..11c5bd4 100644 (file)
@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 #include <stdio.h>
+#include <assert.h>
 #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;
   }