summaryrefslogtreecommitdiff
path: root/tools/check_elf_file.py
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2022-10-27 00:44:24 +0000
committer Spandan Das <spandandas@google.com> 2022-10-27 02:08:23 +0000
commit60b8195c833545f063e60999b49cb373d98964cd (patch)
tree3a2a8b4ac8baab6951995bd56942717adf260882 /tools/check_elf_file.py
parentf95b5f77588a1272bd10570ff1a0ebc426a05bef (diff)
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
Diffstat (limited to 'tools/check_elf_file.py')
-rwxr-xr-xtools/check_elf_file.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/check_elf_file.py b/tools/check_elf_file.py
index 0b80226935..eaa1854af3 100755
--- a/tools/check_elf_file.py
+++ b/tools/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: