1*c54f35caSApple OSS Distributions# -*- mode: makefile;-*- 2*c54f35caSApple OSS Distributions# 3*c54f35caSApple OSS Distributions# Copyright (C) 1999-2022 Apple Inc. All rights reserved. 4*c54f35caSApple OSS Distributions# 5*c54f35caSApple OSS Distributions# MakeInc.def contains global definitions for building, 6*c54f35caSApple OSS Distributions# linking, and installing files. 7*c54f35caSApple OSS Distributions# 8*c54f35caSApple OSS Distributions 9*c54f35caSApple OSS Distributions# 10*c54f35caSApple OSS Distributions# Architecture Configuration options 11*c54f35caSApple OSS Distributions# 12*c54f35caSApple OSS DistributionsSUPPORTED_ARCH_CONFIGS := X86_64 X86_64H ARM64 13*c54f35caSApple OSS Distributions 14*c54f35caSApple OSS Distributions# 15*c54f35caSApple OSS Distributions# Kernel Configuration options 16*c54f35caSApple OSS Distributions# 17*c54f35caSApple OSS DistributionsSUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE KASAN 18*c54f35caSApple OSS Distributions 19*c54f35caSApple OSS Distributions 20*c54f35caSApple OSS Distributions# 21*c54f35caSApple OSS Distributions# Machine Configuration options 22*c54f35caSApple OSS Distributions# 23*c54f35caSApple OSS Distributions 24*c54f35caSApple OSS DistributionsSUPPORTED_X86_64_MACHINE_CONFIGS = NONE 25*c54f35caSApple OSS DistributionsSUPPORTED_X86_64H_MACHINE_CONFIGS = NONE 26*c54f35caSApple OSS Distributions 27*c54f35caSApple OSS Distributionsifneq ($(findstring _Sim,$(RC_ProjectName)),) 28*c54f35caSApple OSS DistributionsSUPPORTED_ARM64_MACHINE_CONFIGS = NONE 29*c54f35caSApple OSS Distributionselse ifneq ($(findstring _host,$(RC_ProjectName)),) 30*c54f35caSApple OSS DistributionsSUPPORTED_ARM64_MACHINE_CONFIGS = NONE 31*c54f35caSApple OSS Distributionselse 32*c54f35caSApple OSS DistributionsSUPPORTED_ARM64_MACHINE_CONFIGS = BCM2837 T6000 T8101 T8103 VMAPPLE 33*c54f35caSApple OSS Distributions 34*c54f35caSApple OSS Distributionsendif 35*c54f35caSApple OSS Distributions 36*c54f35caSApple OSS Distributions# 37*c54f35caSApple OSS Distributions# Setup up *_LC variables during recursive invocations 38*c54f35caSApple OSS Distributions# 39*c54f35caSApple OSS Distributions 40*c54f35caSApple OSS Distributionsifndef CURRENT_ARCH_CONFIG_LC 41*c54f35caSApple OSS Distributions export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z) 42*c54f35caSApple OSS Distributionsendif 43*c54f35caSApple OSS Distributions 44*c54f35caSApple OSS Distributionsifndef CURRENT_KERNEL_CONFIG_LC 45*c54f35caSApple OSS Distributions export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z) 46*c54f35caSApple OSS Distributionsendif 47*c54f35caSApple OSS Distributions 48*c54f35caSApple OSS Distributionsifndef CURRENT_MACHINE_CONFIG_LC 49*c54f35caSApple OSS Distributions export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z) 50*c54f35caSApple OSS Distributionsendif 51*c54f35caSApple OSS Distributions 52*c54f35caSApple OSS Distributions# 53*c54f35caSApple OSS Distributions# Component List 54*c54f35caSApple OSS Distributions# 55*c54f35caSApple OSS DistributionsCOMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security san 56*c54f35caSApple OSS DistributionsCOMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH)))) 57*c54f35caSApple OSS DistributionsCOMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST)) 58*c54f35caSApple OSS Distributions 59*c54f35caSApple OSS DistributionsMACHINE_FLAGS_ARM64_T8101 = -DARM64_BOARD_CONFIG_T8101 -mcpu=apple-a14 60*c54f35caSApple OSS DistributionsMACHINE_FLAGS_ARM64_T8103 = -DARM64_BOARD_CONFIG_T8103 -mcpu=apple-a14 61*c54f35caSApple OSS DistributionsMACHINE_FLAGS_ARM64_T6000 = -DARM64_BOARD_CONFIG_T6000 -mcpu=apple-a14 62*c54f35caSApple OSS DistributionsMACHINE_FLAGS_ARM64_VMAPPLE = -DARM64_BOARD_CONFIG_VMAPPLE -march=armv8.5a 63*c54f35caSApple OSS DistributionsMACHINE_FLAGS_ARM64_BCM2837 = -DARM64_BOARD_CONFIG_BCM2837 64*c54f35caSApple OSS Distributions 65*c54f35caSApple OSS Distributions 66*c54f35caSApple OSS Distributions# 67*c54f35caSApple OSS Distributions# Deployment target flag 68*c54f35caSApple OSS Distributions# 69*c54f35caSApple OSS Distributionsifeq ($(PLATFORM),MacOSX) 70*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) -DXNU_TARGET_OS_OSX 71*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = -Wl,-macosx_version_min,$(SDKVERSION) 72*c54f35caSApple OSS Distributionselse ifeq ($(PLATFORM),DriverKit) 73*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -target apple-driverkit$(SDKVERSION) -DXNU_TARGET_OS_OSX 74*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = -Wl,-target,apple-driverkit$(SDKVERSION) 75*c54f35caSApple OSS Distributionselse ifeq ($(PLATFORM),WatchOS) 76*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_WATCH 77*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 78*c54f35caSApple OSS Distributionselse ifeq ($(PLATFORM),tvOS) 79*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV 80*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 81*c54f35caSApple OSS Distributionselse ifeq ($(PLATFORM),AppleTVOS) 82*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV 83*c54f35caSApple OSS Distributionselse ifeq ($(PLATFORM),BridgeOS) 84*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_BRIDGE 85*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 86*c54f35caSApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) 87*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_IOS 88*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = -Wl,-ios_version_min,$(SDKVERSION) 89*c54f35caSApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) 90*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = 91*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 92*c54f35caSApple OSS Distributionselse 93*c54f35caSApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = 94*c54f35caSApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 95*c54f35caSApple OSS Distributionsendif 96*c54f35caSApple OSS Distributions 97*c54f35caSApple OSS Distributions 98*c54f35caSApple OSS DistributionsDEPLOYMENT_TARGET_DEFINES = -DXNU_PLATFORM_$(PLATFORM) 99*c54f35caSApple OSS Distributions 100*c54f35caSApple OSS Distributions 101*c54f35caSApple OSS Distributions# 102*c54f35caSApple OSS Distributions# Standard defines list 103*c54f35caSApple OSS Distributions# 104*c54f35caSApple OSS DistributionsDEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \ 105*c54f35caSApple OSS Distributions -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile -DXNU_KERN_EVENT_DATA_IS_VLA \ 106*c54f35caSApple OSS Distributions -DCURRENT_MACHINE_CONFIG_LC=$(CURRENT_MACHINE_CONFIG_LC) \ 107*c54f35caSApple OSS Distributions $(CONFIG_DEFINES) $(SEED_DEFINES) 108*c54f35caSApple OSS Distributions 109*c54f35caSApple OSS Distributions# Enable caching with `make CCACHE=ccache` 110*c54f35caSApple OSS Distributions# This intentionally does not override $(CC) because that will confuse 111*c54f35caSApple OSS Distributions# utilities like mig. 112*c54f35caSApple OSS DistributionsCCACHE ?= 113*c54f35caSApple OSS Distributions 114*c54f35caSApple OSS Distributions# 115*c54f35caSApple OSS Distributions# Compiler command 116*c54f35caSApple OSS Distributions# 117*c54f35caSApple OSS DistributionsKCC = $(CCACHE) $(CC) 118*c54f35caSApple OSS DistributionsKC++ = $(CCACHE) $(CXX) 119*c54f35caSApple OSS Distributions 120*c54f35caSApple OSS DistributionsGENASSYM_KCC = $(CCACHE) $(CC) 121*c54f35caSApple OSS Distributions 122*c54f35caSApple OSS Distributions# 123*c54f35caSApple OSS Distributions# Compiler warning flags 124*c54f35caSApple OSS Distributions# 125*c54f35caSApple OSS Distributions 126*c54f35caSApple OSS DistributionsUSE_WERROR := 1 127*c54f35caSApple OSS Distributionsifneq ($(BUILD_WERROR),) 128*c54f35caSApple OSS DistributionsUSE_WERROR := $(BUILD_WERROR) 129*c54f35caSApple OSS Distributionsendif 130*c54f35caSApple OSS Distributions 131*c54f35caSApple OSS Distributionsifeq ($(USE_WERROR),1) 132*c54f35caSApple OSS DistributionsWERROR := -Werror 133*c54f35caSApple OSS Distributionsendif 134*c54f35caSApple OSS Distributions 135*c54f35caSApple OSS Distributions# Shared C/C++ warning flags 136*c54f35caSApple OSS Distributions# NOTE: order matters here. -Wno-xxx goes before opt-in of ones we want 137*c54f35caSApple OSS DistributionsWARNFLAGS_STD := \ 138*c54f35caSApple OSS Distributions -Weverything \ 139*c54f35caSApple OSS Distributions -Wundef-prefix=TARGET_OS_ \ 140*c54f35caSApple OSS Distributions -Wundef-prefix=LCK_GRP_USE_ARG \ 141*c54f35caSApple OSS Distributions -Wno-pedantic \ 142*c54f35caSApple OSS Distributions $(WERROR) \ 143*c54f35caSApple OSS Distributions -Wno-bad-function-cast \ 144*c54f35caSApple OSS Distributions -Wno-bitwise-instead-of-logical \ 145*c54f35caSApple OSS Distributions -Wno-c++-compat \ 146*c54f35caSApple OSS Distributions -Wno-c++98-compat \ 147*c54f35caSApple OSS Distributions -Wno-conditional-uninitialized \ 148*c54f35caSApple OSS Distributions -Wno-covered-switch-default \ 149*c54f35caSApple OSS Distributions -Wno-disabled-macro-expansion \ 150*c54f35caSApple OSS Distributions -Wno-documentation-unknown-command \ 151*c54f35caSApple OSS Distributions -Wno-extra-semi-stmt \ 152*c54f35caSApple OSS Distributions -Wno-format-non-iso \ 153*c54f35caSApple OSS Distributions -Wno-language-extension-token \ 154*c54f35caSApple OSS Distributions -Wno-missing-variable-declarations \ 155*c54f35caSApple OSS Distributions -Wno-packed \ 156*c54f35caSApple OSS Distributions -Wno-padded \ 157*c54f35caSApple OSS Distributions -Wno-partial-availability \ 158*c54f35caSApple OSS Distributions -Wno-reserved-id-macro \ 159*c54f35caSApple OSS Distributions -Wno-shift-sign-overflow \ 160*c54f35caSApple OSS Distributions -Wno-switch-enum \ 161*c54f35caSApple OSS Distributions -Wno-unaligned-access \ 162*c54f35caSApple OSS Distributions -Wno-undef \ 163*c54f35caSApple OSS Distributions -Wno-unused-macros \ 164*c54f35caSApple OSS Distributions -Wno-used-but-marked-unused \ 165*c54f35caSApple OSS Distributions -Wno-variadic-macros \ 166*c54f35caSApple OSS Distributions -Wno-vla \ 167*c54f35caSApple OSS Distributions -Wno-zero-length-array 168*c54f35caSApple OSS Distributions 169*c54f35caSApple OSS Distributions# When a new clang has new warnings disable them here until the kernel is fixed. 170*c54f35caSApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 171*c54f35caSApple OSS Distributions -Wno-unknown-warning-option \ 172*c54f35caSApple OSS Distributions -Wno-anon-enum-enum-conversion \ 173*c54f35caSApple OSS Distributions -Wno-error=enum-enum-conversion \ 174*c54f35caSApple OSS Distributions -Wno-error=c99-designator \ 175*c54f35caSApple OSS Distributions -Wno-error=reorder-init-list 176*c54f35caSApple OSS Distributions 177*c54f35caSApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 178*c54f35caSApple OSS Distributions -Wno-error=declaration-after-statement 179*c54f35caSApple OSS Distributions 180*c54f35caSApple OSS Distributions# Hand-written sign conversion diagnostics are resolved, but the 181*c54f35caSApple OSS Distributions# auto-generated ones need mig and iig to be updated to fix. Disable the 182*c54f35caSApple OSS Distributions# diagnostic here until we've completed that: 183*c54f35caSApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 184*c54f35caSApple OSS Distributions -Wno-sign-compare \ 185*c54f35caSApple OSS Distributions -Wno-sign-conversion 186*c54f35caSApple OSS Distributions 187*c54f35caSApple OSS Distributions# Opt-ins: 188*c54f35caSApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 189*c54f35caSApple OSS Distributions -Wpointer-arith \ 190*c54f35caSApple OSS Distributions -Wxnu-typed-allocators 191*c54f35caSApple OSS Distributions 192*c54f35caSApple OSS DistributionsCWARNFLAGS_STD = \ 193*c54f35caSApple OSS Distributions $(WARNFLAGS_STD) 194*c54f35caSApple OSS Distributions 195*c54f35caSApple OSS Distributions 196*c54f35caSApple OSS Distributions 197*c54f35caSApple OSS Distributions# Can be overridden in Makefile.template or Makefile.$arch 198*c54f35caSApple OSS Distributionsexport CWARNFLAGS ?= $(CWARNFLAGS_STD) 199*c54f35caSApple OSS Distributions 200*c54f35caSApple OSS Distributionsdefine add_perfile_cflags 201*c54f35caSApple OSS Distributions$(1)_CWARNFLAGS_ADD += $2 202*c54f35caSApple OSS Distributionsendef 203*c54f35caSApple OSS Distributions 204*c54f35caSApple OSS Distributionsdefine rm_perfile_cflags 205*c54f35caSApple OSS Distributions$(1)_CFLAGS_RM += $2 206*c54f35caSApple OSS Distributionsendef 207*c54f35caSApple OSS Distributions 208*c54f35caSApple OSS DistributionsCXXWARNFLAGS_STD = \ 209*c54f35caSApple OSS Distributions $(WARNFLAGS_STD) \ 210*c54f35caSApple OSS Distributions -Wno-c++98-compat-pedantic \ 211*c54f35caSApple OSS Distributions -Wno-exit-time-destructors \ 212*c54f35caSApple OSS Distributions -Wno-global-constructors \ 213*c54f35caSApple OSS Distributions -Wno-old-style-cast 214*c54f35caSApple OSS Distributions 215*c54f35caSApple OSS Distributions# Can be overridden in Makefile.template or Makefile.$arch 216*c54f35caSApple OSS Distributionsexport CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD) 217*c54f35caSApple OSS Distributions 218*c54f35caSApple OSS Distributionsdefine add_perfile_cxxflags 219*c54f35caSApple OSS Distributions$(1)_CXXWARNFLAGS_ADD += $2 220*c54f35caSApple OSS Distributionsendef 221*c54f35caSApple OSS Distributions 222*c54f35caSApple OSS Distributions# 223*c54f35caSApple OSS Distributions# Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers 224*c54f35caSApple OSS Distributions 225*c54f35caSApple OSS DistributionsARCH_FLAGS_X86_64 = -arch x86_64 226*c54f35caSApple OSS DistributionsARCH_FLAGS_X86_64H = -arch x86_64h 227*c54f35caSApple OSS Distributions 228*c54f35caSApple OSS Distributionsifeq ($(RC_ProjectName),xnu_libraries) 229*c54f35caSApple OSS DistributionsBUILD_STATIC_LINK := 1 230*c54f35caSApple OSS DistributionsBUILD_XNU_LIBRARY := 1 231*c54f35caSApple OSS DistributionsRC_NONARCH_CFLAGS += -D__BUILDING_XNU_LIBRARY__=1 232*c54f35caSApple OSS Distributionsendif 233*c54f35caSApple OSS Distributions 234*c54f35caSApple OSS Distributionsifneq ($(filter ARM ARM64,$(CURRENT_ARCH_CONFIG)),) 235*c54f35caSApple OSS Distributions 236*c54f35caSApple OSS Distributionsifneq ($(findstring _Sim,$(RC_ProjectName)),) 237*c54f35caSApple OSS DistributionsARCH_FLAGS_ARM64 = -arch arm64e 238*c54f35caSApple OSS Distributionselse ifneq ($(findstring _host,$(RC_ProjectName)),) 239*c54f35caSApple OSS DistributionsARCH_FLAGS_ARM64 = -arch arm64e 240*c54f35caSApple OSS Distributionselse 241*c54f35caSApple OSS Distributions 242*c54f35caSApple OSS DistributionsARCH_STRING_FOR_CURRENT_MACHINE_CONFIG ?= 243*c54f35caSApple OSS Distributions 244*c54f35caSApple OSS Distributionsifeq ($(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),) 245*c54f35caSApple OSS Distributions 246*c54f35caSApple OSS Distributionsifneq ($(EMBEDDED_DEVICE_MAP),) 247*c54f35caSApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -list -query SELECT DISTINCT KernelMachOArchitecture FROM Targets WHERE KernelPlatform IS \"$(CURRENT_MACHINE_CONFIG_LC)\" LIMIT 1 || echo UNKNOWN ) 248*c54f35caSApple OSS Distributionsifeq ($(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),) 249*c54f35caSApple OSS Distributionsifeq ($(filter $(EXTRA_TARGET_CONFIGS_$(CURRENT_KERNEL_CONFIG)),$(CURRENT_MACHINE_CONFIG)),) 250*c54f35caSApple OSS Distributions$(error Machine config $(CURRENT_MACHINE_CONFIG_LC) not found in EmbeddedDeviceMap) 251*c54f35caSApple OSS Distributionsendif 252*c54f35caSApple OSS Distributionsendif 253*c54f35caSApple OSS Distributionsendif 254*c54f35caSApple OSS Distributions 255*c54f35caSApple OSS Distributionsendif 256*c54f35caSApple OSS Distributions 257*c54f35caSApple OSS Distributionsifeq ($(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),) 258*c54f35caSApple OSS Distributions 259*c54f35caSApple OSS Distributions# Without embdedded device map, use a default arch string 260*c54f35caSApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z) 261*c54f35caSApple OSS Distributionsifneq ($(filter arm64,$(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG)),) 262*c54f35caSApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := arm64e 263*c54f35caSApple OSS Distributionsendif 264*c54f35caSApple OSS Distributions 265*c54f35caSApple OSS Distributionsendif 266*c54f35caSApple OSS Distributions 267*c54f35caSApple OSS Distributions 268*c54f35caSApple OSS DistributionsBUILD_STATIC_LINK := 1 269*c54f35caSApple OSS Distributions 270*c54f35caSApple OSS DistributionsARCH_FLAGS_ARM64 = -arch $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG) 271*c54f35caSApple OSS Distributions 272*c54f35caSApple OSS Distributionsendif 273*c54f35caSApple OSS Distributions 274*c54f35caSApple OSS Distributionselse 275*c54f35caSApple OSS Distributions# non arm machine config string 276*c54f35caSApple OSS Distributionsifndef ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG 277*c54f35caSApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z) 278*c54f35caSApple OSS Distributionsendif 279*c54f35caSApple OSS Distributions 280*c54f35caSApple OSS Distributionsendif 281*c54f35caSApple OSS Distributions 282*c54f35caSApple OSS Distributions# 283*c54f35caSApple OSS Distributions# Default CFLAGS 284*c54f35caSApple OSS Distributions# 285*c54f35caSApple OSS Distributionsifdef RC_NONARCH_CFLAGS 286*c54f35caSApple OSS DistributionsOTHER_CFLAGS = $(RC_NONARCH_CFLAGS) 287*c54f35caSApple OSS Distributionsendif 288*c54f35caSApple OSS Distributions 289*c54f35caSApple OSS Distributions# 290*c54f35caSApple OSS Distributions# Debug info 291*c54f35caSApple OSS Distributions# 292*c54f35caSApple OSS DistributionsDSYMINFODIR = Contents 293*c54f35caSApple OSS DistributionsDSYMKGMACROSDIR = Contents/Resources 294*c54f35caSApple OSS DistributionsDSYMLLDBMACROSDIR = Contents/Resources/Python 295*c54f35caSApple OSS DistributionsDSYMDWARFDIR = Contents/Resources/DWARF 296*c54f35caSApple OSS Distributions 297*c54f35caSApple OSS DistributionsDEBUG_CFLAGS := -g 298*c54f35caSApple OSS DistributionsBUILD_DSYM := 1 299*c54f35caSApple OSS Distributions 300*c54f35caSApple OSS Distributions# 301*c54f35caSApple OSS Distributions# We must not use -fno-keep-inline-functions, or it will remove the dtrace 302*c54f35caSApple OSS Distributions# probes from the kernel. 303*c54f35caSApple OSS Distributions# 304*c54f35caSApple OSS DistributionsCFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \ 305*c54f35caSApple OSS Distributions -ferror-limit=10000 \ 306*c54f35caSApple OSS Distributions -fno-builtin \ 307*c54f35caSApple OSS Distributions -fno-common \ 308*c54f35caSApple OSS Distributions -ftrivial-auto-var-init=zero \ 309*c54f35caSApple OSS Distributions -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \ 310*c54f35caSApple OSS Distributions -fsigned-bitfields \ 311*c54f35caSApple OSS Distributions -fmerge-all-constants \ 312*c54f35caSApple OSS Distributions -fno-c++-static-destructors \ 313*c54f35caSApple OSS Distributions $(OTHER_CFLAGS) 314*c54f35caSApple OSS Distributions 315*c54f35caSApple OSS DistributionsCFLAGS_RELEASE = 316*c54f35caSApple OSS DistributionsCFLAGS_DEVELOPMENT = 317*c54f35caSApple OSS DistributionsCFLAGS_DEBUG = 318*c54f35caSApple OSS DistributionsCFLAGS_KASAN = $(CFLAGS_DEVELOPMENT) 319*c54f35caSApple OSS DistributionsCFLAGS_PROFILE = -pg 320*c54f35caSApple OSS Distributions 321*c54f35caSApple OSS DistributionsCFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \ 322*c54f35caSApple OSS Distributions -DPAGE_SIZE_FIXED -mkernel -msoft-float 323*c54f35caSApple OSS Distributions 324*c54f35caSApple OSS DistributionsCFLAGS_X86_64H = $(CFLAGS_X86_64) 325*c54f35caSApple OSS Distributions 326*c54f35caSApple OSS DistributionsLARGE_MEMORY_DEFINE=-UARM_LARGE_MEMORY 327*c54f35caSApple OSS DistributionsARM64_PLKSEG_ADDR =0xfffffff004004000 328*c54f35caSApple OSS DistributionsARM64_LINK_ADDR =0xfffffff007004000 329*c54f35caSApple OSS Distributions 330*c54f35caSApple OSS Distributions# Use ARM_LARGE_MEMORY config for all MacOSX targets. 331*c54f35caSApple OSS Distributionsifneq ($(filter $(PLATFORM),MacOSX),) 332*c54f35caSApple OSS DistributionsLARGE_MEMORY_DEFINE=-DARM_LARGE_MEMORY=1 333*c54f35caSApple OSS DistributionsARM64_PLKSEG_ADDR =0xfffffe0004004000 334*c54f35caSApple OSS DistributionsARM64_LINK_ADDR =0xfffffe0007004000 335*c54f35caSApple OSS Distributionsendif 336*c54f35caSApple OSS Distributions 337*c54f35caSApple OSS Distributions 338*c54f35caSApple OSS DistributionsCFLAGS_ARM64 = -Darm64 -DARM64 -D__ARM64__ -DLP64 -DPAGE_SIZE_FIXED -DVM_KERNEL_LINK_ADDRESS=$(ARM64_LINK_ADDR) \ 339*c54f35caSApple OSS Distributions $(LARGE_MEMORY_DEFINE) -momit-leaf-frame-pointer -fno-strict-aliasing -D__API__=v4 -mkernel 340*c54f35caSApple OSS Distributions 341*c54f35caSApple OSS DistributionsCFLAGS_RELEASEX86_64 = -O2 342*c54f35caSApple OSS DistributionsCFLAGS_DEVELOPMENTX86_64 = -O2 343*c54f35caSApple OSS DistributionsCFLAGS_KASANX86_64 = $(CFLAGS_DEVELOPMENTX86_64) 344*c54f35caSApple OSS Distributions# No space optimization for the DEBUG kernel for the benefit of gdb: 345*c54f35caSApple OSS DistributionsCFLAGS_DEBUGX86_64 = -O0 346*c54f35caSApple OSS DistributionsCFLAGS_PROFILEX86_64 = -O2 347*c54f35caSApple OSS Distributions 348*c54f35caSApple OSS DistributionsCFLAGS_RELEASEX86_64H = -O2 349*c54f35caSApple OSS DistributionsCFLAGS_DEVELOPMENTX86_64H = -O2 350*c54f35caSApple OSS DistributionsCFLAGS_KASANX86_64H = $(CFLAGS_DEVELOPMENTX86_64H) 351*c54f35caSApple OSS Distributions# No space optimization for the DEBUG kernel for the benefit of gdb: 352*c54f35caSApple OSS DistributionsCFLAGS_DEBUGX86_64H = -O0 353*c54f35caSApple OSS DistributionsCFLAGS_PROFILEX86_64H = -O2 354*c54f35caSApple OSS Distributions 355*c54f35caSApple OSS DistributionsCFLAGS_RELEASEARM = -O2 356*c54f35caSApple OSS DistributionsCFLAGS_DEVELOPMENTARM = -O2 357*c54f35caSApple OSS DistributionsCFLAGS_DEBUGARM = -O0 358*c54f35caSApple OSS DistributionsCFLAGS_PROFILEARM = -O2 359*c54f35caSApple OSS Distributions 360*c54f35caSApple OSS DistributionsCFLAGS_RELEASEARM64 = -O2 361*c54f35caSApple OSS DistributionsCFLAGS_DEVELOPMENTARM64 = -O2 362*c54f35caSApple OSS DistributionsCFLAGS_KASANARM64 = $(CFLAGS_DEVELOPMENTARM64) 363*c54f35caSApple OSS DistributionsCFLAGS_DEBUGARM64 = -O0 364*c54f35caSApple OSS DistributionsCFLAGS_PROFILEARM64 = -O2 365*c54f35caSApple OSS Distributions 366*c54f35caSApple OSS Distributions# 367*c54f35caSApple OSS Distributions# bound-checking support 368*c54f35caSApple OSS Distributions# 369*c54f35caSApple OSS Distributions# BOUND_CHECKS=0 disables, else support is dynamically detected 370*c54f35caSApple OSS Distributions# 371*c54f35caSApple OSS Distributionsifndef BOUND_CHECKS 372*c54f35caSApple OSS Distributionsifeq ($(shell $(CC) -E -fbounds-attributes /dev/null 2>/dev/null && echo 1),1) 373*c54f35caSApple OSS Distributions export BOUND_CHECKS := 1 374*c54f35caSApple OSS Distributionselse 375*c54f35caSApple OSS Distributions export BOUND_CHECKS := 0 376*c54f35caSApple OSS Distributionsendif 377*c54f35caSApple OSS Distributionsendif # ifndef BOUND_CHECKS 378*c54f35caSApple OSS Distributionsifeq ($(BOUND_CHECKS),1) 379*c54f35caSApple OSS DistributionsCFLAGS_BOUND_CHECKS = -fbounds-attributes 380*c54f35caSApple OSS Distributionselse 381*c54f35caSApple OSS DistributionsCFLAGS_BOUND_CHECKS = 382*c54f35caSApple OSS Distributionsendif 383*c54f35caSApple OSS Distributions 384*c54f35caSApple OSS Distributions# 385*c54f35caSApple OSS Distributions# Sanitizers Support (KASan, UBSan) 386*c54f35caSApple OSS Distributions# 387*c54f35caSApple OSS Distributions 388*c54f35caSApple OSS Distributions# Which kernel configurations are built with KCOV enabled. 389*c54f35caSApple OSS DistributionsKCOV_RUNTIME := KASAN 390*c54f35caSApple OSS Distributions 391*c54f35caSApple OSS Distributionsifneq ($(filter RELEASE, $(KCOV_RUNTIME)),) 392*c54f35caSApple OSS Distributions$(error "Sanitizer runtime should not be enabled for RELEASE kernel.") 393*c54f35caSApple OSS Distributionsendif 394*c54f35caSApple OSS Distributions 395*c54f35caSApple OSS Distributions 396*c54f35caSApple OSS DistributionsSAN=0 397*c54f35caSApple OSS Distributions 398*c54f35caSApple OSS Distributions# KASan support 399*c54f35caSApple OSS Distributions# 400*c54f35caSApple OSS Distributions 401*c54f35caSApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),KASAN) 402*c54f35caSApple OSS Distributions# KASan kernel config implicitly enables the KASan instrumentation. 403*c54f35caSApple OSS Distributions# Instrumentation for other sanitizers is enabled explicitly at build time. 404*c54f35caSApple OSS DistributionsKASAN = 1 405*c54f35caSApple OSS Distributionsendif 406*c54f35caSApple OSS Distributions 407*c54f35caSApple OSS Distributionsifeq ($(KASAN),1) 408*c54f35caSApple OSS DistributionsSAN=1 409*c54f35caSApple OSS DistributionsBUILD_LTO=0 410*c54f35caSApple OSS Distributions 411*c54f35caSApple OSS Distributions# KASan Light support 412*c54f35caSApple OSS Distributions# 413*c54f35caSApple OSS Distributions# Light mode omits the HWASAN stack instrumentation. 414*c54f35caSApple OSS Distributions# Not supported by KASan Classic at this moment. 415*c54f35caSApple OSS Distributions 416*c54f35caSApple OSS DistributionsKASAN_LIGHT_PLATFORM := WatchOS 417*c54f35caSApple OSS Distributions 418*c54f35caSApple OSS Distributionsifneq ($(filter $(PLATFORM), $(KASAN_LIGHT_PLATFORM)),) 419*c54f35caSApple OSS DistributionsKASAN_LIGHT=1 420*c54f35caSApple OSS DistributionsHWASAN_INSTRUMENT_STACK=0 421*c54f35caSApple OSS Distributionselse 422*c54f35caSApple OSS DistributionsKASAN_LIGHT=0 423*c54f35caSApple OSS DistributionsHWASAN_INSTRUMENT_STACK=1 424*c54f35caSApple OSS Distributionsendif 425*c54f35caSApple OSS Distributions 426*c54f35caSApple OSS DistributionsKASAN_BLACKLIST=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC) 427*c54f35caSApple OSS Distributions 428*c54f35caSApple OSS Distributions# To calculate the kasan offset, subtract the lowest KVA to sanitize, shifted right by KASAN_SCALE_$INSTRUMENTATION bits, 429*c54f35caSApple OSS Distributions# from the base address of the kasan shadow area, (e.g. for x86_64 solve the following equation: 430*c54f35caSApple OSS Distributions# OFFSET = {VA mapped by the first KASAN PML4 [Currently #494]} - (LOWEST_KVA >> 3) 431*c54f35caSApple OSS Distributions# OFFSET = (0ULL - (512GiB * (512 - 494))) - (LOWEST_SAN_KVA >> 3) 432*c54f35caSApple OSS Distributions# OFFSET = FFFFF70000000000 - ((0ULL - (512GiB * (512 - 496))) >> 3) [PML4 #496 is the first possible KVA] 433*c54f35caSApple OSS Distributions# OFFSET = FFFFF70000000000 - (FFFFF80000000000 >> 3) 434*c54f35caSApple OSS Distributions# OFFSET = DFFFF80000000000 435*c54f35caSApple OSS Distributions# ). 436*c54f35caSApple OSS DistributionsKASAN_OFFSET_X86_64=0xdffff80000000000 437*c54f35caSApple OSS DistributionsKASAN_OFFSET_X86_64H=$(KASAN_OFFSET_X86_64) 438*c54f35caSApple OSS DistributionsKASAN_OFFSET_ARM64=0xf000000000000000 439*c54f35caSApple OSS Distributions 440*c54f35caSApple OSS DistributionsKASAN_OFFSET=$($(addsuffix $(CURRENT_ARCH_CONFIG),KASAN_OFFSET_)) 441*c54f35caSApple OSS Distributions 442*c54f35caSApple OSS Distributions# CLANG HWASAN/KHWASAN instrumentation powers KASAN_TBI. HWASAN traditional prefixing 443*c54f35caSApple OSS Distributions# is replaced by __asan_ to commonize exports across models. 444*c54f35caSApple OSS DistributionsKASAN_SCALE_TBI=4 445*c54f35caSApple OSS DistributionsCFLAGS_KASAN_INSTRUMENTATION_TBI = -DKASAN_TBI=1 -DKASAN_SCALE=$(KASAN_SCALE_TBI) \ 446*c54f35caSApple OSS Distributions -fsanitize=kernel-hwaddress \ 447*c54f35caSApple OSS Distributions -fsanitize-ignorelist=$(KASAN_BLACKLIST) \ 448*c54f35caSApple OSS Distributions -mllvm -hwasan-recover=0 \ 449*c54f35caSApple OSS Distributions -mllvm -hwasan-mapping-offset=$(KASAN_OFFSET) \ 450*c54f35caSApple OSS Distributions -mllvm -hwasan-instrument-atomics=1 \ 451*c54f35caSApple OSS Distributions -mllvm -hwasan-instrument-stack=$(HWASAN_INSTRUMENT_STACK) \ 452*c54f35caSApple OSS Distributions -mllvm -hwasan-uar-retag-to-zero=0 \ 453*c54f35caSApple OSS Distributions -mllvm -hwasan-generate-tags-with-calls=1 \ 454*c54f35caSApple OSS Distributions -mllvm -hwasan-instrument-with-calls=0 \ 455*c54f35caSApple OSS Distributions -mllvm -hwasan-use-short-granules=0 \ 456*c54f35caSApple OSS Distributions -mllvm -hwasan-memory-access-callback-prefix="__asan_" 457*c54f35caSApple OSS Distributions 458*c54f35caSApple OSS Distributions 459*c54f35caSApple OSS DistributionsKASAN_SCALE_CLASSIC=3 460*c54f35caSApple OSS DistributionsCFLAGS_KASAN_INSTRUMENTATION_CLASSIC = -DKASAN_CLASSIC=1 -DKASAN_SCALE=$(KASAN_SCALE_CLASSIC) \ 461*c54f35caSApple OSS Distributions -fsanitize=address \ 462*c54f35caSApple OSS Distributions -mllvm -asan-globals-live-support \ 463*c54f35caSApple OSS Distributions -mllvm -asan-mapping-offset=$(KASAN_OFFSET) \ 464*c54f35caSApple OSS Distributions -fsanitize-ignorelist=$(KASAN_BLACKLIST) 465*c54f35caSApple OSS Distributions 466*c54f35caSApple OSS DistributionsCFLAGS_KASANARM64 += $(CFLAGS_KASAN_INSTRUMENTATION_TBI) 467*c54f35caSApple OSS DistributionsCFLAGS_KASANX86_64 += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 468*c54f35caSApple OSS DistributionsCFLAGS_KASANX86_64H += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 469*c54f35caSApple OSS DistributionsCFLAGS_GEN += -DKASAN=1 -DKASAN_OFFSET=$(KASAN_OFFSET) -DKASAN_LIGHT=$(KASAN_LIGHT) 470*c54f35caSApple OSS Distributions 471*c54f35caSApple OSS DistributionsSFLAGS_KASANARM64 += $(CFLAGS_KASAN_INSTRUMENTATION_TBI) 472*c54f35caSApple OSS DistributionsSFLAGS_KASANX86_64 += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 473*c54f35caSApple OSS DistributionsSFLAGS_KASANX86_64H += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 474*c54f35caSApple OSS DistributionsSFLAGS_GEN += -DKASAN=1 -DKASAN_OFFSET=$(KASAN_OFFSET) -DKASAN_LIGHT=$(KASAN_LIGHT) 475*c54f35caSApple OSS Distributions 476*c54f35caSApple OSS Distributionsendif 477*c54f35caSApple OSS Distributions 478*c54f35caSApple OSS Distributions# UBSan 479*c54f35caSApple OSS Distributions# 480*c54f35caSApple OSS Distributions# The Undefined Behavior sanitizer runtime is always built as part of, and only for, 481*c54f35caSApple OSS Distributions# KASAN variants. UBSan instrumentation is disabled by default and only enabled explicitly 482*c54f35caSApple OSS Distributions# when building with UBSAN=1. 483*c54f35caSApple OSS Distributions# 484*c54f35caSApple OSS Distributions# On iOS RELEASE and DEVELOPMENT kernels, a subset of UBSan checks is enabled along with a minimal 485*c54f35caSApple OSS Distributions# runtime that emulates trap mode (but makes it recoverable). 486*c54f35caSApple OSS Distributions 487*c54f35caSApple OSS Distributionsifeq ($(KASAN), 1) 488*c54f35caSApple OSS Distributions 489*c54f35caSApple OSS Distributionsifeq ($(UBSAN),1) 490*c54f35caSApple OSS DistributionsSAN=1 491*c54f35caSApple OSS Distributions 492*c54f35caSApple OSS DistributionsUBSAN_RUNTIME = 493*c54f35caSApple OSS DistributionsUBSAN_CHECKS += signed-integer-overflow shift pointer-overflow bounds object-size # non-fatal (calls runtime, can return) 494*c54f35caSApple OSS Distributions# UBSAN_CHECKS = undefined nullability unsigned-integer-overflow # everything 495*c54f35caSApple OSS DistributionsUBSAN_CHECKS_FATAL = # fatal (calls runtime, must not return) 496*c54f35caSApple OSS DistributionsUBSAN_CHECKS_TRAP = vla-bound builtin # emit a trap instruction (no runtime support) 497*c54f35caSApple OSS DistributionsUBSAN_DISABLED += vptr function # requires unsupported C++ runtime 498*c54f35caSApple OSS Distributions 499*c54f35caSApple OSS Distributions# UBSan alignment + KASan code size is too large 500*c54f35caSApple OSS Distributions# UBSan unreachable doesn't play nice with ASan (40723397) 501*c54f35caSApple OSS DistributionsUBSAN_DISABLED += alignment unreachable 502*c54f35caSApple OSS Distributions 503*c54f35caSApple OSS Distributionsendif 504*c54f35caSApple OSS Distributions 505*c54f35caSApple OSS Distributionselse 506*c54f35caSApple OSS Distributions 507*c54f35caSApple OSS Distributions# DEVELOPMENT and RELEASE variants 508*c54f35caSApple OSS Distributionsifeq ($(PLATFORM),iPhoneOS) 509*c54f35caSApple OSS Distributions 510*c54f35caSApple OSS Distributions# Currently we have to keep alive two separated UBSAN runtimes (minimal for DEVELOPMENT, 511*c54f35caSApple OSS Distributions# full for KASAN). This implies that we cannot use CFLAGS_$(CURRENT_KERNEL_CONFIG), because 512*c54f35caSApple OSS Distributions# CFLAGS_DEVELOPMENT is folded into CFLAGS_KASAN. For the time being we leave this check here, 513*c54f35caSApple OSS Distributions# as we work (independently) to both break the CFLAGS direct dependency and commonize the 514*c54f35caSApple OSS Distributions# sanitizer runtimes. 515*c54f35caSApple OSS DistributionsUBSAN_MINIMAL_RUNTIME := DEVELOPMENT DEBUG 516*c54f35caSApple OSS Distributionsifneq ($(filter $(CURRENT_KERNEL_CONFIG), $(UBSAN_MINIMAL_RUNTIME)),) 517*c54f35caSApple OSS Distributions 518*c54f35caSApple OSS Distributions# This is (unfortunately) intentional. Currently the "kasan" blacklist, which folds both 519*c54f35caSApple OSS Distributions# ubsan and kasan specific files, is generated for all builds during the 520*c54f35caSApple OSS Distributions# setup phase. The blacklist file itself is divided per-sanitizer, so won't 521*c54f35caSApple OSS Distributions# affect the UBSAN build outside of the entries that are legitimately 522*c54f35caSApple OSS Distributions# intended for it. 523*c54f35caSApple OSS DistributionsUBSAN_BLACKLIST=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC) 524*c54f35caSApple OSS Distributions 525*c54f35caSApple OSS DistributionsUBSAN_CHECKS = signed-integer-overflow 526*c54f35caSApple OSS DistributionsUBSAN_RUNTIME = -fsanitize-minimal-runtime -fsanitize-ignorelist=$(UBSAN_BLACKLIST) 527*c54f35caSApple OSS DistributionsUBSAN_CHECKS_TRAP = 528*c54f35caSApple OSS DistributionsUBSAN_CHECKS_FATAL = 529*c54f35caSApple OSS DistributionsUBSAN_DISABLED = 530*c54f35caSApple OSS Distributionsendif 531*c54f35caSApple OSS Distributionsendif 532*c54f35caSApple OSS Distributions 533*c54f35caSApple OSS Distributionsendif 534*c54f35caSApple OSS Distributions 535*c54f35caSApple OSS DistributionsCFLAGS_GEN += $(UBSAN_RUNTIME) 536*c54f35caSApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS) $(UBSAN_CHECKS_FATAL) $(UBSAN_CHECKS_TRAP),-fsanitize=$(x)) 537*c54f35caSApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS_FATAL),-fno-sanitize-recover=$(x)) 538*c54f35caSApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS_TRAP),-fsanitize-trap=$(x)) 539*c54f35caSApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_DISABLED),-fno-sanitize=$(x)) 540*c54f35caSApple OSS Distributions 541*c54f35caSApple OSS Distributionsifeq ($(KSANCOV),1) 542*c54f35caSApple OSS Distributions# Enable SanitizerCoverage instrumentation in xnu 543*c54f35caSApple OSS DistributionsSAN = 1 544*c54f35caSApple OSS DistributionsKCOV_BLACKLIST := $(OBJROOT)/san/kcov-blacklist-$(CURRENT_ARCH_CONFIG_LC) 545*c54f35caSApple OSS DistributionsKCOV_CFLAGS := -fsanitize-coverage=trace-pc-guard -fsanitize-coverage-ignorelist=$(KCOV_BLACKLIST) 546*c54f35caSApple OSS DistributionsCFLAGS_GEN += $(KCOV_CFLAGS) -DKSANCOV=1 547*c54f35caSApple OSS Distributionsendif 548*c54f35caSApple OSS Distributions 549*c54f35caSApple OSS Distributionsifeq ($(SAN),1) 550*c54f35caSApple OSS DistributionsCFLAGS_GEN += -fsanitize-ignorelist=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC) 551*c54f35caSApple OSS Distributionsendif 552*c54f35caSApple OSS Distributions 553*c54f35caSApple OSS Distributions 554*c54f35caSApple OSS DistributionsCFLAGS = $(CFLAGS_GEN) \ 555*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ 556*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 557*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) \ 558*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_)) \ 559*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_))) \ 560*c54f35caSApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) \ 561*c54f35caSApple OSS Distributions $(DEPLOYMENT_TARGET_DEFINES) \ 562*c54f35caSApple OSS Distributions $(BOUND_CHECKS_DEFINES) \ 563*c54f35caSApple OSS Distributions $(DEFINES) 564*c54f35caSApple OSS Distributions 565*c54f35caSApple OSS Distributions# 566*c54f35caSApple OSS Distributions# Default C++ flags 567*c54f35caSApple OSS Distributions# 568*c54f35caSApple OSS Distributions 569*c54f35caSApple OSS DistributionsOTHER_CXXFLAGS = 570*c54f35caSApple OSS Distributions 571*c54f35caSApple OSS DistributionsCXXFLAGS_GEN = -std=gnu++1z -fsized-deallocation -fapple-kext $(OTHER_CXXFLAGS) 572*c54f35caSApple OSS Distributions 573*c54f35caSApple OSS DistributionsCXXFLAGS = $(CXXFLAGS_GEN) \ 574*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \ 575*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_)) 576*c54f35caSApple OSS Distributions 577*c54f35caSApple OSS Distributions# 578*c54f35caSApple OSS Distributions# Assembler command 579*c54f35caSApple OSS Distributions# 580*c54f35caSApple OSS DistributionsAS = $(CCACHE) $(CC) 581*c54f35caSApple OSS DistributionsS_KCC = $(CC) 582*c54f35caSApple OSS Distributions 583*c54f35caSApple OSS Distributions# 584*c54f35caSApple OSS Distributions# Default SFLAGS 585*c54f35caSApple OSS Distributions# 586*c54f35caSApple OSS DistributionsSFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS) 587*c54f35caSApple OSS Distributions 588*c54f35caSApple OSS DistributionsSFLAGS_RELEASE = 589*c54f35caSApple OSS DistributionsSFLAGS_DEVELOPMENT = 590*c54f35caSApple OSS Distributions 591*c54f35caSApple OSS Distributions# When making non-compatible changes to the XNU runtime, it can be useful to build 592*c54f35caSApple OSS Distributions# a KASAN kernel + runtime, but linked against a DEVELOPMENT kernel cache. 593*c54f35caSApple OSS Distributions# Uncomment the lines below to be able to build development, but passing KASAN=1. 594*c54f35caSApple OSS Distributions# #_ifeq ($(KASAN),1) 595*c54f35caSApple OSS Distributions# SFLAGS_DEVELOPMENT += -DKASAN=1 596*c54f35caSApple OSS Distributions# #_endif 597*c54f35caSApple OSS Distributions 598*c54f35caSApple OSS DistributionsSFLAGS_KASAN = $(SFLAGS_DEVELOPMENT) -DKASAN=1 599*c54f35caSApple OSS DistributionsSFLAGS_DEBUG = 600*c54f35caSApple OSS DistributionsSFLAGS_PROFILE = 601*c54f35caSApple OSS Distributions 602*c54f35caSApple OSS DistributionsSFLAGS_X86_64 = $(CFLAGS_X86_64) 603*c54f35caSApple OSS DistributionsSFLAGS_X86_64H = $(CFLAGS_X86_64H) 604*c54f35caSApple OSS DistributionsSFLAGS_ARM64 = $(CFLAGS_ARM64) 605*c54f35caSApple OSS Distributions 606*c54f35caSApple OSS DistributionsSFLAGS = $(SFLAGS_GEN) \ 607*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ 608*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 609*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),SFLAGS_)) \ 610*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_)) \ 611*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_))) \ 612*c54f35caSApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) \ 613*c54f35caSApple OSS Distributions $(DEPLOYMENT_TARGET_DEFINES) \ 614*c54f35caSApple OSS Distributions $(DEFINES) 615*c54f35caSApple OSS Distributions 616*c54f35caSApple OSS Distributions# 617*c54f35caSApple OSS Distributions# Linker command 618*c54f35caSApple OSS Distributions# 619*c54f35caSApple OSS DistributionsLD = $(KC++) -nostdlib 620*c54f35caSApple OSS Distributions 621*c54f35caSApple OSS Distributions# 622*c54f35caSApple OSS Distributions# Default LDFLAGS 623*c54f35caSApple OSS Distributions# 624*c54f35caSApple OSS Distributions# Availability of DWARF allows DTrace CTF (compressed type format) to be constructed. 625*c54f35caSApple OSS Distributions# ctf_insert creates the CTF section. It needs reserved padding in the 626*c54f35caSApple OSS Distributions# headers for the load command segment and the CTF section structures. 627*c54f35caSApple OSS Distributions# 628*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_GEN = \ 629*c54f35caSApple OSS Distributions -nostdlib \ 630*c54f35caSApple OSS Distributions -fapple-kext \ 631*c54f35caSApple OSS Distributions -Wl,-e,__start \ 632*c54f35caSApple OSS Distributions -Wl,-sectalign,__TEXT,__text,0x1000 \ 633*c54f35caSApple OSS Distributions -Wl,-sectalign,__DATA,__common,0x1000 \ 634*c54f35caSApple OSS Distributions -Wl,-sectalign,__DATA,__bss,0x1000 \ 635*c54f35caSApple OSS Distributions -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \ 636*c54f35caSApple OSS Distributions -Wl,-segprot,__PRELINK_TEXT,r-x,r-x \ 637*c54f35caSApple OSS Distributions -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \ 638*c54f35caSApple OSS Distributions -Wl,-new_linker \ 639*c54f35caSApple OSS Distributions -Wl,-pagezero_size,0x0 \ 640*c54f35caSApple OSS Distributions -Wl,-version_load_command \ 641*c54f35caSApple OSS Distributions -Wl,-function_starts \ 642*c54f35caSApple OSS Distributions -Wl,-headerpad,152 643*c54f35caSApple OSS Distributions 644*c54f35caSApple OSS Distributions# LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -lfirehose_kernel 645*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -L$(SDKROOT)/usr/local/lib/kernel/platform 646*c54f35caSApple OSS Distributions 647*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_RELEASE = 648*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENT = 649*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_KASAN = $(LDFLAGS_KERNEL_DEVELOPMENT) 650*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEBUG = 651*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_PROFILE = 652*c54f35caSApple OSS Distributions 653*c54f35caSApple OSS Distributions# KASLR static slide config: 654*c54f35caSApple OSS Distributionsifndef SLIDE 655*c54f35caSApple OSS DistributionsSLIDE=0x00 656*c54f35caSApple OSS Distributionsendif 657*c54f35caSApple OSS DistributionsKERNEL_MIN_ADDRESS = 0xffffff8000000000 658*c54f35caSApple OSS DistributionsKERNEL_BASE_OFFSET = 0x100000 659*c54f35caSApple OSS Distributions# POSIX shells use signed long for their arithmetic expressions. However, 660*c54f35caSApple OSS Distributions# we're dealing with uintptr_t values here, so explicitly use bash which 661*c54f35caSApple OSS Distributions# is known to be able to handle such larger values. ksh also works; dash 662*c54f35caSApple OSS Distributions# and zsh both fail with different results (zsh even warns you). 663*c54f35caSApple OSS DistributionsKERNEL_STATIC_SLIDE = $(shell $(BASH) -c 'printf "0x%016x" \ 664*c54f35caSApple OSS Distributions $$(( $(SLIDE) << 21 ))') 665*c54f35caSApple OSS DistributionsKERNEL_STATIC_BASE = $(shell $(BASH) -c 'printf "0x%016x" \ 666*c54f35caSApple OSS Distributions $$(( $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ))') 667*c54f35caSApple OSS DistributionsKERNEL_HIB_SECTION_BASE = $(shell $(BASH) -c 'printf "0x%016x" \ 668*c54f35caSApple OSS Distributions $$(( $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ))') 669*c54f35caSApple OSS DistributionsKERNEL_TEXT_BASE = $(shell $(BASH) -c 'printf "0x%016x" \ 670*c54f35caSApple OSS Distributions $$(( $(KERNEL_HIB_SECTION_BASE) + 0x100000 ))') 671*c54f35caSApple OSS Distributions 672*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64 = \ 673*c54f35caSApple OSS Distributions -Wl,-pie \ 674*c54f35caSApple OSS Distributions -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \ 675*c54f35caSApple OSS Distributions -Wl,-image_base,$(KERNEL_TEXT_BASE) \ 676*c54f35caSApple OSS Distributions -Wl,-seg_page_size,__TEXT,0x200000 \ 677*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__bootPT,0x1000 \ 678*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__desc,0x1000 \ 679*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__data,0x1000 \ 680*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__text,0x1000 \ 681*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__const,0x1000 \ 682*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__bss,0x1000 \ 683*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__common,0x1000 \ 684*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \ 685*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \ 686*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \ 687*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \ 688*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__cstring,0x1000 \ 689*c54f35caSApple OSS Distributions -Wl,-sectalign,__DATA,__percpu,0x1000 \ 690*c54f35caSApple OSS Distributions -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \ 691*c54f35caSApple OSS Distributions -Wl,-segprot,__DATA_CONST,r--,r-- \ 692*c54f35caSApple OSS Distributions -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ 693*c54f35caSApple OSS Distributions -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ 694*c54f35caSApple OSS Distributions -Wl,-segprot,__KLDDATA,rw-,rw- \ 695*c54f35caSApple OSS Distributions -Wl,-segprot,__KLD,r-x,r-x \ 696*c54f35caSApple OSS Distributions -Wl,-no_zero_fill_sections \ 697*c54f35caSApple OSS Distributions $(LDFLAGS_NOSTRIP_FLAG) 698*c54f35caSApple OSS Distributions 699*c54f35caSApple OSS Distributionsifeq ($(SAN),1) 700*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64 += \ 701*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__cstring,0x1000 702*c54f35caSApple OSS Distributionsendif 703*c54f35caSApple OSS Distributions 704*c54f35caSApple OSS Distributionsifeq ($(KSANCOV),1) 705*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64 += \ 706*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__sancov_guards,0x1000 \ 707*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__sancov_pcs,0x1000 708*c54f35caSApple OSS Distributionsendif 709*c54f35caSApple OSS Distributions 710*c54f35caSApple OSS Distributions# Define KERNEL_BASE_OFFSET so known at compile time: 711*c54f35caSApple OSS DistributionsCFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) 712*c54f35caSApple OSS DistributionsCFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) 713*c54f35caSApple OSS Distributions 714*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) 715*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) 716*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_KASANX86_64 = $(LDFLAGS_KERNEL_DEVELOPMENTX86_64) \ 717*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__asan_globals,0x1000 \ 718*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__asan_liveness,0x1000 \ 719*c54f35caSApple OSS Distributions -Wl,-sectalign,__HIB,__mod_term_func,0x1000 \ 720*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__mod_init_func,__NULL,__mod_init_func \ 721*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__eh_frame,__NULL,__eh_frame 722*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) 723*c54f35caSApple OSS Distributions 724*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64) 725*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEBUGX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) 726*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENTX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) 727*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_KASANX86_64H = $(LDFLAGS_KERNEL_KASANX86_64) 728*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) 729*c54f35caSApple OSS Distributions 730*c54f35caSApple OSS Distributions# Offset image base by page to have iBoot load kernel TEXT correctly. 731*c54f35caSApple OSS Distributions# First page is used for various purposes : sleep token, reset vector. 732*c54f35caSApple OSS Distributions# We also need a 32MB offset, as this is the minimum block mapping size 733*c54f35caSApple OSS Distributions# for a 16KB page runtime, and we wish to use the first virtual block 734*c54f35caSApple OSS Distributions# to map the low globals page. We also need another 4MB to account for 735*c54f35caSApple OSS Distributions# the address space reserved by L4 (because the reservation is not a 736*c54f35caSApple OSS Distributions# multiple of the block size in alignment/length, we will implictly map 737*c54f35caSApple OSS Distributions# it with our block mapping, and we therefore must reflect that the 738*c54f35caSApple OSS Distributions# first 4MB of the block mapping for xnu do not belong to xnu). 739*c54f35caSApple OSS Distributions# For the moment, kaliber has a unique memory layout (monitor at the top 740*c54f35caSApple OSS Distributions# of memory). Support this by breaking 16KB on other platforms and 741*c54f35caSApple OSS Distributions# mandating 32MB alignment. Image base (i.e. __TEXT) must be 16KB 742*c54f35caSApple OSS Distributions# aligned since ld64 will link with 16KB alignment for ARM64. 743*c54f35caSApple OSS Distributions# 744*c54f35caSApple OSS Distributions# We currently offset by an additional 32MB in order to reclaim memory. 745*c54f35caSApple OSS Distributions# We need a dedicated virtual page for the low globals. Our bootloader 746*c54f35caSApple OSS Distributions# may have a significant chunk of memory (up to an L2 entry in size) 747*c54f35caSApple OSS Distributions# that lies before the kernel. The addition 32MB of virtual padding 748*c54f35caSApple OSS Distributions# ensures that we have enough virtual address space to map all of that 749*c54f35caSApple OSS Distributions# memory as part of the V-to-P mapping. 750*c54f35caSApple OSS Distributions# 23355738 - put __PRELINK_TEXT first. We reserve enough room 751*c54f35caSApple OSS Distributions# for 0x0000000003000000 = 48MB of kexts 752*c54f35caSApple OSS Distributions# 753*c54f35caSApple OSS Distributions# 0xfffffff000000000 (32MB range for low globals) 754*c54f35caSApple OSS Distributions# 0xfffffff002000000 (32MB range to allow for large page physical slide) 755*c54f35caSApple OSS Distributions# 0xfffffff004000000 (16KB range to reserve the first available page) 756*c54f35caSApple OSS Distributions# 0xfffffff004004000 (48MB range for kexts) 757*c54f35caSApple OSS Distributions# 0xfffffff007004000 (Start of xnu proper). 758*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_GENARM64 = \ 759*c54f35caSApple OSS Distributions -Wl,-pie \ 760*c54f35caSApple OSS Distributions -Wl,-static \ 761*c54f35caSApple OSS Distributions -Wl,-segaddr,__PRELINK_TEXT,$(ARM64_PLKSEG_ADDR) \ 762*c54f35caSApple OSS Distributions -Wl,-image_base,$(ARM64_LINK_ADDR) \ 763*c54f35caSApple OSS Distributions \ 764*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__text,__TEXT_EXEC,__hib_text \ 765*c54f35caSApple OSS Distributions \ 766*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__const,__DATA_CONST,__hib_const \ 767*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__cstring,__DATA_CONST,__hib_const \ 768*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__literal8,__DATA_CONST,__hib_const \ 769*c54f35caSApple OSS Distributions -Wl,-rename_section,__HIB,__literal16,__DATA_CONST,__hib_const \ 770*c54f35caSApple OSS Distributions \ 771*c54f35caSApple OSS Distributions -Wl,-rename_segment,__HIB,__HIBDATA \ 772*c54f35caSApple OSS Distributions \ 773*c54f35caSApple OSS Distributions -Wl,-sectalign,__DATA,__const,0x4000 \ 774*c54f35caSApple OSS Distributions -Wl,-sectalign,__DATA,__percpu,0x4000 \ 775*c54f35caSApple OSS Distributions -Wl,-sectalign,__DATA,__data,0x4000 \ 776*c54f35caSApple OSS Distributions -Wl,-rename_section,__DATA,__mod_init_func,__DATA_CONST,__mod_init_func \ 777*c54f35caSApple OSS Distributions -Wl,-rename_section,__DATA,__mod_term_func,__DATA_CONST,__mod_term_func \ 778*c54f35caSApple OSS Distributions -Wl,-rename_section,__DATA,__auth_ptr,__DATA_CONST,__auth_ptr \ 779*c54f35caSApple OSS Distributions -Wl,-rename_section,__DATA,__auth_got,__DATA_CONST,__auth_got \ 780*c54f35caSApple OSS Distributions -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \ 781*c54f35caSApple OSS Distributions -Wl,-segprot,__DATA_CONST,r--,r-- \ 782*c54f35caSApple OSS Distributions -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ 783*c54f35caSApple OSS Distributions -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ 784*c54f35caSApple OSS Distributions -Wl,-segprot,__KLDDATA,rw-,rw- \ 785*c54f35caSApple OSS Distributions -Wl,-segprot,__KLD,r-x,r-x \ 786*c54f35caSApple OSS Distributions -Wl,-rename_section,__TEXT,__text,__TEXT_EXEC,__text \ 787*c54f35caSApple OSS Distributions -Wl,-rename_section,__TEXT,__stubs,__TEXT_EXEC,__stubs \ 788*c54f35caSApple OSS Distributions -Wl,-sectcreate,"__PLK_TEXT_EXEC",__text,/dev/null \ 789*c54f35caSApple OSS Distributions -Wl,-sectcreate,__PRELINK_DATA,__data,/dev/null \ 790*c54f35caSApple OSS Distributions -Wl,-sectcreate,"__PLK_DATA_CONST",__data,/dev/null \ 791*c54f35caSApple OSS Distributions -Wl,-sectcreate,"__PLK_LLVM_COV",__llvm_covmap,/dev/null \ 792*c54f35caSApple OSS Distributions -Wl,-sectcreate,"__PLK_LINKEDIT",__data,/dev/null 793*c54f35caSApple OSS Distributions 794*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_SEGARM64 = \ 795*c54f35caSApple OSS Distributions -Wl,-rename_section,__PPLDATA,__const,__PPLDATA_CONST,__const \ 796*c54f35caSApple OSS Distributions -Wl,-segment_order,__TEXT:__DATA_CONST:__LINKEDIT:__TEXT_EXEC:__TEXT_BOOT_EXEC:__KLD:__PPLTEXT:__PPLTRAMP:__PPLDATA_CONST:__LASTDATA_CONST:__LAST:__PPLDATA:__KLDDATA:__DATA:__HIBDATA:__BOOTDATA \ 797*c54f35caSApple OSS Distributions -Wl,-segprot,__TEXT,r--,r-- \ 798*c54f35caSApple OSS Distributions -Wl,-segprot,__TEXT_EXEC,r-x,r-x \ 799*c54f35caSApple OSS Distributions -Wl,-segprot,__TEXT_BOOT_EXEC,r-x,r-x \ 800*c54f35caSApple OSS Distributions -Wl,-segprot,__PPLTEXT,r-x,r-x \ 801*c54f35caSApple OSS Distributions -Wl,-segprot,__PPLTRAMP,r-x,r-x \ 802*c54f35caSApple OSS Distributions -Wl,-segprot,__PPLDATA_CONST,r--,r-- \ 803*c54f35caSApple OSS Distributions -Wl,-segprot,__LASTDATA_CONST,r--,r-- \ 804*c54f35caSApple OSS Distributions -Wl,-segprot,__LAST,r-x,r-x \ 805*c54f35caSApple OSS Distributions 806*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_RELEASEARM64 = \ 807*c54f35caSApple OSS Distributions $(LDFLAGS_KERNEL_GENARM64) \ 808*c54f35caSApple OSS Distributions $(LDFLAGS_KERNEL_SEGARM64) \ 809*c54f35caSApple OSS Distributions $(LDFLAGS_KERNEL_STRIP_LTO) 810*c54f35caSApple OSS Distributions 811*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_RELEASEARM64 = \ 812*c54f35caSApple OSS Distributions -Wl,-exported_symbols_list,$(TARGET)/all-kpi.exp 813*c54f35caSApple OSS Distributions 814*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENTARM64 = \ 815*c54f35caSApple OSS Distributions $(LDFLAGS_KERNEL_GENARM64) \ 816*c54f35caSApple OSS Distributions $(LDFLAGS_KERNEL_SEGARM64) \ 817*c54f35caSApple OSS Distributions $(LDFLAGS_NOSTRIP_FLAG) 818*c54f35caSApple OSS Distributions 819*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64 = 820*c54f35caSApple OSS Distributions 821*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_KASANARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) 822*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_DEBUGARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) 823*c54f35caSApple OSS Distributions 824*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_KASANARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64) 825*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_DEBUGARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64) 826*c54f35caSApple OSS Distributions 827*c54f35caSApple OSS Distributions# 828*c54f35caSApple OSS Distributions# arm64e specific linker flags that should be used only when linking the kernel 829*c54f35caSApple OSS Distributions# (and not the static kernel cache / kcgen) 830*c54f35caSApple OSS Distributions# 831*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_SUBARCH_arm64e = \ 832*c54f35caSApple OSS Distributions -Wl,-add_split_seg_info \ 833*c54f35caSApple OSS Distributions -Wl,-kernel 834*c54f35caSApple OSS Distributions 835*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_SUBARCH_x86_64 = \ 836*c54f35caSApple OSS Distributions -Wl,-add_split_seg_info \ 837*c54f35caSApple OSS Distributions -Wl,-kernel 838*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY_SUBARCH_x86_64h = $(LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64) 839*c54f35caSApple OSS Distributions 840*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \ 841*c54f35caSApple OSS Distributions $(LDFLAGS_KERNEL_SDK) \ 842*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 843*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \ 844*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \ 845*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \ 846*c54f35caSApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) 847*c54f35caSApple OSS Distributions 848*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_ONLY += \ 849*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_ONLY_CONFIG_))) \ 850*c54f35caSApple OSS Distributions $($(addsuffix $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),LDFLAGS_KERNEL_ONLY_SUBARCH_)) \ 851*c54f35caSApple OSS Distributions -Wl,-alias_list,$(TARGET)/all-alias.exp \ 852*c54f35caSApple OSS Distributions -Wl,-sectcreate,__LINKINFO,__symbolsets,$(TARGET)/symbolsets.plist -Wl,-segprot,__LINKINFO,r--,r-- 853*c54f35caSApple OSS Distributions 854*c54f35caSApple OSS DistributionsLDFILES_KERNEL_ONLY = $(TARGET)/all-kpi.exp $(TARGET)/all-alias.exp $(TARGET)/symbolsets.plist 855*c54f35caSApple OSS Distributions 856*c54f35caSApple OSS Distributions# 857*c54f35caSApple OSS Distributions# Default runtime libraries to be linked with the kernel 858*c54f35caSApple OSS Distributions# 859*c54f35caSApple OSS DistributionsLD_KERNEL_LIBS = -lcc_kext 860*c54f35caSApple OSS DistributionsLD_KERNEL_ARCHIVES = $(LDFLAGS_KERNEL_SDK) -lfirehose_kernel 861*c54f35caSApple OSS Distributions# Link opensource binary library 862*c54f35caSApple OSS Distributionsifneq ($(filter T6000 T8101 VMAPPLE T6000 T8101 VMAPPLE,$(CURRENT_MACHINE_CONFIG)),) 863*c54f35caSApple OSS Distributions LDFLAGS_KERNEL_ONLY += -rdynamic -Wl,-force_load,$(KDKROOT)/System/Library/KernelSupport/lib$(CURRENT_MACHINE_CONFIG).os.$(CURRENT_KERNEL_CONFIG).a 864*c54f35caSApple OSS Distributionsendif 865*c54f35caSApple OSS Distributions 866*c54f35caSApple OSS Distributions 867*c54f35caSApple OSS Distributions# 868*c54f35caSApple OSS Distributions# DTrace support 869*c54f35caSApple OSS Distributions# 870*c54f35caSApple OSS Distributionsifndef DO_CTFMERGE 871*c54f35caSApple OSS DistributionsDO_CTFMERGE := 1 872*c54f35caSApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) 873*c54f35caSApple OSS Distributionsifneq ($(PLATFORM),MacOSX) 874*c54f35caSApple OSS DistributionsDO_CTFMERGE := 0 875*c54f35caSApple OSS Distributionsendif 876*c54f35caSApple OSS Distributionsendif 877*c54f35caSApple OSS Distributionsendif # DO_CTFMERGE 878*c54f35caSApple OSS Distributions 879*c54f35caSApple OSS Distributions 880*c54f35caSApple OSS Distributions# 881*c54f35caSApple OSS Distributions# Default INCFLAGS 882*c54f35caSApple OSS Distributions# 883*c54f35caSApple OSS DistributionsINCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST)) 884*c54f35caSApple OSS DistributionsINCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS 885*c54f35caSApple OSS DistributionsINCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT) 886*c54f35caSApple OSS DistributionsINCFLAGS_LOCAL = -I. 887*c54f35caSApple OSS DistributionsINCFLAGS_SDK = -I$(SDKROOT)/usr/local/include/kernel 888*c54f35caSApple OSS DistributionsINCFLAGS_PLATFORM = -I$(SDKROOT)/$(KPINCDIR)/platform 889*c54f35caSApple OSS Distributions 890*c54f35caSApple OSS DistributionsINCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) $(INCFLAGS_SDK) $(INCFLAGS_PLATFORM) 891*c54f35caSApple OSS Distributions 892*c54f35caSApple OSS Distributions# 893*c54f35caSApple OSS Distributions# Default MIGFLAGS 894*c54f35caSApple OSS Distributions# 895*c54f35caSApple OSS DistributionsMIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 896*c54f35caSApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) 897*c54f35caSApple OSS Distributions 898*c54f35caSApple OSS Distributions# Support for LLVM Profile Guided Optimization (PGO) 899*c54f35caSApple OSS Distributions 900*c54f35caSApple OSS Distributionsifeq ($(BUILD_PROFILE),1) 901*c54f35caSApple OSS DistributionsCFLAGS_GEN += -fprofile-instr-generate -DPROFILE 902*c54f35caSApple OSS DistributionsCXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE 903*c54f35caSApple OSS Distributionsendif 904*c54f35caSApple OSS Distributions 905*c54f35caSApple OSS Distributionsifdef USE_PROFILE 906*c54f35caSApple OSS DistributionsCFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) 907*c54f35caSApple OSS DistributionsCXXFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) 908*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_GEN += -fprofile-instr-use=$(USE_PROFILE) 909*c54f35caSApple OSS Distributions 910*c54f35caSApple OSS DistributionsCFLAGS_GEN += -Wno-error=profile-instr-out-of-date 911*c54f35caSApple OSS Distributionsendif 912*c54f35caSApple OSS Distributions 913*c54f35caSApple OSS Distributions# 914*c54f35caSApple OSS Distributions# Support for LLVM Link Time Optimization (LTO) 915*c54f35caSApple OSS Distributions# 916*c54f35caSApple OSS Distributions# LTO can be explicitly enabled or disabled with BUILD_LTO=1|0 917*c54f35caSApple OSS Distributions# and defaults to enabled except for DEBUG kernels 918*c54f35caSApple OSS Distributions# 919*c54f35caSApple OSS Distributions# CFLAGS_NOLTO_FLAG is needed on a per-file basis (for files 920*c54f35caSApple OSS Distributions# that deal poorly with LTO, or files that must be machine 921*c54f35caSApple OSS Distributions# code *.o files for xnu to build (i.e, setsegname runs on 922*c54f35caSApple OSS Distributions# them). 923*c54f35caSApple OSS Distributions# 924*c54f35caSApple OSS Distributions# LDFLAGS_NOSTRIP_FLAG is used to support configurations that 925*c54f35caSApple OSS Distributions# do not utilize an export list. For these configs to build, 926*c54f35caSApple OSS Distributions# we need to prevent the LTO logic from dead stripping them. 927*c54f35caSApple OSS Distributions 928*c54f35caSApple OSS DistributionsLTO_ENABLED_RELEASE = 1 929*c54f35caSApple OSS DistributionsLTO_ENABLED_DEVELOPMENT = 1 930*c54f35caSApple OSS DistributionsLTO_ENABLED_DEBUG = 0 931*c54f35caSApple OSS DistributionsLTO_ENABLED_KASAN = 0 932*c54f35caSApple OSS Distributions 933*c54f35caSApple OSS Distributionsifneq ($(BUILD_LTO),) 934*c54f35caSApple OSS DistributionsUSE_LTO = $(BUILD_LTO) 935*c54f35caSApple OSS Distributionselse 936*c54f35caSApple OSS DistributionsUSE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG)) 937*c54f35caSApple OSS Distributionsendif 938*c54f35caSApple OSS Distributions 939*c54f35caSApple OSS Distributionsifeq ($(USE_LTO),1) 940*c54f35caSApple OSS DistributionsCFLAGS_GEN += -flto -DBUILT_LTO=1 941*c54f35caSApple OSS DistributionsCXXFLAGS_GEN += -flto -DBUILT_LTO=1 942*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_LTO = -Wl,-mllvm,-inline-threshold=100 943*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_GEN += $(LDFLAGS_KERNEL_LTO) -Wl,-object_path_lto,$(TARGET)/lto.o 944*c54f35caSApple OSS DistributionsLDFLAGS_NOSTRIP_FLAG = -rdynamic 945*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_STRIP_LTO = -Wl,-dead_strip,-no_dead_strip_inits_and_terms 946*c54f35caSApple OSS Distributions 947*c54f35caSApple OSS DistributionsCFLAGS_NOLTO_FLAG = -fno-lto 948*c54f35caSApple OSS Distributionselse 949*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_LTO = 950*c54f35caSApple OSS DistributionsLDFLAGS_NOSTRIP_FLAG = 951*c54f35caSApple OSS DistributionsLDFLAGS_KERNEL_STRIP_LTO = 952*c54f35caSApple OSS DistributionsCFLAGS_NOLTO_FLAG = 953*c54f35caSApple OSS Distributionsendif 954*c54f35caSApple OSS Distributions 955*c54f35caSApple OSS Distributionsifeq ($(BUILD_JSON_COMPILATION_DATABASE),1) 956*c54f35caSApple OSS Distributions# To build the json compilation database, kernel compile commands are 957*c54f35caSApple OSS Distributions# substituted with JSONCOMPILATIONDB, which appends compile commands to the 958*c54f35caSApple OSS Distributions# compilation database (compile_commands.json) rather than executing them. 959*c54f35caSApple OSS Distributions# Because kernel compilations do not actually occur in this mode, downstream 960*c54f35caSApple OSS Distributions# build steps (dSYM, static link, etc) that depend on *.o outputs must be bypassed. 961*c54f35caSApple OSS DistributionsBUILD_DSYM := 0 962*c54f35caSApple OSS DistributionsBUILD_STATIC_LINK := 0 963*c54f35caSApple OSS DistributionsDO_CTFMERGE := 0 964*c54f35caSApple OSS DistributionsKCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC) 965*c54f35caSApple OSS DistributionsKC++ = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CXX) 966*c54f35caSApple OSS DistributionsS_KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC) 967*c54f35caSApple OSS DistributionsSTRIP = true 968*c54f35caSApple OSS Distributionsendif 969*c54f35caSApple OSS Distributions 970*c54f35caSApple OSS Distributions# 971*c54f35caSApple OSS Distributions# Default VPATH 972*c54f35caSApple OSS Distributions# 973*c54f35caSApple OSS Distributionsexport VPATH = .:$(SOURCE) 974*c54f35caSApple OSS Distributions 975*c54f35caSApple OSS Distributions 976*c54f35caSApple OSS Distributions 977*c54f35caSApple OSS Distributions# 978*c54f35caSApple OSS Distributions# Macros that control installation of kernel and its header files 979*c54f35caSApple OSS Distributions# 980*c54f35caSApple OSS Distributions# install flags for header files 981*c54f35caSApple OSS Distributions# 982*c54f35caSApple OSS DistributionsINSTALL_FLAGS = -c -S -m 0444 983*c54f35caSApple OSS DistributionsDATA_INSTALL_FLAGS = -c -S -m 0644 984*c54f35caSApple OSS DistributionsDATA_INSTALL_FLAGS_RO = -c -S -m 0444 985*c54f35caSApple OSS DistributionsEXEC_INSTALL_FLAGS = -c -S -m 0755 986*c54f35caSApple OSS Distributions 987*c54f35caSApple OSS Distributions# 988*c54f35caSApple OSS Distributions# Header file destinations 989*c54f35caSApple OSS Distributions# 990*c54f35caSApple OSS Distributions 991*c54f35caSApple OSS Distributionsifeq ($(DRIVERKIT),1) 992*c54f35caSApple OSS Distributions SDKHEADERSROOT=$(DRIVERKITRUNTIMEROOT) 993*c54f35caSApple OSS Distributions # only whitelisted headers install outside of the DriverKit Runtime hierarchy 994*c54f35caSApple OSS Distributions DRIVERKITSDKHEADERSROOT=$(DRIVERKITROOT) 995*c54f35caSApple OSS Distributions DRIVERKITFRAMEDIR = $(DRIVERKITROOT)/System/Library/Frameworks 996*c54f35caSApple OSS Distributionsendif 997*c54f35caSApple OSS Distributions 998*c54f35caSApple OSS DistributionsFRAMEDIR = $(SDKHEADERSROOT)/System/Library/Frameworks 999*c54f35caSApple OSS Distributions 1000*c54f35caSApple OSS DistributionsIINCVERS = A 1001*c54f35caSApple OSS DistributionsIINCFRAME = $(FRAMEDIR)/IOKit.framework 1002*c54f35caSApple OSS DistributionsIINCDIR = $(IINCFRAME)/Versions/$(IINCVERS)/Headers 1003*c54f35caSApple OSS DistributionsIPINCDIR = $(IINCFRAME)/Versions/$(IINCVERS)/PrivateHeaders 1004*c54f35caSApple OSS DistributionsIRESDIR = $(IINCFRAME)/Versions/$(IINCVERS)/Resources 1005*c54f35caSApple OSS Distributions 1006*c54f35caSApple OSS DistributionsSINCVERS = B 1007*c54f35caSApple OSS DistributionsSINCFRAME = $(FRAMEDIR)/System.framework 1008*c54f35caSApple OSS DistributionsSINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers 1009*c54f35caSApple OSS DistributionsSPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders 1010*c54f35caSApple OSS DistributionsSRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources 1011*c54f35caSApple OSS Distributions 1012*c54f35caSApple OSS Distributionsifndef INCDIR 1013*c54f35caSApple OSS Distributions INCDIR = $(SDKHEADERSROOT)/usr/include 1014*c54f35caSApple OSS Distributionsendif 1015*c54f35caSApple OSS Distributionsifndef DRIVERKITINCDIR 1016*c54f35caSApple OSS Distributions DRIVERKITINCDIR = $(DRIVERKITSDKHEADERSROOT)/usr/include 1017*c54f35caSApple OSS Distributionsendif 1018*c54f35caSApple OSS Distributionsifndef LCLDIR 1019*c54f35caSApple OSS Distributions LCLDIR = $(SDKHEADERSROOT)/usr/local/include 1020*c54f35caSApple OSS Distributionsendif 1021*c54f35caSApple OSS Distributionsifndef DRIVERKITLCLDIR 1022*c54f35caSApple OSS Distributions DRIVERKITLCLDIR = $(DRIVERKITSDKHEADERSROOT)/usr/local/include 1023*c54f35caSApple OSS Distributionsendif 1024*c54f35caSApple OSS Distributions 1025*c54f35caSApple OSS DistributionsKINCVERS = A 1026*c54f35caSApple OSS DistributionsKINCFRAME = $(FRAMEDIR)/Kernel.framework 1027*c54f35caSApple OSS DistributionsKINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers 1028*c54f35caSApple OSS DistributionsKPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders 1029*c54f35caSApple OSS DistributionsKRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources 1030*c54f35caSApple OSS Distributions 1031*c54f35caSApple OSS DistributionsDKIT_INCFRAME = DriverKit.framework 1032*c54f35caSApple OSS Distributions 1033*c54f35caSApple OSS Distributionsifeq ($(PLATFORM),MacOSX) 1034*c54f35caSApple OSS DistributionsDKIT_INCVERS = A 1035*c54f35caSApple OSS DistributionsDKIT_INCDIR = $(DKIT_INCFRAME)/Versions/$(DKIT_INCVERS)/Headers 1036*c54f35caSApple OSS DistributionsDKIT_PINCDIR = $(DKIT_INCFRAME)/Versions/$(DKIT_INCVERS)/PrivateHeaders 1037*c54f35caSApple OSS Distributionselse 1038*c54f35caSApple OSS Distributions# non-macOS SDK frameworks use shallow bundle structure 1039*c54f35caSApple OSS DistributionsDKIT_INCDIR = $(DKIT_INCFRAME)/Headers 1040*c54f35caSApple OSS DistributionsDKIT_PINCDIR = $(DKIT_INCFRAME)/PrivateHeaders 1041*c54f35caSApple OSS Distributionsendif 1042*c54f35caSApple OSS Distributions 1043*c54f35caSApple OSS Distributions# DriverKit SDK frameworks use shallow bundle structure 1044*c54f35caSApple OSS DistributionsDRIVERKIT_DKIT_INCDIR = $(DKIT_INCFRAME)/Headers 1045*c54f35caSApple OSS DistributionsDRIVERKIT_DKIT_PINCDIR = $(DKIT_INCFRAME)/PrivateHeaders 1046*c54f35caSApple OSS Distributions 1047*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF ?= 1048*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UMACH_KERNEL_PRIVATE 1049*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UBSD_KERNEL_PRIVATE 1050*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UIOKIT_KERNEL_PRIVATE 1051*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -ULIBKERN_KERNEL_PRIVATE 1052*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -ULIBSA_KERNEL_PRIVATE 1053*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UPEXPERT_KERNEL_PRIVATE 1054*c54f35caSApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UXNU_KERNEL_PRIVATE 1055*c54f35caSApple OSS Distributions 1056*c54f35caSApple OSS Distributions 1057*c54f35caSApple OSS DistributionsPLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DXNU_PLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UXNU_PLATFORM_$(x))) 1058*c54f35caSApple OSS Distributions 1059*c54f35caSApple OSS Distributions 1060*c54f35caSApple OSS Distributions# Some header guards need to be present and checked in kernel headers but removed from userspace headers 1061*c54f35caSApple OSS DistributionsKERNEL_ONLY_GUARDS_UNIFDEF = 1062*c54f35caSApple OSS Distributions 1063*c54f35caSApple OSS DistributionsSPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -UDRIVERKIT -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) 1064*c54f35caSApple OSS DistributionsSINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -UDRIVERKIT -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) 1065*c54f35caSApple OSS DistributionsDKPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -DDRIVERKIT -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) 1066*c54f35caSApple OSS DistributionsDKINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -DDRIVERKIT -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) 1067*c54f35caSApple OSS DistributionsKPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DKERNEL -DPRIVATE -UDRIVERKIT -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ 1068*c54f35caSApple OSS DistributionsKINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -DKERNEL -UPRIVATE -UDRIVERKIT -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ 1069*c54f35caSApple OSS DistributionsPDATA_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DPRIVATE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ 1070*c54f35caSApple OSS DistributionsDATA_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UPRIVATE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ 1071*c54f35caSApple OSS Distributions 1072*c54f35caSApple OSS Distributions# 1073*c54f35caSApple OSS Distributions# Compononent Header file destinations 1074*c54f35caSApple OSS Distributions# 1075*c54f35caSApple OSS DistributionsEXPDIR = EXPORT_HDRS/$(COMPONENT) 1076*c54f35caSApple OSS Distributions 1077*c54f35caSApple OSS Distributions# 1078*c54f35caSApple OSS Distributions# Strip Flags 1079*c54f35caSApple OSS Distributions# 1080*c54f35caSApple OSS DistributionsSTRIP_FLAGS_RELEASE = -S -x 1081*c54f35caSApple OSS DistributionsSTRIP_FLAGS_DEVELOPMENT = -S 1082*c54f35caSApple OSS DistributionsSTRIP_FLAGS_KASAN = $(STRIP_FLAGS_DEVELOPMENT) 1083*c54f35caSApple OSS DistributionsSTRIP_FLAGS_DEBUG = -S 1084*c54f35caSApple OSS DistributionsSTRIP_FLAGS_PROFILE = -S -x 1085*c54f35caSApple OSS Distributions 1086*c54f35caSApple OSS DistributionsSTRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_)) 1087*c54f35caSApple OSS Distributions 1088*c54f35caSApple OSS Distributions# 1089*c54f35caSApple OSS Distributions# dsymutil flags 1090*c54f35caSApple OSS Distributions# 1091*c54f35caSApple OSS DistributionsDSYMUTIL_FLAGS_GEN = --minimize 1092*c54f35caSApple OSS Distributions 1093*c54f35caSApple OSS DistributionsDSYMUTIL_FLAGS_X86_64 = --arch=x86_64 1094*c54f35caSApple OSS DistributionsDSYMUTIL_FLAGS_X86_64H = --arch=x86_64h 1095*c54f35caSApple OSS DistributionsDSYMUTIL_FLAGS_ARM64 = 1096*c54f35caSApple OSS Distributions 1097*c54f35caSApple OSS DistributionsDSYMUTIL_FLAGS = $(DSYMUTIL_FLAGS_GEN) \ 1098*c54f35caSApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_)) 1099*c54f35caSApple OSS Distributions 1100*c54f35caSApple OSS Distributions# 1101*c54f35caSApple OSS Distributions# Man Page destination 1102*c54f35caSApple OSS Distributions# 1103*c54f35caSApple OSS DistributionsMANDIR = /usr/share/man 1104*c54f35caSApple OSS Distributions 1105*c54f35caSApple OSS Distributions# 1106*c54f35caSApple OSS Distributions# DEBUG alias location 1107*c54f35caSApple OSS Distributions# 1108*c54f35caSApple OSS DistributionsDEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_$(CURRENT_KERNEL_CONFIG_LC) 1109*c54f35caSApple OSS Distributions 1110*c54f35caSApple OSS Distributions# 1111*c54f35caSApple OSS Distributions# mach_kernel install location 1112*c54f35caSApple OSS Distributions# 1113*c54f35caSApple OSS DistributionsINSTALL_KERNEL_DIR = / 1114*c54f35caSApple OSS Distributions 1115*c54f35caSApple OSS Distributions# 1116*c54f35caSApple OSS Distributions# new OS X install location 1117*c54f35caSApple OSS Distributions# 1118*c54f35caSApple OSS DistributionsSYSTEM_LIBRARY_KERNELS_DIR = /System/Library/Kernels 1119*c54f35caSApple OSS Distributions 1120*c54f35caSApple OSS Distributions# 1121*c54f35caSApple OSS Distributions# File names in DSTROOT 1122*c54f35caSApple OSS Distributions# 1123*c54f35caSApple OSS Distributions 1124*c54f35caSApple OSS Distributionsifeq ($(PLATFORM),MacOSX) 1125*c54f35caSApple OSS DistributionsKERNEL_FILE_NAME_PREFIX = kernel 1126*c54f35caSApple OSS Distributionselse 1127*c54f35caSApple OSS DistributionsKERNEL_FILE_NAME_PREFIX = mach 1128*c54f35caSApple OSS Distributionsendif 1129*c54f35caSApple OSS Distributions 1130*c54f35caSApple OSS Distributionsifeq ($(CURRENT_MACHINE_CONFIG),NONE) 1131*c54f35caSApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) 1132*c54f35caSApple OSS DistributionsKERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX) 1133*c54f35caSApple OSS DistributionsKERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py 1134*c54f35caSApple OSS Distributionselse 1135*c54f35caSApple OSS DistributionsKERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC) 1136*c54f35caSApple OSS DistributionsKERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py 1137*c54f35caSApple OSS Distributionsendif 1138*c54f35caSApple OSS Distributionselse 1139*c54f35caSApple OSS DistributionsKERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_MACHINE_CONFIG_LC) 1140*c54f35caSApple OSS DistributionsKERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX)_$(CURRENT_KERNEL_CONFIG_LC).py 1141*c54f35caSApple OSS Distributionsendif 1142*c54f35caSApple OSS Distributions 1143*c54f35caSApple OSS DistributionsCURRENT_ALIAS_MACHINE_CONFIG = $(word 4,$(subst ^, ,$(CURRENT_BUILD_CONFIG))) 1144*c54f35caSApple OSS DistributionsCURRENT_ALIAS_MACHINE_CONFIG_LC = $(shell printf "%s" "$(CURRENT_ALIAS_MACHINE_CONFIG)" | $(TR) A-Z a-z) 1145*c54f35caSApple OSS Distributionsifneq ($(CURRENT_ALIAS_MACHINE_CONFIG),) 1146*c54f35caSApple OSS DistributionsALIAS_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_ALIAS_MACHINE_CONFIG_LC) 1147*c54f35caSApple OSS Distributionsendif 1148*c54f35caSApple OSS Distributions 1149*c54f35caSApple OSS Distributions# 1150*c54f35caSApple OSS Distributions# System.kext pseudo-kext install location 1151*c54f35caSApple OSS Distributions# 1152*c54f35caSApple OSS DistributionsINSTALL_EXTENSIONS_DIR = /System/Library/Extensions 1153*c54f35caSApple OSS Distributions 1154*c54f35caSApple OSS Distributions# 1155*c54f35caSApple OSS Distributions# System.kext PlugIns install location 1156*c54f35caSApple OSS Distributions# 1157*c54f35caSApple OSS DistributionsDSTROOT_SYSTEM_KEXT_PATH = $(addprefix $(DSTROOT)$(INSTALL_EXTENSIONS_DIR),/System.kext/PlugIns) 1158*c54f35caSApple OSS DistributionsSYMROOT_SYSTEM_KEXT_PATH = $(addprefix $(SYMROOT),/System.kext/PlugIns) 1159*c54f35caSApple OSS Distributions 1160*c54f35caSApple OSS Distributions# 1161*c54f35caSApple OSS Distributions# KDK location 1162*c54f35caSApple OSS Distributions# 1163*c54f35caSApple OSS DistributionsINSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK 1164*c54f35caSApple OSS Distributions 1165*c54f35caSApple OSS Distributions# 1166*c54f35caSApple OSS Distributions# Misc. Etc. 1167*c54f35caSApple OSS Distributions# 1168*c54f35caSApple OSS DistributionsINSTALL_SHARE_MISC_DIR = /usr/share/misc 1169*c54f35caSApple OSS DistributionsINSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace 1170*c54f35caSApple OSS DistributionsINSTALL_DTRACE_LIBEXEC_DIR = /usr/libexec/dtrace 1171*c54f35caSApple OSS Distributions 1172*c54f35caSApple OSS Distributions# 1173*c54f35caSApple OSS Distributions# Overrides for XBS build aliases 1174*c54f35caSApple OSS Distributions# 1175*c54f35caSApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_headers_driverkit),) 1176*c54f35caSApple OSS DistributionsUSE_BINARY_PLIST = 1 1177*c54f35caSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_debug),) 1178*c54f35caSApple OSS DistributionsINSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR) 1179*c54f35caSApple OSS DistributionsINSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR) 1180*c54f35caSApple OSS DistributionsINSTALL_KERNEL_SYM_TO_KDK = 1 1181*c54f35caSApple OSS DistributionsINSTALL_XNU_DEBUG_FILES = 1 1182*c54f35caSApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) 1183*c54f35caSApple OSS DistributionsINSTALL_KERNEL_SYM_TO_KDK = 1 1184*c54f35caSApple OSS DistributionsUSE_BINARY_PLIST = 1 1185*c54f35caSApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) 1186*c54f35caSApple OSS DistributionsUSE_BINARY_PLIST = 1 1187*c54f35caSApple OSS Distributionselse ifeq ($(PLATFORM),MacOSX) 1188*c54f35caSApple OSS DistributionsINSTALL_KERNEL_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) 1189*c54f35caSApple OSS DistributionsINSTALL_KERNEL_SYM_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) 1190*c54f35caSApple OSS DistributionsINSTALL_KERNEL_SYM_TO_KDK = $(if $(filter YES,$(DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT)),1,0) 1191*c54f35caSApple OSS Distributionsendif 1192*c54f35caSApple OSS Distributions 1193*c54f35caSApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_kasan),) 1194*c54f35caSApple OSS DistributionsINSTALL_KASAN_ONLY = 1 1195*c54f35caSApple OSS Distributionsendif 1196*c54f35caSApple OSS Distributions 1197*c54f35caSApple OSS Distributions# vim: set ft=make: 1198