0

Is there a way to get the volatile and non-volatile registers from Ghidra's CompilerSpec? For instance, when I look into the ARM.cspec I get the following information:

<unaffected>
<register name="r4"/>
<register name="r5"/>
<register name="r6"/>
<register name="r7"/>
<register name="r8"/>
<register name="r9"/>
<register name="r10"/>
<register name="r11"/>
<register name="d8"/>
<register name="d9"/>
<register name="d10"/>
<register name="d11"/>
<register name="d12"/>
<register name="d13"/>
<register name="d14"/>
<register name="d15"/>
<register name="sp"/>
</unaffected>
<killedbycall>
<register name="r1"/>
<register name="d0"/>
<register name="d1"/>
<register name="d2"/>
<register name="d3"/>
<register name="d4"/>
<register name="d5"/>
<register name="d6"/>
<register name="d7"/>
</killedbycall>

However, I was only able to find an interface to get the input parameters for the individual calling conventions which are also listed in the same file using:

for(PrototypeModel model : program.getCompilerSpec().getCallingConventions()) {
    System.out.println(model.getName());
    for(VariableStorage storage : model.getPotentialInputRegisterStorage(program)) {
        System.out.printf("    Register: %s\n", storage.getRegister().toString());
    }
}

I would like to avoid having my own file which lists the information for all architectures when I can extract it directly from Ghidra.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.