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