]> git.saurik.com Git - apple/libsystem.git/commitdiff
Libsystem-1292.50.1.tar.gz macos-1101 macos-112 v1292.50.1 v1292.60.1
authorApple <opensource@apple.com>
Thu, 19 Nov 2020 01:07:40 +0000 (01:07 +0000)
committerApple <opensource@apple.com>
Thu, 19 Nov 2020 01:07:40 +0000 (01:07 +0000)
Libsystem.xcconfig
Libsystem.xcodeproj/project.pbxproj
i386.c [new file with mode: 0644]
init.c
optionallibs
optionallibs_i386 [new file with mode: 0644]
requiredlibs
requiredlibs_i386 [new file with mode: 0644]
xcodescripts/linker_arguments.sh

index c11431b5429cee433b2a4e6e53c4eb527e963e54..545b4366e3658dd2edf2d6497ea20edfae200705 100644 (file)
@@ -10,10 +10,13 @@ ASAN_IN_NORMAL_VARIANT_RC_1 = $(ASAN_IN_NORMAL_VARIANT_DK_$(DRIVERKIT))
 ASAN_IN_NORMAL_VARIANT_RC_ = NO
 ASAN_IN_NORMAL_VARIANT = $(ASAN_IN_NORMAL_VARIANT_RC_$(RC_SUPPORT_ADDRESS_SANITIZATION))
 
+// Apple Internal Sanitizer dylib path
+SANITIZER_DYLIB_DIR = /usr/appleinternal/lib/sanitizers
+
 ASAN_CFLAGS_ =
 ASAN_CFLAGS_YES = -DCURRENT_VARIANT_asan=1
 ASAN_LDFLAGS_ =
-SHARED_ASAN_LDFLAGS = -L $(SDKROOT)/usr/local/lib/sanitizers -Xlinker -not_for_dyld_shared_cache -rpath /usr/local/lib/sanitizers/
+SHARED_ASAN_LDFLAGS = -L $(SDKROOT)$(SANITIZER_DYLIB_DIR) -Xlinker -not_for_dyld_shared_cache -rpath $(SANITIZER_DYLIB_DIR)/
 ASAN_LDFLAGS_YES[sdk=macosx*] = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_osx_dynamic
 ASAN_LDFLAGS_YES[sdk=iphoneos*] = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_ios_dynamic
 ASAN_LDFLAGS_YES[sdk=watchos*] = $(SHARED_ASAN_LDFLAGS) -Xlinker -upward-lclang_rt.asan_watchos_dynamic
@@ -75,6 +78,10 @@ PLIST_FILE_OUTPUT_FORMAT = binary
 PLIST_FILE_OUTPUT_FORMAT[sdk=macosx*] = xml
 EXCLUDED_SOURCE_FILE_NAMES[sdk=driverkit*] = Info.plist
 
+EXCLUDED_SOURCE_FILE_NAMES = $(inherited) i386.c
+INCLUDED_SOURCE_FILE_NAMES[sdk=macos*][arch=i386] = $(inherited) i386.c
+EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*][arch=i386] = $(inherited) init.c CompatibilityHacks.c
+
 // override presence of $(EXECUTABLE_VARIANT_SUFFIX) in the default EXECUTABLE_NAME rdar://26234727
 DYLIB_INSTALL_NAME_EXECUTABLE_NAME = $(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_SUFFIX)
 DYLIB_INSTALL_NAME_EXECUTABLE_PATH = $(DYLIB_INSTALL_NAME_EXECUTABLE_NAME)
index bba1b8e9250a29449a768fe5894e1763b9fc495c..1ea3af3c2c7b77bf16d0eb4d8dc9bb57aab08e1d 100644 (file)
@@ -73,6 +73,7 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+               2B9D8B542402427100E7F338 /* i386.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B9D8B53240239BD00E7F338 /* i386.c */; };
                923662F821276300001FB3E7 /* enable_asan_mode in Copy enable_asan_mode */ = {isa = PBXBuildFile; fileRef = 8C0BF1291F58E51D00706493 /* enable_asan_mode */; };
                BA2BD900136D282200FF78C0 /* Info.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = BA5511B6136C9D780012B9B5 /* Info.plist */; };
                BA2FABC5136DBF45004383E5 /* linker_arguments_changed.c in Sources */ = {isa = PBXBuildFile; fileRef = BA2FABC4136DBF45004383E5 /* linker_arguments_changed.c */; };
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+               2B9D8B53240239BD00E7F338 /* i386.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = i386.c; sourceTree = "<group>"; };
                8C0BF1291F58E51D00706493 /* enable_asan_mode */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = enable_asan_mode; sourceTree = "<group>"; };
                923662FC212B442C001FB3E7 /* create_asan_override_file.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_asan_override_file.sh; sourceTree = "<group>"; };
                BA2FABC4136DBF45004383E5 /* linker_arguments_changed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = linker_arguments_changed.c; sourceTree = BUILT_PRODUCTS_DIR; };
                                BA5511B6136C9D780012B9B5 /* Info.plist */,
                                C9A43CAB15374DB200388D0C /* alloc_once_private.h */,
                                BA5511B7136C9D780012B9B5 /* init.c */,
+                               2B9D8B53240239BD00E7F338 /* i386.c */,
                                BA5511B9136C9D780012B9B5 /* optionallibs */,
                                BA5511BA136C9D780012B9B5 /* requiredlibs */,
                                E43B88B42245778F00215272 /* optionallibs_driverkit */,
                        buildActionMask = 2147483647;
                        files = (
                                BA5511C9136C9E4D0012B9B5 /* CompatibilityHacks.c in Sources */,
+                               2B9D8B542402427100E7F338 /* i386.c in Sources */,
                                BA5511CA136C9E510012B9B5 /* init.c in Sources */,
                                BA2FABC5136DBF45004383E5 /* linker_arguments_changed.c in Sources */,
                        );
diff --git a/i386.c b/i386.c
new file mode 100644 (file)
index 0000000..0fbd443
--- /dev/null
+++ b/i386.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2007, 2008, 2011-2013 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+// This is the only C file compiled into Libsystem when building for i386.
+// We use EXCLUDED_ and INCLUDED_SOURCE_FILES in the xcconfig to accomplish
+// this.
+//
+// i386 is no longer a supported architecture for macOS. The kernel doesn’t run
+// i386 macOS executables. However, we cannot completely remove the i386
+// slice from libSystem.B.dylib. In order to support the watchOS Simulator,
+// macOS includes several libraries with i386 slices. The watchOS Simulator
+// uses the i386 ISA with a different  Mach-O platform and its own entire set
+// of system libraries. Some of those libraries (including those from the clang/
+// llvm project) verify that the compiler works by compiling and linking a
+// simple executable. That would fail if Libsystem lacked an i386 slice.
+// So, we will preserve a vestigial i386 slice, but no executables can actually
+// use it to run.
+// rdar://problem/59703537
+
+#include <TargetConditionals.h>
+
+#if !defined(__i386__) || !defined(TARGET_OS_OSX) || (TARGET_OS_OSX == 0)
+#error "This file should not be built for this environment"
+#endif // !defined(__i386__) || !defined(TARGET_OS_OSX) || (TARGET_OS_OSX == 0)
+
+#include <sys/reason.h>
+
+struct ProgramVars;
+
+__attribute__((constructor))
+static void
+libSystem_initializer(int argc __attribute__((unused)),
+              const char* argv[]  __attribute__((unused)),
+              const char* envp[]  __attribute__((unused)),
+              const char* apple[]  __attribute__((unused)),
+              const struct ProgramVars* vars  __attribute__((unused)))
+{
+       abort_with_reason(OS_REASON_LIBSYSTEM, 386,
+                       "i386 is not supported on macOS",
+                       OS_REASON_FLAG_CONSISTENT_FAILURE);
+}
diff --git a/init.c b/init.c
index 9d604e0c529bf115d3622809748fe5510fa4c957..cdc51303dcc0436fbdb0e4e2d51379457a696388 100644 (file)
--- a/init.c
+++ b/init.c
@@ -225,6 +225,7 @@ libSystem_initializer(int argc,
        _libSystem_ktrace_init_func(LIBC);
 
        // TODO: Move __malloc_init before __libc_init after breaking malloc's upward link to Libc
+       // Note that __malloc_init() will also initialize ASAN when it is present
        __malloc_init(apple);
        _libSystem_ktrace_init_func(MALLOC);
 
@@ -234,9 +235,6 @@ libSystem_initializer(int argc,
        _libSystem_ktrace_init_func(KEYMGR);
 #endif
 
-       // No ASan interceptors are invoked before this point. ASan is normally initialized via the malloc interceptor:
-       // _dyld_initializer() -> tlv_load_notification -> wrap_malloc -> ASanInitInternal
-
        _dyld_initializer();
        _libSystem_ktrace_init_func(DYLD);
 
@@ -285,6 +283,37 @@ libSystem_initializer(int argc,
        }
 #endif
 
+#if TARGET_OS_OSX && !defined(__i386__)
+       bool enable_system_version_compat = false;
+       bool enable_ios_version_compat = false;
+       char *system_version_compat_override = getenv("SYSTEM_VERSION_COMPAT");
+       if (system_version_compat_override != NULL) {
+               long override = strtol(system_version_compat_override, NULL, 0);
+               if (override == 1) {
+                       enable_system_version_compat = true;
+               } else if (override == 2) {
+                       enable_ios_version_compat = true;
+               }
+       } else if (dyld_get_active_platform() == PLATFORM_MACCATALYST) {
+               if (!dyld_program_sdk_at_least(dyld_platform_version_iOS_14_0)) {
+                       enable_system_version_compat = true;
+               }
+       } else if (dyld_get_active_platform() == PLATFORM_IOS) {
+               enable_ios_version_compat = true;
+       } else if (!dyld_program_sdk_at_least(dyld_platform_version_macOS_10_16)) {
+               enable_system_version_compat = true;
+       }
+
+       if (enable_system_version_compat || enable_ios_version_compat) {
+               struct _libkernel_late_init_config config = {
+                       .version = 2,
+                       .enable_system_version_compat = enable_system_version_compat,
+                       .enable_ios_version_compat = enable_ios_version_compat,
+               };
+               __libkernel_init_late(&config);
+       }
+#endif // TARGET_OS_OSX && !defined(__i386__)
+
        _libSystem_ktrace0(ARIADNE_LIFECYCLE_libsystem_init | DBG_FUNC_END);
 
        /* <rdar://problem/11588042>
index 40cd8fc345e747269801b61c9b2b17dc2357a94f..60daab2c082aa780a4a0a426dd43ac18e6b710d5 100644 (file)
@@ -4,5 +4,6 @@ quarantine
 system_containermanager
 system_featureflags
 system_networkextension
+system_product_info_filter
 system_secinit
 system_symptoms
diff --git a/optionallibs_i386 b/optionallibs_i386
new file mode 100644 (file)
index 0000000..3a1a491
--- /dev/null
@@ -0,0 +1,33 @@
+cache
+commonCrypto
+compiler_rt
+copyfile
+corecrypto
+dispatch
+dyld
+keymgr
+launch
+macho
+quarantine
+removefile
+system_asl
+system_blocks
+system_c
+system_configuration
+system_containermanager
+system_coreservices
+system_darwin
+system_dnssd
+system_featureflags
+system_info
+system_m
+system_malloc
+system_networkextension
+system_notify
+system_product_info_filter
+system_sandbox
+system_secinit
+system_symptoms
+system_trace
+unwind
+xpc
index 11fff638c404fac39b846af64c8a8dac4febf132..9737e70ff2b55f5b73968970fb605e8c8242ffad 100644 (file)
@@ -10,6 +10,7 @@ removefile
 system_asl
 system_blocks
 system_c
+system_collections
 system_configuration
 system_coreservices
 system_darwin
diff --git a/requiredlibs_i386 b/requiredlibs_i386
new file mode 100644 (file)
index 0000000..6ca7afb
--- /dev/null
@@ -0,0 +1,3 @@
+system_sim_kernel system_kernel
+system_sim_platform system_platform
+system_sim_pthread system_pthread
index 2795481a365d6e4e9cdf66851686060dec47d198..2f22e9b89c84d52329e52fd9bdef18db75c31042 100755 (executable)
@@ -26,6 +26,18 @@ for arch in ${ARCHS}; do
 
        SDK_INSTALL_VARIANT="${DRIVERKIT:+_driverkit}"
 
+       # Unwinding i386 dependencies.
+       # there are no more "real" uses of i386 Libsystem, only dependency
+       # cycles from within the umbrella (plus libobjc and libc++).
+       # We will remove non-critical dylibs (that have no real dependents
+       # anymore) from the umbrella to decrease the overall size of the
+       # i386 umbrella.
+       # (Note that there is no i386 driverkit so this does not conflict
+       # with the preceding rule)
+       if [ "$arch" = "i386" ]; then
+               SDK_INSTALL_VARIANT="_i386"
+       fi
+
        mkdir -p "${TEMPDIR}"
 
        ACTUALLIBS="${TEMPDIR}/${arch}.${variant}.actuallibs"