Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0 Updated BSim launch shell scripts

ghidra183affc338063
diff --git a/Ghidra/RuntimeScripts/Linux/support/bsim b/Ghidra/RuntimeScripts/Linux/support/bsim
index 6f97a9820c..fb69b6cd8c 100755
--- a/Ghidra/RuntimeScripts/Linux/support/bsim
+++ b/Ghidra/RuntimeScripts/Linux/support/bsim
@@ -3,23 +3,18 @@
# Command-line script for interacting with a BSim database
# maximum heap memory (may be increased)
-MAXMEM=768M
+MAXMEM=1G
# launch mode (fg, bg, debug, debug-suspend)
LAUNCH_MODE=fg
-#set debug port for debug mode if used
+VMARG_LIST="-Djava.awt.headless=true "
-OS=`uname -s`
+# Resolve symbolic link if present and get the directory this script lives in.
+# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
+# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the
+# fallback, which doesn't attempt to do anything with links.
+SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
+SCRIPT_DIR="${SCRIPT_FILE%/*}"
-SED=/bin/sed
-if [ "$OS" = "Darwin" ]; then
- SED=/usr/bin/sed
-fi
-
-LAUNCH_DIR=`echo $0 | $SED -e 's/[^\/]*$//'`
-if [ "$LAUNCH_DIR" = "" ]; then
- LAUNCH_DIR="./";
-fi
-
-${LAUNCH_DIR}launch.sh $LAUNCH_MODE jdk "BSim" $MAXMEM "" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"
+${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" $MAXMEM "" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"
diff --git a/Ghidra/RuntimeScripts/Linux/support/bsim_ctl b/Ghidra/RuntimeScripts/Linux/support/bsim_ctl
index 0e9a2142b8..e3e6da22fd 100755
--- a/Ghidra/RuntimeScripts/Linux/support/bsim_ctl
+++ b/Ghidra/RuntimeScripts/Linux/support/bsim_ctl
@@ -8,23 +8,17 @@ MAXMEM=768M
# launch mode (fg, bg, debug, debug-suspend)
LAUNCH_MODE=fg
-#set debug port for debug mode if used
+VMARG_LIST="-Djava.awt.headless=true "
-OS=`uname -s`
-MACHINE=`uname -m`
-
-SED=/bin/sed
-if [ "$OS" = "Darwin" ]; then
- SED=/usr/bin/sed
-fi
-
-LAUNCH_DIR=`echo $0 | $SED -e 's/[^\/]*$//'`
-if [ "$LAUNCH_DIR" = "" ]; then
- LAUNCH_DIR="./";
-fi
+# Resolve symbolic link if present and get the directory this script lives in.
+# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
+# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the
+# fallback, which doesn't attempt to do anything with links.
+SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
+SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Some JVM's with class data sharing enabled have issues with BSim starting with Ghidra's custom
# classloader, so we will disable sharing
VMARG_LIST="-Xshare:off"
-${LAUNCH_DIR}launch.sh $LAUNCH_MODE jdk "BSimControl" $MAXMEM "${VMARG_LIST}" ghidra.features.bsim.query.BSimControlLaunchable "$@"
+${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSimControl" $MAXMEM "${VMARG_LIST}" ghidra.features.bsim.query.BSimControlLaunchable "$@"