It seems that Ghidra uses the information from currentProgram.getExecutablePath()
which takes the value from the options stored with the binary information inside the project:
Code snippet from ghidra.program.database.ProgramDB#getExecutablePath
:
@Override
public String getExecutablePath() {
String path = null;
Options pl = getOptions(PROGRAM_INFO);
path = pl.getString(EXECUTABLE_PATH, UNKNOWN);
return path == null ? UNKNOWN : path;
}
@Override
public void setExecutablePath(String path) {
Options pl = getOptions(PROGRAM_INFO);
pl.setString(EXECUTABLE_PATH, path);
changed = true;
}
To change this you should be able to simply use the corresponding setExecutablePath
method, e.g. by running
currentProgram.setExecutablePath("/new/path/to/binary.elf")
inside the Python REPL.