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