From a8b04d24d53025aaa72f899380b1bd1ff1b44b8a Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Sun, 1 Feb 2026 15:36:35 -0500 Subject: [PATCH 1/3] Fix POSIX shell compatibility of delink script Accidentally used == for a comparison instead of =, while only the latter is in the standard. Ref. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html --- delink/delink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delink/delink.sh b/delink/delink.sh index 161fda4..dab87b2 100755 --- a/delink/delink.sh +++ b/delink/delink.sh @@ -17,7 +17,7 @@ main() { set -- $line set +f; IFS=$IFS_PREV - if [ "$2" == true ]; then # If object is marked for extraction + if [ "$2" = true ]; then # If object is marked for extraction object_name=$1 printf '\n--- %s ---\n' "$object_name" From 91537e765ac9f4a19feb5e947988129814efc7f1 Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Sun, 1 Feb 2026 17:02:13 -0500 Subject: [PATCH 2/3] Fix unwanted delinking path expansion on Windows In short, we ran afoul of this issue because the Ghidra delinking headless script begins its arguments with slashes, making them look like absolute paths: https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line --- delink/delink.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/delink/delink.sh b/delink/delink.sh index dab87b2..2df52e2 100755 --- a/delink/delink.sh +++ b/delink/delink.sh @@ -58,6 +58,12 @@ delink() { else suffix= fi + # POSIX compatibility layers for Windows (like in git bash) will + # interpret arguments like /exporter as filepaths and attempt to + # convert them to Windows paths, breaking them; this variable disables + # that + export MSYS_NO_PATHCONV=1 + "$1/support/analyzeHeadless$suffix" "$2" "$3"\ -process default.xbe\ -noanalysis\ From cef08bf624f68ec8177d3be397b7c5b1df4c1d6d Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Sun, 1 Feb 2026 17:35:49 -0500 Subject: [PATCH 3/3] Documentation enhancements for delink.sh Thanks to Shanghao for helping find and test these different issues. --- documentation/gettingstarted.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/documentation/gettingstarted.md b/documentation/gettingstarted.md index 3b1e9ac..3bed97c 100644 --- a/documentation/gettingstarted.md +++ b/documentation/gettingstarted.md @@ -93,10 +93,10 @@ should be all ready for creating object files for objdiff. ### Producing Object Files -Close all of your Ghidra windows and open a shell in the decompilation -repository's `delink/` directory. The `delink.sh` script is our automated tool -for extracting all the object files that have been identified so far. Invoke -it with three arguments: +Close all of your Ghidra windows and open a Unix-style shell (e.g. Git Bash if +on Windows) in the decompilation repository's `delink/` directory. The +`delink.sh` script is our automated tool for extracting all the object files +that have been identified so far. Invoke it with three arguments: - The path to your Ghidra installation (the directory with files like `ghidraRun` and `ghidraRun.bat`, and directories like `docs/` and @@ -105,13 +105,27 @@ it with three arguments: directory with a name ending in `.rep`) - The name of your JSRF Ghidra project -There are two common errors you might get here: +If you're on Windows, the paths you provide should be Windows filepaths, not +Unix-style paths. Make sure the paths are surrounded by quotes, too (e.g. +`'C:\path\to\whatever'`), else the shell won't understand the backslashes +correctly. + +There are a couple errors you might get here: - `Unable to lock project!`: This means that Ghidra isn't fully closed. Make sure you've completely closed every Ghidra window before running `delink.sh`. - `Script not found: DelinkProgram.java` and - `Invalid script: DelinkProgram.java`: This means that the Ghidra delinker - extension isn't properly installed. Ensure it's installed and enabled first. + `Invalid script: DelinkProgram.java`: This means that the either the Ghidra + delinker extension isn't properly installed, or you've somehow invoked the + script in a way that can't see the extension (e.g. installing Ghidra on + Windows and then invoking the script from WSL). Ensure it's installed and + enabled first, and that you're not running in some kind of environment + different from where you installed Ghidra. +- `java.lang.RuntimeException: Failed to export ...`: This means that the + delinker extension doesn't like something about what it was told to delink. + One known cause is duplicate symbol names. If you haven't modified + `objects.csv` or `symboltable.tsv`, let other people on the project know so + that they can look into fixing it. If all goes well, you'll see the message `Delinking complete!` at the end of the script's output, and the extracted object files will be in the