From f45ce702d250df76d411bec4fd254b6cdd20d8eb Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 21 Apr 2026 14:11:24 +0200 Subject: [PATCH] add abandoned ghidra path remapping script --- ghidra/scripts/RemapSourcePaths.java | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ghidra/scripts/RemapSourcePaths.java diff --git a/ghidra/scripts/RemapSourcePaths.java b/ghidra/scripts/RemapSourcePaths.java new file mode 100644 index 0000000..325f5d4 --- /dev/null +++ b/ghidra/scripts/RemapSourcePaths.java @@ -0,0 +1,36 @@ +import ghidra.program.database.sourcemap.UserDataPathTransformer; +import ghidra.program.model.sourcemap.SourcePathTransformer; + +// Remap: +// /build/source/core (libiwasm) +// /home/christoph/Notes/TU/MastersThesis/FailNix/build-sum2_repl_cored_late/module_host.c +public class RemapSourcePaths extends GhidraScript { + + @Override + protected void run() throws Exception { + String[] args = getScriptArgs(); + if (args.length < 2) { + throw new IllegalArgumentException( + "Missing file paths.\nUsage: RemapSourcePaths "); + } + + // https://ghidra.re/ghidra_docs/api/ghidra/program/model/sourcemap/SourcePathTransformer.html + SourcePathTransformer tx = UserDataPathTransformer.getPathTransformer(currentProgram); + + String oldIwasmDir = "/build/source/core"; + String newIwasmDir = args[0]; + + tx.addDirectoryTransform(oldIwasmDir, newIwasmDir); + println("Added transform:"); + println(" " + oldIwasmDir + " -> " + newIwasmDir); + + // TODO: What to do here? Need to know the build dir name... + String failNix = "/home/christoph/Notes/TU/MastersThesis/FailNix"; + String oldHostDir = failNix + "/build-.../module_host.c"; + String newHostDir = args[1]; + + tx.addDirectoryTransform(oldHostDir, newHostDir); + println("Added transform:"); + println(" " + oldHostDir + " -> " + newHostDir); + } +}