Bump Ghidra HEAD commit c58647b7d Changed files: ``` M Ghidra/Processors/AARCH64/data/languages/AARCH64.cspec M Ghidra/Processors/AARCH64/data/languages/AARCH64_win.cspec M Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc M Ghidra/Processors/ARM/certification.manifest M Ghidra/Processors/ARM/data/languages/ARM.ldefs M Ghidra/Processors/ARM/data/languages/ARM.sinc M Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc A Ghidra/Processors/ARM/data/languages/ARM_apcs.cspec M Ghidra/Processors/ARM/data/languages/ARMneon.sinc M Ghidra/Processors/x86/data/languages/ia.sinc M Ghidra/Processors/x86/data/languages/x86.ldefs ``` Commit details: ``` [Commit 1/10] Hash: 28ca53cb343e655aa4515ee041dbd93004833d44 Date: 2025-05-07 17:41:41 +0000 Message: GP-4923: cspec, ldefs, opinion file support for ARM apcs abi Files changed: M Ghidra/Processors/ARM/certification.manifest M Ghidra/Processors/ARM/data/languages/ARM.ldefs A Ghidra/Processors/ARM/data/languages/ARM_apcs.cspec [Commit 2/10] Hash: b0b1db632c40a90694c0a77bfcded58a6f141847 Date: 2025-05-07 17:40:54 +0000 Message: GP-5192: Fix aarch64 cspec to match aapcs calling convention Files changed: M Ghidra/Processors/AARCH64/data/languages/AARCH64.cspec M Ghidra/Processors/AARCH64/data/languages/AARCH64_win.cspec [Commit 3/10] Hash: a9e193d811dd27ddb9d6fc8e5368ea66388f57a5 Date: 2025-05-07 13:51:22 +0000 Message: GP-5638 update language verions Files changed: M Ghidra/Processors/x86/data/languages/x86.ldefs [Commit 4/10] Hash: ce839ce9fcabd67308d5c669eaf8f0700c686fa0 Date: 2024-05-30 17:41:37 +0930 Message: x86: PUSH FS/GS long mode improvements. Files changed: M Ghidra/Processors/x86/data/languages/ia.sinc [Commit 5/10] Hash: a917cc0345df88aa01efdecba97324f82a7d1f11 Date: 2025-04-11 14:56:38 +0000 Message: GP-5587: Corrected parsing of AARCH64 dsb instruction Files changed: M Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc [Commit 6/10] Hash: 7413204896f07a68f3c7c68cd4568801dafbd4ae Date: 2025-03-10 16:16:04 +0000 Message: GP-5469: Added additional arm VMRS/VMSR instruction variants Files changed: M Ghidra/Processors/ARM/data/languages/ARM.sinc M Ghidra/Processors/ARM/data/languages/ARMneon.sinc [Commit 7/10] Hash: e6b326700c140ca0279c9fd31a59374941dfd721 Date: 2025-01-16 20:13:39 +0000 Message: GP-4731: Fixed decode for mrs Files changed: M Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc [Commit 8/10] Hash: 0c43ccb360fdb3815ab6c549107e2de65a7866b8 Date: 2024-12-08 18:52:24 +0000 Message: wrap stack limit instruction decoders in ifdef block Files changed: M Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc [Commit 9/10] Hash: bb39e4398be04f4f1762e68983cc972f1b9605a7 Date: 2024-12-08 18:49:34 +0000 Message: define stack limit registers for armv8-m Files changed: M Ghidra/Processors/ARM/data/languages/ARM.sinc [Commit 10/10] Hash: 220763c40f947e170d4892692539e7214fef081f Date: 2023-04-24 12:25:49 +0200 Message: instruction decoding for armv8 stack pointer limit registers Files changed: M Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc ```
Sleigh Library
Sleigh is a language used to describe the semantics of instruction sets of general-purpose microprocessors, with enough detail to facilitate the reverse engineering of software compiled for these architectures. It is part of the Ghidra reverse engineering platform and underpins two of its major components: its disassembly and decompilation engines.
This repository provides a CMake-based build project for Sleigh so that it can be built and packaged as a standalone library and be reused in projects other than Ghidra.
Supported Platforms
| Name | Support |
|---|---|
| Linux | Yes |
| macOS | Yes |
| Windows | Yes |
Dependencies and Prerequisites
Required
| Name | Version | Linux Package to Install | macOS Homebrew Package to Install |
|---|---|---|---|
| (HEAD builds) zlib | Recent | zlib1g-dev | zlib |
| Git | Latest | git | N/A |
| CMake | 3.18+ | cmake | cmake |
NOTE: This CMake project pulls the Ghidra source code from the internet during configuration. See the note on Ghidra source code section for more details.
Optional
For building documentation:
| Name | Version | Linux Package to Install | macOS Homebrew Package to Install |
|---|---|---|---|
| Doxygen | Latest | doxygen | doxygen |
| GraphViz | Latest | graphviz | graphviz |
Build and Install the Sleigh Library
# Clone this repository (CMake project for sleigh)
git clone https://github.com/lifting-bits/sleigh.git
cd sleigh
# Configure CMake
cmake -B build -S .
# Build Sleigh
cmake --build build --parallel 8
# Install Sleigh
cmake --install build --prefix ./install
Note on Ghidra source code
The Ghidra source code is not actually included in this git repo, and by default, CMake will automatically pull a stable version from the internet for you.
Please see src/README.md for more information on how to customize which Ghidra source code commit will be used/compiled, including specifying your own local copy of the Ghidra source.
Packaging
The CMake configuration also supports building packages for Sleigh.
For example:
# Package Sleigh
cmake --build build --target package
API Usage
An example program called sleigh-lift has been included to demonstrate how to use the Sleigh API. It takes a hexadecimal string of bytes and can disassemble it or lift it to p-code. The program can be invoked as follows, where the action argument must be either disassemble or pcode:
sleigh-lift [action] [sla_file] [bytes] [-a address] [-p root_sla_dir] [-s pspec_file]
For example, to disassemble the following byte string:
$ sleigh-lift disassemble x86-64.sla 4881ecc00f0000
0x00000000: SUB RSP,0xfc0
And to lift it to p-code:
$ sleigh-lift pcode x86-64.sla 4881ecc00f0000
(register,0x200,1) = INT_LESS (register,0x20,8) (const,0xfc0,8)
(register,0x20b,1) = INT_SBORROW (register,0x20,8) (const,0xfc0,8)
(register,0x20,8) = INT_SUB (register,0x20,8) (const,0xfc0,8)
(register,0x207,1) = INT_SLESS (register,0x20,8) (const,0x0,8)
(register,0x206,1) = INT_EQUAL (register,0x20,8) (const,0x0,8)
(unique,0x12c00,8) = INT_AND (register,0x20,8) (const,0xff,8)
(unique,0x12c80,1) = POPCOUNT (unique,0x12c00,8)
(unique,0x12d00,1) = INT_AND (unique,0x12c80,1) (const,0x1,1)
(register,0x202,1) = INT_EQUAL (unique,0x12d00,1) (const,0x0,1)
If you do not want to build sleigh-lift, you must set the CMake variable sleigh_BUILD_EXTRATOOLS option to OFF during CMake configuration.
Helpers
This repository contains a helper not part of Sleigh/Ghidra, which you can find in the support directory. It has the following signature and can help the user find the location of a given spec file on the system:
std::optional<std::filesystem::path>
FindSpecFile(std::string_view file_name,
const std::vector<std::filesystem::path> &search_paths =
gDefaultSearchPaths);
The sleigh::FindSpecFile function will search the paths provided by the user via the search_paths argument for a spec file with the name file_name. The default argument for search_paths is sleigh::gDefaultSearchPaths which contains the install/build directories generated during CMake configuration and a set of common installation locations.
If you do not want to build the helpers, you must set the CMake variable sleigh_BUILD_SUPPORT option to OFF during CMake configuration.
Integration as a Dependency
An installation of Sleigh provides a CMake interface that you can use when building your project.
You can find an example of how to use the CMake package config file in the find_package example.
We also provide a CMake helper function sleigh_compile to compile your .slaspec files using a sleigh compiler.
You can find a more complex CMake example with compiling Sleigh specifications in the example directory, which uses the upstream-provided sleigh example source code.
Lastly, you can locate the installed compiled sleigh files through the CMake variable sleigh_INSTALL_SPECDIR, which is an absolute path to the root directory for the compiled sleigh files---you should manually inspect this to know what to expect.
Referencing the CMake config file and specfiles CMake file is also suggested for learning more about the exposed CMake variables and modules.
License
See the LICENSE file.