Merge "Migrate check_elf_file.py to python3"

This commit is contained in:
Spandan Das
2022-10-27 16:46:18 +00:00
committed by Gerrit Code Review
3 changed files with 9 additions and 8 deletions

View File

@@ -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"],
}

View File

@@ -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: