summaryrefslogtreecommitdiffstats
path: root/gfx/harfbuzz/src/check-static-inits.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /gfx/harfbuzz/src/check-static-inits.py
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/harfbuzz/src/check-static-inits.py')
-rwxr-xr-xgfx/harfbuzz/src/check-static-inits.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/gfx/harfbuzz/src/check-static-inits.py b/gfx/harfbuzz/src/check-static-inits.py
new file mode 100755
index 0000000000..c6e2db1ea6
--- /dev/null
+++ b/gfx/harfbuzz/src/check-static-inits.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+
+import sys, os, shutil, subprocess, glob, re
+
+builddir = os.getenv ('builddir', os.path.dirname (__file__))
+libs = os.getenv ('libs', '.libs')
+
+objdump = os.getenv ('OBJDUMP', shutil.which ('objdump'))
+if not objdump:
+ print ('check-static-inits.py: \'ldd\' not found; skipping test')
+ sys.exit (77)
+
+if sys.version_info < (3, 5):
+ print ('check-static-inits.py: needs python 3.5 for recursive support in glob')
+ sys.exit (77)
+
+OBJS = glob.glob (os.path.join (builddir, libs, '**', '*hb*.o'), recursive=True)
+if not OBJS:
+ print ('check-static-inits.py: object files not found; skipping test')
+ sys.exit (77)
+
+stat = 0
+tested = 0
+
+for obj in OBJS:
+ result = subprocess.run(objdump.split () + ['-t', obj], 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
+
+ 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 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
+
+ tested += 1
+
+sys.exit (stat if tested else 77)