aboutsummaryrefslogtreecommitdiff
path: root/scripts/lib_syms_sane.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib_syms_sane.sh')
-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