diff options
author | Scott Lobdell <slobdell@google.com> | 2021-04-25 19:53:00 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-04-25 19:53:00 +0000 |
commit | dfa7c0a9b59c4ef591f46f7624dfe687c2bb0a6c (patch) | |
tree | 4b78af6f79fb9de2a712ac6268059bf838000a40 /libc/tools/check-symbols.py | |
parent | 987dccb5f063052171fae7a59cbf9fca808f8f80 (diff) | |
parent | 4626df89bfb561fc06d805e04d040a15f378919f (diff) |
Merge SP1A.210425.001
Change-Id: If71c56f3e2e9fbbeffc7096a560a5ef8b8cd8566
Diffstat (limited to 'libc/tools/check-symbols.py')
-rwxr-xr-x | libc/tools/check-symbols.py | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/libc/tools/check-symbols.py b/libc/tools/check-symbols.py deleted file mode 100755 index 656891790..000000000 --- a/libc/tools/check-symbols.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python - -import glob -import os -import re -import string -import subprocess -import sys - -toolchain = os.environ['ANDROID_TOOLCHAIN'] -arch = re.sub(r'.*/linux-x86/([^/]+)/.*', r'\1', toolchain) - -sys.stderr.write('Checking symbols for arch "%s"...\n' % arch) - -def GetSymbols(library, functions_or_variables): - global api - global arch - - api = '9' - if library == 'libm' and arch == 'arm': - api = '3' - - # There were no 64-bit ABIs before API level 21. - if '64' in arch: - api = '21' - - # What GCC calls aarch64, Android calls arm64. - if arch == 'aarch64': - arch = 'arm64' - - path = '%s/development/ndk/platforms/android-%s/arch-%s/symbols/%s.so.%s.txt' % (os.environ['ANDROID_BUILD_TOP'], api, arch, library, functions_or_variables) - symbols = set() - for line in open(path, 'r'): - symbols.add(line.rstrip()) - #sys.stdout.write('%d %s in %s for %s\n' % (len(symbols), functions_or_variables, library, arch)) - return symbols - -def CheckSymbols(library, functions_or_variables): - expected_symbols = GetSymbols(library, functions_or_variables) - - lib_dir = 'lib' - if '64' in arch: - lib_dir = 'lib64' - - so_file = '%s/system/%s/%s.so' % (os.environ['ANDROID_PRODUCT_OUT'], lib_dir, library) - - # Example readelf output: - # 264: 0001623c 4 FUNC GLOBAL DEFAULT 8 cabsf - # 266: 00016244 4 FUNC GLOBAL DEFAULT 8 dremf - # 267: 00019018 4 OBJECT GLOBAL DEFAULT 11 __fe_dfl_env - # 268: 00000000 0 FUNC GLOBAL DEFAULT UND __aeabi_dcmplt - - - r = re.compile(r' +\d+: [0-9a-f]+ +\d+ (FUNC|OBJECT) +\S+ +\S+ +\d+ (\S+)') - - actual_symbols = set() - for line in subprocess.check_output(['readelf', '-W', '--dyn-syms', so_file]).split('\n'): - m = r.match(line) - if m: - symbol = string.split(m.group(2), '@')[0] - if m.group(1) == 'FUNC' and functions_or_variables == 'functions': - actual_symbols.add(symbol) - elif m.group(1) == 'OBJECT' and functions_or_variables == 'variables': - actual_symbols.add(symbol) - #else: - #print 'ignoring: ' % line - - missing = expected_symbols - actual_symbols - if len(missing) > 0: - sys.stderr.write('%d missing %s in %s for %s:\n' % (len(missing), functions_or_variables, library, arch)) - for miss in sorted(missing): - sys.stderr.write(' %s\n' % miss) - - extra = actual_symbols - expected_symbols - if len(extra) > 0: - sys.stderr.write('%d extra %s in %s for %s:\n' % (len(extra), functions_or_variables, library, arch)) - for s in sorted(extra): - sys.stderr.write(' %s\n' % s) - - return len(missing) == 0 - -CheckSymbols("libc", "functions") -CheckSymbols("libc", "variables") -CheckSymbols("libm", "functions") -CheckSymbols("libm", "variables") - -sys.exit(0) |