-
Notifications
You must be signed in to change notification settings - Fork 3
ghidra: automate architecture detection #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
LIT in CI appears to fail, which is odd, since it worked locally - I shall try it locally again directly and then also with |
cannot reproduce the failure locally even with release / ci builds, trying to rerun jobs |
for whatever reason, looks like when we run
but on the bright side,
c.f. https://github.com/lifting-bits/patchestry/actions/runs/15158732553/job/42630693519?pr=86#step:8:103 |
… things we'll encounter
…g to match other LIT tests
586a5f2
to
ceb126d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Have a comment to fix identation.
… since it looks a little funky to just check section headers for one type of arch
This is often done manually in RE. Ghidra can make a guess, but it isn't always correct, i.e., its guess doesn't handle all Bloodlight addresses correctly. This PR improves on the guess of Ghidra in the fashion one might make such a guess manually, using
readelf
andfile
. The goal of this work is to improve the accuracy of the p-code we create, therefore the accuracy of the C we produce and patch.Bloodlight
What
file
thinks about Bloodlight:firmwares/bloodlight-firmware.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
What
readelf -A
shows for Bloodlight:What
readelf -S
shows for Bloodlight:What we got for Bloodlight by default from Ghidra was:
ARM:LE:32:v8:default
What the guesser function provides to Ghidra instead:
ARM:LE:32:Cortex
PulseOx
What
file
thinks about PulseOx:firmwares/pulseox-firmware.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
What
readelf -A
shows for PulseOx:What
readelf -S
shows for PulseOx:What we got for PulseOx by default from Ghidra:
ARM:LE:32:v8:default
What the guesser function instead provides to Ghidra:
ARM:LE:32:Cortex
One can also test this change with the LIT tests after rebuilding the headless decomp container to use the new entrypoint function: