Code Monkey home page Code Monkey logo

sleigh's Introduction

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.

sleigh's People

Contributors

2over12 avatar alessandrogario avatar artemdinaburg avatar auto-updater[bot] avatar dependabot[bot] avatar ekilmer avatar mike-myers-tob avatar mrexodia avatar pgoodman avatar tetsuo-cpp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sleigh's Issues

Example `sleigh-lift` invocation no longer works

There seems to be a regression at 387f9b0 which has broken disassembly. I'll eyeball the SLEIGH changes that went into that release and see if I submit a patch to Ghidra.

Before:

tetsuo@Alexs-MacBook-Pro install % ./bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
0x00000000: SUB RSP,0xfc0

After:

tetsuo@Alexs-MacBook-Pro install % ./bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
0x00000000: DEC AX
0x00000001: DEC AX
0x00000002: DEC AX
0x00000003: DEC AX
0x00000004: DEC AX
0x00000005: DEC AX
0x00000006: DEC AX

kSleighSpecInstallDir filled in with relative path

In remill builds on latest sleigh (74838a3) the value for the sleighspecinstalldir is static const char *kSleighSpecInstallDir = "share/sleigh/specfiles";. This value causes searching for sla files to fail when the build directory has been deleted, which occurs in the Dockerfile for remill

Build documentation on Windows

In #85, I disabled support for building documentation on Windows because I couldn't figure out how to set up Doxygen properly.

If someone is interested in having documentation building supported in Windows, then a PR would be much appreciated.

Compiling on Windows

Hi team! Thanks for your work, it's really nice! Hope the Ghidra team accept your request and maintain themself a standalone sleigh version.

However, for the moment i'm trying to build it using your repo but without success on windows. When i run the command cmake --install build --prefix ./install it result in:

file INSTALL cannot find
"C:/Users/s0urc3/sleigh/build/Release/sla.lib": File exists"

Any idea wassup?

Write a script to check for new files

When new files are added to Sleigh, sometimes our weekly sync with Ghidra continues working fine and we don't notice. This leads us to having missing headers which we have to fix later down the track (#107).

We should write a script as part of our weekly sync that identifies new files and either adds them to the PR or fails loudly so we can manually fix it.

Add helper to locate SLA files

As per @pgoodman's comment at #9 (comment), we should look into a way of exposing a helper that finds SLA files in the SLEIGH installation that it belongs to. Ideally it should just look like this:

/*
* Returns a string containing the path to the .sla file for a given architecture.
* @param arch: The architecture for which we want to find a .sla file
* @return: An absolute path to the .sla file
* @throw std::invalid_argument: An unknown arch is provided.
*/
std::string FindSlaFile(const std::string& arch);

Add support for building on Windows

Funny enough, it looks like my Windows build system had bfd and libiberty headers and library dependencies in C:\Strawberry\c\include and C:\Strawberry\c\lib\ so these pre-requisites can be satisfied by installing Strawberry Perl.

Developers can choco install the packages for git cmake ninja doxygen.install graphviz etc and get everything else needed.

When building, though, we need to set the _WINDOWS and _WIN64 compile-time definitions, so that all the conditional compilation preprocessor statements in the Ghidra headers will work.

Publish a Release

We should aim to publish a release of pre-built binaries whenever Ghidra publishes a new stable release and whenever we feel like larger changes have happened in the packaging logic...

I'm not sure if there's a good way to keep some sort of semantic versioning scheme with both the packaging changes and the actual Ghidra changes, then again I'm not sure if upstream even keeps track of breaking changes in the C++ code

Use CMake Presets for CI and Dev builds

CMake Presets are a good way to encapsulate and reproduce CMake configuration, build, and test settings in a single file that can be used for CI and as a starting point for development builds.

CMake Presets also allow users to easily override compiler settings and flags without modification to the CMake file(s), which is useful if you want to enable/disable -Werror.

A good example of a CMake presets file can be found here https://github.com/friendlyanon/cmake-init-shared-static/blob/master/CMakePresets.json.

While presets files require a CMake version greater than 3.19, users and developers are encouraged to use the latest version of CMake for development and/or local builds, even if this project states CMake version 3.15 as the minimum supported.

Consistent CMake variable conventions

CMake doesn't exactly have an official convention for variable names or capitalization outside of what the docs say you will get, but there are auto-generated variable names that come from the same capitalization as used in the project(<name> ...) declaration, like _SOURCE_DIR, CMAKE_DISABLE_FIND_PACKAGE_, and others.

While the project is still young, I think we should refactor all cases of variables to use the same capitalization as used in the project(sleigh ...) declaration.

Sleigh-lifter will lift past the end of the provided bytes

We should probably check the length of the lifted instruction to make sure we arent reading bytes from the 0 fill

ie. ./extra-tools/sleigh-lift/sleigh-lift disassemble ARM7_le.sla 002C -p ./specfiles should not print:
0x00000000: andeq r2,r0,r0, lsl #0x18

and should probably present an error like "not enough bytes"

For users who are not aware of how fills work on the backend/context registers etc the current behavior is non-obvious

Add a `--version` argument

The binaries (sleigh-lift) should take a --version argument that outputs relevant version information; ideally we want:

  • Git commit hash of the build
  • Any ghidra component versions used

Build only a subset of components by default

The way the Makefiles in upstream are constructed require us to rebuild the same source files for each component with slightly different compile definitions. This isn't a problem per se, but it can be time consuming if another project wants to use CMake's ExternalProject command (rather than add_subdirectory, because ExternalProject gives a lot more control over the build environment for separate settings than the main project, etc.).

Professional CMake A Practical Guide, 10th ed. gives a good summary:

The ExternalProject moduleโ€™s main purpose is to enable downloading and building external projects that cannot be easily made part of the main project directly. The external project is added as its own separate child build, effectively isolated from the main project and treated more or less as a black box. This means it can be used to build projects for a different architecture, different build settings or even to build a project with a build system other than CMake. It can also be used to handle a project that defines targets or install components that clash with those of the main project.

I think the default, top-level build (cmake -B build -S .) should include all of the same targets we do now, but there should be options that have default values dependent on CMake's PROJECT_IS_TOP_LEVEL variable. All target options are ON when the project is top-level, but it should be possible to turn them off as well. The following are a list of variables that could be used for target groups (discussion is appreciated for use-cases I might not have thought about):

  • sleigh_BUILD_SLA_FILES - Toggle for compiling sleigh files (implies the compiler is built)
    • Use-case: Someone doesn't want to use these sla files
  • sleigh_BUILD_SLA_COMPONENTS - Toggle for all slaspec components (compiler, library, slafiles); implies sleigh_BUILD_SLA_FILES
    • Use-case: Someone wants to compile their own slaspec files and also use the library to do stuff with them (could turn off sleigh_BUILD_SLA_FILES manually if they don't want/need our sla files
  • sleigh_BUILD_DECOMPILER_COMPONENTS - Toggle for building all decompiler components (decompiler, library)
  • sleigh_BUILD_EXTRA_TOOLS - Toggle for building and including all other tools, like the lifter

The above variables will also affect how we handle the installation procedure. It would also make sense to use CMake's install COMPONENTS to let users know which components are installed or not for a configured distribution.


Final note, the releases on this repo will be fully-featured. This issue is to mainly help people who want/need to build from source and prevent time-consuming target building for targets they don't need.

Tests failing on Linux

System: Endeavour os, kernel 5.18.11-arch1-1
Cmake version: 3.23.2
Commit: 5ee2f2c

Following steps at Build section

git clone https://github.com/lifting-bits/sleigh.git
cd sleigh
# Configure CMake
cmake -B build -S .
# Build SLEIGH
cmake --build build -j

results in compilation failure

Expected behavior:
Tests passed without error messages and failures
Actual behavior:
Tests failing with the following message:

Consolidate compiler generated dependencies of target sla
[ 41%] Built target sla
/usr/include/c++/12.1.0/bits/stl_vector.h:1206: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::front() [with _Tp = cmGccStyleDependency; _Alloc = std::allocator<cmGccStyleDependency>; reference = cmGccStyleDependency&]: Assertion 'this->empty()' failed.
make[2]: *** [CMakeFiles/decomp.dir/build.make:1421: CMakeFiles/decomp.dir/depend] Aborted (core dumped)
make[1]: *** [CMakeFiles/Makefile2:1217: CMakeFiles/decomp.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 41%] Linking CXX executable ghidra_test_dbg
[ 55%] Built target ghidra_test_dbg
make: *** [Makefile:146: all] Error 2

However, I am not expirienced user of cmake, so maybe there is some error from my side

Expose a CMake slaspec compilation function

This project should expose and install a function to compile an arbitrary slaspec file.

This would be similar in spirit to how the FindProtobuf.cmake file exposes their codegen capabilities in CMake.

This is an essential feature for downstream users to compile their own custom/patched slaspec files.

Fortunately, there is already some rough function-like capability to compile a given sleigh file here

sleigh/CMakeLists.txt

Lines 492 to 539 in 31ec99d

foreach(spec_file ${spec_file_list})
# Get 'mx51'
cmake_path(GET spec_file STEM LAST_ONLY spec_name)
# Get '<ghidra_source_prefix>/Ghidra/Processors/8051/data/languages'
cmake_path(GET spec_file PARENT_PATH spec_dir)
# Get '8051/data/languages'
cmake_path(RELATIVE_PATH spec_dir
BASE_DIRECTORY "${ghidrasource_SOURCE_DIR}/${spec_files_dir_prefix}"
OUTPUT_VARIABLE spec_proc_dir
)
set(spec_build_log "${spec_files_build_log_dir}/${spec_name}_build.log")
# Combine back again for the build directory output like
# '<build_prefix>/Ghidra/Processors/8051/data/languages'
set(spec_out_dir "${spec_files_root_dir}/${spec_proc_dir}")
# '<build_prefix>/Ghidra/Processors/8051/data/languages/mx51.sla'
set(spec_out "${spec_out_dir}/${spec_name}.sla")
# Copy all other files from the slaspec source directory:
# '<ghidra_source_prefix>/Ghidra/Processors/8051/data/languages'
# TODO: This only copies the directory once, so you will need to remove the whole directory if you update any of
# the other files, like '*.cspec' or '*.ldef' files
# CMake only guarantees update monitoring for file listed explicitly
add_custom_command(
OUTPUT "${spec_out_dir}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${spec_dir}" "${spec_out_dir}"
)
# Compile the sla file
add_custom_command(
OUTPUT "${spec_out}"
DEPENDS "${spec_file}" "${spec_out_dir}" "${spec_files_build_log_dir}"
COMMAND "$<TARGET_FILE:sleigh::sleigh_opt>" ${spec_file} "${spec_out}" > ${spec_build_log} 2>&1
WORKING_DIRECTORY "${spec_dir}"
COMMENT "sleigh: Compiling the ${spec_name} spec file (${spec_build_log})"
BYPRODUCTS ${spec_build_log}
VERBATIM
)
string(REPLACE "." "_" spec_target_name ${spec_name})
set(spec_target "sleigh_spec_${spec_target_name}")
add_custom_target(${spec_target}
DEPENDS ${spec_out}
)
list(APPEND spec_targets ${spec_target})
list(APPEND spec_files ${spec_out})
endforeach()

I think a standalone function should live in a cmake/utils.cmake or something (as long as it's separate from a CMakeLists.txt), which is then installed into the directory alongside the project config file.

Publish built documentation for stable releases

It would be nice to publish the doxygen-built documentation to somewhere public like GitHub Pages using the gh-pages branch. This should initially happen for at least every stable release.

Headers are getting polluted by `using namespace std`

The ghidra source code is riddled with using namespace std in various header files. This is bad practice and it would be nice if this could be patched away. It causes all kinds of confusing issues (one notable one being with std::byte and byte from some Windows COM headers).

Ideally these occurrences would be patched out, but obviously the cost is high because you'd have to maintain an extensive patch set...

Breaking Change: Use `ghidra` instead of `sleigh` for header file directory

Now that upstream has added namespace ghidra to the source files, it probably makes more sense to place the header files in a layout like include/ghidra/*.hh.

This layout is still unofficial because upstream does not separate the headers.

This would be a breaking change because downstream users would be required to change the header include paths from include <sleigh/header.hh> to include <ghidra/header.hh>.

Include test to verify patch that removes 'using namespace std' from headers

A patch was generated (#143) to remove the using namespace std from the sleigh headers due to issues with compilation on Windows (#139).

This repo should include a test that will detect (in some way) whether the rebased patch continues to work.

Compiling the project and running the tests is a good indication that the patch continues to work, but if a new header file is added and includes a using namespace std; that we forget to remove, then we could have regressions.

It's a bit unclear to me what the test would look like, but maybe somebody has a better idea.

Add macOS to CI

At the moment, we're only building on Ubuntu in our CI. We should add macOS builds once the BFD and Iberty dependencies have been removed.

Introduce thread-safe wrapper API

At the moment, loading spec files on different threads is unsafe because of how the XML parsing is implemented. We should consider adding a wrapper API in the support lib that protects this behind some kind of locking mechanism.

Windows tests fail

In #85 support for Windows was added to CI, however there are failing tests that I was unable to figure out. I'm not sure if it's a Windows environment thing when running the tests or if there's a bug with the Windows version of sleigh.

Anyone who wants to take a deeper dive into the failing tests is encouraged to do so and either write up their findings on this issue or create a PR with any fixes!

In the meantime, I am going to gate PRs around requiring the Mac and Linux CI to fully pass before merging, which should help to keep track of the tests we expect to pass while ignoring the Windows tests (although the Windows build step will have to be checked manually ๐Ÿ˜ž due to GitHub Actions not supporting known failure checks).

Support both stable and latest (pinned commit) Ghidra

It would be nice to support not only the latest stable version of Ghidra but also secondary support for building Ghidra from the latest-ish commit on their master branch. This could be implemented through a CMake cache variable to set a stable or HEAD Ghidra release type (i.e. sleigh_GHIDRA_RELEASE_TYPE).

While this would add a few conditional constructs in the CMake and potentially make it harder to read, I think it would be worth it to provide support for these two Ghidra release types. The conditionals would check the value of sleigh_GHIDRA_RELEASE_TYPE and do the right thing, with HEAD value as the moving target.

I can see this being implemented using CMake's FetchContent module. The FetchContent module provides a nice way to pull the Ghidra repo, check out a commit, apply optional patches, and even use your own local copy of a Ghidra source repo for full control over what you are building. This allows for more flexible development of patches for upstream contribution. You can use your own Ghidra source directory during CMake configuration (with a clean build directory) by setting both

-Dsleigh_GHIDRA_RELEASE_TYPE=HEAD -DFETCHCONTENT_SOURCE_DIR_GHIDRASOURCE=<path to your>/ghidra

I've taken a stab at implementing the source code fetching in a cmake/setup-ghidra-source.cmake file, which can be called in the top-level CMakeLists.txt.

I am happy to hook this all up with what exists right now, if you think this is a good approach


CMakeLists.txt

cmake_minimum_required(VERSION 3.21)

# Sets "library_root" variable for decompiler cpp root directory
# Use "ghidrasource_SOURCE_DIR" variable for Ghidra repo root
include(cmake/setup-ghidra-source.cmake)

project(
    sleigh
    VERSION ${sleigh_GHIDRA_VERSION}
    DESCRIPTION "Unofficial CMake build for Ghidra SLEIGH Decompiler"
    HOMEPAGE_URL "https://github.com/lifting-bits/sleigh"
    LANGUAGES CXX
)
...

cmake/setup-ghidra-source.cmake

# ---- Setup Ghidra Source code ----

# Set up Ghidra repo human-readable version settings
set(sleigh_GHIDRA_RELEASE_TYPE "stable" CACHE
  STRING "Ghidra release type to use. Make sure sleigh_GHIDRA_COMMIT is the correct corresponding commit. 'HEAD' is used for active development purposes."
)
# This is just helper for CMake UIs. CMake does not enforce that the value matches one of those listed.
set_property(CACHE sleigh_GHIDRA_RELEASE_TYPE PROPERTY STRINGS "stable" "HEAD")

# **** Setup pinned git info ****

# Ghidra pinned stable version commit
set(ghidra_version "10.0.4")
set(ghidra_git_tag "5b07797cb859d8801ca3a1e08bda1321ca3ce002")
# pinned stable patches list
set(ghidra_patches "")

# Ghidra pinned commits used for pinning last known working HEAD commit
if("${sleigh_GHIDRA_RELEASE_TYPE}" STREQUAL HEAD)
  # TODO: Try to remember to look at Ghidra/application.properties
  # TODO: CMake only likes numeric characters in the version string....
  set(ghidra_version "10.1")
  set(ghidra_git_tag "55b8fcf7d4aeaca37ffb5c947340915d69c84224")
  set(ghidra_patches
    PATCH_COMMAND git am --ignore-space-change --ignore-whitespace --no-gpg-sign
      "${CMAKE_CURRENT_SOURCE_DIR}/patches/HEAD/0001-Fix-arg-parsing-in-sleigh-C-test-runner.patch"
  )
endif()

# For use in the CMake `project` command to set version
set(sleigh_GHIDRA_VERSION "${ghidra_version}" CACHE
  STRING "Numeric Ghidra version corresponding to sleigh_GHIDRA_RELEASE_TYPE and sleigh_GHIDRA_COMMIT. This is used during packaging"
)

set(sleigh_GHIDRA_COMMIT "${ghidra_git_tag}" CACHE
  STRING "Ghidra repo commit to use/checkout. Ensure this correct with respect to sleigh_GHIDRA_VERSION and sleigh_GHIDRA_RELEASE_TYPE."
)
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)

message(STATUS "Using Ghidra version ${sleigh_GHIDRA_VERSION} at commit ${ghidra_short_commit}")

include(FetchContent)
# Write out source directory with identifiable version info
FetchContent_Declare(GhidraSource
    GIT_REPOSITORY https://github.com/NationalSecurityAgency/ghidra
    GIT_TAG "${sleigh_GHIDRA_COMMIT}"
    GIT_PROGRESS TRUE
    SOURCE_DIR "${CMAKE_SOURCE_DIR}/source_${sleigh_GHIDRA_VERSION}_${ghidra_short_commit}"
    ${ghidra_patches}
)
FetchContent_MakeAvailable(GhidraSource)

message(STATUS "Ghidra source located at '${ghidrasource_SOURCE_DIR}'")

# Sanity check on Ghidra source code checkout
set(library_root "${ghidrasource_SOURCE_DIR}/Ghidra/Features/Decompiler/src/decompile/cpp")
if(NOT EXISTS "${library_root}/sleigh.hh")
  message(FATAL_ERROR "The Ghidra source directory has not been initialized correctly. Could not find '${library_root}'")
endif()

Cron job to regularly check and bump for updates to Ghidra HEAD

Related to changes made in #15

I think some sort of bot or GitHub Action would be the best way to keep track of new commits made to Ghidra's default branch (master). Sort of like Dependabot but we would have to script it ourselves. I see the workflow like:

  1. Create a weekly GitHub Action cron job
  2. Grab the latest commit from default development Ghidra branch (master)
  3. Run some checks for updates and make the necessary source code changes (see below for what should be included)
  4. If changes, create new branch, commit and push as new PR to GitHub
  5. Let CI run on created PR
  6. Wait for manual approval/changes

Checks for "updates":

  • New commit to HEAD of Ghidra master branch and update the src/setup-ghidra-source.cmake file/line
  • Automatically update the listing of slaspec files with some find . -name "*.slaspec" magic
  • Check and report in PR details if any files have been added to some monitored directories (removed files will almost certainly cause compilation errors and be caught by CI)

The cron-job action should ideally be runnable locally as well.

Originally discussed by @ekilmer in #15 (comment)

Don't install headers that aren't part of SLEIGH core

At the moment, this CMake wrapper only builds the core part of SLEIGH but omits some optional components. However, the installation includes headers for those optional parts.

So if an application using SLEIGH tries to use an optional component, it will compile fine since the header exists in the installation but will hit an error at linking time. To solve this, we should only install the headers that we can use.

The relevant part of the CMake configuration is here:

FILES_MATCHING PATTERN "*.h*"

Add example program

Add an executable under example/ showing how to get up and running with SLEIGH's API. Ideally we'd have something that takes a binary and has an option to print either Ghidra P-Code or the disassembled instructions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.