xref: /xnu-10002.1.13/tests/Makefile (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1PROJECT := xnu/darwintests
2
3# When building as part of xnu_tests, we get passed a DSTROOT that's got the
4# unit test path in it already.  But, BASEDSTROOT doesn't, so use that instead.
5ifdef BASEDSTROOT
6override DSTROOT = $(BASEDSTROOT)
7endif
8
9INVALID_ARCHS = i386 $(filter armv7%,$(ARCH_CONFIGS))
10ENABLE_LTE_TESTS=YES
11
12OTHER_LTE_INCLUDE_FILES += \
13	/System/Library/PrivateFrameworks/LoggingSupport.framework, \
14	/System/Library/PrivateFrameworks/MobileKeyBag.framework, \
15	/System/Library/Frameworks/IOSurface.framework, \
16	/usr/local/lib/libdarwintest_utils.dylib, \
17	/usr/lib/libapple_crypto.dylib,
18
19DEVELOPER_DIR ?= $(shell xcode-select -p)
20
21# the xnu build system will only ever call us with the default target
22.DEFAULT_GOAL := install
23
24include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
25
26OTHER_CFLAGS  = -Weverything -Wno-gnu-union-cast -Wno-missing-field-initializers -Wno-partial-availability
27OTHER_CFLAGS += -Wno-missing-noreturn -Wno-vla -Wno-reserved-id-macro -Wno-documentation-unknown-command
28OTHER_CFLAGS += -Wno-padded -Wno-used-but-marked-unused -Wno-covered-switch-default -Wno-nullability-extension
29OTHER_CFLAGS += -Wno-gnu-empty-initializer -Wno-unused-macros -Wno-undef -Wno-fixed-enum-extension
30OTHER_CFLAGS += -Wno-gnu-auto-type -Wno-switch-enum -Wno-variadic-macros
31OTHER_CFLAGS += --std=gnu11 -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
32OTHER_CFLAGS += -UT_NAMESPACE_PREFIX -DT_NAMESPACE_PREFIX=xnu -DT_LEAKS_DISABLE=1
33OTHER_CFLAGS += -F $(SDKROOT)/System/Library/PrivateFrameworks
34
35
36CODESIGN:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign)
37CODESIGN_HARDENED_RUNTIME:=$(CODESIGN) -o runtime
38CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign_allocate)
39
40ifeq ($(PLATFORM),iPhoneOS)
41  IOS_TEST_COMPAT = YES
42else
43  IOS_TEST_COMPAT = NO
44endif
45
46# Subsystems
47
48include ktrace/Makefile
49
50INCLUDED_TEST_SOURCE_DIRS += recount
51include recount/Makefile
52INCLUDED_TEST_SOURCE_DIRS += cpu_counters
53include cpu_counters/Makefile
54
55# Miscellaneous Tests
56
57atm_diagnostic_flag: OTHER_CFLAGS += drop_priv.c
58
59atm_diagnostic_flag_entitled: CODE_SIGN_ENTITLEMENTS = atm_diagnostic_flag.entitlements
60atm_diagnostic_flag_entitled: OTHER_CFLAGS += drop_priv.c
61
62avx: INVALID_ARCHS = $(filter arm%,$(ARCH_CONFIGS))
63avx: OTHER_CFLAGS += -mavx512f -mavx512bw -mavx512vl
64avx: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
65avx: CONFIG_FLAGS := $(filter-out -O%,$(CONFIG_FLAGS))
66# Add -mno-implicit-float to prevent the compiler from touching SIMD regs
67# unexpectedly
68avx: CONFIG_FLAGS += -mno-implicit-float
69# Disable vzeroupper insertion to work around rdar://problem/35035096
70avx: CONFIG_FLAGS += -mllvm -x86-use-vzeroupper=0
71ifneq (osx,$(TARGET_NAME))
72EXCLUDED_SOURCES += avx.c
73endif
74
75CUSTOM_TARGETS = sr_entitlement_helper
76
77sr_entitlement_helper: sr_entitlement_helper.c
78	mkdir -p $(SYMROOT)
79	$(CC) -I $(OBJROOT) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) sr_entitlement_helper.c -o $(SYMROOT)/$@
80	echo $(CODESIGN) --force --sign - --timestamp=none --entitlements sr_entitlement.entitlements $(SYMROOT)/$@; \
81	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements sr_entitlement.entitlements $(SYMROOT)/$@;
82
83install-sr_entitlement_helper: sr_entitlement_helper
84	mkdir -p $(INSTALLDIR)
85	cp $(SYMROOT)/sr_entitlement_helper $(INSTALLDIR)
86
87sr_entitlement: OTHER_LDFLAGS += -ldarwintest_utils
88
89restrict_jit: CODE_SIGN_ENTITLEMENTS = restrict_jit.entitlements
90
91backtracing_tests: OTHER_LDFLAGS += -framework CoreSymbolication
92backtracing_tests: CODE_SIGN_ENTITLEMENTS = kernel_symbolication_entitlements.plist
93
94CUSTOM_TARGETS += corpse_backtrace2
95
96corpse_backtrace2:
97		$(MIG) $(CFLAGS) \
98		-DMACH_EXC_SERVER_TASKIDTOKEN \
99		-DMACH_EXC_SERVER_BACKTRACE \
100		-sheader $(OBJROOT)/excserver_backtrace.h \
101		-server $(OBJROOT)/excserver_backtrace.c \
102		-header /dev/null -user /dev/null \
103		excserver_backtrace.defs
104
105install-corpse_backtrace2: ;
106
107corpse_backtrace: corpse_backtrace2 exc_helpers.c
108corpse_backtrace: OTHER_CFLAGS += $(OBJROOT)/excserver_backtrace.c
109corpse_backtrace: OTHER_CFLAGS += -I $(OBJROOT)
110corpse_backtrace: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
111
112CUSTOM_TARGETS += immovable_send_client vm_spawn_tool port_exhaustion_client port_table_limits_client fd_table_limits_client posix_spawnattr_set_crash_behavior_np_child conclave_process
113
114exception_tests: excserver_protect exc_helpers.c
115exception_tests: CODE_SIGN_ENTITLEMENTS = exception_tests.entitlements
116exception_tests: OTHER_CFLAGS += $(OBJROOT)/excserver_protect.c
117exception_tests: OTHER_CFLAGS += -I $(OBJROOT)
118exception_tests: OTHER_CFLAGS += -DENTITLED=1
119
120immovable_send: excserver
121immovable_send: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
122immovable_send: OTHER_LDFLAGS += -ldarwintest_utils -lpthread -framework IOKit
123immovable_send: immovable_send_client
124immovable_send: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
125
126locks: OTHER_LDFLAGS += -ldarwintest_utils
127
128immovable_send_client: immovable_send_client.c
129	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) immovable_send_client.c -o $(SYMROOT)/immovable_send_client
130
131install-immovable_send_client: immovable_send_client
132	mkdir -p $(INSTALLDIR)
133	cp $(SYMROOT)/immovable_send_client $(INSTALLDIR)/
134
135test_conclave_spawn: conclave_process
136conclave_process: conclave_process.c
137	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) conclave_process.c -o $(SYMROOT)/conclave_process
138	$(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
139
140install-conclave_process: conclave_process
141	mkdir -p $(INSTALLDIR)
142	cp $(SYMROOT)/conclave_process $(INSTALLDIR)/
143
144posix_spawnattr_set_crash_behavior_np: posix_spawnattr_set_crash_behavior_np_child
145posix_spawnattr_set_crash_behavior_np: CODE_SIGN_ENTITLEMENTS = posix_spawnattr_set_crash_behavior_np_entitlements.plist
146
147posix_spawnattr_set_crash_behavior_np_child: posix_spawnattr_set_crash_behavior_np_child.c
148	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) posix_spawnattr_set_crash_behavior_np_child.c -o $(SYMROOT)/posix_spawnattr_set_crash_behavior_np_child
149	$(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
150
151install-posix_spawnattr_set_crash_behavior_np_child: posix_spawnattr_set_crash_behavior_np_child
152	mkdir -p $(INSTALLDIR)
153	cp $(SYMROOT)/posix_spawnattr_set_crash_behavior_np_child $(INSTALLDIR)/
154
155posix_spawnattr_set_launch_type_np: posix_spawnattr_set_launch_type_test
156posix_spawnattr_set_launch_type_np: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
157
158posix_spawn_launch_type: CODE_SIGN_ENTITLEMENTS = posix_spawn_launch_type-entitlements.plist
159
160port_exhaustion: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
161port_exhaustion: port_exhaustion_client
162
163port_exhaustion_client: port_exhaustion_client.c
164	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) port_exhaustion_client.c -o $(SYMROOT)/port_exhaustion_client
165
166install-port_exhaustion_client: port_exhaustion_client
167	mkdir -p $(INSTALLDIR)
168	cp $(SYMROOT)/port_exhaustion_client $(INSTALLDIR)/
169
170port_table_limits: rnserver
171port_table_limits: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
172port_table_limits: OTHER_CFLAGS += $(OBJROOT)/rnServer.c -I $(OBJROOT)
173port_table_limits: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
174port_table_limits: port_table_limits_client
175
176port_table_limits_client: port_table_limits_client.c
177	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) port_table_limits_client.c -o $(SYMROOT)/port_table_limits_client
178	$(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
179
180install-port_table_limits_client: port_table_limits_client
181	mkdir -p $(INSTALLDIR)
182	cp $(SYMROOT)/port_table_limits_client $(INSTALLDIR)/
183
184ipc/task_name_for_pid: CODE_SIGN_ENTITLEMENTS = ipc/task_name_for_pid_entitlement.plist
185
186fd_table_limits: rnserver
187fd_table_limits: OTHER_CFLAGS += $(OBJROOT)/rnServer.c -I $(OBJROOT)
188fd_table_limits: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
189fd_table_limits: fd_table_limits_client
190
191fd_table_limits_client: fd_table_limits_client.c
192	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) fd_table_limits_client.c -o $(SYMROOT)/fd_table_limits_client
193	$(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
194
195install-fd_table_limits_client: fd_table_limits_client
196	mkdir -p $(INSTALLDIR)
197	cp $(SYMROOT)/fd_table_limits_client $(INSTALLDIR)/
198
199vm_spawn_tool: INVALID_ARCHS = i386
200vm_spawn_tool: vm_spawn_tool.c
201	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_spawn_tool.c -o $(SYMROOT)/vm_spawn_tool
202
203install-vm_spawn_tool: vm_spawn_tool
204	mkdir -p $(INSTALLDIR)/tools
205	cp $(SYMROOT)/vm_spawn_tool $(INSTALLDIR)/tools/
206
207CUSTOM_TARGETS += imm_pinned_control_port_crasher
208
209imm_pinned_control_port: excserver
210imm_pinned_control_port: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
211imm_pinned_control_port: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
212imm_pinned_control_port: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
213imm_pinned_control_port: imm_pinned_control_port_crasher
214
215imm_pinned_control_port_crasher: imm_pinned_control_port_crasher.c
216	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders \
217	imm_pinned_control_port_crasher.c -o $(SYMROOT)/imm_pinned_control_port_crasher
218	$(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
219
220install-imm_pinned_control_port_crasher: imm_pinned_control_port_crasher
221	mkdir -p $(INSTALLDIR)
222	cp $(SYMROOT)/imm_pinned_control_port_crasher $(INSTALLDIR)/
223
224CUSTOM_TARGETS += reply_port_defense_client
225
226reply_port_defense: excserver
227reply_port_defense: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
228reply_port_defense: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
229reply_port_defense: reply_port_defense_client
230
231reply_port_defense_client: reply_port_defense_client.c
232	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders \
233	reply_port_defense_client.c -o $(SYMROOT)/reply_port_defense_client
234	$(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@
235
236install-reply_port_defense_client: reply_port_defense_client
237	mkdir -p $(INSTALLDIR)
238	cp $(SYMROOT)/reply_port_defense_client $(INSTALLDIR)/
239
240kas_info: OTHER_LDFLAGS += -framework CoreSymbolication
241kas_info: CODE_SIGN_ENTITLEMENTS = kernel_symbolication_entitlements.plist
242
243EXCLUDED_SOURCES += drop_priv.c xnu_quick_test_helpers.c memorystatus_assertion_helpers.c bpflib.c in_cksum.c test_utils.c inet_transfer.c net_test_lib.c
244
245ifneq ($(IOS_TEST_COMPAT),YES)
246EXCLUDED_SOURCES += jumbo_va_spaces_28530648.c perf_compressor.c vm/memorystatus_freeze_test.c vm/memorystatus_freeze_test_entitled.c vm/entitlement_increased_memory_limit.c vm/ios13extended_footprint.c vm/entitlement_internal_bands.c
247endif
248
249perf_compressor: OTHER_LDFLAGS += -ldarwintest_utils
250perf_compressor: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
251
252
253vm/memorystatus_freeze_test: CODE_SIGN_ENTITLEMENTS=./task_for_pid_entitlement.plist
254vm/memorystatus_freeze_test: OTHER_LDFLAGS += -ldarwintest_utils
255vm/memorystatus_freeze_test: memorystatus_assertion_helpers.c test_utils.c vm/memorystatus_freeze_test.c
256	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
257	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
258
259vm/memorystatus_freeze_test_entitled: CODE_SIGN_ENTITLEMENTS=./vm/memorystatus_freeze_test_entitled.plist
260vm/memorystatus_freeze_test_entitled: OTHER_LDFLAGS += -ldarwintest_utils
261vm/memorystatus_freeze_test_entitled: test_utils.c vm/memorystatus_freeze_test_entitled.c
262	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
263	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
264
265memorystatus_is_assertion: OTHER_LDFLAGS += -ldarwintest_utils
266memorystatus_is_assertion: OTHER_CFLAGS += memorystatus_assertion_helpers.c
267
268memorystatus_vm_map_fork: OTHER_CFLAGS += test_utils.c
269memorystatus_vm_map_fork: OTHER_LDFLAGS += -ldarwintest_utils
270
271shared_cache_tests: OTHER_LDFLAGS += -ldarwintest_utils
272
273stackshot_tests: ./stackshot-entitlements.plist
274stackshot_tests: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
275stackshot_tests: OTHER_CFLAGS += -Wno-objc-messaging-id
276stackshot_tests: OTHER_LDFLAGS += -lkdd -lz -ldarwintest_utils -framework Foundation -framework IOKit
277
278stackshot_accuracy: ./stackshot-entitlements.plist
279stackshot_accuracy: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
280stackshot_accuracy: OTHER_CFLAGS += -ldarwintest_utils -Wno-objc-messaging-id
281stackshot_accuracy: OTHER_LDFLAGS += -lkdd -ldarwintest_utils -framework Foundation
282stackshot_accuracy: INVALID_ARCHS = i386
283
284stackshot_spawn_exit_stress: ./stackshot-entitlements.plist
285stackshot_spawn_exit_stress: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
286
287ifeq ($(PLATFORM),MacOSX)
288CUSTOM_TARGETS += stackshot_translated_child
289
290stackshot_translated_child: INVALID_ARCHS = arm64 arm64e
291stackshot_translated_child: stackshot_translated_child.c
292	$(CC) $(DT_CFLAGS) -I $(OBJROOT) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) stackshot_translated_child.c -o $(SYMROOT)/stackshot_translated_child
293
294install-stackshot_translated_child: stackshot_translated_child
295	mkdir -p $(INSTALLDIR)
296	cp $(SYMROOT)/stackshot_translated_child $(INSTALLDIR)/
297else
298EXCLUDED_SOURCES += stackshot_translated_child.c
299endif
300
301microstackshot_tests: ./stackshot-entitlements.plist
302microstackshot_tests: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
303microstackshot_tests: OTHER_LDFLAGS = -ldarwintest_utils -framework ktrace -framework kperf -framework CoreFoundation
304
305memorystatus_zone_test: ./stackshot-entitlements.plist
306memorystatus_zone_test: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
307memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
308memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
309memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
310
311memcmp_zero: OTHER_CFLAGS += ../osfmk/arm64/memcmp_zero.s
312
313text_corruption: OTHER_LDFLAGS += -ldarwintest_utils
314CUSTOM_TARGETS += text_corruption_helper
315
316text_corruption_helper:
317	$(CC) $(LDFLAGS) $(CFLAGS) text_corruption_helper.c -lm -o $(SYMROOT)/$@;
318	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
319
320install-text_corruption_helper: text_corruption_helper
321	mkdir -p $(INSTALLDIR)
322	cp $(SYMROOT)/text_corruption_helper $(INSTALLDIR)/
323
324codesigntests: CODE_SIGN_ENTITLEMENTS=codesigntests-entitlements.plist
325codesigntests: OTHER_CFLAGS += -DTESTNAME=codesigntests
326# Adding a custom target and build/install rules since CODE_SIGN_ENTITLEMENTS
327# does not take in arguments, and we need to sign this test using a sha256T
328# digest
329
330OTHER_TEST_TARGETS += codesigntests_sha256t
331codesigntests_sha256t: OTHER_CFLAGS += -DTESTNAME=codesigntests_sha256t
332
333codesigntests_sha256t: codesigntests.c
334	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(DT_LDFLAGS) $(LDFLAGS) $(CFLAGS) codesigntests.c -o $(SYMROOT)/$@;
335	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --digest=sha256T -s - --entitlements codesigntests-entitlements.plist $(SYMROOT)/$@;
336install-codesigntests_sha256t: codesigntests_sha256t
337	mkdir -p $(INSTALLDIR)
338	cp $(SYMROOT)/codesigntests_sha256t $(INSTALLDIR)/
339
340
341ecc_test: OTHER_LDFLAGS += -ldarwintest_utils
342CUSTOM_TARGETS += ecc_test_helper
343
344ecc_test_helper:
345	$(CC) $(LDFLAGS) $(CFLAGS) ecc_test_helper.c -lm -o $(SYMROOT)/$@;
346	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
347
348install-ecc_test_helper: ecc_test_helper
349	mkdir -p $(INSTALLDIR)
350	cp $(SYMROOT)/ecc_test_helper $(INSTALLDIR)/
351
352kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
353kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
354
355test_knote_use_after_free: OTHER_CFLAGS += -Wno-unused-macros
356test_knote_use_after_free: OTHER_LDFLAGS += -ldarwintest_utils -lpthread
357
358mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
359
360monotonic_core: ./stackshot-entitlements.plist
361monotonic_core: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
362monotonic_core: OTHER_LDFLAGS += -framework ktrace
363
364perfmon_unit_tests: OTHER_CFLAGS += -Wno-missing-variable-declarations -Wno-format-pedantic -Wno-language-extension-token
365
366perf_exit: perf_exit_proc
367perf_exit: ./stackshot-entitlements.plist
368perf_exit: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
369perf_exit: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils
370perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
371
372ipc/mach_exc_port_substitute: excserver
373ipc/mach_exc_port_substitute: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
374ipc/mach_exc_port_substitute: CODE_SIGN_ENTITLEMENTS = ipc/mach_exc_port_substitute.plist
375
376CUSTOM_TARGETS += prioritize_process_launch_helper
377prioritize_process_launch: prioritize_process_launch_helper
378
379prioritize_process_launch_helper: prioritize_process_launch_helper.c
380	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) prioritize_process_launch_helper.c -o $(SYMROOT)/prioritize_process_launch_helper
381	echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
382	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
383
384install-prioritize_process_launch_helper: prioritize_process_launch_helper
385	mkdir -p $(INSTALLDIR)
386	cp $(SYMROOT)/prioritize_process_launch_helper $(INSTALLDIR)/
387
388
389perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
390
391mach_exception_reply: OTHER_CFLAGS += -Wno-cast-align
392mach_exception_reply: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
393
394os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
395os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
396os_thread_self_restrict: OTHER_LDFLAGS += -sectcreate __TEXT __info_plist os_thread_self_restrict-identifier.plist
397
398subsystem_root_path: subsystem_root_path.c subsystem_root_path-entitlements.plist
399subsystem_root_path: CODE_SIGN_ENTITLEMENTS=subsystem_root_path-entitlements.plist
400
401EXCLUDED_SOURCES += $(wildcard bounded_ptr_src/*.cpp)
402bounded_ptr: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
403bounded_ptr: $(wildcard bounded_ptr_src/*.cpp) bounded_ptr.cpp
404
405EXCLUDED_SOURCES += bounded_ptr_03.cpp
406bounded_ptr_03: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++03 $(DT_LDFLAGS)
407bounded_ptr_03: bounded_ptr_03.cpp
408
409EXCLUDED_SOURCES += $(wildcard bounded_array_src/*.cpp)
410bounded_array: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
411bounded_array: $(wildcard bounded_array_src/*.cpp) bounded_array.cpp
412
413EXCLUDED_SOURCES += $(wildcard bounded_array_ref_src/*.cpp)
414bounded_array_ref: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
415bounded_array_ref: $(wildcard bounded_array_ref_src/*.cpp) bounded_array_ref.cpp
416
417EXCLUDED_SOURCES += $(wildcard intrusive_shared_ptr_src/*.cpp)
418intrusive_shared_ptr: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
419intrusive_shared_ptr: $(wildcard intrusive_shared_ptr_src/*.cpp) intrusive_shared_ptr.cpp
420
421EXCLUDED_SOURCES += $(wildcard safe_allocation_src/*.cpp)
422safe_allocation: OTHER_CXXFLAGS += -Werror=implicit-int-conversion -Werror=shorten-64-to-32 -I$(SRCROOT)/../libkern -std=c++17
423safe_allocation: $(wildcard safe_allocation_src/*.cpp) safe_allocation.cpp
424
425EXCLUDED_SOURCES += osptr_compat.cpp
426osptr_98: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++98 -DOSPTR_STD="98"
427osptr_98: osptr_compat.cpp
428	$(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
429osptr_11: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++11 -DOSPTR_STD="11"
430osptr_11: osptr_compat.cpp
431	$(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
432osptr_14: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++14 -DOSPTR_STD="14"
433osptr_14: osptr_compat.cpp
434	$(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
435osptr_17: OTHER_CXXFLAGS += -I$(SRCROOT)/../libkern -std=c++17 -DOSPTR_STD="17"
436osptr_17: osptr_compat.cpp
437	$(CXX) $(DT_CXXFLAGS) $(OTHER_CXXFLAGS) $(CXXFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
438
439priority_queue: OTHER_CXXFLAGS += -std=c++17
440vm/zalloc: OTHER_LDFLAGS += -ldarwintest_utils
441vm/zalloc_buddy: OTHER_CFLAGS += -Wno-format-pedantic
442
443os_refcnt: OTHER_CFLAGS += -I$(SRCROOT)/../libkern/ -Wno-gcc-compat -Wno-undef -O3 -flto
444
445kernel_inspection: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
446kernel_inspection: OTHER_CFLAGS += -DENTITLED=1
447
448turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
449turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
450
451CUSTOM_TARGETS += perf_exit_proc
452
453perf_exit_proc:
454	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
455
456install-perf_exit_proc: perf_exit_proc
457	mkdir -p $(INSTALLDIR)
458	cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
459
460stackshot_idle_25570396: ./stackshot-entitlements.plist
461stackshot_idle_25570396: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
462stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
463stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
464
465stackshot_block_owner_14362384: ./stackshot-entitlements.plist
466stackshot_block_owner_14362384: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
467stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
468ifeq ($(PLATFORM),MacOSX)
469stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
470endif
471
472all: $(DSTROOT)/usr/local/bin/kcdata
473
474$(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
475	mkdir -p $(dir $@)
476	cp $< $@
477	chmod a+x $@
478
479xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
480
481CUSTOM_TARGETS += vm_set_max_addr_helper
482
483vm_set_max_addr_helper: vm_set_max_addr_helper.c
484	$(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
485	echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
486	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
487
488install-vm_set_max_addr_helper: vm_set_max_addr_helper
489	mkdir -p $(INSTALLDIR)
490	cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
491
492CUSTOM_TARGETS += subsystem_root_path_helper_entitled
493CUSTOM_TARGETS += subsystem_root_path_helper
494
495subsystem_root_path_helper_entitled: subsystem_root_path_helper.c subsystem_root_path-entitlements.plist
496	$(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) subsystem_root_path_helper.c -o $(SYMROOT)/subsystem_root_path_helper_entitled; \
497	echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
498	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements subsystem_root_path-entitlements.plist $(SYMROOT)/$@;
499
500install-subsystem_root_path_helper_entitled: subsystem_root_path_helper_entitled
501	mkdir -p $(INSTALLDIR)
502	cp $(SYMROOT)/subsystem_root_path_helper_entitled $(INSTALLDIR)/
503
504subsystem_root_path_helper: subsystem_root_path_helper.c
505	$(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) subsystem_root_path_helper.c -o $(SYMROOT)/subsystem_root_path_helper; \
506	echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
507	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
508
509install-subsystem_root_path_helper: subsystem_root_path_helper
510	mkdir -p $(INSTALLDIR)
511	cp $(SYMROOT)/subsystem_root_path_helper $(INSTALLDIR)/
512
513CUSTOM_TARGETS += vm_test_code_signing_helper
514
515vm_test_code_signing_helper: vm_test_code_signing_helper.c
516	$(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_test_code_signing_helper.c -o $(SYMROOT)/vm_test_code_signing_helper; \
517	echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
518	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
519
520install-vm_test_code_signing_helper: vm_test_code_signing_helper
521	mkdir -p $(INSTALLDIR)
522	cp $(SYMROOT)/vm_test_code_signing_helper $(INSTALLDIR)/
523
524vm_test_code_signing: OTHER_LDFLAGS += -ldarwintest_utils
525
526INCLUDED_TEST_SOURCE_DIRS += vm ipc rm workq
527
528# Revert to legacy vm_test suite until <rdar://problem/56675212> gets solved
529EXCLUDED_SOURCES += vm/vm_allocation.c
530
531EXCLUDED_SOURCES += jumbo_va_spaces_common.c
532
533ifeq ($(IOS_TEST_COMPAT),YES)
534OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled jumbo_va_spaces_52551256 vm_phys_footprint_legacy vm/entitlement_increased_memory_limit vm/entitlement_increased_memory_limit_unentitled vm/ios13extended_footprint vm/memorystatus_freeze_test vm/memorystatus_freeze_test_entitled vm/entitlement_internal_bands vm/entitlement_internal_bands_unentitled
535
536jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
537jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1 -DTESTNAME=jumbo_va_spaces_28530648
538jumbo_va_spaces_28530648: jumbo_va_spaces_common.c
539jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
540jumbo_va_spaces_28530648: OTHER_LDFLAGS += -sectcreate __TEXT __info_plist jumbo_va_spaces_28530648-identifier.plist
541
542jumbo_va_spaces_52551256: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_52551256.entitlements
543jumbo_va_spaces_52551256: OTHER_CFLAGS += -DENTITLED=1 -DTESTNAME=jumbo_va_spaces_52551256
544jumbo_va_spaces_52551256: OTHER_LDFLAGS += -ldarwintest_utils
545jumbo_va_spaces_52551256: jumbo_va_spaces_28530648.c jumbo_va_spaces_common.c
546	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
547	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
548
549jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
550jumbo_va_spaces_28530648_unentitled: OTHER_CFLAGS += -DTESTNAME=jumbo_va_spaces_28530648_unentitled
551
552jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c jumbo_va_spaces_common.c
553	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
554
555vm/entitlement_increased_memory_limit: CODE_SIGN_ENTITLEMENTS = vm/entitlement_increased_memory_limit.entitlements
556vm/entitlement_increased_memory_limit: OTHER_CFLAGS += -DENTITLED=1 jumbo_va_spaces_common.c
557vm/entitlement_increased_memory_limit: OTHER_LDFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
558vm/entitlement_increased_memory_limit: vm/entitlement_increased_memory_limit.c
559	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
560	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
561
562vm/entitlement_increased_memory_limit_unentitled: OTHER_LDFLAGS += -ldarwintest_utils memorystatus_assertion_helpers.c
563vm/entitlement_increased_memory_limit_unentitled: vm/entitlement_increased_memory_limit.c jumbo_va_spaces_common.c
564	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
565
566vm/entitlement_internal_bands: CODE_SIGN_ENTITLEMENTS = vm/entitlement_internal_bands.entitlements
567vm/entitlement_internal_bands: OTHER_CFLAGS += -DENTITLED=1
568vm/entitlement_internal_bands: OTHER_LDFLAGS += -ldarwintest_utils
569vm/entitlement_internal_bands: vm/entitlement_internal_bands.c memorystatus_assertion_helpers.c
570	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
571	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
572
573vm/entitlement_internal_bands_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
574vm/entitlement_internal_bands_unentitled: vm/entitlement_internal_bands.c memorystatus_assertion_helpers.c
575	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $^ -o $(SYMROOT)/$@
576	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
577
578vm/ios13extended_footprint: CODE_SIGN_ENTITLEMENTS = vm/ios13extended_footprint.entitlements
579vm/ios13extended_footprint: vm/ios13extended_footprint.c
580	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
581	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none --entitlements $(CODE_SIGN_ENTITLEMENTS) $(SYMROOT)/$@;
582
583vm_phys_footprint_legacy: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
584vm_phys_footprint_legacy: OTHER_CFLAGS += -DLEGACY_FOOTPRINT_ENTITLED=1
585vm_phys_footprint_legacy: CODE_SIGN_ENTITLEMENTS=./legacy_footprint.entitlement
586vm_phys_footprint_legacy: vm_phys_footprint.c
587	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
588
589endif
590
591CUSTOM_TARGETS += vm/hello
592
593vm/hello: vm/hello.c
594	$(CC) $(LDFLAGS) $(CFLAGS) $< -o $(SYMROOT)/$@
595	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
596
597.PHONY: install-vm/hello
598install-vm/hello: vm/hello
599	mkdir -p $(INSTALLDIR)/vm
600	cp $(SYMROOT)/vm/hello $(INSTALLDIR)/vm/
601
602vm/vm_tainted_executable: vm/hello
603
604task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
605
606ipc_read_inspect: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
607
608ipc_thread_ports_race: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
609ipc_thread_ports_race: OTHER_LDFLAGS += -ldarwintest_utils
610
611proc_info: recount/recount_test_utils.c
612proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
613proc_info: OTHER_LDFLAGS += -ldarwintest_utils
614
615proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
616
617proc_info_44873309: CODE_SIGN_ENTITLEMENTS = ./proc_info_44873309.entitlements
618
619disk_mount_conditioner: disk_mount_conditioner*
620disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
621disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
622
623disk_mount_conditioner: OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
624disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
625disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
626disk_mount_conditioner_unentitled: disk_mount_conditioner.c
627	$(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
628
629work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
630work_interval_test: OTHER_CFLAGS += -DENTITLED=1
631
632work_interval_data_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
633work_interval_data_test: OTHER_CFLAGS += -DENTITLED=1
634work_interval_data_test: OTHER_LDFLAGS += -lpthread
635
636game_mode: CODE_SIGN_ENTITLEMENTS = game_mode.entitlements
637
638settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
639
640settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
641settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
642
643thread_group_set_32261625: ./stackshot-entitlements.plist
644thread_group_set_32261625: CODE_SIGN_ENTITLEMENTS=./stackshot-entitlements.plist
645thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
646
647task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
648task_info: OTHER_CFLAGS += test_utils.c
649task_info: OTHER_LDFLAGS += -ldarwintest_utils
650
651extract_right_soft_fail: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
652
653ifneq ($(IOS_TEST_COMPAT),YES)
654	EXCLUDED_SOURCES += task_vm_info_decompressions.c
655endif
656
657ifneq ($(PLATFORM),iPhoneOS)
658	EXCLUDED_SOURCES += vm/compression_sweep.c
659endif
660
661bpf_write: bpflib.c in_cksum.c net_test_lib.c
662bpf_write: OTHER_LDFLAGS += -ldarwintest_utils
663
664udp_bind_connect: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
665tcp_bind_connect: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
666tcp_send_implied_connect: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
667socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
668socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
669icmp_fragmetned_payload: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
670
671net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
672
673net_bridge: inet_transfer.c bpflib.c in_cksum.c net_test_lib.c
674net_bridge: OTHER_LDFLAGS += -ldarwintest_utils
675net_bridge: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
676
677if_generation_id: net_test_lib.c in_cksum.c
678if_generation_id: OTHER_LDFLAGS += -ldarwintest_utils
679
680bpf_direction: bpflib.c
681bpf_direction: OTHER_LDFLAGS += -ldarwintest_utils
682bpf_direction: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
683
684ipv6_bind_race: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
685
686CUSTOM_TARGETS += posix_spawn_archpref_helper
687
688posix_spawn_archpref_helper: posix_spawn_archpref_helper.c
689	$(CC) $(LDFLAGS) $(CFLAGS) posix_spawn_archpref_helper.c -o $(SYMROOT)/$@;
690	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
691
692install-posix_spawn_archpref_helper: posix_spawn_archpref_helper
693	mkdir -p $(INSTALLDIR)
694	cp $(SYMROOT)/posix_spawn_archpref_helper $(INSTALLDIR)/
695
696CUSTOM_TARGETS += posix_spawn_alt_rosetta_helper
697
698posix_spawn_alt_rosetta_helper: posix_spawn_alt_rosetta_helper.c
699	$(CC) $(LDFLAGS) $(CFLAGS) posix_spawn_alt_rosetta_helper.c -o $(SYMROOT)/$@;
700	env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
701
702install-posix_spawn_alt_rosetta_helper: posix_spawn_alt_rosetta_helper
703	mkdir -p $(INSTALLDIR)
704	cp $(SYMROOT)/posix_spawn_alt_rosetta_helper $(INSTALLDIR)/
705
706MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
707
708CUSTOM_TARGETS += excserver
709
710excserver:
711	$(MIG) $(CFLAGS) \
712		-sheader $(OBJROOT)/excserver.h \
713		-server $(OBJROOT)/excserver.c \
714		-header /dev/null -user /dev/null \
715		excserver.defs
716install-excserver: ;
717
718CUSTOM_TARGETS += excserver_protect
719
720excserver_protect:
721	$(MIG) $(CFLAGS) \
722		-DMACH_EXC_SERVER_TASKIDTOKEN \
723		-sheader $(OBJROOT)/excserver_protect.h \
724		-server $(OBJROOT)/excserver_protect.c \
725		-header /dev/null -user /dev/null \
726		excserver_protect.defs
727install-excserver_protect: ;
728
729EXCLUDED_SOURCES += exc_helpers.c
730
731CUSTOM_TARGETS += notifyserver
732
733notifyserver:
734	$(MIG) $(CFLAGS) \
735		-DMACH_NOTIFY_SERVICE_PORT_DESTROYED_EXPECTED \
736		-user /dev/null \
737		-header $(OBJROOT)/notify.h \
738		-sheader $(OBJROOT)/notifyServer.h \
739		-server $(OBJROOT)/notifyServer.c \
740		notifyserver.defs
741install-notifyserver: ;
742
743CUSTOM_TARGETS += rnserver
744
745rnserver:
746	$(MIG) $(CFLAGS) \
747		-user /dev/null \
748		-header $(OBJROOT)/rn.h \
749		-sheader $(OBJROOT)/rnServer.h \
750		-server $(OBJROOT)/rnServer.c \
751		rnserver.defs
752install-rnserver: ;
753
754
755x18_entitled: OTHER_CFLAGS += -Wno-language-extension-token
756x18_entitled: CODE_SIGN_ENTITLEMENTS = x18-entitlements.plist
757x18_unentitled: OTHER_CFLAGS += -Wno-language-extension-token
758ifneq ($(PLATFORM),MacOSX)
759EXCLUDED_SOURCES += x18_legacy.c
760else
761x18_legacy: OTHER_CFLAGS += -Wno-language-extension-token -Wl,-platform_version -Wl,macos -Wl,10.12 -Wl,10.12
762endif
763
764pmap_bench: INVALID_ARCHS = $(filter-out arm%,$(ARCH_CONFIGS))
765
766pmap_stress: INVALID_ARCHS = $(filter-out arm%,$(ARCH_CONFIGS))
767
768hw_breakpoint_step_arm64: CODE_SIGN_ENTITLEMENTS = hw_breakpoint_step_arm64_entitlements.plist
769hw_breakpoint_step_arm64: INVALID_ARCHS = $(filter-out arm64%,$(ARCH_CONFIGS))
770hw_breakpoint_step_arm64: excserver
771hw_breakpoint_step_arm64: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
772
773exc_resource_threads: excserver
774exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
775exc_resource_threads: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
776
777mach_service_port: notifyserver
778mach_service_port: OTHER_CFLAGS += $(OBJROOT)/notifyServer.c -I $(OBJROOT)
779
780fp_exception: excserver exc_helpers.c
781fp_exception: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
782fp_exception: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
783
784ptrauth_failure: excserver exc_helpers.c
785ptrauth_failure: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT) -Wno-language-extension-token
786ptrauth_failure: CODESIGN = $(CODESIGN_HARDENED_RUNTIME)
787ptrauth_failure: CODE_SIGN_ENTITLEMENTS = set_state_and_exception_port.entitlement
788
789decompression_failure: excserver exc_helpers.c
790decompression_failure: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
791decompression_failure: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
792
793ipc/kernel_signed_pac_thread_state: excserver
794ipc/kernel_signed_pac_thread_state: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
795ipc/kernel_signed_pac_thread_state: CODE_SIGN_ENTITLEMENTS = pac_exception_entitlement.plist
796
797ifeq ($(findstring arm64e,$(ARCH_CONFIGS)),)
798EXCLUDED_SOURCES += pac_exception_entitlement.c
799else
800pac_exception_entitlement: excserver exc_helpers.c
801pac_exception_entitlement: OTHER_CFLAGS += $(OBJROOT)/excserver.c -Wno-language-extension-token
802pac_exception_entitlement: CODE_SIGN_ENTITLEMENTS = pac_exception_entitlement.plist
803endif
804
805ifeq ($(findstring arm64,$(ARCH_CONFIGS)),)
806EXCLUDED_SOURCES += arm_cpu_capabilities.c
807else
808arm_cpu_capabilities: INVALID_ARCHS = armv7k x86_64 x86_64h
809arm_cpu_capabilities: excserver exc_helpers.c
810arm_cpu_capabilities: OTHER_CFLAGS += $(OBJROOT)/excserver.c -Wno-language-extension-token -mcpu=apple-a15
811arm_cpu_capabilities: CODE_SIGN_ENTITLEMENTS = set_exception_port.entitlement
812endif
813
814# Disabling building of ldt files as dt_extractmeta crashes
815# in build systems. Ref rdar://110251082
816# Leaving commented bits for future re-enablement
817EXCLUDED_SOURCES += ldt_code32.s ldt.c
818
819#ifeq ($(findstring x86_64,$(ARCH_CONFIGS)),)
820#EXCLUDED_SOURCES += ldt_code32.s ldt.c
821