Add support for AArch64 XOM binaries.
Adds build system support for generating AArch64 binaries with
execute-only memory layouts via a new LOCAL_XOM property. Also adds
support for an ENABLE_XOM build flag for global builds.
Bug: 77958880
Test: make -j ENABLE_XOM=true
Change-Id: I6af9e3615d0a9fdff802eae50e6ad94311ec8046
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