mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Update Ghidra HEAD to commit 317a88148 (#245)
Upstream has added a compression mechanism for compiled sleigh files. They use Zlib to perform the compression and have added the source code to the Ghidra repo. However, this commit does not use Ghidra's Zlib source and instead searches for it on the host. This commit also fixes a number of bugs that prevent various parts of the CI pipeline from working on supported OSes. These patches will be reported upstream. Changed files: ``` M Ghidra/Features/Decompiler/src/decompile/cpp/Makefile M Ghidra/Features/Decompiler/src/decompile/cpp/address.hh M Ghidra/Features/Decompiler/src/decompile/cpp/architecture.hh M Ghidra/Features/Decompiler/src/decompile/cpp/block.hh M Ghidra/Features/Decompiler/src/decompile/cpp/comment.hh A Ghidra/Features/Decompiler/src/decompile/cpp/compression.cc A Ghidra/Features/Decompiler/src/decompile/cpp/compression.hh M Ghidra/Features/Decompiler/src/decompile/cpp/float.cc M Ghidra/Features/Decompiler/src/decompile/cpp/float.hh M Ghidra/Features/Decompiler/src/decompile/cpp/flow.cc M Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc M Ghidra/Features/Decompiler/src/decompile/cpp/fspec.hh M Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh M Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_block.cc M Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc M Ghidra/Features/Decompiler/src/decompile/cpp/inject_sleigh.cc M Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh M Ghidra/Features/Decompiler/src/decompile/cpp/marshal.cc M Ghidra/Features/Decompiler/src/decompile/cpp/marshal.hh M Ghidra/Features/Decompiler/src/decompile/cpp/op.cc M Ghidra/Features/Decompiler/src/decompile/cpp/op.hh M Ghidra/Features/Decompiler/src/decompile/cpp/options.cc M Ghidra/Features/Decompiler/src/decompile/cpp/pcodeparse.cc M Ghidra/Features/Decompiler/src/decompile/cpp/pcodeparse.y M Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc M Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh A Ghidra/Features/Decompiler/src/decompile/cpp/slaformat.cc A Ghidra/Features/Decompiler/src/decompile/cpp/slaformat.hh M Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc M Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.cc M Ghidra/Features/Decompiler/src/decompile/cpp/sleighbase.cc M Ghidra/Features/Decompiler/src/decompile/cpp/sleighbase.hh M Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh M Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.hh M Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.y M Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.hh M Ghidra/Features/Decompiler/src/decompile/cpp/slghpattern.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghpattern.hh M Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l M Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.hh M Ghidra/Features/Decompiler/src/decompile/cpp/space.cc M Ghidra/Features/Decompiler/src/decompile/cpp/space.hh M Ghidra/Features/Decompiler/src/decompile/cpp/translate.cc M Ghidra/Features/Decompiler/src/decompile/cpp/translate.hh M Ghidra/Features/Decompiler/src/decompile/cpp/type.cc M Ghidra/Features/Decompiler/src/decompile/unittests/testfuncproto.cc M Ghidra/Features/Decompiler/src/decompile/unittests/testmarshal.cc A Ghidra/Features/Decompiler/src/decompile/zlib/README.txt A Ghidra/Features/Decompiler/src/decompile/zlib/adler32.c A Ghidra/Features/Decompiler/src/decompile/zlib/deflate.c A Ghidra/Features/Decompiler/src/decompile/zlib/deflate.h A Ghidra/Features/Decompiler/src/decompile/zlib/gzguts.h A Ghidra/Features/Decompiler/src/decompile/zlib/inffast.c A Ghidra/Features/Decompiler/src/decompile/zlib/inffast.h A Ghidra/Features/Decompiler/src/decompile/zlib/inffixed.h A Ghidra/Features/Decompiler/src/decompile/zlib/inflate.c A Ghidra/Features/Decompiler/src/decompile/zlib/inflate.h A Ghidra/Features/Decompiler/src/decompile/zlib/inftrees.c A Ghidra/Features/Decompiler/src/decompile/zlib/inftrees.h A Ghidra/Features/Decompiler/src/decompile/zlib/trees.c A Ghidra/Features/Decompiler/src/decompile/zlib/trees.h A Ghidra/Features/Decompiler/src/decompile/zlib/zconf.h A Ghidra/Features/Decompiler/src/decompile/zlib/zlib.h A Ghidra/Features/Decompiler/src/decompile/zlib/zutil.c A Ghidra/Features/Decompiler/src/decompile/zlib/zutil.h M Ghidra/Processors/68000/data/languages/68000.ldefs M Ghidra/Processors/AARCH64/certification.manifest M Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefs M Ghidra/Processors/AARCH64/data/languages/AARCH64.opinion A Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec M Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefs M Ghidra/Processors/ARM/data/languages/ARM.ldefs M Ghidra/Processors/Loongarch/data/languages/loongarch.ldefs M Ghidra/Processors/MIPS/data/languages/mips.ldefs M Ghidra/Processors/PA-RISC/data/languages/pa-risc.sinc M Ghidra/Processors/PowerPC/data/languages/ppc.ldefs M Ghidra/Processors/RISCV/data/languages/riscv.ldefs M Ghidra/Processors/Sparc/data/languages/SparcV9.ldefs M Ghidra/Processors/SuperH4/data/languages/SuperH4.ldefs M Ghidra/Processors/Xtensa/data/languages/xtensa.ldefs M Ghidra/Processors/x86/certification.manifest A Ghidra/Processors/x86/data/languages/x86-64-swift.cspec M Ghidra/Processors/x86/data/languages/x86.ldefs M Ghidra/Processors/x86/data/languages/x86.opinion ```
This commit is contained in:
committed by
GitHub
parent
f2323af0ee
commit
24b9034914
+30
-12
@@ -55,7 +55,9 @@ jobs:
|
||||
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}
|
||||
@@ -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
|
||||
@@ -132,15 +138,25 @@ jobs:
|
||||
./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 }}
|
||||
@@ -148,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
|
||||
@@ -223,14 +250,5 @@ jobs:
|
||||
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
|
||||
|
||||
+19
-4
@@ -140,10 +140,12 @@ set(public_include_header_list
|
||||
"${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)
|
||||
@@ -158,6 +160,11 @@ endforeach()
|
||||
# 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
|
||||
#
|
||||
@@ -190,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
|
||||
#
|
||||
@@ -217,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")
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
"inherits": ["flags-windows", "ci-std"],
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"architecture": "x64",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
|
||||
},
|
||||
"hidden": true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ This repository provides a CMake-based build project for Sleigh so that it can b
|
||||
|
||||
| Name | Version | Linux Package to Install | macOS Homebrew Package to Install |
|
||||
| ---- | ------- | ------------------------ | --------------------------------- |
|
||||
| (HEAD builds) [zlib](https://www.zlib.net/) | Recent | zlib1g-dev | zlib |
|
||||
| [Git](https://git-scm.com/) | Latest | git | N/A |
|
||||
| [CMake](https://cmake.org/) | 3.18+ | cmake | cmake |
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -265,8 +265,14 @@ int main(int argc, char *argv[]) {
|
||||
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) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 67ac779382508ab0d5ff10bcb0a8453068cce5a2 Mon Sep 17 00:00:00 2001
|
||||
From 6c36965500d26d5a35dfbc91725956ae1d51e394 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Mon, 5 Jun 2023 16:45:04 +1200
|
||||
Subject: [PATCH 1/2] Fix UBSAN errors in decompiler
|
||||
Subject: [PATCH 1/5] Fix UBSAN errors in decompiler
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
|
||||
@@ -13,16 +13,15 @@ Subject: [PATCH 1/2] 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 +-
|
||||
12 files changed, 57 insertions(+), 21 deletions(-)
|
||||
11 files changed, 56 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
index 82771cc04..da78c8071 100644
|
||||
index dc96f0c19..3482cf17c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
@@ -2661,8 +2661,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
@@ -2727,8 +2727,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
modellist.push_back(mymodel);
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
@@ -38,7 +37,7 @@ index 82771cc04..da78c8071 100644
|
||||
|
||||
void ParameterBasic::setTypeLock(bool val)
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
index f77817073..283d81c31 100644
|
||||
index fc094ee96..1f7e53ebe 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
@@ -503,7 +503,13 @@ void Funcdata::setHighLevel(void)
|
||||
@@ -57,10 +56,10 @@ index f77817073..283d81c31 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 0e3decc80..403ec35a7 100644
|
||||
index 921335173..46cdc39f3 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
@@ -672,7 +672,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
@@ -666,7 +666,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
break;
|
||||
case CPUI_PIECE:
|
||||
resmask = getIn(0)->getNZMask();
|
||||
@@ -136,7 +135,7 @@ index ca9d71ab9..85d4dd281 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
index ae2e502c1..a22b8ebdc 100644
|
||||
index 3703c8ef5..ac6e21c00 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -153,7 +152,7 @@ index ae2e502c1..a22b8ebdc 100644
|
||||
consume = ~consume;
|
||||
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
|
||||
|
||||
@@ -6789,8 +6794,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -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;
|
||||
@@ -165,7 +164,7 @@ index ae2e502c1..a22b8ebdc 100644
|
||||
Varnode *vn1 = op->getIn(1);
|
||||
if (!vn1->isConstant()) return 0;
|
||||
Varnode *outvn = op->getOut();
|
||||
@@ -8600,7 +8606,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -8616,7 +8622,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 flowsize = outvn->getSize();
|
||||
uintb mask = calc_mask( flowsize );
|
||||
@@ -179,7 +178,7 @@ index ae2e502c1..a22b8ebdc 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 2e3531ea2..42482be7c 100644
|
||||
index cd9b9835b..8a4616c3b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
@@ -22,6 +22,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
@@ -199,12 +198,12 @@ index 2e3531ea2..42482be7c 100644
|
||||
|
||||
bool ConstTpl::isConstSpace(void) const
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
index 8e283dca0..652600c16 100644
|
||||
index e0b069959..9117a45c7 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
static void printHandleSelector(ostream &s,v_field val);
|
||||
static v_field readHandleSelector(const string &name);
|
||||
@@ -47,7 +47,7 @@ class ConstTpl {
|
||||
uintb value_real;
|
||||
v_field select; // Which part of handle to use as constant
|
||||
public:
|
||||
- ConstTpl(void) { type = real; value_real = 0; }
|
||||
+ ConstTpl(void) { type = real; value_real = 0; select = v_space; }
|
||||
@@ -212,10 +211,10 @@ index 8e283dca0..652600c16 100644
|
||||
type=op2.type; value=op2.value; value_real=op2.value_real; select=op2.select; }
|
||||
ConstTpl(const_type tp,uintb val);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
index b40f74389..3c37958df 100644
|
||||
index c060053bf..c9004023c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
@@ -2163,8 +2163,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
@@ -2164,8 +2164,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
ostringstream msg;
|
||||
SymbolTree::const_iterator iter;
|
||||
for(iter=scope->begin();iter!=scope->end();++iter) {
|
||||
@@ -225,24 +224,11 @@ index b40f74389..3c37958df 100644
|
||||
if (sym->getRefCount() == 0)
|
||||
msg << " Label <" << sym->getName() << "> was placed but not used" << endl;
|
||||
else if (!sym->isPlaced())
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
index b308e1b71..af2982aee 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
@@ -2569,7 +2569,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
const List &list(el->getChildren());
|
||||
List::const_iterator iter;
|
||||
iter = list.begin();
|
||||
- patexp = (PatternValue *)PatternExpression::restoreExpression(*iter,trans);
|
||||
+ patexp = PatternExpression::restoreExpression(*iter,trans);
|
||||
patexp->layClaim();
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index 32ede6b0f..238d97f40 100644
|
||||
index e6292e138..bd31b7470 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -3384,8 +3384,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
@@ -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()) {
|
||||
@@ -266,5 +252,5 @@ index c35bde877..061e53677 100644
|
||||
uintb true_result = ((uintb)(int32_t)f) & 0xffffffff;
|
||||
uintb encoding = format.getEncoding(f);
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.44.0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 9fd26cd754b6f83e45199db896fd0fcea23cd59d 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 2/2] 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 2/2] Use `stroull` instead of `stroul` to parse address
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
index bf4e1dc96..594b4583a 100644
|
||||
index 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 @@
|
||||
@@ -21,7 +21,7 @@ index bf4e1dc96..594b4583a 100644
|
||||
namespace ghidra {
|
||||
|
||||
AttributeId ATTRIB_BASE = AttributeId("base",89);
|
||||
@@ -290,7 +292,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
@@ -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 bf4e1dc96..594b4583a 100644
|
||||
enddata = (const char *) tmpdata;
|
||||
if (enddata - s.c_str() == s.size()) { // If no size or offset override
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.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
|
||||
|
||||
@@ -48,7 +48,7 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# TODO: CMake only likes numeric characters in the version string....
|
||||
set(ghidra_head_version "11.1")
|
||||
set(ghidra_version "${ghidra_head_version}")
|
||||
set(ghidra_head_git_tag "c5bad0a88f31b4b63bd75ca669486ebd1eeec3fb")
|
||||
set(ghidra_head_git_tag "317a8814883804f0c4f18c64d97411b1c6d6283e")
|
||||
set(ghidra_git_tag "${ghidra_head_git_tag}")
|
||||
set(ghidra_shallow FALSE)
|
||||
set(ghidra_patches
|
||||
@@ -57,6 +57,9 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-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()
|
||||
@@ -198,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"
|
||||
|
||||
@@ -42,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
|
||||
|
||||
@@ -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