diff --git a/third_party/xnu/EXTERNAL_HEADERS/mach-o/loader.h b/third_party/xnu/EXTERNAL_HEADERS/mach-o/loader.h index 3b7f0ee3..72e8c39b 100644 --- a/third_party/xnu/EXTERNAL_HEADERS/mach-o/loader.h +++ b/third_party/xnu/EXTERNAL_HEADERS/mach-o/loader.h @@ -40,6 +40,13 @@ */ #include +/* + * is expected to define the flavors of the thread + * states and the structures of those flavors for each machine. +#include +#include + */ + /* * The 32-bit mach header appears at the very beginning of the object file for * 32-bit architectures. @@ -203,6 +210,22 @@ struct mach_header_64 { #define MH_APP_EXTENSION_SAFE 0x02000000 /* The code was linked for use in an application extension. */ +#define MH_NLIST_OUTOFSYNC_WITH_DYLDINFO 0x04000000 /* The external symbols + listed in the nlist symbol table do + not include all the symbols listed in + the dyld info. */ + +#define MH_SIM_SUPPORT 0x08000000 /* Allow LC_MIN_VERSION_MACOS and + LC_BUILD_VERSION load commands with + the platforms macOS, iOSMac, + iOSSimulator, tvOSSimulator and + watchOSSimulator. */ + +#define MH_DYLIB_IN_CACHE 0x80000000 /* Only for use on dylibs. When this bit + is set, the dylib is part of the dyld + shared cache, rather than loose in + the filesystem. */ + /* * The load commands directly follow the mach_header. The total size of all * of the commands is given by the sizeofcmds field in the mach_header. All @@ -297,6 +320,8 @@ struct load_command { #define LC_VERSION_MIN_WATCHOS 0x30 /* build for Watch min OS version */ #define LC_NOTE 0x31 /* arbitrary data included within a Mach-O file */ #define LC_BUILD_VERSION 0x32 /* build for platform min OS version */ +#define LC_DYLD_EXPORTS_TRIE (0x33 | LC_REQ_DYLD) /* used with linkedit_data_command, payload is trie */ +#define LC_DYLD_CHAINED_FIXUPS (0x34 | LC_REQ_DYLD) /* used with linkedit_data_command */ /* * A variable length string in a load command is represented by an lc_str @@ -374,6 +399,9 @@ struct segment_command_64 { /* for 64-bit architectures */ first page of the segment is not protected. All other pages of the segment are protected. */ +#define SG_READ_ONLY 0x10 /* This segment is made read-only after fixups */ + + /* * A segment is made up of zero or more sections. Non-MH_OBJECT files have @@ -499,6 +527,8 @@ struct section_64 { /* for 64-bit architectures */ #define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 /* functions to call to initialize TLV values */ +#define S_INIT_FUNC_OFFSETS 0x16 /* 32-bit offsets to + initializers */ /* * Constants for the section attributes part of the flags field of a section @@ -760,14 +790,14 @@ struct dylinker_command { * Thread commands contain machine-specific data structures suitable for * use in the thread state primitives. The machine specific data structures * follow the struct thread_command as follows. - * Each flavor of machine specific data structure is preceded by an unsigned - * long constant for the flavor of that data structure, an uint32_t - * that is the count of longs of the size of the state data structure and then + * Each flavor of machine specific data structure is preceded by an uint32_t + * constant for the flavor of that data structure, an uint32_t that is the + * count of uint32_t's of the size of the state data structure and then * the state data structure follows. This triple may be repeated for many * flavors. The constants for the flavors, counts and state data structure * definitions are expected to be in the header file . * These machine specific data structures sizes must be multiples of - * 4 bytes The cmdsize reflects the total size of the thread_command + * 4 bytes. The cmdsize reflects the total size of the thread_command * and all of the sizes of the constants for the flavors, counts and state * data structures. * @@ -781,7 +811,7 @@ struct thread_command { uint32_t cmd; /* LC_THREAD or LC_UNIXTHREAD */ uint32_t cmdsize; /* total size of this command */ /* uint32_t flavor flavor of thread state */ - /* uint32_t count count of longs in thread state */ + /* uint32_t count count of uint32_t's in thread state */ /* struct XXX_thread_state state thread state for this flavor */ /* ... */ }; @@ -1157,8 +1187,10 @@ struct rpath_command { struct linkedit_data_command { uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, - LC_DYLIB_CODE_SIGN_DRS or - LC_LINKER_OPTIMIZATION_HINT. */ + LC_DYLIB_CODE_SIGN_DRS, + LC_LINKER_OPTIMIZATION_HINT, + LC_DYLD_EXPORTS_TRIE, or + LC_DYLD_CHAINED_FIXUPS. */ uint32_t cmdsize; /* sizeof(struct linkedit_data_command) */ uint32_t dataoff; /* file offset of data in __LINKEDIT segment */ uint32_t datasize; /* file size of data in __LINKEDIT segment */ @@ -1231,6 +1263,12 @@ struct build_tool_version { #define PLATFORM_IOS 2 #define PLATFORM_TVOS 3 #define PLATFORM_WATCHOS 4 +#define PLATFORM_BRIDGEOS 5 +#define PLATFORM_IOSMAC 6 +#define PLATFORM_IOSSIMULATOR 7 +#define PLATFORM_TVOSSIMULATOR 8 +#define PLATFORM_WATCHOSSIMULATOR 9 +#define PLATFORM_DRIVERKIT 10 /* Known values for the tool field above. */ #define TOOL_CLANG 1 @@ -1378,6 +1416,7 @@ struct dyld_info_command { #define BIND_SPECIAL_DYLIB_SELF 0 #define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1 #define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2 +#define BIND_SPECIAL_DYLIB_WEAK_LOOKUP -3 #define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1 #define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8 @@ -1397,6 +1436,9 @@ struct dyld_info_command { #define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0 #define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0 #define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0 +#define BIND_OPCODE_THREADED 0xD0 +#define BIND_SUBOPCODE_THREADED_SET_BIND_ORDINAL_TABLE_SIZE_ULEB 0x00 +#define BIND_SUBOPCODE_THREADED_APPLY 0x01 /* @@ -1406,6 +1448,7 @@ struct dyld_info_command { #define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03 #define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00 #define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01 +#define EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE 0x02 #define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04 #define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08 #define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10 diff --git a/third_party/xnu/README.crashpad b/third_party/xnu/README.crashpad index 274faf16..55a67d5a 100644 --- a/third_party/xnu/README.crashpad +++ b/third_party/xnu/README.crashpad @@ -2,7 +2,7 @@ Name: XNU Short Name: xnu URL: https://opensource.apple.com/source/xnu/ URL: https://opensource.apple.com/tarballs/xnu/ -Version: 4903.221.2 (from macOS 10.14.1) +Version: 6153.11.26 (from macOS 10.15.0) License: APSL 2.0 License File: APPLE_LICENSE Security Critical: no @@ -11,9 +11,12 @@ Description: XNU is the operating system kernel used on macOS and other Apple systems. Local Modifications: - - Only EXTERNAL_HEADERS/mach-o/loader.h is included. Its #includes of + - EXTERNAL_HEADERS/mach-o/loader.h is present. Its #includes of and have been - removed as unnecessary. Note that its #includes of and + commented out as unnecessary. Note that its #includes of and have been retained but these headers have not been provided. External headers must be made available to provide the cpu_type_t, cpu_subtype_t, and vm_prot_t types. + - osfmk/mach/exc.defs is present, to fill in for on iOS, where + it is missing. + - Anything not listed above is omitted. diff --git a/third_party/xnu/osfmk/mach/exc.defs b/third_party/xnu/osfmk/mach/exc.defs new file mode 100644 index 00000000..734e7408 --- /dev/null +++ b/third_party/xnu/osfmk/mach/exc.defs @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * Abstract: + * MiG definitions file for Mach exception interface. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + +#if KERNEL_USER + KernelUser +#endif + exc 2401; + +#include +#include + +ServerPrefix catch_; + +type exception_data_t = array[*:2] of integer_t; +type exception_type_t = int; + +routine exception_raise( + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; + exception : exception_type_t; + code : exception_data_t +#if EXC_SERVER_SECTOKEN + ; + ServerSecToken stoken : security_token_t +#endif +#if EXC_SERVER_AUDITTOKEN + ; + ServerAuditToken atoken: audit_token_t +#endif + ); + +routine exception_raise_state( + exception_port : mach_port_t; + exception : exception_type_t; + code : exception_data_t, const; + inout flavor : int; + old_state : thread_state_t, const; + out new_state : thread_state_t +#if EXC_SERVER_SECTOKEN + ; + ServerSecToken stoken : security_token_t +#endif +#if EXC_SERVER_AUDITTOKEN + ; + ServerAuditToken atoken: audit_token_t +#endif + ); + +routine exception_raise_state_identity( + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; + exception : exception_type_t; + code : exception_data_t; + inout flavor : int; + old_state : thread_state_t; + out new_state : thread_state_t +#if EXC_SERVER_SECTOKEN + ; + ServerSecToken stoken : security_token_t +#endif +#if EXC_SERVER_AUDITTOKEN + ; + ServerAuditToken atoken: audit_token_t +#endif + ); + +/* vim: set ft=c : */ diff --git a/util/BUILD.gn b/util/BUILD.gn index fdd2fe14..56346c11 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -22,22 +22,28 @@ if (crashpad_is_in_chromium) { set_sources_assignment_filter([]) } -if (crashpad_is_mac) { - if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { - import("//build/config/sysroot.gni") - } else { - import("//third_party/mini_chromium/mini_chromium/build/sysroot.gni") +if (crashpad_is_mac || crashpad_is_ios) { + if (crashpad_is_mac) { + if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) { + import("//build/config/sysroot.gni") + } else { + import("//third_party/mini_chromium/mini_chromium/build/sysroot.gni") + } } action_foreach("mig") { script = "mach/mig.py" - sources = [ - "$sysroot/usr/include/mach/exc.defs", - "$sysroot/usr/include/mach/mach_exc.defs", - "$sysroot/usr/include/mach/notify.defs", - "mach/child_port.defs", - ] + if (crashpad_is_mac) { + sources = [ + "$sysroot/usr/include/mach/exc.defs", + "$sysroot/usr/include/mach/mach_exc.defs", + "$sysroot/usr/include/mach/notify.defs", + "mach/child_port.defs", + ] + } else if (crashpad_is_ios) { + sources = [ "../third_party/xnu/osfmk/mach/exc.defs" ] + } outputs = [ "$target_gen_dir/mach/{{source_name_part}}User.c", @@ -67,7 +73,7 @@ if (crashpad_is_mac) { ] } } - if (sysroot != "") { + if (!crashpad_is_ios && sysroot != "") { args += [ "--sdk", sysroot, @@ -510,6 +516,13 @@ static_library("util") { deps += [ "../third_party/mini_chromium:base" ] + if (crashpad_is_mac || crashpad_is_ios) { + include_dirs += [ "$root_build_dir/gen" ] + deps += [ + ":mig_output", + ] + } + if (crashpad_is_mac) { libs = [ "bsm", @@ -518,10 +531,8 @@ static_library("util") { "IOKit.framework", ] deps += [ - ":mig_output", "../third_party/apple_cf:apple_cf", ] - include_dirs += [ "$root_build_dir/gen" ] } if (crashpad_is_win) {