1#############################################################
2## Set up my_pack_module_relocations
3## Input variables:
4##   DISABLE_RELOCATION_PACKER,
5##   LOCAL_PACK_MODULE_RELOCATIONS*,
6##   *TARGET_PACK_MODULE_RELOCATIONS,
7##   LOCAL_MODULE_CLASS, HOST_OS
8##   LOCAL_IS_HOST_MODULE
9## Output variables:
10##   my_pack_module_relocations, if false skip relocation_packer
11#############################################################
12
13my_pack_module_relocations := false
14ifneq ($(DISABLE_RELOCATION_PACKER),true)
15  my_pack_module_relocations := $(firstword \
16    $(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
17    $(LOCAL_PACK_MODULE_RELOCATIONS))
18endif
19
20ifeq ($(my_pack_module_relocations),)
21  my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
22endif
23
24# Do not pack relocations for executables. Because packing results in
25# non-zero p_vaddr which causes kernel to load executables to lower
26# address (starting at 0x8000) http://b/20665974
27ifeq ($(filter SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
28  my_pack_module_relocations := false
29endif
30
31ifdef LOCAL_IS_HOST_MODULE
32  # Do not pack relocations on host modules
33  my_pack_module_relocations := false
34endif
35
36# Lld relocation packing cannot be enabled for binaries before Android Pie.
37ifneq ($(LOCAL_SDK_VERSION),)
38  ifneq ($(LOCAL_SDK_VERSION),current)
39    ifeq ($(call math_lt,$(LOCAL_SDK_VERSION),28),true)
40      my_pack_module_relocations := false
41    endif
42  endif
43endif
44