summaryrefslogtreecommitdiffstats
path: root/scripts/undefsym.py
diff options
context:
space:
mode:
authorPeter Maydell2020-09-08 14:23:58 +0200
committerPeter Maydell2020-09-08 14:23:58 +0200
commit46853bd9e7126e0673b12e6d2bf1ee9dedc5afbd (patch)
treea1ba94b8a457fa245e77d08a5bc26f7af1b3fa7b /scripts/undefsym.py
parentMerge remote-tracking branch 'remotes/hdeller/tags/target-hppa-pull-request' ... (diff)
parentdocs: update build system documentation (diff)
downloadqemu-46853bd9e7126e0673b12e6d2bf1ee9dedc5afbd.tar.gz
qemu-46853bd9e7126e0673b12e6d2bf1ee9dedc5afbd.tar.xz
qemu-46853bd9e7126e0673b12e6d2bf1ee9dedc5afbd.zip
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging
meson related: * convert unit tests * bugfixes for mtest2make * miscellaneous bugfixes * dead code removal and configure cleanups * oss-fuzz fixes * msys fixes # gpg: Signature made Tue 08 Sep 2020 10:43:27 BST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini-gitlab/tags/for-upstream: (45 commits) docs: update build system documentation meson: remove linkage of sdl to baum meson: Convert undefsym.sh to undefsym.py fuzz: Add support for custom fuzzing library meson: specify fuzz linker script as a project arg oss-fuzz: fix rpath configure: update dtc submodule docs: suggest Meson replacements for various configure functions configure: drop dead variables and functions configure: do not include dependency flags in QEMU_CFLAGS and LIBS meson: get opengl compilation flags from OPENGL_CFLAGS meson: get glib compilation flags from GLIB_CFLAGS configure: do not look for install(1) configure: remove unnecessary libm test configure: move -ldl test to meson meson: keep all compiler flags detection together configure: move disassembler configuration to meson Makefile: inline the relevant parts of rules.mak Makefile: remove dead variables and includes meson: compute config_all_devices directly ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/undefsym.py')
-rw-r--r--scripts/undefsym.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/undefsym.py b/scripts/undefsym.py
new file mode 100644
index 0000000000..69a895cd26
--- /dev/null
+++ b/scripts/undefsym.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+# Before a shared module's DSO is produced, a static library is built for it
+# and passed to this script. The script generates -Wl,-u options to force
+# the inclusion of symbol from libqemuutil.a if the shared modules need them,
+# This is necessary because the modules may use functions not needed by the
+# executable itself, which would cause the function to not be linked in.
+# Then the DSO loading would fail because of the missing symbol.
+
+
+import sys
+import subprocess
+
+def filter_lines_set(stdout, from_staticlib):
+ linesSet = set()
+ for line in stdout.splitlines():
+ tokens = line.split(b' ')
+ if len(tokens) >= 1:
+ if len(tokens) > 1:
+ if from_staticlib and tokens[1] == b'U':
+ continue
+ if not from_staticlib and tokens[1] != b'U':
+ continue
+ new_line = b'-Wl,-u,' + tokens[0]
+ if not new_line in linesSet:
+ linesSet.add(new_line)
+ return linesSet
+
+def main(args):
+ if len(args) <= 3:
+ sys.exit(0)
+
+ nm = args[1]
+ staticlib = args[2]
+ pc = subprocess.run([nm, "-P", "-g", staticlib], stdout=subprocess.PIPE)
+ if pc.returncode != 0:
+ sys.exit(1)
+ staticlib_syms = filter_lines_set(pc.stdout, True)
+
+ shared_modules = args[3:]
+ pc = subprocess.run([nm, "-P", "-g"] + shared_modules, stdout=subprocess.PIPE)
+ if pc.returncode != 0:
+ sys.exit(1)
+ modules_undef_syms = filter_lines_set(pc.stdout, False)
+ lines = sorted(staticlib_syms.intersection(modules_undef_syms))
+ sys.stdout.buffer.write(b'\n'.join(lines))
+
+if __name__ == "__main__":
+ main(sys.argv)