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