add abandoned ghidra path remapping script
This commit is contained in:
36
ghidra/scripts/RemapSourcePaths.java
Normal file
36
ghidra/scripts/RemapSourcePaths.java
Normal file
@ -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 <libiwasm> <host>");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user