···11/*
22This file is part of Darling.
3344-Copyright (C) 2012-2013 Lubos Dolezel
44+Copyright (C) 2012-2016 Lubos Dolezel
5566Darling is free software: you can redistribute it and/or modify
77it under the terms of the GNU General Public License as published by
···19192020#include "DateTimeUtils.h"
2121#include <climits>
2222+#include <ctime>
22232324UTCDateTime Darling::time_tToUTC(time_t t)
2425{
···9798 }
9899}
99100101101+void GetDateTime(unsigned long* secs)
102102+{
103103+ time_t t;
104104+ time(&t);
105105+106106+ *secs = t + 2082844800l;
107107+}
+3
src/CoreServices/DateTimeUtils.h
···5252OSErr UCConvertCFAbsoluteTimeToSeconds(CFAbsoluteTime in, uint32_t* out);
5353OSErr UCConvertCFAbsoluteTimeToLongDateTime(CFAbsoluteTime in, int64_t* out);
54545555+// Seconds since 1.1.1904
5656+void GetDateTime(unsigned long* secs);
5757+5558}
56595760namespace Darling
+8-1
src/dyld/dyld-multilib.c
···5050 int fd = -1;
5151 const char* target = "64";
5252 bool reg;
5353+ char *progfile, *pos;
53545455 if (argc == 2 && (reg = !strcmp(argv[1], "--register") || !strcmp(argv[1], "--deregister")))
5556 return registerDeregister(argv[0], reg);
56575858+ progfile = argv[1];
5959+ if ((pos = strchr(progfile, '!')) != NULL)
6060+ {
6161+ progfile = strdup(argv[1]);
6262+ progfile[pos - argv[1]] = '\0';
6363+ }
5764 if (argc > 1)
5858- fd = open(argv[1], O_RDONLY | O_CLOEXEC);
6565+ fd = open(progfile, O_RDONLY | O_CLOEXEC);
59666067 // We let real dyld output all serious error messages
6168 // not to duplicate the functionality.
+3-1
src/dyld/dyld.cpp
···120120 "kernel extensions and other Mach-O files cannot be executed with dyld");
121121 }
122122123123- if (!unprefixed_argv0.empty())
123123+ if (pretendArgv0 != nullptr)
124124+ argv[1] = (char*) pretendArgv0;
125125+ else if (!unprefixed_argv0.empty())
124126 argv[1] = (char*) unprefixed_argv0.c_str();
125127126128 obj->setCommandLine(argc-1, &argv[1], envp);
+10-2
src/kernel/emulation/linux/process/execve.c
···4040 uint32_t magic;
4141 char magic_array[256];
4242 } m;
4343-4343+4444 // Ideally, if everybody used binfmt_misc to allow direct
4545 // execution of Mach-O binaries under Darling, this wouldn't
4646 // be necessary. But we cannot rely on that.
···9595 // It is a Mach-O file
9696 int len, i;
9797 char** modargvp;
9898+ char *translated, *buf;
989999100 len = __prefix_get_dyld_path(dyld_path, sizeof(dyld_path)-1);
100101 if (len < 0)
···116117 // Allocate a new argvp, execute dyld_path
117118 modargvp = (char**) __builtin_alloca(sizeof(void*) * (len+1));
118119 modargvp[0] = dyld_path;
119119- modargvp[1] = (char*) __prefix_translate_path_link(fname);
120120+121121+ translated = (char*) __prefix_translate_path_link(fname);
122122+ buf = __builtin_alloca(strlen(translated) + 2 + strlen(argvp[0]));
123123+124124+ strcpy(buf, translated);
125125+ strcat(buf, "!");
126126+ strcat(buf, argvp[0]);
127127+ modargvp[1] = buf;
120128121129 for (i = 2; i < len+1; i++)
122130 modargvp[i] = argvp[i-1];