diff --git a/src/CoreServices/DateTimeUtils.cpp b/src/CoreServices/DateTimeUtils.cpp
index a10a2689f..e33988125 100644
--- a/src/CoreServices/DateTimeUtils.cpp
+++ b/src/CoreServices/DateTimeUtils.cpp
@@ -1,7 +1,7 @@
/*
This file is part of Darling.
-Copyright (C) 2012-2013 Lubos Dolezel
+Copyright (C) 2012-2016 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@ along with Darling. If not, see .
#include "DateTimeUtils.h"
#include
+#include
UTCDateTime Darling::time_tToUTC(time_t t)
{
@@ -97,3 +98,10 @@ OSErr UCConvertCFAbsoluteTimeToLongDateTime(CFAbsoluteTime in, int64_t* out)
}
}
+void GetDateTime(unsigned long* secs)
+{
+ time_t t;
+ time(&t);
+
+ *secs = t + 2082844800l;
+}
diff --git a/src/CoreServices/DateTimeUtils.h b/src/CoreServices/DateTimeUtils.h
index bc5e7a867..6d18d9204 100644
--- a/src/CoreServices/DateTimeUtils.h
+++ b/src/CoreServices/DateTimeUtils.h
@@ -52,6 +52,9 @@ OSErr UCConvertCFAbsoluteTimeToUTCDateTime(CFAbsoluteTime in, UTCDateTime* out);
OSErr UCConvertCFAbsoluteTimeToSeconds(CFAbsoluteTime in, uint32_t* out);
OSErr UCConvertCFAbsoluteTimeToLongDateTime(CFAbsoluteTime in, int64_t* out);
+// Seconds since 1.1.1904
+void GetDateTime(unsigned long* secs);
+
}
namespace Darling
diff --git a/src/dyld/dyld-multilib.c b/src/dyld/dyld-multilib.c
index 3c9633692..f5b990bb2 100644
--- a/src/dyld/dyld-multilib.c
+++ b/src/dyld/dyld-multilib.c
@@ -50,12 +50,19 @@ int main(int argc, char** argv)
int fd = -1;
const char* target = "64";
bool reg;
+ char *progfile, *pos;
if (argc == 2 && (reg = !strcmp(argv[1], "--register") || !strcmp(argv[1], "--deregister")))
return registerDeregister(argv[0], reg);
+ progfile = argv[1];
+ if ((pos = strchr(progfile, '!')) != NULL)
+ {
+ progfile = strdup(argv[1]);
+ progfile[pos - argv[1]] = '\0';
+ }
if (argc > 1)
- fd = open(argv[1], O_RDONLY | O_CLOEXEC);
+ fd = open(progfile, O_RDONLY | O_CLOEXEC);
// We let real dyld output all serious error messages
// not to duplicate the functionality.
diff --git a/src/dyld/dyld.cpp b/src/dyld/dyld.cpp
index b3d6a52fa..0ec764f35 100644
--- a/src/dyld/dyld.cpp
+++ b/src/dyld/dyld.cpp
@@ -120,7 +120,9 @@ int main(int argc, char** argv, char** envp)
"kernel extensions and other Mach-O files cannot be executed with dyld");
}
- if (!unprefixed_argv0.empty())
+ if (pretendArgv0 != nullptr)
+ argv[1] = (char*) pretendArgv0;
+ else if (!unprefixed_argv0.empty())
argv[1] = (char*) unprefixed_argv0.c_str();
obj->setCommandLine(argc-1, &argv[1], envp);
diff --git a/src/external/bash b/src/external/bash
index 34280113b..12325c41b 160000
--- a/src/external/bash
+++ b/src/external/bash
@@ -1 +1 @@
-Subproject commit 34280113bd880471889d1972199cedd060939c8c
+Subproject commit 12325c41bd74e1c19bfa0c7fefeb567ea2c077ef
diff --git a/src/kernel/emulation/linux/process/execve.c b/src/kernel/emulation/linux/process/execve.c
index b84daaea3..6564d8fef 100644
--- a/src/kernel/emulation/linux/process/execve.c
+++ b/src/kernel/emulation/linux/process/execve.c
@@ -40,7 +40,7 @@ long sys_execve(char* fname, char** argvp, char** envp)
uint32_t magic;
char magic_array[256];
} m;
-
+
// Ideally, if everybody used binfmt_misc to allow direct
// execution of Mach-O binaries under Darling, this wouldn't
// be necessary. But we cannot rely on that.
@@ -95,6 +95,7 @@ long sys_execve(char* fname, char** argvp, char** envp)
// It is a Mach-O file
int len, i;
char** modargvp;
+ char *translated, *buf;
len = __prefix_get_dyld_path(dyld_path, sizeof(dyld_path)-1);
if (len < 0)
@@ -116,7 +117,14 @@ long sys_execve(char* fname, char** argvp, char** envp)
// Allocate a new argvp, execute dyld_path
modargvp = (char**) __builtin_alloca(sizeof(void*) * (len+1));
modargvp[0] = dyld_path;
- modargvp[1] = (char*) __prefix_translate_path_link(fname);
+
+ translated = (char*) __prefix_translate_path_link(fname);
+ buf = __builtin_alloca(strlen(translated) + 2 + strlen(argvp[0]));
+
+ strcpy(buf, translated);
+ strcat(buf, "!");
+ strcat(buf, argvp[0]);
+ modargvp[1] = buf;
for (i = 2; i < len+1; i++)
modargvp[i] = argvp[i-1];