Ghidra: How to get Unaffected and Killedbycall Register Lists from cspec file

Created on 12 Oct 2020  路  1Comment  路  Source: NationalSecurityAgency/ghidra

I'm looking for a way to extract the register lists for "unaffected" and "killedbycall" registers from the language's corresponding cspec file. I was looking through the API docs for CompilerSpec and Language related interfaces but was only able to find the list of parameter registers for each calling convention via the PrototypeModel.
I also saw that the SleighLanguageDescription class offers a function to get the cspec file. However, I'd like to avoid having to parse the XML file.
Is there a function in the API that I may have overlooked?

Below is an example for the ARM compiler spec:

<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>

Most helpful comment

Unfortunately, we do not currently parse that portion of the PrototypeModel into the Java API - although we probably should. I will have to defer to @caheckman on this.

>All comments

Unfortunately, we do not currently parse that portion of the PrototypeModel into the Java API - although we probably should. I will have to defer to @caheckman on this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chibicitiberiu picture chibicitiberiu  路  3Comments

Merculous picture Merculous  路  3Comments

huettenhain picture huettenhain  路  3Comments

forkoz picture forkoz  路  3Comments

pd0wm picture pd0wm  路  3Comments