this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'master' of https://github.com/darlinghq/darling

+90 -16
+14 -16
src/kernel/emulation/linux/process/execve.c
··· 96 96 char *nl, *interp, *arg; 97 97 char** modargvp; 98 98 int i, j; 99 - 99 + 100 100 nl = memchr(m.magic_array, '\n', sizeof(m.magic_array)); 101 101 if (nl == NULL) 102 102 return -ENOEXEC; 103 - 103 + 104 104 *nl = '\0'; 105 - 105 + 106 106 for (i = 2; isspace(m.magic_array[i]); i++); 107 - 107 + 108 108 interp = &m.magic_array[i]; 109 - 109 + 110 110 for (i = 0; !isspace(interp[i]) && interp[i]; i++); 111 - 111 + 112 112 if (interp[i] == '\0') 113 113 arg = NULL; 114 114 else 115 115 arg = &interp[i]; 116 - 116 + 117 117 if (arg != NULL) 118 118 { 119 119 *arg = '\0'; // terminate interp ··· 124 124 if (*arg == '\0') 125 125 arg = NULL; // no argument, just whitespace 126 126 } 127 - 127 + 128 128 // Count original arguments 129 129 while (argvp[len++]); 130 - 130 + 131 131 // Allocate a new argvp 132 132 modargvp = (char**) __builtin_alloca(sizeof(void*) * (len+3)); 133 - 133 + 134 134 i = 0; 135 135 136 136 modargvp[i++] = mldr_path; ··· 138 138 if (arg != NULL) 139 139 modargvp[i++] = arg; 140 140 modargvp[i] = fname; 141 - 141 + 142 142 // Append original arguments 143 143 for (j = 1; j < len+1; j++) 144 144 modargvp[i+j] = argvp[j]; 145 - 145 + 146 146 argvp = modargvp; 147 147 fname = mldr_path; 148 148 } 149 - else 150 - { 151 - return -ENOEXEC; 152 - } 149 + 150 + // otherwise, it's a native Linux executable (ELF) 153 151 154 152 ret = LINUX_SYSCALL(__NR_execve, fname, argvp, envp); 155 153 if (ret < 0)
+76
tools/stub-gen-c-func.py
··· 1 + # This file is part of Darling. 2 + # 3 + # Copyright (C) 2017 Lubos Dolezel 4 + # 5 + # Darling is free software: you can redistribute it and/or modify 6 + # it under the terms of the GNU General Public License as published by 7 + # the Free Software Foundation, either version 3 of the License, or 8 + # (at your option) any later version. 9 + # 10 + # Darling is distributed in the hope that it will be useful, 11 + # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + # GNU General Public License for more details. 14 + # 15 + # You should have received a copy of the GNU General Public License 16 + # along with Darling. If not, see <http://www.gnu.org/licenses/>. 17 + 18 + import sys, subprocess 19 + 20 + def usage(): 21 + print "Usage: %s <Mach-O> <output directory>" % sys.argv[0] 22 + 23 + if len(sys.argv) != 3: 24 + usage() 25 + 26 + macho = sys.argv[1] 27 + dest = sys.argv[2] 28 + 29 + out = subprocess.check_output(["nm", "-Ug", macho]) 30 + 31 + functions = [] 32 + for line in out.split("\n"): 33 + if line == "": 34 + continue 35 + components = line.split(" ") 36 + id = components[1] 37 + name = components[2] 38 + # Remove the underscore 39 + name = name[1 : len(name)] 40 + 41 + if id == "T": 42 + functions.append(name) 43 + 44 + header = open(dest + "/functions.h", "w") 45 + source = open(dest + "/functions.c", "w") 46 + 47 + copyright ="""/* 48 + This file is part of Darling. 49 + 50 + Copyright (C) 2017 Lubos Dolezel 51 + 52 + Darling is free software: you can redistribute it and/or modify 53 + it under the terms of the GNU General Public License as published by 54 + the Free Software Foundation, either version 3 of the License, or 55 + (at your option) any later version. 56 + 57 + Darling is distributed in the hope that it will be useful, 58 + but WITHOUT ANY WARRANTY; without even the implied warranty of 59 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 60 + GNU General Public License for more details. 61 + 62 + You should have received a copy of the GNU General Public License 63 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 64 + */ 65 + 66 + """ 67 + 68 + header.write(copyright) 69 + source.write(copyright) 70 + 71 + for funcname in functions: 72 + header.write("void %s(void);\n" % funcname) 73 + source.write("void %s(void) { }\n" % funcname) 74 + 75 + header.close() 76 + source.close()