1# Check the correctness of the prebuilt ELF files 2# 3# This check ensures that DT_SONAME matches with the filename, DT_NEEDED 4# matches the shared libraries specified in LOCAL_SHARED_LIBRARIES, and all 5# undefined symbols in the prebuilt binary can be found in one of the shared 6# libraries specified in LOCAL_SHARED_LIBRARIES. 7# 8# Inputs: 9# - LOCAL_ALLOW_UNDEFINED_SYMBOLS 10# - LOCAL_IGNORE_MAX_PAGE_SIZE 11# - LOCAL_BUILT_MODULE 12# - LOCAL_IS_HOST_MODULE 13# - LOCAL_MODULE_CLASS 14# - TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE 15# - TARGET_MAX_PAGE_SIZE_SUPPORTED 16# - intermediates 17# - my_installed_module_stem 18# - my_prebuilt_src_file 19# - my_check_elf_file_shared_lib_files 20# - my_system_shared_libraries 21 22ifndef LOCAL_IS_HOST_MODULE 23ifneq ($(filter $(LOCAL_MODULE_CLASS),SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS),) 24check_elf_files_stamp := $(intermediates)/check_elf_files.timestamp 25$(check_elf_files_stamp): PRIVATE_SONAME := $(if $(filter $(LOCAL_MODULE_CLASS),SHARED_LIBRARIES),$(my_installed_module_stem)) 26$(check_elf_files_stamp): PRIVATE_ALLOW_UNDEFINED_SYMBOLS := $(LOCAL_ALLOW_UNDEFINED_SYMBOLS) 27$(check_elf_files_stamp): PRIVATE_SYSTEM_SHARED_LIBRARIES := $(my_system_shared_libraries) 28# PRIVATE_SHARED_LIBRARY_FILES are file paths to built shared libraries. 29# In addition to $(my_check_elf_file_shared_lib_files), some file paths are 30# added by `resolve-shared-libs-for-elf-file-check` from `core/main.mk`. 31$(check_elf_files_stamp): PRIVATE_SHARED_LIBRARY_FILES := $(my_check_elf_file_shared_lib_files) 32 33# For different page sizes to work, we must support a larger max page size 34# as well as properly reflect page size at runtime. Limit this check, since many 35# devices set the max page size (for future proof) than actually use the 36# larger page size. 37ifeq ($(strip $(TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE)),true) 38ifeq ($(strip $(LOCAL_IGNORE_MAX_PAGE_SIZE)),true) 39$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE := 40else 41$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE := $(TARGET_MAX_PAGE_SIZE_SUPPORTED) 42endif 43else 44$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE := 45endif 46 47$(check_elf_files_stamp): $(my_prebuilt_src_file) $(my_check_elf_file_shared_lib_files) $(CHECK_ELF_FILE) $(LLVM_READOBJ) 48 @echo Check prebuilt ELF binary: $< 49 $(hide) mkdir -p $(dir $@) 50 $(hide) rm -f $@ 51 $(hide) $(CHECK_ELF_FILE) \ 52 --skip-bad-elf-magic \ 53 --skip-unknown-elf-machine \ 54 $(if $(PRIVATE_MAX_PAGE_SIZE),--max-page-size=$(PRIVATE_MAX_PAGE_SIZE)) \ 55 $(if $(PRIVATE_SONAME),--soname $(PRIVATE_SONAME)) \ 56 $(foreach l,$(PRIVATE_SHARED_LIBRARY_FILES),--shared-lib $(l)) \ 57 $(foreach l,$(PRIVATE_SYSTEM_SHARED_LIBRARIES),--system-shared-lib $(l)) \ 58 $(if $(PRIVATE_ALLOW_UNDEFINED_SYMBOLS),--allow-undefined-symbols) \ 59 --llvm-readobj=$(LLVM_READOBJ) \ 60 $< 61 $(hide) touch $@ 62 63CHECK_ELF_FILES.$(check_elf_files_stamp) := 1 64 65ifneq ($(strip $(LOCAL_CHECK_ELF_FILES)),false) 66ifneq ($(strip $(BUILD_BROKEN_PREBUILT_ELF_FILES)),true) 67$(LOCAL_BUILT_MODULE): $(check_elf_files_stamp) 68check-elf-files: $(check_elf_files_stamp) 69endif # BUILD_BROKEN_PREBUILT_ELF_FILES 70endif # LOCAL_CHECK_ELF_FILES 71 72endif # SHARED_LIBRARIES, EXECUTABLES, NATIVE_TESTS 73endif # !LOCAL_IS_HOST_MODULE 74