summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-11-22 16:09:59 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-11-22 16:09:59 +0100
commit2ff19f084f3a50272606583c27eb8e2bb01fe75f (patch)
treeb04f1a1ef7328075110e3f7c3124cc3e9ea91ba8 /scripts
parent168ef9be32ad754d7bcb38ed70787237fc12630d (diff)
Add a hacky script to sanity check symbols exported by libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/lib_syms_sane.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/lib_syms_sane.sh b/scripts/lib_syms_sane.sh
new file mode 100755
index 0000000..d49ff1b
--- /dev/null
+++ b/scripts/lib_syms_sane.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+SPC="[[:space:]]\+"
+HEXNUM="[0-9a-fA-F]\+"
+NUM="[0-9]\+"
+
+WINE_PATTERN="^${SPC}${HEXNUM}${SPC}${NUM}${SPC}"
+ELF_PATTERN="^${SPC}${NUM}:${SPC}${HEXNUM}${SPC}${NUM}${SPC}"
+
+symbols_from_file() {
+ case "$1" in
+ *.dll)
+ winedump -j export "$1" | grep "$WINE_PATTERN" | \
+ sed "s/$WINE_PATTERN//g"
+ ;;
+ *)
+ readelf -TW -s "$1" | grep "$ELF_PATTERN" | grep -v "UND" | \
+ sed "s/$ELF_PATTERN//g" | grep -o "${NUM}${SPC}.\+$" | \
+ sed "s/^${NUM}${SPC}//g"
+ esac
+}
+
+symbols_from_file "$1" | grep -q "^sqfs_.*"
+
+if [ "$?" != "0" ]; then
+ symbols_from_file "$1"
+ echo "ERROR: No symbols with sqfs_ prefix found!"
+ exit 1
+fi
+
+symbols_from_file "$1" | grep -v "^sqfs_"
+
+if [ "$?" != "1" ]; then
+ echo "ERROR: Symbols without sqfs_ prefix found!"
+ exit 1
+fi
+
+exit 0