summaryrefslogtreecommitdiff
path: root/src/coreclr/hosts/unixcorerun
diff options
context:
space:
mode:
authorMatt Ellis <matell@microsoft.com>2015-04-16 10:58:41 -0700
committerMatt Ellis <matell@microsoft.com>2015-04-16 10:58:41 -0700
commitd9bb4aad182f5c9940bea45b2dae0f3fe953c108 (patch)
treeeab4382c47e45b7b379ef0a9a3af8e4d16fcc6f0 /src/coreclr/hosts/unixcorerun
parentbaa57a0bd737d2cb43bd947274a552d3f0b7c202 (diff)
downloadcoreclr-d9bb4aad182f5c9940bea45b2dae0f3fe953c108.tar.gz
coreclr-d9bb4aad182f5c9940bea45b2dae0f3fe953c108.tar.bz2
coreclr-d9bb4aad182f5c9940bea45b2dae0f3fe953c108.zip
Explicitly load libcoreclrpal in corerun
libcoreclr has a dependency on libcoreclrpal, but libcoreclrpal is usually not on the path the loader probes, since it is SxS with the runtime itself. Instead of forcing LD_LIBRARY_PATH to be set just have corerun load the PAL from the same folder as the runtime before loading libcoreclr. Fixes #709
Diffstat (limited to 'src/coreclr/hosts/unixcorerun')
-rw-r--r--src/coreclr/hosts/unixcorerun/corerun.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/coreclr/hosts/unixcorerun/corerun.cpp b/src/coreclr/hosts/unixcorerun/corerun.cpp
index 28441a80e1..5f7bb6525b 100644
--- a/src/coreclr/hosts/unixcorerun/corerun.cpp
+++ b/src/coreclr/hosts/unixcorerun/corerun.cpp
@@ -18,8 +18,10 @@
// The name of the CoreCLR native runtime DLL.
#if defined(__APPLE__)
+static const char * const coreClrPal = "libcoreclrpal.dylib";
static const char * const coreClrDll = "libcoreclr.dylib";
#else
+static const char * const coreClrPal = "libcoreclrpal.so";
static const char * const coreClrDll = "libcoreclr.so";
#endif
@@ -280,10 +282,20 @@ int ExecuteManagedAssembly(
// Indicates failure
int exitCode = -1;
+ std::string coreClrPalPath(clrFilesAbsolutePath);
+ coreClrPalPath.append("/");
+ coreClrPalPath.append(coreClrPal);
+
std::string coreClrDllPath(clrFilesAbsolutePath);
coreClrDllPath.append("/");
coreClrDllPath.append(coreClrDll);
+ if (coreClrPalPath.length() >= PATH_MAX)
+ {
+ fprintf(stderr, "Absolute path to libcoreclrpal.so too long\n");
+ return -1;
+ }
+
if (coreClrDllPath.length() >= PATH_MAX)
{
fprintf(stderr, "Absolute path to libcoreclr.so too long\n");
@@ -300,6 +312,14 @@ int ExecuteManagedAssembly(
std::string tpaList;
AddFilesFromDirectoryToTpaList(clrFilesAbsolutePath, tpaList);
+
+ void* coreclrPal = dlopen(coreClrPalPath.c_str(), RTLD_NOW | RTLD_GLOBAL);
+ if (coreclrPal == nullptr)
+ {
+ char* error = dlerror();
+ fprintf(stderr, "dlopen failed to open the libcoreclrpal.so with error %s\n", error);
+ return -1;
+ }
void* coreclrLib = dlopen(coreClrDllPath.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (coreclrLib != nullptr)