From 628a9ee28a280d3e57bb870f0c4bf5a6c5976b99 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 6 Apr 2025 02:15:51 -0600 Subject: [PATCH] [check-static-inits] objdump all objects together We won't see which object has the bad initializers anymore. We can later adapt to objdump each object one by one if any error was found. Changes test runtime from 1s down to 0.15s. --- src/check-static-inits.py | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/check-static-inits.py b/src/check-static-inits.py index c6e2db1ea..2acd04602 100755 --- a/src/check-static-inits.py +++ b/src/check-static-inits.py @@ -22,30 +22,30 @@ if not OBJS: stat = 0 tested = 0 -for obj in OBJS: - result = subprocess.run(objdump.split () + ['-t', obj], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +result = subprocess.run(objdump.split () + ['-t'] + OBJS, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if result.returncode: - if result.stderr.find (b'not recognized') != -1: - # https://github.com/harfbuzz/harfbuzz/issues/3019 - print ('objdump %s returned "not recognized", skipping' % obj) - continue - print ('objdump %s returned error:\n%s' % (obj, result.stderr.decode ('utf-8'))) - stat = 2 +if result.returncode: + if result.stderr.find (b'not recognized') != -1: + # https://github.com/harfbuzz/harfbuzz/issues/3019 + print ('objdump %s returned "not recognized", skipping') + else: + print ('objdump returned error:\n%s' % (result.stderr.decode ('utf-8'))) + stat = 2 +else: + tested = 1 - result = result.stdout.decode ('utf-8') +result = result.stdout.decode ('utf-8') - # Checking that no object file has static initializers - for l in re.findall (r'^.*\.[cd]tors.*$', result, re.MULTILINE): - if not re.match (r'.*\b0+\b', l): - print ('Ouch, %s has static initializers/finalizers' % obj) - stat = 1 +# Checking that no object file has static initializers +for l in re.findall (r'^.*\.[cd]tors.*$', result, re.MULTILINE): + if not re.match (r'.*\b0+\b', l): + print ('Ouch, library has static initializers/finalizers') + stat = 1 - # Checking that no object file has lazy static C++ constructors/destructors or other such stuff - if ('__cxa_' in result) and ('__ubsan_handle' not in result): - print ('Ouch, %s has lazy static C++ constructors/destructors or other such stuff' % obj) - stat = 1 +# Checking that no object file has lazy static C++ constructors/destructors or other such stuff +if ('__cxa_' in result) and ('__ubsan_handle' not in result): + print ('Ouch, library has lazy static C++ constructors/destructors or other such stuff') + stat = 1 - tested += 1 sys.exit (stat if tested else 77)