Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
SLEIGH: assembly template not following the usual mnemonic + operands #315
I'm trying to add support for the Qualcomm's Hexagon V5x architecture to Ghidra.
However, I am facing 1 non-blocking and 1 blocking issue:
Because Ghidra strips whitespace from the beginning of the display section, I end up with:
I've been using
Is there any solution to these issues? If not, I'm guessing the Sleigh language has to be modified.
For reference, here is my current code:
I dug a little bit into Ghidra's source code and I am now certain that fixing the second issue requires major changes to the current architecture. Let me present my findings if anyone is interested:
So now I am left wondering if I should make any modifications at all. I definitively could us some advice from the main developers on wether or not it is a good idea to implement those changes, and if they would be willing to merge these hypothetical changes in the next release. Or to make them themselves.
Nice work there!
I think it would be nice to make the changes necessary or at least provide a patch for them.
How you are used to a syntax makes a lot when it comes to how fast one can get a grip of what's going on when it comes to assembler; not in an all cases but in the common case I've encountered this all over with mediocre REers (you should know who you are).
I've been giving it some more thought. Here's what I'm currently thinking:
Can you say, for each of these instructions, which part is the mnemonic? I know I can't.
Because Sleigh only supports templates in a simple shape (
This would make the
My current idea is to programmatically override the class representing a disassembled instruction so that it returns different mnemonic / operands values when used for the listing display.
I don't know yet at which level this should be performed:
I'm also unsure how to do it from a processor module: using Java reflection maybe?
Then we could either have the mnemonic field display an empty string and move everything into the operands field, or we could create a new special field
This still leaves the issue of the
Looking at the file that defines the properties of a processor specification, I've found:
It looks like the first one can be useful to override the rendering of the instructions.
Update: I've added a
Now I still need to override the instruction template, but I'm more confident that I was this morning.
I have kinda been able to do what I wanted by defining 3 custom fields: Hexagon Prefix / Hexagon Suffix to display the
I'm not a big fan of my solution because the user is forced to add these 3 custom fields, and worse, the remove the existing Mnemonic / Operands fields. These fields are also used to display data, e.g. Mnemonic might be
I took a look at the instruction manual for this processor. The processor is quite a beast, and the format of the instructions are somewhat unique.
Thank you for your answer @emteere, it is very much appreciated!
If you ever got time to work on this, please keep me updated. In the meantime, I might continue to work on this, but I should definitively open-source what I have already done (even though it is not pretty).