xref: /xnu-8796.121.2/makedefs/MakeInc.san (revision c54f35ca767986246321eb901baf8f5ff7923f6a)
1*c54f35caSApple OSS Distributions# -*- mode: makefile;-*-
2*c54f35caSApple OSS Distributions#
3*c54f35caSApple OSS Distributions# Copyright (C) 2021 Apple Inc. All rights reserved.
4*c54f35caSApple OSS Distributions#
5*c54f35caSApple OSS Distributions# MakeInc.san contains global definitions for building,
6*c54f35caSApple OSS Distributions# linking and installing sanitizer runtime support.
7*c54f35caSApple OSS Distributions#
8*c54f35caSApple OSS Distributions
9*c54f35caSApple OSS Distributions#
10*c54f35caSApple OSS Distributions# Generates rule to build symbolset file from specific export file.
11*c54f35caSApple OSS Distributions#
12*c54f35caSApple OSS Distributions#     $(1) - Kext name (without .symbolset suffix)
13*c54f35caSApple OSS Distributions#     $(2) - Exports name (without .exports suffix)
14*c54f35caSApple OSS Distributions
15*c54f35caSApple OSS Distributionsdefine san_symbolset_template
16*c54f35caSApple OSS Distributions
17*c54f35caSApple OSS DistributionsSYMBOL_SET_BUILD_$(1) := $$(OBJPATH)/config/$(1).symbolset
18*c54f35caSApple OSS Distributions
19*c54f35caSApple OSS Distributions# Our external dependency on config/allsymbols from config hierarchy config_all is hardcoded in the toplevel Makefile!
20*c54f35caSApple OSS Distributions$$(SYMBOL_SET_BUILD_$(1)): $$(SRCROOT)/config/$(2).exports $$(OBJPATH)/config/allsymbols $$(KEXT_CREATE_SYMBOL_SET)
21*c54f35caSApple OSS Distributions	@$$(LOG_SYMBOLSET) "$(1)$$(Color0) ($$(ColorLF)$$(CURRENT_ARCH_CONFIG_LC), $$(CURRENT_KERNEL_CONFIG_LC) $$(Color0))"
22*c54f35caSApple OSS Distributions	$$(_v)$$(KEXT_CREATE_SYMBOL_SET)			\
23*c54f35caSApple OSS Distributions		$$(ARCH_FLAGS_$$(CURRENT_ARCH_CONFIG))	\
24*c54f35caSApple OSS Distributions		-import $$(OBJPATH)/config/allsymbols		\
25*c54f35caSApple OSS Distributions		-export $$<		                \
26*c54f35caSApple OSS Distributions		-output $$@ $(_vstdout)
27*c54f35caSApple OSS Distributions
28*c54f35caSApple OSS Distributionsendef
29*c54f35caSApple OSS Distributions
30*c54f35caSApple OSS Distributions#
31*c54f35caSApple OSS Distributions# Generate rule to build System.kext plugin for give sanitizer.
32*c54f35caSApple OSS Distributions#
33*c54f35caSApple OSS Distributions#     $(1) - Name of the kext plugin
34*c54f35caSApple OSS Distributions#     $(2) - Name of the kext variant binary (Kasan_kasan, Kcov, ...)
35*c54f35caSApple OSS Distributions#
36*c54f35caSApple OSS Distributions
37*c54f35caSApple OSS Distributionsdefine san_kext_dstroot_rule_template
38*c54f35caSApple OSS Distributions
39*c54f35caSApple OSS DistributionsDSTROOT_KEXT_$(2) := $$(DSTROOT_SYSTEM_KEXT_PATH)/$(1)/$(2)
40*c54f35caSApple OSS Distributions
41*c54f35caSApple OSS Distributions$$(DSTROOT_KEXT_$(2)): $$(DSTROOT_SYSTEM_KEXT_PATH)/$(1)/% : $$(SYMROOT_SYSTEM_KEXT_PATH)/$(1)/%
42*c54f35caSApple OSS Distributions	$$(_v)$$(MKDIR) $$(@D)
43*c54f35caSApple OSS Distributions	@$$(LOG_INSTALLVARIANT) "$$(Color0)symbolset $$(ColorF)$$(@F)$$(Color0) ($$(ColorLF)$$(CURRENT_KERNEL_CONFIG_LC)$$(Color0))"
44*c54f35caSApple OSS Distributions	$$(_v)$$(INSTALL) $$(EXEC_INSTALL_FLAGS) $$< $$@
45*c54f35caSApple OSS Distributions
46*c54f35caSApple OSS Distributionsendef
47*c54f35caSApple OSS Distributions
48*c54f35caSApple OSS Distributions#
49*c54f35caSApple OSS Distributions# Generate rule to build System.kext plugin in SYMROOT
50*c54f35caSApple OSS Distributions#
51*c54f35caSApple OSS Distributions#     $(1) - Name of the kext plugin
52*c54f35caSApple OSS Distributions#     $(2) - Name of the kext variant binary (Kasan_kasan, Kcov, ...)
53*c54f35caSApple OSS Distributions#     $(3) - build configs to get symbolset binaries from corresponding OBJDIR
54*c54f35caSApple OSS Distributions#
55*c54f35caSApple OSS Distributions
56*c54f35caSApple OSS Distributionsdefine san_kext_symroot_rule_template
57*c54f35caSApple OSS Distributions
58*c54f35caSApple OSS DistributionsSYMROOT_KEXT_$(2) := $$(SYMROOT_SYSTEM_KEXT_PATH)/$(1)/$(2)
59*c54f35caSApple OSS Distributions
60*c54f35caSApple OSS Distributions$$(SYMROOT_KEXT_$(2)): $$(addsuffix /config/$(2).symbolset, \
61*c54f35caSApple OSS Distributions		$$(addprefix $$(OBJROOT)/,$$(foreach bc,$(3),$$(call function_convert_build_config_to_objdir,$$(bc)))))
62*c54f35caSApple OSS Distributions	@$$(LOG_INSTALLSYM) "$$(Color0)symbolset $$(ColorF)$(2)$$(Color0) ($$(ColorLF)$$(CURRENT_KERNEL_CONFIG_LC)$$(Color0))"
63*c54f35caSApple OSS Distributions	$$(_v)$$(MKDIR) $$(@D)
64*c54f35caSApple OSS Distributions	$$(_v)$$(LIPO) -create `(echo $$^ | xargs -L 1 lipo -detailed_info) | \
65*c54f35caSApple OSS Distributions		awk '/is architecture/ {s[$$$$6]=$$$$3} END {for (a in s) {print s[a]}}'` -output $$@ $$(_vstdout)
66*c54f35caSApple OSS Distributions
67*c54f35caSApple OSS Distributionsendef
68