Closed abelbriggs1 closed 2 months ago
I've tested it and it looks good. Thanks for finding this, I had no idea upstream had fixed this even before the first public release.
Maybe change the name that shows up in the GUI to something like "MIPS-R5900 Unaligned Load/Store Fixer" so people know it's the version from the extension.
The standard implementations of memcpy/strcpy were often optimized to chains of paired unaligned
ldr
/sdr
instructions. The resulting pcode is extremely ugly and impossible to read, so upstream Ghidra implemented aMipsPreAnalyzer
which would detect paired instructions and combine them into a single 4-byte/8-byte memory operation.This PR adds Ghidra's
MipsPreAnalyzer
to the repository which will work if the analyzed CPU isMIPS-R5900
.Inlined
memcpy
Before:![memcpy_before_fix](https://github.com/chaoticgd/ghidra-emotionengine-reloaded/assets/27463243/80d78c41-80c7-4247-9139-a8e01b65700b)
After:![memcpy_after_fix](https://github.com/chaoticgd/ghidra-emotionengine-reloaded/assets/27463243/21b04bdb-f595-4485-8128-f98c68d71e7d)
Inlined
strcpy
Before:![strcpy_before_fix](https://github.com/chaoticgd/ghidra-emotionengine-reloaded/assets/27463243/c433710d-35aa-428b-9586-0cfa9c0e371d)
After:![strcpy_after_fix](https://github.com/chaoticgd/ghidra-emotionengine-reloaded/assets/27463243/093a44e9-5e65-44a9-b75d-6d4a370d447f)
The resulting code is still a bit annoying in the case of strcpy, but it's still much more usable.