mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 393ed42fc6 | |||
| 57e6d7c79d | |||
| 8c5b8049a6 | |||
| 7b1232ec99 | |||
| f9a4905c31 | |||
| ff5929e1fc | |||
| 844e5e07fe | |||
| 51bd95f360 | |||
| f63b99a700 | |||
| f1d1eab45f | |||
| 83ae3b5dfe | |||
| 548b28c67d | |||
| f23739ee3f | |||
| c8cb034afb | |||
| 384d7de32a | |||
| d75230a7bc | |||
| 7e9641e394 | |||
| 37b2cbcf1c | |||
| 7c6b742446 | |||
| b3669ea4bd | |||
| e1562dd87f | |||
| 262f8d8421 | |||
| ef4e13d243 | |||
| 6d6335b2c5 | |||
| 6f03e21e23 | |||
| cae987f993 | |||
| c3564b1e3e | |||
| 259bccedf0 | |||
| ddfe4bff8e | |||
| 186b4fe693 | |||
| 487732a026 | |||
| 2c197599aa | |||
| 316c91ccfb | |||
| b80fefc001 | |||
| d3ca7d78d6 | |||
| 7a045dd5e8 | |||
| f12acdfd99 | |||
| 97933e2ffe | |||
| 4b225d9317 | |||
| a130f452ac | |||
| df7b7c4ff2 | |||
| ded4e6ac03 | |||
| a4e41c9b35 | |||
| 56f3346c60 |
+48
-27
@@ -3,15 +3,15 @@ name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- "*"
|
||||
|
||||
# Version tags should start with "v"
|
||||
tags:
|
||||
- 'v*'
|
||||
- "v*"
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -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
|
||||
@@ -51,21 +51,23 @@ jobs:
|
||||
|
||||
- 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
|
||||
vcpkg install zlib:x64-windows-static
|
||||
|
||||
- name: Generate cache key
|
||||
shell: cmake -P {0}
|
||||
run: |
|
||||
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_KEY=build_${{ matrix.os }}_type-${{ matrix.build_type }}-${{ matrix.release }}")
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_TIMESTAMP=${current_date}")
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_KEY=build_${{ matrix.os }}_type-${{ matrix.build_type }}-${{ matrix.release }}\n")
|
||||
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 }}
|
||||
@@ -107,6 +109,10 @@ jobs:
|
||||
-j 2
|
||||
-v
|
||||
|
||||
- name: Test the project
|
||||
working-directory: build
|
||||
run: ctest -VV -C ${{ matrix.build_type }}
|
||||
|
||||
- name: Build the docs
|
||||
run: cmake
|
||||
--build build
|
||||
@@ -127,17 +133,30 @@ 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 }}
|
||||
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 2 --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 }}
|
||||
@@ -145,6 +164,17 @@ jobs:
|
||||
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 2 --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
|
||||
@@ -182,13 +212,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.14
|
||||
uses: softprops/action-gh-release@v2.0.4
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
||||
with:
|
||||
files: ${{ env.DEB_PACKAGE_PATH }}
|
||||
@@ -196,12 +226,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.14
|
||||
uses: softprops/action-gh-release@v2.0.4
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
||||
with:
|
||||
files: ${{ env.RPM_PACKAGE_PATH }}
|
||||
@@ -209,25 +239,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.14
|
||||
uses: softprops/action-gh-release@v2.0.4
|
||||
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,9 +12,9 @@ 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'
|
||||
@@ -23,11 +23,11 @@ jobs:
|
||||
id: head_update
|
||||
run: |
|
||||
# Sets some outputs. See next step
|
||||
python3.7 scripts/update_ghidra_head.py --ci
|
||||
python3 scripts/update_ghidra_head.py --ci
|
||||
|
||||
# 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,10 +36,19 @@ jobs:
|
||||
|
||||
- name: Create PR
|
||||
if: steps.head_update.outputs.did_update
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
title: Update Ghidra HEAD to commit ${{ steps.head_update.outputs.short_sha }}
|
||||
commit-message: Bump Ghidra HEAD commit ${{ steps.head_update.outputs.short_sha }}
|
||||
commit-message: |
|
||||
Bump Ghidra HEAD commit ${{ steps.head_update.outputs.short_sha }}
|
||||
|
||||
Changed files:
|
||||
|
||||
${{ steps.head_update.outputs.changed_files }}
|
||||
body: |
|
||||
Changed files:
|
||||
|
||||
${{ steps.head_update.outputs.changed_files }}
|
||||
branch: cron/update-ghidra-${{ steps.head_update.outputs.short_sha }}
|
||||
delete-branch: true
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
+31
-9
@@ -30,7 +30,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,21 +135,35 @@ 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"
|
||||
)
|
||||
#if(sleigh_RELEASE_IS_HEAD)
|
||||
# list(APPEND public_include_header_list
|
||||
# )
|
||||
#endif()
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
list(APPEND public_include_header_list
|
||||
"${library_root}/compression.hh"
|
||||
"${library_root}/slaformat.hh"
|
||||
)
|
||||
endif()
|
||||
# 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
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
|
||||
#
|
||||
# sla
|
||||
@@ -183,6 +197,10 @@ set_target_properties(sleigh_sla PROPERTIES
|
||||
OUTPUT_NAME_DEBUG sla_dbg
|
||||
)
|
||||
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
target_link_libraries(sleigh_sla PUBLIC ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
#
|
||||
# decomp
|
||||
#
|
||||
@@ -210,6 +228,10 @@ set_target_properties(sleigh_decomp PROPERTIES
|
||||
OUTPUT_NAME_DEBUG decomp_dbg
|
||||
)
|
||||
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
target_link_libraries(sleigh_decomp PUBLIC ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
# 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")
|
||||
|
||||
+6
-1
@@ -37,7 +37,8 @@
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_EXTENSIONS": "OFF",
|
||||
"CMAKE_CXX_STANDARD": "11",
|
||||
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
|
||||
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
|
||||
"CMAKE_POSITION_INDEPENDENT_CODE": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -78,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
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
* @ekilmer @tetsuo-cpp
|
||||
@@ -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 |
|
||||
|
||||
|
||||
@@ -15,10 +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@")
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(ZLIB)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/sleighTargets.cmake")
|
||||
|
||||
# Helpers exposed by default when finding sleigh
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/modules/sleighCompile.cmake")
|
||||
|
||||
@@ -45,7 +45,7 @@ static void PrintVersion(void) {
|
||||
}
|
||||
}
|
||||
|
||||
class InMemoryLoadImage : public LoadImage {
|
||||
class InMemoryLoadImage : public ghidra::LoadImage {
|
||||
public:
|
||||
explicit InMemoryLoadImage(uint64_t base_addr)
|
||||
: LoadImage("nofile"), base_addr(base_addr) {}
|
||||
@@ -55,7 +55,8 @@ public:
|
||||
image_buffer = std::move(buf);
|
||||
}
|
||||
|
||||
void loadFill(unsigned char *ptr, int size, const Address &addr) override {
|
||||
void loadFill(unsigned char *ptr, int size,
|
||||
const ghidra::Address &addr) override {
|
||||
uint64_t start = addr.getOffset();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
uint64_t offset = start + i;
|
||||
@@ -108,18 +109,18 @@ static std::string ParseHexBytes(std::string_view bytes, uint64_t addr,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
class AssemblyPrinter : public AssemblyEmit {
|
||||
class AssemblyPrinter : public ghidra::AssemblyEmit {
|
||||
public:
|
||||
void dump(const Address &addr, const std::string &mnemonic,
|
||||
void dump(const ghidra::Address &addr, const std::string &mnemonic,
|
||||
const std::string &body) override {
|
||||
addr.printRaw(std::cout);
|
||||
std::cout << ": " << mnemonic << ' ' << body << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
static void PrintAssembly(Sleigh &engine, uint64_t addr, size_t len) {
|
||||
static void PrintAssembly(ghidra::Sleigh &engine, uint64_t addr, size_t len) {
|
||||
AssemblyPrinter asm_emit;
|
||||
Address cur_addr(engine.getDefaultCodeSpace(), addr),
|
||||
ghidra::Address cur_addr(engine.getDefaultCodeSpace(), addr),
|
||||
last_addr(engine.getDefaultCodeSpace(), addr + len);
|
||||
while (cur_addr < last_addr) {
|
||||
int32_t instr_len = engine.printAssembly(asm_emit, cur_addr);
|
||||
@@ -127,15 +128,16 @@ static void PrintAssembly(Sleigh &engine, uint64_t addr, size_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintVarData(std::ostream &s, VarnodeData &data) {
|
||||
static void PrintVarData(std::ostream &s, ghidra::VarnodeData &data) {
|
||||
s << '(' << data.space->getName() << ',';
|
||||
data.space->printOffset(s, data.offset);
|
||||
s << ',' << std::dec << data.size << ')';
|
||||
}
|
||||
|
||||
class PcodePrinter : public PcodeEmit {
|
||||
class PcodePrinter : public ghidra::PcodeEmit {
|
||||
public:
|
||||
void dump(const Address &, OpCode op, VarnodeData *outvar, VarnodeData *vars,
|
||||
void dump(const ghidra::Address &, ghidra::OpCode op,
|
||||
ghidra::VarnodeData *outvar, ghidra::VarnodeData *vars,
|
||||
int32_t isize) override {
|
||||
if (outvar) {
|
||||
PrintVarData(std::cout, *outvar);
|
||||
@@ -150,9 +152,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static void PrintPcode(Sleigh &engine, uint64_t addr, size_t len) {
|
||||
static void PrintPcode(ghidra::Sleigh &engine, uint64_t addr, size_t len) {
|
||||
PcodePrinter pcode_emit;
|
||||
Address cur_addr(engine.getDefaultCodeSpace(), addr),
|
||||
ghidra::Address cur_addr(engine.getDefaultCodeSpace(), addr),
|
||||
last_addr(engine.getDefaultCodeSpace(), addr + len);
|
||||
while (cur_addr < last_addr) {
|
||||
int32_t instr_len = engine.oneInstruction(pcode_emit, cur_addr);
|
||||
@@ -257,13 +259,20 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Put together Sleigh components
|
||||
AttributeId::initialize();
|
||||
ElementId::initialize();
|
||||
ghidra::AttributeId::initialize();
|
||||
ghidra::ElementId::initialize();
|
||||
InMemoryLoadImage load_image(addr);
|
||||
ContextInternal ctx;
|
||||
Sleigh engine(&load_image, &ctx);
|
||||
DocumentStorage storage;
|
||||
Element *root = storage.openDocument(sla_file_path->string())->getRoot();
|
||||
ghidra::ContextInternal ctx;
|
||||
ghidra::Sleigh engine(&load_image, &ctx);
|
||||
ghidra::DocumentStorage storage;
|
||||
#ifdef sleigh_RELEASE_IS_HEAD
|
||||
std::istringstream sla("<sleigh>" + sla_file_path->string() + "</sleigh>");
|
||||
ghidra::Element *root =
|
||||
storage.parseDocument(sla)->getRoot();
|
||||
#else
|
||||
ghidra::Element *root =
|
||||
storage.openDocument(sla_file_path->string())->getRoot();
|
||||
#endif
|
||||
storage.registerTag(root);
|
||||
std::optional<std::filesystem::path> pspec_file_path;
|
||||
if (args->pspec_file_name) {
|
||||
@@ -287,7 +296,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
if (pspec_file_path) {
|
||||
Element *pspec_root = storage.openDocument(pspec_file_path->string())->getRoot();
|
||||
ghidra::Element *pspec_root =
|
||||
storage.openDocument(pspec_file_path->string())->getRoot();
|
||||
storage.registerTag(pspec_root);
|
||||
}
|
||||
engine.initialize(storage);
|
||||
@@ -296,14 +306,15 @@ int main(int argc, char *argv[]) {
|
||||
// we can set the default context
|
||||
// This imitates what is done in
|
||||
// void Architecture::parseProcessorConfig(DocumentStorage &store)
|
||||
const Element *el = storage.getTag("processor_spec");
|
||||
const ghidra::Element *el = storage.getTag("processor_spec");
|
||||
if (el) {
|
||||
XmlDecode decoder(&engine, el);
|
||||
uint4 elemId = decoder.openElement(ELEM_PROCESSOR_SPEC);
|
||||
for(;;) {
|
||||
uint4 subId = decoder.peekElement();
|
||||
if (subId == 0) break;
|
||||
else if (subId == ELEM_CONTEXT_DATA) {
|
||||
ghidra::XmlDecode decoder(&engine, el);
|
||||
ghidra::uint4 elemId = decoder.openElement(ghidra::ELEM_PROCESSOR_SPEC);
|
||||
for (;;) {
|
||||
ghidra::uint4 subId = decoder.peekElement();
|
||||
if (subId == 0)
|
||||
break;
|
||||
else if (subId == ghidra::ELEM_CONTEXT_DATA) {
|
||||
ctx.decodeFromSpec(decoder);
|
||||
break;
|
||||
} else {
|
||||
|
||||
+107
-38
@@ -1,18 +1,26 @@
|
||||
"""Script to update CMake files for latest Ghidra Sleigh changes"""
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from typing import AnyStr, Union
|
||||
from pathlib import Path
|
||||
from typing import AnyStr, Union, List
|
||||
|
||||
PROJECT_ROOT = pathlib.Path(__file__).parent.parent.resolve()
|
||||
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",
|
||||
]
|
||||
|
||||
GIT_EXE = shutil.which("git")
|
||||
assert GIT_EXE is not None
|
||||
|
||||
@@ -21,21 +29,18 @@ def msg(s: str) -> None:
|
||||
print(f"[!] {s}")
|
||||
|
||||
|
||||
PathString = Union[AnyStr, pathlib.Path]
|
||||
PathString = Union[AnyStr, Path]
|
||||
|
||||
|
||||
def clone_ghidra_git(dir: PathString) -> None:
|
||||
def clone_ghidra_git(clone_dir: PathString) -> None:
|
||||
"""Clone the Ghidra git dir at specified directory"""
|
||||
# Shallow clone
|
||||
assert GIT_EXE is not None
|
||||
subprocess.run(
|
||||
[
|
||||
GIT_EXE,
|
||||
"clone",
|
||||
"https://github.com/NationalSecurityAgency/ghidra",
|
||||
"--depth",
|
||||
"1",
|
||||
dir,
|
||||
clone_dir,
|
||||
],
|
||||
stdout=sys.stdout,
|
||||
stderr=sys.stderr,
|
||||
@@ -43,36 +48,90 @@ def clone_ghidra_git(dir: PathString) -> None:
|
||||
)
|
||||
|
||||
|
||||
def update_head_commit(latest_commit: str):
|
||||
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(
|
||||
[
|
||||
GIT_EXE,
|
||||
"diff",
|
||||
"--name-status",
|
||||
f"{old_commit}...{new_commit}",
|
||||
"--",
|
||||
*paths,
|
||||
],
|
||||
cwd=repo,
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
fd, abspath = tempfile.mkstemp()
|
||||
with open(fd, "w") as w:
|
||||
with open(SETUP_GHIDRA_FILE, "r") as r:
|
||||
with setup_file.open("r") as r:
|
||||
for line in r:
|
||||
match = re.search(head_commit_line, line)
|
||||
if match is not None:
|
||||
current_commit = match.group(1)
|
||||
if current_commit != latest_commit:
|
||||
msg(f"Found new commit: {latest_commit}")
|
||||
line = re.sub(
|
||||
head_commit_line,
|
||||
f'set(ghidra_head_git_tag "{latest_commit}")',
|
||||
line,
|
||||
)
|
||||
updated = True
|
||||
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)
|
||||
|
||||
# Make the swap with the new content
|
||||
shutil.copymode(SETUP_GHIDRA_FILE, abspath)
|
||||
os.remove(SETUP_GHIDRA_FILE)
|
||||
shutil.move(abspath, SETUP_GHIDRA_FILE)
|
||||
shutil.copymode(setup_file, abspath)
|
||||
os.remove(setup_file)
|
||||
shutil.move(abspath, setup_file)
|
||||
return updated
|
||||
|
||||
|
||||
def update_head_version_file(ghidra_root_dir: PathString) -> None:
|
||||
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]+)?)\"\)"
|
||||
@@ -86,7 +145,7 @@ def update_head_version_file(ghidra_root_dir: PathString) -> None:
|
||||
assert match is not None
|
||||
source_version = match.group(1)
|
||||
|
||||
with SETUP_GHIDRA_FILE.open("r") as f:
|
||||
with setup_file.open("r") as f:
|
||||
content = f.read()
|
||||
match = re.search(cmake_head_version_line, content)
|
||||
assert match is not None
|
||||
@@ -99,7 +158,7 @@ def update_head_version_file(ghidra_root_dir: PathString) -> None:
|
||||
msg(f"Found new version: {source_version}")
|
||||
fd, abspath = tempfile.mkstemp()
|
||||
with open(fd, "w") as w:
|
||||
with SETUP_GHIDRA_FILE.open("r") as r:
|
||||
with setup_file.open("r") as r:
|
||||
for line in r:
|
||||
match = re.search(cmake_head_version_line, line)
|
||||
if match is not None:
|
||||
@@ -111,9 +170,9 @@ def update_head_version_file(ghidra_root_dir: PathString) -> None:
|
||||
w.write(line)
|
||||
|
||||
# Make the swap with the new content
|
||||
shutil.copymode(SETUP_GHIDRA_FILE, abspath)
|
||||
os.remove(SETUP_GHIDRA_FILE)
|
||||
shutil.move(abspath, SETUP_GHIDRA_FILE)
|
||||
shutil.copymode(setup_file, abspath)
|
||||
os.remove(setup_file)
|
||||
shutil.move(abspath, setup_file)
|
||||
|
||||
|
||||
def update_spec_files(ghidra_repo_dir: PathString, cmake_file: PathString):
|
||||
@@ -122,9 +181,7 @@ def update_spec_files(ghidra_repo_dir: PathString, cmake_file: PathString):
|
||||
for dirpath, _, fnames in os.walk(ghidra_repo_dir / "Ghidra" / "Processors"):
|
||||
for file in fnames:
|
||||
if file.endswith(".slaspec"):
|
||||
spec_files.append(
|
||||
(pathlib.Path(dirpath) / file).relative_to(ghidra_repo_dir)
|
||||
)
|
||||
spec_files.append((Path(dirpath) / file).relative_to(ghidra_repo_dir))
|
||||
assert len(spec_files) > 0
|
||||
spec_files.sort()
|
||||
|
||||
@@ -152,22 +209,27 @@ def get_latest_commit(ghidra_repo_dir: PathString) -> str:
|
||||
)
|
||||
|
||||
|
||||
def update_head(ghidra_repo_dir: PathString, ci: bool) -> bool:
|
||||
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 = pathlib.Path(tmpdirname.name) / "ghidra"
|
||||
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(latest_commit)
|
||||
did_update_commit = update_head_commit(
|
||||
setup_file, ghidra_repo_dir, latest_commit, ci
|
||||
)
|
||||
if did_update_commit:
|
||||
if ci:
|
||||
print(f"::set-output name=short_sha::{latest_commit[:9]}")
|
||||
print("::set-output name=did_update::true")
|
||||
update_spec_files(ghidra_repo_dir, HEAD_SPEC_FILE)
|
||||
update_head_version_file(ghidra_repo_dir)
|
||||
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}")
|
||||
|
||||
@@ -186,7 +248,7 @@ if __name__ == "__main__":
|
||||
def dir_path(string):
|
||||
if string is None:
|
||||
return string
|
||||
string = pathlib.Path(string).expanduser().resolve()
|
||||
string = Path(string).expanduser().resolve()
|
||||
if string.is_dir():
|
||||
return string
|
||||
else:
|
||||
@@ -207,5 +269,12 @@ if __name__ == "__main__":
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not update_head(args.ghidra_repo, args.ci):
|
||||
if args.ci:
|
||||
assert (
|
||||
"GITHUB_OUTPUT" in os.environ
|
||||
), "CI needs `GITHUB_OUTPUT` environment variable set to a file location"
|
||||
|
||||
if not update_head(SETUP_GHIDRA_FILE, HEAD_SPEC_FILE, args.ghidra_repo, args.ci):
|
||||
msg("No update required")
|
||||
else:
|
||||
msg("Update required!")
|
||||
|
||||
+35
-72
@@ -1,10 +1,9 @@
|
||||
From f62b1e5483a99efe3ae6598291ec010ecee749d4 Mon Sep 17 00:00:00 2001
|
||||
From 6c36965500d26d5a35dfbc91725956ae1d51e394 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Mon, 7 Feb 2022 02:02:03 +1100
|
||||
Subject: [PATCH] Fix UBSAN errors in decompiler
|
||||
Date: Mon, 5 Jun 2023 16:45:04 +1200
|
||||
Subject: [PATCH 1/5] Fix UBSAN errors in decompiler
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/address.cc | 4 ++--
|
||||
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
|
||||
.../src/decompile/cpp/funcdata_varnode.cc | 8 +++++++-
|
||||
.../Decompiler/src/decompile/cpp/op.cc | 6 +++++-
|
||||
@@ -14,38 +13,15 @@ Subject: [PATCH] Fix UBSAN errors in decompiler
|
||||
.../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 +-
|
||||
13 files changed, 59 insertions(+), 23 deletions(-)
|
||||
11 files changed, 56 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
index 1cb02c5b2..3a60d1322 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
@@ -685,7 +685,7 @@ uintb sign_extend(uintb in,int4 sizein,int4 sizeout)
|
||||
void sign_extend(intb &val,int4 bit)
|
||||
|
||||
{
|
||||
- intb mask = 0;
|
||||
+ uintb mask = 0;
|
||||
mask = (~mask)<<bit;
|
||||
if (((val>>bit)&1)!=0)
|
||||
val |= mask;
|
||||
@@ -699,7 +699,7 @@ void sign_extend(intb &val,int4 bit)
|
||||
void zero_extend(intb &val,int4 bit)
|
||||
|
||||
{
|
||||
- intb mask = 0;
|
||||
+ uintb mask = 0;
|
||||
mask = (~mask)<<bit;
|
||||
mask <<= 1;
|
||||
val &= (~mask);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
index 0526ed04c..e79fd041e 100644
|
||||
index dc96f0c19..3482cf17c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
@@ -2633,8 +2633,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
@@ -2727,8 +2727,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
modellist.push_back(mymodel);
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
@@ -61,10 +37,10 @@ index 0526ed04c..e79fd041e 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 e6b282ac7..f6a35728f 100644
|
||||
index fc094ee96..1f7e53ebe 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
@@ -501,7 +501,13 @@ void Funcdata::setHighLevel(void)
|
||||
@@ -503,7 +503,13 @@ void Funcdata::setHighLevel(void)
|
||||
void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset)
|
||||
|
||||
{
|
||||
@@ -80,10 +56,10 @@ index e6b282ac7..f6a35728f 100644
|
||||
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 b4f8a3f8e..068393416 100644
|
||||
index 921335173..46cdc39f3 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
@@ -667,7 +667,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();
|
||||
@@ -97,16 +73,16 @@ index b4f8a3f8e..068393416 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 3b84bac6a..3e0c39904 100644
|
||||
index aebcfd910..6c47e6eb1 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
@@ -747,7 +747,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
|
||||
|
||||
{
|
||||
- uintb res = (in1>>(in2*8)) & calc_mask(sizeout);
|
||||
+ uintb res = in1;
|
||||
+ if ((in2*8) < sizeof(in1)) {
|
||||
+ if (in2 < sizeof(in1)) {
|
||||
+ res >>= (in2*8);
|
||||
+ } else {
|
||||
+ res = 0;
|
||||
@@ -116,10 +92,10 @@ index 3b84bac6a..3e0c39904 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
index 49128f7e6..133da8178 100644
|
||||
index ca9d71ab9..85d4dd281 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
@@ -619,8 +619,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
@@ -621,8 +621,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
uint4 smallsize = (numbits+7)/8; // Size of input (output of rhs)
|
||||
bool shiftneeded = (bitoffset != 0);
|
||||
bool zextneeded = true;
|
||||
@@ -132,7 +108,7 @@ index 49128f7e6..133da8178 100644
|
||||
|
||||
if (vn->getSize().getType()==ConstTpl::real) {
|
||||
// If we know the size of the bitranged varnode, we can
|
||||
@@ -724,9 +726,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
@@ -726,9 +728,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +118,7 @@ index 49128f7e6..133da8178 100644
|
||||
if (truncneeded && ((bitoffset % 8)==0)) {
|
||||
truncshift = bitoffset/8;
|
||||
bitoffset = 0;
|
||||
@@ -749,8 +748,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
@@ -751,8 +750,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
appendOp(CPUI_INT_RIGHT,res,bitoffset,4);
|
||||
if (truncneeded)
|
||||
appendOp(CPUI_SUBPIECE,res,truncshift,4);
|
||||
@@ -159,10 +135,10 @@ index 49128f7e6..133da8178 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
index b5bdb4700..ef741545c 100644
|
||||
index 3703c8ef5..ac6e21c00 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
@@ -974,7 +974,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
if (outvn->isPrecisLo()||outvn->isPrecisHi()) return 0; // Don't pull apart double precision object
|
||||
|
||||
@@ -176,7 +152,7 @@ index b5bdb4700..ef741545c 100644
|
||||
consume = ~consume;
|
||||
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
|
||||
|
||||
@@ -6785,8 +6790,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -6803,8 +6808,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;
|
||||
@@ -188,7 +164,7 @@ index b5bdb4700..ef741545c 100644
|
||||
Varnode *vn1 = op->getIn(1);
|
||||
if (!vn1->isConstant()) return 0;
|
||||
Varnode *outvn = op->getOut();
|
||||
@@ -7822,7 +7828,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -8616,7 +8622,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 flowsize = outvn->getSize();
|
||||
uintb mask = calc_mask( flowsize );
|
||||
@@ -202,10 +178,10 @@ index b5bdb4700..ef741545c 100644
|
||||
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 f8c1580a8..8ae5ff293 100644
|
||||
index cd9b9835b..8a4616c3b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
@@ -20,6 +20,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
@@ -22,6 +22,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
|
||||
{ // Constructor for relative jump constants and uniques
|
||||
type = tp;
|
||||
@@ -213,7 +189,7 @@ index f8c1580a8..8ae5ff293 100644
|
||||
}
|
||||
|
||||
ConstTpl::ConstTpl(const_type tp,uintb val)
|
||||
@@ -54,6 +55,7 @@ ConstTpl::ConstTpl(AddrSpace *sid)
|
||||
@@ -56,6 +57,7 @@ ConstTpl::ConstTpl(AddrSpace *sid)
|
||||
{
|
||||
type = spaceid;
|
||||
value.spaceid = sid;
|
||||
@@ -222,12 +198,12 @@ index f8c1580a8..8ae5ff293 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 dccf0437d..f7f598667 100644
|
||||
index e0b069959..9117a45c7 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
@@ -46,7 +46,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; }
|
||||
@@ -235,10 +211,10 @@ index dccf0437d..f7f598667 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 3ec58b9d0..55fcfd7c8 100644
|
||||
index c060053bf..c9004023c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
@@ -2150,8 +2150,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) {
|
||||
@@ -248,24 +224,11 @@ index 3ec58b9d0..55fcfd7c8 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 5f4a8fe32..50bc33b8b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
@@ -2499,7 +2499,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 b8dbcd55b..b2d0c1bb6 100644
|
||||
index e6292e138..bd31b7470 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -3073,8 +3073,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
@@ -3561,8 +3561,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()) {
|
||||
@@ -276,10 +239,10 @@ index b8dbcd55b..b2d0c1bb6 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 ab99382a3..67d92c573 100644
|
||||
index c35bde877..061e53677 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -338,7 +338,7 @@ TEST(float_opTrunc_to_int) {
|
||||
@@ -346,7 +346,7 @@ TEST(float_opTrunc_to_int) {
|
||||
|
||||
for(float f:float_test_values) {
|
||||
// avoid undefined behavior
|
||||
@@ -289,5 +252,5 @@ index ab99382a3..67d92c573 100644
|
||||
uintb true_result = ((uintb)(int32_t)f) & 0xffffffff;
|
||||
uintb encoding = format.getEncoding(f);
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.44.0
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
From 031d9830abe8517540389672fd22dc479e46d696 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Sun, 13 Feb 2022 12:59:42 -0500
|
||||
Subject: [PATCH] Small improvements to C++ decompiler testing from CLI
|
||||
|
||||
* Fixes argument parsing to accept more than one option for specifying
|
||||
paths.
|
||||
|
||||
* Return a non-zero exit code (clamped to max value 255, even if more
|
||||
than 255 tests fail) indicating number of failed tests. This is
|
||||
helpful when running in a script (like in CI) to detect failures
|
||||
instead of detecting failures through manual visual inspection of
|
||||
output text.
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/test.cc | 42 ++++++++++++++-----
|
||||
.../Decompiler/src/decompile/cpp/test.hh | 2 +-
|
||||
.../src/decompile/cpp/testfunction.cc | 3 +-
|
||||
.../src/decompile/cpp/testfunction.hh | 2 +-
|
||||
4 files changed, 36 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc
|
||||
index e81f2564a..ebc049c29 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc
|
||||
@@ -14,6 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test.hh"
|
||||
+
|
||||
+#include <algorithm>
|
||||
+
|
||||
#include "libdecomp.hh"
|
||||
|
||||
vector<UnitTest *> UnitTest::tests;
|
||||
@@ -21,7 +24,8 @@ vector<UnitTest *> UnitTest::tests;
|
||||
/// Run all the tests unless a non-empty set of names is passed in.
|
||||
/// In which case, only the named tests in the set are run.
|
||||
/// \param testNames is the set of names
|
||||
-void UnitTest::run(set<string> &testNames)
|
||||
+/// \return number of failed tests
|
||||
+int UnitTest::run(set<string> &testNames)
|
||||
|
||||
{
|
||||
int total = 0;
|
||||
@@ -42,6 +46,7 @@ void UnitTest::run(set<string> &testNames)
|
||||
}
|
||||
std::cerr << "==============================" << std::endl;
|
||||
std::cerr << passed << "/" << total << " tests passed." << std::endl;
|
||||
+ return total - passed;
|
||||
}
|
||||
|
||||
/// Create list of the absolute path of all tests to be run
|
||||
@@ -85,7 +90,7 @@ int main(int argc, char **argv) {
|
||||
set<string> dataTestNames;
|
||||
string dirname("../datatests");
|
||||
string sleighdirname("../../../../../../..");
|
||||
- if (argc > 0) {
|
||||
+ while (argc > 0) {
|
||||
string command(argv[0]);
|
||||
if (command == "-path") {
|
||||
dirname = argv[1];
|
||||
@@ -109,30 +114,47 @@ int main(int argc, char **argv) {
|
||||
argv += 1;
|
||||
argc -= 1;
|
||||
}
|
||||
- }
|
||||
- if (argc > 0) {
|
||||
- string command(argv[0]);
|
||||
- if (command == "unittests") {
|
||||
+ else if (command == "unittests") {
|
||||
runUnitTests = true;
|
||||
runDataTests = false; // Run only unit tests
|
||||
unitTestNames.insert(argv + 1,argv + argc);
|
||||
+ break;
|
||||
}
|
||||
else if (command == "datatests") {
|
||||
runUnitTests = false; // Run only data-tests
|
||||
runDataTests = true;
|
||||
dataTestNames.insert(argv + 1,argv + argc);
|
||||
+ break;
|
||||
}
|
||||
else {
|
||||
- cout << "USAGE: ghidra_test [-path <datatestdir>] [[unittests|datatests] [testname1 testname2 ...]]" << endl;
|
||||
+ cout << "USAGE: ghidra_test [-usesleighenv] [-sleighpath <sleighdir>] [-path <datatestdir>] [[unittests|datatests] [testname1 testname2 ...]]" << endl;
|
||||
+ return -1;
|
||||
}
|
||||
}
|
||||
startDecompilerLibrary(sleighdirname.c_str());
|
||||
- if (runUnitTests)
|
||||
- UnitTest::run(unitTestNames);
|
||||
+
|
||||
+ // Keep track of failed tests as return code to indicate failures, clamped at
|
||||
+ // max 255 value
|
||||
+ int failedTests = 0;
|
||||
+ if (runUnitTests) {
|
||||
+ int errors = UnitTest::run(unitTestNames);
|
||||
+ // Clamp at 255 max return code
|
||||
+ failedTests = std::min(
|
||||
+ failedTests +
|
||||
+ (errors < 0 ? 255 : std::min(errors, 255)),
|
||||
+ 255);
|
||||
+ }
|
||||
if (runDataTests) {
|
||||
vector<string> testFiles;
|
||||
gatherDataTests(dirname,dataTestNames,testFiles);
|
||||
cout << endl << endl;
|
||||
- FunctionTestCollection::runTestFiles(testFiles,cout);
|
||||
+ int errors = FunctionTestCollection::runTestFiles(testFiles,cout);
|
||||
+ // Clamp at 255 max return code
|
||||
+ failedTests = std::min(
|
||||
+ failedTests +
|
||||
+ (errors < 0 ? 255 : std::min(errors, 255)),
|
||||
+ 255);
|
||||
}
|
||||
+
|
||||
+ return failedTests;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh
|
||||
index 8b762c5b1..a138f511d 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh
|
||||
@@ -54,7 +54,7 @@ struct UnitTest {
|
||||
tests.push_back(this);
|
||||
}
|
||||
|
||||
- static void run(std::set<std::string> &testNames); ///< Run all the instantiated tests
|
||||
+ static int run(std::set<std::string> &testNames); ///< Run all the instantiated tests
|
||||
};
|
||||
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc
|
||||
index 66f8d3fa2..c136a964b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc
|
||||
@@ -304,7 +304,7 @@ void FunctionTestCollection::runTests(list<string> &lateStream)
|
||||
/// Run through all XML files in the given list, processing each in turn.
|
||||
/// \param testFiles is the given list of test files
|
||||
/// \param s is the output stream to print results to
|
||||
-void FunctionTestCollection::runTestFiles(const vector<string> &testFiles,ostream &s)
|
||||
+int FunctionTestCollection::runTestFiles(const vector<string> &testFiles,ostream &s)
|
||||
|
||||
{
|
||||
int4 totalTestsApplied = 0;
|
||||
@@ -344,4 +344,5 @@ void FunctionTestCollection::runTestFiles(const vector<string> &testFiles,ostrea
|
||||
if (iter == failures.end()) break;
|
||||
}
|
||||
}
|
||||
+ return totalTestsApplied - totalTestsSucceeded;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh
|
||||
index 52125b401..46abd6bce 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh
|
||||
@@ -91,7 +91,7 @@ class FunctionTestCollection {
|
||||
void restoreXml(DocumentStorage &store,const Element *el); ///< Load tests from a \<decompilertest> tag.
|
||||
void restoreXmlOldForm(DocumentStorage &store,const Element *el); ///< Load tests from \<binaryimage> tag.
|
||||
void runTests(list<string> &lateStream); ///< Run the script and perform the tests
|
||||
- static void runTestFiles(const vector<string> &testFiles,ostream &s); ///< Run tests for each listed file
|
||||
+ static int runTestFiles(const vector<string> &testFiles,ostream &s); ///< Run tests for each listed file
|
||||
};
|
||||
|
||||
#endif
|
||||
--
|
||||
2.35.1
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
From 44c439d879c18c2873d5605821132957680a4405 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Thu, 28 Jul 2022 09:20:03 -0400
|
||||
Subject: [PATCH] Add include guards to decompiler C++ headers
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh | 6 ++++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh | 5 +++++
|
||||
.../Features/Decompiler/src/decompile/cpp/slgh_compile.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh | 6 ++++++
|
||||
6 files changed, 32 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
index 875d3bb78..6ade01ecc 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
@@ -17,6 +17,9 @@
|
||||
/// \file bfd_arch.hh
|
||||
/// \brief Specific implementation of Architecture using GNU BFD libraries
|
||||
|
||||
+#ifndef __BFD_ARCH__
|
||||
+#define __BFD_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage_bfd.hh"
|
||||
|
||||
@@ -47,3 +50,5 @@ class BfdArchitecture : public SleighArchitecture {
|
||||
BfdArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
|
||||
virtual ~BfdArchitecture(void) {}
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
index 364a5258d..edd6ce865 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
@@ -14,8 +14,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
+
|
||||
+#ifndef __GRAPH__
|
||||
+#define __GRAPH__
|
||||
+
|
||||
#include "funcdata.hh"
|
||||
|
||||
extern void dump_dataflow_graph(Funcdata &data,ostream &s);
|
||||
extern void dump_controlflow_graph(const string &name,const BlockGraph &graph,ostream &s);
|
||||
extern void dump_dom_graph(const string &name,const BlockGraph &graph,ostream &s);
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
index 3ca912dd6..0b70d8b22 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
@@ -16,6 +16,9 @@
|
||||
/// \file ifaceterm.hh
|
||||
/// \brief Add some terminal capabilities to the command-line interface (IfaceStatus)
|
||||
|
||||
+#ifndef __IFACE_TERM__
|
||||
+#define __IFACE_TERM__
|
||||
+
|
||||
#include "interface.hh"
|
||||
|
||||
#ifdef __TERMINAL__
|
||||
@@ -48,3 +51,5 @@ class IfaceTerm : public IfaceStatus {
|
||||
virtual void popScript(void);
|
||||
virtual bool isStreamFinished(void) const;
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
index 2245840a0..490abf901 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
/// \file raw_arch.hh
|
||||
/// \brief Bare bones capability for treating a file as a raw executable image
|
||||
+
|
||||
+#ifndef __RAW_ARCH__
|
||||
+#define __RAW_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage.hh"
|
||||
|
||||
@@ -46,3 +50,4 @@ class RawBinaryArchitecture : public SleighArchitecture {
|
||||
virtual ~RawBinaryArchitecture(void) {}
|
||||
};
|
||||
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
index e7ab19185..8fd9ba2fd 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
@@ -16,6 +16,9 @@
|
||||
/// \file slgh_compile.hh
|
||||
/// \brief High-level control of the sleigh compilation process
|
||||
|
||||
+#ifndef __SLGH_COMPILE__
|
||||
+#define __SLGH_COMPILE__
|
||||
+
|
||||
#include "sleighbase.hh"
|
||||
#include "pcodecompile.hh"
|
||||
#include "filemanage.hh"
|
||||
@@ -446,3 +449,5 @@ class SleighCompile : public SleighBase {
|
||||
|
||||
extern SleighCompile *slgh; ///< A global reference to the SLEIGH compiler accessible to the parse functions
|
||||
extern int yydebug; ///< Debug state for the SLEIGH parse functions
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
index d395fb8a3..6371148b0 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
/// \file xml_arch.hh
|
||||
/// \brief Extension to read executables based on an XML format
|
||||
+
|
||||
+#ifndef __XML_ARCH__
|
||||
+#define __XML_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage_xml.hh"
|
||||
|
||||
@@ -45,3 +49,5 @@ class XmlArchitecture : public SleighArchitecture {
|
||||
XmlArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
|
||||
virtual ~XmlArchitecture(void) {}
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.37.1
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
From 0891ecb91231978ef912c3215925bcdea6f14ce7 Mon Sep 17 00:00:00 2001
|
||||
From 290b06621c7a8c32c1470d16dbd8740876d57640 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Wed, 3 Aug 2022 20:01:18 +1000
|
||||
Subject: [PATCH 4/4] Use `stroull` instead of `stroul` to parse address
|
||||
Subject: [PATCH 2/5] Use `stroull` instead of `stroul` to parse address
|
||||
offsets
|
||||
|
||||
---
|
||||
@@ -9,7 +9,7 @@ Subject: [PATCH 4/4] 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 40a3e3bfe..ff6f282ca 100644
|
||||
index bda09fc94..d077ee375 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
@@ -16,6 +16,8 @@
|
||||
@@ -18,10 +18,10 @@ index 40a3e3bfe..ff6f282ca 100644
|
||||
|
||||
+#include <climits>
|
||||
+
|
||||
namespace ghidra {
|
||||
|
||||
AttributeId ATTRIB_BASE = AttributeId("base",89);
|
||||
AttributeId ATTRIB_DEADCODEDELAY = AttributeId("deadcodedelay",90);
|
||||
AttributeId ATTRIB_DELAY = AttributeId("delay", 91);
|
||||
@@ -268,7 +270,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
@@ -274,7 +276,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
}
|
||||
}
|
||||
catch(LowlevelError &err) { // Name doesn't exist
|
||||
@@ -34,5 +34,5 @@ index 40a3e3bfe..ff6f282ca 100644
|
||||
enddata = (const char *) tmpdata;
|
||||
if (enddata - s.c_str() == s.size()) { // If no size or offset override
|
||||
--
|
||||
2.38.1
|
||||
2.44.0
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From 73d6f5a2a9a39dba3117947b3e27fe112c7d7074 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Mon, 4 Mar 2024 11:18:57 -0500
|
||||
Subject: [PATCH 3/5] Fix sleighexample
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc
|
||||
index f356825c9..5cab3f85c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc
|
||||
@@ -315,12 +315,12 @@ int main(int argc,char **argv)
|
||||
ContextInternal context;
|
||||
|
||||
// Set up the assembler/pcode-translator
|
||||
- string sleighfilename = "specfiles/x86.sla";
|
||||
+ istringstream sleighfilename("<sleigh>specfiles/x86.sla</sleigh>");
|
||||
Sleigh trans(&loader,&context);
|
||||
|
||||
// Read sleigh file into DOM
|
||||
DocumentStorage docstorage;
|
||||
- Element *sleighroot = docstorage.openDocument(sleighfilename)->getRoot();
|
||||
+ Element *sleighroot = docstorage.parseDocument(sleighfilename)->getRoot();
|
||||
docstorage.registerTag(sleighroot);
|
||||
trans.initialize(docstorage); // Initialize the translator
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From 2b6f5b2a70158503c844e8259717b7168ced9bc0 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Sat, 30 Mar 2024 18:26:27 -0400
|
||||
Subject: [PATCH 4/5] Fix opening sla files on Windows
|
||||
|
||||
Compressed files need to be opened as binaries when reading.
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc
|
||||
index 471b99199..ba1a3b22c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc
|
||||
@@ -560,7 +560,7 @@ void Sleigh::initialize(DocumentStorage &store)
|
||||
if (el == (const Element *)0)
|
||||
throw LowlevelError("Could not find sleigh tag");
|
||||
sla::FormatDecode decoder(this);
|
||||
- ifstream s(el->getContent());
|
||||
+ ifstream s(el->getContent(), std::ios_base::binary);
|
||||
if (!s)
|
||||
throw LowlevelError("Could not open .sla file: " + el->getContent());
|
||||
decoder.ingestStream(s);
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From a7fc8b440ab58cb377460e11c7449488ff5abc96 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Sat, 30 Mar 2024 18:46:16 -0400
|
||||
Subject: [PATCH 5/5] Add missing index check to prevent errors in Windows
|
||||
|
||||
Not sure why this only appears when testing on Windows.
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc
|
||||
index ac94d261c..a76ad389b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc
|
||||
@@ -1842,7 +1842,7 @@ void IfcProtooverride::execute(istream &s)
|
||||
s >> ws;
|
||||
Address callpoint(parse_machaddr(s,discard,*dcp->conf->types));
|
||||
int4 i;
|
||||
- for(i=0;dcp->fd->numCalls();++i)
|
||||
+ for(i=0;i<dcp->fd->numCalls();++i)
|
||||
if (dcp->fd->getCallSpecs(i)->getOp()->getAddr() == callpoint) break;
|
||||
if (i == dcp->fd->numCalls())
|
||||
throw IfaceExecutionError("No call is made at this address");
|
||||
--
|
||||
2.44.0
|
||||
|
||||
+37
-59
@@ -1,10 +1,10 @@
|
||||
From 42dd4d97396e7769bbbaca78c7a546835d72d974 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Mon, 7 Feb 2022 02:02:03 +1100
|
||||
Subject: [PATCH 3/4] Fix UBSAN errors in decompiler
|
||||
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
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/address.cc | 4 ++--
|
||||
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
|
||||
.../src/decompile/cpp/funcdata_varnode.cc | 8 +++++++-
|
||||
.../Decompiler/src/decompile/cpp/op.cc | 6 +++++-
|
||||
@@ -17,35 +17,13 @@ Subject: [PATCH 3/4] Fix UBSAN errors in decompiler
|
||||
.../Decompiler/src/decompile/cpp/slghsymbol.cc | 2 +-
|
||||
.../Decompiler/src/decompile/cpp/type.cc | 2 +-
|
||||
.../src/decompile/unittests/testfloatemu.cc | 2 +-
|
||||
13 files changed, 59 insertions(+), 23 deletions(-)
|
||||
12 files changed, 57 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
index b3758ddd1..0b3bf04c8 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
@@ -685,7 +685,7 @@ uintb sign_extend(uintb in,int4 sizein,int4 sizeout)
|
||||
void sign_extend(intb &val,int4 bit)
|
||||
|
||||
{
|
||||
- intb mask = 0;
|
||||
+ uintb mask = 0;
|
||||
mask = (~mask)<<bit;
|
||||
if (((val>>bit)&1)!=0)
|
||||
val |= mask;
|
||||
@@ -699,7 +699,7 @@ void sign_extend(intb &val,int4 bit)
|
||||
void zero_extend(intb &val,int4 bit)
|
||||
|
||||
{
|
||||
- intb mask = 0;
|
||||
+ uintb mask = 0;
|
||||
mask = (~mask)<<bit;
|
||||
mask <<= 1;
|
||||
val &= (~mask);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
index 19ed41c63..d1bd842d8 100644
|
||||
index 8380d3cd..a18d5007 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
@@ -2656,8 +2656,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
@@ -2661,8 +2661,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
modellist.push_back(mymodel);
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
@@ -61,10 +39,10 @@ index 19ed41c63..d1bd842d8 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 2b26961f0..117518e24 100644
|
||||
index f7781707..283d81c3 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
@@ -501,7 +501,13 @@ void Funcdata::setHighLevel(void)
|
||||
@@ -503,7 +503,13 @@ void Funcdata::setHighLevel(void)
|
||||
void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset)
|
||||
|
||||
{
|
||||
@@ -80,10 +58,10 @@ index 2b26961f0..117518e24 100644
|
||||
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 b4f8a3f8e..068393416 100644
|
||||
index 0e3decc8..403ec35a 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
@@ -667,7 +667,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
@@ -672,7 +672,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
break;
|
||||
case CPUI_PIECE:
|
||||
resmask = getIn(0)->getNZMask();
|
||||
@@ -97,16 +75,16 @@ index b4f8a3f8e..068393416 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 3b84bac6a..3e0c39904 100644
|
||||
index fcd75cc7..ed0e005a 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
@@ -747,7 +747,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
@@ -750,7 +750,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
uintb OpBehaviorSubpiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const
|
||||
|
||||
{
|
||||
- uintb res = (in1>>(in2*8)) & calc_mask(sizeout);
|
||||
+ uintb res = in1;
|
||||
+ if ((in2*8) < sizeof(in1)) {
|
||||
+ if (in2 < sizeof(in1)) {
|
||||
+ res >>= (in2*8);
|
||||
+ } else {
|
||||
+ res = 0;
|
||||
@@ -116,10 +94,10 @@ index 3b84bac6a..3e0c39904 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
index 49128f7e6..133da8178 100644
|
||||
index ca9d71ab..85d4dd28 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
@@ -619,8 +619,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
@@ -621,8 +621,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
uint4 smallsize = (numbits+7)/8; // Size of input (output of rhs)
|
||||
bool shiftneeded = (bitoffset != 0);
|
||||
bool zextneeded = true;
|
||||
@@ -132,7 +110,7 @@ index 49128f7e6..133da8178 100644
|
||||
|
||||
if (vn->getSize().getType()==ConstTpl::real) {
|
||||
// If we know the size of the bitranged varnode, we can
|
||||
@@ -724,9 +726,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
@@ -726,9 +728,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +120,7 @@ index 49128f7e6..133da8178 100644
|
||||
if (truncneeded && ((bitoffset % 8)==0)) {
|
||||
truncshift = bitoffset/8;
|
||||
bitoffset = 0;
|
||||
@@ -749,8 +748,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
@@ -751,8 +750,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
appendOp(CPUI_INT_RIGHT,res,bitoffset,4);
|
||||
if (truncneeded)
|
||||
appendOp(CPUI_SUBPIECE,res,truncshift,4);
|
||||
@@ -159,10 +137,10 @@ index 49128f7e6..133da8178 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
index 9701f642b..7e8030ae8 100644
|
||||
index 4851365d..d069d1c9 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
@@ -974,7 +974,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
if (outvn->isPrecisLo()||outvn->isPrecisHi()) return 0; // Don't pull apart double precision object
|
||||
|
||||
@@ -176,7 +154,7 @@ index 9701f642b..7e8030ae8 100644
|
||||
consume = ~consume;
|
||||
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
|
||||
|
||||
@@ -6788,8 +6793,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -6782,8 +6787,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;
|
||||
@@ -188,7 +166,7 @@ index 9701f642b..7e8030ae8 100644
|
||||
Varnode *vn1 = op->getIn(1);
|
||||
if (!vn1->isConstant()) return 0;
|
||||
Varnode *outvn = op->getOut();
|
||||
@@ -8272,7 +8278,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -8593,7 +8599,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 flowsize = outvn->getSize();
|
||||
uintb mask = calc_mask( flowsize );
|
||||
@@ -202,10 +180,10 @@ index 9701f642b..7e8030ae8 100644
|
||||
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 ecebc0970..1c9ab7560 100644
|
||||
index 2e3531ea..42482be7 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
@@ -20,6 +20,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
@@ -22,6 +22,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
|
||||
{ // Constructor for relative jump constants and uniques
|
||||
type = tp;
|
||||
@@ -213,7 +191,7 @@ index ecebc0970..1c9ab7560 100644
|
||||
}
|
||||
|
||||
ConstTpl::ConstTpl(const_type tp,uintb val)
|
||||
@@ -54,6 +55,7 @@ ConstTpl::ConstTpl(AddrSpace *sid)
|
||||
@@ -56,6 +57,7 @@ ConstTpl::ConstTpl(AddrSpace *sid)
|
||||
{
|
||||
type = spaceid;
|
||||
value.spaceid = sid;
|
||||
@@ -222,10 +200,10 @@ index ecebc0970..1c9ab7560 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 3b836244c..1fbd169c9 100644
|
||||
index 8e283dca..652600c1 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
@@ -46,7 +46,7 @@ class ConstTpl {
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
static void printHandleSelector(ostream &s,v_field val);
|
||||
static v_field readHandleSelector(const string &name);
|
||||
public:
|
||||
@@ -235,10 +213,10 @@ index 3b836244c..1fbd169c9 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 c26cd468f..40d731480 100644
|
||||
index b40f7438..3c37958d 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
@@ -2152,8 +2152,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
@@ -2163,8 +2163,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
ostringstream msg;
|
||||
SymbolTree::const_iterator iter;
|
||||
for(iter=scope->begin();iter!=scope->end();++iter) {
|
||||
@@ -249,10 +227,10 @@ index c26cd468f..40d731480 100644
|
||||
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 dbb8f9e51..85bd54261 100644
|
||||
index b308e1b7..af2982ae 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
@@ -2565,7 +2565,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
@@ -2569,7 +2569,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
const List &list(el->getChildren());
|
||||
List::const_iterator iter;
|
||||
iter = list.begin();
|
||||
@@ -262,10 +240,10 @@ index dbb8f9e51..85bd54261 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index 316074389..91bf4bc77 100644
|
||||
index 30faf0b6..e76a0619 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -3233,8 +3233,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
@@ -3359,8 +3359,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()) {
|
||||
@@ -276,10 +254,10 @@ index 316074389..91bf4bc77 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 ab99382a3..67d92c573 100644
|
||||
index c35bde87..061e5367 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -338,7 +338,7 @@ TEST(float_opTrunc_to_int) {
|
||||
@@ -346,7 +346,7 @@ TEST(float_opTrunc_to_int) {
|
||||
|
||||
for(float f:float_test_values) {
|
||||
// avoid undefined behavior
|
||||
@@ -289,5 +267,5 @@ index ab99382a3..67d92c573 100644
|
||||
uintb true_result = ((uintb)(int32_t)f) & 0xffffffff;
|
||||
uintb encoding = format.getEncoding(f);
|
||||
--
|
||||
2.38.1
|
||||
2.39.2 (Apple Git-143)
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
From 3100df1ece29160185e1bc9602a3b4c299914965 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Sun, 13 Feb 2022 12:59:42 -0500
|
||||
Subject: [PATCH 1/4] Small improvements to C++ decompiler testing from CLI
|
||||
|
||||
* Fixes argument parsing to accept more than one option for specifying
|
||||
paths.
|
||||
|
||||
* Return a non-zero exit code (clamped to max value 255, even if more
|
||||
than 255 tests fail) indicating number of failed tests. This is
|
||||
helpful when running in a script (like in CI) to detect failures
|
||||
instead of detecting failures through manual visual inspection of
|
||||
output text.
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/test.cc | 42 ++++++++++++++-----
|
||||
.../Decompiler/src/decompile/cpp/test.hh | 2 +-
|
||||
.../src/decompile/cpp/testfunction.cc | 3 +-
|
||||
.../src/decompile/cpp/testfunction.hh | 2 +-
|
||||
4 files changed, 36 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc
|
||||
index e81f2564a..ebc049c29 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc
|
||||
@@ -14,6 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "test.hh"
|
||||
+
|
||||
+#include <algorithm>
|
||||
+
|
||||
#include "libdecomp.hh"
|
||||
|
||||
vector<UnitTest *> UnitTest::tests;
|
||||
@@ -21,7 +24,8 @@ vector<UnitTest *> UnitTest::tests;
|
||||
/// Run all the tests unless a non-empty set of names is passed in.
|
||||
/// In which case, only the named tests in the set are run.
|
||||
/// \param testNames is the set of names
|
||||
-void UnitTest::run(set<string> &testNames)
|
||||
+/// \return number of failed tests
|
||||
+int UnitTest::run(set<string> &testNames)
|
||||
|
||||
{
|
||||
int total = 0;
|
||||
@@ -42,6 +46,7 @@ void UnitTest::run(set<string> &testNames)
|
||||
}
|
||||
std::cerr << "==============================" << std::endl;
|
||||
std::cerr << passed << "/" << total << " tests passed." << std::endl;
|
||||
+ return total - passed;
|
||||
}
|
||||
|
||||
/// Create list of the absolute path of all tests to be run
|
||||
@@ -85,7 +90,7 @@ int main(int argc, char **argv) {
|
||||
set<string> dataTestNames;
|
||||
string dirname("../datatests");
|
||||
string sleighdirname("../../../../../../..");
|
||||
- if (argc > 0) {
|
||||
+ while (argc > 0) {
|
||||
string command(argv[0]);
|
||||
if (command == "-path") {
|
||||
dirname = argv[1];
|
||||
@@ -109,30 +114,47 @@ int main(int argc, char **argv) {
|
||||
argv += 1;
|
||||
argc -= 1;
|
||||
}
|
||||
- }
|
||||
- if (argc > 0) {
|
||||
- string command(argv[0]);
|
||||
- if (command == "unittests") {
|
||||
+ else if (command == "unittests") {
|
||||
runUnitTests = true;
|
||||
runDataTests = false; // Run only unit tests
|
||||
unitTestNames.insert(argv + 1,argv + argc);
|
||||
+ break;
|
||||
}
|
||||
else if (command == "datatests") {
|
||||
runUnitTests = false; // Run only data-tests
|
||||
runDataTests = true;
|
||||
dataTestNames.insert(argv + 1,argv + argc);
|
||||
+ break;
|
||||
}
|
||||
else {
|
||||
- cout << "USAGE: ghidra_test [-path <datatestdir>] [[unittests|datatests] [testname1 testname2 ...]]" << endl;
|
||||
+ cout << "USAGE: ghidra_test [-usesleighenv] [-sleighpath <sleighdir>] [-path <datatestdir>] [[unittests|datatests] [testname1 testname2 ...]]" << endl;
|
||||
+ return -1;
|
||||
}
|
||||
}
|
||||
startDecompilerLibrary(sleighdirname.c_str());
|
||||
- if (runUnitTests)
|
||||
- UnitTest::run(unitTestNames);
|
||||
+
|
||||
+ // Keep track of failed tests as return code to indicate failures, clamped at
|
||||
+ // max 255 value
|
||||
+ int failedTests = 0;
|
||||
+ if (runUnitTests) {
|
||||
+ int errors = UnitTest::run(unitTestNames);
|
||||
+ // Clamp at 255 max return code
|
||||
+ failedTests = std::min(
|
||||
+ failedTests +
|
||||
+ (errors < 0 ? 255 : std::min(errors, 255)),
|
||||
+ 255);
|
||||
+ }
|
||||
if (runDataTests) {
|
||||
vector<string> testFiles;
|
||||
gatherDataTests(dirname,dataTestNames,testFiles);
|
||||
cout << endl << endl;
|
||||
- FunctionTestCollection::runTestFiles(testFiles,cout);
|
||||
+ int errors = FunctionTestCollection::runTestFiles(testFiles,cout);
|
||||
+ // Clamp at 255 max return code
|
||||
+ failedTests = std::min(
|
||||
+ failedTests +
|
||||
+ (errors < 0 ? 255 : std::min(errors, 255)),
|
||||
+ 255);
|
||||
}
|
||||
+
|
||||
+ return failedTests;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh
|
||||
index 8b762c5b1..a138f511d 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh
|
||||
@@ -54,7 +54,7 @@ struct UnitTest {
|
||||
tests.push_back(this);
|
||||
}
|
||||
|
||||
- static void run(std::set<std::string> &testNames); ///< Run all the instantiated tests
|
||||
+ static int run(std::set<std::string> &testNames); ///< Run all the instantiated tests
|
||||
};
|
||||
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc
|
||||
index 6311dba06..4f7110bb4 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.cc
|
||||
@@ -304,7 +304,7 @@ void FunctionTestCollection::runTests(list<string> &lateStream)
|
||||
/// Run through all XML files in the given list, processing each in turn.
|
||||
/// \param testFiles is the given list of test files
|
||||
/// \param s is the output stream to print results to
|
||||
-void FunctionTestCollection::runTestFiles(const vector<string> &testFiles,ostream &s)
|
||||
+int FunctionTestCollection::runTestFiles(const vector<string> &testFiles,ostream &s)
|
||||
|
||||
{
|
||||
int4 totalTestsApplied = 0;
|
||||
@@ -344,4 +344,5 @@ void FunctionTestCollection::runTestFiles(const vector<string> &testFiles,ostrea
|
||||
if (iter == failures.end()) break;
|
||||
}
|
||||
}
|
||||
+ return totalTestsApplied - totalTestsSucceeded;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh
|
||||
index 52125b401..46abd6bce 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/testfunction.hh
|
||||
@@ -91,7 +91,7 @@ class FunctionTestCollection {
|
||||
void restoreXml(DocumentStorage &store,const Element *el); ///< Load tests from a \<decompilertest> tag.
|
||||
void restoreXmlOldForm(DocumentStorage &store,const Element *el); ///< Load tests from \<binaryimage> tag.
|
||||
void runTests(list<string> &lateStream); ///< Run the script and perform the tests
|
||||
- static void runTestFiles(const vector<string> &testFiles,ostream &s); ///< Run tests for each listed file
|
||||
+ static int runTestFiles(const vector<string> &testFiles,ostream &s); ///< Run tests for each listed file
|
||||
};
|
||||
|
||||
#endif
|
||||
--
|
||||
2.38.1
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
From 5189064a0b81b74b5844b461f2f2b4d1a398ab59 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Thu, 28 Jul 2022 09:20:03 -0400
|
||||
Subject: [PATCH 2/4] Add include guards to decompiler C++ headers
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh | 6 ++++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh | 5 +++++
|
||||
.../Features/Decompiler/src/decompile/cpp/slgh_compile.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh | 6 ++++++
|
||||
6 files changed, 32 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
index 875d3bb78..6ade01ecc 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
@@ -17,6 +17,9 @@
|
||||
/// \file bfd_arch.hh
|
||||
/// \brief Specific implementation of Architecture using GNU BFD libraries
|
||||
|
||||
+#ifndef __BFD_ARCH__
|
||||
+#define __BFD_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage_bfd.hh"
|
||||
|
||||
@@ -47,3 +50,5 @@ class BfdArchitecture : public SleighArchitecture {
|
||||
BfdArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
|
||||
virtual ~BfdArchitecture(void) {}
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
index 364a5258d..edd6ce865 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
@@ -14,8 +14,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
+
|
||||
+#ifndef __GRAPH__
|
||||
+#define __GRAPH__
|
||||
+
|
||||
#include "funcdata.hh"
|
||||
|
||||
extern void dump_dataflow_graph(Funcdata &data,ostream &s);
|
||||
extern void dump_controlflow_graph(const string &name,const BlockGraph &graph,ostream &s);
|
||||
extern void dump_dom_graph(const string &name,const BlockGraph &graph,ostream &s);
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
index 3ca912dd6..0b70d8b22 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
@@ -16,6 +16,9 @@
|
||||
/// \file ifaceterm.hh
|
||||
/// \brief Add some terminal capabilities to the command-line interface (IfaceStatus)
|
||||
|
||||
+#ifndef __IFACE_TERM__
|
||||
+#define __IFACE_TERM__
|
||||
+
|
||||
#include "interface.hh"
|
||||
|
||||
#ifdef __TERMINAL__
|
||||
@@ -48,3 +51,5 @@ class IfaceTerm : public IfaceStatus {
|
||||
virtual void popScript(void);
|
||||
virtual bool isStreamFinished(void) const;
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
index 2245840a0..490abf901 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
/// \file raw_arch.hh
|
||||
/// \brief Bare bones capability for treating a file as a raw executable image
|
||||
+
|
||||
+#ifndef __RAW_ARCH__
|
||||
+#define __RAW_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage.hh"
|
||||
|
||||
@@ -46,3 +50,4 @@ class RawBinaryArchitecture : public SleighArchitecture {
|
||||
virtual ~RawBinaryArchitecture(void) {}
|
||||
};
|
||||
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
index e7ab19185..8fd9ba2fd 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
@@ -16,6 +16,9 @@
|
||||
/// \file slgh_compile.hh
|
||||
/// \brief High-level control of the sleigh compilation process
|
||||
|
||||
+#ifndef __SLGH_COMPILE__
|
||||
+#define __SLGH_COMPILE__
|
||||
+
|
||||
#include "sleighbase.hh"
|
||||
#include "pcodecompile.hh"
|
||||
#include "filemanage.hh"
|
||||
@@ -446,3 +449,5 @@ class SleighCompile : public SleighBase {
|
||||
|
||||
extern SleighCompile *slgh; ///< A global reference to the SLEIGH compiler accessible to the parse functions
|
||||
extern int yydebug; ///< Debug state for the SLEIGH parse functions
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
index d395fb8a3..6371148b0 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
/// \file xml_arch.hh
|
||||
/// \brief Extension to read executables based on an XML format
|
||||
+
|
||||
+#ifndef __XML_ARCH__
|
||||
+#define __XML_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage_xml.hh"
|
||||
|
||||
@@ -45,3 +49,5 @@ class XmlArchitecture : public SleighArchitecture {
|
||||
XmlArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
|
||||
virtual ~XmlArchitecture(void) {}
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.38.1
|
||||
|
||||
+11
-9
@@ -1,14 +1,16 @@
|
||||
From 773dda85b84a03c8795e27f1df87e6024bdb208a Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Wed, 3 Aug 2022 20:01:18 +1000
|
||||
Subject: [PATCH] Use `stroull` instead of `stroul` to parse address offsets
|
||||
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
|
||||
offsets
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/space.cc | 7 ++++++-
|
||||
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 c51e58560..c5cc7541d 100644
|
||||
index bf4e1dc9..594b4583 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
@@ -16,6 +16,8 @@
|
||||
@@ -17,10 +19,10 @@ index c51e58560..c5cc7541d 100644
|
||||
|
||||
+#include <climits>
|
||||
+
|
||||
namespace ghidra {
|
||||
|
||||
AttributeId ATTRIB_BASE = AttributeId("base",89);
|
||||
AttributeId ATTRIB_DEADCODEDELAY = AttributeId("deadcodedelay",90);
|
||||
AttributeId ATTRIB_DELAY = AttributeId("delay", 91);
|
||||
@@ -268,7 +270,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
@@ -290,7 +292,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
}
|
||||
}
|
||||
catch(LowlevelError &err) { // Name doesn't exist
|
||||
@@ -33,5 +35,5 @@ index c51e58560..c5cc7541d 100644
|
||||
enddata = (const char *) tmpdata;
|
||||
if (enddata - s.c_str() == s.size()) { // If no size or offset override
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.39.2 (Apple Git-143)
|
||||
|
||||
@@ -22,37 +22,44 @@ set_property(CACHE sleigh_RELEASE_TYPE PROPERTY STRINGS "stable" "HEAD")
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
# Ghidra pinned stable version commit
|
||||
set(ghidra_version "10.2.1")
|
||||
set(ghidra_version "11.0.2")
|
||||
set(ghidra_git_tag "Ghidra_${ghidra_version}_build")
|
||||
set(ghidra_shallow TRUE)
|
||||
|
||||
set(sleigh_ADDITIONAL_PATCHES "" CACHE STRING
|
||||
"The accepted patch format is git patch files, to be applied via git am. The format of the list is a CMake semicolon separated list.")
|
||||
|
||||
# See this thread for more details https://github.community/t/github-actions-bot-email-address/17204/5
|
||||
set(ghidra_patch_user "github-actions[bot]")
|
||||
set(ghidra_patch_email "41898282+github-actions[bot]@users.noreply.github.com")
|
||||
|
||||
# pinned stable patches list
|
||||
set(ghidra_patches
|
||||
PATCH_COMMAND "${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0001-Small-improvements-to-C-decompiler-testing-from-CLI.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0002-Add-include-guards-to-decompiler-C-headers.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0003-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0004-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
PATCH_COMMAND "${GIT_EXECUTABLE}" config user.name "${ghidra_patch_user}" &&
|
||||
"${GIT_EXECUTABLE}" config user.email "${ghidra_patch_email}" &&
|
||||
"${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"
|
||||
)
|
||||
|
||||
# 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.3")
|
||||
set(ghidra_head_version "11.1")
|
||||
set(ghidra_version "${ghidra_head_version}")
|
||||
set(ghidra_head_git_tag "97097daa681d43ee3a57c10523c382ec7cfafa88")
|
||||
set(ghidra_head_git_tag "2a7897c3661e03db2e6c1e0e42d2362b654790a2")
|
||||
set(ghidra_git_tag "${ghidra_head_git_tag}")
|
||||
set(ghidra_shallow FALSE)
|
||||
set(ghidra_patches
|
||||
PATCH_COMMAND "${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Small-improvements-to-C-decompiler-testing-from-CLI.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Add-include-guards-to-decompiler-C-headers.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0004-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
PATCH_COMMAND "${GIT_EXECUTABLE}" config user.name "${ghidra_patch_user}" &&
|
||||
"${GIT_EXECUTABLE}" config user.email "${ghidra_patch_email}" &&
|
||||
"${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-Fix-sleighexample.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0004-Fix-opening-sla-files-on-Windows.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0005-Add-missing-index-check-to-prevent-errors-in-Windows.patch"
|
||||
)
|
||||
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
|
||||
else()
|
||||
@@ -158,11 +165,13 @@ 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"
|
||||
)
|
||||
#if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# list(APPEND sleigh_deccore_source_list
|
||||
# )
|
||||
#endif()
|
||||
# if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# list(APPEND sleigh_deccore_source_list
|
||||
# )
|
||||
# endif()
|
||||
|
||||
set(sleigh_extra_source_list
|
||||
"${library_root}/callgraph.cc"
|
||||
@@ -192,6 +201,12 @@ set(sleigh_source_list
|
||||
"${library_root}/context.cc"
|
||||
"${library_root}/filemanage.cc"
|
||||
)
|
||||
if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
list(APPEND sleigh_source_list
|
||||
"${library_root}/slaformat.cc"
|
||||
"${library_root}/compression.cc"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(sleigh_ghidra_source_list
|
||||
"${library_root}/ghidra_arch.cc"
|
||||
@@ -205,7 +220,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,11 +28,14 @@ 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"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8eind.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8xmega.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/BPF/data/languages/BPF_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/CP1600/data/languages/CP1600.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/CR16/data/languages/CR16B.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/CR16/data/languages/CR16C.slaspec"
|
||||
@@ -56,6 +59,10 @@ 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/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"
|
||||
@@ -86,6 +93,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"
|
||||
@@ -121,8 +130,11 @@ 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"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/tricore/data/languages/tricore.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/x86/data/languages/x86-64.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/x86/data/languages/x86.slaspec"
|
||||
|
||||
@@ -28,11 +28,14 @@ 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"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8eind.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Atmel/data/languages/avr8xmega.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/BPF/data/languages/BPF_le.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/CP1600/data/languages/CP1600.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/CR16/data/languages/CR16B.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/CR16/data/languages/CR16C.slaspec"
|
||||
@@ -56,6 +59,10 @@ 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/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"
|
||||
@@ -86,6 +93,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"
|
||||
@@ -121,8 +130,11 @@ 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"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/tricore/data/languages/tricore.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/x86/data/languages/x86-64.slaspec"
|
||||
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/x86/data/languages/x86.slaspec"
|
||||
|
||||
@@ -59,6 +59,8 @@ target_include_directories(sleigh_support
|
||||
SYSTEM
|
||||
PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
|
||||
# For libconfig.h
|
||||
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
|
||||
)
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
|
||||
+112
-102
@@ -15,108 +15,118 @@
|
||||
#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 <sleigh/slghparse.hh>
|
||||
#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/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 <ghidra/slghparse.hh>
|
||||
} // End namespace ghidra
|
||||
#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>
|
||||
|
||||
// #ifdef sleigh_RELEASE_IS_HEAD
|
||||
// #endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
+36
-4
@@ -20,14 +20,16 @@ add_executable(sleigh_ghidra_test
|
||||
|
||||
"${library_root}/../unittests/testcirclerange.cc"
|
||||
"${library_root}/../unittests/testfloatemu.cc"
|
||||
"${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)
|
||||
# target_sources(sleigh_ghidra_test PRIVATE
|
||||
# )
|
||||
#endif()
|
||||
# if(sleigh_RELEASE_IS_HEAD)
|
||||
# target_sources(sleigh_ghidra_test PRIVATE
|
||||
# )
|
||||
# endif()
|
||||
|
||||
target_compile_features(sleigh_ghidra_test PRIVATE cxx_std_11)
|
||||
target_include_directories(sleigh_ghidra_test PRIVATE "${library_root}")
|
||||
@@ -40,6 +42,10 @@ if(HAVE_TERMIOS_H)
|
||||
endif()
|
||||
sleigh_add_optional_defines(sleigh_ghidra_test PRIVATE)
|
||||
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
target_link_libraries(sleigh_ghidra_test PRIVATE ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
add_test(
|
||||
NAME sleigh_ghidra_unittest
|
||||
COMMAND sleigh_ghidra_test -sleighpath "${PROJECT_BINARY_DIR}" unittests
|
||||
@@ -51,3 +57,29 @@ add_test(
|
||||
-path "${library_root}/../datatests"
|
||||
datatests
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Test for removal of using namespace std patches
|
||||
#
|
||||
if(sleigh_BUILD_SUPPORT)
|
||||
add_executable(sleigh_namespace_std_test
|
||||
no_using_namespace_std.cpp
|
||||
)
|
||||
target_link_libraries(sleigh_namespace_std_test
|
||||
PRIVATE
|
||||
sleigh::sla
|
||||
sleigh::decomp
|
||||
sleigh::support
|
||||
)
|
||||
if(WIN32)
|
||||
# Ensure no issue with /permissive- and std::byte colliding deeply in the
|
||||
# sleigh headers when compiling against Windows headers
|
||||
target_compile_features(sleigh_namespace_std_test PRIVATE cxx_std_20)
|
||||
endif()
|
||||
# Really only testing that it compiles
|
||||
add_test(
|
||||
NAME sleigh_namespace_std_test
|
||||
COMMAND sleigh_namespace_std_test
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
struct vector {};
|
||||
struct set {};
|
||||
struct unordered_map {};
|
||||
struct string {};
|
||||
|
||||
#include <sleigh/libsleigh.hh>
|
||||
|
||||
int main() {
|
||||
vector v;
|
||||
set s;
|
||||
unordered_map m;
|
||||
string str;
|
||||
}
|
||||
@@ -50,6 +50,11 @@ set_target_properties(sleigh_decompiler PROPERTIES
|
||||
OUTPUT_NAME_DEBUG decomp_dbg
|
||||
)
|
||||
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(sleigh_decompiler PRIVATE ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include("GNUInstallDirs")
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ set_target_properties(sleigh_ghidra PROPERTIES
|
||||
OUTPUT_NAME_DEBUG ghidra_dbg
|
||||
)
|
||||
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(sleigh_ghidra PRIVATE ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include("GNUInstallDirs")
|
||||
|
||||
|
||||
@@ -36,6 +36,11 @@ set_target_properties(sleigh_sleigh PROPERTIES
|
||||
OUTPUT_NAME_DEBUG sleigh_dbg
|
||||
)
|
||||
|
||||
if(sleigh_RELEASE_IS_HEAD)
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(sleigh_sleigh PRIVATE ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include("GNUInstallDirs")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user