this repo has no description
1
fork

Configure Feed

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

Set DYLD_TASK_INFO from system_kernel initialization (darlinghq/darling#304)

+69 -24
+7 -3
src/dyld/src/dyldInitialization.cpp
··· 195 195 } 196 196 197 197 198 + extern "C" void setup_elfcalls(const char** apple); 198 199 extern "C" void mach_init(); 199 200 extern "C" void __guard_setup(const char* apple[]); 200 201 ··· 213 214 rebaseDyld(dyldsMachHeader, slide); 214 215 } 215 216 216 - // allow dyld to use mach messaging 217 - mach_init(); 218 - 219 217 // kernel sets up env pointer to be just past end of agv array 220 218 const char** envp = &argv[argc+1]; 221 219 ··· 223 221 const char** apple = envp; 224 222 while(*apple != NULL) { ++apple; } 225 223 ++apple; 224 + 225 + // Setup elfcalls for Darling 226 + setup_elfcalls(apple); 227 + 228 + // allow dyld to use mach messaging 229 + mach_init(); 226 230 227 231 // set up random value for stack canary 228 232 __guard_setup(apple);
+7 -4
src/kernel/emulation/linux/mach/CMakeLists.txt
··· 1 1 project(mach_server_client) 2 2 3 3 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -nostdinc") 4 - include_directories("${CMAKE_SOURCE_DIR}/platform-include") 5 - include_directories("${CMAKE_SOURCE_DIR}/src/libc/include") 6 - include_directories("${CMAKE_SOURCE_DIR}/src/kernel/emulation/linux/ext") 7 - include_directories("${CMAKE_SOURCE_DIR}/src/kernel/libsyscall/wrappers") 4 + include_directories( 5 + ${CMAKE_SOURCE_DIR}/platform-include 6 + ${CMAKE_SOURCE_DIR}/src/libc/include 7 + ${CMAKE_SOURCE_DIR}/src/kernel/emulation/linux/ext 8 + ${CMAKE_SOURCE_DIR}/src/kernel/libsyscall/wrappers 9 + ${CMAKE_SOURCE_DIR}/src/startup 10 + ) 8 11 9 12 set(mach_server_client_sources 10 13 mach_traps.c
+22
src/kernel/emulation/linux/mach/lkm.c
··· 4 4 #include <unistd.h> 5 5 #include <sys/resource.h> 6 6 #include "../../libsyscall/wrappers/_libkernel_init.h" 7 + #include <elfcalls.h> 8 + 9 + extern struct elf_calls* _elfcalls; 7 10 8 11 int driver_fd = -1; 9 12 ··· 16 19 extern int sys_dup2(int, int); 17 20 extern int sys_fcntl(int, int, int); 18 21 extern _libkernel_functions_t _libkernel_functions; 22 + 23 + static void setup_dyld_info(void); 19 24 20 25 void mach_driver_init(void) 21 26 { ··· 65 70 66 71 driver_fd = d; 67 72 } 73 + 74 + // Setup TASK_DYLD_INFO (needed for debuggers) 75 + setup_dyld_info(); 76 + } 77 + 78 + static void setup_dyld_info(void) 79 + { 80 + struct set_dyld_info_args dyld_info; 81 + uintptr_t loc; 82 + size_t len; 83 + 84 + _elfcalls->dyld_info(&loc, &len); 85 + 86 + dyld_info.all_images_address = loc; 87 + dyld_info.all_images_length = len; 88 + 89 + __real_ioctl(driver_fd, NR_set_dyld_info, &dyld_info); 68 90 } 69 91 70 92 __attribute__((visibility("default")))
+1
src/kernel/libsyscall/CMakeLists.txt
··· 73 73 set(syscall_sources 74 74 mach/mach_traps.S 75 75 os/alloc_once.c 76 + wrappers/elfcalls.c 76 77 wrappers/libproc/libproc.c 77 78 wrappers/libproc/proc_listpidspath.c 78 79
+2 -17
src/kernel/libsyscall/wrappers/_libkernel_init.c
··· 27 27 */ 28 28 29 29 #include "_libkernel_init.h" 30 - #include <elfcalls.h> 30 + #include "elfcalls.h" 31 31 32 32 extern int mach_init(void); 33 33 34 - __attribute__((visibility("default"))) 35 - struct elf_calls* _elfcalls; 36 - 37 - extern int strncmp(const char *s1, const char *s2, __SIZE_TYPE__ n); 38 - extern unsigned long long __simple_atoi16(const char* str, const char** endp); 39 - 40 34 /* dlsym() funcptr is for legacy support in exc_catcher */ 41 35 void* (*_dlsym)(void*, const char*) __attribute__((visibility("hidden"))); 42 36 ··· 49 43 const char *apple[] __attribute__((unused)), 50 44 const struct ProgramVars *vars __attribute__((unused))) 51 45 { 52 - int i; 53 46 _libkernel_functions = fns; 54 47 if (fns->dlsym) { 55 48 _dlsym = fns->dlsym; 56 49 } 57 50 58 - for (i = 0; apple[i] != NULL; i++) 59 - { 60 - if (strncmp(apple[i], "elf_calls=", 10) == 0) 61 - { 62 - uintptr_t table = (uintptr_t) __simple_atoi16(apple[i] + 12, NULL); 63 - _elfcalls = (struct elf_calls*) table; 64 - } 65 - } 66 - 51 + setup_elfcalls(apple); 67 52 mach_init(); 68 53 }
+23
src/kernel/libsyscall/wrappers/elfcalls.c
··· 1 + #include <stdint.h> 2 + #include <stddef.h> 3 + #include <elfcalls.h> 4 + 5 + extern int strncmp(const char *s1, const char *s2, __SIZE_TYPE__ n); 6 + extern unsigned long long __simple_atoi16(const char* str, const char** endp); 7 + 8 + __attribute__((visibility("default"))) 9 + struct elf_calls* _elfcalls; 10 + 11 + void setup_elfcalls(const char** apple) 12 + { 13 + int i; 14 + for (i = 0; apple[i] != NULL; i++) 15 + { 16 + if (strncmp(apple[i], "elf_calls=", 10) == 0) 17 + { 18 + uintptr_t table = (uintptr_t) __simple_atoi16(apple[i] + 12, NULL); 19 + _elfcalls = (struct elf_calls*) table; 20 + } 21 + } 22 + } 23 +
+7
src/kernel/libsyscall/wrappers/elfcalls.h
··· 1 + #ifndef _KERNEL_ELFCALLS_H 2 + #define _KERNEL_ELFCALLS_H 3 + 4 + void setup_elfcalls(const char** apple); 5 + 6 + #endif 7 +