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_BUILT_MODULE 11# - LOCAL_IS_HOST_MODULE 12# - LOCAL_MODULE_CLASS 13# - intermediates 14# - my_installed_module_stem 15# - my_prebuilt_src_file 16# - my_check_elf_file_shared_lib_files 17# - my_system_shared_libraries 18 19ifndef LOCAL_IS_HOST_MODULE 20ifneq ($(filter $(LOCAL_MODULE_CLASS),SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS),) 21check_elf_files_stamp := $(intermediates)/check_elf_files.timestamp 22$(check_elf_files_stamp): PRIVATE_SONAME := $(if $(filter $(LOCAL_MODULE_CLASS),SHARED_LIBRARIES),$(my_installed_module_stem)) 23$(check_elf_files_stamp): PRIVATE_ALLOW_UNDEFINED_SYMBOLS := $(LOCAL_ALLOW_UNDEFINED_SYMBOLS) 24$(check_elf_files_stamp): PRIVATE_SYSTEM_SHARED_LIBRARIES := $(my_system_shared_libraries) 25# PRIVATE_SHARED_LIBRARY_FILES are file paths to built shared libraries. 26# In addition to $(my_check_elf_file_shared_lib_files), some file paths are 27# added by `resolve-shared-libs-for-elf-file-check` from `core/main.mk`. 28$(check_elf_files_stamp): PRIVATE_SHARED_LIBRARY_FILES := $(my_check_elf_file_shared_lib_files) 29$(check_elf_files_stamp): $(my_prebuilt_src_file) $(my_check_elf_file_shared_lib_files) $(CHECK_ELF_FILE) $(LLVM_READOBJ) 30 @echo Check prebuilt ELF binary: $< 31 $(hide) mkdir -p $(dir $@) 32 $(hide) rm -f $@ 33 $(hide) $(CHECK_ELF_FILE) \ 34 --skip-bad-elf-magic \ 35 --skip-unknown-elf-machine \ 36 $(if $(PRIVATE_SONAME),--soname $(PRIVATE_SONAME)) \ 37 $(foreach l,$(PRIVATE_SHARED_LIBRARY_FILES),--shared-lib $(l)) \ 38 $(foreach l,$(PRIVATE_SYSTEM_SHARED_LIBRARIES),--system-shared-lib $(l)) \ 39 $(if $(PRIVATE_ALLOW_UNDEFINED_SYMBOLS),--allow-undefined-symbols) \ 40 --llvm-readobj=$(LLVM_READOBJ) \ 41 $< 42 $(hide) touch $@ 43 44CHECK_ELF_FILES.$(check_elf_files_stamp) := 1 45 46ifneq ($(strip $(LOCAL_CHECK_ELF_FILES)),false) 47ifneq ($(strip $(BUILD_BROKEN_PREBUILT_ELF_FILES)),true) 48$(LOCAL_BUILT_MODULE): $(check_elf_files_stamp) 49check-elf-files: $(check_elf_files_stamp) 50endif # BUILD_BROKEN_PREBUILT_ELF_FILES 51endif # LOCAL_CHECK_ELF_FILES 52 53endif # SHARED_LIBRARIES, EXECUTABLES, NATIVE_TESTS 54endif # !LOCAL_IS_HOST_MODULE 55