From 2b3b86da3f4014ac805bd490e3d9c0837ec2ded3 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Thu, 6 Apr 2017 15:40:36 -0700 Subject: [PATCH 01/17] Build basic_cmds --- .gitmodules | 3 +++ src/CMakeLists.txt | 3 +++ src/external/basic_cmds | 1 + 3 files changed, 7 insertions(+) create mode 160000 src/external/basic_cmds diff --git a/.gitmodules b/.gitmodules index d4ba87d27..f4cd4fd52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -215,3 +215,6 @@ [submodule "src/external/doc_cmds"] path = src/external/doc_cmds url = ../darling-doc_cmds.git +[submodule "src/external/basic_cmds"] + path = src/external/basic_cmds + url = ../darling-basic_cmds.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 981413012..5bef11a19 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,6 +186,9 @@ add_subdirectory(external/screen) add_subdirectory(unxip) add_subdirectory(external/zsh) add_subdirectory(external/doc_cmds) +add_subdirectory(external/basic_cmds) + + add_subdirectory(external/libcxxabi) add_subdirectory(external/libcxx) diff --git a/src/external/basic_cmds b/src/external/basic_cmds new file mode 160000 index 000000000..b1ed4f0f6 --- /dev/null +++ b/src/external/basic_cmds @@ -0,0 +1 @@ +Subproject commit b1ed4f0f6a981590542071d8b36535cf3e441be0 -- 2.51.2 From c70524cff685249d213bdfb5733c56fb5ae2e525 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Thu, 6 Apr 2017 19:33:36 -0700 Subject: [PATCH 02/17] Build misc_cmds --- .gitmodules | 3 +++ src/CMakeLists.txt | 2 +- src/external/misc_cmds | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 160000 src/external/misc_cmds diff --git a/.gitmodules b/.gitmodules index f4cd4fd52..1f4083c4d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -218,3 +218,6 @@ [submodule "src/external/basic_cmds"] path = src/external/basic_cmds url = ../darling-basic_cmds.git +[submodule "src/external/misc_cmds"] + path = src/external/misc_cmds + url = ../darling-misc_cmds.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5bef11a19..f73fa3a57 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -187,7 +187,7 @@ add_subdirectory(unxip) add_subdirectory(external/zsh) add_subdirectory(external/doc_cmds) add_subdirectory(external/basic_cmds) - +add_subdirectory(external/misc_cmds) add_subdirectory(external/libcxxabi) add_subdirectory(external/libcxx) diff --git a/src/external/misc_cmds b/src/external/misc_cmds new file mode 160000 index 000000000..9e03c7669 --- /dev/null +++ b/src/external/misc_cmds @@ -0,0 +1 @@ +Subproject commit 9e03c766998263c699ebaa836bb6f3d06c8fb407 -- 2.51.2 From 9539c45b55ed41400d9f0e2f0b5d1f279a06911b Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Thu, 6 Apr 2017 20:02:11 -0700 Subject: [PATCH 03/17] Build patch_cmds --- .gitmodules | 3 +++ src/CMakeLists.txt | 1 + src/external/patch_cmds | 1 + 3 files changed, 5 insertions(+) create mode 160000 src/external/patch_cmds diff --git a/.gitmodules b/.gitmodules index 1f4083c4d..8cdc1e7f7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -221,3 +221,6 @@ [submodule "src/external/misc_cmds"] path = src/external/misc_cmds url = ../darling-misc_cmds.git +[submodule "src/external/patch_cmds"] + path = src/external/patch_cmds + url = ../darling-patch_cmds.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f73fa3a57..1b0d56b18 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -188,6 +188,7 @@ add_subdirectory(external/zsh) add_subdirectory(external/doc_cmds) add_subdirectory(external/basic_cmds) add_subdirectory(external/misc_cmds) +add_subdirectory(external/patch_cmds) add_subdirectory(external/libcxxabi) add_subdirectory(external/libcxx) diff --git a/src/external/patch_cmds b/src/external/patch_cmds new file mode 160000 index 000000000..68902fb25 --- /dev/null +++ b/src/external/patch_cmds @@ -0,0 +1 @@ +Subproject commit 68902fb252bd0834ef47b3e8c45f9d0e2652e149 -- 2.51.2 From a9abe47e0d761598390f7a7a8f095460d6a3fec1 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Fri, 7 Apr 2017 08:31:04 -0700 Subject: [PATCH 04/17] Fake the GID too --- src/kernel/emulation/linux/unistd/getegid.c | 7 +++++++ src/kernel/emulation/linux/unistd/getgid.c | 6 ++++++ src/kernel/emulation/linux/unistd/getgroups.c | 4 ++-- src/tools/sudo | 6 ++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/kernel/emulation/linux/unistd/getegid.c b/src/kernel/emulation/linux/unistd/getegid.c index faee4d99a..f556e691b 100644 --- a/src/kernel/emulation/linux/unistd/getegid.c +++ b/src/kernel/emulation/linux/unistd/getegid.c @@ -2,11 +2,18 @@ #include "../base.h" #include "../errno.h" #include +#include +#include long sys_getegid(void) { int ret; +#ifndef VARIANT_DYLD // dyld cannot call getenv + if (getenv("__FAKE_SETGID_ROOT") != NULL) + return 0; +#endif + #ifdef __NR_getegid32 ret = LINUX_SYSCALL0(__NR_getegid32); #else diff --git a/src/kernel/emulation/linux/unistd/getgid.c b/src/kernel/emulation/linux/unistd/getgid.c index 423c7b20c..e9096d240 100644 --- a/src/kernel/emulation/linux/unistd/getgid.c +++ b/src/kernel/emulation/linux/unistd/getgid.c @@ -2,10 +2,16 @@ #include "../base.h" #include "../errno.h" #include +#include +#include long sys_getgid(void) { int ret; +#ifndef VARIANT_DYLD // dyld cannot call getenv + if (getenv("__FAKE_SETGID_ROOT") != NULL) + return 0; +#endif #ifdef __NR_getgid32 ret = LINUX_SYSCALL0(__NR_getgid32); diff --git a/src/kernel/emulation/linux/unistd/getgroups.c b/src/kernel/emulation/linux/unistd/getgroups.c index 80f734b15..e3de98803 100644 --- a/src/kernel/emulation/linux/unistd/getgroups.c +++ b/src/kernel/emulation/linux/unistd/getgroups.c @@ -8,8 +8,8 @@ long sys_getgroups(unsigned int size, int* gidset) { int ret; - - if (getenv("__FAKE_SETUID_ROOT")) + + if (getenv("__FAKE_SETGID_ROOT")) { if (size >= 1) { diff --git a/src/tools/sudo b/src/tools/sudo index e59551d99..247ad2442 100644 --- a/src/tools/sudo +++ b/src/tools/sudo @@ -27,4 +27,10 @@ if [ $# -lt 1 ]; then fi export __FAKE_SETUID_ROOT=1 +export __FAKE_SETGID_ROOT=1 + +if [ $1 == "-k" ]; then + shift +fi + exec "${@:1}" -- 2.51.2 From 0a0ab22382a2bddb086e17c6bc282a5a0cb1ce39 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Fri, 7 Apr 2017 19:04:50 -0700 Subject: [PATCH 05/17] Add DSTools and DirectoryServices This is for the `dsmemberutil` program, needed by the Homebrew installer --- .gitmodules | 6 ++++++ platform-include/DSlibinfoMIG_types.h | 1 + platform-include/DSmemberdMIG.h | 1 + platform-include/DSmemberdMIG_types.h | 1 + platform-include/membership.h | 1 + platform-include/membershipPriv.h | 1 + platform-include/ntsid.h | 1 + src/CMakeLists.txt | 2 ++ src/external/DSTools | 1 + src/external/DirectoryService | 1 + 10 files changed, 16 insertions(+) create mode 120000 platform-include/DSlibinfoMIG_types.h create mode 120000 platform-include/DSmemberdMIG.h create mode 120000 platform-include/DSmemberdMIG_types.h create mode 120000 platform-include/membership.h create mode 120000 platform-include/membershipPriv.h create mode 120000 platform-include/ntsid.h create mode 160000 src/external/DSTools create mode 160000 src/external/DirectoryService diff --git a/.gitmodules b/.gitmodules index 8cdc1e7f7..77dc31fe9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -224,3 +224,9 @@ [submodule "src/external/patch_cmds"] path = src/external/patch_cmds url = ../darling-patch_cmds.git +[submodule "src/external/DSTools"] + path = src/external/DSTools + url = ../darling-DSTools.git +[submodule "src/external/DirectoryService"] + path = src/external/DirectoryService + url = ../darling-DirectoryService.git diff --git a/platform-include/DSlibinfoMIG_types.h b/platform-include/DSlibinfoMIG_types.h new file mode 120000 index 000000000..d05f36a60 --- /dev/null +++ b/platform-include/DSlibinfoMIG_types.h @@ -0,0 +1 @@ +../src/external/DirectoryService/Server/DSlibinfoMIG_types.h \ No newline at end of file diff --git a/platform-include/DSmemberdMIG.h b/platform-include/DSmemberdMIG.h new file mode 120000 index 000000000..cb2b5b8b6 --- /dev/null +++ b/platform-include/DSmemberdMIG.h @@ -0,0 +1 @@ +../src/external/DirectoryService/gen/DSmemberdMIG.h \ No newline at end of file diff --git a/platform-include/DSmemberdMIG_types.h b/platform-include/DSmemberdMIG_types.h new file mode 120000 index 000000000..16971e7c4 --- /dev/null +++ b/platform-include/DSmemberdMIG_types.h @@ -0,0 +1 @@ +../src/external/DirectoryService/Server/DSmemberdMIG_types.h \ No newline at end of file diff --git a/platform-include/membership.h b/platform-include/membership.h new file mode 120000 index 000000000..15fe6f85a --- /dev/null +++ b/platform-include/membership.h @@ -0,0 +1 @@ +../src/libinfo/membership.subproj/membership.h \ No newline at end of file diff --git a/platform-include/membershipPriv.h b/platform-include/membershipPriv.h new file mode 120000 index 000000000..d0a17b4eb --- /dev/null +++ b/platform-include/membershipPriv.h @@ -0,0 +1 @@ +../src/libinfo/membership.subproj/membershipPriv.h \ No newline at end of file diff --git a/platform-include/ntsid.h b/platform-include/ntsid.h new file mode 120000 index 000000000..31c10c50e --- /dev/null +++ b/platform-include/ntsid.h @@ -0,0 +1 @@ +../src/libinfo/membership.subproj/ntsid.h \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b0d56b18..1266fee9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -189,6 +189,8 @@ add_subdirectory(external/doc_cmds) add_subdirectory(external/basic_cmds) add_subdirectory(external/misc_cmds) add_subdirectory(external/patch_cmds) +add_subdirectory(external/DSTools) +add_subdirectory(external/DirectoryService) add_subdirectory(external/libcxxabi) add_subdirectory(external/libcxx) diff --git a/src/external/DSTools b/src/external/DSTools new file mode 160000 index 000000000..b1d05a7ba --- /dev/null +++ b/src/external/DSTools @@ -0,0 +1 @@ +Subproject commit b1d05a7ba1c1467f294deff30a8e0763b3321426 diff --git a/src/external/DirectoryService b/src/external/DirectoryService new file mode 160000 index 000000000..5026ba14b --- /dev/null +++ b/src/external/DirectoryService @@ -0,0 +1 @@ +Subproject commit 5026ba14b9bc01bd5780548a423fa7cdab1feaba -- 2.51.2 From f0e8f43654524f8bf228dd1f74555fd6ca6ffe4a Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sat, 8 Apr 2017 20:03:15 +0300 Subject: [PATCH 06/17] Fix exec'ing ELFs --- src/kernel/emulation/linux/process/execve.c | 30 ++++++++++----------- 1 file changed, 14 insertions(+), 16 deletions(-) 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 07/17] 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 08/17] 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 09/17] 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() -- 2.51.2 From ab1b98f5a58afeb5fd9c114c451665c1386a2132 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 13:48:26 -0700 Subject: [PATCH 10/17] Some OpenDirectory work --- platform-include/launch.h | 1 + platform-include/opendirectory | 1 + platform-include/xpc/private.h | 1 + src/external/libxpc | 2 +- src/libinfo/CMakeLists.txt | 8 +++++++- src/libinfo/membership.subproj/CMakeLists.txt | 4 ++++ src/opendirectory/include/opendirectory/odipc.h | 7 +++++++ 7 files changed, 22 insertions(+), 2 deletions(-) create mode 120000 platform-include/launch.h create mode 120000 platform-include/opendirectory create mode 120000 platform-include/xpc/private.h create mode 100644 src/opendirectory/include/opendirectory/odipc.h diff --git a/platform-include/launch.h b/platform-include/launch.h new file mode 120000 index 000000000..4a4e515dc --- /dev/null +++ b/platform-include/launch.h @@ -0,0 +1 @@ +../src/launchd/liblaunch/launch.h \ No newline at end of file diff --git a/platform-include/opendirectory b/platform-include/opendirectory new file mode 120000 index 000000000..6e3312b23 --- /dev/null +++ b/platform-include/opendirectory @@ -0,0 +1 @@ +../src/opendirectory/include/opendirectory/ \ No newline at end of file diff --git a/platform-include/xpc/private.h b/platform-include/xpc/private.h new file mode 120000 index 000000000..65329a7b9 --- /dev/null +++ b/platform-include/xpc/private.h @@ -0,0 +1 @@ +../../src/external/libxpc/xpc/private.h \ No newline at end of file diff --git a/src/external/libxpc b/src/external/libxpc index f72de1d0e..da28ea126 160000 --- a/src/external/libxpc +++ b/src/external/libxpc @@ -1 +1 @@ -Subproject commit f72de1d0e6f4a14b93972df871a8f7158d61517c +Subproject commit da28ea126aa2d9867932eaf3c488910aa9667708 diff --git a/src/libinfo/CMakeLists.txt b/src/libinfo/CMakeLists.txt index 4c0246473..a826279a2 100644 --- a/src/libinfo/CMakeLists.txt +++ b/src/libinfo/CMakeLists.txt @@ -15,9 +15,13 @@ add_definitions(-DHAVE_STDINT_H=1) add_definitions(-D__APPLE__ -D__DYNAMIC__) add_definitions(-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=1080) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC -w -ggdb") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC -ggdb") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib") +add_compile_options( + -Wno-macro-redefined +) + include_directories(${CMAKE_SOURCE_DIR}/src/libc/darwin) include_directories(${CMAKE_SOURCE_DIR}/src/kernel/libsyscall/wrappers) include_directories(${CMAKE_SOURCE_DIR}/src/libmalloc/include) @@ -64,6 +68,8 @@ add_circular(system_info FAT libdispatch_shared system_notify platform + xpc + compiler_rt DEPENDENCIES resolv-darwin ) diff --git a/src/libinfo/membership.subproj/CMakeLists.txt b/src/libinfo/membership.subproj/CMakeLists.txt index f49632e60..6230232e7 100644 --- a/src/libinfo/membership.subproj/CMakeLists.txt +++ b/src/libinfo/membership.subproj/CMakeLists.txt @@ -10,6 +10,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../external/libdispatch/) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../lookup.subproj) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_definitions( + -DDS_AVAILABLE +) + set(info-membership_sources membership.c ) diff --git a/src/opendirectory/include/opendirectory/odipc.h b/src/opendirectory/include/opendirectory/odipc.h new file mode 100644 index 000000000..3b1a7fbf3 --- /dev/null +++ b/src/opendirectory/include/opendirectory/odipc.h @@ -0,0 +1,7 @@ +#ifndef _OD_ODIPC_H_ +#define _OD_ODIPC_H_ + +#define kODMachMembershipPortNameDebug 1 +#define kODMachMembershipPortName 1 + +#endif -- 2.51.2 From bfc5afc061a014311e74229ffc82281a9f5ed3c8 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 13:49:27 -0700 Subject: [PATCH 11/17] Update darling-dmg and shell_cmds --- src/external/darling-dmg | 2 +- src/external/shell_cmds | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/external/darling-dmg b/src/external/darling-dmg index c11aff761..c09b9caf2 160000 --- a/src/external/darling-dmg +++ b/src/external/darling-dmg @@ -1 +1 @@ -Subproject commit c11aff761732d0f5ecdd39314d8f34a9065993bb +Subproject commit c09b9caf2610483bc22b3b17bab22eb6f2a668fa diff --git a/src/external/shell_cmds b/src/external/shell_cmds index 32e712e50..77a1df692 160000 --- a/src/external/shell_cmds +++ b/src/external/shell_cmds @@ -1 +1 @@ -Subproject commit 32e712e504ef872647167e2bc25c3d1b0d5bc2f8 +Subproject commit 77a1df69236be2755928e8ffcbcf2b75876260e4 -- 2.51.2 From 29df86d67a565ff848ce5ad642eea6b39af34497 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 13:56:14 -0700 Subject: [PATCH 12/17] Stop building BSD patch GNU patch is used by macOS instead --- src/external/patch_cmds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external/patch_cmds b/src/external/patch_cmds index 68902fb25..346880dc9 160000 --- a/src/external/patch_cmds +++ b/src/external/patch_cmds @@ -1 +1 @@ -Subproject commit 68902fb252bd0834ef47b3e8c45f9d0e2652e149 +Subproject commit 346880dc91fdcf4f714119a7d64c003a7a2570dc -- 2.51.2 From e3bf8634c30cfab314ac44506c248c5c5118fefe Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 13:56:40 -0700 Subject: [PATCH 13/17] Build ImageIO stubs --- src/CMakeLists.txt | 1 + src/ImageIO/CMakeLists.txt | 21 +++++ src/ImageIO/functions.c | 165 +++++++++++++++++++++++++++++++++++++ src/ImageIO/functions.h | 165 +++++++++++++++++++++++++++++++++++++ 4 files changed, 352 insertions(+) create mode 100644 src/ImageIO/CMakeLists.txt create mode 100755 src/ImageIO/functions.c create mode 100755 src/ImageIO/functions.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1266fee9e..b3c7dd02e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -191,6 +191,7 @@ add_subdirectory(external/misc_cmds) add_subdirectory(external/patch_cmds) add_subdirectory(external/DSTools) add_subdirectory(external/DirectoryService) +add_subdirectory(ImageIO) add_subdirectory(external/libcxxabi) add_subdirectory(external/libcxx) diff --git a/src/ImageIO/CMakeLists.txt b/src/ImageIO/CMakeLists.txt new file mode 100644 index 000000000..81ea26f88 --- /dev/null +++ b/src/ImageIO/CMakeLists.txt @@ -0,0 +1,21 @@ +project(ImageIO) + +add_compile_options( + -nostdinc +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_framework(ImageIO + FAT + CURRENT_VERSION + VERSION "A" + + SOURCES + functions.c + + DEPENDENCIES + system +) diff --git a/src/ImageIO/functions.c b/src/ImageIO/functions.c new file mode 100755 index 000000000..0cd72e1a0 --- /dev/null +++ b/src/ImageIO/functions.c @@ -0,0 +1,165 @@ +/* +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 . +*/ + +void CGCopyBasicPropertiesOfImageAtPath(void) { } +void CGImageConvertExtendedSRGBToColorspace(void) { } +void CGImageCopyFileWithGPSInformation(void) { } +void CGImageCopyFileWithParameters(void) { } +void CGImageCopyJPEGData(void) { } +void CGImageCopyJPEGDataAndColorSpace(void) { } +void CGImageCopySourceData(void) { } +void CGImageCreateByMatchingToColorSpace(void) { } +void CGImageCreateByMatchingToDisplay(void) { } +void CGImageCreateByScaling(void) { } +void CGImageCreateCopyWithAlphaInfo(void) { } +void CGImageCreateCopyWithParameters(void) { } +void CGImageCreateEXIFDataFromProperties(void) { } +void CGImageCreateEXIFJPEGData(void) { } +void CGImageCreateFromIOSurface(void) { } +void CGImageCreateThumb(void) { } +void CGImageDestinationAddImage(void) { } +void CGImageDestinationAddImageAndMetadata(void) { } +void CGImageDestinationAddImageFromSource(void) { } +void CGImageDestinationAddImageFromSourceWithMetadata(void) { } +void CGImageDestinationAddImageWithMetadata(void) { } +void CGImageDestinationCopyImageFormats(void) { } +void CGImageDestinationCopyImageSource(void) { } +void CGImageDestinationCopyTypeIdentifiers(void) { } +void CGImageDestinationCreateWithData(void) { } +void CGImageDestinationCreateWithDataConsumer(void) { } +void CGImageDestinationCreateWithURL(void) { } +void CGImageDestinationFinalize(void) { } +void CGImageDestinationGetTypeID(void) { } +void CGImageDestinationSetProperties(void) { } +void CGImageMetadataCopyStringValueWithPath(void) { } +void CGImageMetadataCopyTagMatchingImageProperty(void) { } +void CGImageMetadataCopyTagWithPath(void) { } +void CGImageMetadataCopyTags(void) { } +void CGImageMetadataCreateFromData(void) { } +void CGImageMetadataCreateFromMetadataProperties(void) { } +void CGImageMetadataCreateFromXMPData(void) { } +void CGImageMetadataCreateMetadataProperties(void) { } +void CGImageMetadataCreateMutable(void) { } +void CGImageMetadataCreateMutableCopy(void) { } +void CGImageMetadataCreateSerializedData(void) { } +void CGImageMetadataCreateSidecar(void) { } +void CGImageMetadataCreateXMPData(void) { } +void CGImageMetadataEnumerateTagsUsingBlock(void) { } +void CGImageMetadataGetTypeID(void) { } +void CGImageMetadataPropertyCreate(void) { } +void CGImageMetadataPropertyGetPropertyName(void) { } +void CGImageMetadataPropertyGetSchema(void) { } +void CGImageMetadataPropertyGetSuggestedPrefix(void) { } +void CGImageMetadataPropertyGetTypeID(void) { } +void CGImageMetadataPropertyGetValue(void) { } +void CGImageMetadataPropertySetValue(void) { } +void CGImageMetadataRegisterNamespaceForPrefix(void) { } +void CGImageMetadataRemoveTagWithPath(void) { } +void CGImageMetadataSerialize(void) { } +void CGImageMetadataSetTagWithPath(void) { } +void CGImageMetadataSetValueMatchingImageProperty(void) { } +void CGImageMetadataSetValueWithPath(void) { } +void CGImageMetadataTagCopyName(void) { } +void CGImageMetadataTagCopyNamespace(void) { } +void CGImageMetadataTagCopyPrefix(void) { } +void CGImageMetadataTagCopyQualifiers(void) { } +void CGImageMetadataTagCopyValue(void) { } +void CGImageMetadataTagCreate(void) { } +void CGImageMetadataTagGetType(void) { } +void CGImageMetadataTagGetTypeID(void) { } +void CGImageMetadataValueAddQualifier(void) { } +void CGImageMetadataValueCreate(void) { } +void CGImageMetadataValueGetNamespaceURI(void) { } +void CGImageMetadataValueGetQualifiers(void) { } +void CGImageMetadataValueGetSuggestedNamespacePrefix(void) { } +void CGImageMetadataValueGetTypeID(void) { } +void CGImageMetadataValueGetValue(void) { } +void CGImageMetadataValueIsAlternate(void) { } +void CGImageMetadataValueIsAlternateText(void) { } +void CGImageMetadataValueSetIsAlternate(void) { } +void CGImageMetadataValueSetIsAlternateText(void) { } +void CGImageMetadataValueSetNamespaceURI(void) { } +void CGImageMetadataValueSetSuggestedNamespacePrefix(void) { } +void CGImagePluginGetMetadata(void) { } +void CGImagePluginGetOptions(void) { } +void CGImagePluginGetProperties(void) { } +void CGImagePluginGetSession(void) { } +void CGImagePluginInitJPEGAtOffset(void) { } +void CGImagePluginInitThumbJPEGAtOffset(void) { } +void CGImagePluginReadRawIPTCProps(void) { } +void CGImagePluginReadRawXMPProps(void) { } +void CGImagePluginReadRawXMPSidecarProps(void) { } +void CGImagePluginSetBandProc(void) { } +void CGImagePluginSetClipPath(void) { } +void CGImagePluginSetImage(void) { } +void CGImagePluginSetImageBlockProc(void) { } +void CGImagePluginSetJpegProvider(void) { } +void CGImageReadSessionCreateFILE(void) { } +void CGImageReadSessionGetBytePointer(void) { } +void CGImageReadSessionGetBytes(void) { } +void CGImageReadSessionGetBytesAtOffset(void) { } +void CGImageReadSessionGetFilePath(void) { } +void CGImageReadSessionGetReadRef(void) { } +void CGImageReadSessionGetSize(void) { } +void CGImageReadSessionIsFinal(void) { } +void CGImageReadSessionReleaseBytePointer(void) { } +void CGImageReadSessionRewind(void) { } +void CGImageReadSessionSeek(void) { } +void CGImageReadSessionSkipBytes(void) { } +void CGImageSaveToFile(void) { } +void CGImageSourceAddProperty(void) { } +void CGImageSourceCopyMetadataAtIndex(void) { } +void CGImageSourceCopyMetadataPropertiesAtIndex(void) { } +void CGImageSourceCopyProperties(void) { } +void CGImageSourceCopyPropertiesAtIndex(void) { } +void CGImageSourceCopyTypeExtensions(void) { } +void CGImageSourceCopyTypeIdentifiers(void) { } +void CGImageSourceCreateIOSurfaceAtIndex(void) { } +void CGImageSourceCreateImageAtIndex(void) { } +void CGImageSourceCreateIncremental(void) { } +void CGImageSourceCreateThumbnailAtIndex(void) { } +void CGImageSourceCreateWithData(void) { } +void CGImageSourceCreateWithDataProvider(void) { } +void CGImageSourceCreateWithFile(void) { } +void CGImageSourceCreateWithURL(void) { } +void CGImageSourceGetCount(void) { } +void CGImageSourceGetImageCacheAtIndex(void) { } +void CGImageSourceGetProperties(void) { } +void CGImageSourceGetPropertiesAtIndex(void) { } +void CGImageSourceGetStatus(void) { } +void CGImageSourceGetStatusAtIndex(void) { } +void CGImageSourceGetType(void) { } +void CGImageSourceGetTypeID(void) { } +void CGImageSourceGetTypeWithData(void) { } +void CGImageSourceGetTypeWithDataProvider(void) { } +void CGImageSourceGetTypeWithExtension(void) { } +void CGImageSourceGetTypeWithFile(void) { } +void CGImageSourceGetTypeWithURL(void) { } +void CGImageSourceIsColorOptimizedForSharing(void) { } +void CGImageSourceRemoveCacheAtIndex(void) { } +void CGImageSourceUpdateData(void) { } +void CGImageSourceUpdateDataProvider(void) { } +void CGImageWriteEXIFJPEGToPath(void) { } +void CGImageWriteEXIFJPEGWithMetadata(void) { } +void CGImageWriteSessionPutBytes(void) { } +void CopyMetadataFromFileAtPath(void) { } +void CopyMetadataFromSequentialDataProviderCallbacks(void) { } +void GetMetadataPropertyMatchingSchemaAndPropertyName(void) { } +void ImageIODebug(void) { } +void ImageIOSetLoggingProc(void) { } diff --git a/src/ImageIO/functions.h b/src/ImageIO/functions.h new file mode 100755 index 000000000..42a1e4f88 --- /dev/null +++ b/src/ImageIO/functions.h @@ -0,0 +1,165 @@ +/* +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 . +*/ + +void CGCopyBasicPropertiesOfImageAtPath(void); +void CGImageConvertExtendedSRGBToColorspace(void); +void CGImageCopyFileWithGPSInformation(void); +void CGImageCopyFileWithParameters(void); +void CGImageCopyJPEGData(void); +void CGImageCopyJPEGDataAndColorSpace(void); +void CGImageCopySourceData(void); +void CGImageCreateByMatchingToColorSpace(void); +void CGImageCreateByMatchingToDisplay(void); +void CGImageCreateByScaling(void); +void CGImageCreateCopyWithAlphaInfo(void); +void CGImageCreateCopyWithParameters(void); +void CGImageCreateEXIFDataFromProperties(void); +void CGImageCreateEXIFJPEGData(void); +void CGImageCreateFromIOSurface(void); +void CGImageCreateThumb(void); +void CGImageDestinationAddImage(void); +void CGImageDestinationAddImageAndMetadata(void); +void CGImageDestinationAddImageFromSource(void); +void CGImageDestinationAddImageFromSourceWithMetadata(void); +void CGImageDestinationAddImageWithMetadata(void); +void CGImageDestinationCopyImageFormats(void); +void CGImageDestinationCopyImageSource(void); +void CGImageDestinationCopyTypeIdentifiers(void); +void CGImageDestinationCreateWithData(void); +void CGImageDestinationCreateWithDataConsumer(void); +void CGImageDestinationCreateWithURL(void); +void CGImageDestinationFinalize(void); +void CGImageDestinationGetTypeID(void); +void CGImageDestinationSetProperties(void); +void CGImageMetadataCopyStringValueWithPath(void); +void CGImageMetadataCopyTagMatchingImageProperty(void); +void CGImageMetadataCopyTagWithPath(void); +void CGImageMetadataCopyTags(void); +void CGImageMetadataCreateFromData(void); +void CGImageMetadataCreateFromMetadataProperties(void); +void CGImageMetadataCreateFromXMPData(void); +void CGImageMetadataCreateMetadataProperties(void); +void CGImageMetadataCreateMutable(void); +void CGImageMetadataCreateMutableCopy(void); +void CGImageMetadataCreateSerializedData(void); +void CGImageMetadataCreateSidecar(void); +void CGImageMetadataCreateXMPData(void); +void CGImageMetadataEnumerateTagsUsingBlock(void); +void CGImageMetadataGetTypeID(void); +void CGImageMetadataPropertyCreate(void); +void CGImageMetadataPropertyGetPropertyName(void); +void CGImageMetadataPropertyGetSchema(void); +void CGImageMetadataPropertyGetSuggestedPrefix(void); +void CGImageMetadataPropertyGetTypeID(void); +void CGImageMetadataPropertyGetValue(void); +void CGImageMetadataPropertySetValue(void); +void CGImageMetadataRegisterNamespaceForPrefix(void); +void CGImageMetadataRemoveTagWithPath(void); +void CGImageMetadataSerialize(void); +void CGImageMetadataSetTagWithPath(void); +void CGImageMetadataSetValueMatchingImageProperty(void); +void CGImageMetadataSetValueWithPath(void); +void CGImageMetadataTagCopyName(void); +void CGImageMetadataTagCopyNamespace(void); +void CGImageMetadataTagCopyPrefix(void); +void CGImageMetadataTagCopyQualifiers(void); +void CGImageMetadataTagCopyValue(void); +void CGImageMetadataTagCreate(void); +void CGImageMetadataTagGetType(void); +void CGImageMetadataTagGetTypeID(void); +void CGImageMetadataValueAddQualifier(void); +void CGImageMetadataValueCreate(void); +void CGImageMetadataValueGetNamespaceURI(void); +void CGImageMetadataValueGetQualifiers(void); +void CGImageMetadataValueGetSuggestedNamespacePrefix(void); +void CGImageMetadataValueGetTypeID(void); +void CGImageMetadataValueGetValue(void); +void CGImageMetadataValueIsAlternate(void); +void CGImageMetadataValueIsAlternateText(void); +void CGImageMetadataValueSetIsAlternate(void); +void CGImageMetadataValueSetIsAlternateText(void); +void CGImageMetadataValueSetNamespaceURI(void); +void CGImageMetadataValueSetSuggestedNamespacePrefix(void); +void CGImagePluginGetMetadata(void); +void CGImagePluginGetOptions(void); +void CGImagePluginGetProperties(void); +void CGImagePluginGetSession(void); +void CGImagePluginInitJPEGAtOffset(void); +void CGImagePluginInitThumbJPEGAtOffset(void); +void CGImagePluginReadRawIPTCProps(void); +void CGImagePluginReadRawXMPProps(void); +void CGImagePluginReadRawXMPSidecarProps(void); +void CGImagePluginSetBandProc(void); +void CGImagePluginSetClipPath(void); +void CGImagePluginSetImage(void); +void CGImagePluginSetImageBlockProc(void); +void CGImagePluginSetJpegProvider(void); +void CGImageReadSessionCreateFILE(void); +void CGImageReadSessionGetBytePointer(void); +void CGImageReadSessionGetBytes(void); +void CGImageReadSessionGetBytesAtOffset(void); +void CGImageReadSessionGetFilePath(void); +void CGImageReadSessionGetReadRef(void); +void CGImageReadSessionGetSize(void); +void CGImageReadSessionIsFinal(void); +void CGImageReadSessionReleaseBytePointer(void); +void CGImageReadSessionRewind(void); +void CGImageReadSessionSeek(void); +void CGImageReadSessionSkipBytes(void); +void CGImageSaveToFile(void); +void CGImageSourceAddProperty(void); +void CGImageSourceCopyMetadataAtIndex(void); +void CGImageSourceCopyMetadataPropertiesAtIndex(void); +void CGImageSourceCopyProperties(void); +void CGImageSourceCopyPropertiesAtIndex(void); +void CGImageSourceCopyTypeExtensions(void); +void CGImageSourceCopyTypeIdentifiers(void); +void CGImageSourceCreateIOSurfaceAtIndex(void); +void CGImageSourceCreateImageAtIndex(void); +void CGImageSourceCreateIncremental(void); +void CGImageSourceCreateThumbnailAtIndex(void); +void CGImageSourceCreateWithData(void); +void CGImageSourceCreateWithDataProvider(void); +void CGImageSourceCreateWithFile(void); +void CGImageSourceCreateWithURL(void); +void CGImageSourceGetCount(void); +void CGImageSourceGetImageCacheAtIndex(void); +void CGImageSourceGetProperties(void); +void CGImageSourceGetPropertiesAtIndex(void); +void CGImageSourceGetStatus(void); +void CGImageSourceGetStatusAtIndex(void); +void CGImageSourceGetType(void); +void CGImageSourceGetTypeID(void); +void CGImageSourceGetTypeWithData(void); +void CGImageSourceGetTypeWithDataProvider(void); +void CGImageSourceGetTypeWithExtension(void); +void CGImageSourceGetTypeWithFile(void); +void CGImageSourceGetTypeWithURL(void); +void CGImageSourceIsColorOptimizedForSharing(void); +void CGImageSourceRemoveCacheAtIndex(void); +void CGImageSourceUpdateData(void); +void CGImageSourceUpdateDataProvider(void); +void CGImageWriteEXIFJPEGToPath(void); +void CGImageWriteEXIFJPEGWithMetadata(void); +void CGImageWriteSessionPutBytes(void); +void CopyMetadataFromFileAtPath(void); +void CopyMetadataFromSequentialDataProviderCallbacks(void); +void GetMetadataPropertyMatchingSchemaAndPropertyName(void); +void ImageIODebug(void); +void ImageIOSetLoggingProc(void); -- 2.51.2 From 28652c46d1f7edbe9173ca61d7cb0c5367490687 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 14:04:02 -0700 Subject: [PATCH 14/17] Improvements to stub-gen-c-func.py --- tools/stub-gen-c-func.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/stub-gen-c-func.py b/tools/stub-gen-c-func.py index e5a11be05..26119d4da 100644 --- a/tools/stub-gen-c-func.py +++ b/tools/stub-gen-c-func.py @@ -18,7 +18,7 @@ import sys, subprocess def usage(): - print "Usage: %s " % sys.argv[0] + print("Usage: %s " % sys.argv[0]) if len(sys.argv) != 3: usage() @@ -29,14 +29,12 @@ dest = sys.argv[2] out = subprocess.check_output(["nm", "-Ug", macho]) functions = [] -for line in out.split("\n"): +for line in out.splitlines(): if line == "": continue - components = line.split(" ") - id = components[1] - name = components[2] + address, id, name = line.split(" ") # Remove the underscore - name = name[1 : len(name)] + name = name[1 : ] if id == "T": functions.append(name) @@ -71,6 +69,3 @@ 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() -- 2.51.2 From 8ec15186ad90382bb149c2235e394dd77779b44b Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 14:04:48 -0700 Subject: [PATCH 15/17] Do one import per line --- tools/stub-gen-c-func.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/stub-gen-c-func.py b/tools/stub-gen-c-func.py index 26119d4da..b9b36a532 100644 --- a/tools/stub-gen-c-func.py +++ b/tools/stub-gen-c-func.py @@ -15,7 +15,8 @@ # You should have received a copy of the GNU General Public License # along with Darling. If not, see . -import sys, subprocess +import sys +import subprocess def usage(): print("Usage: %s " % sys.argv[0]) -- 2.51.2 From ddbcac42e063daaabe5f0850766c4e7406c20e23 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Sat, 8 Apr 2017 14:40:17 -0700 Subject: [PATCH 16/17] Build login.framework and DebugSymbols.framework --- src/CMakeLists.txt | 2 + src/DebugSymbols/CMakeLists.txt | 28 ++- src/DebugSymbols/DebugSymbols.mm | 2 - src/DebugSymbols/README.md | 4 - src/DebugSymbols/functions.c | 49 ++++ src/DebugSymbols/functions.h | 49 ++++ .../include/DebugSymbols/DebugSymbols.h | 0 src/external/system_cmds | 2 +- src/login/CMakeLists.txt | 22 ++ src/login/functions.c | 222 ++++++++++++++++++ src/login/functions.h | 222 ++++++++++++++++++ 11 files changed, 582 insertions(+), 20 deletions(-) delete mode 100644 src/DebugSymbols/DebugSymbols.mm delete mode 100644 src/DebugSymbols/README.md create mode 100755 src/DebugSymbols/functions.c create mode 100755 src/DebugSymbols/functions.h delete mode 100644 src/DebugSymbols/include/DebugSymbols/DebugSymbols.h create mode 100644 src/login/CMakeLists.txt create mode 100644 src/login/functions.c create mode 100644 src/login/functions.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3c7dd02e..738f6f71d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,8 @@ add_subdirectory(external/patch_cmds) add_subdirectory(external/DSTools) add_subdirectory(external/DirectoryService) add_subdirectory(ImageIO) +add_subdirectory(login) +add_subdirectory(DebugSymbols) add_subdirectory(external/libcxxabi) add_subdirectory(external/libcxx) diff --git a/src/DebugSymbols/CMakeLists.txt b/src/DebugSymbols/CMakeLists.txt index 7b04cc217..4ef796a6c 100644 --- a/src/DebugSymbols/CMakeLists.txt +++ b/src/DebugSymbols/CMakeLists.txt @@ -1,20 +1,22 @@ project(DebugSymbols) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) - cmake_policy(SET CMP0005 NEW) -endif(COMMAND cmake_policy) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_compile_options( + -nostdinc +) -set(DebugSymbols_sources - DebugSymbols.mm +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} ) -SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/darling") -SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +add_framework(DebugSymbols + FAT + CURRENT_VERSION + PRIVATE + VERSION "A" -add_library(DebugSymbols SHARED ${DebugSymbols_sources}) + SOURCES + functions.c -install(TARGETS DebugSymbols DESTINATION "${CMAKE_INSTALL_LIBDIR}/darling") + DEPENDENCIES + system +) diff --git a/src/DebugSymbols/DebugSymbols.mm b/src/DebugSymbols/DebugSymbols.mm deleted file mode 100644 index ead15b2af..000000000 --- a/src/DebugSymbols/DebugSymbols.mm +++ /dev/null @@ -1,2 +0,0 @@ -void blank() { -} diff --git a/src/DebugSymbols/README.md b/src/DebugSymbols/README.md deleted file mode 100644 index b24f80153..000000000 --- a/src/DebugSymbols/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# DebugSymbols.framework - -`DebugSymbols.framework` helps locate dSYM files when given a UUID. - diff --git a/src/DebugSymbols/functions.c b/src/DebugSymbols/functions.c new file mode 100755 index 000000000..e11bca5e6 --- /dev/null +++ b/src/DebugSymbols/functions.c @@ -0,0 +1,49 @@ +/* +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 . +*/ + +void DBGAddDSYMURL(void) { } +void DBGBlockPath(void) { } +void DBGCopyDSYMPropertyLists(void) { } +void DBGCopyDSYMURLForUUID(void) { } +void DBGCopyDSYMURLForUUIDWithOptions(void) { } +void DBGCopyFullDSYMURLForUUID(void) { } +void DBGCopyFullDSYMURLForUUIDWithOptions(void) { } +void DBGCopyMatchingUUIDsForURL(void) { } +void DBGDwarfClose(void) { } +void DBGDwarfGetAttributeKey(void) { } +void DBGDwarfGetCompileUnitFunctions(void) { } +void DBGDwarfGetCompileUnitLineTable(void) { } +void DBGDwarfGetCompileUnits(void) { } +void DBGDwarfGetDIEObjectsForAddress(void) { } +void DBGDwarfGetFirstChild(void) { } +void DBGDwarfGetLinkMap(void) { } +void DBGDwarfGetParent(void) { } +void DBGDwarfGetSibling(void) { } +void DBGDwarfGetTagKey(void) { } +void DBGDwarfOpen(void) { } +void DBGExplicitSearchPathAdd(void) { } +void DBGExplicitSearchPathRemove(void) { } +void DBGExplicitSearchPathRemoveAll(void) { } +void DBGPauseWatchingPaths(void) { } +void DBGRegisterObserver(void) { } +void DBGResumeWatchingPaths(void) { } +void DBGSpotlightStart(void) { } +void DBGSpotlightStop(void) { } +void DBGTerminate(void) { } +void DBGUnregisterObserver(void) { } diff --git a/src/DebugSymbols/functions.h b/src/DebugSymbols/functions.h new file mode 100755 index 000000000..d4979f354 --- /dev/null +++ b/src/DebugSymbols/functions.h @@ -0,0 +1,49 @@ +/* +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 . +*/ + +void DBGAddDSYMURL(void); +void DBGBlockPath(void); +void DBGCopyDSYMPropertyLists(void); +void DBGCopyDSYMURLForUUID(void); +void DBGCopyDSYMURLForUUIDWithOptions(void); +void DBGCopyFullDSYMURLForUUID(void); +void DBGCopyFullDSYMURLForUUIDWithOptions(void); +void DBGCopyMatchingUUIDsForURL(void); +void DBGDwarfClose(void); +void DBGDwarfGetAttributeKey(void); +void DBGDwarfGetCompileUnitFunctions(void); +void DBGDwarfGetCompileUnitLineTable(void); +void DBGDwarfGetCompileUnits(void); +void DBGDwarfGetDIEObjectsForAddress(void); +void DBGDwarfGetFirstChild(void); +void DBGDwarfGetLinkMap(void); +void DBGDwarfGetParent(void); +void DBGDwarfGetSibling(void); +void DBGDwarfGetTagKey(void); +void DBGDwarfOpen(void); +void DBGExplicitSearchPathAdd(void); +void DBGExplicitSearchPathRemove(void); +void DBGExplicitSearchPathRemoveAll(void); +void DBGPauseWatchingPaths(void); +void DBGRegisterObserver(void); +void DBGResumeWatchingPaths(void); +void DBGSpotlightStart(void); +void DBGSpotlightStop(void); +void DBGTerminate(void); +void DBGUnregisterObserver(void); diff --git a/src/DebugSymbols/include/DebugSymbols/DebugSymbols.h b/src/DebugSymbols/include/DebugSymbols/DebugSymbols.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/external/system_cmds b/src/external/system_cmds index b3f3dd0bd..1f32732fe 160000 --- a/src/external/system_cmds +++ b/src/external/system_cmds @@ -1 +1 @@ -Subproject commit b3f3dd0bd8f920407cc88483727948c8ed7b2ab9 +Subproject commit 1f32732fe2667d08bdb28ef93dd1e1612a734042 diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt new file mode 100644 index 000000000..1f066f746 --- /dev/null +++ b/src/login/CMakeLists.txt @@ -0,0 +1,22 @@ +project(login) + +add_compile_options( + -nostdinc +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_framework(login + FAT + CURRENT_VERSION + PRIVATE + VERSION "A" + + SOURCES + functions.c + + DEPENDENCIES + system +) diff --git a/src/login/functions.c b/src/login/functions.c new file mode 100644 index 000000000..0e09730b4 --- /dev/null +++ b/src/login/functions.c @@ -0,0 +1,222 @@ +/* +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 . +*/ + +void CFXPCRelease(void) { } +void CreateArgumentsForFunction(void) { } +void GetSessionAgentClient(void) { } +void GetSessionManagementClient(void) { } +void JoinAuditSessionIfNeeded(void) { } +void LFAppleIDBreadcrumbCheckin(void) { } +void LFAppleIDBreadcrumbCopyAppleIDForUser(void) { } +void LFAppleIDBreadcrumbCopyOldKeychainPassword(void) { } +void LFAppleIDBreadcrumbUpdate(void) { } +void LFArgumentsAddAuditSessionID(void) { } +void LFArgumentsAddBoolean(void) { } +void LFArgumentsAddCFObject(void) { } +void LFArgumentsAddCString(void) { } +void LFArgumentsAddConnection(void) { } +void LFArgumentsAddConnectionEndpoint(void) { } +void LFArgumentsAddInt64(void) { } +void LFArgumentsAddLFClient(void) { } +void LFArgumentsAddLFServer(void) { } +void LFArgumentsAddMachPort(void) { } +void LFArgumentsAddNull(void) { } +void LFArgumentsAddUInt64(void) { } +void LFArgumentsCallFunction(void) { } +void LFArgumentsCopyFunctionIdentifier(void) { } +void LFArgumentsCreate(void) { } +void LFArgumentsCreateWithArguments(void) { } +void LFArgumentsCreateWithXPCDictionary(void) { } +void LFArgumentsGetDictionary(void) { } +void LFArgumentsGetFunction(void) { } +void LFArgumentsIsValid(void) { } +void LFArgumentsShouldAddArgumentForFlag(void) { } +void LFClientAddErrorHandler(void) { } +void LFClientCreateWithConnection(void) { } +void LFClientCreateWithConnectionAndServer(void) { } +void LFClientCreateWithServiceName(void) { } +void LFClientGetConnection(void) { } +void LFClientGetEndpoint(void) { } +void LFClientGetPID(void) { } +void LFClientGetServer(void) { } +void LFClientGetTypeID(void) { } +void LFClientRemoveErrorHandler(void) { } +void LFClientSendArgumentsAndGetCFReply(void) { } +void LFClientSendArgumentsAndGetReply(void) { } +void LFClientSetEndpoint(void) { } +void LFClientSetEventHandler(void) { } +void LFClientSetInstance(void) { } +void LFClientSetIsMachService(void) { } +void LFClientSetPrivileged(void) { } +void LFClientSetUserID(void) { } +void LFClientStart(void) { } +void LFClientStop(void) { } +void LFDBLoggingControllerStart(void) { } +void LFDBLoggingControllerStop(void) { } +void LFDictionaryCreateMutableWithObjectForKey(void) { } +void LFDictionaryGetBooleanForKey(void) { } +void LFDictionaryGetCFIndexForKey(void) { } +void LFDictionaryGetDictionaryForKey(void) { } +void LFDictionaryGetDoubleForKey(void) { } +void LFDictionarySetBoolean(void) { } +void LFDictionarySetCFIndex(void) { } +void LFDictionarySetDictionary(void) { } +void LFFunctionCacheAddFunction(void) { } +void LFFunctionCacheCreateServerFunction(void) { } +void LFFunctionCacheGetFunction(void) { } +void LFFunctionCreateClientFunction(void) { } +void LFFunctionCreateServerFunction(void) { } +void LFFunctionGetIdentifier(void) { } +void LFLogUnhandledEventType(void) { } +void LFSMCloseSession(void) { } +void LFSMCopyAllSessions(void) { } +void LFSMCopyCurrentSession(void) { } +void LFSMCopySessionProperties(void) { } +void LFSMCopySessionWithCGSessionID(void) { } +void LFSMCreateDefaultSessionOptions(void) { } +void LFSMCreateSessionWithOptions(void) { } +void LFSMCreateSessionWithOptionsByStartingServer(void) { } +void LFSMSessionGetTypeID(void) { } +void LFSMSwitchToSessionWithOptions(void) { } +void LFServerCreate(void) { } +void LFServerGetClientForConnection(void) { } +void LFServerGetConnection(void) { } +void LFServerGetEventHandler(void) { } +void LFServerGetServiceName(void) { } +void LFServerGetTypeID(void) { } +void LFServerSetIsMachService(void) { } +void LFServerStart(void) { } +void LFServerStop(void) { } +void LFStringCreateFromString(void) { } +void LogindServerCreate(void) { } +void LogindServerRelease(void) { } +void SACBeginLoginTransition(void) { } +void SACCopyOnceMiniBuddyItem(void) { } +void SACDeleteMiniBuddyItem(void) { } +void SACDisableFileVaultForCurrentUserWithPassword(void) { } +void SACEnableFileVaultForCurrentUserWithPassword(void) { } +void SACFaceTimeCallRingStart(void) { } +void SACFaceTimeCallRingStop(void) { } +void SACLOFinishDelayedLogout(void) { } +void SACLORegisterLogoutStatusCallbacks(void) { } +void SACLOStartLogout(void) { } +void SACLOStartLogoutWithOptions(void) { } +void SACLegacyFileVaultCloseProgressWindow(void) { } +void SACLegacyFileVaultSetBarPercentage(void) { } +void SACLegacyFileVaultSetPhase(void) { } +void SACLegacyFileVaultSetTask(void) { } +void SACLegacyFileVaultShowErrorMessage(void) { } +void SACLegacyFileVaultShowProgressWindow(void) { } +void SACLegacyFileVaultUpdateTimeRemaining(void) { } +void SACLegacyFileVaultUpdateUI(void) { } +void SACLockScreenImmediate(void) { } +void SACLogoutComplete(void) { } +void SACMessageFaceTimeCancelCall(void) { } +void SACMessageFaceTimeMuteCall(void) { } +void SACMessageLogoutStatusClientLogoutFailed(void) { } +void SACMessageLogoutStatusClientLogoutSuccess(void) { } +void SACMessageMiniBuddyUIShowing(void) { } +void SACMiniBuddyCopyUpgradeDictionary(void) { } +void SACMiniBuddySignalCompleted(void) { } +void SACMiniBuddySignalFinishedStage1WithOptions(void) { } +void SACProximityPreferencesChanged(void) { } +void SACRestartForUser(void) { } +void SACSaveSetupUserScreenShots(void) { } +void SACScreenLockEnabled(void) { } +void SACScreenLockPreferencesChanged(void) { } +void SACScreenSaverCanRun(void) { } +void SACScreenSaverDidFadeInBackground(void) { } +void SACScreenSaverIsRunning(void) { } +void SACScreenSaverIsRunningInBackground(void) { } +void SACScreenSaverStartNow(void) { } +void SACScreenSaverStopNow(void) { } +void SACScreenSaverStopNowWithOptions(void) { } +void SACScreenSaverTimeRemaining(void) { } +void SACSetAppleIDVerified(void) { } +void SACSetAutoLoginPassword(void) { } +void SACSetFileVaultPassword(void) { } +void SACSetFinalSnapshot(void) { } +void SACSetMiniBuddyItem(void) { } +void SACSetPhoneProximity(void) { } +void SACSetScreenSaverCanRun(void) { } +void SACShieldWindowShowing(void) { } +void SACStartProgressIndicator(void) { } +void SACStartSessionForLoginWindow(void) { } +void SACStartSessionForUser(void) { } +void SACStopProgressIndicator(void) { } +void SACStopSessionForLoginWindow(void) { } +void SACSwitchToLoginWindow(void) { } +void SACSwitchToUser(void) { } +void SACUpdateAppleIDUserLogin(void) { } +void SACWriteKeyboardType(void) { } +void SAClearLWScreenShots(void) { } +void SAClearLaunchSoftwareUpdateTrigger(void) { } +void SAClearSoftwareUpdateOptions(void) { } +void SAPrepareForSetupUserScreenShots(void) { } +void SAResetLoginKeychainForAutoLoginPassword(void) { } +void SASSessionStateForUser(void) { } +void SASetAppleIDVerified(void) { } +void SASetAutoLoginUserScreenLocked(void) { } +void SASetAutologinPW(void) { } +void SASetLaunchSoftwareUpdateTrigger(void) { } +void SASetPreviousStartupWasPanic(void) { } +void SASetSCDynamicStoreConsoleInformation(void) { } +void SASetSessionAuthenticatedFlag(void) { } +void SASetSessionHasConsoleAccessFlag(void) { } +void SASetSessionState(void) { } +void SASetSoftwareUpdateOption(void) { } +void SASetSwapCompaction(void) { } +void SASetTextEncodingBias(void) { } +void SASync(void) { } +void SASystemNotifyPost(void) { } +void SAWriteKeyboardType(void) { } +void SLOAddErrorHandler(void) { } +void SLOLegacyFileVaultSetState(void) { } +void SLOStartLogoutOfType(void) { } +void SMCopySessionUserInfo(void) { } +void SMGetSessionAgentConnection(void) { } +void SMRegisterSessionAgent(void) { } +void SMSetSessionUserInfo(void) { } +void SOStartSessionWithOptions(void) { } +void SessionAgentServerCreate(void) { } +void SessionAgentServerGetServer(void) { } +void SessionAgentServerRelease(void) { } +void SessionLogoutServerCreate(void) { } +void SessionLogoutServerRelease(void) { } +void SessionOwnerServerCreate(void) { } +void SessionOwnerServerRelease(void) { } +void _LFArgumentsCopyDebugDesc(void) { } +void _LFArgumentsCopyFormattingDesc(void) { } +void _LFArgumentsFinalize(void) { } +void _LFArgumentsInit(void) { } +void _LFFunctionCopyDebugDesc(void) { } +void _LFFunctionCopyFormattingDesc(void) { } +void _LFFunctionCreateServerFunction(void) { } +void _LFFunctionEqual(void) { } +void _LFFunctionFinalize(void) { } +void _LFFunctionHash(void) { } +void _LFFunctionInit(void) { } +void _LFGetBreadcrumbEncryptedKeyWithBlock(void) { } +void _LFServerCopyDebugDesc(void) { } +void _LFServerCopyFormattingDesc(void) { } +void _LFServerEqual(void) { } +void _LFServerFinalize(void) { } +void _LFServerHash(void) { } +void _LFSetBreadcrumbEncryptedKeyWithBlock(void) { } +void logindServerGetServer(void) { } diff --git a/src/login/functions.h b/src/login/functions.h new file mode 100644 index 000000000..d879aa1f1 --- /dev/null +++ b/src/login/functions.h @@ -0,0 +1,222 @@ +/* +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 . +*/ + +void CFXPCRelease(void); +void CreateArgumentsForFunction(void); +void GetSessionAgentClient(void); +void GetSessionManagementClient(void); +void JoinAuditSessionIfNeeded(void); +void LFAppleIDBreadcrumbCheckin(void); +void LFAppleIDBreadcrumbCopyAppleIDForUser(void); +void LFAppleIDBreadcrumbCopyOldKeychainPassword(void); +void LFAppleIDBreadcrumbUpdate(void); +void LFArgumentsAddAuditSessionID(void); +void LFArgumentsAddBoolean(void); +void LFArgumentsAddCFObject(void); +void LFArgumentsAddCString(void); +void LFArgumentsAddConnection(void); +void LFArgumentsAddConnectionEndpoint(void); +void LFArgumentsAddInt64(void); +void LFArgumentsAddLFClient(void); +void LFArgumentsAddLFServer(void); +void LFArgumentsAddMachPort(void); +void LFArgumentsAddNull(void); +void LFArgumentsAddUInt64(void); +void LFArgumentsCallFunction(void); +void LFArgumentsCopyFunctionIdentifier(void); +void LFArgumentsCreate(void); +void LFArgumentsCreateWithArguments(void); +void LFArgumentsCreateWithXPCDictionary(void); +void LFArgumentsGetDictionary(void); +void LFArgumentsGetFunction(void); +void LFArgumentsIsValid(void); +void LFArgumentsShouldAddArgumentForFlag(void); +void LFClientAddErrorHandler(void); +void LFClientCreateWithConnection(void); +void LFClientCreateWithConnectionAndServer(void); +void LFClientCreateWithServiceName(void); +void LFClientGetConnection(void); +void LFClientGetEndpoint(void); +void LFClientGetPID(void); +void LFClientGetServer(void); +void LFClientGetTypeID(void); +void LFClientRemoveErrorHandler(void); +void LFClientSendArgumentsAndGetCFReply(void); +void LFClientSendArgumentsAndGetReply(void); +void LFClientSetEndpoint(void); +void LFClientSetEventHandler(void); +void LFClientSetInstance(void); +void LFClientSetIsMachService(void); +void LFClientSetPrivileged(void); +void LFClientSetUserID(void); +void LFClientStart(void); +void LFClientStop(void); +void LFDBLoggingControllerStart(void); +void LFDBLoggingControllerStop(void); +void LFDictionaryCreateMutableWithObjectForKey(void); +void LFDictionaryGetBooleanForKey(void); +void LFDictionaryGetCFIndexForKey(void); +void LFDictionaryGetDictionaryForKey(void); +void LFDictionaryGetDoubleForKey(void); +void LFDictionarySetBoolean(void); +void LFDictionarySetCFIndex(void); +void LFDictionarySetDictionary(void); +void LFFunctionCacheAddFunction(void); +void LFFunctionCacheCreateServerFunction(void); +void LFFunctionCacheGetFunction(void); +void LFFunctionCreateClientFunction(void); +void LFFunctionCreateServerFunction(void); +void LFFunctionGetIdentifier(void); +void LFLogUnhandledEventType(void); +void LFSMCloseSession(void); +void LFSMCopyAllSessions(void); +void LFSMCopyCurrentSession(void); +void LFSMCopySessionProperties(void); +void LFSMCopySessionWithCGSessionID(void); +void LFSMCreateDefaultSessionOptions(void); +void LFSMCreateSessionWithOptions(void); +void LFSMCreateSessionWithOptionsByStartingServer(void); +void LFSMSessionGetTypeID(void); +void LFSMSwitchToSessionWithOptions(void); +void LFServerCreate(void); +void LFServerGetClientForConnection(void); +void LFServerGetConnection(void); +void LFServerGetEventHandler(void); +void LFServerGetServiceName(void); +void LFServerGetTypeID(void); +void LFServerSetIsMachService(void); +void LFServerStart(void); +void LFServerStop(void); +void LFStringCreateFromString(void); +void LogindServerCreate(void); +void LogindServerRelease(void); +void SACBeginLoginTransition(void); +void SACCopyOnceMiniBuddyItem(void); +void SACDeleteMiniBuddyItem(void); +void SACDisableFileVaultForCurrentUserWithPassword(void); +void SACEnableFileVaultForCurrentUserWithPassword(void); +void SACFaceTimeCallRingStart(void); +void SACFaceTimeCallRingStop(void); +void SACLOFinishDelayedLogout(void); +void SACLORegisterLogoutStatusCallbacks(void); +void SACLOStartLogout(void); +void SACLOStartLogoutWithOptions(void); +void SACLegacyFileVaultCloseProgressWindow(void); +void SACLegacyFileVaultSetBarPercentage(void); +void SACLegacyFileVaultSetPhase(void); +void SACLegacyFileVaultSetTask(void); +void SACLegacyFileVaultShowErrorMessage(void); +void SACLegacyFileVaultShowProgressWindow(void); +void SACLegacyFileVaultUpdateTimeRemaining(void); +void SACLegacyFileVaultUpdateUI(void); +void SACLockScreenImmediate(void); +void SACLogoutComplete(void); +void SACMessageFaceTimeCancelCall(void); +void SACMessageFaceTimeMuteCall(void); +void SACMessageLogoutStatusClientLogoutFailed(void); +void SACMessageLogoutStatusClientLogoutSuccess(void); +void SACMessageMiniBuddyUIShowing(void); +void SACMiniBuddyCopyUpgradeDictionary(void); +void SACMiniBuddySignalCompleted(void); +void SACMiniBuddySignalFinishedStage1WithOptions(void); +void SACProximityPreferencesChanged(void); +void SACRestartForUser(void); +void SACSaveSetupUserScreenShots(void); +void SACScreenLockEnabled(void); +void SACScreenLockPreferencesChanged(void); +void SACScreenSaverCanRun(void); +void SACScreenSaverDidFadeInBackground(void); +void SACScreenSaverIsRunning(void); +void SACScreenSaverIsRunningInBackground(void); +void SACScreenSaverStartNow(void); +void SACScreenSaverStopNow(void); +void SACScreenSaverStopNowWithOptions(void); +void SACScreenSaverTimeRemaining(void); +void SACSetAppleIDVerified(void); +void SACSetAutoLoginPassword(void); +void SACSetFileVaultPassword(void); +void SACSetFinalSnapshot(void); +void SACSetMiniBuddyItem(void); +void SACSetPhoneProximity(void); +void SACSetScreenSaverCanRun(void); +void SACShieldWindowShowing(void); +void SACStartProgressIndicator(void); +void SACStartSessionForLoginWindow(void); +void SACStartSessionForUser(void); +void SACStopProgressIndicator(void); +void SACStopSessionForLoginWindow(void); +void SACSwitchToLoginWindow(void); +void SACSwitchToUser(void); +void SACUpdateAppleIDUserLogin(void); +void SACWriteKeyboardType(void); +void SAClearLWScreenShots(void); +void SAClearLaunchSoftwareUpdateTrigger(void); +void SAClearSoftwareUpdateOptions(void); +void SAPrepareForSetupUserScreenShots(void); +void SAResetLoginKeychainForAutoLoginPassword(void); +void SASSessionStateForUser(void); +void SASetAppleIDVerified(void); +void SASetAutoLoginUserScreenLocked(void); +void SASetAutologinPW(void); +void SASetLaunchSoftwareUpdateTrigger(void); +void SASetPreviousStartupWasPanic(void); +void SASetSCDynamicStoreConsoleInformation(void); +void SASetSessionAuthenticatedFlag(void); +void SASetSessionHasConsoleAccessFlag(void); +void SASetSessionState(void); +void SASetSoftwareUpdateOption(void); +void SASetSwapCompaction(void); +void SASetTextEncodingBias(void); +void SASync(void); +void SASystemNotifyPost(void); +void SAWriteKeyboardType(void); +void SLOAddErrorHandler(void); +void SLOLegacyFileVaultSetState(void); +void SLOStartLogoutOfType(void); +void SMCopySessionUserInfo(void); +void SMGetSessionAgentConnection(void); +void SMRegisterSessionAgent(void); +void SMSetSessionUserInfo(void); +void SOStartSessionWithOptions(void); +void SessionAgentServerCreate(void); +void SessionAgentServerGetServer(void); +void SessionAgentServerRelease(void); +void SessionLogoutServerCreate(void); +void SessionLogoutServerRelease(void); +void SessionOwnerServerCreate(void); +void SessionOwnerServerRelease(void); +void _LFArgumentsCopyDebugDesc(void); +void _LFArgumentsCopyFormattingDesc(void); +void _LFArgumentsFinalize(void); +void _LFArgumentsInit(void); +void _LFFunctionCopyDebugDesc(void); +void _LFFunctionCopyFormattingDesc(void); +void _LFFunctionCreateServerFunction(void); +void _LFFunctionEqual(void); +void _LFFunctionFinalize(void); +void _LFFunctionHash(void); +void _LFFunctionInit(void); +void _LFGetBreadcrumbEncryptedKeyWithBlock(void); +void _LFServerCopyDebugDesc(void); +void _LFServerCopyFormattingDesc(void); +void _LFServerEqual(void); +void _LFServerFinalize(void); +void _LFServerHash(void); +void _LFSetBreadcrumbEncryptedKeyWithBlock(void); +void logindServerGetServer(void); -- 2.51.2 From 5ad660ca6b9f3d9489de2ed053df9e4c5e58c949 Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Sat, 8 Apr 2017 23:44:04 +0200 Subject: [PATCH 17/17] Initial BSD syscall tracing (resolves #282) --- src/kernel/emulation/linux/syscalls-table.S | 30 +- src/kernel/emulation/linux/unistd/write.c | 7 + src/xtrace/CMakeLists.txt | 1 + src/xtrace/bsd_trace.cpp | 573 ++++++++++++++++++++ src/xtrace/simple.c | 6 +- src/xtrace/trampoline.S | 13 + src/xtrace/xtracelib.c | 51 +- 7 files changed, 665 insertions(+), 16 deletions(-) create mode 100644 src/xtrace/bsd_trace.cpp diff --git a/src/kernel/emulation/linux/syscalls-table.S b/src/kernel/emulation/linux/syscalls-table.S index d598b4a97..797f88deb 100644 --- a/src/kernel/emulation/linux/syscalls-table.S +++ b/src/kernel/emulation/linux/syscalls-table.S @@ -5,6 +5,8 @@ #if defined(__x86_64__) __darling_bsd_syscall: +Lentry_hook: + .space 13, 0x90 movq ___bsd_syscall_table@GOTPCREL(%rip), %r10 movq (%r10,%rax,8), %r10 test %r10, %r10 @@ -16,11 +18,22 @@ __darling_bsd_syscall: pushq %r11 call *%r10 addq $16, %rsp +.std_ret: +Lexit_hook: + .space 13, 0x90 ret .no_sys: movq %rax, %rdi call ___unknown_syscall - ret + jmp .std_ret + +.section __DATA,__data +.globl __darling_bsd_syscall_entry +.globl __darling_bsd_syscall_exit +__darling_bsd_syscall_entry: + .quad Lentry_hook +__darling_bsd_syscall_exit: + .quad Lexit_hook #elif defined(__i386__) @@ -29,6 +42,8 @@ __darling_bsd_syscall: movl %ecx, -24+off(%esp) __darling_bsd_syscall: +Lentry_hook: + .space 6, 0x90 calll 1f 1: popl %ecx @@ -48,18 +63,29 @@ __darling_bsd_syscall: subl $24, %esp call *%eax addl $24, %esp +.std_ret: +Lexit_hook: + .space 6, 0x90 ret .no_sys: pushl %ecx call ___unknown_syscall addl $4, %esp - ret + jmp .std_ret .section __IMPORT,__pointers,non_lazy_symbol_pointers L___bsd_syscall_table$non_lazy_ptr: .indirect_symbol ___bsd_syscall_table .long 0 +.section __DATA,__data +.globl __darling_bsd_syscall_entry +.globl __darling_bsd_syscall_exit +__darling_bsd_syscall_entry: + .long Lentry_hook +__darling_bsd_syscall_exit: + .long Lexit_hook + .subsections_via_symbols #else diff --git a/src/kernel/emulation/linux/unistd/write.c b/src/kernel/emulation/linux/unistd/write.c index f7502b0c5..3c462a5ca 100644 --- a/src/kernel/emulation/linux/unistd/write.c +++ b/src/kernel/emulation/linux/unistd/write.c @@ -8,6 +8,13 @@ long sys_write(int fd, const void* mem, int len) return sys_write_nocancel(fd, mem, len); } +__attribute__((visibility("default"))) +long __write_for_xtrace(int fd, const void* mem, int len) +{ + return sys_write_nocancel(fd, mem, len); +} + + long sys_write_nocancel(int fd, const void* mem, int len) { int ret; diff --git a/src/xtrace/CMakeLists.txt b/src/xtrace/CMakeLists.txt index b85eae97a..9d07b89e3 100644 --- a/src/xtrace/CMakeLists.txt +++ b/src/xtrace/CMakeLists.txt @@ -10,6 +10,7 @@ set(xtrace_sources simple.c trampoline.S mach_trace.cpp + bsd_trace.cpp ) set(DYLIB_INSTALL_NAME "/usr/lib/darling/libxtrace.dylib") diff --git a/src/xtrace/bsd_trace.cpp b/src/xtrace/bsd_trace.cpp new file mode 100644 index 000000000..ec09f0146 --- /dev/null +++ b/src/xtrace/bsd_trace.cpp @@ -0,0 +1,573 @@ +#include "simple.h" +#include +#include +#include "xtracelib.h" + +_Thread_local int bsd_call_nr = -1; + +static void print_errno(char* buf, uintptr_t rv); +static void print_errno_num(char* buf, uintptr_t rv); +static void print_errno_ptr(char* buf, uintptr_t rv); + +// awk '/^[0-9]/ { if ($6 !~ "nosys") { split($6, a, "("); print "[" $1 "] = { \"" a[1] "\", NULL, print_errno }," } }' + +static const struct calldef bsd_defs[600] = { + [1] = { "exit", NULL, print_errno_num }, + [2] = { "fork", NULL, print_errno_num }, + [3] = { "read", NULL, print_errno_num }, + [4] = { "write", NULL, print_errno_num }, + [5] = { "open", NULL, print_errno_num }, + [6] = { "close", NULL, print_errno_num }, + [7] = { "wait4", NULL, print_errno_num }, + [9] = { "link", NULL, print_errno_num }, + [10] = { "unlink", NULL, print_errno_num }, + [12] = { "chdir", NULL, print_errno_num }, + [13] = { "fchdir", NULL, print_errno_num }, + [14] = { "mknod", NULL, print_errno_num }, + [15] = { "chmod", NULL, print_errno_num }, + [16] = { "chown", NULL, print_errno_num }, + [18] = { "getfsstat", NULL, print_errno_num }, + [20] = { "getpid", NULL, print_errno_num }, + [23] = { "setuid", NULL, print_errno_num }, + [24] = { "getuid", NULL, print_errno_num }, + [25] = { "geteuid", NULL, print_errno_num }, + [26] = { "ptrace", NULL, print_errno_num }, + [27] = { "recvmsg", NULL, print_errno_num }, + [28] = { "sendmsg", NULL, print_errno_num }, + [29] = { "recvfrom", NULL, print_errno_num }, + [30] = { "accept", NULL, print_errno_num }, + [31] = { "getpeername", NULL, print_errno_num }, + [32] = { "getsockname", NULL, print_errno_num }, + [33] = { "access", NULL, print_errno_num }, + [34] = { "chflags", NULL, print_errno_num }, + [35] = { "fchflags", NULL, print_errno_num }, + [36] = { "sync", NULL, print_errno_num }, + [37] = { "kill", NULL, print_errno_num }, + [39] = { "getppid", NULL, print_errno_num }, + [41] = { "dup", NULL, print_errno_num }, + [42] = { "pipe", NULL, print_errno_num }, + [43] = { "getegid", NULL, print_errno_num }, + [46] = { "sigaction", NULL, print_errno_num }, + [47] = { "getgid", NULL, print_errno_num }, + [48] = { "sigprocmask", NULL, print_errno_num }, + [49] = { "getlogin", NULL, print_errno_num }, + [50] = { "setlogin", NULL, print_errno_num }, + [51] = { "acct", NULL, print_errno_num }, + [52] = { "sigpending", NULL, print_errno_num }, + [53] = { "sigaltstack", NULL, print_errno_num }, + [54] = { "ioctl", NULL, print_errno_num }, + [55] = { "reboot", NULL, print_errno_num }, + [56] = { "revoke", NULL, print_errno_num }, + [57] = { "symlink", NULL, print_errno_num }, + [58] = { "readlink", NULL, print_errno_num }, + [59] = { "execve", NULL, print_errno_num }, + [60] = { "umask", NULL, print_errno_num }, + [61] = { "chroot", NULL, print_errno_num }, + [65] = { "msync", NULL, print_errno_num }, + [66] = { "vfork", NULL, print_errno_num }, + [73] = { "munmap", NULL, print_errno_num }, + [74] = { "mprotect", NULL, print_errno_num }, + [75] = { "madvise", NULL, print_errno_num }, + [78] = { "mincore", NULL, print_errno_num }, + [79] = { "getgroups", NULL, print_errno_num }, + [80] = { "setgroups", NULL, print_errno_num }, + [81] = { "getpgrp", NULL, print_errno_num }, + [82] = { "setpgid", NULL, print_errno_num }, + [83] = { "setitimer", NULL, print_errno_num }, + [85] = { "swapon", NULL, print_errno_num }, + [86] = { "getitimer", NULL, print_errno_num }, + [89] = { "getdtablesize", NULL, print_errno_num }, + [90] = { "dup2", NULL, print_errno_num }, + [92] = { "fcntl", NULL, print_errno_num }, + [93] = { "select", NULL, print_errno_num }, + [95] = { "fsync", NULL, print_errno_num }, + [96] = { "setpriority", NULL, print_errno_num }, + [97] = { "socket", NULL, print_errno_num }, + [98] = { "connect", NULL, print_errno_num }, + [100] = { "getpriority", NULL, print_errno_num }, + [104] = { "bind", NULL, print_errno_num }, + [105] = { "setsockopt", NULL, print_errno_num }, + [106] = { "listen", NULL, print_errno_num }, + [111] = { "sigsuspend", NULL, print_errno_num }, + [116] = { "gettimeofday", NULL, print_errno_num }, + [117] = { "getrusage", NULL, print_errno_num }, + [118] = { "getsockopt", NULL, print_errno_num }, + [120] = { "readv", NULL, print_errno_num }, + [121] = { "writev", NULL, print_errno_num }, + [122] = { "settimeofday", NULL, print_errno_num }, + [123] = { "fchown", NULL, print_errno_num }, + [124] = { "fchmod", NULL, print_errno_num }, + [126] = { "setreuid", NULL, print_errno_num }, + [127] = { "setregid", NULL, print_errno_num }, + [128] = { "rename", NULL, print_errno_num }, + [131] = { "flock", NULL, print_errno_num }, + [132] = { "mkfifo", NULL, print_errno_num }, + [133] = { "sendto", NULL, print_errno_num }, + [134] = { "shutdown", NULL, print_errno_num }, + [135] = { "socketpair", NULL, print_errno_num }, + [136] = { "mkdir", NULL, print_errno_num }, + [137] = { "rmdir", NULL, print_errno_num }, + [138] = { "utimes", NULL, print_errno_num }, + [139] = { "futimes", NULL, print_errno_num }, + [140] = { "adjtime", NULL, print_errno_num }, + [142] = { "gethostuuid", NULL, print_errno_num }, + [147] = { "setsid", NULL, print_errno_num }, + [151] = { "getpgid", NULL, print_errno_num }, + [152] = { "setprivexec", NULL, print_errno_num }, + [153] = { "pread", NULL, print_errno_num }, + [154] = { "pwrite", NULL, print_errno_num }, + [155] = { "nfssvc", NULL, print_errno_num }, + [157] = { "statfs", NULL, print_errno_num }, + [158] = { "fstatfs", NULL, print_errno_num }, + [159] = { "unmount", NULL, print_errno_num }, + [161] = { "getfh", NULL, print_errno_num }, + [165] = { "quotactl", NULL, print_errno_num }, + [167] = { "mount", NULL, print_errno_num }, + [169] = { "csops", NULL, print_errno_num }, + [170] = { "csops_audittoken", NULL, print_errno_num }, + [173] = { "waitid", NULL, print_errno_num }, + [177] = { "kdebug_typefilter", NULL, print_errno_num }, + [178] = { "kdebug_trace_string", NULL, print_errno_num }, + [179] = { "kdebug_trace64", NULL, print_errno_num }, + [180] = { "kdebug_trace", NULL, print_errno_num }, + [181] = { "setgid", NULL, print_errno_num }, + [182] = { "setegid", NULL, print_errno_num }, + [183] = { "seteuid", NULL, print_errno_num }, + [184] = { "sigreturn", NULL, print_errno_num }, + [187] = { "fdatasync", NULL, print_errno_num }, + [188] = { "stat", NULL, print_errno_num }, + [189] = { "fstat", NULL, print_errno_num }, + [190] = { "lstat", NULL, print_errno_num }, + [191] = { "pathconf", NULL, print_errno_num }, + [192] = { "fpathconf", NULL, print_errno_num }, + [194] = { "getrlimit", NULL, print_errno_num }, + [195] = { "setrlimit", NULL, print_errno_num }, + [196] = { "getdirentries", NULL, print_errno_num }, + [197] = { "mmap", NULL, print_errno_ptr }, + [199] = { "lseek", NULL, print_errno_num }, + [200] = { "truncate", NULL, print_errno_num }, + [201] = { "ftruncate", NULL, print_errno_num }, + [202] = { "sysctl", NULL, print_errno_num }, + [203] = { "mlock", NULL, print_errno_num }, + [204] = { "munlock", NULL, print_errno_num }, + [205] = { "undelete", NULL, print_errno_num }, + [216] = { "open_dprotected_np", NULL, print_errno_num }, + [220] = { "getattrlist", NULL, print_errno_num }, + [221] = { "setattrlist", NULL, print_errno_num }, + [222] = { "getdirentriesattr", NULL, print_errno_num }, + [223] = { "exchangedata", NULL, print_errno_num }, + [225] = { "searchfs", NULL, print_errno_num }, + [226] = { "delete", NULL, print_errno_num }, + [227] = { "copyfile", NULL, print_errno_num }, + [228] = { "fgetattrlist", NULL, print_errno_num }, + [229] = { "fsetattrlist", NULL, print_errno_num }, + [230] = { "poll", NULL, print_errno_num }, + [231] = { "watchevent", NULL, print_errno_num }, + [232] = { "waitevent", NULL, print_errno_num }, + [233] = { "modwatch", NULL, print_errno_num }, + [234] = { "getxattr", NULL, print_errno_num }, + [235] = { "fgetxattr", NULL, print_errno_num }, + [236] = { "setxattr", NULL, print_errno_num }, + [237] = { "fsetxattr", NULL, print_errno_num }, + [238] = { "removexattr", NULL, print_errno_num }, + [239] = { "fremovexattr", NULL, print_errno_num }, + [240] = { "listxattr", NULL, print_errno_num }, + [241] = { "flistxattr", NULL, print_errno_num }, + [242] = { "fsctl", NULL, print_errno_num }, + [243] = { "initgroups", NULL, print_errno_num }, + [244] = { "posix_spawn", NULL, print_errno_num }, + [245] = { "ffsctl", NULL, print_errno_num }, + [247] = { "nfsclnt", NULL, print_errno_num }, + [248] = { "fhopen", NULL, print_errno_num }, + [250] = { "minherit", NULL, print_errno_num }, + [251] = { "semsys", NULL, print_errno_num }, + [252] = { "msgsys", NULL, print_errno_num }, + [253] = { "shmsys", NULL, print_errno_num }, + [254] = { "semctl", NULL, print_errno_num }, + [255] = { "semget", NULL, print_errno_num }, + [256] = { "semop", NULL, print_errno_num }, + [258] = { "msgctl", NULL, print_errno_num }, + [259] = { "msgget", NULL, print_errno_num }, + [260] = { "msgsnd", NULL, print_errno_num }, + [261] = { "msgrcv", NULL, print_errno_num }, + [262] = { "shmat", NULL, print_errno_num }, + [263] = { "shmctl", NULL, print_errno_num }, + [264] = { "shmdt", NULL, print_errno_num }, + [265] = { "shmget", NULL, print_errno_num }, + [266] = { "shm_open", NULL, print_errno_num }, + [267] = { "shm_unlink", NULL, print_errno_num }, + [268] = { "sem_open", NULL, print_errno_num }, + [269] = { "sem_close", NULL, print_errno_num }, + [270] = { "sem_unlink", NULL, print_errno_num }, + [271] = { "sem_wait", NULL, print_errno_num }, + [272] = { "sem_trywait", NULL, print_errno_num }, + [273] = { "sem_post", NULL, print_errno_num }, + [274] = { "sysctlbyname", NULL, print_errno_num }, + [277] = { "open_extended", NULL, print_errno_num }, + [278] = { "umask_extended", NULL, print_errno_num }, + [279] = { "stat_extended", NULL, print_errno_num }, + [280] = { "lstat_extended", NULL, print_errno_num }, + [281] = { "fstat_extended", NULL, print_errno_num }, + [282] = { "chmod_extended", NULL, print_errno_num }, + [283] = { "fchmod_extended", NULL, print_errno_num }, + [284] = { "access_extended", NULL, print_errno_num }, + [285] = { "settid", NULL, print_errno_num }, + [286] = { "gettid", NULL, print_errno_num }, + [287] = { "setsgroups", NULL, print_errno_num }, + [288] = { "getsgroups", NULL, print_errno_num }, + [289] = { "setwgroups", NULL, print_errno_num }, + [290] = { "getwgroups", NULL, print_errno_num }, + [291] = { "mkfifo_extended", NULL, print_errno_num }, + [292] = { "mkdir_extended", NULL, print_errno_num }, + [293] = { "identitysvc", NULL, print_errno_num }, + [294] = { "shared_region_check_np", NULL, print_errno_num }, + [296] = { "vm_pressure_monitor", NULL, print_errno_num }, + [297] = { "psynch_rw_longrdlock", NULL, print_errno_num }, + [298] = { "psynch_rw_yieldwrlock", NULL, print_errno_num }, + [299] = { "psynch_rw_downgrade", NULL, print_errno_num }, + [300] = { "psynch_rw_upgrade", NULL, print_errno_num }, + [301] = { "psynch_mutexwait", NULL, print_errno_num }, + [302] = { "psynch_mutexdrop", NULL, print_errno_num }, + [303] = { "psynch_cvbroad", NULL, print_errno_num }, + [304] = { "psynch_cvsignal", NULL, print_errno_num }, + [305] = { "psynch_cvwait", NULL, print_errno_num }, + [306] = { "psynch_rw_rdlock", NULL, print_errno_num }, + [307] = { "psynch_rw_wrlock", NULL, print_errno_num }, + [308] = { "psynch_rw_unlock", NULL, print_errno_num }, + [309] = { "psynch_rw_unlock2", NULL, print_errno_num }, + [310] = { "getsid", NULL, print_errno_num }, + [311] = { "settid_with_pid", NULL, print_errno_num }, + [312] = { "psynch_cvclrprepost", NULL, print_errno_num }, + [313] = { "aio_fsync", NULL, print_errno_num }, + [314] = { "aio_return", NULL, print_errno_num }, + [315] = { "aio_suspend", NULL, print_errno_num }, + [316] = { "aio_cancel", NULL, print_errno_num }, + [317] = { "aio_error", NULL, print_errno_num }, + [318] = { "aio_read", NULL, print_errno_num }, + [319] = { "aio_write", NULL, print_errno_num }, + [320] = { "lio_listio", NULL, print_errno_num }, + [322] = { "iopolicysys", NULL, print_errno_num }, + [323] = { "process_policy", NULL, print_errno_num }, + [324] = { "mlockall", NULL, print_errno_num }, + [325] = { "munlockall", NULL, print_errno_num }, + [327] = { "issetugid", NULL, print_errno_num }, + [328] = { "__pthread_kill", NULL, print_errno_num }, + [329] = { "__pthread_sigmask", NULL, print_errno_num }, + [330] = { "__sigwait", NULL, print_errno_num }, + [331] = { "__disable_threadsignal", NULL, print_errno_num }, + [332] = { "__pthread_markcancel", NULL, print_errno_num }, + [333] = { "__pthread_canceled", NULL, print_errno_num }, + [334] = { "__semwait_signal", NULL, print_errno_num }, + [336] = { "proc_info", NULL, print_errno_num }, + [337] = { "sendfile", NULL, print_errno_num }, + [338] = { "stat64", NULL, print_errno_num }, + [339] = { "fstat64", NULL, print_errno_num }, + [340] = { "lstat64", NULL, print_errno_num }, + [341] = { "stat64_extended", NULL, print_errno_num }, + [342] = { "lstat64_extended", NULL, print_errno_num }, + [343] = { "fstat64_extended", NULL, print_errno_num }, + [344] = { "getdirentries64", NULL, print_errno_num }, + [345] = { "statfs64", NULL, print_errno_num }, + [346] = { "fstatfs64", NULL, print_errno_num }, + [347] = { "getfsstat64", NULL, print_errno_num }, + [348] = { "__pthread_chdir", NULL, print_errno_num }, + [349] = { "__pthread_fchdir", NULL, print_errno_num }, + [350] = { "audit", NULL, print_errno_num }, + [351] = { "auditon", NULL, print_errno_num }, + [353] = { "getauid", NULL, print_errno_num }, + [354] = { "setauid", NULL, print_errno_num }, + [357] = { "getaudit_addr", NULL, print_errno_num }, + [358] = { "setaudit_addr", NULL, print_errno_num }, + [359] = { "auditctl", NULL, print_errno_num }, + [360] = { "bsdthread_create", NULL, print_errno_num }, + [361] = { "bsdthread_terminate", NULL, print_errno_num }, + [362] = { "kqueue", NULL, print_errno_num }, + [363] = { "kevent", NULL, print_errno_num }, + [364] = { "lchown", NULL, print_errno_num }, + [366] = { "bsdthread_register", NULL, print_errno_num }, + [367] = { "workq_open", NULL, print_errno_num }, + [368] = { "workq_kernreturn", NULL, print_errno_num }, + [369] = { "kevent64", NULL, print_errno_num }, + [370] = { "__old_semwait_signal", NULL, print_errno_num }, + [371] = { "__old_semwait_signal_nocancel", NULL, print_errno_num }, + [372] = { "thread_selfid", NULL, print_errno_num }, + [373] = { "ledger", NULL, print_errno_num }, + [374] = { "kevent_qos", NULL, print_errno_num }, + [380] = { "__mac_execve", NULL, print_errno_num }, + [381] = { "__mac_syscall", NULL, print_errno_num }, + [382] = { "__mac_get_file", NULL, print_errno_num }, + [383] = { "__mac_set_file", NULL, print_errno_num }, + [384] = { "__mac_get_link", NULL, print_errno_num }, + [385] = { "__mac_set_link", NULL, print_errno_num }, + [386] = { "__mac_get_proc", NULL, print_errno_num }, + [387] = { "__mac_set_proc", NULL, print_errno_num }, + [388] = { "__mac_get_fd", NULL, print_errno_num }, + [389] = { "__mac_set_fd", NULL, print_errno_num }, + [390] = { "__mac_get_pid", NULL, print_errno_num }, + [394] = { "pselect", NULL, print_errno_num }, + [395] = { "pselect_nocancel", NULL, print_errno_num }, + [396] = { "read_nocancel", NULL, print_errno_num }, + [397] = { "write_nocancel", NULL, print_errno_num }, + [398] = { "open_nocancel", NULL, print_errno_num }, + [399] = { "close_nocancel", NULL, print_errno_num }, + [400] = { "wait4_nocancel", NULL, print_errno_num }, + [401] = { "recvmsg_nocancel", NULL, print_errno_num }, + [402] = { "sendmsg_nocancel", NULL, print_errno_num }, + [403] = { "recvfrom_nocancel", NULL, print_errno_num }, + [404] = { "accept_nocancel", NULL, print_errno_num }, + [405] = { "msync_nocancel", NULL, print_errno_num }, + [406] = { "fcntl_nocancel", NULL, print_errno_num }, + [407] = { "select_nocancel", NULL, print_errno_num }, + [408] = { "fsync_nocancel", NULL, print_errno_num }, + [409] = { "connect_nocancel", NULL, print_errno_num }, + [410] = { "sigsuspend_nocancel", NULL, print_errno_num }, + [411] = { "readv_nocancel", NULL, print_errno_num }, + [412] = { "writev_nocancel", NULL, print_errno_num }, + [413] = { "sendto_nocancel", NULL, print_errno_num }, + [414] = { "pread_nocancel", NULL, print_errno_num }, + [415] = { "pwrite_nocancel", NULL, print_errno_num }, + [416] = { "waitid_nocancel", NULL, print_errno_num }, + [417] = { "poll_nocancel", NULL, print_errno_num }, + [418] = { "msgsnd_nocancel", NULL, print_errno_num }, + [419] = { "msgrcv_nocancel", NULL, print_errno_num }, + [420] = { "sem_wait_nocancel", NULL, print_errno_num }, + [421] = { "aio_suspend_nocancel", NULL, print_errno_num }, + [422] = { "__sigwait_nocancel", NULL, print_errno_num }, + [423] = { "__semwait_signal_nocancel", NULL, print_errno_num }, + [424] = { "__mac_mount", NULL, print_errno_num }, + [425] = { "__mac_get_mount", NULL, print_errno_num }, + [426] = { "__mac_getfsstat", NULL, print_errno_num }, + [427] = { "fsgetpath", NULL, print_errno_num }, + [428] = { "audit_session_self", NULL, print_errno_num }, + [429] = { "audit_session_join", NULL, print_errno_num }, + [430] = { "fileport_makeport", NULL, print_errno_num }, + [431] = { "fileport_makefd", NULL, print_errno_num }, + [432] = { "audit_session_port", NULL, print_errno_num }, + [433] = { "pid_suspend", NULL, print_errno_num }, + [434] = { "pid_resume", NULL, print_errno_num }, + [438] = { "shared_region_map_and_slide_np", NULL, print_errno_num }, + [439] = { "kas_info", NULL, print_errno_num }, + [440] = { "memorystatus_control", NULL, print_errno_num }, + [441] = { "guarded_open_np", NULL, print_errno_num }, + [442] = { "guarded_close_np", NULL, print_errno_num }, + [443] = { "guarded_kqueue_np", NULL, print_errno_num }, + [444] = { "change_fdguard_np", NULL, print_errno_num }, + [445] = { "usrctl", NULL, print_errno_num }, + [446] = { "proc_rlimit_control", NULL, print_errno_num }, + [447] = { "connectx", NULL, print_errno_num }, + [448] = { "disconnectx", NULL, print_errno_num }, + [449] = { "peeloff", NULL, print_errno_num }, + [450] = { "socket_delegate", NULL, print_errno_num }, + [451] = { "telemetry", NULL, print_errno_num }, + [452] = { "proc_uuid_policy", NULL, print_errno_num }, + [453] = { "memorystatus_get_level", NULL, print_errno_num }, + [454] = { "system_override", NULL, print_errno_num }, + [455] = { "vfs_purge", NULL, print_errno_num }, + [456] = { "sfi_ctl", NULL, print_errno_num }, + [457] = { "sfi_pidctl", NULL, print_errno_num }, + [458] = { "coalition", NULL, print_errno_num }, + [459] = { "coalition_info", NULL, print_errno_num }, + [460] = { "necp_match_policy", NULL, print_errno_num }, + [461] = { "getattrlistbulk", NULL, print_errno_num }, + [462] = { "clonefileat", NULL, print_errno_num }, + [463] = { "openat", NULL, print_errno_num }, + [464] = { "openat_nocancel", NULL, print_errno_num }, + [465] = { "renameat", NULL, print_errno_num }, + [466] = { "faccessat", NULL, print_errno_num }, + [467] = { "fchmodat", NULL, print_errno_num }, + [468] = { "fchownat", NULL, print_errno_num }, + [469] = { "fstatat", NULL, print_errno_num }, + [470] = { "fstatat64", NULL, print_errno_num }, + [471] = { "linkat", NULL, print_errno_num }, + [472] = { "unlinkat", NULL, print_errno_num }, + [473] = { "readlinkat", NULL, print_errno_num }, + [474] = { "symlinkat", NULL, print_errno_num }, + [475] = { "mkdirat", NULL, print_errno_num }, + [476] = { "getattrlistat", NULL, print_errno_num }, + [477] = { "proc_trace_log", NULL, print_errno_num }, + [478] = { "bsdthread_ctl", NULL, print_errno_num }, + [479] = { "openbyid_np", NULL, print_errno_num }, + [480] = { "recvmsg_x", NULL, print_errno_num }, + [481] = { "sendmsg_x", NULL, print_errno_num }, + [482] = { "thread_selfusage", NULL, print_errno_num }, + [483] = { "csrctl", NULL, print_errno_num }, + [484] = { "guarded_open_dprotected_np", NULL, print_errno_num }, + [485] = { "guarded_write_np", NULL, print_errno_num }, + [486] = { "guarded_pwrite_np", NULL, print_errno_num }, + [487] = { "guarded_writev_np", NULL, print_errno_num }, + [488] = { "renameatx_np", NULL, print_errno_num }, + [489] = { "mremap_encrypted", NULL, print_errno_num }, + [490] = { "netagent_trigger", NULL, print_errno_num }, + [491] = { "stack_snapshot_with_config", NULL, print_errno_num }, + [492] = { "microstackshot", NULL, print_errno_num }, + [493] = { "grab_pgo_data", NULL, print_errno_num }, + [494] = { "persona", NULL, print_errno_num }, + [499] = { "work_interval_ctl", NULL, print_errno_num }, + [500] = { "getentropy", NULL, print_errno_num }, + [501] = { "necp_open", NULL, print_errno_num }, + [502] = { "necp_client_action", NULL, print_errno_num }, + [515] = { "ulock_wait", NULL, print_errno_num }, + [516] = { "ulock_wake", NULL, print_errno_num }, + [517] = { "fclonefileat", NULL, print_errno_num }, + [518] = { "fs_snapshot", NULL, print_errno_num }, + [520] = { "terminate_with_payload", NULL, print_errno_num }, + [521] = { "abort_with_payload", NULL, print_errno_num }, +}; + +extern "C" +void darling_bsd_syscall_entry_print(int nr, void* args[]) +{ + bsd_call_nr = nr; + handle_generic_entry(bsd_defs, "bsd", bsd_call_nr, args); +} + +extern "C" +void darling_bsd_syscall_exit_print(uintptr_t retval) +{ + handle_generic_exit(bsd_defs, "bsd", bsd_call_nr, retval); + bsd_call_nr = -1; +} + +const char* error_strings[128] = { + [1] = "EPERM", + [2] = "ENOENT", + [3] = "ESRCH", + [4] = "EINTR", + [5] = "EIO", + [6] = "ENXIO", + [7] = "E2BIG", + [8] = "ENOEXEC", + [9] = "EBADF", + [10] = "ECHILD", + [11] = "EDEADLK", + [12] = "ENOMEM", + [13] = "EACCES", + [14] = "EFAULT", + [15] = "ENOTBLK", + [16] = "EBUSY", + [17] = "EEXIST", + [18] = "EXDEV", + [19] = "ENODEV", + [20] = "ENOTDIR", + [21] = "EISDIR", + [22] = "EINVAL", + [23] = "ENFILE", + [24] = "EMFILE", + [25] = "ENOTTY", + [26] = "ETXTBSY", + [27] = "EFBIG", + [28] = "ENOSPC", + [29] = "ESPIPE", + [30] = "EROFS", + [31] = "EMLINK", + [32] = "EPIPE", + [33] = "EDOM", + [34] = "ERANGE", + [35] = "EAGAIN", + [36] = "EINPROGRESS", + [37] = "EALREADY", + [38] = "ENOTSOCK", + [39] = "EDESTADDRREQ", + [40] = "EMSGSIZE", + [41] = "EPROTOTYPE", + [42] = "ENOPROTOOPT", + [43] = "EPROTONOSUPPORT", + [44] = "ESOCKTNOSUPPORT", + [45] = "ENOTSUP", + [46] = "EPFNOSUPPORT", + [47] = "EAFNOSUPPORT", + [48] = "EADDRINUSE", + [49] = "EADDRNOTAVAIL", + [50] = "ENETDOWN", + [51] = "ENETUNREACH", + [52] = "ENETRESET", + [53] = "ECONNABORTED", + [54] = "ECONNRESET", + [55] = "ENOBUFS", + [56] = "EISCONN", + [57] = "ENOTCONN", + [58] = "ESHUTDOWN", + [59] = "ETOOMANYREFS", + [60] = "ETIMEDOUT", + [61] = "ECONNREFUSED", + [62] = "ELOOP", + [63] = "ENAMETOOLONG", + [64] = "EHOSTDOWN", + [65] = "EHOSTUNREACH", + [66] = "ENOTEMPTY", + [67] = "EPROCLIM", + [68] = "EUSERS", + [69] = "EDQUOT", + [70] = "ESTALE", + [71] = "EREMOTE", + [72] = "EBADRPC", + [73] = "ERPCMISMATCH", + [74] = "EPROGUNAVAIL", + [75] = "EPROGMISMATCH", + [76] = "EPROCUNAVAIL", + [77] = "ENOLCK", + [78] = "ENOSYS", + [79] = "EFTYPE", + [80] = "EAUTH", + [81] = "ENEEDAUTH", + [82] = "EPWROFF", + [83] = "EDEVERR", + [84] = "EOVERFLOW", + [85] = "EBADEXEC", + [86] = "EBADARCH", + [87] = "ESHLIBVERS", + [88] = "EBADMACHO", + [89] = "ECANCELED", + [90] = "EIDRM", + [91] = "ENOMSG", + [92] = "EILSEQ", + [93] = "ENOATTR", + [94] = "EBADMSG", + [95] = "EMULTIHOP", + [96] = "ENODATA", + [97] = "ENOLINK", + [98] = "ENOSR", + [99] = "ENOSTR", + [100] = "EPROTO", + [101] = "ETIME", + [102] = "EOPNOTSUPP", + [103] = "ENOPOLICY", + [104] = "ENOTRECOVERABLE", + [105] = "EOWNERDEAD", + [106] = "EQFULL", +}; + +static void print_errno_num(char* buf, uintptr_t rv) +{ + intptr_t v = (intptr_t)rv; + if (v >= 0 || v < -4095) + { + __simple_sprintf(buf, "%d", rv); + } + else + print_errno(buf, rv); +} + +static void print_errno_ptr(char* buf, uintptr_t rv) +{ + intptr_t v = (intptr_t)rv; + if (v >= 0 || v < -4095) + { + __simple_sprintf(buf, "%p", rv); + } + else + print_errno(buf, rv); +} + +static void print_errno(char* buf, uintptr_t rv) +{ + const char* error = NULL; + intptr_t v = (intptr_t)rv; + if (-v < 128) + error = error_strings[-v]; + if (error != NULL) + __simple_sprintf(buf, "%s", error); + else + __simple_sprintf(buf, "%d", v); +} + diff --git a/src/xtrace/simple.c b/src/xtrace/simple.c index d7197ee2b..8bdb5fe66 100644 --- a/src/xtrace/simple.c +++ b/src/xtrace/simple.c @@ -1,11 +1,13 @@ #include "simple.h" #include #include -#include void __simple_vsprintf(char* buf, const char* format, va_list vl); extern char* memchr(char* buf, int c, __SIZE_TYPE__ n); +// We cannot call standard write(), because it would loop back to xtrace +extern int __write_for_xtrace(int fd, const void* mem, __SIZE_TYPE__ count); + int __simple_strlen(const char* text) { int len = 0; @@ -123,7 +125,7 @@ void __simple_printf(const char* format, ...) __simple_vsprintf(buffer, format, vl); va_end(vl); - write(2, buffer, __simple_strlen(buffer)); + __write_for_xtrace(2, buffer, __simple_strlen(buffer)); } void __simple_sprintf(char *buffer, const char* format, ...) diff --git a/src/xtrace/trampoline.S b/src/xtrace/trampoline.S index 34918c5cb..28db5069a 100644 --- a/src/xtrace/trampoline.S +++ b/src/xtrace/trampoline.S @@ -34,4 +34,17 @@ _darling_mach_syscall_exit_trampoline: trampoline_leave ret +.private_extern _darling_bsd_syscall_entry_trampoline +_darling_bsd_syscall_entry_trampoline: + trampoline_enter + call _darling_bsd_syscall_entry_print + trampoline_leave + ret + +.private_extern _darling_bsd_syscall_exit_trampoline +_darling_bsd_syscall_exit_trampoline: + trampoline_enter + call _darling_bsd_syscall_exit_print + trampoline_leave + ret diff --git a/src/xtrace/xtracelib.c b/src/xtrace/xtracelib.c index 5ebb61326..d2f718a23 100644 --- a/src/xtrace/xtracelib.c +++ b/src/xtrace/xtracelib.c @@ -9,6 +9,8 @@ // Defined in assembly extern void darling_mach_syscall_entry_trampoline(void); extern void darling_mach_syscall_exit_trampoline(void); +extern void darling_bsd_syscall_entry_trampoline(void); +extern void darling_bsd_syscall_exit_trampoline(void); extern int sys_thread_selfid(void); #ifdef __x86_64__ @@ -24,9 +26,31 @@ __attribute__((packed)); // Defined in libsystem_kernel extern struct hook* _darling_mach_syscall_entry; extern struct hook* _darling_mach_syscall_exit; +extern struct hook* _darling_bsd_syscall_entry; +extern struct hook* _darling_bsd_syscall_exit; + +static void xtrace_setup_mach(void); +static void xtrace_setup_bsd(void); +static void setup_hook(struct hook* hook, void* fnptr); __attribute__((constructor)) void xtrace_setup() +{ + xtrace_setup_mach(); + xtrace_setup_bsd(); +} + +static void setup_hook(struct hook* hook, void* fnptr) +{ + hook->movabs[0] = 0x49; + hook->movabs[1] = 0xbc; + hook->call[0] = 0x41; + hook->call[1] = 0xff; + hook->call[2] = 0xd4; + hook->addr = (uintptr_t)fnptr; +} + +static void xtrace_setup_mach(void) { uintptr_t area = (uintptr_t)_darling_mach_syscall_entry; @@ -35,20 +59,23 @@ void xtrace_setup() mprotect((void*) area, 4096, PROT_READ | PROT_WRITE | PROT_EXEC); - _darling_mach_syscall_entry->movabs[0] = 0x49; - _darling_mach_syscall_entry->movabs[1] = 0xbc; - _darling_mach_syscall_entry->call[0] = 0x41; - _darling_mach_syscall_entry->call[1] = 0xff; - _darling_mach_syscall_entry->call[2] = 0xd4; + setup_hook(_darling_mach_syscall_entry, darling_mach_syscall_entry_trampoline); + setup_hook(_darling_mach_syscall_exit, darling_mach_syscall_exit_trampoline); + + mprotect((void*) area, 4096, PROT_READ | PROT_EXEC); +} + +static void xtrace_setup_bsd(void) +{ + uintptr_t area = (uintptr_t)_darling_bsd_syscall_entry; - _darling_mach_syscall_exit->movabs[0] = 0x49; - _darling_mach_syscall_exit->movabs[1] = 0xbc; - _darling_mach_syscall_exit->call[0] = 0x41; - _darling_mach_syscall_exit->call[1] = 0xff; - _darling_mach_syscall_exit->call[2] = 0xd4; + // __asm__("int3"); + area &= ~(4096-1); + + mprotect((void*) area, 4096, PROT_READ | PROT_WRITE | PROT_EXEC); - _darling_mach_syscall_entry->addr = (uint64_t)darling_mach_syscall_entry_trampoline; - _darling_mach_syscall_exit->addr = (uint64_t)darling_mach_syscall_exit_trampoline; + setup_hook(_darling_bsd_syscall_entry, darling_bsd_syscall_entry_trampoline); + setup_hook(_darling_bsd_syscall_exit, darling_bsd_syscall_exit_trampoline); mprotect((void*) area, 4096, PROT_READ | PROT_EXEC); } -- 2.51.2