]> git.saurik.com Git - apple/libsystem.git/blob - i386.c
Libsystem-1292.100.5.tar.gz
[apple/libsystem.git] / i386.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 // This is the only C file compiled into Libsystem when building for i386.
30 // We use EXCLUDED_ and INCLUDED_SOURCE_FILES in the xcconfig to accomplish
31 // this.
32 //
33 // i386 is no longer a supported architecture for macOS. The kernel doesn’t run
34 // i386 macOS executables. However, we cannot completely remove the i386
35 // slice from libSystem.B.dylib. In order to support the watchOS Simulator,
36 // macOS includes several libraries with i386 slices. The watchOS Simulator
37 // uses the i386 ISA with a different Mach-O platform and its own entire set
38 // of system libraries. Some of those libraries (including those from the clang/
39 // llvm project) verify that the compiler works by compiling and linking a
40 // simple executable. That would fail if Libsystem lacked an i386 slice.
41 // So, we will preserve a vestigial i386 slice, but no executables can actually
42 // use it to run.
43 // rdar://problem/59703537
44
45 #include <TargetConditionals.h>
46
47 #if !defined(__i386__) || !defined(TARGET_OS_OSX) || (TARGET_OS_OSX == 0)
48 #error "This file should not be built for this environment"
49 #endif // !defined(__i386__) || !defined(TARGET_OS_OSX) || (TARGET_OS_OSX == 0)
50
51 #include <sys/reason.h>
52
53 struct ProgramVars;
54
55 __attribute__((constructor))
56 static void
57 libSystem_initializer(int argc __attribute__((unused)),
58 const char* argv[] __attribute__((unused)),
59 const char* envp[] __attribute__((unused)),
60 const char* apple[] __attribute__((unused)),
61 const struct ProgramVars* vars __attribute__((unused)))
62 {
63 abort_with_reason(OS_REASON_LIBSYSTEM, 386,
64 "i386 is not supported on macOS",
65 OS_REASON_FLAG_CONSISTENT_FAILURE);
66 }