this repo has no description
1
fork

Configure Feed

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

Getting closer to Hello world running The current problem is two open descriptors for /dev/mach, which results in malfunctions in pthread initialization, which results in a crash when it tries to print out the error while libc is not inited yet

+10 -43
+8 -1
src/kernel/CMakeLists.txt
··· 9 9 add_subdirectory(emulation/linux) 10 10 11 11 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3 -w -fblocks -ggdb") 12 - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__DARWIN_UNIX03 -fPIC -w -nostdinc -Wl,-undefined,suppress -Wl,-flat_namespace") 12 + 13 + # Why -bind_at_load is necessary: 14 + # I couldn't find something like -Bsymbolic in Apple's ld 15 + # -> internal functions are being resolved by dyld 16 + # -> dyld places stubs -> stubs go into dyld_stub_binder at first use 17 + # -> there is a temporary loss of 16-byte stack alignment in __darling_bsd_syscall 18 + # -> dyld_stub_binder checks for this and bails out with a SIGSEGV 19 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__DARWIN_UNIX03 -fPIC -w -nostdinc -Wl,-bind_at_load -Wl,-undefined,suppress -Wl,-flat_namespace") 13 20 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib") 14 21 15 22 include_directories(${DARLING_TOP_DIRECTORY}/kernel-include)
+2 -42
src/libsystem/init.c
··· 96 96 * libsyscall_initializer() initializes all of libSystem.dylib <rdar://problem/4892197> 97 97 */ 98 98 static __attribute__((constructor)) 99 - void libSystem_initializer(int argc, const char* argv[], const char* envp[] /*, const char* apple[], const struct ProgramVars* vars*/) 99 + void libSystem_initializer(int argc, const char* argv[], const char* envp[] , const char* apple[], const struct ProgramVars* vars) 100 100 { 101 101 static const struct _libkernel_functions libkernel_funcs = { 102 102 .version = 1, ··· 106 106 .realloc = realloc, 107 107 ._pthread_exit_if_canceled = _pthread_exit_if_canceled, 108 108 }; 109 - 110 - _darling_initialize_commpage(); 111 - 112 - int* x_argc; 113 - char*** x_argv; 114 - char*** x_envp; 115 - char** apple = { NULL }; 116 - struct ProgramVars vars; 117 - 118 - /* Early initialization - original Apple code assumes pthread_init() doesn't print errors */ 119 - /*__darling_get_args(&x_argc, &x_argv, &x_envp, &vars); 120 - 121 - if (!*x_argc) 122 - { 123 - char* excl; 124 - 125 - // Darling libdyld is not being used 126 - // to execute a Mach-O binary. 127 - // Use what the ELF loader gave us. 128 - *x_argc = argc - 1; 129 - *x_argv = argv + 1; 130 - *x_envp = envp; 131 - 132 - excl = strchr(argv[1], '!'); 133 - if (excl != NULL) 134 - argv[1] = excl+1; 135 - 136 - vars.NXArgcPtr = x_argc; 137 - vars.NXArgvPtr = x_argv; 138 - vars.environPtr = x_envp; 139 - vars.__prognamePtr = &(*x_argv)[0]; 140 - vars.mh = NULL; 141 - 142 - __darling_set_environ(envp); // Initialize glibc's environ 143 - } 144 - __darling_set_libc_vars(x_argc, x_argv, x_envp);*/ 145 109 146 - /* cerror() calls require working pthread_self() */ 147 - char dummy_self[4096]; 148 - memset(dummy_self, 0, sizeof(dummy_self)); 149 - __pthread_set_self(dummy_self); 150 - 110 + _darling_initialize_commpage(); 151 111 __libkernel_init(&libkernel_funcs, *envp, apple, &vars); 152 112 153 113 bootstrap_init();