mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Compare commits
134 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf13fdebba | |||
| a49bbcc9cf | |||
| 1f41ff02e6 | |||
| 060f42d28c | |||
| eadedecf28 | |||
| 7807d6619a | |||
| 443cfcfdc7 | |||
| d888cdd5ea | |||
| 7a92039e1a | |||
| 4af948df00 | |||
| 95b848e8ed | |||
| 8e27d6ef0a | |||
| 9cc6adc272 | |||
| b763518f2f | |||
| a0a8aa27c0 | |||
| 3efc7415f8 | |||
| 45dc2a0dbb | |||
| b9eef57dee | |||
| f9c852bc57 | |||
| 3e96d296e0 | |||
| 9d4d450551 | |||
| 184fabc5aa | |||
| 4cedffc104 | |||
| 873108dd0e | |||
| 4ddd7f2f89 | |||
| 00f42b7ef7 | |||
| 31868c9d70 | |||
| a96b7fdcc6 | |||
| 78ed150957 | |||
| bc2f60c4b8 | |||
| 85a209708f | |||
| 6f193278c1 | |||
| df49d10291 | |||
| d2f443e358 | |||
| b871c4a6b8 | |||
| 58f4812a02 | |||
| 9a983d5a01 | |||
| fbec9dee2b | |||
| aeea2f6d2e | |||
| e83ec16d28 | |||
| 52c4f0db49 | |||
| ab92d51452 | |||
| 5de8b6c8d6 | |||
| 91ab01ad36 | |||
| db074738f1 | |||
| ca9534df0c | |||
| 2e03227e87 | |||
| bcb4ff6f4a | |||
| ac55146b2c | |||
| 35fbbf873e | |||
| 014530d317 | |||
| 4d8bdb54a3 | |||
| 364b5e4ff9 | |||
| 4519d754ab | |||
| 6db8a80488 | |||
| 39f087356c | |||
| 0c5929b716 | |||
| 84a582a33c | |||
| d8ce6443bf | |||
| ae03ceb39c | |||
| 39d6587cf9 | |||
| 2bb6cfe47b | |||
| c3a84c541a | |||
| 45e124cdab | |||
| e4a5f4326c | |||
| 9cacf73c09 | |||
| c25484c07a | |||
| 4b7000b597 | |||
| dc79090c83 | |||
| 2d65648571 | |||
| 9650669dc3 | |||
| 8a595daf70 | |||
| 69e080e45a | |||
| 4110ce82e0 | |||
| 1464c57bad | |||
| bddd3b2342 | |||
| 5e84d25f0e | |||
| 9ebd0d7dbb | |||
| 92470fe795 | |||
| 39c1230211 | |||
| ebaea7183a | |||
| 95e45d8dd9 | |||
| f05a833db4 | |||
| 231a28b524 | |||
| 33ac2ef4f6 | |||
| 34a699c3bd | |||
| 05e1de0a8c | |||
| 24b9034914 | |||
| f2323af0ee | |||
| c3908f6d90 | |||
| 6924bbce83 | |||
| 1c23eba9ea | |||
| 0353b200d8 | |||
| 1dcdea8701 | |||
| 76e5cb4aca | |||
| 09ba8106d6 | |||
| aa46946172 | |||
| 6e0feed91c | |||
| acabb5ffc5 | |||
| 4becc755e9 | |||
| a1a03dbd26 | |||
| 403275e36c | |||
| 98158b7ebb | |||
| e6f6d4398f | |||
| 81a04f2e1c | |||
| a0345f9df2 | |||
| 0c3b79aa33 | |||
| b4f479a86f | |||
| ee82a39842 | |||
| 71870b0bcd | |||
| b2cd7abc2e | |||
| 40d91fd61b | |||
| 67c695f263 | |||
| c4cab14295 | |||
| e46879c87f | |||
| 5d9f0a1862 | |||
| f9bbbbcdb0 | |||
| cfa08a5f9c | |||
| 7702679f9e | |||
| 8ab198294f | |||
| 064320f431 | |||
| 0ea1abe327 | |||
| 8c12126d65 | |||
| 10ad498c54 | |||
| 534adad29a | |||
| 393adb711e | |||
| fb4dec76cb | |||
| 331f4cc2b7 | |||
| 0d84e6ffb5 | |||
| f84470ac10 | |||
| 04d1204eb5 | |||
| 1c5fad6a6b | |||
| 459824f983 | |||
| ea5986827e |
+53
-30
@@ -25,7 +25,7 @@ jobs:
|
||||
release: [stable, HEAD]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Git User for Applying Patches
|
||||
# See this thread for more details https://github.community/t/github-actions-bot-email-address/17204/5
|
||||
@@ -43,19 +43,21 @@ jobs:
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> ${GITHUB_ENV}
|
||||
brew install \
|
||||
brew install --formula \
|
||||
ccache \
|
||||
cmake \
|
||||
doxygen \
|
||||
graphviz
|
||||
|
||||
- name: Install Windows system dependencies
|
||||
if: runner.os == 'Windows'
|
||||
uses: nick-fields/retry@v2
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
timeout_minutes: 10
|
||||
max_attempts: 3
|
||||
command: choco install ccache doxygen.install graphviz
|
||||
command: |
|
||||
choco install ccache doxygen.install graphviz
|
||||
Add-Content -Path $env:GITHUB_ENV -Value "CCACHE_EXE=$(Resolve-Path C:\ProgramData\chocolatey\lib\ccache\tools\*\ccache.exe)"
|
||||
vcpkg install zlib:x64-windows-static
|
||||
|
||||
- name: Generate cache key
|
||||
shell: cmake -P {0}
|
||||
@@ -65,7 +67,7 @@ jobs:
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_TIMESTAMP=${current_date}\n")
|
||||
|
||||
- name: Update the cache (ccache)
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: "${{ github.workspace }}/ccache"
|
||||
key: ${{ env.CACHE_KEY }}_ccache_${{ env.CACHE_TIMESTAMP }}
|
||||
@@ -99,14 +101,20 @@ jobs:
|
||||
run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])"
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
-Dsleigh_RELEASE_TYPE=${{ matrix.release }}
|
||||
"-DCMAKE_PROJECT_INCLUDE:FILEPATH=${{ github.workspace }}/cmake/ccache-msvc.cmake"
|
||||
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
|
||||
|
||||
- name: Build the project
|
||||
run: cmake
|
||||
--build build
|
||||
--config ${{ matrix.build_type }}
|
||||
-j 2
|
||||
-j 4
|
||||
-v
|
||||
|
||||
- name: Test the project
|
||||
working-directory: build
|
||||
run: ctest -VV -C ${{ matrix.build_type }}
|
||||
|
||||
- name: Build the docs
|
||||
run: cmake
|
||||
--build build
|
||||
@@ -117,7 +125,7 @@ jobs:
|
||||
- name: Run the example
|
||||
run: cmake
|
||||
--build build
|
||||
-j 2
|
||||
-j 4
|
||||
--config ${{ matrix.build_type }}
|
||||
--target sleigh_example_runner
|
||||
|
||||
@@ -127,29 +135,53 @@ jobs:
|
||||
--prefix install
|
||||
|
||||
- name: Smoketest sleigh lift
|
||||
run: ./install/bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
|
||||
run: |
|
||||
./install/bin/sleigh-lift --version
|
||||
./install/bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
|
||||
./install/bin/sleigh-lift pcode x86-64.sla 4881ecc00f0000
|
||||
|
||||
- name: Test install directory
|
||||
- name: Test install directory Unix
|
||||
if: runner.os != 'Windows'
|
||||
working-directory: tests/find_package
|
||||
run: |
|
||||
cmake -B build -S . "-Dsleigh_DIR=${{ github.workspace }}/install/lib/cmake/sleigh" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
cmake --build build -j 2 --config ${{ matrix.build_type }}
|
||||
cmake --build build -j 4 --config ${{ matrix.build_type }}
|
||||
cd build
|
||||
ctest -V -C ${{ matrix.build_type }}
|
||||
- name: Test install directory Windows
|
||||
if: runner.os == 'Windows'
|
||||
working-directory: tests/find_package
|
||||
run: |
|
||||
cmake -B build -S . "-Dsleigh_DIR=${{ github.workspace }}/install/lib/cmake/sleigh" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
cmake --build build -j 4 --config ${{ matrix.build_type }}
|
||||
cd build
|
||||
ctest -V -C ${{ matrix.build_type }}
|
||||
|
||||
- name: Test tool install directory
|
||||
- name: Test tool install directory Unix
|
||||
if: runner.os != 'Windows'
|
||||
working-directory: extra-tools/sleigh-lift
|
||||
run: |
|
||||
cmake -B build -S . "-Dsleigh_DIR=${{ github.workspace }}/install/lib/cmake/sleigh" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
cmake --build build -j 2 --config ${{ matrix.build_type }}
|
||||
cmake --build build -j 4 --config ${{ matrix.build_type }}
|
||||
cmake --install build --config ${{ matrix.build_type }} --prefix install
|
||||
./install/bin/sleigh-lift --version
|
||||
./install/bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
|
||||
./install/bin/sleigh-lift pcode x86-64.sla 4881ecc00f0000
|
||||
- name: Test tool install directory Windows
|
||||
if: runner.os == 'Windows'
|
||||
working-directory: extra-tools/sleigh-lift
|
||||
run: |
|
||||
cmake -B build -S . "-Dsleigh_DIR=${{ github.workspace }}/install/lib/cmake/sleigh" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
cmake --build build -j 4 --config ${{ matrix.build_type }}
|
||||
cmake --install build --config ${{ matrix.build_type }} --prefix install
|
||||
./install/bin/sleigh-lift --version
|
||||
./install/bin/sleigh-lift disassemble x86-64.sla 4881ecc00f0000
|
||||
./install/bin/sleigh-lift pcode x86-64.sla 4881ecc00f0000
|
||||
|
||||
- name: Create the packages
|
||||
run: cmake
|
||||
--build build
|
||||
-j 2
|
||||
-j 4
|
||||
--config ${{ matrix.build_type }}
|
||||
--target package
|
||||
|
||||
@@ -159,7 +191,7 @@ jobs:
|
||||
sudo dpkg -i build/*.deb
|
||||
|
||||
cmake -S tests/find_package -B find_package_build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
cmake --build find_package_build -j 2 --config ${{ matrix.build_type }} --verbose
|
||||
cmake --build find_package_build -j 4 --config ${{ matrix.build_type }} --verbose
|
||||
|
||||
- name: Locate the packages (RelWithDebInfo only)
|
||||
if: matrix.build_type == 'RelWithDebInfo'
|
||||
@@ -182,13 +214,13 @@ jobs:
|
||||
# DEB Package
|
||||
- name: Upload the DEB package artifact (RelWithDebInfo only)
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.DEB_PACKAGE_NAME }}
|
||||
path: ${{ env.DEB_PACKAGE_PATH }}
|
||||
|
||||
- name: Release DEB package artifact (RelWithDebInfo only)
|
||||
uses: softprops/action-gh-release@v0.1.15
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
||||
with:
|
||||
files: ${{ env.DEB_PACKAGE_PATH }}
|
||||
@@ -196,12 +228,12 @@ jobs:
|
||||
# RPM Package
|
||||
- name: Upload the RPM package artifact (RelWithDebInfo only)
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.RPM_PACKAGE_NAME }}
|
||||
path: ${{ env.RPM_PACKAGE_PATH }}
|
||||
- name: Release RPM package artifact (RelWithDebInfo only)
|
||||
uses: softprops/action-gh-release@v0.1.15
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
||||
with:
|
||||
files: ${{ env.RPM_PACKAGE_PATH }}
|
||||
@@ -209,25 +241,16 @@ jobs:
|
||||
# TGZ Package
|
||||
- name: Upload the TGZ package artifact (RelWithDebInfo only)
|
||||
if: matrix.build_type == 'RelWithDebInfo'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.TGZ_PACKAGE_NAME }}
|
||||
path: ${{ env.TGZ_PACKAGE_PATH }}
|
||||
|
||||
- name: Release TGZ package artifact (RelWithDebInfo only)
|
||||
uses: softprops/action-gh-release@v0.1.15
|
||||
uses: softprops/action-gh-release@v2.3.2
|
||||
if: matrix.build_type == 'RelWithDebInfo' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
||||
with:
|
||||
files: ${{ env.TGZ_PACKAGE_PATH }}
|
||||
|
||||
# This step is down at the bottom because Windows fails but we still want
|
||||
# to upload the built binaries, regardless. We also want to see if/when
|
||||
# Windows tests start passing or are still failing, so there is no special
|
||||
# handling. GitHub Actions does not support the concept of an allowable
|
||||
# failure state
|
||||
- name: Run the tests
|
||||
working-directory: build
|
||||
run: ctest -VV -C ${{ matrix.build_type }}
|
||||
|
||||
- name: ccache stats
|
||||
run: ccache -s
|
||||
|
||||
@@ -12,12 +12,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
# Use oldest supported version for maximum script compatibility
|
||||
python-version: '3.7'
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Run Update Script
|
||||
id: head_update
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
|
||||
# Need this to run further Actions on the newly created PR
|
||||
# See here for more details https://github.com/peter-evans/create-pull-request/blob/28fa4848947e0faa7fa50647691d01477589d5e9/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens
|
||||
- uses: tibdex/github-app-token@v1
|
||||
- uses: tibdex/github-app-token@v2
|
||||
if: steps.head_update.outputs.did_update
|
||||
id: generate-token
|
||||
with:
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
|
||||
- name: Create PR
|
||||
if: steps.head_update.outputs.did_update
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
title: Update Ghidra HEAD to commit ${{ steps.head_update.outputs.short_sha }}
|
||||
commit-message: |
|
||||
@@ -45,10 +45,18 @@ jobs:
|
||||
Changed files:
|
||||
|
||||
${{ steps.head_update.outputs.changed_files }}
|
||||
|
||||
Commit details:
|
||||
|
||||
${{ steps.head_update.outputs.commit_details }}
|
||||
body: |
|
||||
Changed files:
|
||||
|
||||
${{ steps.head_update.outputs.changed_files }}
|
||||
|
||||
Commit details:
|
||||
|
||||
${{ steps.head_update.outputs.commit_details }}
|
||||
branch: cron/update-ghidra-${{ steps.head_update.outputs.short_sha }}
|
||||
delete-branch: true
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
+26
-5
@@ -8,6 +8,9 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
|
||||
# For MSVC ccache to use /Z7 with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
|
||||
cmake_policy(SET CMP0141 NEW)
|
||||
|
||||
include(cmake/prelude.cmake)
|
||||
|
||||
# Sets "library_root" variable for decompiler cpp root directory
|
||||
@@ -30,7 +33,7 @@ include(cmake/project-is-top-level.cmake)
|
||||
include(cmake/options.cmake)
|
||||
|
||||
#
|
||||
# Move headers so we can prefix with "sleigh/"
|
||||
# Move headers so we can prefix with "ghidra/"
|
||||
#
|
||||
set(public_include_header_list
|
||||
"${library_root}/action.hh"
|
||||
@@ -135,6 +138,14 @@ set(public_include_header_list
|
||||
"${library_root}/xml_arch.hh"
|
||||
"${library_root}/unionresolve.hh"
|
||||
"${library_root}/marshal.hh"
|
||||
"${library_root}/analyzesigs.hh"
|
||||
"${library_root}/modelrules.hh"
|
||||
"${library_root}/signature.hh"
|
||||
"${library_root}/signature_ghidra.hh"
|
||||
"${library_root}/compression.hh"
|
||||
"${library_root}/multiprecision.hh"
|
||||
"${library_root}/slaformat.hh"
|
||||
"${library_root}/constseq.hh"
|
||||
)
|
||||
#if(sleigh_RELEASE_IS_HEAD)
|
||||
# list(APPEND public_include_header_list
|
||||
@@ -143,13 +154,19 @@ set(public_include_header_list
|
||||
# Create custom target so that IDEs know these files are part of the sources
|
||||
add_custom_target(sleigh_all_headers SOURCES ${public_include_header_list})
|
||||
set(public_headers_dir ${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
file(MAKE_DIRECTORY "${public_headers_dir}/sleigh")
|
||||
configure_file(cmake/libconfig.h.in "${public_headers_dir}/sleigh/libconfig.h")
|
||||
file(MAKE_DIRECTORY "${public_headers_dir}/ghidra")
|
||||
# Copy the public headers into our build directory so that we can control the layout.
|
||||
# Ideally, we want to let people '#include <sleigh/{header}>' without installing sleigh
|
||||
# Ideally, we want to let people '#include <ghidra/{header}>' without installing sleigh
|
||||
foreach(public_header ${public_include_header_list})
|
||||
configure_file("${public_header}" "${public_headers_dir}/sleigh" COPYONLY)
|
||||
configure_file("${public_header}" "${public_headers_dir}/ghidra" COPYONLY)
|
||||
endforeach()
|
||||
# This project also generates a helper header for managing sleigh versions.
|
||||
# We intentionally use the `sleigh` directory for this header because it's
|
||||
# not from upstream.
|
||||
configure_file(cmake/libconfig.h.in "${public_headers_dir}/sleigh/libconfig.h")
|
||||
|
||||
# External Dependencies
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
#
|
||||
# sla
|
||||
@@ -183,6 +200,8 @@ set_target_properties(sleigh_sla PROPERTIES
|
||||
OUTPUT_NAME_DEBUG sla_dbg
|
||||
)
|
||||
|
||||
target_link_libraries(sleigh_sla PUBLIC ZLIB::ZLIB)
|
||||
|
||||
#
|
||||
# decomp
|
||||
#
|
||||
@@ -210,6 +229,8 @@ set_target_properties(sleigh_decomp PROPERTIES
|
||||
OUTPUT_NAME_DEBUG decomp_dbg
|
||||
)
|
||||
|
||||
target_link_libraries(sleigh_decomp PUBLIC ZLIB::ZLIB)
|
||||
|
||||
# This is the root directory where all individual processor spec file directories will be created.
|
||||
# NOTE: Needs to be defined here before the install rules
|
||||
set(spec_files_build_dir "${CMAKE_CURRENT_BINARY_DIR}/specfiles")
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
"inherits": ["flags-windows", "ci-std"],
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "x64",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ This repository provides a CMake-based build project for Sleigh so that it can b
|
||||
|
||||
| Name | Version | Linux Package to Install | macOS Homebrew Package to Install |
|
||||
| ---- | ------- | ------------------------ | --------------------------------- |
|
||||
| (HEAD builds) [zlib](https://www.zlib.net/) | Recent | zlib1g-dev | zlib |
|
||||
| [Git](https://git-scm.com/) | Latest | git | N/A |
|
||||
| [CMake](https://cmake.org/) | 3.18+ | cmake | cmake |
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# This module configures ccache to work with MSVC
|
||||
# Based on: https://github.com/ccache/ccache/wiki/MS-Visual-Studio
|
||||
|
||||
# Only do this for Windows MSVC builds
|
||||
if(NOT WIN32 OR NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Assume the parent environment has this set
|
||||
# Chocolatey creates a shim which doesn't work when renamed
|
||||
set(CCACHE_EXE "$ENV{CCACHE_EXE}")
|
||||
if(NOT CCACHE_EXE)
|
||||
message(STATUS "ccache not found - MSVC ccache support disabled")
|
||||
return()
|
||||
endif()
|
||||
message(STATUS "Found ccache - ${CCACHE_EXE}")
|
||||
|
||||
message(STATUS "Configuring ccache for MSVC")
|
||||
|
||||
file(COPY_FILE
|
||||
"${CCACHE_EXE}" "${CMAKE_BINARY_DIR}/cl.exe"
|
||||
ONLY_IF_DIFFERENT)
|
||||
|
||||
# By default Visual Studio generators will use /Zi which is not compatible
|
||||
# with ccache, so tell Visual Studio to use /Z7 instead.
|
||||
message(STATUS "Setting MSVC debug information format to 'Embedded'")
|
||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
|
||||
|
||||
set(CMAKE_VS_GLOBALS
|
||||
"CLToolExe=cl.exe"
|
||||
"CLToolPath=${CMAKE_BINARY_DIR}"
|
||||
"UseMultiToolTask=true"
|
||||
"DebugInformationFormat=OldStyle"
|
||||
)
|
||||
@@ -15,11 +15,14 @@
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/sleighTargets.cmake")
|
||||
|
||||
# Extra version details. Either 'stable' or 'HEAD'
|
||||
set(sleigh_RELEASE_IS_HEAD "@sleigh_RELEASE_IS_HEAD@")
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(ZLIB)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/sleighTargets.cmake")
|
||||
|
||||
# Helpers exposed by default when finding sleigh
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/modules/sleighCompile.cmake")
|
||||
|
||||
|
||||
@@ -265,8 +265,9 @@ int main(int argc, char *argv[]) {
|
||||
ghidra::ContextInternal ctx;
|
||||
ghidra::Sleigh engine(&load_image, &ctx);
|
||||
ghidra::DocumentStorage storage;
|
||||
std::istringstream sla("<sleigh>" + sla_file_path->string() + "</sleigh>");
|
||||
ghidra::Element *root =
|
||||
storage.openDocument(sla_file_path->string())->getRoot();
|
||||
storage.parseDocument(sla)->getRoot();
|
||||
storage.registerTag(root);
|
||||
std::optional<std::filesystem::path> pspec_file_path;
|
||||
if (args->pspec_file_name) {
|
||||
|
||||
+453
-219
@@ -1,280 +1,514 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Script to update CMake files for latest Ghidra Sleigh changes"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from typing import AnyStr, Union, List
|
||||
from typing import List, Dict, Optional, Any, Tuple
|
||||
|
||||
|
||||
# Constants
|
||||
PROJECT_ROOT = Path(__file__).parent.parent.resolve()
|
||||
HEAD_SPEC_FILE = PROJECT_ROOT / "src" / "spec_files_HEAD.cmake"
|
||||
assert HEAD_SPEC_FILE.exists()
|
||||
SETUP_GHIDRA_FILE = PROJECT_ROOT / "src" / "setup-ghidra-source.cmake"
|
||||
assert SETUP_GHIDRA_FILE.exists()
|
||||
|
||||
# Paths in Ghidra repo that affect this repo. Used with git diff
|
||||
SLEIGH_PATHS: List[str] = [
|
||||
# Source code and tests
|
||||
"Ghidra/Features/Decompiler/src/decompile",
|
||||
# Sleigh files
|
||||
"Ghidra/Processors",
|
||||
# Paths in Ghidra repo that affect this repo
|
||||
SLEIGH_PATHS = [
|
||||
"Ghidra/Features/Decompiler/src/decompile", # Source code and tests
|
||||
"Ghidra/Processors", # Sleigh files
|
||||
]
|
||||
|
||||
GIT_EXE = shutil.which("git")
|
||||
assert GIT_EXE is not None
|
||||
# Regex patterns
|
||||
HEAD_COMMIT_PATTERN = r"set\(ghidra_head_git_tag \"([0-9A-Fa-f]+)\"\)"
|
||||
VERSION_PATTERN = r"set\(ghidra_head_version \"([0-9]+(\.[0-9]+)*)\"\)"
|
||||
APP_VERSION_PATTERN = r"application.version=([0-9]+(\.[0-9]+)*)"
|
||||
|
||||
|
||||
def msg(s: str) -> None:
|
||||
print(f"[!] {s}")
|
||||
class GitHelper:
|
||||
"""Helper class for Git operations"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.git_exe = shutil.which("git")
|
||||
if self.git_exe is None:
|
||||
raise RuntimeError("Git executable not found in PATH")
|
||||
|
||||
PathString = Union[AnyStr, Path]
|
||||
def run(
|
||||
self, args: List[str], cwd: Path, capture_output: bool = False
|
||||
) -> subprocess.CompletedProcess:
|
||||
"""Run a git command with the given arguments"""
|
||||
assert self.git_exe is not None
|
||||
cmd = [self.git_exe] + args
|
||||
return subprocess.run(
|
||||
cmd,
|
||||
cwd=cwd,
|
||||
stdout=subprocess.PIPE if capture_output else sys.stdout,
|
||||
stderr=subprocess.PIPE if capture_output else sys.stderr,
|
||||
check=True,
|
||||
text=True if capture_output else False,
|
||||
)
|
||||
|
||||
def clone(self, repo_url: str, target_dir: Path) -> None:
|
||||
"""Clone a git repository"""
|
||||
print(f"Cloning {repo_url} to {target_dir}...")
|
||||
self.run(["clone", repo_url, str(target_dir)], cwd=PROJECT_ROOT)
|
||||
|
||||
def clone_ghidra_git(clone_dir: PathString) -> None:
|
||||
"""Clone the Ghidra git dir at specified directory"""
|
||||
assert GIT_EXE is not None
|
||||
subprocess.run(
|
||||
[
|
||||
GIT_EXE,
|
||||
"clone",
|
||||
"https://github.com/NationalSecurityAgency/ghidra",
|
||||
clone_dir,
|
||||
],
|
||||
stdout=sys.stdout,
|
||||
stderr=sys.stderr,
|
||||
check=True,
|
||||
)
|
||||
def get_head_commit(self, repo_dir: Path) -> str:
|
||||
"""Get the HEAD commit SHA of the repository"""
|
||||
result = self.run(["rev-parse", "HEAD"], cwd=repo_dir, capture_output=True)
|
||||
return result.stdout.strip()
|
||||
|
||||
def check_commit_exists(self, repo_dir: Path, commit: str) -> bool:
|
||||
"""Check if a commit exists in the repository"""
|
||||
try:
|
||||
self.run(["cat-file", "-e", commit], repo_dir, capture_output=True)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
def git_get_changed_files(
|
||||
repo: Path, old_commit: str, new_commit: str, paths: List[str], ci: bool
|
||||
) -> List[str]:
|
||||
"""Get list of changed files from old_commit to new_commit at the specified paths"""
|
||||
assert GIT_EXE is not None
|
||||
changed_files = (
|
||||
subprocess.run(
|
||||
def get_commit_info(
|
||||
self, repo_dir: Path, old_commit: str, new_commit: str, paths: List[str]
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Get detailed information about commits affecting specified paths"""
|
||||
result = self.run(
|
||||
[
|
||||
"log",
|
||||
"--pretty=format:%H%n%ad%n%s%n%b%n====",
|
||||
"--date=iso",
|
||||
f"{old_commit}..{new_commit}",
|
||||
"--",
|
||||
*paths,
|
||||
],
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
log_output = result.stdout.strip()
|
||||
commits = []
|
||||
|
||||
if log_output:
|
||||
commit_sections = log_output.split("\n====")
|
||||
|
||||
for section in commit_sections:
|
||||
if not section.strip():
|
||||
continue
|
||||
|
||||
lines = section.strip().split("\n")
|
||||
commit_hash = lines[0]
|
||||
commit_date = lines[1]
|
||||
commit_msg = lines[2]
|
||||
body = "\n".join(lines[3:]) if len(lines) > 3 else ""
|
||||
|
||||
# Get files modified in this commit
|
||||
files_result = self.run(
|
||||
[
|
||||
"diff-tree",
|
||||
"--no-commit-id",
|
||||
"--name-status",
|
||||
"-r",
|
||||
commit_hash,
|
||||
"--",
|
||||
*paths,
|
||||
],
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
commit_files = files_result.stdout.strip().splitlines()
|
||||
# Filter out Java files
|
||||
commit_files = [f for f in commit_files if not f.endswith(".java")]
|
||||
|
||||
if commit_files:
|
||||
commits.append(
|
||||
{
|
||||
"hash": commit_hash,
|
||||
"date": commit_date,
|
||||
"message": commit_msg,
|
||||
"body": body,
|
||||
"files": commit_files,
|
||||
}
|
||||
)
|
||||
|
||||
return commits
|
||||
|
||||
def get_changed_files(
|
||||
self, repo_dir: Path, old_commit: str, new_commit: str, paths: List[str]
|
||||
) -> List[str]:
|
||||
"""Get list of files changed between commits"""
|
||||
result = self.run(
|
||||
[
|
||||
GIT_EXE,
|
||||
"diff",
|
||||
"--name-status",
|
||||
f"{old_commit}...{new_commit}",
|
||||
"--",
|
||||
*paths,
|
||||
],
|
||||
cwd=repo,
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
.stdout.decode()
|
||||
.strip()
|
||||
.splitlines()
|
||||
)
|
||||
num_changed = len(changed_files)
|
||||
if num_changed > 0:
|
||||
msg(f"Found {num_changed} changed sleigh files:")
|
||||
print("\n".join(changed_files))
|
||||
if ci:
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out:
|
||||
gh_out.write("changed_files<<EOF\n")
|
||||
gh_out.write("```\n")
|
||||
gh_out.write("\n".join(changed_files))
|
||||
gh_out.write("\n```\n")
|
||||
gh_out.write("EOF\n")
|
||||
return changed_files
|
||||
|
||||
changed_files = result.stdout.strip().splitlines()
|
||||
# Filter out Java files
|
||||
changed_files = [f for f in changed_files if not f.endswith(".java")]
|
||||
|
||||
return changed_files
|
||||
|
||||
|
||||
def is_sleigh_updated(
|
||||
ghidra_repo: Path, old_commit: str, new_commit: str, ci: bool
|
||||
) -> bool:
|
||||
"""Check if files we're interested in have been touched at all"""
|
||||
changed_files = git_get_changed_files(
|
||||
ghidra_repo, old_commit, new_commit, SLEIGH_PATHS, ci
|
||||
)
|
||||
return len(changed_files) > 0
|
||||
class GhidraUpdater:
|
||||
"""Handles updating Ghidra-related CMake files"""
|
||||
|
||||
def __init__(self, ci_mode: bool = False, dry_run: bool = False) -> None:
|
||||
self.git = GitHelper()
|
||||
self.ci_mode = ci_mode
|
||||
self.dry_run = dry_run
|
||||
|
||||
def update_head_commit(
|
||||
setup_file: Path, ghidra_repo_dir: PathString, latest_commit: str, ci: bool
|
||||
) -> bool:
|
||||
"""Edit the Ghidra script to point to the latest commit"""
|
||||
head_commit_line = r"set\(ghidra_head_git_tag \"([0-9A-Fa-f]+)\"\)"
|
||||
updated = False
|
||||
# Validate required paths
|
||||
if not HEAD_SPEC_FILE.exists():
|
||||
raise FileNotFoundError(f"HEAD spec file not found: {HEAD_SPEC_FILE}")
|
||||
if not SETUP_GHIDRA_FILE.exists():
|
||||
raise FileNotFoundError(f"Setup Ghidra file not found: {SETUP_GHIDRA_FILE}")
|
||||
|
||||
fd, abspath = tempfile.mkstemp()
|
||||
with open(fd, "w") as w:
|
||||
with setup_file.open("r") as r:
|
||||
for line in r:
|
||||
match = re.search(head_commit_line, line)
|
||||
if match is not None:
|
||||
# Set up GitHub Actions outputs if in CI mode
|
||||
if self.ci_mode and "GITHUB_OUTPUT" not in os.environ:
|
||||
raise RuntimeError("CI mode requires GITHUB_OUTPUT environment variable")
|
||||
|
||||
def clone_ghidra_if_needed(
|
||||
self, repo_dir: Optional[Path] = None
|
||||
) -> Tuple[Path, Optional[tempfile.TemporaryDirectory]]:
|
||||
"""Clone Ghidra repo if a directory is not provided"""
|
||||
temp_dir = None
|
||||
|
||||
if repo_dir is None:
|
||||
temp_dir = tempfile.TemporaryDirectory()
|
||||
repo_dir = Path(temp_dir.name) / "ghidra"
|
||||
self.git.clone("https://github.com/NationalSecurityAgency/ghidra", repo_dir)
|
||||
|
||||
return repo_dir, temp_dir
|
||||
|
||||
def log_github_output(self, key: str, value: str) -> None:
|
||||
"""Log output for GitHub Actions"""
|
||||
if self.ci_mode:
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
|
||||
f.write(f"{key}={value}\n")
|
||||
|
||||
def log_github_multiline_output(self, key: str, value: str) -> None:
|
||||
"""Log multiline output for GitHub Actions"""
|
||||
if self.ci_mode:
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
|
||||
f.write(f"{key}<<EOF\n")
|
||||
f.write(value)
|
||||
f.write("\nEOF\n")
|
||||
|
||||
def display_changes(
|
||||
self, repo_dir: Path, start_commit: str, end_commit: str
|
||||
) -> Tuple[List[str], List[Dict[str, Any]]]:
|
||||
"""Display changes between two commits and return the changed files and commit info"""
|
||||
# Get changed files
|
||||
changed_files = self.git.get_changed_files(
|
||||
repo_dir, start_commit, end_commit, SLEIGH_PATHS
|
||||
)
|
||||
|
||||
if not changed_files:
|
||||
print("No sleigh files were modified between these commits")
|
||||
return [], []
|
||||
|
||||
# Output changes for logging
|
||||
num_changed = len(changed_files)
|
||||
print(f"Found {num_changed} changed sleigh files:")
|
||||
for file in changed_files:
|
||||
print(f" {file}")
|
||||
|
||||
# Get detailed commit info for logging
|
||||
commit_info = self.git.get_commit_info(
|
||||
repo_dir, start_commit, end_commit, SLEIGH_PATHS
|
||||
)
|
||||
|
||||
if commit_info:
|
||||
print(f"\nCommits affecting sleigh files ({len(commit_info)}):\n")
|
||||
for i, commit in enumerate(commit_info, 1):
|
||||
print(f"[Commit {i}/{len(commit_info)}]")
|
||||
print(f"Hash: {commit['hash']}")
|
||||
print(f"Date: {commit['date']}")
|
||||
print(f"Message: {commit['message']}")
|
||||
if commit["body"]:
|
||||
print(f"Details:\n{commit['body']}")
|
||||
print("\nFiles changed:")
|
||||
for file in commit["files"]:
|
||||
print(f" {file}")
|
||||
print("")
|
||||
|
||||
# Log outputs for GitHub Actions
|
||||
if self.ci_mode:
|
||||
self.log_github_output("short_sha", end_commit[:9])
|
||||
self.log_github_output("did_update", "true")
|
||||
|
||||
# Log changed files
|
||||
changed_files_str = "```\n" + "\n".join(changed_files) + "\n```"
|
||||
self.log_github_multiline_output("changed_files", changed_files_str)
|
||||
|
||||
# Log commit details
|
||||
if commit_info:
|
||||
details = ["```"]
|
||||
for i, commit in enumerate(commit_info, 1):
|
||||
details.append(f"[Commit {i}/{len(commit_info)}]")
|
||||
details.append(f"Hash: {commit['hash']}")
|
||||
details.append(f"Date: {commit['date']}")
|
||||
details.append(f"Message: {commit['message']}")
|
||||
if commit["body"]:
|
||||
details.append(f"Details:\n{commit['body']}")
|
||||
details.append("\nFiles changed:")
|
||||
for file in commit["files"]:
|
||||
details.append(f" {file}")
|
||||
details.append("")
|
||||
# Replace trailing newline for last entry
|
||||
details[-1] = "```"
|
||||
|
||||
self.log_github_multiline_output("commit_details", "\n".join(details))
|
||||
|
||||
return changed_files, commit_info
|
||||
|
||||
def update_head_commit(
|
||||
self, repo_dir: Path, setup_file: Path
|
||||
) -> Tuple[bool, str, str]:
|
||||
"""Update the HEAD commit in the setup file if needed"""
|
||||
# Get latest commit hash
|
||||
latest_commit = self.git.get_head_commit(repo_dir)
|
||||
current_commit = None
|
||||
|
||||
# Find current commit hash in setup file
|
||||
with setup_file.open("r") as f:
|
||||
for line in f:
|
||||
match = re.search(HEAD_COMMIT_PATTERN, line)
|
||||
if match:
|
||||
current_commit = match.group(1)
|
||||
if current_commit != latest_commit:
|
||||
msg(f"Found new commit: {latest_commit}")
|
||||
if is_sleigh_updated(
|
||||
ghidra_repo_dir, current_commit, latest_commit, ci
|
||||
):
|
||||
line = re.sub(
|
||||
head_commit_line,
|
||||
f'set(ghidra_head_git_tag "{latest_commit}")',
|
||||
line,
|
||||
)
|
||||
updated = True
|
||||
else:
|
||||
msg("No sleigh files updated")
|
||||
w.write(line)
|
||||
break
|
||||
|
||||
# Make the swap with the new content
|
||||
shutil.copymode(setup_file, abspath)
|
||||
os.remove(setup_file)
|
||||
shutil.move(abspath, setup_file)
|
||||
return updated
|
||||
if current_commit is None:
|
||||
raise ValueError("Could not find current commit in setup file")
|
||||
|
||||
# Check if update is needed
|
||||
if current_commit == latest_commit:
|
||||
print(f"Already at the latest commit: {latest_commit}")
|
||||
return False, current_commit, latest_commit
|
||||
|
||||
def update_head_version_file(setup_file: Path, ghidra_root_dir: PathString) -> None:
|
||||
"""Edit the Ghidra script to point to the latest version"""
|
||||
cmake_head_version_line = (
|
||||
r"set\(ghidra_head_version \"([0-9]+(\.[0-9]+)?(\.[0-9]+)?)\"\)"
|
||||
)
|
||||
print(f"Found new commit: {latest_commit}")
|
||||
|
||||
with (ghidra_root_dir / "Ghidra" / "application.properties").open("r") as f:
|
||||
content = f.read()
|
||||
match = re.search(
|
||||
r"application.version=([0-9]+(\.[0-9]+)?(\.[0-9]+)?)", content
|
||||
# Check if sleigh files were updated and display changes
|
||||
changed_files, commit_info = self.display_changes(
|
||||
repo_dir, current_commit, latest_commit
|
||||
)
|
||||
assert match is not None
|
||||
source_version = match.group(1)
|
||||
|
||||
with setup_file.open("r") as f:
|
||||
content = f.read()
|
||||
match = re.search(cmake_head_version_line, content)
|
||||
assert match is not None
|
||||
cmake_version = match.group(1)
|
||||
if not changed_files:
|
||||
return False, current_commit, latest_commit
|
||||
|
||||
if cmake_version == source_version:
|
||||
msg(f"No new version bump")
|
||||
return
|
||||
# Update the setup file if not in dry run mode
|
||||
if not self.dry_run:
|
||||
self._replace_in_file(
|
||||
setup_file,
|
||||
HEAD_COMMIT_PATTERN,
|
||||
f'set(ghidra_head_git_tag "{latest_commit}")',
|
||||
)
|
||||
|
||||
msg(f"Found new version: {source_version}")
|
||||
fd, abspath = tempfile.mkstemp()
|
||||
with open(fd, "w") as w:
|
||||
with setup_file.open("r") as r:
|
||||
for line in r:
|
||||
match = re.search(cmake_head_version_line, line)
|
||||
if match is not None:
|
||||
line = re.sub(
|
||||
cmake_head_version_line,
|
||||
f'set(ghidra_head_version "{source_version}")',
|
||||
line,
|
||||
)
|
||||
w.write(line)
|
||||
return True, current_commit, latest_commit
|
||||
|
||||
# Make the swap with the new content
|
||||
shutil.copymode(setup_file, abspath)
|
||||
os.remove(setup_file)
|
||||
shutil.move(abspath, setup_file)
|
||||
def update_version(self, repo_dir: Path, setup_file: Path) -> None:
|
||||
"""Update the Ghidra version in the setup file if needed"""
|
||||
# Get source version from application.properties
|
||||
app_properties_file = repo_dir / "Ghidra" / "application.properties"
|
||||
|
||||
with app_properties_file.open("r") as f:
|
||||
content = f.read()
|
||||
match = re.search(APP_VERSION_PATTERN, content)
|
||||
if not match:
|
||||
raise ValueError("Could not find version in application.properties")
|
||||
source_version = match.group(1)
|
||||
|
||||
# Get current version from setup file
|
||||
with setup_file.open("r") as f:
|
||||
content = f.read()
|
||||
match = re.search(VERSION_PATTERN, content)
|
||||
if not match:
|
||||
raise ValueError("Could not find version in setup file")
|
||||
cmake_version = match.group(1)
|
||||
|
||||
# Check if update is needed
|
||||
if cmake_version == source_version:
|
||||
print("No new version bump")
|
||||
return
|
||||
|
||||
print(f"Found new version: {source_version}")
|
||||
|
||||
# Update the setup file if not in dry run mode
|
||||
if not self.dry_run:
|
||||
self._replace_in_file(
|
||||
setup_file,
|
||||
VERSION_PATTERN,
|
||||
f'set(ghidra_head_version "{source_version}")',
|
||||
)
|
||||
|
||||
def update_spec_files(self, repo_dir: Path, spec_file: Path) -> None:
|
||||
"""Update the list of spec files in the CMake file"""
|
||||
# Find all .slaspec files
|
||||
spec_files = []
|
||||
processors_dir = repo_dir / "Ghidra" / "Processors"
|
||||
|
||||
for path in processors_dir.glob("**/*.slaspec"):
|
||||
spec_files.append(path.relative_to(repo_dir))
|
||||
|
||||
spec_files.sort()
|
||||
print(f"Found {len(spec_files)} slaspec files")
|
||||
|
||||
# Write the updated spec file list
|
||||
if not self.dry_run and spec_files:
|
||||
with spec_file.open("w") as f:
|
||||
f.write("set(spec_file_list\n")
|
||||
for spec in spec_files:
|
||||
f.write(f' "${{ghidrasource_SOURCE_DIR}}/{spec}"\n')
|
||||
f.write(")\n")
|
||||
|
||||
def _replace_in_file(self, file_path: Path, pattern: str, replacement: str) -> None:
|
||||
"""Replace text in a file matching the pattern with the replacement"""
|
||||
temp_file = tempfile.NamedTemporaryFile(mode="w", delete=False)
|
||||
|
||||
with file_path.open("r") as src, open(temp_file.name, "w") as dst:
|
||||
for line in src:
|
||||
dst.write(re.sub(pattern, replacement, line))
|
||||
|
||||
# Replace the original file with the modified one
|
||||
shutil.copymode(file_path, temp_file.name)
|
||||
os.remove(file_path)
|
||||
shutil.move(temp_file.name, file_path)
|
||||
|
||||
def update(self, repo_dir: Optional[Path] = None) -> bool:
|
||||
"""Main update method to orchestrate the update process"""
|
||||
# Clone repo if not provided
|
||||
repo_dir, temp_dir = self.clone_ghidra_if_needed(repo_dir)
|
||||
|
||||
try:
|
||||
# Update the HEAD commit
|
||||
did_update, _, _ = self.update_head_commit(repo_dir, SETUP_GHIDRA_FILE)
|
||||
|
||||
# If commit was updated, also update version and spec files
|
||||
if did_update:
|
||||
self.update_version(repo_dir, SETUP_GHIDRA_FILE)
|
||||
self.update_spec_files(repo_dir, HEAD_SPEC_FILE)
|
||||
|
||||
return did_update
|
||||
|
||||
finally:
|
||||
# Clean up temp directory if created
|
||||
if temp_dir:
|
||||
temp_dir.cleanup()
|
||||
|
||||
def compare_commits(
|
||||
self, repo_dir: Path, start_commit: str, end_commit: Optional[str] = None
|
||||
) -> None:
|
||||
"""Compare changes between two commits without updating any files"""
|
||||
# If end_commit is not provided, use HEAD
|
||||
if end_commit is None:
|
||||
end_commit = self.git.get_head_commit(repo_dir)
|
||||
print(f"Using HEAD as end commit: {end_commit}")
|
||||
|
||||
print(f"Comparing commits {start_commit} to {end_commit}")
|
||||
|
||||
# Check if the commits exist
|
||||
for commit in [start_commit, end_commit]:
|
||||
if not self.git.check_commit_exists(repo_dir, commit):
|
||||
raise ValueError(f"Commit {commit} does not exist in the repository")
|
||||
|
||||
# Display changes
|
||||
self.display_changes(repo_dir, start_commit, end_commit)
|
||||
|
||||
|
||||
def update_spec_files(ghidra_repo_dir: PathString, cmake_file: PathString):
|
||||
"""Based on the files in the Ghidra repo, write an updated list of spec files."""
|
||||
spec_files = []
|
||||
for dirpath, _, fnames in os.walk(ghidra_repo_dir / "Ghidra" / "Processors"):
|
||||
for file in fnames:
|
||||
if file.endswith(".slaspec"):
|
||||
spec_files.append((Path(dirpath) / file).relative_to(ghidra_repo_dir))
|
||||
assert len(spec_files) > 0
|
||||
spec_files.sort()
|
||||
|
||||
msg(f"Found {len(spec_files)} slaspec files")
|
||||
|
||||
with open(cmake_file, "w") as f:
|
||||
f.write("set(spec_file_list\n")
|
||||
for spec in spec_files:
|
||||
f.write(f' "${{ghidrasource_SOURCE_DIR}}/{spec}"\n')
|
||||
f.write(")\n")
|
||||
|
||||
|
||||
def get_latest_commit(ghidra_repo_dir: PathString) -> str:
|
||||
"""Get the commit SHA that the repo is currently at"""
|
||||
assert GIT_EXE is not None
|
||||
return (
|
||||
subprocess.run(
|
||||
[GIT_EXE, "rev-parse", "HEAD"],
|
||||
cwd=ghidra_repo_dir,
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
.stdout.decode()
|
||||
.strip()
|
||||
)
|
||||
|
||||
|
||||
def update_head(
|
||||
setup_file: Path, spec_file: Path, ghidra_repo_dir: PathString, ci: bool
|
||||
) -> bool:
|
||||
"""Update to latest head and make changes to the CMake files"""
|
||||
tmpdirname = None
|
||||
if ghidra_repo_dir is None:
|
||||
tmpdirname = tempfile.TemporaryDirectory()
|
||||
ghidra_repo_dir = Path(tmpdirname.name) / "ghidra"
|
||||
clone_ghidra_git(ghidra_repo_dir)
|
||||
|
||||
latest_commit = get_latest_commit(ghidra_repo_dir)
|
||||
did_update_commit = update_head_commit(
|
||||
setup_file, ghidra_repo_dir, latest_commit, ci
|
||||
)
|
||||
if did_update_commit:
|
||||
if ci:
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out:
|
||||
gh_out.write(f"short_sha={latest_commit[:9]}\n")
|
||||
gh_out.write("did_update=true\n")
|
||||
update_spec_files(ghidra_repo_dir, spec_file)
|
||||
update_head_version_file(setup_file, ghidra_repo_dir)
|
||||
else:
|
||||
msg(f"Already at the latest commit: {latest_commit}")
|
||||
|
||||
if tmpdirname is not None:
|
||||
tmpdirname.cleanup()
|
||||
|
||||
if did_update_commit:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse, os
|
||||
|
||||
def dir_path(string):
|
||||
if string is None:
|
||||
return string
|
||||
string = Path(string).expanduser().resolve()
|
||||
if string.is_dir():
|
||||
return string
|
||||
else:
|
||||
raise NotADirectoryError(string)
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
"""Parse command line arguments"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Update CMake files to latest Ghidra commit."
|
||||
description="Find and collect changes between two Ghidra commits. Update CMake files to latest Ghidra commit if specified."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--ghidra-repo",
|
||||
type=dir_path,
|
||||
type=str,
|
||||
help="Use a specific Ghidra repo directory instead of downloading it from the internet",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--ci",
|
||||
action="store_true",
|
||||
help="Output GitHub Actions commands for recording information in CI",
|
||||
help="Output GitHub Actions commands for recording information in CI. Requires GITHUB_OUTPUT environment variable.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--dry-run",
|
||||
action="store_true",
|
||||
help="Show what would be changed without actually modifying any files",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"start_commit",
|
||||
nargs="?",
|
||||
type=str,
|
||||
help="Starting commit for comparison. When specified, no CMake files will be updated.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"end_commit",
|
||||
nargs="?",
|
||||
type=str,
|
||||
help="Ending commit for comparison. If not specified, uses current HEAD of the repo. Requires start_commit.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.ci:
|
||||
assert (
|
||||
"GITHUB_OUTPUT" in os.environ
|
||||
), "CI needs `GITHUB_OUTPUT` environment variable set to a file location"
|
||||
# Convert ghidra-repo path if provided
|
||||
if args.ghidra_repo:
|
||||
repo_path = Path(args.ghidra_repo).expanduser().resolve()
|
||||
if not repo_path.is_dir():
|
||||
parser.error(f"Ghidra repo directory does not exist: {repo_path}")
|
||||
args.ghidra_repo = repo_path
|
||||
|
||||
if not update_head(SETUP_GHIDRA_FILE, HEAD_SPEC_FILE, args.ghidra_repo, args.ci):
|
||||
msg("No update required")
|
||||
else:
|
||||
msg("Update required!")
|
||||
# Validate commit arguments
|
||||
if args.end_commit and not args.start_commit:
|
||||
parser.error("Cannot specify end_commit without start_commit")
|
||||
|
||||
# If commits are specified, a Ghidra repo is required
|
||||
if args.start_commit and not args.ghidra_repo:
|
||||
parser.error("--ghidra-repo is required when specifying commits")
|
||||
|
||||
return args
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Main entry point"""
|
||||
args = parse_args()
|
||||
|
||||
try:
|
||||
updater = GhidraUpdater(ci_mode=args.ci, dry_run=args.dry_run)
|
||||
|
||||
# If start_commit is specified, run in comparison mode
|
||||
if args.start_commit:
|
||||
updater.compare_commits(
|
||||
args.ghidra_repo, args.start_commit, args.end_commit
|
||||
)
|
||||
else:
|
||||
# Normal update mode
|
||||
did_update = updater.update(args.ghidra_repo)
|
||||
|
||||
if not did_update:
|
||||
print("No update required")
|
||||
elif args.dry_run:
|
||||
print("Update would be required!")
|
||||
else:
|
||||
print("Update required!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
From 67ac779382508ab0d5ff10bcb0a8453068cce5a2 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Mon, 5 Jun 2023 16:45:04 +1200
|
||||
Subject: [PATCH 1/2] Fix UBSAN errors in decompiler
|
||||
From 7c6e51dd1234387b98e1ad61d3f88a0565364b28 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Mon, 12 Aug 2024 12:02:35 -0400
|
||||
Subject: [PATCH 1/6] Fix UBSAN errors in decompiler
|
||||
|
||||
Co-authored-by: Alex Cameron <asc@tetsuo.sh>
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
|
||||
.../src/decompile/cpp/funcdata_varnode.cc | 8 +++++++-
|
||||
.../Decompiler/src/decompile/cpp/op.cc | 6 +++++-
|
||||
.../Decompiler/src/decompile/cpp/opbehavior.cc | 8 +++++++-
|
||||
.../src/decompile/cpp/pcodecompile.cc | 18 +++++++++++-------
|
||||
.../Decompiler/src/decompile/cpp/ruleaction.cc | 18 ++++++++++++++----
|
||||
.../Decompiler/src/decompile/cpp/ruleaction.cc | 12 +++++++++---
|
||||
.../Decompiler/src/decompile/cpp/semantics.cc | 2 ++
|
||||
.../Decompiler/src/decompile/cpp/semantics.hh | 2 +-
|
||||
.../src/decompile/cpp/slgh_compile.cc | 2 +-
|
||||
.../Decompiler/src/decompile/cpp/slghsymbol.cc | 2 +-
|
||||
.../Decompiler/src/decompile/cpp/type.cc | 2 +-
|
||||
.../src/decompile/unittests/testfloatemu.cc | 2 +-
|
||||
12 files changed, 57 insertions(+), 21 deletions(-)
|
||||
10 files changed, 44 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
index 82771cc04..da78c8071 100644
|
||||
index d78b78731c..caf4b24d15 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
@@ -2661,8 +2661,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
@@ -2868,8 +2868,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
modellist.push_back(mymodel);
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
@@ -37,30 +36,11 @@ index 82771cc04..da78c8071 100644
|
||||
}
|
||||
|
||||
void ParameterBasic::setTypeLock(bool val)
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
index f77817073..283d81c31 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
@@ -503,7 +503,13 @@ void Funcdata::setHighLevel(void)
|
||||
void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset)
|
||||
|
||||
{
|
||||
- uintb newConsume = (vn->getConsume() >> 8*lsbOffset) & calc_mask(newVn->getSize());
|
||||
+ uintb newConsume = vn->getConsume();
|
||||
+ if (8*lsbOffset < sizeof(newConsume)) {
|
||||
+ newConsume >>= 8*lsbOffset;
|
||||
+ } else {
|
||||
+ newConsume = 0;
|
||||
+ }
|
||||
+ newConsume &= calc_mask(newVn->getSize());
|
||||
|
||||
uint4 vnFlags = vn->getFlags() & (Varnode::directwrite|Varnode::addrforce);
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
index 0e3decc80..403ec35a7 100644
|
||||
index d51460be84..45bf394862 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
@@ -672,7 +672,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
@@ -666,7 +666,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
break;
|
||||
case CPUI_PIECE:
|
||||
resmask = getIn(0)->getNZMask();
|
||||
@@ -74,7 +54,7 @@ index 0e3decc80..403ec35a7 100644
|
||||
break;
|
||||
case CPUI_INT_MULT:
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
index aebcfd910..6c47e6eb1 100644
|
||||
index aebcfd9103..6c47e6eb15 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
@@ -746,7 +746,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
@@ -93,7 +73,7 @@ index aebcfd910..6c47e6eb1 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
index ca9d71ab9..85d4dd281 100644
|
||||
index ca9d71ab99..85d4dd281d 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
@@ -621,8 +621,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
@@ -136,7 +116,7 @@ index ca9d71ab9..85d4dd281 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
index ae2e502c1..a22b8ebdc 100644
|
||||
index 009570af71..72b2a10503 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -153,7 +133,7 @@ index ae2e502c1..a22b8ebdc 100644
|
||||
consume = ~consume;
|
||||
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
|
||||
|
||||
@@ -6789,8 +6794,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -7031,8 +7036,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *sb = op->getIn(0);
|
||||
Datatype *sbType = sb->getTypeReadFacing(op);
|
||||
if (sbType->getMetatype() != TYPE_PTR) return 0;
|
||||
@@ -165,21 +145,8 @@ index ae2e502c1..a22b8ebdc 100644
|
||||
Varnode *vn1 = op->getIn(1);
|
||||
if (!vn1->isConstant()) return 0;
|
||||
Varnode *outvn = op->getOut();
|
||||
@@ -8600,7 +8606,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 flowsize = outvn->getSize();
|
||||
uintb mask = calc_mask( flowsize );
|
||||
- mask <<= 8*((int4)op->getIn(1)->getOffset());
|
||||
+ if (8*((int4)op->getIn(1)->getOffset()) < sizeof(mask)) {
|
||||
+ mask <<= 8*((int4)op->getIn(1)->getOffset());
|
||||
+ } else {
|
||||
+ mask = 0;
|
||||
+ }
|
||||
bool aggressive = outvn->isPtrFlow();
|
||||
if (!aggressive) {
|
||||
if ((vn->getConsume() & mask) != vn->getConsume()) return 0;
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
index 2e3531ea2..42482be7c 100644
|
||||
index cd9b9835b1..8a4616c3b9 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
@@ -22,6 +22,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
@@ -199,12 +166,12 @@ index 2e3531ea2..42482be7c 100644
|
||||
|
||||
bool ConstTpl::isConstSpace(void) const
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
index 8e283dca0..652600c16 100644
|
||||
index e0b069959d..9117a45c75 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
static void printHandleSelector(ostream &s,v_field val);
|
||||
static v_field readHandleSelector(const string &name);
|
||||
@@ -47,7 +47,7 @@ class ConstTpl {
|
||||
uintb value_real;
|
||||
v_field select; // Which part of handle to use as constant
|
||||
public:
|
||||
- ConstTpl(void) { type = real; value_real = 0; }
|
||||
+ ConstTpl(void) { type = real; value_real = 0; select = v_space; }
|
||||
@@ -212,10 +179,10 @@ index 8e283dca0..652600c16 100644
|
||||
type=op2.type; value=op2.value; value_real=op2.value_real; select=op2.select; }
|
||||
ConstTpl(const_type tp,uintb val);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
index b40f74389..3c37958df 100644
|
||||
index 50d85e22ba..9f3b456229 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
@@ -2163,8 +2163,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
@@ -2164,8 +2164,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
ostringstream msg;
|
||||
SymbolTree::const_iterator iter;
|
||||
for(iter=scope->begin();iter!=scope->end();++iter) {
|
||||
@@ -225,24 +192,11 @@ index b40f74389..3c37958df 100644
|
||||
if (sym->getRefCount() == 0)
|
||||
msg << " Label <" << sym->getName() << "> was placed but not used" << endl;
|
||||
else if (!sym->isPlaced())
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
index b308e1b71..af2982aee 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
@@ -2569,7 +2569,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
const List &list(el->getChildren());
|
||||
List::const_iterator iter;
|
||||
iter = list.begin();
|
||||
- patexp = (PatternValue *)PatternExpression::restoreExpression(*iter,trans);
|
||||
+ patexp = PatternExpression::restoreExpression(*iter,trans);
|
||||
patexp->layClaim();
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index 32ede6b0f..238d97f40 100644
|
||||
index fd0ab26fb4..7f654c220b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -3384,8 +3384,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
@@ -3728,8 +3728,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
top.submeta = sub; // Search on the incorrect submeta
|
||||
iter = tree.lower_bound(&top);
|
||||
while(iter != tree.end()) {
|
||||
@@ -253,10 +207,10 @@ index 32ede6b0f..238d97f40 100644
|
||||
++iter;
|
||||
if (ptr->submeta == sub) {
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
index c35bde877..061e53677 100644
|
||||
index 2571f55f1a..fe40e22b1b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -346,7 +346,7 @@ TEST(float_opTrunc_to_int) {
|
||||
@@ -375,7 +375,7 @@ TEST(float_opTrunc_to_int) {
|
||||
|
||||
for(float f:float_test_values) {
|
||||
// avoid undefined behavior
|
||||
@@ -266,5 +220,5 @@ index c35bde877..061e53677 100644
|
||||
uintb true_result = ((uintb)(int32_t)f) & 0xffffffff;
|
||||
uintb encoding = format.getEncoding(f);
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.48.1
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 9fd26cd754b6f83e45199db896fd0fcea23cd59d Mon Sep 17 00:00:00 2001
|
||||
From 5e37c51ebc8a3ae0f32a3cb0049aaebafec48d7d Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Wed, 3 Aug 2022 20:01:18 +1000
|
||||
Subject: [PATCH 2/2] Use `stroull` instead of `stroul` to parse address
|
||||
Subject: [PATCH 2/6] Use `stroull` instead of `stroul` to parse address
|
||||
offsets
|
||||
|
||||
---
|
||||
@@ -9,7 +9,7 @@ Subject: [PATCH 2/2] Use `stroull` instead of `stroul` to parse address
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
index bf4e1dc96..594b4583a 100644
|
||||
index dbaa2e775f..72927bf379 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
@@ -16,6 +16,8 @@
|
||||
@@ -21,7 +21,7 @@ index bf4e1dc96..594b4583a 100644
|
||||
namespace ghidra {
|
||||
|
||||
AttributeId ATTRIB_BASE = AttributeId("base",89);
|
||||
@@ -290,7 +292,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
@@ -277,7 +279,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
}
|
||||
}
|
||||
catch(LowlevelError &err) { // Name doesn't exist
|
||||
@@ -34,5 +34,5 @@ index bf4e1dc96..594b4583a 100644
|
||||
enddata = (const char *) tmpdata;
|
||||
if (enddata - s.c_str() == s.size()) { // If no size or offset override
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.48.1
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From 0feb881ef1cbc9aa4639e16914b7d9ed863baadf Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Tue, 29 Oct 2024 15:30:57 -0400
|
||||
Subject: [PATCH 3/6] Use string resize instead of reserve
|
||||
|
||||
assign will fix up the size to hold all of what's copied
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
index 5f5fa0c7b3..4cd77156f2 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
@@ -67,7 +67,6 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
|
||||
|
||||
{
|
||||
if (charsize == 1 && numChars < maximumChars) {
|
||||
- data.byteData.reserve(size);
|
||||
data.byteData.assign(buf,buf+size);
|
||||
}
|
||||
else {
|
||||
@@ -77,9 +76,9 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
|
||||
return;
|
||||
string resString = s.str();
|
||||
int4 newSize = resString.size();
|
||||
- data.byteData.reserve(newSize + 1);
|
||||
const uint1 *ptr = (const uint1 *)resString.c_str();
|
||||
data.byteData.assign(ptr,ptr+newSize);
|
||||
+ data.byteData.resize(newSize + 1, 0);
|
||||
data.byteData[newSize] = 0; // Make sure there is a null terminator
|
||||
}
|
||||
data.isTruncated = (numChars >= maximumChars);
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
From 2a8f30f31c24ecc7bd499648b97bb8b0c2705b78 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Tue, 29 Oct 2024 17:51:09 -0400
|
||||
Subject: [PATCH 4/6] Ignore floating point test due to compilation differences
|
||||
|
||||
This test fails on macOS and Windows. I'm unsure whether it's an OS or
|
||||
compiler issue.
|
||||
---
|
||||
.../Decompiler/src/decompile/unittests/testfloatemu.cc | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
index fe40e22b1b..91440e2510 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -184,7 +184,8 @@ TEST(double_decimal_precision) {
|
||||
double f0 = doubleFromRawBits(0x3fc5555555555555);
|
||||
ASSERT_EQUALS(ff.printDecimal(f0, false), "0.16666666666666666");
|
||||
double f1 = doubleFromRawBits(0x7fefffffffffffff);
|
||||
- ASSERT_EQUALS(ff.printDecimal(f1, false), "1.79769313486232e+308");
|
||||
+ // Windows and Mac print 1.7976931348623157e+308
|
||||
+ // ASSERT_EQUALS(ff.printDecimal(f1, false), "1.79769313486232e+308");
|
||||
double f2 = doubleFromRawBits(0x3fd555555c7dda4b);
|
||||
ASSERT_EQUALS(ff.printDecimal(f2, false), "0.33333334");
|
||||
double f3 = doubleFromRawBits(0x3fd0000000000000);
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From 04cca72897d9088713a6e2dadb2774ad20ae7703 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Wed, 30 Oct 2024 14:26:57 -0400
|
||||
Subject: [PATCH 5/6] Allow positive or negative NAN in decompiler floating
|
||||
point test
|
||||
|
||||
At least on Apple Silicon, this test reports positive NAN.
|
||||
|
||||
Use the regex optional operator '?' to allow for positive or negative
|
||||
NAN.
|
||||
---
|
||||
.../Decompiler/src/decompile/datatests/floatprint.xml | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml b/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml
|
||||
index f8108d3d32..1060a3e193 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml
|
||||
@@ -58,13 +58,13 @@ bbbdd7d9df7cdb3d000000000000f03f
|
||||
<stringmatch name="Float print #3" min="1" max="1">floatv3 = -0.001;</stringmatch>
|
||||
<stringmatch name="Float print #4" min="1" max="1">floatv4 = 1e-06;</stringmatch>
|
||||
<stringmatch name="Float print #5" min="1" max="1">floatv5 = INFINITY;</stringmatch>
|
||||
-<stringmatch name="Float print #6" min="1" max="1">floatv6 = -NAN;</stringmatch>
|
||||
+<stringmatch name="Float print #6" min="1" max="1">floatv6 = -?NAN;</stringmatch>
|
||||
<stringmatch name="Float print #7" min="1" max="1">floatv7 = 3.141592e-06;</stringmatch>
|
||||
<stringmatch name="Float print #8" min="1" max="1">double1 = 0.6666666666666666;</stringmatch>
|
||||
<stringmatch name="Float print #9" min="1" max="1">double2 = 2.0;</stringmatch>
|
||||
<stringmatch name="Float print #10" min="1" max="1">double3 = -0.001;</stringmatch>
|
||||
<stringmatch name="Float print #11" min="1" max="1">double4 = 1e-10;</stringmatch>
|
||||
<stringmatch name="Float print #12" min="1" max="1">double5 = INFINITY;</stringmatch>
|
||||
-<stringmatch name="Float print #13" min="1" max="1">double6 = -NAN;</stringmatch>
|
||||
+<stringmatch name="Float print #13" min="1" max="1">double6 = -?NAN;</stringmatch>
|
||||
<stringmatch name="Float print #14" min="1" max="1">double7 = 3.1415926535897933e-06;</stringmatch>
|
||||
</decompilertest>
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From a7dee0fbb1838e4e22a1c970718b84976ffb2932 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Sat, 8 Feb 2025 17:59:57 -0500
|
||||
Subject: [PATCH 6/6] decompiler: Fix strict weak ordering TypePartialEnum
|
||||
|
||||
This fixes Windows Debug error encountered in testing where it was
|
||||
complaining about lack of strict weak ordering.
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/type.cc | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index 7f654c220b..3f10c78c2f 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -2300,6 +2300,7 @@ int4 TypePartialEnum::compareDependency(const Datatype &op) const
|
||||
|
||||
{
|
||||
if (submeta != op.getSubMeta()) return (submeta < op.getSubMeta()) ? -1 : 1;
|
||||
+ if (parent == &op) return 1; // op is our TypeEnum
|
||||
TypePartialEnum *tp = (TypePartialEnum *) &op; // Both must be partial
|
||||
if (parent != tp->parent) return (parent < tp->parent) ? -1 : 1; // Compare absolute pointers
|
||||
if (offset != tp->offset) return (offset < tp->offset) ? -1 : 1;
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
From 0e437cb96249306d17f26ff6614871ecd9b37359 Mon Sep 17 00:00:00 2001
|
||||
From: "github-actions[bot]"
|
||||
<41898282+github-actions[bot]@users.noreply.github.com>
|
||||
Date: Wed, 2 Aug 2023 23:19:42 +1000
|
||||
Subject: [PATCH 1/2] Fix UBSAN errors in decompiler
|
||||
From 2eb1eb2999fb55204fdffb7469380dadb3e7a25a Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Mon, 12 Aug 2024 12:02:35 -0400
|
||||
Subject: [PATCH 1/6] Fix UBSAN errors in decompiler
|
||||
|
||||
Co-authored-by: Alex Cameron <asc@tetsuo.sh>
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
|
||||
.../src/decompile/cpp/funcdata_varnode.cc | 8 +++++++-
|
||||
.../Decompiler/src/decompile/cpp/op.cc | 6 +++++-
|
||||
.../Decompiler/src/decompile/cpp/opbehavior.cc | 8 +++++++-
|
||||
.../src/decompile/cpp/pcodecompile.cc | 18 +++++++++++-------
|
||||
.../Decompiler/src/decompile/cpp/ruleaction.cc | 18 ++++++++++++++----
|
||||
.../Decompiler/src/decompile/cpp/ruleaction.cc | 12 +++++++++---
|
||||
.../Decompiler/src/decompile/cpp/semantics.cc | 2 ++
|
||||
.../Decompiler/src/decompile/cpp/semantics.hh | 2 +-
|
||||
.../src/decompile/cpp/slgh_compile.cc | 2 +-
|
||||
.../Decompiler/src/decompile/cpp/slghsymbol.cc | 2 +-
|
||||
.../Decompiler/src/decompile/cpp/type.cc | 2 +-
|
||||
.../src/decompile/unittests/testfloatemu.cc | 2 +-
|
||||
12 files changed, 57 insertions(+), 21 deletions(-)
|
||||
10 files changed, 44 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
index 8380d3cd..a18d5007 100644
|
||||
index cafce3f7ba..b696fe6879 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
@@ -2661,8 +2661,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
@@ -2893,8 +2893,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
modellist.push_back(mymodel);
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
@@ -38,30 +36,11 @@ index 8380d3cd..a18d5007 100644
|
||||
}
|
||||
|
||||
void ParameterBasic::setTypeLock(bool val)
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
index f7781707..283d81c3 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
@@ -503,7 +503,13 @@ void Funcdata::setHighLevel(void)
|
||||
void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset)
|
||||
|
||||
{
|
||||
- uintb newConsume = (vn->getConsume() >> 8*lsbOffset) & calc_mask(newVn->getSize());
|
||||
+ uintb newConsume = vn->getConsume();
|
||||
+ if (8*lsbOffset < sizeof(newConsume)) {
|
||||
+ newConsume >>= 8*lsbOffset;
|
||||
+ } else {
|
||||
+ newConsume = 0;
|
||||
+ }
|
||||
+ newConsume &= calc_mask(newVn->getSize());
|
||||
|
||||
uint4 vnFlags = vn->getFlags() & (Varnode::directwrite|Varnode::addrforce);
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
index 0e3decc8..403ec35a 100644
|
||||
index a62ee56fc3..66bcd48db0 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
@@ -672,7 +672,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
@@ -666,7 +666,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
break;
|
||||
case CPUI_PIECE:
|
||||
resmask = getIn(0)->getNZMask();
|
||||
@@ -75,10 +54,10 @@ index 0e3decc8..403ec35a 100644
|
||||
break;
|
||||
case CPUI_INT_MULT:
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
index fcd75cc7..ed0e005a 100644
|
||||
index aebcfd9103..6c47e6eb15 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
@@ -750,7 +750,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
@@ -746,7 +746,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
uintb OpBehaviorSubpiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const
|
||||
|
||||
{
|
||||
@@ -94,7 +73,7 @@ index fcd75cc7..ed0e005a 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
index ca9d71ab..85d4dd28 100644
|
||||
index ca9d71ab99..85d4dd281d 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
@@ -621,8 +621,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
@@ -137,7 +116,7 @@ index ca9d71ab..85d4dd28 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
index 4851365d..d069d1c9 100644
|
||||
index 8df64ca548..1bd96ea3df 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -154,7 +133,7 @@ index 4851365d..d069d1c9 100644
|
||||
consume = ~consume;
|
||||
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
|
||||
|
||||
@@ -6782,8 +6787,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -7298,8 +7303,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *sb = op->getIn(0);
|
||||
Datatype *sbType = sb->getTypeReadFacing(op);
|
||||
if (sbType->getMetatype() != TYPE_PTR) return 0;
|
||||
@@ -166,21 +145,8 @@ index 4851365d..d069d1c9 100644
|
||||
Varnode *vn1 = op->getIn(1);
|
||||
if (!vn1->isConstant()) return 0;
|
||||
Varnode *outvn = op->getOut();
|
||||
@@ -8593,7 +8599,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 flowsize = outvn->getSize();
|
||||
uintb mask = calc_mask( flowsize );
|
||||
- mask <<= 8*((int4)op->getIn(1)->getOffset());
|
||||
+ if (8*((int4)op->getIn(1)->getOffset()) < sizeof(mask)) {
|
||||
+ mask <<= 8*((int4)op->getIn(1)->getOffset());
|
||||
+ } else {
|
||||
+ mask = 0;
|
||||
+ }
|
||||
bool aggressive = outvn->isPtrFlow();
|
||||
if (!aggressive) {
|
||||
if ((vn->getConsume() & mask) != vn->getConsume()) return 0;
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
index 2e3531ea..42482be7 100644
|
||||
index cd9b9835b1..8a4616c3b9 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
@@ -22,6 +22,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
@@ -200,12 +166,12 @@ index 2e3531ea..42482be7 100644
|
||||
|
||||
bool ConstTpl::isConstSpace(void) const
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
index 8e283dca..652600c1 100644
|
||||
index e0b069959d..9117a45c75 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
static void printHandleSelector(ostream &s,v_field val);
|
||||
static v_field readHandleSelector(const string &name);
|
||||
@@ -47,7 +47,7 @@ class ConstTpl {
|
||||
uintb value_real;
|
||||
v_field select; // Which part of handle to use as constant
|
||||
public:
|
||||
- ConstTpl(void) { type = real; value_real = 0; }
|
||||
+ ConstTpl(void) { type = real; value_real = 0; select = v_space; }
|
||||
@@ -213,10 +179,10 @@ index 8e283dca..652600c1 100644
|
||||
type=op2.type; value=op2.value; value_real=op2.value_real; select=op2.select; }
|
||||
ConstTpl(const_type tp,uintb val);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
index b40f7438..3c37958d 100644
|
||||
index 50d85e22ba..9f3b456229 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
@@ -2163,8 +2163,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
@@ -2164,8 +2164,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
ostringstream msg;
|
||||
SymbolTree::const_iterator iter;
|
||||
for(iter=scope->begin();iter!=scope->end();++iter) {
|
||||
@@ -226,24 +192,11 @@ index b40f7438..3c37958d 100644
|
||||
if (sym->getRefCount() == 0)
|
||||
msg << " Label <" << sym->getName() << "> was placed but not used" << endl;
|
||||
else if (!sym->isPlaced())
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
index b308e1b7..af2982ae 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
@@ -2569,7 +2569,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
const List &list(el->getChildren());
|
||||
List::const_iterator iter;
|
||||
iter = list.begin();
|
||||
- patexp = (PatternValue *)PatternExpression::restoreExpression(*iter,trans);
|
||||
+ patexp = PatternExpression::restoreExpression(*iter,trans);
|
||||
patexp->layClaim();
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index 30faf0b6..e76a0619 100644
|
||||
index f00502ba65..7ff2ab7606 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -3359,8 +3359,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
@@ -3731,8 +3731,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
top.submeta = sub; // Search on the incorrect submeta
|
||||
iter = tree.lower_bound(&top);
|
||||
while(iter != tree.end()) {
|
||||
@@ -254,10 +207,10 @@ index 30faf0b6..e76a0619 100644
|
||||
++iter;
|
||||
if (ptr->submeta == sub) {
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
index c35bde87..061e5367 100644
|
||||
index 2571f55f1a..fe40e22b1b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -346,7 +346,7 @@ TEST(float_opTrunc_to_int) {
|
||||
@@ -375,7 +375,7 @@ TEST(float_opTrunc_to_int) {
|
||||
|
||||
for(float f:float_test_values) {
|
||||
// avoid undefined behavior
|
||||
@@ -267,5 +220,5 @@ index c35bde87..061e5367 100644
|
||||
uintb true_result = ((uintb)(int32_t)f) & 0xffffffff;
|
||||
uintb encoding = format.getEncoding(f);
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.50.1
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
From 95f230f46bdb95aa4aab7f5d320691f87107fb36 Mon Sep 17 00:00:00 2001
|
||||
From: "github-actions[bot]"
|
||||
<41898282+github-actions[bot]@users.noreply.github.com>
|
||||
Date: Wed, 2 Aug 2023 23:20:14 +1000
|
||||
Subject: [PATCH 2/2] Use `stroull` instead of `stroul` to parse address
|
||||
From da383f3b96085349e80b4de6fcb3ed7e88a00a05 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Wed, 3 Aug 2022 20:01:18 +1000
|
||||
Subject: [PATCH 2/6] Use `stroull` instead of `stroul` to parse address
|
||||
offsets
|
||||
|
||||
---
|
||||
@@ -10,7 +9,7 @@ Subject: [PATCH 2/2] Use `stroull` instead of `stroul` to parse address
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
index bf4e1dc9..594b4583 100644
|
||||
index dbaa2e775f..72927bf379 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
@@ -16,6 +16,8 @@
|
||||
@@ -22,7 +21,7 @@ index bf4e1dc9..594b4583 100644
|
||||
namespace ghidra {
|
||||
|
||||
AttributeId ATTRIB_BASE = AttributeId("base",89);
|
||||
@@ -290,7 +292,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
@@ -277,7 +279,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
}
|
||||
}
|
||||
catch(LowlevelError &err) { // Name doesn't exist
|
||||
@@ -35,5 +34,5 @@ index bf4e1dc9..594b4583 100644
|
||||
enddata = (const char *) tmpdata;
|
||||
if (enddata - s.c_str() == s.size()) { // If no size or offset override
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.50.1
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From 61ab4b5c63c33aa7c522f6e217e7ab9e01c0b956 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Tue, 29 Oct 2024 15:30:57 -0400
|
||||
Subject: [PATCH 3/6] Use string resize instead of reserve
|
||||
|
||||
assign will fix up the size to hold all of what's copied
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
index 5f5fa0c7b3..4cd77156f2 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
@@ -67,7 +67,6 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
|
||||
|
||||
{
|
||||
if (charsize == 1 && numChars < maximumChars) {
|
||||
- data.byteData.reserve(size);
|
||||
data.byteData.assign(buf,buf+size);
|
||||
}
|
||||
else {
|
||||
@@ -77,9 +76,9 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
|
||||
return;
|
||||
string resString = s.str();
|
||||
int4 newSize = resString.size();
|
||||
- data.byteData.reserve(newSize + 1);
|
||||
const uint1 *ptr = (const uint1 *)resString.c_str();
|
||||
data.byteData.assign(ptr,ptr+newSize);
|
||||
+ data.byteData.resize(newSize + 1, 0);
|
||||
data.byteData[newSize] = 0; // Make sure there is a null terminator
|
||||
}
|
||||
data.isTruncated = (numChars >= maximumChars);
|
||||
--
|
||||
2.50.1
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
From af4f89efce38c924bfc342dfa51507a03177fcf4 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Tue, 29 Oct 2024 17:51:09 -0400
|
||||
Subject: [PATCH 4/6] Ignore floating point test due to compilation differences
|
||||
|
||||
This test fails on macOS and Windows. I'm unsure whether it's an OS or
|
||||
compiler issue.
|
||||
---
|
||||
.../Decompiler/src/decompile/unittests/testfloatemu.cc | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
index fe40e22b1b..91440e2510 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -184,7 +184,8 @@ TEST(double_decimal_precision) {
|
||||
double f0 = doubleFromRawBits(0x3fc5555555555555);
|
||||
ASSERT_EQUALS(ff.printDecimal(f0, false), "0.16666666666666666");
|
||||
double f1 = doubleFromRawBits(0x7fefffffffffffff);
|
||||
- ASSERT_EQUALS(ff.printDecimal(f1, false), "1.79769313486232e+308");
|
||||
+ // Windows and Mac print 1.7976931348623157e+308
|
||||
+ // ASSERT_EQUALS(ff.printDecimal(f1, false), "1.79769313486232e+308");
|
||||
double f2 = doubleFromRawBits(0x3fd555555c7dda4b);
|
||||
ASSERT_EQUALS(ff.printDecimal(f2, false), "0.33333334");
|
||||
double f3 = doubleFromRawBits(0x3fd0000000000000);
|
||||
--
|
||||
2.50.1
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From 997a83bdf0c562bcc110682177937b0a3f386fdc Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Wed, 30 Oct 2024 14:26:57 -0400
|
||||
Subject: [PATCH 5/6] Allow positive or negative NAN in decompiler floating
|
||||
point test
|
||||
|
||||
At least on Apple Silicon, this test reports positive NAN.
|
||||
|
||||
Use the regex optional operator '?' to allow for positive or negative
|
||||
NAN.
|
||||
---
|
||||
.../Decompiler/src/decompile/datatests/floatprint.xml | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml b/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml
|
||||
index f8108d3d32..1060a3e193 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/datatests/floatprint.xml
|
||||
@@ -58,13 +58,13 @@ bbbdd7d9df7cdb3d000000000000f03f
|
||||
<stringmatch name="Float print #3" min="1" max="1">floatv3 = -0.001;</stringmatch>
|
||||
<stringmatch name="Float print #4" min="1" max="1">floatv4 = 1e-06;</stringmatch>
|
||||
<stringmatch name="Float print #5" min="1" max="1">floatv5 = INFINITY;</stringmatch>
|
||||
-<stringmatch name="Float print #6" min="1" max="1">floatv6 = -NAN;</stringmatch>
|
||||
+<stringmatch name="Float print #6" min="1" max="1">floatv6 = -?NAN;</stringmatch>
|
||||
<stringmatch name="Float print #7" min="1" max="1">floatv7 = 3.141592e-06;</stringmatch>
|
||||
<stringmatch name="Float print #8" min="1" max="1">double1 = 0.6666666666666666;</stringmatch>
|
||||
<stringmatch name="Float print #9" min="1" max="1">double2 = 2.0;</stringmatch>
|
||||
<stringmatch name="Float print #10" min="1" max="1">double3 = -0.001;</stringmatch>
|
||||
<stringmatch name="Float print #11" min="1" max="1">double4 = 1e-10;</stringmatch>
|
||||
<stringmatch name="Float print #12" min="1" max="1">double5 = INFINITY;</stringmatch>
|
||||
-<stringmatch name="Float print #13" min="1" max="1">double6 = -NAN;</stringmatch>
|
||||
+<stringmatch name="Float print #13" min="1" max="1">double6 = -?NAN;</stringmatch>
|
||||
<stringmatch name="Float print #14" min="1" max="1">double7 = 3.1415926535897933e-06;</stringmatch>
|
||||
</decompilertest>
|
||||
--
|
||||
2.50.1
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From 7de365659e8a4068106c43eeb7e7dd923726a9e2 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Sat, 8 Feb 2025 17:59:57 -0500
|
||||
Subject: [PATCH 6/6] decompiler: Fix strict weak ordering TypePartialEnum
|
||||
|
||||
This fixes Windows Debug error encountered in testing where it was
|
||||
complaining about lack of strict weak ordering.
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/type.cc | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index 7ff2ab7606..aa96671bcd 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -2303,6 +2303,7 @@ int4 TypePartialEnum::compareDependency(const Datatype &op) const
|
||||
|
||||
{
|
||||
if (submeta != op.getSubMeta()) return (submeta < op.getSubMeta()) ? -1 : 1;
|
||||
+ if (parent == &op) return 1; // op is our TypeEnum
|
||||
TypePartialEnum *tp = (TypePartialEnum *) &op; // Both must be partial
|
||||
if (parent != tp->parent) return (parent < tp->parent) ? -1 : 1; // Compare absolute pointers
|
||||
if (offset != tp->offset) return (offset < tp->offset) ? -1 : 1;
|
||||
--
|
||||
2.50.1
|
||||
|
||||
@@ -22,7 +22,7 @@ set_property(CACHE sleigh_RELEASE_TYPE PROPERTY STRINGS "stable" "HEAD")
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
# Ghidra pinned stable version commit
|
||||
set(ghidra_version "10.3.2")
|
||||
set(ghidra_version "11.4.1")
|
||||
set(ghidra_git_tag "Ghidra_${ghidra_version}_build")
|
||||
set(ghidra_shallow TRUE)
|
||||
|
||||
@@ -40,15 +40,19 @@ set(ghidra_patches
|
||||
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0001-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0003-Use-string-resize-instead-of-reserve.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0004-Ignore-floating-point-test-due-to-compilation-differ.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0005-Allow-positive-or-negative-NAN-in-decompiler-floatin.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0006-decompiler-Fix-strict-weak-ordering-TypePartialEnum.patch"
|
||||
)
|
||||
|
||||
# Ghidra pinned commits used for pinning last known working HEAD commit
|
||||
if("${sleigh_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_head_version "10.4")
|
||||
set(ghidra_head_version "12.0")
|
||||
set(ghidra_version "${ghidra_head_version}")
|
||||
set(ghidra_head_git_tag "b0e0c7372af0236f3dd809ee19e35e01b437b770")
|
||||
set(ghidra_head_git_tag "7e6c01f283be9cd5f0d8f0dfd126ad1674d8bde7")
|
||||
set(ghidra_git_tag "${ghidra_head_git_tag}")
|
||||
set(ghidra_shallow FALSE)
|
||||
set(ghidra_patches
|
||||
@@ -57,6 +61,10 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-Use-string-resize-instead-of-reserve.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0004-Ignore-floating-point-test-due-to-compilation-differ.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0005-Allow-positive-or-negative-NAN-in-decompiler-floatin.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0006-decompiler-Fix-strict-weak-ordering-TypePartialEnum.patch"
|
||||
)
|
||||
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
|
||||
else()
|
||||
@@ -162,6 +170,10 @@ set(sleigh_deccore_source_list
|
||||
"${library_root}/opbehavior.cc"
|
||||
"${library_root}/paramid.cc"
|
||||
"${library_root}/unionresolve.cc"
|
||||
"${library_root}/modelrules.cc"
|
||||
"${library_root}/signature.cc"
|
||||
"${library_root}/multiprecision.cc"
|
||||
"${library_root}/constseq.cc"
|
||||
)
|
||||
#if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# list(APPEND sleigh_deccore_source_list
|
||||
@@ -195,7 +207,13 @@ set(sleigh_source_list
|
||||
"${library_root}/semantics.cc"
|
||||
"${library_root}/context.cc"
|
||||
"${library_root}/filemanage.cc"
|
||||
"${library_root}/slaformat.cc"
|
||||
"${library_root}/compression.cc"
|
||||
)
|
||||
# if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# list(APPEND sleigh_source_list
|
||||
# )
|
||||
# endif()
|
||||
|
||||
set(sleigh_ghidra_source_list
|
||||
"${library_root}/ghidra_arch.cc"
|
||||
@@ -209,7 +227,12 @@ set(sleigh_ghidra_source_list
|
||||
"${library_root}/ghidra_process.cc"
|
||||
"${library_root}/comment_ghidra.cc"
|
||||
"${library_root}/string_ghidra.cc"
|
||||
"${library_root}/signature_ghidra.cc"
|
||||
)
|
||||
# if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# list(APPEND sleigh_ghidra_source_list
|
||||
# )
|
||||
# endif()
|
||||
|
||||
set(sleigh_slacomp_source_list
|
||||
"${library_root}/slgh_compile.cc"
|
||||
|
||||
@@ -28,6 +28,8 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM7_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8m_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8m_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr32a.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8e.slaspec"
|
||||
@@ -57,6 +59,12 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/HCS12/data/languages/HCS12.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/HCS12/data/languages/HCS12X.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/JVM/data/languages/JVM.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch32_f32.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch32_f64.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch64_f32.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch64_f64.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/M16C/data/languages/M16C_60.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/M16C/data/languages/M16C_80.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/M8C/data/languages/m8c.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MC6800/data/languages/6805.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MC6800/data/languages/6809.slaspec"
|
||||
@@ -87,6 +95,8 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_quicciii_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_quicciii_le.slaspec"
|
||||
@@ -122,6 +132,8 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_wsz_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_wsz_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/V850/data/languages/V850.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Xtensa/data/languages/xtensa_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Xtensa/data/languages/xtensa_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Z80/data/languages/z180.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Z80/data/languages/z80.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/eBPF/data/languages/eBPF_le.slaspec"
|
||||
|
||||
@@ -28,6 +28,8 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM7_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8m_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/ARM/data/languages/ARM8m_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr32a.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8e.slaspec"
|
||||
@@ -57,6 +59,12 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/HCS12/data/languages/HCS12.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/HCS12/data/languages/HCS12X.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/JVM/data/languages/JVM.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch32_f32.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch32_f64.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch64_f32.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Loongarch/data/languages/loongarch64_f64.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/M16C/data/languages/M16C_60.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/M16C/data/languages/M16C_80.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/M8C/data/languages/m8c.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MC6800/data/languages/6805.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MC6800/data/languages/6809.slaspec"
|
||||
@@ -87,6 +95,8 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_quicciii_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_32_quicciii_le.slaspec"
|
||||
@@ -122,6 +132,8 @@ set(spec_file_list
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_wsz_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_wsz_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/V850/data/languages/V850.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Xtensa/data/languages/xtensa_be.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Xtensa/data/languages/xtensa_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Z80/data/languages/z180.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Z80/data/languages/z80.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/eBPF/data/languages/eBPF_le.slaspec"
|
||||
|
||||
+113
-102
@@ -15,110 +15,121 @@
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
#include <sleigh/action.hh>
|
||||
#include <sleigh/address.hh>
|
||||
#include <sleigh/architecture.hh>
|
||||
#include <sleigh/block.hh>
|
||||
#include <sleigh/blockaction.hh>
|
||||
#include <sleigh/callgraph.hh>
|
||||
#include <sleigh/capability.hh>
|
||||
#include <sleigh/cast.hh>
|
||||
#include <sleigh/codedata.hh>
|
||||
#include <sleigh/comment.hh>
|
||||
#include <sleigh/comment_ghidra.hh>
|
||||
#include <sleigh/condexe.hh>
|
||||
#include <sleigh/context.hh>
|
||||
#include <sleigh/coreaction.hh>
|
||||
#include <sleigh/cover.hh>
|
||||
#include <sleigh/cpool.hh>
|
||||
#include <sleigh/cpool_ghidra.hh>
|
||||
#include <sleigh/crc32.hh>
|
||||
#include <sleigh/database.hh>
|
||||
#include <sleigh/database_ghidra.hh>
|
||||
#include <sleigh/doccore.hh>
|
||||
#include <sleigh/docmain.hh>
|
||||
#include <sleigh/double.hh>
|
||||
#include <sleigh/dynamic.hh>
|
||||
#include <sleigh/emulate.hh>
|
||||
#include <sleigh/emulateutil.hh>
|
||||
#include <sleigh/error.hh>
|
||||
#include <sleigh/filemanage.hh>
|
||||
#include <sleigh/float.hh>
|
||||
#include <sleigh/flow.hh>
|
||||
#include <sleigh/fspec.hh>
|
||||
#include <sleigh/funcdata.hh>
|
||||
#include <sleigh/ghidra_arch.hh>
|
||||
#include <sleigh/ghidra_context.hh>
|
||||
#include <sleigh/ghidra_process.hh>
|
||||
#include <sleigh/ghidra_translate.hh>
|
||||
#include <sleigh/globalcontext.hh>
|
||||
#include <sleigh/grammar.hh>
|
||||
#include <sleigh/graph.hh>
|
||||
#include <sleigh/heritage.hh>
|
||||
#include <sleigh/ifacedecomp.hh>
|
||||
#include <sleigh/ifaceterm.hh>
|
||||
#include <sleigh/inject_ghidra.hh>
|
||||
#include <sleigh/inject_sleigh.hh>
|
||||
#include <sleigh/interface.hh>
|
||||
#include <sleigh/jumptable.hh>
|
||||
#include <sleigh/libdecomp.hh>
|
||||
#include <sleigh/loadimage.hh>
|
||||
#include <sleigh/loadimage_ghidra.hh>
|
||||
#include <sleigh/loadimage_xml.hh>
|
||||
#include <sleigh/memstate.hh>
|
||||
#include <sleigh/merge.hh>
|
||||
#include <sleigh/op.hh>
|
||||
#include <sleigh/opbehavior.hh>
|
||||
#include <sleigh/opcodes.hh>
|
||||
#include <sleigh/options.hh>
|
||||
#include <sleigh/override.hh>
|
||||
#include <sleigh/paramid.hh>
|
||||
#include <sleigh/partmap.hh>
|
||||
#include <sleigh/pcodecompile.hh>
|
||||
#include <sleigh/pcodeinject.hh>
|
||||
#include <sleigh/pcodeparse.hh>
|
||||
#include <sleigh/pcoderaw.hh>
|
||||
#include <sleigh/prefersplit.hh>
|
||||
#include <sleigh/prettyprint.hh>
|
||||
#include <sleigh/printc.hh>
|
||||
#include <sleigh/printjava.hh>
|
||||
#include <sleigh/printlanguage.hh>
|
||||
#include <sleigh/rangemap.hh>
|
||||
#include <sleigh/rangeutil.hh>
|
||||
#include <sleigh/raw_arch.hh>
|
||||
#include <sleigh/ruleaction.hh>
|
||||
#include <sleigh/rulecompile.hh>
|
||||
#include <sleigh/semantics.hh>
|
||||
#include <sleigh/sleigh.hh>
|
||||
#include <sleigh/sleigh_arch.hh>
|
||||
#include <sleigh/sleighbase.hh>
|
||||
#include <sleigh/slgh_compile.hh>
|
||||
#include <ghidra/action.hh>
|
||||
#include <ghidra/address.hh>
|
||||
#include <ghidra/architecture.hh>
|
||||
#include <ghidra/block.hh>
|
||||
#include <ghidra/blockaction.hh>
|
||||
#include <ghidra/callgraph.hh>
|
||||
#include <ghidra/capability.hh>
|
||||
#include <ghidra/cast.hh>
|
||||
#include <ghidra/codedata.hh>
|
||||
#include <ghidra/comment.hh>
|
||||
#include <ghidra/comment_ghidra.hh>
|
||||
#include <ghidra/condexe.hh>
|
||||
#include <ghidra/context.hh>
|
||||
#include <ghidra/coreaction.hh>
|
||||
#include <ghidra/cover.hh>
|
||||
#include <ghidra/cpool.hh>
|
||||
#include <ghidra/cpool_ghidra.hh>
|
||||
#include <ghidra/crc32.hh>
|
||||
#include <ghidra/database.hh>
|
||||
#include <ghidra/database_ghidra.hh>
|
||||
#include <ghidra/doccore.hh>
|
||||
#include <ghidra/docmain.hh>
|
||||
#include <ghidra/double.hh>
|
||||
#include <ghidra/dynamic.hh>
|
||||
#include <ghidra/emulate.hh>
|
||||
#include <ghidra/emulateutil.hh>
|
||||
#include <ghidra/error.hh>
|
||||
#include <ghidra/filemanage.hh>
|
||||
#include <ghidra/float.hh>
|
||||
#include <ghidra/flow.hh>
|
||||
#include <ghidra/fspec.hh>
|
||||
#include <ghidra/funcdata.hh>
|
||||
#include <ghidra/ghidra_arch.hh>
|
||||
#include <ghidra/ghidra_context.hh>
|
||||
#include <ghidra/ghidra_process.hh>
|
||||
#include <ghidra/ghidra_translate.hh>
|
||||
#include <ghidra/globalcontext.hh>
|
||||
#include <ghidra/grammar.hh>
|
||||
#include <ghidra/graph.hh>
|
||||
#include <ghidra/heritage.hh>
|
||||
#include <ghidra/ifacedecomp.hh>
|
||||
#include <ghidra/ifaceterm.hh>
|
||||
#include <ghidra/inject_ghidra.hh>
|
||||
#include <ghidra/inject_sleigh.hh>
|
||||
#include <ghidra/interface.hh>
|
||||
#include <ghidra/jumptable.hh>
|
||||
#include <ghidra/libdecomp.hh>
|
||||
#include <ghidra/loadimage.hh>
|
||||
#include <ghidra/loadimage_ghidra.hh>
|
||||
#include <ghidra/loadimage_xml.hh>
|
||||
#include <ghidra/memstate.hh>
|
||||
#include <ghidra/merge.hh>
|
||||
#include <ghidra/op.hh>
|
||||
#include <ghidra/opbehavior.hh>
|
||||
#include <ghidra/opcodes.hh>
|
||||
#include <ghidra/options.hh>
|
||||
#include <ghidra/override.hh>
|
||||
#include <ghidra/paramid.hh>
|
||||
#include <ghidra/partmap.hh>
|
||||
#include <ghidra/pcodecompile.hh>
|
||||
#include <ghidra/pcodeinject.hh>
|
||||
#include <ghidra/pcodeparse.hh>
|
||||
#include <ghidra/pcoderaw.hh>
|
||||
#include <ghidra/prefersplit.hh>
|
||||
#include <ghidra/prettyprint.hh>
|
||||
#include <ghidra/printc.hh>
|
||||
#include <ghidra/printjava.hh>
|
||||
#include <ghidra/printlanguage.hh>
|
||||
#include <ghidra/rangemap.hh>
|
||||
#include <ghidra/rangeutil.hh>
|
||||
#include <ghidra/raw_arch.hh>
|
||||
#include <ghidra/ruleaction.hh>
|
||||
#include <ghidra/rulecompile.hh>
|
||||
#include <ghidra/semantics.hh>
|
||||
#include <ghidra/sleigh.hh>
|
||||
#include <ghidra/sleigh_arch.hh>
|
||||
#include <ghidra/sleighbase.hh>
|
||||
#include <ghidra/slgh_compile.hh>
|
||||
// This is required because slghparse.hh does not have a namespace block
|
||||
namespace ghidra {
|
||||
#include <sleigh/slghparse.hh>
|
||||
#include <ghidra/slghparse.hh>
|
||||
} // End namespace ghidra
|
||||
#include <sleigh/slghpatexpress.hh>
|
||||
#include <sleigh/slghpattern.hh>
|
||||
#include <sleigh/slghsymbol.hh>
|
||||
#include <sleigh/space.hh>
|
||||
#include <sleigh/string_ghidra.hh>
|
||||
#include <sleigh/stringmanage.hh>
|
||||
#include <sleigh/subflow.hh>
|
||||
#include <sleigh/testfunction.hh>
|
||||
#include <sleigh/transform.hh>
|
||||
#include <sleigh/translate.hh>
|
||||
#include <sleigh/type.hh>
|
||||
#include <sleigh/typegrp_ghidra.hh>
|
||||
#include <sleigh/typeop.hh>
|
||||
#include <sleigh/types.h>
|
||||
#include <sleigh/unify.hh>
|
||||
#include <sleigh/userop.hh>
|
||||
#include <sleigh/variable.hh>
|
||||
#include <sleigh/varmap.hh>
|
||||
#include <sleigh/varnode.hh>
|
||||
#include <sleigh/xml.hh>
|
||||
#include <sleigh/xml_arch.hh>
|
||||
#include <sleigh/unionresolve.hh>
|
||||
#include <sleigh/marshal.hh>
|
||||
#include <ghidra/slghpatexpress.hh>
|
||||
#include <ghidra/slghpattern.hh>
|
||||
#include <ghidra/slghsymbol.hh>
|
||||
#include <ghidra/space.hh>
|
||||
#include <ghidra/string_ghidra.hh>
|
||||
#include <ghidra/stringmanage.hh>
|
||||
#include <ghidra/subflow.hh>
|
||||
#include <ghidra/testfunction.hh>
|
||||
#include <ghidra/transform.hh>
|
||||
#include <ghidra/translate.hh>
|
||||
#include <ghidra/type.hh>
|
||||
#include <ghidra/typegrp_ghidra.hh>
|
||||
#include <ghidra/typeop.hh>
|
||||
#include <ghidra/types.h>
|
||||
#include <ghidra/unify.hh>
|
||||
#include <ghidra/userop.hh>
|
||||
#include <ghidra/variable.hh>
|
||||
#include <ghidra/varmap.hh>
|
||||
#include <ghidra/varnode.hh>
|
||||
#include <ghidra/xml.hh>
|
||||
#include <ghidra/xml_arch.hh>
|
||||
#include <ghidra/unionresolve.hh>
|
||||
#include <ghidra/marshal.hh>
|
||||
#include <ghidra/analyzesigs.hh>
|
||||
#include <ghidra/modelrules.hh>
|
||||
#include <ghidra/signature.hh>
|
||||
#include <ghidra/signature_ghidra.hh>
|
||||
#include <ghidra/compression.hh>
|
||||
#include <ghidra/multiprecision.hh>
|
||||
#include <ghidra/slaformat.hh>
|
||||
|
||||
// #ifdef sleigh_RELEASE_IS_HEAD
|
||||
// #endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -23,6 +23,7 @@ add_executable(sleigh_ghidra_test
|
||||
"${library_root}/../unittests/testfuncproto.cc"
|
||||
"${library_root}/../unittests/testtypes.cc"
|
||||
"${library_root}/../unittests/testmarshal.cc"
|
||||
"${library_root}/../unittests/testparamstore.cc"
|
||||
)
|
||||
|
||||
# if(sleigh_RELEASE_IS_HEAD)
|
||||
@@ -41,6 +42,8 @@ if(HAVE_TERMIOS_H)
|
||||
endif()
|
||||
sleigh_add_optional_defines(sleigh_ghidra_test PRIVATE)
|
||||
|
||||
target_link_libraries(sleigh_ghidra_test PRIVATE ZLIB::ZLIB)
|
||||
|
||||
add_test(
|
||||
NAME sleigh_ghidra_unittest
|
||||
COMMAND sleigh_ghidra_test -sleighpath "${PROJECT_BINARY_DIR}" unittests
|
||||
|
||||
@@ -50,6 +50,9 @@ set_target_properties(sleigh_decompiler PROPERTIES
|
||||
OUTPUT_NAME_DEBUG decomp_dbg
|
||||
)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(sleigh_decompiler PRIVATE ZLIB::ZLIB)
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include("GNUInstallDirs")
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ set_target_properties(sleigh_ghidra PROPERTIES
|
||||
OUTPUT_NAME_DEBUG ghidra_dbg
|
||||
)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(sleigh_ghidra PRIVATE ZLIB::ZLIB)
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include("GNUInstallDirs")
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ set_target_properties(sleigh_sleigh PROPERTIES
|
||||
OUTPUT_NAME_DEBUG sleigh_dbg
|
||||
)
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(sleigh_sleigh PRIVATE ZLIB::ZLIB)
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include("GNUInstallDirs")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user