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
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)
/* 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 */,
);
--- /dev/null
+/*
+ * 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);
+}
_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);
_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);
}
#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>
system_containermanager
system_featureflags
system_networkextension
+system_product_info_filter
system_secinit
system_symptoms
--- /dev/null
+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
system_asl
system_blocks
system_c
+system_collections
system_configuration
system_coreservices
system_darwin
--- /dev/null
+system_sim_kernel system_kernel
+system_sim_platform system_platform
+system_sim_pthread system_pthread
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"