Skip to content

Commit

Permalink
[runtime] Fix the executable name we use for embedded. (dotnet#2095)
Browse files Browse the repository at this point in the history
We need to know the executable name to deduce the assembly name for the main assembly.
  • Loading branch information
rolfbjarne authored May 16, 2017
1 parent a4214e9 commit 425274a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <pthread.h>
#include <objc/runtime.h>
#include <sys/stat.h>
#include <dlfcn.h>

#include "product.h"
#include "shared.h"
Expand Down Expand Up @@ -1112,8 +1113,27 @@ -(void) xamarinSetGCHandle: (int) gc_handle;
return;
initialized = true;

char *argv[] = { (char *) "embedded" };
char *argv[] = { NULL };
char *libname = NULL;

Dl_info info;
if (dladdr ((void *) xamarin_initialize_embedded, &info) != 0) {
char *last_sep = strrchr (info.dli_fname, '/');
if (last_sep == NULL) {
libname = strdup (info.dli_fname);
} else {
libname = strdup (last_sep + 1);
}
argv [0] = libname;
}

if (argv [0] == NULL)
argv [0] = (char *) "embedded";

xamarin_main (1, argv, XamarinLaunchModeEmbedded);

if (libname != NULL)
free (libname);
}

/* Installs g_print/g_error handlers that will redirect output to the system Console */
Expand Down

0 comments on commit 425274a

Please sign in to comment.