ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Add support for PowerPC COFF Relocations

Open rndtrash opened this issue 1 year ago • 10 comments

Windows NT 4.0 for PowerPC uses COFF for the bootloader. Vanilla Ghidra 10.4 doesn't want to open these executables without the PPC relocation handler, even though these executables don't even have any relocations.

This code is based on the x86_32 COFF relocation handler and the official Microsoft docs.

VENEER.EXE (PPC default 32-bit LE): Снимок экрана от 2023-11-17 07-25-08

rndtrash avatar Nov 17 '23 04:11 rndtrash

Hello. If possible, can you attach your test binary?

ryanmkurtz avatar Nov 17 '23 20:11 ryanmkurtz

Hello. If possible, can you attach your test binary?

Sure, here are a couple of files that I used for testing. Both are PowerPC, default, 32-bit, Little-endian.

SETUPLDR.zip VENEER.zip

rndtrash avatar Nov 17 '23 23:11 rndtrash

I am not reproducing the issue of Ghidra 10.4 not being to import these files. I am getting the error that there is a missing relocation handler, but the import succeeds and I am able to open/analyze. Was that not your experience?

ryanmkurtz avatar Nov 20 '23 22:11 ryanmkurtz

Oh, that's embarrassing. I was double-clicking on the blue part of the line, and it didn't open the file. Clicking just on the label works. Sorry for wasting your time on that. ☹️ image

Still, this red message looks ominous, so I guess my commit is not that useless after all. 😄 image

rndtrash avatar Nov 20 '23 23:11 rndtrash

Yes, not useless...I just wish we had a binary to test the 2 relocations you implemented.

ryanmkurtz avatar Nov 20 '23 23:11 ryanmkurtz

Additionally, testing these files has inspired me to make some quality of life improvements to the CoffLoader. I am going to mark up the COFF header, and at least detect that it's a PowerPC processor to greatly reduce the number of processors you have to filter out to find the right variant. I will take your relocation file, but I might remove those 2 implementations if i don't feel confident in them without testing them.

ryanmkurtz avatar Nov 21 '23 13:11 ryanmkurtz

That's great! I'll look for a proper PowerPC COFF executable.

rndtrash avatar Nov 21 '23 14:11 rndtrash

Ok, i'll wait to hear back from you before I decide on your relocation implementations.

ryanmkurtz avatar Nov 21 '23 15:11 ryanmkurtz

@rndtrash Any luck finding samples?

ryanmkurtz avatar Dec 05 '23 16:12 ryanmkurtz

@rndtrash Any luck finding samples?

I did not find a sample yet, but I have some suspicions, it looks like Visual C++ for Power PC might generate a COFF object.

rndtrash avatar Dec 06 '23 19:12 rndtrash

Oh, did you find a sample?😮

rndtrash avatar Jan 04 '24 16:01 rndtrash

No, i just removed those 2 implementations until one can be found.

ryanmkurtz avatar Jan 04 '24 17:01 ryanmkurtz