diff --git a/src/kernel/emulation/linux/process/execve.c b/src/kernel/emulation/linux/process/execve.c index 6c32488c8..9403f8cb6 100644 --- a/src/kernel/emulation/linux/process/execve.c +++ b/src/kernel/emulation/linux/process/execve.c @@ -96,24 +96,24 @@ long sys_execve(char* fname, char** argvp, char** envp) char *nl, *interp, *arg; char** modargvp; int i, j; - + nl = memchr(m.magic_array, '\n', sizeof(m.magic_array)); if (nl == NULL) return -ENOEXEC; - + *nl = '\0'; - + for (i = 2; isspace(m.magic_array[i]); i++); - + interp = &m.magic_array[i]; - + for (i = 0; !isspace(interp[i]) && interp[i]; i++); - + if (interp[i] == '\0') arg = NULL; else arg = &interp[i]; - + if (arg != NULL) { *arg = '\0'; // terminate interp @@ -124,13 +124,13 @@ long sys_execve(char* fname, char** argvp, char** envp) if (*arg == '\0') arg = NULL; // no argument, just whitespace } - + // Count original arguments while (argvp[len++]); - + // Allocate a new argvp modargvp = (char**) __builtin_alloca(sizeof(void*) * (len+3)); - + i = 0; modargvp[i++] = mldr_path; @@ -138,18 +138,16 @@ long sys_execve(char* fname, char** argvp, char** envp) if (arg != NULL) modargvp[i++] = arg; modargvp[i] = fname; - + // Append original arguments for (j = 1; j < len+1; j++) modargvp[i+j] = argvp[j]; - + argvp = modargvp; fname = mldr_path; } - else - { - return -ENOEXEC; - } + + // otherwise, it's a native Linux executable (ELF) ret = LINUX_SYSCALL(__NR_execve, fname, argvp, envp); if (ret < 0) -- 2.51.2 From 742b0f6bad1b65dba92976823ff8aac52f2f5c2b Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sat, 8 Apr 2017 20:07:37 +0300 Subject: [PATCH 2/4] Fix hdiutil --- src/external/darling-dmg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external/darling-dmg b/src/external/darling-dmg index c09b9caf2..c11aff761 160000 --- a/src/external/darling-dmg +++ b/src/external/darling-dmg @@ -1 +1 @@ -Subproject commit c09b9caf2610483bc22b3b17bab22eb6f2a668fa +Subproject commit c11aff761732d0f5ecdd39314d8f34a9065993bb -- 2.51.2 From f01f28650fefbf40c8ce42f2ae824458320e3644 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sun, 9 Apr 2017 02:12:47 +0800 Subject: [PATCH 3/4] Add /bin/expr --- src/external/shell_cmds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external/shell_cmds b/src/external/shell_cmds index 77a1df692..32e712e50 160000 --- a/src/external/shell_cmds +++ b/src/external/shell_cmds @@ -1 +1 @@ -Subproject commit 77a1df69236be2755928e8ffcbcf2b75876260e4 +Subproject commit 32e712e504ef872647167e2bc25c3d1b0d5bc2f8 -- 2.51.2 From 0c00bb48fdc29143ea2dbaf5cd3c5d84711862a8 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 13:43:52 -0700 Subject: [PATCH 4/4] Create stub-gen-c-func.py --- tools/stub-gen-c-func.py | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tools/stub-gen-c-func.py diff --git a/tools/stub-gen-c-func.py b/tools/stub-gen-c-func.py new file mode 100644 index 000000000..e5a11be05 --- /dev/null +++ b/tools/stub-gen-c-func.py @@ -0,0 +1,76 @@ +# This file is part of Darling. +# +# Copyright (C) 2017 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Darling is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Darling. If not, see . + +import sys, subprocess + +def usage(): + print "Usage: %s " % sys.argv[0] + +if len(sys.argv) != 3: + usage() + +macho = sys.argv[1] +dest = sys.argv[2] + +out = subprocess.check_output(["nm", "-Ug", macho]) + +functions = [] +for line in out.split("\n"): + if line == "": + continue + components = line.split(" ") + id = components[1] + name = components[2] + # Remove the underscore + name = name[1 : len(name)] + + if id == "T": + functions.append(name) + +header = open(dest + "/functions.h", "w") +source = open(dest + "/functions.c", "w") + +copyright ="""/* +This file is part of Darling. + +Copyright (C) 2017 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 +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Darling is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Darling. If not, see . +*/ + +""" + +header.write(copyright) +source.write(copyright) + +for funcname in functions: + header.write("void %s(void);\n" % funcname) + source.write("void %s(void) { }\n" % funcname) + +header.close() +source.close()