NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.9k stars 5.89k forks source link

Fix PowerPC:BE:64 LQ instruction to support signed offsets #6827

Open v-p-b opened 3 months ago

v-p-b commented 3 months ago

Based on the Power ISA manual sign extended DQ<<4 is added to RA to get source EA.

I'm working on adding support for AS/400 programs to Ghidra. While my code is available in a dedicated repository, I'd like to see at least the Processor module improvements upstreamed. This PR is my first attempt to contribute code to Ghidra, so this is just a minimal change, and I'd appreciate any further feedback on how to improve the rest of the Processor module and maybe even getting the Loader/Analyzer exts to the project!

This PR can be tested with the following instruction (also present in the DEREF2.pgm shared here):

e1 1f ff b1 lq r8,-50(r31),0x01

This instruction doesn't decompile with the existing PowerPC:BE:64:A2-32addr language variant (which includes ppc_isa.sinc that defines LQ), but it correctly decompiles with this fix.