Merge "Add support for TARGET_PRODUCT_PROP"
diff --git a/core/Makefile b/core/Makefile
index 587eaf8..6db4b2b 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -3690,7 +3690,7 @@
 	$(hide) cp $(BUILT_VENDOR_MATRIX) $(zip_root)/META/vendor_matrix.xml
 endif
 ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
-	$(hide) echo "dynamic_partition_use=true" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "use_dynamic_partitions=true" >> $(zip_root)/META/misc_info.txt
 endif
 ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
 	$(hide) echo "dynamic_partition_retrofit=true" >> $(zip_root)/META/misc_info.txt
diff --git a/core/binary.mk b/core/binary.mk
index d7112b6..23defdc 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -73,6 +73,30 @@
   my_native_coverage := false
 endif
 
+ifeq ($(strip $(ENABLE_XOM)),true)
+  ifndef LOCAL_IS_HOST_MODULE
+    my_xom := true
+    # Disable XOM in excluded paths.
+    combined_xom_exclude_paths := $(XOM_EXCLUDE_PATHS) \
+                                  $(PRODUCT_XOM_EXCLUDE_PATHS)
+    ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_xom_exclude_paths)),\
+           $(filter $(dir)%,$(LOCAL_PATH)))),)
+      my_xom := false
+    endif
+
+    # Allow LOCAL_XOM to override the above
+    ifdef LOCAL_XOM
+      my_xom := $(LOCAL_XOM)
+    endif
+
+    ifeq ($(strip $(my_xom)),true)
+      ifeq (arm64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+        my_ldflags += -Wl,-execute-only
+      endif
+    endif
+  endif
+endif
+
 my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
 ifdef SANITIZE_HOST
 ifdef LOCAL_IS_HOST_MODULE
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 64caa18..0417e13 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -302,6 +302,7 @@
 LOCAL_VTS_MODE:=
 LOCAL_WARNINGS_ENABLE:=
 LOCAL_WHOLE_STATIC_LIBRARIES:=
+LOCAL_XOM:=
 LOCAL_YACCFLAGS:=
 # TODO: deprecate, it does nothing
 OVERRIDE_BUILT_MODULE_PATH:=
diff --git a/core/product.mk b/core/product.mk
index 7d5f9b3..fbdd237 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -212,6 +212,7 @@
     PRODUCT_USE_DYNAMIC_PARTITIONS \
     PRODUCT_RETROFIT_DYNAMIC_PARTITIONS \
     PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
+    PRODUCT_XOM_EXCLUDE_PATHS \
 
 define dump-product
 $(info ==== $(1) ====)\
diff --git a/core/product_config.mk b/core/product_config.mk
index d4275d2..ac7fe91 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -501,6 +501,10 @@
 PRODUCT_CFI_INCLUDE_PATHS := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CFI_INCLUDE_PATHS))
 
+# Whether any paths are excluded from being set XOM when ENABLE_XOM=true
+PRODUCT_XOM_EXCLUDE_PATHS := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_XOM_EXCLUDE_PATHS))
+
 # which Soong namespaces to export to Make
 PRODUCT_SOONG_NAMESPACES := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SOONG_NAMESPACES))
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 4328453..48dd228 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -82,6 +82,8 @@
 $(call add_json_bool, EnableCFI,                         $(call invert_bool,$(filter false,$(ENABLE_CFI))))
 $(call add_json_list, CFIExcludePaths,                   $(CFI_EXCLUDE_PATHS) $(PRODUCT_CFI_EXCLUDE_PATHS))
 $(call add_json_list, CFIIncludePaths,                   $(CFI_INCLUDE_PATHS) $(PRODUCT_CFI_INCLUDE_PATHS))
+$(call add_json_bool, EnableXOM,                         $(filter true,$(ENABLE_XOM)))
+$(call add_json_list, XOMExcludePaths,                   $(XOM_EXCLUDE_PATHS) $(PRODUCT_XOM_EXCLUDE_PATHS))
 $(call add_json_list, IntegerOverflowExcludePaths,       $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
 
 $(call add_json_bool, ClangTidy,                         $(filter 1 true,$(WITH_TIDY)))
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 68275dc..7e9677b 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -2013,10 +2013,10 @@
   OPTIONS.oem_dicts = _LoadOemDicts(OPTIONS.oem_source)
 
   # Assume retrofitting dynamic partitions when base build does not set
-  # dynamic_partition_use but target build does.
+  # use_dynamic_partitions but target build does.
   if (OPTIONS.source_info_dict and
-      OPTIONS.source_info_dict.get("dynamic_partition_use") != "true" and
-      OPTIONS.target_info_dict.get("dynamic_partition_use") == "true"):
+      OPTIONS.source_info_dict.get("use_dynamic_partitions") != "true" and
+      OPTIONS.target_info_dict.get("use_dynamic_partitions") == "true"):
     if OPTIONS.target_info_dict.get("dynamic_partition_retrofit") != "true":
       raise common.ExternalError(
           "Expect to generate incremental OTA for retrofitting dynamic "