Index: build/android/resource_sizes.py |
diff --git a/build/android/resource_sizes.py b/build/android/resource_sizes.py |
index 77000b9ded635f4d25125bd85079ebd0c9abe028..ad425d943e3a0331eb95b123c6af792e3fd75315 100755 |
--- a/build/android/resource_sizes.py |
+++ b/build/android/resource_sizes.py |
@@ -160,7 +160,7 @@ def _CreateSectionNameSizeMap(so_path, tools_prefix): |
def _ParseLibBuildId(so_path, tools_prefix): |
"""Returns the Build ID of the given native library.""" |
- stdout = _RunReadelf(so_path, ['n'], tools_prefix) |
+ stdout = _RunReadelf(so_path, ['-n'], tools_prefix) |
match = re.search(r'Build ID: (\w+)', stdout) |
return match.group(1) if match else None |
@@ -596,17 +596,26 @@ def _PrintStaticInitializersCountFromApk(apk_filename, tools_prefix, |
chartjson=None): |
print 'Finding static initializers (can take a minute)' |
with zipfile.ZipFile(apk_filename) as z: |
- infolist = z.infolist() |
+ infolist = sorted(z.infolist(), key=lambda z: z.file_size, reverse=True) |
out_dir = constants.GetOutDirectory() |
si_count = 0 |
+ saw_first_so = False |
for zip_info in infolist: |
# Check file size to account for placeholder libraries. |
if zip_info.filename.endswith('.so') and zip_info.file_size > 0: |
lib_name = os.path.basename(zip_info.filename).replace('crazy.', '') |
unstripped_path = os.path.join(out_dir, 'lib.unstripped', lib_name) |
if os.path.exists(unstripped_path): |
+ # Some 64 bit APKS (MonochromePublic.apk, SystemWebView.apk) include |
+ # 32 bit .so files. Since some bots already perform |
+ # dump-static-initializers.py checks on the 32 bit unstripped so files, |
+ # we ignore these when 64 bit .so files are present by only checking the |
+ # largest .so file (this also avoids the complexity of finding .so files |
+ # generated with a secondary toolchain). See http://crbug.com/708942. |
+ check_unstripped, saw_first_so = not saw_first_so, True |
agrieve
2017/04/06 19:26:46
This will not check the SIs in the crazy linker, w
|
si_count += _PrintStaticInitializersCount( |
- apk_filename, zip_info.filename, unstripped_path, tools_prefix) |
+ apk_filename, zip_info.filename, unstripped_path, tools_prefix, |
+ check_unstripped) |
else: |
raise Exception('Unstripped .so not found. Looked here: %s', |
unstripped_path) |
@@ -615,7 +624,7 @@ def _PrintStaticInitializersCountFromApk(apk_filename, tools_prefix, |
def _PrintStaticInitializersCount(apk_path, apk_so_name, so_with_symbols_path, |
- tools_prefix): |
+ tools_prefix, check_unstripped): |
"""Counts the number of static initializers in the given shared library. |
Additionally, files for which static initializers were found are printed |
on the standard output. |
@@ -632,18 +641,21 @@ def _PrintStaticInitializersCount(apk_path, apk_so_name, so_with_symbols_path, |
# static initializers. This does not work on all archs (particularly arm). |
# TODO(rnephew): Get rid of warning when crbug.com/585588 is fixed. |
with Unzip(apk_path, filename=apk_so_name) as unzipped_so: |
- _VerifyLibBuildIdsMatch(tools_prefix, unzipped_so, so_with_symbols_path) |
+ if check_unstripped: |
+ _VerifyLibBuildIdsMatch(tools_prefix, unzipped_so, so_with_symbols_path) |
readelf_si_count = CountStaticInitializers(unzipped_so, tools_prefix) |
- sis, dump_si_count = GetStaticInitializers( |
- so_with_symbols_path, tools_prefix) |
- if readelf_si_count != dump_si_count: |
- print ('There are %d files with static initializers, but ' |
- 'dump-static-initializers found %d: files' % |
- (readelf_si_count, dump_si_count)) |
- else: |
- print '%s - Found %d files with static initializers:' % ( |
- os.path.basename(so_with_symbols_path), dump_si_count) |
- print '\n'.join(sis) |
+ |
+ if check_unstripped: |
+ sis, dump_si_count = GetStaticInitializers( |
+ so_with_symbols_path, tools_prefix) |
+ if readelf_si_count != dump_si_count: |
+ print ('There are %d files with static initializers, but ' |
+ 'dump-static-initializers found %d files' % |
+ (readelf_si_count, dump_si_count)) |
+ else: |
+ print '%s - Found %d files with static initializers:' % ( |
+ os.path.basename(so_with_symbols_path), dump_si_count) |
+ print '\n'.join(sis) |
return readelf_si_count |