From 2ff19f084f3a50272606583c27eb8e2bb01fe75f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 22 Nov 2022 16:09:59 +0100 Subject: Add a hacky script to sanity check symbols exported by libsquashfs Signed-off-by: David Oberhollenzer --- scripts/lib_syms_sane.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/lib_syms_sane.sh 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 -- cgit v1.2.3