Migrate check_elf_file.py to python3
Also, create a python_binary_host so that it runs using the hermetic python toolchain. Test: m check-elf-files Bug: 203436762 Change-Id: I964342a27f6b6c9dcdbbe910d4dc6c9ec00c2213
This commit is contained in:
@@ -612,7 +612,7 @@ TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
|
||||
JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
|
||||
DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
|
||||
FAT16COPY := build/make/tools/fat16copy.py
|
||||
CHECK_ELF_FILE := build/make/tools/check_elf_file.py
|
||||
CHECK_ELF_FILE := $(HOST_OUT_EXECUTABLES)/check_elf_file$(HOST_EXECUTABLE_SUFFIX)
|
||||
LPMAKE := $(HOST_OUT_EXECUTABLES)/lpmake$(HOST_EXECUTABLE_SUFFIX)
|
||||
ADD_IMG_TO_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/add_img_to_target_files$(HOST_EXECUTABLE_SUFFIX)
|
||||
BUILD_IMAGE := $(HOST_OUT_EXECUTABLES)/build_image$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
@@ -59,3 +59,8 @@ python_binary_host {
|
||||
name: "check_radio_versions",
|
||||
srcs: ["check_radio_versions.py"],
|
||||
}
|
||||
|
||||
python_binary_host {
|
||||
name: "check_elf_file",
|
||||
srcs: ["check_elf_file.py"],
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2019 The Android Open Source Project
|
||||
#
|
||||
@@ -196,11 +196,7 @@ class ELFParser(object):
|
||||
def _read_llvm_readobj(cls, elf_file_path, header, llvm_readobj):
|
||||
"""Run llvm-readobj and parse the output."""
|
||||
cmd = [llvm_readobj, '--dynamic-table', '--dyn-symbols', elf_file_path]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out, _ = proc.communicate()
|
||||
rc = proc.returncode
|
||||
if rc != 0:
|
||||
raise subprocess.CalledProcessError(rc, cmd, out)
|
||||
out = subprocess.check_output(cmd, text=True)
|
||||
lines = out.splitlines()
|
||||
return cls._parse_llvm_readobj(elf_file_path, header, lines)
|
||||
|
||||
@@ -467,7 +463,7 @@ class Checker(object):
|
||||
"""Check whether all undefined symbols are resolved to a definition."""
|
||||
all_elf_files = [self._file_under_test] + self._shared_libs
|
||||
missing_symbols = []
|
||||
for sym, imported_vers in self._file_under_test.imported.iteritems():
|
||||
for sym, imported_vers in self._file_under_test.imported.items():
|
||||
for imported_ver in imported_vers:
|
||||
lib = self._find_symbol_from_libs(all_elf_files, sym, imported_ver)
|
||||
if not lib:
|
||||
|
Reference in New Issue
Block a user