Sleigh patches
The sleigh repository uses git am to apply a list of patches to a specific Ghidra base commit. These patches are mostly to make Ghidra's decompiler source code reusable as a library and suitable for packaging. You can find more information in sleigh/src/README.md.
Remill has a bunch of additional patches, which improve the semantics themselves (sleigh files). These are applied on top of the sleigh patches and specified in sleigh_ADDITIONAL_PATCHES.
To update the patches or the sleigh base commit, we need to get a cloned Ghidra source tree that only has the sleigh patches applied. From there we will apply the patches in this repository manually and recreate the patch folder.
- Go in
build/_deps/ghidrasource-srcand rungit statusto make sure you are in a clean state. You might need to rungit am --abortto abort the patching process if you had patch failures. - Modify remill's
CMakeLists.txtto setsleigh_ADDITIONAL_PATCHESto be empty and re-configure remill. This will apply just the patches of the sleigh project's tag we pinned. - Get the commit hash of the clean Ghidra patches with
git rev-parse HEADand note it as<base-commit>. - Apply the patches in
dependencies/sleigh_patches/one by one withgit am ../../../dependencies/sleigh_patches/0001-xyz.patch. If you get any errors, manually apply the patch (you can trygit apply ../../../dependencies/sleigh_patches/0001-xyz.patch) and thengit add .followed bygit am --continue. The goal is to create a commit for every patch. - Delete all the old patches:
rm dependencies/sleigh_patches/*.patch. - Recreate the patch list:
git format-patch remill-sleigh-7c6b742-base -o ../../../dependencies/sleigh_patches/. - Reconfigure remill's CMake to make sure everything applies correctly and then change
sleigh_ADDITIONAL_PATCHESback to include all of the patches independencies/sleigh_patches/.
Note: Sometimes you run into issues where git am cannot correctly apply all the patches. This is usually related to whitespace issues. Before exporting the patch list you can run git rebase <base-commit> --whitespace=fix to make sure everything is cleaned up correctly and ready to be applied.