summaryrefslogtreecommitdiff
path: root/src/coreclr
diff options
context:
space:
mode:
authorHadi Brais <hadi.b@live.com>2017-04-09 00:54:23 +0530
committerDan Moseley <danmose@microsoft.com>2017-04-08 12:24:23 -0700
commit551a7c5563105f7ec9a9d9273204d0a07a02c4fa (patch)
tree411087a62f3966b85b5ba052447b59f1a2405703 /src/coreclr
parent1ed5cf1a3a2aebe5487dff7984d0305ceec9823b (diff)
downloadcoreclr-551a7c5563105f7ec9a9d9273204d0a07a02c4fa.tar.gz
coreclr-551a7c5563105f7ec9a9d9273204d0a07a02c4fa.tar.bz2
coreclr-551a7c5563105f7ec9a9d9273204d0a07a02c4fa.zip
Fix corerun issue when loaded from PATH (#10745)
Diffstat (limited to 'src/coreclr')
-rw-r--r--src/coreclr/hosts/unixcoreconsole/coreconsole.cpp13
-rw-r--r--src/coreclr/hosts/unixcorerun/corerun.cpp2
-rw-r--r--src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp21
3 files changed, 7 insertions, 29 deletions
diff --git a/src/coreclr/hosts/unixcoreconsole/coreconsole.cpp b/src/coreclr/hosts/unixcoreconsole/coreconsole.cpp
index e43124d0f2..d46f6ef5bb 100644
--- a/src/coreclr/hosts/unixcoreconsole/coreconsole.cpp
+++ b/src/coreclr/hosts/unixcoreconsole/coreconsole.cpp
@@ -93,7 +93,6 @@ bool ParseArguments(
int main(const int argc, const char* argv[])
{
// Make sure we have a full path for argv[0].
- std::string argv0AbsolutePath;
std::string entryPointExecutablePath;
if (!GetEntrypointExecutableAbsolutePath(entryPointExecutablePath))
@@ -102,15 +101,9 @@ int main(const int argc, const char* argv[])
return -1;
}
- if (!GetAbsolutePath(entryPointExecutablePath.c_str(), argv0AbsolutePath))
- {
- perror("Could not normalize full path to current executable");
- return -1;
- }
-
// We will try to load the managed assembly with the same name as this executable
// but with the .dll extension.
- std::string programPath(argv0AbsolutePath);
+ std::string programPath(entryPointExecutablePath);
programPath.append(".dll");
const char* managedAssemblyAbsolutePath = programPath.c_str();
@@ -146,13 +139,13 @@ int main(const int argc, const char* argv[])
}
std::string clrFilesAbsolutePath;
- if(!GetClrFilesAbsolutePath(argv0AbsolutePath.c_str(), clrFilesPath, clrFilesAbsolutePath))
+ if(!GetClrFilesAbsolutePath(entryPointExecutablePath.c_str(), clrFilesPath, clrFilesAbsolutePath))
{
return -1;
}
int exitCode = ExecuteManagedAssembly(
- argv0AbsolutePath.c_str(),
+ entryPointExecutablePath.c_str(),
clrFilesAbsolutePath.c_str(),
managedAssemblyAbsolutePath,
managedAssemblyArgc,
diff --git a/src/coreclr/hosts/unixcorerun/corerun.cpp b/src/coreclr/hosts/unixcorerun/corerun.cpp
index da886d4338..4e5c9d9839 100644
--- a/src/coreclr/hosts/unixcorerun/corerun.cpp
+++ b/src/coreclr/hosts/unixcorerun/corerun.cpp
@@ -127,7 +127,7 @@ int corerun(const int argc, const char* argv[])
// Make sure we have a full path for argv[0].
std::string argv0AbsolutePath;
- if (!GetAbsolutePath(argv[0], argv0AbsolutePath))
+ if (!GetEntrypointExecutableAbsolutePath(argv0AbsolutePath))
{
perror("Could not get full path");
return -1;
diff --git a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
index 5ac7654780..d40fb424e6 100644
--- a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
+++ b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
@@ -49,21 +49,7 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
// Get path to the executable for the current process using
// platform specific means.
-#if defined(__linux__) || (defined(__NetBSD__) && !defined(KERN_PROC_PATHNAME))
- // On Linux, fetch the entry point EXE absolute path, inclusive of filename.
- char exe[PATH_MAX];
- ssize_t res = readlink(symlinkEntrypointExecutable, exe, PATH_MAX - 1);
- if (res != -1)
- {
- exe[res] = '\0';
- entrypointExecutable.assign(exe);
- result = true;
- }
- else
- {
- result = false;
- }
-#elif defined(__APPLE__)
+#if defined(__APPLE__)
// On Mac, we ask the OS for the absolute path to the entrypoint executable
uint32_t lenActualPath = 0;
@@ -115,10 +101,9 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
result = false;
}
#else
- // On non-Mac OS, return the symlink that will be resolved by GetAbsolutePath
+ // On other OSs, return the symlink that will be resolved by GetAbsolutePath
// to fetch the entrypoint EXE absolute path, inclusive of filename.
- entrypointExecutable.assign(symlinkEntrypointExecutable);
- result = true;
+ result = GetAbsolutePath(symlinkEntrypointExecutable, entrypointExecutable);
#endif
return result;