├── APPLE_LICENSE ├── CompatibilityHacks.c ├── Info.plist ├── Libsystem.xcconfig ├── Libsystem.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── alloc_once_private.h ├── enable_asan_mode ├── featureflags └── Libsystem.plist ├── init.c ├── optionallibs ├── optionallibs_driverkit ├── optionallibs_exclavekit ├── requiredlibs ├── requiredlibs_driverkit ├── requiredlibs_exclavekit └── xcodescripts ├── create_asan_override_file.sh ├── create_dylib_symlinks.sh ├── create_system_framework.sh └── linker_arguments.sh /APPLE_LICENSE: -------------------------------------------------------------------------------- 1 | APPLE PUBLIC SOURCE LICENSE 2 | Version 2.0 - August 6, 2003 3 | 4 | Please read this License carefully before downloading this software. By 5 | downloading or using this software, you are agreeing to be bound by the terms 6 | of this License. If you do not or cannot agree to the terms of this License, 7 | please do not download or use the software. 8 | 9 | Apple Note: In January 2007, Apple changed its corporate name from "Apple 10 | Computer, Inc." to "Apple Inc." This change has been reflected below and 11 | copyright years updated, but no other changes have been made to the APSL 2.0. 12 | 13 | 1. General; Definitions. This License applies to any program or other 14 | work which Apple Inc. ("Apple") makes publicly available and which contains a 15 | notice placed by Apple identifying such program or work as "Original Code" and 16 | stating that it is subject to the terms of this Apple Public Source License 17 | version 2.0 ("License"). As used in this License: 18 | 19 | 1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is the 20 | grantor of rights, (i) claims of patents that are now or hereafter acquired, 21 | owned by or assigned to Apple and (ii) that cover subject matter contained in 22 | the Original Code, but only to the extent necessary to use, reproduce and/or 23 | distribute the Original Code without infringement; and (b) in the case where 24 | You are the grantor of rights, (i) claims of patents that are now or hereafter 25 | acquired, owned by or assigned to You and (ii) that cover subject matter in 26 | Your Modifications, taken alone or in combination with Original Code. 27 | 28 | 1.2 "Contributor" means any person or entity that creates or contributes to 29 | the creation of Modifications. 30 | 31 | 1.3 "Covered Code" means the Original Code, Modifications, the combination 32 | of Original Code and any Modifications, and/or any respective portions thereof. 33 | 34 | 1.4 "Externally Deploy" means: (a) to sublicense, distribute or otherwise 35 | make Covered Code available, directly or indirectly, to anyone other than You; 36 | and/or (b) to use Covered Code, alone or as part of a Larger Work, in any way 37 | to provide a service, including but not limited to delivery of content, through 38 | electronic communication with a client other than You. 39 | 40 | 1.5 "Larger Work" means a work which combines Covered Code or portions 41 | thereof with code not governed by the terms of this License. 42 | 43 | 1.6 "Modifications" mean any addition to, deletion from, and/or change to, 44 | the substance and/or structure of the Original Code, any previous 45 | Modifications, the combination of Original Code and any previous Modifications, 46 | and/or any respective portions thereof. When code is released as a series of 47 | files, a Modification is: (a) any addition to or deletion from the contents of 48 | a file containing Covered Code; and/or (b) any new file or other representation 49 | of computer program statements that contains any part of Covered Code. 50 | 51 | 1.7 "Original Code" means (a) the Source Code of a program or other work as 52 | originally made available by Apple under this License, including the Source 53 | Code of any updates or upgrades to such programs or works made available by 54 | Apple under this License, and that has been expressly identified by Apple as 55 | such in the header file(s) of such work; and (b) the object code compiled from 56 | such Source Code and originally made available by Apple under this License 57 | 58 | 1.8 "Source Code" means the human readable form of a program or other work 59 | that is suitable for making modifications to it, including all modules it 60 | contains, plus any associated interface definition files, scripts used to 61 | control compilation and installation of an executable (object code). 62 | 63 | 1.9 "You" or "Your" means an individual or a legal entity exercising rights 64 | under this License. For legal entities, "You" or "Your" includes any entity 65 | which controls, is controlled by, or is under common control with, You, where 66 | "control" means (a) the power, direct or indirect, to cause the direction or 67 | management of such entity, whether by contract or otherwise, or (b) ownership 68 | of fifty percent (50%) or more of the outstanding shares or beneficial 69 | ownership of such entity. 70 | 71 | 2. Permitted Uses; Conditions & Restrictions. Subject to the terms and 72 | conditions of this License, Apple hereby grants You, effective on the date You 73 | accept this License and download the Original Code, a world-wide, royalty-free, 74 | non-exclusive license, to the extent of Apple's Applicable Patent Rights and 75 | copyrights covering the Original Code, to do the following: 76 | 77 | 2.1 Unmodified Code. You may use, reproduce, display, perform, internally 78 | distribute within Your organization, and Externally Deploy verbatim, unmodified 79 | copies of the Original Code, for commercial or non-commercial purposes, 80 | provided that in each instance: 81 | 82 | (a) You must retain and reproduce in all copies of Original Code the 83 | copyright and other proprietary notices and disclaimers of Apple as they appear 84 | in the Original Code, and keep intact all notices in the Original Code that 85 | refer to this License; and 86 | 87 | (b) You must include a copy of this License with every copy of Source Code 88 | of Covered Code and documentation You distribute or Externally Deploy, and You 89 | may not offer or impose any terms on such Source Code that alter or restrict 90 | this License or the recipients' rights hereunder, except as permitted under 91 | Section 6. 92 | 93 | 2.2 Modified Code. You may modify Covered Code and use, reproduce, 94 | display, perform, internally distribute within Your organization, and 95 | Externally Deploy Your Modifications and Covered Code, for commercial or 96 | non-commercial purposes, provided that in each instance You also meet all of 97 | these conditions: 98 | 99 | (a) You must satisfy all the conditions of Section 2.1 with respect to the 100 | Source Code of the Covered Code; 101 | 102 | (b) You must duplicate, to the extent it does not already exist, the notice 103 | in Exhibit A in each file of the Source Code of all Your Modifications, and 104 | cause the modified files to carry prominent notices stating that You changed 105 | the files and the date of any change; and 106 | 107 | (c) If You Externally Deploy Your Modifications, You must make Source Code 108 | of all Your Externally Deployed Modifications either available to those to whom 109 | You have Externally Deployed Your Modifications, or publicly available. Source 110 | Code of Your Externally Deployed Modifications must be released under the terms 111 | set forth in this License, including the license grants set forth in Section 3 112 | below, for as long as you Externally Deploy the Covered Code or twelve (12) 113 | months from the date of initial External Deployment, whichever is longer. You 114 | should preferably distribute the Source Code of Your Externally Deployed 115 | Modifications electronically (e.g. download from a web site). 116 | 117 | 2.3 Distribution of Executable Versions. In addition, if You Externally 118 | Deploy Covered Code (Original Code and/or Modifications) in object code, 119 | executable form only, You must include a prominent notice, in the code itself 120 | as well as in related documentation, stating that Source Code of the Covered 121 | Code is available under the terms of this License with information on how and 122 | where to obtain such Source Code. 123 | 124 | 2.4 Third Party Rights. You expressly acknowledge and agree that although 125 | Apple and each Contributor grants the licenses to their respective portions of 126 | the Covered Code set forth herein, no assurances are provided by Apple or any 127 | Contributor that the Covered Code does not infringe the patent or other 128 | intellectual property rights of any other entity. Apple and each Contributor 129 | disclaim any liability to You for claims brought by any other entity based on 130 | infringement of intellectual property rights or otherwise. As a condition to 131 | exercising the rights and licenses granted hereunder, You hereby assume sole 132 | responsibility to secure any other intellectual property rights needed, if any. 133 | For example, if a third party patent license is required to allow You to 134 | distribute the Covered Code, it is Your responsibility to acquire that license 135 | before distributing the Covered Code. 136 | 137 | 3. Your Grants. In consideration of, and as a condition to, the licenses 138 | granted to You under this License, You hereby grant to any person or entity 139 | receiving or distributing Covered Code under this License a non-exclusive, 140 | royalty-free, perpetual, irrevocable license, under Your Applicable Patent 141 | Rights and other intellectual property rights (other than patent) owned or 142 | controlled by You, to use, reproduce, display, perform, modify, sublicense, 143 | distribute and Externally Deploy Your Modifications of the same scope and 144 | extent as Apple's licenses under Sections 2.1 and 2.2 above. 145 | 146 | 4. Larger Works. You may create a Larger Work by combining Covered Code 147 | with other code not governed by the terms of this License and distribute the 148 | Larger Work as a single product. In each such instance, You must make sure the 149 | requirements of this License are fulfilled for the Covered Code or any portion 150 | thereof. 151 | 152 | 5. Limitations on Patent License. Except as expressly stated in Section 153 | 2, no other patent rights, express or implied, are granted by Apple herein. 154 | Modifications and/or Larger Works may require additional patent licenses from 155 | Apple which Apple may grant in its sole discretion. 156 | 157 | 6. Additional Terms. You may choose to offer, and to charge a fee for, 158 | warranty, support, indemnity or liability obligations and/or other rights 159 | consistent with the scope of the license granted herein ("Additional Terms") to 160 | one or more recipients of Covered Code. However, You may do so only on Your own 161 | behalf and as Your sole responsibility, and not on behalf of Apple or any 162 | Contributor. You must obtain the recipient's agreement that any such Additional 163 | Terms are offered by You alone, and You hereby agree to indemnify, defend and 164 | hold Apple and every Contributor harmless for any liability incurred by or 165 | claims asserted against Apple or such Contributor by reason of any such 166 | Additional Terms. 167 | 168 | 7. Versions of the License. Apple may publish revised and/or new versions 169 | of this License from time to time. Each version will be given a distinguishing 170 | version number. Once Original Code has been published under a particular 171 | version of this License, You may continue to use it under the terms of that 172 | version. You may also choose to use such Original Code under the terms of any 173 | subsequent version of this License published by Apple. No one other than Apple 174 | has the right to modify the terms applicable to Covered Code created under this 175 | License. 176 | 177 | 8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in 178 | part pre-release, untested, or not fully tested works. The Covered Code may 179 | contain errors that could cause failures or loss of data, and may be incomplete 180 | or contain inaccuracies. You expressly acknowledge and agree that use of the 181 | Covered Code, or any portion thereof, is at Your sole and entire risk. THE 182 | COVERED CODE IS PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT OF 183 | ANY KIND AND APPLE AND APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" 184 | FOR THE PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM 185 | ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT NOT 186 | LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY, OF 187 | SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY, OF 188 | QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. APPLE AND EACH 189 | CONTRIBUTOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE 190 | COVERED CODE, THAT THE FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR 191 | REQUIREMENTS, THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR 192 | ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO ORAL OR 193 | WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE AUTHORIZED 194 | REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY. You acknowledge 195 | that the Covered Code is not intended for use in the operation of nuclear 196 | facilities, aircraft navigation, communication systems, or air traffic control 197 | machines in which case the failure of the Covered Code could lead to death, 198 | personal injury, or severe physical or environmental damage. 199 | 200 | 9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO 201 | EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL, 202 | INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO THIS LICENSE OR 203 | YOUR USE OR INABILITY TO USE THE COVERED CODE, OR ANY PORTION THEREOF, WHETHER 204 | UNDER A THEORY OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCTS 205 | LIABILITY OR OTHERWISE, EVEN IF APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF 206 | THE POSSIBILITY OF SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL 207 | PURPOSE OF ANY REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF 208 | LIABILITY OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT 209 | APPLY TO YOU. In no event shall Apple's total liability to You for all damages 210 | (other than as may be required by applicable law) under this License exceed the 211 | amount of fifty dollars ($50.00). 212 | 213 | 10. Trademarks. This License does not grant any rights to use the 214 | trademarks or trade names "Apple", "Mac", "Mac OS", "QuickTime", "QuickTime 215 | Streaming Server" or any other trademarks, service marks, logos or trade names 216 | belonging to Apple (collectively "Apple Marks") or to any trademark, service 217 | mark, logo or trade name belonging to any Contributor. You agree not to use 218 | any Apple Marks in or as part of the name of products derived from the Original 219 | Code or to endorse or promote products derived from the Original Code other 220 | than as expressly permitted by and in strict compliance at all times with 221 | Apple's third party trademark usage guidelines which are posted at 222 | http://www.apple.com/legal/guidelinesfor3rdparties.html. 223 | 224 | 11. Ownership. Subject to the licenses granted under this License, each 225 | Contributor retains all rights, title and interest in and to any Modifications 226 | made by such Contributor. Apple retains all rights, title and interest in and 227 | to the Original Code and any Modifications made by or on behalf of Apple 228 | ("Apple Modifications"), and such Apple Modifications will not be automatically 229 | subject to this License. Apple may, at its sole discretion, choose to license 230 | such Apple Modifications under this License, or on different terms from those 231 | contained in this License or may choose not to license them at all. 232 | 233 | 12. Termination. 234 | 235 | 12.1 Termination. This License and the rights granted hereunder will 236 | terminate: 237 | 238 | (a) automatically without notice from Apple if You fail to comply with any 239 | term(s) of this License and fail to cure such breach within 30 days of becoming 240 | aware of such breach; 241 | (b) immediately in the event of the circumstances described in Section 242 | 13.5(b); or 243 | (c) automatically without notice from Apple if You, at any time during the 244 | term of this License, commence an action for patent infringement against Apple; 245 | provided that Apple did not first commence an action for patent infringement 246 | against You in that instance. 247 | 248 | 12.2 Effect of Termination. Upon termination, You agree to immediately stop 249 | any further use, reproduction, modification, sublicensing and distribution of 250 | the Covered Code. All sublicenses to the Covered Code which have been properly 251 | granted prior to termination shall survive any termination of this License. 252 | Provisions which, by their nature, should remain in effect beyond the 253 | termination of this License shall survive, including but not limited to 254 | Sections 3, 5, 8, 9, 10, 11, 12.2 and 13. No party will be liable to any other 255 | for compensation, indemnity or damages of any sort solely as a result of 256 | terminating this License in accordance with its terms, and termination of this 257 | License will be without prejudice to any other right or remedy of any party. 258 | 259 | 13. Miscellaneous. 260 | 261 | 13.1 Government End Users. The Covered Code is a "commercial item" as 262 | defined in FAR 2.101. Government software and technical data rights in the 263 | Covered Code include only those rights customarily provided to the public as 264 | defined in this License. This customary commercial license in technical data 265 | and software is provided in accordance with FAR 12.211 (Technical Data) and 266 | 12.212 (Computer Software) and, for Department of Defense purchases, DFAR 267 | 252.227-7015 (Technical Data -- Commercial Items) and 227.7202-3 (Rights in 268 | Commercial Computer Software or Computer Software Documentation). Accordingly, 269 | all U.S. Government End Users acquire Covered Code with only those rights set 270 | forth herein. 271 | 272 | 13.2 Relationship of Parties. This License will not be construed as 273 | creating an agency, partnership, joint venture or any other form of legal 274 | association between or among You, Apple or any Contributor, and You will not 275 | represent to the contrary, whether expressly, by implication, appearance or 276 | otherwise. 277 | 278 | 13.3 Independent Development. Nothing in this License will impair Apple's 279 | right to acquire, license, develop, have others develop for it, market and/or 280 | distribute technology or products that perform the same or similar functions 281 | as, or otherwise compete with, Modifications, Larger Works, technology or 282 | products that You may develop, produce, market or distribute. 283 | 284 | 13.4 Waiver; Construction. Failure by Apple or any Contributor to enforce 285 | any provision of this License will not be deemed a waiver of future enforcement 286 | of that or any other provision. Any law or regulation which provides that the 287 | language of a contract shall be construed against the drafter will not apply to 288 | this License. 289 | 290 | 13.5 Severability. (a) If for any reason a court of competent jurisdiction 291 | finds any provision of this License, or portion thereof, to be unenforceable, 292 | that provision of the License will be enforced to the maximum extent 293 | permissible so as to effect the economic benefits and intent of the parties, 294 | and the remainder of this License will continue in full force and effect. (b) 295 | Notwithstanding the foregoing, if applicable law prohibits or restricts You 296 | from fully and/or specifically complying with Sections 2 and/or 3 or prevents 297 | the enforceability of either of those Sections, this License will immediately 298 | terminate and You must immediately discontinue any use of the Covered Code and 299 | destroy all copies of it that are in your possession or control. 300 | 301 | 13.6 Dispute Resolution. Any litigation or other dispute resolution between 302 | You and Apple relating to this License shall take place in the Northern 303 | District of California, and You and Apple hereby consent to the personal 304 | jurisdiction of, and venue in, the state and federal courts within that 305 | District with respect to this License. The application of the United Nations 306 | Convention on Contracts for the International Sale of Goods is expressly 307 | excluded. 308 | 309 | 13.7 Entire Agreement; Governing Law. This License constitutes the entire 310 | agreement between the parties with respect to the subject matter hereof. This 311 | License shall be governed by the laws of the United States and the State of 312 | California, except that body of California law concerning conflicts of law. 313 | 314 | Where You are located in the province of Quebec, Canada, the following clause 315 | applies: The parties hereby confirm that they have requested that this License 316 | and all related documents be drafted in English. Les parties ont exigé que le 317 | présent contrat et tous les documents connexes soient rédigés en anglais. 318 | 319 | EXHIBIT A. 320 | 321 | "Portions Copyright (c) 1999-2007 Apple Inc. All Rights Reserved. 322 | 323 | This file contains Original Code and/or Modifications of Original Code as 324 | defined in and that are subject to the Apple Public Source License Version 2.0 325 | (the 'License'). You may not use this file except in compliance with the 326 | License. Please obtain a copy of the License at 327 | http://www.opensource.apple.com/apsl/ and read it before using this file. 328 | 329 | The Original Code and all software distributed under the License are 330 | distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS 331 | OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT 332 | LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 333 | PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the 334 | specific language governing rights and limitations under the License." 335 | 336 | -------------------------------------------------------------------------------- /CompatibilityHacks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | /* 30 | * See: , , 31 | */ 32 | 33 | #include 34 | 35 | #if defined(__x86_64__) && !TARGET_OS_DRIVERKIT 36 | 37 | #define SYM(sym) \ 38 | __asm__(".globl R8289209$_" #sym "; R8289209$_" #sym ": jmp _" #sym) 39 | 40 | /****************/ 41 | 42 | SYM(close); 43 | SYM(fork); 44 | SYM(fsync); 45 | SYM(getattrlist); 46 | SYM(getrlimit); 47 | SYM(getxattr); 48 | SYM(open); 49 | SYM(pthread_attr_destroy); 50 | SYM(pthread_attr_init); 51 | SYM(pthread_attr_setdetachstate); 52 | SYM(pthread_create); 53 | SYM(pthread_mutex_lock); 54 | SYM(pthread_mutex_unlock); 55 | SYM(pthread_self); 56 | SYM(ptrace); 57 | SYM(read); 58 | SYM(setattrlist); 59 | SYM(setrlimit); 60 | SYM(sigaction); 61 | SYM(stat); 62 | SYM(sysctl); 63 | SYM(time); 64 | SYM(unlink); 65 | SYM(write); 66 | 67 | #endif /* defined(__x86_64__) && !TARGET_OS_DRIVERKIT*/ 68 | 69 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | System 9 | CFBundleIdentifier 10 | com.apple.System 11 | CFBundleName 12 | System 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 11 19 | CFBundleSignature 20 | ???? 21 | 22 | 23 | -------------------------------------------------------------------------------- /Libsystem.xcconfig: -------------------------------------------------------------------------------- 1 | #include "/Makefiles/CoreOS/Xcode/BSD.xcconfig" 2 | 3 | // NO means only libSystem.B_asan.dylib will be ASanified. 4 | // YES means even the normal variant, libSystem.B.dylib, will be ASanified. 5 | // 6 | // XBS sets RC_SUPPORT_ADDRESS_SANITIZATION=1 to trigger the ASanified normal variant. 7 | ASAN_IN_NORMAL_VARIANT_DK_ = YES 8 | ASAN_IN_NORMAL_VARIANT_DK_1 = NO 9 | ASAN_IN_NORMAL_VARIANT_RC_1 = $(ASAN_IN_NORMAL_VARIANT_DK_$(DRIVERKIT)$(EXCLAVEKIT)) 10 | ASAN_IN_NORMAL_VARIANT_RC_ = NO 11 | ASAN_IN_NORMAL_VARIANT = $(ASAN_IN_NORMAL_VARIANT_RC_$(RC_SUPPORT_ADDRESS_SANITIZATION)) 12 | 13 | // Apple Internal Sanitizer dylib path 14 | SANITIZER_DYLIB_DIR = /usr/appleinternal/lib/sanitizers 15 | 16 | ASAN_CFLAGS_NO = 17 | ASAN_CFLAGS_YES = -DSUPPORT_ASAN=1 18 | ASAN_LDFLAGS_NO = 19 | SHARED_ASAN_LDFLAGS = -L $(SDKROOT)$(SANITIZER_DYLIB_DIR) -Xlinker -not_for_dyld_shared_cache -rpath $(SANITIZER_DYLIB_DIR)/ 20 | ASAN_LDFLAGS_YES_macosx = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_osx_dynamic 21 | ASAN_LDFLAGS_YES_iphoneos = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_ios_dynamic 22 | ASAN_LDFLAGS_YES_watchos = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_watchos_dynamic 23 | ASAN_LDFLAGS_YES_appletvos = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_tvos_dynamic 24 | ASAN_LDFLAGS_YES_bridgeos = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_bridgeos_dynamic 25 | // default to using PLATFORM_NAME as the asan name 26 | ASAN_LDFLAGS_YES[sdk=*os*] = $(ASAN_LDFLAGS_YES_$(PLATFORM_NAME):default=$(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_$(PLATFORM_NAME)_dynamic) 27 | 28 | // "no_asan" variant 29 | // 30 | // The "no_asan" variant is only built when ASAN_IN_NORMAL_VARIANT=YES. 31 | // The variant exists to provide a way to opt-out processes from the 32 | // "Whole OS ASan" mode. It should be identical to the "normal" variant 33 | // except it does **not** upward link the ASan runtime. Despite the name, 34 | // this does not enforce that ASan is not used. This is because an ASan 35 | // instrumented binary could also cause the ASan runtime to be loaded. 36 | NOASAN_CFLAGS_YES = $(ASAN_CFLAGS_YES) 37 | NOASAN_LDFLAGS_YES = 38 | EXTRA_BUILD_VARIANTS_ASAN_IN_NORMAL_VARIANT_NO = 39 | EXTRA_BUILD_VARIANTS_ASAN_IN_NORMAL_VARIANT_YES = no_asan 40 | EXTRA_BUILD_VARIANTS_ASAN_IN_NORMAL_VARIANT = $(EXTRA_BUILD_VARIANTS_ASAN_IN_NORMAL_VARIANT_$(ASAN_IN_NORMAL_VARIANT)) 41 | 42 | SDK_INSTALL_ROOT[sdk=driverkit*] = $(DRIVERKITROOT) // TODO: switch to SYSTEM_PREFIX? 43 | SDK_INSTALL_ROOT[sdk=exclavekit*] = $(SYSTEM_PREFIX) 44 | SDK_INSTALL_HEADERS_ROOT[sdk=driverkit*] = $(SDK_INSTALL_ROOT)/$(SDK_RUNTIME_HEADERS_PREFIX) 45 | SDK_RUNTIME_HEADERS_PREFIX = Runtime 46 | SDK_INSTALL_HEADERS_ROOT[sdk=exclavekit*] = $(SDK_INSTALL_ROOT) 47 | 48 | BUILD_VARIANTS = normal debug asan $(EXTRA_BUILD_VARIANTS_ASAN_IN_NORMAL_VARIANT) 49 | BUILD_VARIANTS[sdk=driverkit*] = normal debug 50 | BUILD_VARIANTS[sdk=exclavekit*] = normal 51 | ARCHS = $(ARCHS_STANDARD_32_64_BIT) 52 | ARCHS[sdk=exclavekit*] = arm64e 53 | SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator driverkit exclavekit.macosx exclavekit.iphoneos 54 | INSTALL_PATH = $(SDK_INSTALL_ROOT)/usr/lib 55 | INSTALL_PATH_PREFIX = $(SDK_INSTALL_ROOT) 56 | INSTALL_PATH_FRAMEWORK_PREFIX = $(SDK_INSTALL_HEADERS_ROOT) 57 | DYLIB_CURRENT_VERSION = $(CURRENT_VERSION_STRING_$(RC_XBS)) 58 | // used in PRODUCT_NAME of dylib target 59 | DYLIB_NAME_VERSION_SUFFIX = .B 60 | DYLIB_NAME_VERSION_SUFFIX[sdk=driverkit*] = 61 | DYLIB_NAME_VERSION_SUFFIX[sdk=exclavekit*] = 62 | SYSTEM_HEADER_SEARCH_PATHS = $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders $(inherited) 63 | SYSTEM_HEADER_SEARCH_PATHS[sdk=driverkit*] = $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/usr/local/include $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/usr/include $(SDKROOT)/$(SDK_INSTALL_ROOT)/usr/local/include 64 | SYSTEM_HEADER_SEARCH_PATHS[sdk=exclavekit*] = $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/usr/local/include $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/usr/include 65 | SYSTEM_FRAMEWORK_SEARCH_PATHS = $(MSL_FRAMEWORK_SEARCH_PATHS) $(inherited) 66 | SYSTEM_FRAMEWORK_SEARCH_PATHS[sdk=driverkit*] = $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/PrivateFrameworks $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/Frameworks $(MSL_FRAMEWORK_SEARCH_PATHS) 67 | SYSTEM_FRAMEWORK_SEARCH_PATHS[sdk=exclavekit*] = $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/PrivateFrameworks $(SDKROOT)/$(SDK_INSTALL_HEADERS_ROOT)/System/Library/Frameworks $(MSL_FRAMEWORK_SEARCH_PATHS) 68 | 69 | MSL_FRAMEWORK_SEARCH_PATHS = 70 | MSL_FRAMEWORK_SEARCH_PATHS[sdk=driverkit*] = $(SDKROOT)$(DRIVERKITROOT)/System/Library/PrivateFrameworks 71 | 72 | OTHER_CFLAGS = -include $(BUILT_PRODUCTS_DIR)/config.$(CURRENT_ARCH).$(CURRENT_VARIANT).h -DCURRENT_VARIANT_$(CURRENT_VARIANT)=1 73 | OTHER_CFLAGS_normal = $(ASAN_CFLAGS_$(ASAN_IN_NORMAL_VARIANT:default=NO)) 74 | // Preserve existing behaviour of modifying debug variant. 75 | OTHER_CFLAGS_debug = $(ASAN_CFLAGS_$(ASAN_IN_NORMAL_VARIANT:default=NO)) 76 | OTHER_CFLAGS_asan = $(ASAN_CFLAGS_YES) 77 | OTHER_CFLAGS_no_asan = $(NOASAN_CFLAGS_YES) 78 | 79 | OTHER_LDFLAGS = -Wl,-search_paths_first -nodefaultlibs @$(BUILT_PRODUCTS_DIR)/linker_arguments.$(CURRENT_ARCH).$(CURRENT_VARIANT).txt $(PLATFORM_LDFLAGS) 80 | OTHER_LDFLAGS_normal = $(ASAN_LDFLAGS_$(ASAN_IN_NORMAL_VARIANT:default=NO)) 81 | // Preserve existing behaviour of modifying debug variant. 82 | OTHER_LDFLAGS_debug = $(ASAN_LDFLAGS_$(ASAN_IN_NORMAL_VARIANT:default=NO)) 83 | OTHER_LDFLAGS_asan = $(ASAN_LDFLAGS_YES) 84 | OTHER_LDFLAGS_no_asan = $(NOASAN_LDFLAGS_YES) 85 | 86 | 87 | // whitelist of libraries in DriverKit SDK allowed to link directly against libSystem.dylib (outside of the umbrella) 88 | // "clang" is the allowable client string for the sanitizer runtimes, like 89 | // "libclang_rt.asan_osx_dynamic.dylib" 90 | PLATFORM_LDFLAGS[sdk=driverkit*] = -Wl,-allowable_client,c++ -Wl,-allowable_client,c++abi -Wl,-allowable_client,DriverKit -Wl,-allowable_client,clang -Wl,-allowable_client,swiftCore -Wl,-allowable_client,swiftSwiftOnoneSupport 91 | PLATFORM_LDFLAGS[sdk=exclavekit*] = -Wl,-upward-lobjc 92 | 93 | LD_GENERATE_MAP_FILE = YES 94 | EXECUTABLE_PREFIX = lib 95 | PRIVATE_HEADERS_FOLDER_PATH = $(SDK_INSTALL_HEADERS_ROOT)/usr/local/include/os 96 | LIBRARY_SEARCH_PATHS = $(SDKROOT)/$(SDK_INSTALL_ROOT)/usr/lib/system $(SDKROOT)/$(SDK_INSTALL_ROOT)/usr/local/lib/system 97 | GCC_NO_COMMON_BLOCKS = YES 98 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES 99 | GCC_WARN_ABOUT_RETURN_TYPE = YES 100 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES 101 | GCC_TREAT_WARNINGS_AS_ERRORS = YES 102 | GCC_WARN_UNUSED_VARIABLE = YES 103 | CURRENT_VERSION_STRING_ = 159 104 | CURRENT_VERSION_STRING_YES = $(CURRENT_PROJECT_VERSION) 105 | INFOPLIST_INSTALL_PATH = Versions/B/Resources 106 | INFOPLIST_INSTALL_PATH[sdk=iphoneos*] = 107 | INFOPLIST_INSTALL_PATH[sdk=*simulator*] = 108 | INFOPLIST_INSTALL_PATH[sdk=watchos*] = 109 | INFOPLIST_OUTPUT_FORMAT = binary 110 | INFOPLIST_OUTPUT_FORMAT[sdk=macosx*] = xml 111 | APPLY_RULES_IN_COPY_FILES = YES 112 | PLIST_FILE_OUTPUT_FORMAT = binary 113 | PLIST_FILE_OUTPUT_FORMAT[sdk=macosx*] = xml 114 | EXCLUDED_SOURCE_FILE_NAMES[sdk=driverkit*] = Info.plist 115 | EXCLUDED_SOURCE_FILE_NAMES[sdk=exclavekit*] = Info.plist 116 | 117 | EXCLUDED_SOURCE_FILE_NAMES = $(inherited) 118 | 119 | EXCLUDED_SOURCE_FILE_NAMES[sdk=exclavekit*] = $(inherited) CompatibilityHacks.c alloc_once_private.h 120 | 121 | // override presence of $(EXECUTABLE_VARIANT_SUFFIX) in the default EXECUTABLE_NAME rdar://26234727 122 | DYLIB_INSTALL_NAME_EXECUTABLE_NAME = $(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_SUFFIX) 123 | DYLIB_INSTALL_NAME_EXECUTABLE_PATH = $(DYLIB_INSTALL_NAME_EXECUTABLE_NAME) 124 | LD_DYLIB_INSTALL_NAME = $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(DYLIB_INSTALL_NAME_EXECUTABLE_PATH) 125 | 126 | IS_ZIPPERED = YES 127 | -------------------------------------------------------------------------------- /Libsystem.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 2BBCA223278E5D9600224D15 /* Libsystem_exclavekit */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 2BBCA22A278E5D9600224D15 /* Build configuration list for PBXAggregateTarget "Libsystem_exclavekit" */; 13 | buildPhases = ( 14 | ); 15 | dependencies = ( 16 | 2BBCA224278E5D9600224D15 /* PBXTargetDependency */, 17 | 2BBCA226278E5D9600224D15 /* PBXTargetDependency */, 18 | 2BBCA228278E5D9600224D15 /* PBXTargetDependency */, 19 | ); 20 | name = Libsystem_exclavekit; 21 | productName = Libsystem_driverkit; 22 | }; 23 | 923662F4212762D7001FB3E7 /* Sanitizer Support */ = { 24 | isa = PBXAggregateTarget; 25 | buildConfigurationList = 923662F6212762D7001FB3E7 /* Build configuration list for PBXAggregateTarget "Sanitizer Support" */; 26 | buildPhases = ( 27 | 923662F7212762EA001FB3E7 /* Copy enable_asan_mode */, 28 | 923662FB21276319001FB3E7 /* Run create_asan_override_file.sh */, 29 | ); 30 | dependencies = ( 31 | ); 32 | name = "Sanitizer Support"; 33 | productName = "Sanitizer Support"; 34 | }; 35 | BA5511CF136CA8480012B9B5 /* Generate Linker Arguments */ = { 36 | isa = PBXAggregateTarget; 37 | buildConfigurationList = BA5511D0136CA8480012B9B5 /* Build configuration list for PBXAggregateTarget "Generate Linker Arguments" */; 38 | buildPhases = ( 39 | BA5511D4136CA8680012B9B5 /* ShellScript */, 40 | ); 41 | dependencies = ( 42 | ); 43 | name = "Generate Linker Arguments"; 44 | productName = "Generate Linker Arguments"; 45 | }; 46 | BA5511D6136D22ED0012B9B5 /* Generate Symlinks */ = { 47 | isa = PBXAggregateTarget; 48 | buildConfigurationList = BA5511D7136D22ED0012B9B5 /* Build configuration list for PBXAggregateTarget "Generate Symlinks" */; 49 | buildPhases = ( 50 | BA5511D9136D23110012B9B5 /* ShellScript */, 51 | BA2BD8FE136D271D00FF78C0 /* ShellScript */, 52 | BA2BD8FF136D27FE00FF78C0 /* CopyFiles */, 53 | ); 54 | dependencies = ( 55 | ); 56 | name = "Generate Symlinks"; 57 | productName = "Generate Symlinks"; 58 | }; 59 | E47E982E221DFDFC006E312E /* Libsystem_driverkit */ = { 60 | isa = PBXAggregateTarget; 61 | buildConfigurationList = E47E9830221DFDFC006E312E /* Build configuration list for PBXAggregateTarget "Libsystem_driverkit" */; 62 | buildPhases = ( 63 | ); 64 | dependencies = ( 65 | E47E983D221DFE8B006E312E /* PBXTargetDependency */, 66 | E47E983F221DFE90006E312E /* PBXTargetDependency */, 67 | E47E9841221DFE94006E312E /* PBXTargetDependency */, 68 | ); 69 | name = Libsystem_driverkit; 70 | productName = Libsystem_driverkit; 71 | }; 72 | E47E9831221DFE23006E312E /* Libsystem */ = { 73 | isa = PBXAggregateTarget; 74 | buildConfigurationList = E47E9832221DFE23006E312E /* Build configuration list for PBXAggregateTarget "Libsystem" */; 75 | buildPhases = ( 76 | 8C1C6CD52655B054001B99C7 /* Install FeatureFlags */, 77 | ); 78 | dependencies = ( 79 | E47E9835221DFE4A006E312E /* PBXTargetDependency */, 80 | E47E9837221DFE4F006E312E /* PBXTargetDependency */, 81 | E47E9839221DFE58006E312E /* PBXTargetDependency */, 82 | E47E983B221DFE5E006E312E /* PBXTargetDependency */, 83 | ); 84 | name = Libsystem; 85 | productName = Libsystem; 86 | }; 87 | /* End PBXAggregateTarget section */ 88 | 89 | /* Begin PBXBuildFile section */ 90 | 8C1C6CD62655B06A001B99C7 /* Libsystem.plist in Install FeatureFlags */ = {isa = PBXBuildFile; fileRef = 8C7F4804264C24F1007076D8 /* Libsystem.plist */; }; 91 | 923662F821276300001FB3E7 /* enable_asan_mode in Copy enable_asan_mode */ = {isa = PBXBuildFile; fileRef = 8C0BF1291F58E51D00706493 /* enable_asan_mode */; }; 92 | BA2BD900136D282200FF78C0 /* Info.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = BA5511B6136C9D780012B9B5 /* Info.plist */; }; 93 | BA2FABC5136DBF45004383E5 /* linker_arguments_changed.c in Sources */ = {isa = PBXBuildFile; fileRef = BA2FABC4136DBF45004383E5 /* linker_arguments_changed.c */; }; 94 | BA5511C9136C9E4D0012B9B5 /* CompatibilityHacks.c in Sources */ = {isa = PBXBuildFile; fileRef = BA5511B4136C9D780012B9B5 /* CompatibilityHacks.c */; }; 95 | BA5511CA136C9E510012B9B5 /* init.c in Sources */ = {isa = PBXBuildFile; fileRef = BA5511B7136C9D780012B9B5 /* init.c */; }; 96 | C9A43CAC15374DB200388D0C /* alloc_once_private.h in Headers */ = {isa = PBXBuildFile; fileRef = C9A43CAB15374DB200388D0C /* alloc_once_private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 97 | /* End PBXBuildFile section */ 98 | 99 | /* Begin PBXContainerItemProxy section */ 100 | 2BBCA225278E5D9600224D15 /* PBXContainerItemProxy */ = { 101 | isa = PBXContainerItemProxy; 102 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 103 | proxyType = 1; 104 | remoteGlobalIDString = BA5511D6136D22ED0012B9B5; 105 | remoteInfo = "Generate Symlinks"; 106 | }; 107 | 2BBCA227278E5D9600224D15 /* PBXContainerItemProxy */ = { 108 | isa = PBXContainerItemProxy; 109 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 110 | proxyType = 1; 111 | remoteGlobalIDString = BA5511CF136CA8480012B9B5; 112 | remoteInfo = "Generate Linker Arguments"; 113 | }; 114 | 2BBCA229278E5D9600224D15 /* PBXContainerItemProxy */ = { 115 | isa = PBXContainerItemProxy; 116 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 117 | proxyType = 1; 118 | remoteGlobalIDString = BA5511C3136C9E2E0012B9B5; 119 | remoteInfo = System; 120 | }; 121 | 8C3F0589284EB2280040B6D2 /* PBXContainerItemProxy */ = { 122 | isa = PBXContainerItemProxy; 123 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 124 | proxyType = 1; 125 | remoteGlobalIDString = BA5511CF136CA8480012B9B5; 126 | remoteInfo = "Generate Linker Arguments"; 127 | }; 128 | E47E9834221DFE4A006E312E /* PBXContainerItemProxy */ = { 129 | isa = PBXContainerItemProxy; 130 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 131 | proxyType = 1; 132 | remoteGlobalIDString = 923662F4212762D7001FB3E7; 133 | remoteInfo = "Sanitizer Support"; 134 | }; 135 | E47E9836221DFE4F006E312E /* PBXContainerItemProxy */ = { 136 | isa = PBXContainerItemProxy; 137 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 138 | proxyType = 1; 139 | remoteGlobalIDString = BA5511D6136D22ED0012B9B5; 140 | remoteInfo = "Generate Symlinks"; 141 | }; 142 | E47E9838221DFE58006E312E /* PBXContainerItemProxy */ = { 143 | isa = PBXContainerItemProxy; 144 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 145 | proxyType = 1; 146 | remoteGlobalIDString = BA5511CF136CA8480012B9B5; 147 | remoteInfo = "Generate Linker Arguments"; 148 | }; 149 | E47E983A221DFE5E006E312E /* PBXContainerItemProxy */ = { 150 | isa = PBXContainerItemProxy; 151 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 152 | proxyType = 1; 153 | remoteGlobalIDString = BA5511C3136C9E2E0012B9B5; 154 | remoteInfo = System; 155 | }; 156 | E47E983C221DFE8B006E312E /* PBXContainerItemProxy */ = { 157 | isa = PBXContainerItemProxy; 158 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 159 | proxyType = 1; 160 | remoteGlobalIDString = BA5511D6136D22ED0012B9B5; 161 | remoteInfo = "Generate Symlinks"; 162 | }; 163 | E47E983E221DFE90006E312E /* PBXContainerItemProxy */ = { 164 | isa = PBXContainerItemProxy; 165 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 166 | proxyType = 1; 167 | remoteGlobalIDString = BA5511CF136CA8480012B9B5; 168 | remoteInfo = "Generate Linker Arguments"; 169 | }; 170 | E47E9840221DFE94006E312E /* PBXContainerItemProxy */ = { 171 | isa = PBXContainerItemProxy; 172 | containerPortal = BA5511A9136C9D400012B9B5 /* Project object */; 173 | proxyType = 1; 174 | remoteGlobalIDString = BA5511C3136C9E2E0012B9B5; 175 | remoteInfo = System; 176 | }; 177 | /* End PBXContainerItemProxy section */ 178 | 179 | /* Begin PBXCopyFilesBuildPhase section */ 180 | 8C1C6CD52655B054001B99C7 /* Install FeatureFlags */ = { 181 | isa = PBXCopyFilesBuildPhase; 182 | buildActionMask = 8; 183 | dstPath = /System/Library/FeatureFlags/Domain; 184 | dstSubfolderSpec = 0; 185 | files = ( 186 | 8C1C6CD62655B06A001B99C7 /* Libsystem.plist in Install FeatureFlags */, 187 | ); 188 | name = "Install FeatureFlags"; 189 | runOnlyForDeploymentPostprocessing = 1; 190 | }; 191 | 8C7F4805264C2545007076D8 /* Install FeatureFlags */ = { 192 | isa = PBXCopyFilesBuildPhase; 193 | buildActionMask = 8; 194 | dstPath = /System/Library/FeatureFlags/Domain; 195 | dstSubfolderSpec = 0; 196 | files = ( 197 | ); 198 | name = "Install FeatureFlags"; 199 | runOnlyForDeploymentPostprocessing = 1; 200 | }; 201 | 923662F7212762EA001FB3E7 /* Copy enable_asan_mode */ = { 202 | isa = PBXCopyFilesBuildPhase; 203 | buildActionMask = 8; 204 | dstPath = "$(INSTALL_PATH_PREFIX)/usr/local/bin"; 205 | dstSubfolderSpec = 0; 206 | files = ( 207 | 923662F821276300001FB3E7 /* enable_asan_mode in Copy enable_asan_mode */, 208 | ); 209 | name = "Copy enable_asan_mode"; 210 | runOnlyForDeploymentPostprocessing = 1; 211 | }; 212 | BA2BD8FF136D27FE00FF78C0 /* CopyFiles */ = { 213 | isa = PBXCopyFilesBuildPhase; 214 | buildActionMask = 8; 215 | dstPath = "$(INSTALL_PATH_PREFIX)/System/Library/Frameworks/System.framework/$(INFOPLIST_INSTALL_PATH)"; 216 | dstSubfolderSpec = 0; 217 | files = ( 218 | BA2BD900136D282200FF78C0 /* Info.plist in CopyFiles */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 1; 221 | }; 222 | /* End PBXCopyFilesBuildPhase section */ 223 | 224 | /* Begin PBXFileReference section */ 225 | 2BBCA221278E5D2C00224D15 /* requiredlibs_exclavekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = requiredlibs_exclavekit; sourceTree = ""; }; 226 | 2BBCA222278E5D2C00224D15 /* optionallibs_exclavekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = optionallibs_exclavekit; sourceTree = ""; }; 227 | 8C0BF1291F58E51D00706493 /* enable_asan_mode */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = enable_asan_mode; sourceTree = ""; }; 228 | 8C7F4804264C24F1007076D8 /* Libsystem.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Libsystem.plist; sourceTree = ""; }; 229 | 923662FC212B442C001FB3E7 /* create_asan_override_file.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_asan_override_file.sh; sourceTree = ""; }; 230 | BA2FABC4136DBF45004383E5 /* linker_arguments_changed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = linker_arguments_changed.c; sourceTree = BUILT_PRODUCTS_DIR; }; 231 | BA5511B3136C9D780012B9B5 /* APPLE_LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = APPLE_LICENSE; sourceTree = ""; }; 232 | BA5511B4136C9D780012B9B5 /* CompatibilityHacks.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CompatibilityHacks.c; sourceTree = ""; }; 233 | BA5511B6136C9D780012B9B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 234 | BA5511B7136C9D780012B9B5 /* init.c */ = {isa = PBXFileReference; indentWidth = 8; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = ""; tabWidth = 8; usesTabs = 1; }; 235 | BA5511B9136C9D780012B9B5 /* optionallibs */ = {isa = PBXFileReference; lastKnownFileType = text; path = optionallibs; sourceTree = ""; }; 236 | BA5511BA136C9D780012B9B5 /* requiredlibs */ = {isa = PBXFileReference; lastKnownFileType = text; path = requiredlibs; sourceTree = ""; }; 237 | BA5511C4136C9E2E0012B9B5 /* libSystem.B.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libSystem.B.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 238 | C64EE1D7136F644700676C52 /* create_dylib_symlinks.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_dylib_symlinks.sh; sourceTree = ""; }; 239 | C64EE1D8136F644700676C52 /* create_system_framework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_system_framework.sh; sourceTree = ""; }; 240 | C64EE1D9136F644700676C52 /* linker_arguments.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = linker_arguments.sh; sourceTree = ""; }; 241 | C9A43CAB15374DB200388D0C /* alloc_once_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alloc_once_private.h; sourceTree = ""; }; 242 | C9B56C55153751A600C153A8 /* Libsystem.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Libsystem.xcconfig; sourceTree = ""; }; 243 | E43B88B32245778F00215272 /* requiredlibs_driverkit */ = {isa = PBXFileReference; lastKnownFileType = text; path = requiredlibs_driverkit; sourceTree = ""; }; 244 | E43B88B42245778F00215272 /* optionallibs_driverkit */ = {isa = PBXFileReference; lastKnownFileType = text; path = optionallibs_driverkit; sourceTree = ""; }; 245 | /* End PBXFileReference section */ 246 | 247 | /* Begin PBXFrameworksBuildPhase section */ 248 | BA5511C1136C9E2E0012B9B5 /* Frameworks */ = { 249 | isa = PBXFrameworksBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXFrameworksBuildPhase section */ 256 | 257 | /* Begin PBXGroup section */ 258 | 8C7F4803264C24A3007076D8 /* featureflags */ = { 259 | isa = PBXGroup; 260 | children = ( 261 | 8C7F4804264C24F1007076D8 /* Libsystem.plist */, 262 | ); 263 | path = featureflags; 264 | sourceTree = ""; 265 | }; 266 | BA2FABC7136DBF6F004383E5 /* Generated Files */ = { 267 | isa = PBXGroup; 268 | children = ( 269 | BA2FABC4136DBF45004383E5 /* linker_arguments_changed.c */, 270 | ); 271 | name = "Generated Files"; 272 | sourceTree = ""; 273 | }; 274 | BA5511A7136C9D400012B9B5 = { 275 | isa = PBXGroup; 276 | children = ( 277 | C9B56C55153751A600C153A8 /* Libsystem.xcconfig */, 278 | BA5511B3136C9D780012B9B5 /* APPLE_LICENSE */, 279 | BA5511B4136C9D780012B9B5 /* CompatibilityHacks.c */, 280 | BA5511B6136C9D780012B9B5 /* Info.plist */, 281 | C9A43CAB15374DB200388D0C /* alloc_once_private.h */, 282 | BA5511B7136C9D780012B9B5 /* init.c */, 283 | BA5511B9136C9D780012B9B5 /* optionallibs */, 284 | BA5511BA136C9D780012B9B5 /* requiredlibs */, 285 | E43B88B42245778F00215272 /* optionallibs_driverkit */, 286 | E43B88B32245778F00215272 /* requiredlibs_driverkit */, 287 | 2BBCA222278E5D2C00224D15 /* optionallibs_exclavekit */, 288 | 2BBCA221278E5D2C00224D15 /* requiredlibs_exclavekit */, 289 | 8C0BF1291F58E51D00706493 /* enable_asan_mode */, 290 | 8C7F4803264C24A3007076D8 /* featureflags */, 291 | C64EE1D6136F644700676C52 /* xcodescripts */, 292 | BA5511C5136C9E2E0012B9B5 /* Products */, 293 | BA2FABC7136DBF6F004383E5 /* Generated Files */, 294 | ); 295 | sourceTree = ""; 296 | }; 297 | BA5511C5136C9E2E0012B9B5 /* Products */ = { 298 | isa = PBXGroup; 299 | children = ( 300 | BA5511C4136C9E2E0012B9B5 /* libSystem.B.dylib */, 301 | ); 302 | name = Products; 303 | sourceTree = ""; 304 | }; 305 | C64EE1D6136F644700676C52 /* xcodescripts */ = { 306 | isa = PBXGroup; 307 | children = ( 308 | 923662FC212B442C001FB3E7 /* create_asan_override_file.sh */, 309 | C64EE1D7136F644700676C52 /* create_dylib_symlinks.sh */, 310 | C64EE1D8136F644700676C52 /* create_system_framework.sh */, 311 | C64EE1D9136F644700676C52 /* linker_arguments.sh */, 312 | ); 313 | path = xcodescripts; 314 | sourceTree = ""; 315 | }; 316 | /* End PBXGroup section */ 317 | 318 | /* Begin PBXHeadersBuildPhase section */ 319 | BA5511C2136C9E2E0012B9B5 /* Headers */ = { 320 | isa = PBXHeadersBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | C9A43CAC15374DB200388D0C /* alloc_once_private.h in Headers */, 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | /* End PBXHeadersBuildPhase section */ 328 | 329 | /* Begin PBXNativeTarget section */ 330 | BA5511C3136C9E2E0012B9B5 /* System */ = { 331 | isa = PBXNativeTarget; 332 | buildConfigurationList = BA5511C7136C9E2E0012B9B5 /* Build configuration list for PBXNativeTarget "System" */; 333 | buildPhases = ( 334 | BA5511C0136C9E2E0012B9B5 /* Sources */, 335 | BA5511C1136C9E2E0012B9B5 /* Frameworks */, 336 | BA5511C2136C9E2E0012B9B5 /* Headers */, 337 | 8C7F4805264C2545007076D8 /* Install FeatureFlags */, 338 | ); 339 | buildRules = ( 340 | ); 341 | dependencies = ( 342 | 8C3F058A284EB2280040B6D2 /* PBXTargetDependency */, 343 | ); 344 | name = System; 345 | productName = System; 346 | productReference = BA5511C4136C9E2E0012B9B5 /* libSystem.B.dylib */; 347 | productType = "com.apple.product-type.library.dynamic"; 348 | }; 349 | /* End PBXNativeTarget section */ 350 | 351 | /* Begin PBXProject section */ 352 | BA5511A9136C9D400012B9B5 /* Project object */ = { 353 | isa = PBXProject; 354 | attributes = { 355 | LastUpgradeCheck = 0700; 356 | TargetAttributes = { 357 | 923662F4212762D7001FB3E7 = { 358 | CreatedOnToolsVersion = 10.0; 359 | ProvisioningStyle = Automatic; 360 | }; 361 | E47E982E221DFDFC006E312E = { 362 | CreatedOnToolsVersion = 11.0; 363 | }; 364 | E47E9831221DFE23006E312E = { 365 | CreatedOnToolsVersion = 11.0; 366 | }; 367 | }; 368 | }; 369 | buildConfigurationList = BA5511AC136C9D400012B9B5 /* Build configuration list for PBXProject "Libsystem" */; 370 | compatibilityVersion = "Xcode 3.2"; 371 | developmentRegion = English; 372 | hasScannedForEncodings = 0; 373 | knownRegions = ( 374 | English, 375 | en, 376 | ); 377 | mainGroup = BA5511A7136C9D400012B9B5; 378 | productRefGroup = BA5511C5136C9E2E0012B9B5 /* Products */; 379 | projectDirPath = ""; 380 | projectRoot = ""; 381 | targets = ( 382 | E47E9831221DFE23006E312E /* Libsystem */, 383 | E47E982E221DFDFC006E312E /* Libsystem_driverkit */, 384 | 2BBCA223278E5D9600224D15 /* Libsystem_exclavekit */, 385 | BA5511C3136C9E2E0012B9B5 /* System */, 386 | BA5511CF136CA8480012B9B5 /* Generate Linker Arguments */, 387 | BA5511D6136D22ED0012B9B5 /* Generate Symlinks */, 388 | 923662F4212762D7001FB3E7 /* Sanitizer Support */, 389 | ); 390 | }; 391 | /* End PBXProject section */ 392 | 393 | /* Begin PBXShellScriptBuildPhase section */ 394 | 923662FB21276319001FB3E7 /* Run create_asan_override_file.sh */ = { 395 | isa = PBXShellScriptBuildPhase; 396 | buildActionMask = 8; 397 | files = ( 398 | ); 399 | inputFileListPaths = ( 400 | ); 401 | inputPaths = ( 402 | ); 403 | name = "Run create_asan_override_file.sh"; 404 | outputFileListPaths = ( 405 | ); 406 | outputPaths = ( 407 | ); 408 | runOnlyForDeploymentPostprocessing = 1; 409 | shellPath = /bin/sh; 410 | shellScript = "set -x\nset -e\n\n\"${SRCROOT}/xcodescripts/create_asan_override_file.sh\"\n"; 411 | }; 412 | BA2BD8FE136D271D00FF78C0 /* ShellScript */ = { 413 | isa = PBXShellScriptBuildPhase; 414 | buildActionMask = 8; 415 | files = ( 416 | ); 417 | inputPaths = ( 418 | ); 419 | outputPaths = ( 420 | ); 421 | runOnlyForDeploymentPostprocessing = 1; 422 | shellPath = /bin/sh; 423 | shellScript = "set -x\nset -e\n\n\"${SRCROOT}/xcodescripts/create_system_framework.sh\" \"${DSTROOT}\" \"${SRCROOT}\" \"${ACTION}\" \"${ARCHS}\" \"${BUILD_VARIANTS}\"\n"; 424 | }; 425 | BA5511D4136CA8680012B9B5 /* ShellScript */ = { 426 | isa = PBXShellScriptBuildPhase; 427 | buildActionMask = 2147483647; 428 | files = ( 429 | ); 430 | inputPaths = ( 431 | "$(SRCROOT)/optionallibs", 432 | "$(SRCROOT)/requiredlibs", 433 | "$(SRCROOT)/xcodescripts/linker_arguments.sh", 434 | ); 435 | outputPaths = ( 436 | "$(BUILT_PRODUCTS_DIR)/linker_arguments_changed.c", 437 | ); 438 | runOnlyForDeploymentPostprocessing = 0; 439 | shellPath = /bin/sh; 440 | shellScript = "set -x\nset -e\n\n# workaround 48125283\n[ -n \"$DRIVERKIT_DEPLOYMENT_TARGET\" ] && unset MACOSX_DEPLOYMENT_TARGET\n\n\"${SRCROOT}/xcodescripts/linker_arguments.sh\" \"${ARCHS}\" \"${BUILD_VARIANTS}\" \"${BUILT_PRODUCTS_DIR}\" \"${SDKROOT}\" \"${SRCROOT}\"\n"; 441 | }; 442 | BA5511D9136D23110012B9B5 /* ShellScript */ = { 443 | isa = PBXShellScriptBuildPhase; 444 | buildActionMask = 8; 445 | files = ( 446 | ); 447 | inputPaths = ( 448 | ); 449 | outputPaths = ( 450 | ); 451 | runOnlyForDeploymentPostprocessing = 1; 452 | shellPath = /bin/sh; 453 | shellScript = "set -x\nset -e\n\n\"${SRCROOT}/xcodescripts/create_dylib_symlinks.sh\" \"${DSTROOT}\" \"${ACTION}\" \"${BUILD_VARIANTS}\"\n"; 454 | }; 455 | /* End PBXShellScriptBuildPhase section */ 456 | 457 | /* Begin PBXSourcesBuildPhase section */ 458 | BA5511C0136C9E2E0012B9B5 /* Sources */ = { 459 | isa = PBXSourcesBuildPhase; 460 | buildActionMask = 2147483647; 461 | files = ( 462 | BA5511C9136C9E4D0012B9B5 /* CompatibilityHacks.c in Sources */, 463 | BA5511CA136C9E510012B9B5 /* init.c in Sources */, 464 | BA2FABC5136DBF45004383E5 /* linker_arguments_changed.c in Sources */, 465 | ); 466 | runOnlyForDeploymentPostprocessing = 0; 467 | }; 468 | /* End PBXSourcesBuildPhase section */ 469 | 470 | /* Begin PBXTargetDependency section */ 471 | 2BBCA224278E5D9600224D15 /* PBXTargetDependency */ = { 472 | isa = PBXTargetDependency; 473 | target = BA5511D6136D22ED0012B9B5 /* Generate Symlinks */; 474 | targetProxy = 2BBCA225278E5D9600224D15 /* PBXContainerItemProxy */; 475 | }; 476 | 2BBCA226278E5D9600224D15 /* PBXTargetDependency */ = { 477 | isa = PBXTargetDependency; 478 | target = BA5511CF136CA8480012B9B5 /* Generate Linker Arguments */; 479 | targetProxy = 2BBCA227278E5D9600224D15 /* PBXContainerItemProxy */; 480 | }; 481 | 2BBCA228278E5D9600224D15 /* PBXTargetDependency */ = { 482 | isa = PBXTargetDependency; 483 | target = BA5511C3136C9E2E0012B9B5 /* System */; 484 | targetProxy = 2BBCA229278E5D9600224D15 /* PBXContainerItemProxy */; 485 | }; 486 | 8C3F058A284EB2280040B6D2 /* PBXTargetDependency */ = { 487 | isa = PBXTargetDependency; 488 | target = BA5511CF136CA8480012B9B5 /* Generate Linker Arguments */; 489 | targetProxy = 8C3F0589284EB2280040B6D2 /* PBXContainerItemProxy */; 490 | }; 491 | E47E9835221DFE4A006E312E /* PBXTargetDependency */ = { 492 | isa = PBXTargetDependency; 493 | target = 923662F4212762D7001FB3E7 /* Sanitizer Support */; 494 | targetProxy = E47E9834221DFE4A006E312E /* PBXContainerItemProxy */; 495 | }; 496 | E47E9837221DFE4F006E312E /* PBXTargetDependency */ = { 497 | isa = PBXTargetDependency; 498 | target = BA5511D6136D22ED0012B9B5 /* Generate Symlinks */; 499 | targetProxy = E47E9836221DFE4F006E312E /* PBXContainerItemProxy */; 500 | }; 501 | E47E9839221DFE58006E312E /* PBXTargetDependency */ = { 502 | isa = PBXTargetDependency; 503 | target = BA5511CF136CA8480012B9B5 /* Generate Linker Arguments */; 504 | targetProxy = E47E9838221DFE58006E312E /* PBXContainerItemProxy */; 505 | }; 506 | E47E983B221DFE5E006E312E /* PBXTargetDependency */ = { 507 | isa = PBXTargetDependency; 508 | target = BA5511C3136C9E2E0012B9B5 /* System */; 509 | targetProxy = E47E983A221DFE5E006E312E /* PBXContainerItemProxy */; 510 | }; 511 | E47E983D221DFE8B006E312E /* PBXTargetDependency */ = { 512 | isa = PBXTargetDependency; 513 | target = BA5511D6136D22ED0012B9B5 /* Generate Symlinks */; 514 | targetProxy = E47E983C221DFE8B006E312E /* PBXContainerItemProxy */; 515 | }; 516 | E47E983F221DFE90006E312E /* PBXTargetDependency */ = { 517 | isa = PBXTargetDependency; 518 | target = BA5511CF136CA8480012B9B5 /* Generate Linker Arguments */; 519 | targetProxy = E47E983E221DFE90006E312E /* PBXContainerItemProxy */; 520 | }; 521 | E47E9841221DFE94006E312E /* PBXTargetDependency */ = { 522 | isa = PBXTargetDependency; 523 | target = BA5511C3136C9E2E0012B9B5 /* System */; 524 | targetProxy = E47E9840221DFE94006E312E /* PBXContainerItemProxy */; 525 | }; 526 | /* End PBXTargetDependency section */ 527 | 528 | /* Begin XCBuildConfiguration section */ 529 | 2BBCA22B278E5D9600224D15 /* Release */ = { 530 | isa = XCBuildConfiguration; 531 | buildSettings = { 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | }; 534 | name = Release; 535 | }; 536 | 923662F5212762D7001FB3E7 /* Release */ = { 537 | isa = XCBuildConfiguration; 538 | buildSettings = { 539 | CODE_SIGN_STYLE = Automatic; 540 | PRODUCT_NAME = "$(TARGET_NAME)"; 541 | }; 542 | name = Release; 543 | }; 544 | BA5511AF136C9D400012B9B5 /* Release */ = { 545 | isa = XCBuildConfiguration; 546 | baseConfigurationReference = C9B56C55153751A600C153A8 /* Libsystem.xcconfig */; 547 | buildSettings = { 548 | }; 549 | name = Release; 550 | }; 551 | BA5511C6136C9E2E0012B9B5 /* Release */ = { 552 | isa = XCBuildConfiguration; 553 | baseConfigurationReference = C9B56C55153751A600C153A8 /* Libsystem.xcconfig */; 554 | buildSettings = { 555 | PRODUCT_NAME = "$(TARGET_NAME)$(DYLIB_NAME_VERSION_SUFFIX)"; 556 | SDKROOT = macosx.internal; 557 | }; 558 | name = Release; 559 | }; 560 | BA5511D1136CA8480012B9B5 /* Release */ = { 561 | isa = XCBuildConfiguration; 562 | baseConfigurationReference = C9B56C55153751A600C153A8 /* Libsystem.xcconfig */; 563 | buildSettings = { 564 | PRODUCT_NAME = "$(TARGET_NAME)"; 565 | }; 566 | name = Release; 567 | }; 568 | BA5511D8136D22ED0012B9B5 /* Release */ = { 569 | isa = XCBuildConfiguration; 570 | baseConfigurationReference = C9B56C55153751A600C153A8 /* Libsystem.xcconfig */; 571 | buildSettings = { 572 | INSTALLHDRS_SCRIPT_PHASE = YES; 573 | PRODUCT_NAME = "$(TARGET_NAME)"; 574 | }; 575 | name = Release; 576 | }; 577 | E47E982F221DFDFC006E312E /* Release */ = { 578 | isa = XCBuildConfiguration; 579 | buildSettings = { 580 | PRODUCT_NAME = "$(TARGET_NAME)"; 581 | }; 582 | name = Release; 583 | }; 584 | E47E9833221DFE23006E312E /* Release */ = { 585 | isa = XCBuildConfiguration; 586 | buildSettings = { 587 | PRODUCT_NAME = "$(TARGET_NAME)"; 588 | }; 589 | name = Release; 590 | }; 591 | /* End XCBuildConfiguration section */ 592 | 593 | /* Begin XCConfigurationList section */ 594 | 2BBCA22A278E5D9600224D15 /* Build configuration list for PBXAggregateTarget "Libsystem_exclavekit" */ = { 595 | isa = XCConfigurationList; 596 | buildConfigurations = ( 597 | 2BBCA22B278E5D9600224D15 /* Release */, 598 | ); 599 | defaultConfigurationIsVisible = 0; 600 | defaultConfigurationName = Release; 601 | }; 602 | 923662F6212762D7001FB3E7 /* Build configuration list for PBXAggregateTarget "Sanitizer Support" */ = { 603 | isa = XCConfigurationList; 604 | buildConfigurations = ( 605 | 923662F5212762D7001FB3E7 /* Release */, 606 | ); 607 | defaultConfigurationIsVisible = 0; 608 | defaultConfigurationName = Release; 609 | }; 610 | BA5511AC136C9D400012B9B5 /* Build configuration list for PBXProject "Libsystem" */ = { 611 | isa = XCConfigurationList; 612 | buildConfigurations = ( 613 | BA5511AF136C9D400012B9B5 /* Release */, 614 | ); 615 | defaultConfigurationIsVisible = 0; 616 | defaultConfigurationName = Release; 617 | }; 618 | BA5511C7136C9E2E0012B9B5 /* Build configuration list for PBXNativeTarget "System" */ = { 619 | isa = XCConfigurationList; 620 | buildConfigurations = ( 621 | BA5511C6136C9E2E0012B9B5 /* Release */, 622 | ); 623 | defaultConfigurationIsVisible = 0; 624 | defaultConfigurationName = Release; 625 | }; 626 | BA5511D0136CA8480012B9B5 /* Build configuration list for PBXAggregateTarget "Generate Linker Arguments" */ = { 627 | isa = XCConfigurationList; 628 | buildConfigurations = ( 629 | BA5511D1136CA8480012B9B5 /* Release */, 630 | ); 631 | defaultConfigurationIsVisible = 0; 632 | defaultConfigurationName = Release; 633 | }; 634 | BA5511D7136D22ED0012B9B5 /* Build configuration list for PBXAggregateTarget "Generate Symlinks" */ = { 635 | isa = XCConfigurationList; 636 | buildConfigurations = ( 637 | BA5511D8136D22ED0012B9B5 /* Release */, 638 | ); 639 | defaultConfigurationIsVisible = 0; 640 | defaultConfigurationName = Release; 641 | }; 642 | E47E9830221DFDFC006E312E /* Build configuration list for PBXAggregateTarget "Libsystem_driverkit" */ = { 643 | isa = XCConfigurationList; 644 | buildConfigurations = ( 645 | E47E982F221DFDFC006E312E /* Release */, 646 | ); 647 | defaultConfigurationIsVisible = 0; 648 | defaultConfigurationName = Release; 649 | }; 650 | E47E9832221DFE23006E312E /* Build configuration list for PBXAggregateTarget "Libsystem" */ = { 651 | isa = XCConfigurationList; 652 | buildConfigurations = ( 653 | E47E9833221DFE23006E312E /* Release */, 654 | ); 655 | defaultConfigurationIsVisible = 0; 656 | defaultConfigurationName = Release; 657 | }; 658 | /* End XCConfigurationList section */ 659 | }; 660 | rootObject = BA5511A9136C9D400012B9B5 /* Project object */; 661 | } 662 | -------------------------------------------------------------------------------- /Libsystem.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /alloc_once_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #ifndef __OS_ALLOC__ 30 | #define __OS_ALLOC__ 31 | 32 | #ifndef __OS_ALLOC_INDIRECT__ 33 | #define __OS_ALLOC_INDIRECT__ 34 | #endif // __OS_ALLOC_INDIRECT__ 35 | 36 | #include 37 | 38 | /* Keys for use with os_once_alloc. */ 39 | 40 | /* Keys for Libsystem. */ 41 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_NOTIFY 0 42 | #define OS_ALLOC_ONCE_KEY_LIBXPC 1 43 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_C 2 44 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_INFO 3 45 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_NETWORK 4 46 | #define OS_ALLOC_ONCE_KEY_LIBCACHE 5 47 | #define OS_ALLOC_ONCE_KEY_LIBCOMMONCRYPTO 6 48 | #define OS_ALLOC_ONCE_KEY_LIBDISPATCH 7 49 | #define OS_ALLOC_ONCE_KEY_LIBDYLD 8 50 | #define OS_ALLOC_ONCE_KEY_LIBKEYMGR 9 51 | #define OS_ALLOC_ONCE_KEY_LIBLAUNCH 10 52 | #define OS_ALLOC_ONCE_KEY_LIBMACHO 11 53 | #define OS_ALLOC_ONCE_KEY_OS_TRACE 12 54 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_BLOCKS 13 55 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_MALLOC 14 56 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_PLATFORM 15 57 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_PTHREAD 16 58 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_STATS 17 59 | #define OS_ALLOC_ONCE_KEY_LIBSECINIT 18 60 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_CORESERVICES 19 61 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_SYMPTOMS 20 62 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_PLATFORM_ASL 21 63 | #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_FEATUREFLAGS 22 64 | 65 | /* Keys OS_ALLOC_ONCE_KEY_MAX - 10 upwards are reserved for the system. */ 66 | #define OS_ALLOC_ONCE_KEY_RESERVED_0 (OS_ALLOC_ONCE_KEY_MAX - 10) 67 | #define OS_ALLOC_ONCE_KEY_RESERVED_1 (OS_ALLOC_ONCE_KEY_MAX - 9) 68 | #define OS_ALLOC_ONCE_KEY_RESERVED_2 (OS_ALLOC_ONCE_KEY_MAX - 8) 69 | #define OS_ALLOC_ONCE_KEY_RESERVED_3 (OS_ALLOC_ONCE_KEY_MAX - 7) 70 | #define OS_ALLOC_ONCE_KEY_RESERVED_4 (OS_ALLOC_ONCE_KEY_MAX - 6) 71 | #define OS_ALLOC_ONCE_KEY_RESERVED_5 (OS_ALLOC_ONCE_KEY_MAX - 5) 72 | #define OS_ALLOC_ONCE_KEY_RESERVED_6 (OS_ALLOC_ONCE_KEY_MAX - 4) 73 | #define OS_ALLOC_ONCE_KEY_RESERVED_7 (OS_ALLOC_ONCE_KEY_MAX - 3) 74 | #define OS_ALLOC_ONCE_KEY_RESERVED_8 (OS_ALLOC_ONCE_KEY_MAX - 2) 75 | #define OS_ALLOC_ONCE_KEY_RESERVED_9 (OS_ALLOC_ONCE_KEY_MAX - 1) 76 | 77 | /* OS_ALLOC_ONCE_KEY_MAX cannot be used. */ 78 | 79 | #endif // __OS_ALLOC__ 80 | -------------------------------------------------------------------------------- /enable_asan_mode: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ASAN_HALT_ON_ERROR=0 4 | ASAN_START_DEACTIVATED=1 5 | DARWINUP_OPTIONS=() 6 | LIBSYSTEM_B="/usr/lib/libSystem.B.dylib" 7 | LIBSYSTEM_B_ASAN="/usr/lib/libSystem.B_asan.dylib" 8 | # Use long name to reduce possibility of collision with other roots. 9 | ROOT_TMP=/tmp/___tmp_whole_os_asan_root___from_enable_asan_mode_script 10 | ROOT_NAME="$(basename "${ROOT_TMP}")" 11 | VERBOSE=0 12 | 13 | function usage() { 14 | echo "Usage:" 15 | echo "$0 [OPTIONS] " 16 | echo "$0 --help" 17 | echo "" 18 | echo " is one of the following:" 19 | echo "" 20 | echo "enable - Enables Whole OS ASan mode on the system" 21 | echo "disable - Disables Whole OS ASan mode on the system" 22 | echo "" 23 | echo "OPTIONS" 24 | echo "" 25 | echo "--help" 26 | echo "--halt-on-error " 27 | echo " Set ASan's halt_on_error option (default: ${ASAN_HALT_ON_ERROR})" 28 | echo "" 29 | echo "--start-deactivated " 30 | echo " Set ASan's start_deactivated option (default: ${ASAN_START_DEACTIVATED})" 31 | echo "" 32 | echo "--verbose" 33 | echo "" 34 | echo "DESCRIPTION" 35 | echo "" 36 | echo "This script puts the device into \"Whole OS ASan mode\" where ASan is loaded" 37 | echo "into most userspace processes." 38 | echo "" 39 | } 40 | 41 | function root_user_check() { 42 | if [[ $(id -u) != 0 ]]; then echo "Must be run as root." 1>&2; exit 1; fi 43 | } 44 | 45 | function create_root() { 46 | # This function generates a root on-the-fly in a temporary directory. 47 | # The intention is that this root is installable using darwinup. 48 | root_user_check 49 | 50 | RSYNC_OPTIONS=() 51 | if [ "${VERBOSE}" -ne 0 ]; then 52 | RSYNC_OPTIONS+=( \ 53 | "--progress" \ 54 | "--human-readable" \ 55 | ) 56 | fi 57 | 58 | rm -rf "${ROOT_TMP}" 59 | mkdir -p "${ROOT_TMP}" 60 | # Use rsync so we preserve the right ownership and permissions set. 61 | rsync --archive --relative "${RSYNC_OPTIONS[@]}" \ 62 | /usr/lib/libSystem.B_asan.dylib \ 63 | "${ROOT_TMP}" 64 | 65 | # Move the ASan variant into the location of the normal variant. 66 | mv "${ROOT_TMP}/${LIBSYSTEM_B_ASAN}" "${ROOT_TMP}/${LIBSYSTEM_B}" 67 | 68 | # If this file is present on the system and we are using a development build 69 | # then the usual memory resource limits won't be applied. 70 | # rdar://problem/43520116 71 | DISABLE_MEM_LIMIT_COOKIE_FILE="/usr/local/share/launchd-disable-memory-limits" 72 | DISABLE_MEM_LIMIT_COOKIE_CONTENTS="kEnableAsanDisableMemLimit" 73 | 74 | DISABLE_MEM_LIMIT_COOKIE_DIR="$(dirname "${DISABLE_MEM_LIMIT_COOKIE_FILE}")" 75 | mkdir -p "${ROOT_TMP}/${DISABLE_MEM_LIMIT_COOKIE_DIR}" 76 | echo "${DISABLE_MEM_LIMIT_COOKIE_CONTENTS}" > "${ROOT_TMP}/${DISABLE_MEM_LIMIT_COOKIE_FILE}" 77 | 78 | # Set ASan options 79 | # TODO(dliew): rdar://problem/73592766 80 | ASAN_OPTIONS_FILE_PATH="/System/Library/Preferences/com.apple.asan.options" 81 | ASAN_OPTIONS="color=never:handle_segv=0:handle_sigbus=0:handle_sigill=0:handle_sigfpe=0:external_symbolizer_path=:log_path=stderr:log_exe_name=0:print_module_map=2:detect_odr_violation=0:start_deactivated=1:halt_on_error=0" 82 | 83 | # Patch options based on script settings. 84 | if [ "X$(echo "${ASAN_OPTIONS}" | grep -c "start_deactivated")" != "X1" ]; then 85 | echo "INTERNAL ERROR: start_deactivated not in ASAN_OPTIONS" 2>&1 86 | exit 1 87 | fi 88 | if [ "X$(echo "${ASAN_OPTIONS}" | grep -c "halt_on_error")" != "X1" ]; then 89 | echo "INTERNAL ERROR: halt_on_error not in ASAN_OPTIONS" 2>&1 90 | exit 1 91 | fi 92 | ASAN_OPTIONS=$(echo "${ASAN_OPTIONS}" | \ 93 | sed -E "s/start_deactivated=[0-9]+/start_deactivated=${ASAN_START_DEACTIVATED}/;s/halt_on_error=[0-9]+/halt_on_error=${ASAN_HALT_ON_ERROR}/") 94 | 95 | ASAN_OPTIONS_FILE_DIR="$(dirname "${ASAN_OPTIONS_FILE_PATH}")" 96 | mkdir -p "${ROOT_TMP}/${ASAN_OPTIONS_FILE_DIR}" 97 | [ ${VERBOSE} -ne 0 ] && echo "Setting ASan options: ${ASAN_OPTIONS}" 98 | echo "${ASAN_OPTIONS}" > "${ROOT_TMP}/${ASAN_OPTIONS_FILE_PATH}" 99 | 100 | if [ ${VERBOSE} -ne 0 ]; then 101 | echo "Created root at \"${ROOT_TMP}\"" 102 | fi 103 | } 104 | 105 | function install_root() { 106 | root_user_check 107 | if [ ${VERBOSE} -ne 0 ]; then 108 | echo "Installing root \"${ROOT_TMP}\"" 109 | fi 110 | darwinup "${DARWINUP_OPTIONS[@]}" install "${ROOT_TMP}" 111 | } 112 | 113 | function is_root_installed() { 114 | DARWINUP_OUTPUT=$(darwinup list "${ROOT_NAME}" | grep -c "${ROOT_NAME}") 115 | if [ "${DARWINUP_OUTPUT}" = "0" ]; then 116 | echo "0" 117 | else 118 | echo "1" 119 | fi 120 | } 121 | 122 | function remove_root() { 123 | root_user_check 124 | if [ ${VERBOSE} -ne 0 ]; then 125 | echo "Uninstalling root \"${ROOT_NAME}\"" 126 | fi 127 | darwinup "${DARWINUP_OPTIONS[@]}" uninstall "${ROOT_NAME}" 128 | } 129 | 130 | function enable_asan_mode() { 131 | if [ "$(is_root_installed)" -eq 1 ]; then 132 | echo "ASan mode is already enabled." 2>&1 133 | exit 1 134 | fi 135 | create_root 136 | install_root 137 | echo "Root installed. You should now reboot." 138 | } 139 | 140 | function disable_asan_mode() { 141 | if [ "$(is_root_installed)" -eq 0 ]; then 142 | echo "ASan mode is already disabled." 2>&1 143 | exit 1 144 | fi 145 | remove_root 146 | echo "Root removed. You should now reboot." 147 | } 148 | 149 | function status_asan_mode() { 150 | if [ "$(is_root_installed)" -eq 1 ]; then 151 | echo "ASan mode is enabled." 152 | else 153 | echo "ASan mode is disabled." 154 | fi 155 | } 156 | 157 | function parse_bool() { 158 | if [ $# -ne 3 ]; then 159 | echo "INTERNAL ERROR: Wrong number of args parsed" 2>&1 160 | exit 1 161 | fi 162 | VALUE="$1" 163 | DEST_VAR="$2" 164 | CONSUMER_ARG="$3" 165 | if [ -z "${VALUE}" ]; then 166 | echo "Value passed to ${CONSUMER_ARG} cannot be empty" 2>&1 167 | exit 1 168 | fi 169 | DEST_VALUE="" 170 | if [ "${VALUE}" = "1" ]; then 171 | DEST_VALUE=1 172 | elif [ "${VALUE}" = "0" ]; then 173 | DEST_VALUE=0 174 | else 175 | echo "${CONSUMER_ARG} passed value \"${VALUE}\" which is not a boolean" 2>&1 176 | exit 1 177 | fi 178 | eval ${DEST_VAR}="${DEST_VALUE}" 179 | } 180 | 181 | # Begin 182 | 183 | # Parse options 184 | if [ $# -lt 1 ]; then 185 | echo "At least one argument must be provided" 2>&1 186 | usage 187 | exit 1 188 | fi 189 | 190 | # Parse args 191 | ACTION="" 192 | while [ $# -ne 0 ]; do 193 | case "$1" in 194 | --halt-on-error) 195 | shift 196 | parse_bool "$1" ASAN_HALT_ON_ERROR "--halt-on-error" 197 | ;; 198 | --help) 199 | usage 200 | exit 0 201 | ;; 202 | --start-deactivated) 203 | shift 204 | parse_bool "$1" ASAN_START_DEACTIVATED "--start-deactivated" 205 | ;; 206 | -v|--verbose) 207 | VERBOSE=1 208 | ;; 209 | *) 210 | # If last arg parse as action 211 | if [ $# -eq 1 ]; then 212 | ACTION="${1}" 213 | else 214 | echo "Unrecognised option \"${1}\"" 2>&1 215 | exit 1 216 | fi 217 | ;; 218 | esac 219 | shift 220 | done 221 | 222 | if [ ${VERBOSE} -ne 0 ]; then 223 | DARWINUP_OPTIONS+=(-v) 224 | set -x 225 | fi 226 | 227 | # Do action 228 | case "${ACTION}" in 229 | enable) 230 | enable_asan_mode 231 | ;; 232 | disable) 233 | disable_asan_mode 234 | ;; 235 | status) 236 | status_asan_mode 237 | ;; 238 | *) 239 | echo "Unknown action \"${ACTION}\"" 2>&1 240 | exit 1 241 | ;; 242 | esac 243 | 244 | exit 0 245 | -------------------------------------------------------------------------------- /featureflags/Libsystem.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | posix_spawn_filtering 6 | 7 | Enabled 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, 2011-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | #include // for TARGET_OS_* 30 | #include 31 | 32 | #if !TARGET_OS_EXCLAVEKIT 33 | 34 | #include 35 | #include 36 | #include 37 | #include <_libc_init.h> 38 | #include 39 | #include 40 | #if !TARGET_OS_DRIVERKIT 41 | #include 42 | #include 43 | #include 44 | #include 45 | #endif 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include <_libkernel_init.h> // Must be after voucher_private.h 51 | #include 52 | 53 | #if TARGET_OS_DRIVERKIT 54 | #include 55 | #endif 56 | 57 | #ifndef HAVE_DUET_PREWARM 58 | #define HAVE_DUET_PREWARM (!TARGET_OS_DRIVERKIT && (TARGET_OS_IOS || TARGET_OS_TV)) 59 | #endif 60 | 61 | #if HAVE_DUET_PREWARM 62 | #include <_simple.h> 63 | #include 64 | #endif 65 | 66 | #include 67 | 68 | // system library initialisers 69 | extern void mach_init(void); // from libsystem_kernel.dylib 70 | extern void __libplatform_init(void *future_use, const char *envp[], const char *apple[], const struct ProgramVars *vars); 71 | extern void __pthread_init(const struct _libpthread_functions *libpthread_funcs, const char *envp[], const char *apple[], const struct ProgramVars *vars); // from libsystem_pthread.dylib 72 | extern void __pthread_late_init(const char *envp[], const char *apple[], const struct ProgramVars *vars); // from libsystem_pthread.dylib 73 | extern void _sanitizers_init(const char *envp[], const char *apple[]); // from libsanitizers.dylib 74 | extern void __malloc_init(const char *apple[]); // from libsystem_malloc.dylib 75 | extern void _dyld_initializer(void); // from libdyld.dylib 76 | extern void libdispatch_init(void); // from libdispatch.dylib 77 | extern void _libxpc_initializer(void); // from libxpc.dylib 78 | extern void _libsecinit_initializer(void); // from libsecinit.dylib 79 | extern void _libtrace_init(void); // from libsystem_trace.dylib 80 | extern void _container_init(const char *apple[]); // from libsystem_containermanager.dylib 81 | extern void __libdarwin_init(void); // from libsystem_darwin.dylib 82 | 83 | 84 | // clear qos tsd (from pthread) 85 | extern void _pthread_clear_qos_tsd(mach_port_t) __attribute__((weak_import)); 86 | 87 | // system library atfork handlers 88 | extern void _pthread_atfork_prepare(void); 89 | extern void _pthread_atfork_parent(void); 90 | extern void _pthread_atfork_child(void); 91 | extern void _pthread_atfork_prepare_handlers(); 92 | extern void _pthread_atfork_parent_handlers(void); 93 | extern void _pthread_atfork_child_handlers(void); 94 | extern void _pthread_exit_if_canceled(int); 95 | 96 | extern void dispatch_atfork_prepare(void); 97 | extern void dispatch_atfork_parent(void); 98 | extern void dispatch_atfork_child(void); 99 | 100 | extern void _libtrace_fork_child(void); 101 | 102 | extern void _malloc_fork_prepare(void); 103 | extern void _malloc_fork_parent(void); 104 | extern void _malloc_fork_child(void); 105 | 106 | extern void _mach_fork_child(void); 107 | extern void _notify_fork_child(void); 108 | extern void _dyld_atfork_prepare(void); 109 | extern void _dyld_atfork_parent(void); 110 | extern void _dyld_fork_child(void); 111 | extern void _dyld_dlopen_atfork_prepare(void); 112 | extern void _dyld_dlopen_atfork_parent(void); 113 | extern void _dyld_dlopen_atfork_child(void); 114 | extern void xpc_atfork_prepare(void); 115 | extern void xpc_atfork_parent(void); 116 | extern void xpc_atfork_child(void); 117 | extern void _libSC_info_fork_prepare(void); 118 | extern void _libSC_info_fork_parent(void); 119 | extern void _libSC_info_fork_child(void); 120 | extern void _asl_fork_child(void); 121 | 122 | #if defined(HAVE_SYSTEM_CORESERVICES) 123 | // libsystem_coreservices.dylib 124 | extern void _libcoreservices_fork_child(void); 125 | extern char *_dirhelper(int, char *, size_t); 126 | #endif 127 | 128 | // advance decls for below; 129 | static void libSystem_atfork_prepare(unsigned int flags, ...); 130 | static void libSystem_atfork_parent(unsigned int flags, ...); 131 | static void libSystem_atfork_child(unsigned int flags, ...); 132 | 133 | static inline void __end_prewarm(const char* envp[]); 134 | 135 | __attribute__((__visibility__("default"))) void libSystem_init_after_boot_tasks_4launchd(void); 136 | 137 | // should_enable_posix_spawn_filtering can only be used after 138 | // _libxpc_initializer() has run 139 | #define should_enable_posix_spawn_filtering() \ 140 | (os_variant_allows_internal_security_policies("com.apple.libsystem") && \ 141 | os_feature_enabled(Libsystem, posix_spawn_filtering)) 142 | 143 | #if SUPPORT_ASAN 144 | const char *__asan_default_options(void); 145 | #endif 146 | 147 | static inline void 148 | _libSystem_ktrace4(uint32_t code, uint64_t a, uint64_t b, uint64_t c, uint64_t d) 149 | { 150 | if (__builtin_expect(*(volatile uint32_t *)_COMM_PAGE_KDEBUG_ENABLE == 0, 1)) return; 151 | kdebug_trace(code, a, b, c, d); 152 | } 153 | #define _libSystem_ktrace3(code, a, b, c) _libSystem_ktrace4(code, a, b, c, 0) 154 | #define _libSystem_ktrace2(code, a, b) _libSystem_ktrace4(code, a, b, 0, 0) 155 | #define _libSystem_ktrace1(code, a) _libSystem_ktrace4(code, a, 0, 0, 0) 156 | #define _libSystem_ktrace0(code) _libSystem_ktrace4(code, 0, 0, 0, 0) 157 | 158 | /* 159 | * these define stable Ariadne tracepoints. If initializers are removed, or 160 | * added, then old tracepoints MUST NOT be recycled. 161 | */ 162 | enum { 163 | ARIADNE_LIFECYCLE_libsystem_init = ARIADNEDBG_CODE(220, 4), 164 | }; 165 | 166 | /* 167 | * These represent the initializer "name" 168 | * 169 | * They happen to match the order of the initializers at some point in time, 170 | * but there's no guarantee made that traecepoints will appear in numerical 171 | * order. As initializers come and go, new codes shall be allocated, 172 | * and no slots reused. 173 | */ 174 | enum init_func { 175 | INIT_SYSTEM = 0, 176 | INIT_KERNEL = 1, 177 | INIT_PLATFORM = 2, 178 | INIT_PTHREAD = 3, 179 | INIT_LIBC = 4, 180 | INIT_MALLOC = 5, 181 | /* INIT_KEYMGR = 6, */ 182 | INIT_DYLD = 7, 183 | INIT_LIBDISPATCH = 8, 184 | INIT_LIBXPC = 9, 185 | INIT_LIBTRACE = 10, 186 | INIT_SECINIT = 11, 187 | INIT_CONTAINERMGR = 12, 188 | INIT_DARWIN = 13, 189 | INIT_SANITIZERS = 14, 190 | }; 191 | 192 | #define _libSystem_ktrace_init_func(what) \ 193 | _libSystem_ktrace1(ARIADNE_LIFECYCLE_libsystem_init | DBG_FUNC_NONE, INIT_##what) 194 | 195 | 196 | #if TARGET_OS_DRIVERKIT 197 | 198 | __attribute__((weak_import)) void msl_initialize(void); 199 | 200 | __attribute__((noinline)) 201 | static struct _malloc_msl_symbols* 202 | fill_msl_symbols(struct _malloc_msl_symbols *msl_symbols) { 203 | if (&msl_initialize == NULL) { 204 | return NULL; 205 | } 206 | *msl_symbols = (struct _malloc_msl_symbols){ 207 | .version = 1, 208 | .handle_memory_event = &msl_handle_memory_event, 209 | .stack_logging_locked = &msl_stack_logging_locked, 210 | .fork_prepare = &msl_fork_prepare, 211 | .fork_child = &msl_fork_child, 212 | .fork_parent = &msl_fork_parent, 213 | //stack_logging_mode_type and stack_logging_mode_t are identical 214 | .turn_on_stack_logging = (boolean_t (*) (stack_logging_mode_type type))&msl_turn_on_stack_logging, 215 | .turn_off_stack_logging = &msl_turn_off_stack_logging, 216 | .set_flags_from_environment = &msl_set_flags_from_environment, 217 | .initialize = &msl_initialize, 218 | .copy_msl_lite_hooks = &msl_copy_msl_lite_hooks, 219 | }; 220 | return msl_symbols; 221 | } 222 | #endif 223 | 224 | 225 | // libsyscall_initializer() initializes all of libSystem.dylib 226 | // 227 | __attribute__((constructor)) 228 | static void 229 | libSystem_initializer(int argc, 230 | const char* argv[], 231 | const char* envp[], 232 | const char* apple[], 233 | const struct ProgramVars* vars) 234 | { 235 | static const struct _libkernel_functions libkernel_funcs = { 236 | .version = 5, 237 | // V1 functions 238 | #if !TARGET_OS_DRIVERKIT 239 | .dlsym = dlsym, 240 | #endif 241 | .malloc = malloc, 242 | .free = free, 243 | .realloc = realloc, 244 | ._pthread_exit_if_canceled = _pthread_exit_if_canceled, 245 | // V2 functions (removed) 246 | // V3 functions 247 | .pthread_clear_qos_tsd = _pthread_clear_qos_tsd, 248 | // V4 functions 249 | .pthread_current_stack_contains_np = pthread_current_stack_contains_np, 250 | #if defined(_MALLOC_TYPE_AVAILABILITY) 251 | // V5 functions 252 | .malloc_type_malloc = malloc_type_malloc, 253 | .malloc_type_free = malloc_type_free, 254 | .malloc_type_realloc = malloc_type_realloc, 255 | #endif 256 | }; 257 | 258 | static const struct _libpthread_functions libpthread_funcs = { 259 | .version = 2, 260 | .exit = exit, 261 | .malloc = malloc, 262 | .free = free, 263 | }; 264 | 265 | static const struct _libc_functions libc_funcs = { 266 | .version = 2, 267 | #if defined(HAVE_SYSTEM_CORESERVICES) 268 | .dirhelper = _dirhelper, 269 | #endif 270 | .atfork_prepare_v2 = libSystem_atfork_prepare, 271 | .atfork_parent_v2 = libSystem_atfork_parent, 272 | .atfork_child_v2 = libSystem_atfork_child, 273 | }; 274 | 275 | _libSystem_ktrace0(ARIADNE_LIFECYCLE_libsystem_init | DBG_FUNC_START); 276 | 277 | __libkernel_init(&libkernel_funcs, envp, apple, vars); 278 | _libSystem_ktrace_init_func(KERNEL); 279 | 280 | __libplatform_init(NULL, envp, apple, vars); 281 | _libSystem_ktrace_init_func(PLATFORM); 282 | 283 | __pthread_init(&libpthread_funcs, envp, apple, vars); 284 | _libSystem_ktrace_init_func(PTHREAD); 285 | 286 | _libc_initializer(&libc_funcs, envp, apple, vars); 287 | _libSystem_ktrace_init_func(LIBC); 288 | 289 | #if !TARGET_OS_DRIVERKIT 290 | _sanitizers_init(envp, apple); 291 | _libSystem_ktrace_init_func(SANITIZERS); 292 | #endif 293 | 294 | // TODO: Move __malloc_init before __libc_init after breaking malloc's upward link to Libc 295 | // Note that __malloc_init() will also initialize ASAN when it is present 296 | __malloc_init(apple); 297 | _libSystem_ktrace_init_func(MALLOC); 298 | 299 | _dyld_initializer(); 300 | _libSystem_ktrace_init_func(DYLD); 301 | 302 | #if TARGET_OS_OSX || TARGET_OS_IOS 303 | __pthread_late_init(envp, apple, vars); 304 | #endif 305 | 306 | libdispatch_init(); 307 | _libSystem_ktrace_init_func(LIBDISPATCH); 308 | 309 | #if !TARGET_OS_DRIVERKIT 310 | _libxpc_initializer(); 311 | _libSystem_ktrace_init_func(LIBXPC); 312 | 313 | #if SUPPORT_ASAN 314 | setenv("DT_BYPASS_LEAKS_CHECK", "1", 1); 315 | #endif 316 | #endif // !TARGET_OS_DRIVERKIT 317 | 318 | // must be initialized after dispatch 319 | _libtrace_init(); 320 | _libSystem_ktrace_init_func(LIBTRACE); 321 | 322 | #if !TARGET_OS_DRIVERKIT 323 | #if defined(HAVE_SYSTEM_SECINIT) 324 | _libsecinit_initializer(); 325 | _libSystem_ktrace_init_func(SECINIT); 326 | #endif 327 | 328 | #if defined(HAVE_SYSTEM_CONTAINERMANAGER) 329 | _container_init(apple); 330 | _libSystem_ktrace_init_func(CONTAINERMGR); 331 | #endif 332 | 333 | __libdarwin_init(); 334 | _libSystem_ktrace_init_func(DARWIN); 335 | #endif // !TARGET_OS_DRIVERKIT 336 | 337 | 338 | #if TARGET_OS_DRIVERKIT 339 | struct _malloc_msl_symbols msl_symbols_buf = {}; 340 | const struct _malloc_msl_symbols *msl_symbols = fill_msl_symbols(&msl_symbols_buf); 341 | #endif 342 | 343 | const struct _malloc_late_init mli = { 344 | .version = 2, 345 | #if !TARGET_OS_DRIVERKIT 346 | .dlopen = dlopen, 347 | .dlsym = dlsym, 348 | // this must come after _libxpc_initializer() 349 | .internal_diagnostics = os_variant_has_internal_diagnostics("com.apple.libsystem"), 350 | #else 351 | .msl = msl_symbols, 352 | #endif 353 | }; 354 | 355 | __malloc_late_init(&mli); 356 | 357 | #if !TARGET_OS_IPHONE 358 | /* - Preserve the old behavior of apple[] for 359 | * programs that haven't linked against newer SDK. 360 | */ 361 | #define APPLE0_PREFIX "executable_path=" 362 | if (dyld_get_program_sdk_version() < DYLD_MACOSX_VERSION_10_11){ 363 | if (strncmp(apple[0], APPLE0_PREFIX, strlen(APPLE0_PREFIX)) == 0){ 364 | apple[0] = apple[0] + strlen(APPLE0_PREFIX); 365 | } 366 | } 367 | #endif 368 | 369 | #if TARGET_OS_OSX || POSIX_SPAWN_FILTERING_ENABLED 370 | bool enable_system_version_compat = false; 371 | bool enable_ios_version_compat = false; 372 | bool enable_posix_spawn_filtering = false; 373 | #endif // TARGET_OS_OSX || POSIX_SPAWN_FILTERING_ENABLED 374 | 375 | #if TARGET_OS_OSX 376 | char *system_version_compat_override = getenv("SYSTEM_VERSION_COMPAT"); 377 | if (system_version_compat_override != NULL) { 378 | long override = strtol(system_version_compat_override, NULL, 0); 379 | if (override == 1) { 380 | enable_system_version_compat = true; 381 | } else if (override == 2) { 382 | enable_ios_version_compat = true; 383 | } 384 | } else if (dyld_get_active_platform() == PLATFORM_MACCATALYST) { 385 | if (!dyld_program_sdk_at_least(dyld_platform_version_iOS_14_0)) { 386 | enable_system_version_compat = true; 387 | } 388 | } else if (dyld_get_active_platform() == PLATFORM_IOS) { 389 | enable_ios_version_compat = true; 390 | } else if (!dyld_program_sdk_at_least(dyld_platform_version_macOS_10_16)) { 391 | enable_system_version_compat = true; 392 | } 393 | #endif // TARGET_OS_OSX 394 | 395 | #if POSIX_SPAWN_FILTERING_ENABLED 396 | /* 397 | * In launchd (pid 1), feature flags are not available here because the data 398 | * volume is not mounted yet. We'll query posix_spawn_filtering via the 399 | * libSystem_init_after_boot_tasks_4launchd call below instead. 400 | */ 401 | if (getpid() != 1 && should_enable_posix_spawn_filtering()) { 402 | enable_posix_spawn_filtering = true; 403 | } 404 | #endif // POSIX_SPAWN_FILTERING_ENABLED 405 | 406 | #if TARGET_OS_OSX || POSIX_SPAWN_FILTERING_ENABLED 407 | if (enable_system_version_compat || enable_ios_version_compat || enable_posix_spawn_filtering) { 408 | struct _libkernel_late_init_config config = { 409 | .version = 3, 410 | .enable_system_version_compat = enable_system_version_compat, 411 | .enable_ios_version_compat = enable_ios_version_compat, 412 | .enable_posix_spawn_filtering = enable_posix_spawn_filtering, 413 | }; 414 | __libkernel_init_late(&config); 415 | } 416 | #else // TARGET_OS_OSX || POSIX_SPAWN_FILTERING_ENABLED 417 | #endif // TARGET_OS_OSX || POSIX_SPAWN_FILTERING_ENABLED 418 | 419 | __end_prewarm(envp); 420 | 421 | _libSystem_ktrace0(ARIADNE_LIFECYCLE_libsystem_init | DBG_FUNC_END); 422 | 423 | /* 424 | * C99 standard has the following in section 7.5(3): 425 | * "The value of errno is zero at program startup, but is never set 426 | * to zero by any library function." 427 | */ 428 | errno = 0; 429 | } 430 | 431 | extern __attribute__((__visibility__("default"))) 432 | void 433 | libSystem_init_after_boot_tasks_4launchd() 434 | { 435 | #if POSIX_SPAWN_FILTERING_ENABLED 436 | if (should_enable_posix_spawn_filtering()) { 437 | struct _libkernel_init_after_boot_tasks_config config = { 438 | .version = 1, 439 | .enable_posix_spawn_filtering = true, 440 | }; 441 | __libkernel_init_after_boot_tasks(&config); 442 | } 443 | #endif // POSIX_SPAWN_FILTERING_ENABLED 444 | } 445 | 446 | /* 447 | * libSystem_atfork_{prepare,parent,child}() are called by libc during fork(2) 448 | * and vfork(2) now that vfork is just an alias for fork - but vfork doesn't 449 | * call API pthread_atfork handlers, only the Libsystem-internal handlers. 450 | */ 451 | static void 452 | libSystem_atfork_prepare(unsigned int flags, ...) 453 | { 454 | // dlopen has to be done first, before even the pthread handlers. 455 | // This is to prevent callbacks/initializers in dlopen'ed code from 456 | // deadlocking with everything else. We hope nobody registers a 457 | // pthread_atfork handler that calls dlopen. 458 | _dyld_dlopen_atfork_prepare(); 459 | 460 | if ((flags & LIBSYSTEM_ATFORK_HANDLERS_ONLY_FLAG) == 0) { 461 | // second call client prepare handlers registered with pthread_atfork() 462 | _pthread_atfork_prepare_handlers(); 463 | } 464 | 465 | // third call hardwired fork prepare handlers for Libsystem components 466 | // in the _reverse_ order of library initalization above 467 | #if !TARGET_OS_DRIVERKIT 468 | _libSC_info_fork_prepare(); 469 | xpc_atfork_prepare(); 470 | #endif // !TARGET_OS_DRIVERKIT 471 | dispatch_atfork_prepare(); 472 | _dyld_atfork_prepare(); 473 | _malloc_fork_prepare(); 474 | cc_atfork_prepare(); 475 | _libc_fork_prepare(); 476 | _pthread_atfork_prepare(); 477 | } 478 | 479 | static void 480 | libSystem_atfork_parent(unsigned int flags, ...) 481 | { 482 | // first call hardwired fork parent handlers for Libsystem components 483 | // in the order of library initalization above 484 | _pthread_atfork_parent(); 485 | cc_atfork_parent(); 486 | _malloc_fork_parent(); 487 | _libc_fork_parent(); 488 | _dyld_atfork_parent(); 489 | dispatch_atfork_parent(); 490 | #if !TARGET_OS_DRIVERKIT 491 | xpc_atfork_parent(); 492 | _libSC_info_fork_parent(); 493 | #endif // !TARGET_OS_DRIVERKIT 494 | 495 | // second dlopen 496 | // Note that this is not in the reverse order from prepare() 497 | // This is to avoid deadlock with third-party pthread handlers. 498 | // The thinking being that we should fully handle all libSystem code 499 | // then jump to third-party code 500 | _dyld_dlopen_atfork_parent(); 501 | 502 | if ((flags & LIBSYSTEM_ATFORK_HANDLERS_ONLY_FLAG) == 0) { 503 | // third call client parent handlers registered with pthread_atfork() 504 | _pthread_atfork_parent_handlers(); 505 | } 506 | } 507 | 508 | static void 509 | libSystem_atfork_child(unsigned int flags, ...) 510 | { 511 | // first call hardwired fork child handlers for Libsystem components 512 | // in the order of library initalization above 513 | _mach_fork_child(); 514 | _pthread_atfork_child(); 515 | cc_atfork_child(); 516 | _malloc_fork_child(); 517 | _libc_fork_child(); // _arc4_fork_child calls malloc 518 | _dyld_fork_child(); 519 | dispatch_atfork_child(); 520 | #if !TARGET_OS_DRIVERKIT 521 | #if defined(HAVE_SYSTEM_CORESERVICES) 522 | _libcoreservices_fork_child(); 523 | #endif 524 | _asl_fork_child(); 525 | _notify_fork_child(); 526 | xpc_atfork_child(); 527 | #endif // !TARGET_OS_DRIVERKIT 528 | _libtrace_fork_child(); 529 | #if !TARGET_OS_DRIVERKIT 530 | _libSC_info_fork_child(); 531 | #endif // !TARGET_OS_DRIVERKIT 532 | 533 | // second dlopen 534 | // Note that this is not in the reverse order from prepare() 535 | // This is to avoid deadlock with third-party pthread handlers. 536 | // The thinking being that we should fully handle all libSystem code 537 | // then jump to third-party code 538 | _dyld_dlopen_atfork_child(); 539 | 540 | if ((flags & LIBSYSTEM_ATFORK_HANDLERS_ONLY_FLAG) == 0) { 541 | // third call client child handlers registered with pthread_atfork() 542 | _pthread_atfork_child_handlers(); 543 | } 544 | } 545 | 546 | #define DUET_PREWARM_ENV_VAR "ActivePrewarm" 547 | #define DUET_PREWARM_MACH_SERV "com.apple.dasd.end-prewarm" 548 | 549 | /* 550 | Process may be prewarmard by Duet - in which they are launched 551 | ahead of when they are first needed. For a prewarm launch, we want 552 | to end the prewarm and suspend the process if needed before we 553 | excute any third party code 554 | */ 555 | static inline void __end_prewarm(const char* envp[]) { 556 | #if HAVE_DUET_PREWARM 557 | if (_simple_getenv(envp, DUET_PREWARM_ENV_VAR) != NULL) { 558 | xpc_pipe_t pipe = xpc_pipe_create(DUET_PREWARM_MACH_SERV, XPC_PIPE_PRIVILEGED | XPC_PIPE_USE_SYNC_IPC_OVERRIDE); 559 | if (pipe == NULL) { 560 | os_log_fault(os_log_create("com.apple.libsystem", "duet.prewarm"), "Libsystem end prewarm failed to look up mach service"); 561 | return; 562 | } 563 | 564 | xpc_object_t msg = xpc_dictionary_create_empty(); 565 | if (msg == NULL) { 566 | xpc_release(pipe); 567 | os_log_fault(os_log_create("com.apple.libsystem", "duet.prewarm"), "Libsystem end prewarm failed to look up mach service"); 568 | return; 569 | } 570 | xpc_object_t reply = NULL; 571 | (void)xpc_pipe_routine(pipe, msg, &reply); 572 | 573 | xpc_release(pipe); 574 | xpc_release(msg); 575 | if (reply != NULL) { 576 | xpc_release(reply); 577 | } 578 | 579 | return; 580 | } 581 | #endif 582 | } 583 | 584 | #if SUPPORT_ASAN 585 | 586 | // Prevents use of coloring terminal signals in report. These 587 | // hinder readability when writing to files or the system log. 588 | #define ASAN_OPT_NO_COLOR "color=never" 589 | 590 | // Disables ASan's signal handlers. It's better to let the system catch 591 | // these kinds of crashes. 592 | #define ASAN_OPT_NO_SIGNAL_HANDLERS ":handle_segv=0:handle_sigbus=0:handle_sigill=0:handle_sigfpe=0" 593 | 594 | // Disables using the out-of-process symbolizer (atos) but still allows 595 | // in-process symbolization via `dladdr()`. This gives useful function names 596 | // (unless they are redacted) which can be helpful in the event we can't 597 | // symbolize offline. Out-of-process symbolization isn't useful because 598 | // the dSYMs are usually not present on the device. 599 | #define ASAN_OPT_NO_OOP_SYMBOLIZER ":external_symbolizer_path=" 600 | 601 | // Don't try to log to a file. It's difficult to find a location for the file 602 | // that is writable so just write to stderr. 603 | #define ASAN_OPT_FILE_LOG ":log_path=stderr:log_exe_name=0" 604 | 605 | // Print the module map when finding an issue. This is necessary for offline 606 | // symbolication. 607 | #define ASAN_OPT_MODULE_MAP ":print_module_map=2" 608 | 609 | // Disable ODR violation checking. 610 | // Investigate enabling ODR checking for ASan in BATS and in the `_asan` variant 611 | #define ASAN_OPT_NO_ODR_VIOLATION ":detect_odr_violation=0" 612 | 613 | // Start ASan in deactivated mode. This reduces memory overhead until 614 | // instrumented code is loaded. This prevents catching bugs if no instrumented 615 | // code is loaded. 616 | #define ASAN_OPT_START_DEACTIVATED ":start_deactivated=1" 617 | 618 | // Do not crash when an error is found. This always works for errors caught via 619 | // ASan's interceptors. This won't work for errors caught in ASan 620 | // instrumentation unless the code is compiled with 621 | // `-fsanitize-recover=address`. If this option is being used then the ASan 622 | // reports can only be found by looking at the system log. 623 | #define ASAN_OPT_NO_HALT_ON_ERROR ":halt_on_error=0" 624 | 625 | // Crash when an error is found. 626 | #define ASAN_OPT_HALT_ON_ERROR ":halt_on_error=1" 627 | 628 | // ASan options common to all supported variants 629 | #define COMMON_ASAN_OPTIONS \ 630 | ASAN_OPT_NO_COLOR \ 631 | ASAN_OPT_NO_SIGNAL_HANDLERS \ 632 | ASAN_OPT_NO_OOP_SYMBOLIZER \ 633 | ASAN_OPT_FILE_LOG \ 634 | ASAN_OPT_MODULE_MAP \ 635 | ASAN_OPT_NO_ODR_VIOLATION 636 | 637 | #if defined(CURRENT_VARIANT_normal) || defined(CURRENT_VARIANT_debug) || defined (CURRENT_VARIANT_no_asan) 638 | 639 | // In the normal variant ASan will be running in all userspace processes ("whole userspace ASan"). 640 | // This mode exists to support "ASan in BATS". 641 | // 642 | // Supporting ASan in the debug variant preserves existing behavior. 643 | // 644 | // The no_asan variant does not load the ASan runtime. However, the runtime 645 | // might still be loaded if a program or its dependencies are instrumented. 646 | // There is nothing we can do to prevent this so we should set the appropriate 647 | // ASan options (same as normal variant) if it does happen. We try to do this 648 | // here but this currently doesn't work due to rdar://problem/72212914. 649 | // 650 | // These variants use the following extra options: 651 | // 652 | // ASAN_OPT_NO_HALT_ON_ERROR - Try to avoid crash loops and increase the 653 | // chances of booting successfully. 654 | // ASAN_OPT_START_DEACTIVATED - Try to reduce memory overhead. 655 | 656 | # define DEFAULT_ASAN_OPTIONS \ 657 | COMMON_ASAN_OPTIONS \ 658 | ASAN_OPT_START_DEACTIVATED \ 659 | ASAN_OPT_NO_HALT_ON_ERROR 660 | 661 | #elif defined(CURRENT_VARIANT_asan) 662 | 663 | // The `_asan` variant is used to support running proceses with 664 | // `DYLD_IMAGE_SUFFIX=_asan`. This mode is typically used to target select parts of the OS. 665 | // 666 | // It uses the following extra options: 667 | // 668 | // ASAN_OPT_HALT_ON_ERROR - Crashing is better than just writing the error to the system log 669 | // if the system can handle this. This workflow is 670 | // more tolerant (e.g. `launchctl debug`) to crashing 671 | // than the "whole userspace ASan" workflow. 672 | 673 | # define DEFAULT_ASAN_OPTIONS \ 674 | COMMON_ASAN_OPTIONS \ 675 | ASAN_OPT_HALT_ON_ERROR 676 | 677 | #else 678 | # error Supporting ASan is not supported in the current variant 679 | #endif 680 | 681 | char dynamic_asan_opts[1024] = {0}; 682 | const char *__asan_default_options(void) { 683 | int fd = open("/System/Library/Preferences/com.apple.asan.options", O_RDONLY); 684 | if (fd != -1) { 685 | ssize_t remaining_size = sizeof(dynamic_asan_opts) - 1; 686 | char *p = dynamic_asan_opts; 687 | ssize_t read_bytes = 0; 688 | do { 689 | read_bytes = read(fd, p, remaining_size); 690 | remaining_size -= read_bytes; 691 | } while (read_bytes > 0); 692 | close(fd); 693 | 694 | if (dynamic_asan_opts[0]) { 695 | return dynamic_asan_opts; 696 | } 697 | } 698 | 699 | return DEFAULT_ASAN_OPTIONS; 700 | } 701 | 702 | #undef ASAN_OPT_NO_COLOR 703 | #undef ASAN_OPT_NO_SIGNAL_HANDLERS 704 | #undef ASAN_OPT_NO_OOP_SYMBOLIZER 705 | #undef ASAN_OPT_FILE_LOG 706 | #undef ASAN_OPT_MODULE_MAP 707 | #undef ASAN_OPT_NO_ODR_VIOLATION 708 | #undef ASAN_OPT_START_DEACTIVATED 709 | #undef ASAN_OPT_NO_HALT_ON_ERROR 710 | #undef ASAN_OPT_HALT_ON_ERROR 711 | 712 | #undef COMMON_ASAN_OPTIONS 713 | #undef DEFAULT_ASAN_OPTIONS 714 | 715 | #endif 716 | 717 | /* 718 | * Old crt1.o glue used to call through mach_init_routine which was used to initialize libSystem. 719 | * LibSystem now auto-initializes but mach_init_routine is left for binary compatibility. 720 | */ 721 | static void mach_init_old(void) {} 722 | void (*mach_init_routine)(void) = &mach_init_old; 723 | 724 | /* 725 | * This __crashreporter_info__ symbol is for all non-dylib parts of libSystem. 726 | */ 727 | const char *__crashreporter_info__; 728 | asm (".desc __crashreporter_info__, 0x10"); 729 | 730 | #else // TARGET_OS_EXCLAVEKIT 731 | 732 | #include 733 | #include 734 | 735 | struct ProgramVars; // forward reference 736 | 737 | extern void __liblibc_plat_init(int argc, const char* argv[], const char *envp[], const char *apple[], const struct ProgramVars *vars); 738 | 739 | extern void _dyld_initializer(void); 740 | 741 | extern void _objc_init(void); 742 | 743 | __attribute__((constructor)) 744 | static void 745 | libSystem_initializer(int argc, 746 | const char* argv[], 747 | const char* envp[], 748 | const char* apple[], 749 | const struct ProgramVars* vars) 750 | { 751 | // Initialize liblibc_plat.dylib: We pass it all the args that dyld has passed to us. 752 | __liblibc_plat_init(argc, argv, envp, apple, vars); 753 | 754 | // Initialize malloc zones. 755 | /* Temp. hack */ 756 | /* We need to check if malloc was already initialized by the platform code */ 757 | if (malloc_default_zone() == NULL) { 758 | __malloc_init(NULL); 759 | } 760 | 761 | // Initialize libdyld.dylib. 762 | _dyld_initializer(); 763 | 764 | // Initialize libobjc.dylib. Note that this is an upward-link call. 765 | // We currently don't have a good way of avoiding this in processes that don't use Objective-C. 766 | _objc_init(); 767 | } 768 | 769 | #endif // TARGET_OS_EXCLAVEKIT 770 | -------------------------------------------------------------------------------- /optionallibs: -------------------------------------------------------------------------------- 1 | keymgr 2 | quarantine 3 | system_containermanager 4 | system_darwindirectory 5 | system_eligibility 6 | system_featureflags 7 | system_networkextension 8 | system_secinit 9 | system_symptoms 10 | -------------------------------------------------------------------------------- /optionallibs_driverkit: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /optionallibs_exclavekit: -------------------------------------------------------------------------------- 1 | compiler_rt 2 | corecrypto 3 | system_darwin 4 | system_kernel 5 | system_pthread 6 | -------------------------------------------------------------------------------- /requiredlibs: -------------------------------------------------------------------------------- 1 | cache 2 | commonCrypto 3 | compiler_rt 4 | copyfile 5 | corecrypto 6 | dispatch 7 | dyld 8 | macho 9 | removefile 10 | system_asl 11 | system_blocks 12 | system_c 13 | system_collections 14 | system_configuration 15 | system_coreservices 16 | system_darwin 17 | system_dnssd 18 | system_info 19 | system_sim_kernel system_kernel 20 | system_m 21 | system_malloc 22 | system_notify 23 | system_sim_platform system_platform 24 | system_sim_pthread system_pthread 25 | system_sandbox 26 | system_sanitizers 27 | system_trace 28 | unwind 29 | xpc 30 | -------------------------------------------------------------------------------- /requiredlibs_driverkit: -------------------------------------------------------------------------------- 1 | compiler_rt 2 | corecrypto 3 | dispatch 4 | dyld 5 | macho 6 | system_blocks 7 | system_c 8 | system_kernel 9 | system_m 10 | system_malloc 11 | system_platform 12 | system_pthread 13 | system_trace 14 | -------------------------------------------------------------------------------- /requiredlibs_exclavekit: -------------------------------------------------------------------------------- 1 | libc 2 | libc_plat 3 | dispatch 4 | dyld 5 | macho 6 | system_blocks 7 | system_c 8 | system_collections 9 | system_m 10 | system_malloc 11 | system_platform 12 | system_trace 13 | unwind 14 | -------------------------------------------------------------------------------- /xcodescripts/create_asan_override_file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | if [ "${RC_SUPPORT_ADDRESS_SANITIZATION}" == "1" -a "${ACTION}" == "install" ]; then 4 | mkdir -p "${DSTROOT}/usr/local/share/" 5 | echo "please" > "${DSTROOT}/usr/local/share/launchd-disable-memory-limits" 6 | fi 7 | -------------------------------------------------------------------------------- /xcodescripts/create_dylib_symlinks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | if [ $# -ne 3 ]; then 4 | echo "Usage: $0 " 1>&2 5 | exit 1 6 | fi 7 | 8 | if [[ "${DRIVERKIT}" == "1" ]]; then exit 0; fi; # No compatibility symlinks in DriverKit SDK 9 | if [[ "${EXCLAVEKIT}" == "1" ]]; then exit 0; fi; # No compatibility symlinks in ExclaveKit SDK 10 | 11 | DSTROOT="$1${INSTALL_PATH_PREFIX}" 12 | ACTION="$2" 13 | VARIANTS="$3" 14 | 15 | BSD_LIBS="c info m pthread dbm poll dl rpcsvc proc" 16 | 17 | if [[ "${PLATFORM_NAME}" =~ macosx ]]; then 18 | BSD_LIBS="${BSD_LIBS} gcc_s.1" 19 | fi 20 | 21 | mkdir -p "${DSTROOT}/usr/lib" || exit 1 22 | 23 | if [ "${ACTION}" != "installhdrs" ]; then 24 | for variant in ${VARIANTS}; do 25 | suffix="" 26 | if [ ${variant} != "normal" ]; then 27 | suffix="_${variant}" 28 | fi 29 | 30 | ln -sf "libSystem.B${suffix}.dylib" "${DSTROOT}/usr/lib/libSystem${suffix}.dylib" || exit 1 31 | 32 | for i in ${BSD_LIBS}; do 33 | ln -sf "libSystem.dylib" "${DSTROOT}/usr/lib/lib${i}.dylib" || exit 1 34 | done 35 | done 36 | fi 37 | -------------------------------------------------------------------------------- /xcodescripts/create_system_framework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | if [ $# -ne 5 ]; then 4 | echo "Usage: $0 " 1>&2 5 | exit 1 6 | fi 7 | 8 | if [[ "${EXCLAVEKIT}" == "1" ]]; then exit 0; fi; # No compatibility symlinks or System.framework in ExclaveKit SDK 9 | 10 | DSTROOT="$1${INSTALL_PATH_FRAMEWORK_PREFIX}" 11 | SRCROOT="$2" 12 | ACTION="$3" 13 | ARCHS="$4" 14 | VARIANTS="$5" 15 | 16 | FPATH="/System/Library/Frameworks/System.framework" 17 | 18 | # System.framework on iOS needs to be a special snowflake. 19 | # Other projects install headers into Versions/B/PrivateHeaders the sub-directories 20 | # and symlinks still need to exist, even though they don't fit in flat bundles. 21 | mkdir -p "${DSTROOT}/${FPATH}" || exit 1 22 | mkdir -p "${DSTROOT}/${FPATH}/Versions" || exit 1 23 | mkdir -p "${DSTROOT}/${FPATH}/Versions/B" || exit 1 24 | ln -sf "B" "${DSTROOT}/${FPATH}/Versions/Current" || exit 1 25 | ln -sf "Versions/Current/PrivateHeaders" "${DSTROOT}/${FPATH}/PrivateHeaders" || exit 1 26 | 27 | if [[ "${DRIVERKIT}" == "1" ]]; then exit 0; fi; # No compatibility symlinks in DriverKit SDK 28 | 29 | if [[ "${PLATFORM_NAME}" =~ macosx ]]; then 30 | ln -sf "Versions/Current/Resources" "${DSTROOT}/${FPATH}/Resources" || exit 1 31 | 32 | for variant in ${VARIANTS}; do 33 | suffix="" 34 | if [ ${variant} != "normal" ]; then 35 | suffix="_${variant}" 36 | fi 37 | ln -sf "Versions/Current/System${suffix}" "${DSTROOT}/${FPATH}/System${suffix}" || exit 1 38 | ln -sf "../../../../../../usr/lib/libSystem.B${suffix}.dylib" "${DSTROOT}/${FPATH}/Versions/B/System${suffix}" || exit 1 39 | done 40 | else 41 | for variant in ${VARIANTS}; do 42 | suffix="" 43 | if [ ${variant} != "normal" ]; then 44 | suffix="_${variant}" 45 | fi 46 | 47 | ln -sf "../../../../usr/lib/libSystem.B${suffix}.dylib" "${DSTROOT}/${FPATH}/System${suffix}" || exit 1 48 | done 49 | fi 50 | -------------------------------------------------------------------------------- /xcodescripts/linker_arguments.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | if [ $# -ne 5 ]; then 4 | echo "Usage: $0 " 1>&2 5 | exit 1 6 | fi 7 | 8 | shopt -s nullglob 9 | 10 | ARCHS="$1" 11 | VARIANTS="$2" 12 | OUTPUTDIR="$3" 13 | SDKROOT="$4" 14 | SRCROOT="$5" 15 | 16 | LIBSYS="${SDKROOT}/${SDK_INSTALL_ROOT}/usr/local/lib/system" 17 | LSYS="${SDKROOT}/${SDK_INSTALL_ROOT}/usr/lib/system" 18 | 19 | mkdir -p "${OUTPUTDIR}" 20 | 21 | for arch in ${ARCHS}; do 22 | for variant in ${VARIANTS}; do 23 | OUTPUTFILE="${OUTPUTDIR}/linker_arguments.${arch}.${variant}.txt" 24 | OUTPUTCONFIG="${OUTPUTDIR}/config.${arch}.${variant}.h" 25 | TEMPDIR="${OUTPUTDIR}/linker_arguments_tmp" 26 | 27 | SDK_INSTALL_VARIANT="${DRIVERKIT:+_driverkit}${EXCLAVEKIT:+_exclavekit}" 28 | 29 | mkdir -p "${TEMPDIR}" 30 | 31 | ACTUALLIBS="${TEMPDIR}/${arch}.${variant}.actuallibs" 32 | ALLLIBS="${TEMPDIR}/${arch}.${variant}.alllibs" 33 | FROMUSRLIBSYSTEM="${TEMPDIR}/${arch}.${variant}.fromusrlibsystem" 34 | FROMUSRLOCALLIBSYSTEM="${TEMPDIR}/${arch}.${variant}.fromusrlocallibsystem" 35 | INUSRLIBSYSTEM="${TEMPDIR}/${arch}.${variant}.inusrlibsystem" 36 | INUSRLOCALLIBSYSTEM="${TEMPDIR}/${arch}.${variant}.inusrlocallibsystem" 37 | MISSINGLIBS="${TEMPDIR}/${arch}.${variant}.missinglibs" 38 | POSSIBLEUSRLOCALLIBSYSTEM="${TEMPDIR}/${arch}.${variant}.possibleusrlocallibsystem" 39 | OPTIONALLIBS="${SRCROOT}/optionallibs${SDK_INSTALL_VARIANT}" 40 | REQUIREDLIBS="${SRCROOT}/requiredlibs${SDK_INSTALL_VARIANT}" 41 | 42 | if [ ${variant} = "normal" ]; then 43 | SUFFIX="" 44 | else 45 | SUFFIX="_${variant}" 46 | fi 47 | 48 | rm -f "${OUTPUTFILE}" 49 | 50 | cat ${REQUIREDLIBS} ${OPTIONALLIBS} | sort > ${ALLLIBS} 51 | 52 | # Strip away variant information to do presence checks 53 | # non-normal variants can always link against normal clients 54 | cd ${LSYS} && ls lib*.{dylib,tbd,api,spi} | sed -E -e 's/_(debug|profile|static)\././' | while read l; do 55 | if [ "${l: -6}" == ".dylib" ]; then 56 | xcrun -sdk "${SDKROOT}" lipo "${LSYS}/${l}" -verify_arch "${arch}" 2>/dev/null 57 | else 58 | xcrun -sdk "${SDKROOT}" tapi archive "${LSYS}/${l}" --verify-arch "${arch}" 2>/dev/null 59 | fi 60 | if [ $? -eq 0 ]; then 61 | echo "${l}" 62 | fi 63 | done | sed -E -e 's/^lib//' -e 's/\..*$$//' | sort -u > ${INUSRLIBSYSTEM} 64 | [ -d ${LIBSYS} ] && cd ${LIBSYS} && ls lib*.a | sed -E -e 's/_(debug|profile|static)\././' | while read l; do 65 | xcrun -sdk "${SDKROOT}" lipo "${LIBSYS}/${l}" -verify_arch "${arch}" 2>/dev/null 66 | if [ $? -eq 0 ]; then 67 | echo "${l}" 68 | fi 69 | done | sed -E -e 's/^lib//' -e 's/\..*$$//' | sort -u > ${INUSRLOCALLIBSYSTEM} 70 | 71 | while read line ; do 72 | for lib in ${line} ; do 73 | egrep "^${lib}$" ${INUSRLIBSYSTEM} && break 74 | done 75 | done < ${ALLLIBS} > ${FROMUSRLIBSYSTEM} 76 | 77 | while read line ; do 78 | for lib in ${line} ; do 79 | egrep -q "^${lib}$" ${INUSRLIBSYSTEM} && break 80 | egrep "^${lib}$" ${INUSRLOCALLIBSYSTEM} && break 81 | done 82 | done < ${ALLLIBS} > ${POSSIBLEUSRLOCALLIBSYSTEM} 83 | 84 | comm -13 ${FROMUSRLIBSYSTEM} ${POSSIBLEUSRLOCALLIBSYSTEM} > ${FROMUSRLOCALLIBSYSTEM} 85 | cat ${FROMUSRLIBSYSTEM} ${FROMUSRLOCALLIBSYSTEM} | sort > ${ACTUALLIBS} 86 | 87 | while read line ; do 88 | found=0 89 | for lib in ${line} ; do 90 | egrep -q "^${lib}$" ${ACTUALLIBS} && found=1 91 | done 92 | [[ $found == 0 ]] && echo ${line} 93 | done < ${REQUIREDLIBS} > ${MISSINGLIBS} 94 | 95 | if [ -s ${MISSINGLIBS} ]; then 96 | echo '*** missing required libs ***' 97 | cat ${MISSINGLIBS} 98 | exit 1 99 | fi 100 | 101 | cat ${FROMUSRLIBSYSTEM} | while read lib; do 102 | echo "#define HAVE_"$(echo "${lib/_sim/}" | tr 'a-z' 'A-Z')" 1" 103 | done >> "${OUTPUTCONFIG}" 104 | 105 | cat ${FROMUSRLIBSYSTEM} | while read lib; do 106 | echo "-Wl,-reexport-l${lib}" 107 | done >> "${OUTPUTFILE}" 108 | 109 | # Allow static archives to degrade to their non-variant versions 110 | cat ${FROMUSRLOCALLIBSYSTEM} | while read lib; do 111 | LPATH="${LIBSYS}/lib${lib}${SUFFIX}.a" 112 | xcrun -sdk "${SDKROOT}" lipo "${LPATH}" -verify_arch "${arch}" 2>/dev/null 113 | if [ $? -ne 0 ]; then 114 | LPATH="${LIBSYS}/lib${lib}.a" 115 | fi 116 | echo "-Wl,-force_load,${LPATH}" 117 | done >> "${OUTPUTFILE}" 118 | 119 | if ! [[ -z "$DRIVERKIT" ]]; then 120 | echo "-iframeworkwithsysroot${DRIVERKITROOT}/System/Library/PrivateFrameworks" >> "${OUTPUTFILE}" 121 | echo "-weak_framework MallocStackLogging" >> "${OUTPUTFILE}" 122 | fi 123 | 124 | echo "Final contents of ${OUTPUTFILE}:" 125 | cat "${OUTPUTFILE}" 126 | done 127 | done 128 | 129 | MARKERFILE="${OUTPUTDIR}/linker_arguments_changed.c" 130 | 131 | for arch in ${ARCHS}; do 132 | for variant in ${VARIANTS}; do 133 | OUTPUTFILE="${OUTPUTDIR}/linker_arguments.${arch}.${variant}.txt" 134 | cat "${OUTPUTFILE}" 135 | done 136 | done | shasum | sed 's,^,// ,' > "${MARKERFILE}" 137 | 138 | exit 0 139 | --------------------------------------------------------------------------------