Compare commits

..

69 Commits

Author SHA1 Message Date
Eric Kilmer 4db93c4191 Ghidra 12.0.4 (#403) 2026-03-04 10:51:47 -05:00
Eric Kilmer c0160c4205 ci: Don't archive when using upload-artifact GHA (#402)
Prevents rpm and deb packages from being zipped
2026-03-02 09:21:54 -05:00
dependabot[bot] 1d1d978f0d build(deps): bump actions/upload-artifact from 6 to 7 (#400)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-02 09:00:48 -05:00
auto-updater[bot] 7afb02ef95 Update Ghidra HEAD to commit fc73f70b9 (#401)
Bump Ghidra HEAD commit fc73f70b9

Changed files:

```
M	Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc
M	Ghidra/Processors/AARCH64/data/languages/AARCH64instructions.sinc
```

Commit details:

```
[Commit 1/3]
Hash: ea52a687b2ee0070c868dfc0234001479fce2988
Date: 2026-02-24 10:49:41 -0500
Message: GP-6448: Added AARCH64 CSSC instructions

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64instructions.sinc

[Commit 2/3]
Hash: 3fbe33860b6a66815f888415e05539084f596fbd
Date: 2024-04-30 13:33:09 +0930
Message: AA64: fix ldar load size for 32bit variant

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc

[Commit 3/3]
Hash: bbe8d7ca93ab42dad6aa0afa1e0fa1b6ab62c608
Date: 2024-04-30 14:30:35 +0930
Message: AA64: fix ldpsw increment size to match load

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc
```

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-02 08:01:02 -05:00
Eric Kilmer 6ecd80ee22 Merge branch 'ekilmer/run-asan-v2': Add ASAN/UBSAN and libc++ assertions CI
Add sanitizer and assertions CI jobs, fix UBSAN signed left shift
errors, and port the compareFinalOrder strict-weak ordering patch
to stable. Drop redundant Linux/macOS Debug builds in favor of
these more targeted checks.

* ekilmer/run-asan-v2:
  Add compareFinalOrder strict-weak ordering patch to stable
  Drop Debug builds on Linux and macOS in favor of sanitizer/assertions
  Install LLVM explicitly in sanitizer and assertions CI jobs
  Add libc++ assertions CI job for strict-weak ordering checks
  Add ASAN/UBSAN CI testing and fix signed left shift UB
2026-02-25 23:05:06 +00:00
Eric Kilmer 0c1eeeae77 Add compareFinalOrder strict-weak ordering patch to stable
Port the existing HEAD patch (0007) to stable as well.
FlowBlock::compareFinalOrder returns true when both blocks have
index 0, violating strict weak ordering irreflexivity. This is
caught by the libc++ assertions CI job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:40:23 +00:00
Eric Kilmer f696911f67 Drop Debug builds on Linux and macOS in favor of sanitizer/assertions
The sanitizer and assertions CI jobs provide more useful Debug-like
coverage on Linux than a plain Debug build. Keep Debug builds only for
Windows where sanitizers are not available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:04:22 +00:00
Eric Kilmer 27289bcc29 Install LLVM explicitly in sanitizer and assertions CI jobs
Use the official LLVM apt script to install clang rather than relying
on whichever version happens to ship on the runner. The version is
configured via a workflow-level LLVM_VERSION env variable (currently 21)
so bumping is a one-line change.

The assertions job also installs the matching versioned libc++-dev and
libc++abi-dev packages.

Remove CMAKE_CXX_COMPILER from the ci-assertions preset so the CXX
environment variable is respected by CMake in both CI and local use.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 22:02:26 +00:00
Eric Kilmer 876fc733fb Add libc++ assertions CI job for strict-weak ordering checks
Add a ci-assertions CMake preset that builds with libc++ in debug
hardening mode (_LIBCPP_HARDENING_MODE_DEBUG), which catches STL
contract violations at runtime — most importantly strict-weak ordering
violations in comparators passed to std::sort.

Add a corresponding assertions CI job that runs HEAD-only, since new
comparator bugs from upstream Ghidra surface there first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:16:45 +00:00
Eric Kilmer b6adc0337a Add ASAN/UBSAN CI testing and fix signed left shift UB
Add a sanitizer CI job that builds and tests with AddressSanitizer and
UndefinedBehaviorSanitizer using clang on Ubuntu for both stable and
HEAD release tracks.

Fix three UBSAN signed left shift errors found during sanitizer testing
by casting signed values to unsigned before left shifting:
- address.hh sign_extend(): left shift of negative value / overflow
- slghpatexpress.cc LeftShiftExpression: left shift of negative value

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:16:13 +00:00
Eric Kilmer 4578ac2fba Add claude skill to help debug test failures
This will likely improve over time as more tests fail or different
methods for exposing bugs are used (like sanitizers)
2026-02-25 16:34:05 +00:00
Eric Kilmer 1b2041b6aa Add CLAUDE.md 2026-02-25 16:34:05 +00:00
Eric Kilmer eb980ff91d Add devcontainer for debugging with latest build tools
Provides a sandboxed Ubuntu 24.04 environment with LLVM 21
(clang, clangd, lld, lldb, libc++), cmake, ninja, and ccache
for building and debugging the decompiler with up-to-date tooling.

While there are only minimal VSCode extensions installed by default, I
automatically install Claude Code and my own dotfiles plus additional tools
2026-02-25 16:31:37 +00:00
auto-updater[bot] fbefd7d828 Update Ghidra HEAD to commit e3c1b6393 (#397)
* Bump Ghidra HEAD commit e3c1b6393

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
M	Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
A	Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc
A	Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/block.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/constseq.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/flow.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.cc
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/funcdata_varnode.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/grammar.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/grammar.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/grammar.y
M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.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/op.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/opcodes.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/printjava.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/printlanguage.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/printlanguage.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/type.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.hh
```

Commit details:

```
[Commit 1/2]
Hash: bf1f4288aa3b317e3c097773ba4b8e7b89ae09c7
Date: 2026-02-10 19:33:46 +0000
Message: GP-5922 Integer formatting for switch cases

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/block.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/flow.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_block.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printjava.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printlanguage.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printlanguage.hh

[Commit 2/2]
Hash: 402d10d6cc66e1fcf3d8f36bc851ef652773e018
Date: 2025-09-05 00:01:44 +0000
Message: GP-2493 Bitfield support in the Decompiler

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
  M	Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
  A	Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc
  A	Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/constseq.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/grammar.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/grammar.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/grammar.y
  M	Ghidra/Features/Decompiler/src/decompile/cpp/marshal.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/opcodes.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printlanguage.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/printlanguage.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/type.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.hh
```

* Add new C++ files to CMake

* Fix more strict weak ordering issues

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eric Kilmer <eric.kilmer@trailofbits.com>
2026-02-24 22:11:46 -05:00
auto-updater[bot] 9daaa780c2 Update Ghidra HEAD to commit 0ee235fba (#396)
Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/constseq.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/constseq.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_op.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
M	Ghidra/Processors/8051/data/languages/80251.sinc
M	Ghidra/Processors/AARCH64/data/languages/AARCH64.pspec
M	Ghidra/Processors/AARCH64/data/languages/AARCH64neon.sinc
M	Ghidra/Processors/ARM/data/languages/ARMinstructions.sinc
M	Ghidra/Processors/CR16/data/languages/CR16C.sinc
M	Ghidra/Processors/MIPS/data/languages/mips16.sinc
M	Ghidra/Processors/PIC/data/languages/pic18_instructions.sinc
M	Ghidra/Processors/PowerPC/data/languages/altivec.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc
```

Commit details:

```
[Commit 1/19]
Hash: 1660b9ca4718c9907d279653a99c6d4190a1071f
Date: 2026-02-09 15:33:05 +0000
Message: GP-6419: Fixed MIPS16 pcodetest failures

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 2/19]
Hash: a05ba1f778511e92abc29c933cb17da9477cc7c5
Date: 2026-02-05 23:13:56 +0000
Message: GP-6416 Add support for simplifying unequal LEFT then RIGHT shifts

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc

[Commit 3/19]
Hash: 690a23344f9de200056b8e7af4384e26f42e300b
Date: 2026-02-05 19:28:59 +0000
Message: GP-6393 Deduplicate INDIRECT storage for HeapSequence

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/constseq.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/constseq.hh

[Commit 4/19]
Hash: 6ced49d1d7fd91663e7627b11fc4e68dd06bca1c
Date: 2026-02-03 16:08:01 +0000
Message: GP-4241: Discoverable per-arch userop-lib framework and AARCH64 port.

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64.pspec

[Commit 5/19]
Hash: 9a9b6cd063bc830c749804be0ab4213ec8de0010
Date: 2026-01-29 20:26:27 +0000
Message: GP-6388 Adjust getInputCast for TypeOpPtradd and TypeOpPtrsub

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc

[Commit 6/19]
Hash: c9be1860c181581ee192cb86e97eeec983a6bf00
Date: 2024-05-28 17:09:24 +0930
Message: AArch32: fixed ldrexd
Details:
* fixed addr src register aliased as first dest register of a double word load causing second word load at the value of first load

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARMinstructions.sinc

[Commit 7/19]
Hash: c0bc9a882b7e6c6d3c0549c4410a8ae1abb68f00
Date: 2024-02-08 10:19:47 +0100
Message: PowerPC VLE: Fix se_blrl flow
Details:
Opcode se_blrl is branch link register and link. Treating it as a return break flow and is wrong. Non VLE is already correct.

Files changed:
  M	Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc

[Commit 8/19]
Hash: e94681701a89f34cf35edc18085684a8e40fc6b7
Date: 2025-12-02 02:03:52 +0100
Message: CR16: fix CR16C TBIT instruction

Files changed:
  M	Ghidra/Processors/CR16/data/languages/CR16C.sinc

[Commit 9/19]
Hash: af8a3704212b157d21bfddad834f6485fdfabeb1
Date: 2025-12-02 22:00:49 +0100
Message: Fix eBPF compare-and-exchange instruction
Details:
Linux kernel's documentation tells in
https://www.kernel.org/doc/html/v6.0/bpf/instruction-set.html#atomic-operations

> The BPF_CMPXCHG operation atomically compares the value addressed by
> dst_reg + off with R0. If they match, the value addressed by
> dst_reg + off is replaced with src_reg. In either case, the value that
> was at dst_reg + off before the operation is zero-extended and loaded
> back to R0.

If the values don't match, *(dst_reg + off) is not supposed to be
modified.

Moreover, register R0 is always modified and the 32-bit instruction
truncates its value (with a zero-extension). This is also clear in the
implementation of BPF_CMPXCHG in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf/core.c?h=v6.18#n2186

    case BPF_CMPXCHG:
            if (BPF_SIZE(insn->code) == BPF_W)
                    BPF_R0 = (u32) atomic_cmpxchg(
                            (atomic_t *)(unsigned long) (DST + insn->off),
                            (u32) BPF_R0, (u32) SRC);
            else if (BPF_SIZE(insn->code) == BPF_DW)
                    BPF_R0 = (u64) atomic64_cmpxchg(
                            (atomic64_t *)(unsigned long) (DST + insn->off),
                            (u64) BPF_R0, (u64) SRC);

Fix the semantic of the compare-and-exchange instruction accordingly.

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc

[Commit 10/19]
Hash: ff6eb2213bca878cdcef0e9cec20e524d8d9f944
Date: 2025-12-02 16:19:37 +0100
Message: Fix disassembly of eBPF atomic instructions
Details:
eBPF ISA v3 introduced atomic instructions:
https://www.kernel.org/doc/html/v6.0/bpf/instruction-set.html#atomic-operations

These instructions are encoded using BPF_ATOMIC | BPF_W  | BPF_STX
and BPF_ATOMIC | BPF_DW | BPF_STX for 32-bit and 64-bit operations,
with:

    BPF_ATOMIC = 0xc0
    BPF_DW = 0x18
    BPF_W = 0
    BPF_STX = 0x03

While Ghidra's semantic section is constructed correctly (atomic add
uses an addition ; atomic or uses or ; ...), the disassembly always
displays STXXADDW and STXXADDDW. These mnemonics come from the
deprecated name BPF_XADD = BPF_ATOMIC | BPF_ADD = 0xc0.

Replace the confusing mnemonics with the ones used by binutils and
documented in
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/doc/c-bpf.texi;h=003cb92a457985038a9abc1ffbf347f636eb0586;hb=2bc7af1ff7732451b6a7b09462a815c3284f9613#l745

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc

[Commit 11/19]
Hash: c1f97cde08ab235c0fe9adb723971a608550fdc2
Date: 2025-12-22 19:47:24 +0100
Message: Fix missing Altivec vadduws instruction

Files changed:
  M	Ghidra/Processors/PowerPC/data/languages/altivec.sinc

[Commit 12/19]
Hash: c981c0b5dd19818117178f3ce4a9d8737c306e65
Date: 2025-12-16 20:07:56 +0000
Message: GP-6004: Refactored out duplicated constructors

Files changed:
  M	Ghidra/Processors/PIC/data/languages/pic18_instructions.sinc

[Commit 13/19]
Hash: 78859d55fdf28dfbe9dac0658948754515d44e36
Date: 2025-12-04 19:25:56 +0000
Message: GP-5905: Fixed issue with 80251 instructions referencing SPX register

Files changed:
  M	Ghidra/Processors/8051/data/languages/80251.sinc

[Commit 14/19]
Hash: 826834c424b631358f06899dfd0203138ba2cb7d
Date: 2025-11-25 13:32:37 +0100
Message: decompiler: Fix extreme value checks in Funcdata::replaceLessequal
Details:
Fixes https://github.com/NationalSecurityAgency/ghidra/issues/8696

The checks for extreme values when transforming <= to < were incomplete
and relied on undefined behavior, making compilers optimize them out.

Specifically, for SLESS_EQUAL, the decompiler relied on integer overflows.
For integers smaller than 8 bytes, no overflow will occur when adding 1,
resulting in a missed case and, thus, x <= INT_MAX will become x < INT_MIN.
For the signed case when subtracting one, the compiler removes the check
due to undefined behavior, resulting in another missed case.

To fix this, add helper functions for computing maximum and minimum values
for signed and unsigned varnodes and directly check for them.

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_op.cc

[Commit 15/19]
Hash: 2e3bedf7daf1c5c38cbf1c3f90b6f4cd449f7020
Date: 2025-11-04 13:50:15 +0000
Message: GP-6004: Corrected bit-pattern comments

Files changed:
  M	Ghidra/Processors/PIC/data/languages/pic18_instructions.sinc

[Commit 16/19]
Hash: 49c13a7ba733f2af63f3d33d83cba8103456249e
Date: 2025-09-17 10:43:57 +0200
Message: missed one

Files changed:
  M	Ghidra/Processors/PIC/data/languages/pic18_instructions.sinc

[Commit 17/19]
Hash: 48ca4badb7ea2eb18ffd6f9b6ede356932160067
Date: 2025-09-13 16:17:07 -0700
Message: forgot to take out this change

Files changed:
  M	Ghidra/Processors/PIC/data/languages/pic18_instructions.sinc

[Commit 18/19]
Hash: 7fa6bda98ee9a350be49c0b4a8f9cf8c83b39490
Date: 2025-09-10 00:58:15 -0700
Message: remove destREG to fix double inc/dec

Files changed:
  M	Ghidra/Processors/PIC/data/languages/pic18_instructions.sinc

[Commit 19/19]
Hash: 5e4522fc3a2a547c9b1c94ab293890bb9f767ac3
Date: 2024-04-09 16:43:13 +0930
Message: AA64: Change sha1h shift to rotate

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64neon.sinc
```

---------

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-17 09:59:06 -05:00
Eric Kilmer 0eb9da05b7 ci: Fix GHA PR update script message character escaping 2026-02-17 09:36:10 -05:00
Eric Kilmer 76278daf20 ci: Fix app-id and private-key options to create-github-app-token 2026-02-17 09:13:42 -05:00
Eric Kilmer db0dc4c479 Ghidra 12.0.3 (#395) 2026-02-11 09:24:27 -05:00
Eric Kilmer efe3b7dcbd Ghidra 12.0.2 (#394) 2026-01-31 17:21:45 -05:00
Eric Kilmer d4b0316955 Use official actions/create-github-app-token (#393) 2026-01-26 17:03:10 -05:00
Eric Kilmer 86f39ba60f Detect new files requiring manual intervention in Ghidra HEAD updates (#390)
Add functionality to the weekly sync workflow to detect newly added or
deleted C++ source files and spec files that may require manual CMake
configuration updates. When such files are detected, the PR body will
include a warning section listing the files and instructions for
maintainers.

This addresses issue #121 where new files added to Sleigh in Ghidra
weren't being noticed, leading to missing headers that required manual
fixes later.

Changes:
- Add CategorizedChanges dataclass to track added/deleted cpp/spec files
- Add helper methods to parse git status and categorize files
- Expand IGNORED_EXTENSIONS to filter more non-relevant file types
- Set new GitHub Actions outputs: needs_manual_intervention and
  intervention_details
- Update workflow to conditionally add warning section to PR body

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 09:44:50 -05:00
dependabot[bot] 0dd2d21bdc build(deps): bump actions/upload-pages-artifact from 3 to 4 (#392)
Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-pages-artifact/releases)
- [Commits](https://github.com/actions/upload-pages-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-pages-artifact
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-26 08:24:01 -05:00
auto-updater[bot] d02e760030 Update Ghidra HEAD to commit ccbdd4f66 (#391)
Bump Ghidra HEAD commit ccbdd4f66

Changed files:

```
M	Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc
```

Commit details:

```
[Commit 1/1]
Hash: b5fb4d36ed94a83c52fcf11b701f43b2ef18404a
Date: 2024-05-29 00:43:57 +0930
Message: AA64: Add ls_data8 to ldapr

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64base.sinc
```

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-26 00:40:10 +00:00
Eric Kilmer 42d2ee7457 Replace peter-evans/create-pull-request with native git and gh CLI (#389)
Reduces third-party dependencies by using native git commands and the
pre-installed gh CLI instead of the peter-evans/create-pull-request
action. Adds idempotency check to skip if PR already exists for branch.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 11:05:28 -05:00
Eric Kilmer 0664b5c545 Dark-mode for index.html 2026-01-23 17:51:57 -05:00
Eric Kilmer cd6078bb22 Publish both stable and HEAD docs to GitHub Pages 2026-01-23 17:44:19 -05:00
Eric Kilmer fc49d2340e Deploy Doxygen docs to GitHub Pages
https://lifting-bits.github.io/sleigh
2026-01-23 17:26:42 -05:00
auto-updater[bot] 1df5e051d3 Update Ghidra HEAD to commit 549735683 (#387)
Bump Ghidra HEAD commit 549735683

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/sleighbase.cc
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.y
M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.hh
M	Ghidra/Processors/RISCV/data/languages/riscv.opinion
```

Commit details:

```
[Commit 1/7]
Hash: 6208df2d50d716b4faf87d3a0c0603d45aac4cb3
Date: 2026-01-13 10:44:59 -0500
Message: GP-1 Corrected RISCV import opinion file

Files changed:
  M	Ghidra/Processors/RISCV/data/languages/riscv.opinion

[Commit 2/7]
Hash: 1789bb9c5e66cb1e5ad2072b73c4bf7fbc713f67
Date: 2026-01-12 21:00:06 -0500
Message: GP-1 minor doc fix

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc

[Commit 3/7]
Hash: 7828f235d315807d18ecb873fad34b209a02ce65
Date: 2026-01-12 21:51:54 +0000
Message: GP-6316 Increase maximum temporary size for SLEIGH to 256 bytes

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/sleighbase.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh

[Commit 4/7]
Hash: 4830a7ab99548aa898e861b967f48c92dd741f48
Date: 2026-01-12 19:33:12 +0000
Message: GP-6314 Reset label counter for every named section

Files changed:
  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.y

[Commit 5/7]
Hash: 123bd5cbe6d54105c96bb8a0b5c1b81f84b29e97
Date: 2026-01-09 20:37:38 +0000
Message: GP-6310 Apply extension patch if consumption is beyond small variable

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.hh

[Commit 6/7]
Hash: 451334568f3200f453b6b3985b5949f72747f1c6
Date: 2026-01-09 20:15:16 +0000
Message: Let RuleShiftAnd apply in more situations

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc

[Commit 7/7]
Hash: 92091a7a2ad59309514d808c7eb890492f5c49e8
Date: 2025-12-02 10:59:10 +0100
Message: decompiler: fix bit extractions with RuleShiftAnd and RuleShiftCompare
Details:
Fixes https://github.com/NationalSecurityAgency/ghidra/issues/8717

RuleShiftAnd previously replaced the AND opcode with COPY. This,
however doesn't update the NZMask of the Varnode. As a result, following
rules may assume the NZMask after the AND operation also applies to the
Varnode being copied.

In combination with RuleShiftCompare, an expression of the form
(a & bitmask) >> const != 0, wrongfully is reduced to a != 0.
Instead of replacing the AND with COPY, we now replace the input
of the shift operation instead. This way, future rules will see
the correct NZMask.

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
```
2026-01-19 08:56:30 -05:00
Eric Kilmer edc5fabd3a Ghidra 12.0.1 (#386) 2026-01-15 15:52:35 +00:00
auto-updater[bot] 9316045354 Update Ghidra HEAD to commit 6ef256cef (#385)
Bump Ghidra HEAD commit 6ef256cef

Changed files:

```
M	Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefs
M	Ghidra/Processors/AARCH64/data/languages/AARCH64.opinion
M	Ghidra/Processors/x86/data/languages/x86.opinion
```

Commit details:

```
[Commit 1/1]
Hash: ad00d5734f82266e7d58624a36075da33d8e3005
Date: 2025-12-23 19:04:43 -0500
Message: GP-3960: ElfLoader can now recognize Swift and golang

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefs
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64.opinion
  M	Ghidra/Processors/x86/data/languages/x86.opinion
```
2026-01-05 09:40:32 -05:00
auto-updater[bot] ec98f45ecf Update Ghidra HEAD to commit dc5836119 (#384)
Bump Ghidra HEAD commit dc5836119

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc
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/type.cc
```

Commit details:

```
[Commit 1/4]
Hash: 19836741896fd7664c9de9519a8841f9b593ae9f
Date: 2025-12-17 19:52:07 +0000
Message: GP-6237 Move the unique crossbuild region to more significant bits

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh

[Commit 2/4]
Hash: b8e698d97804de62a7dbf6664b0e3f264725c3d9
Date: 2025-09-12 20:10:43 +0000
Message: GP-3834 Allow 256 case switch, if a LOAD is present

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc

[Commit 3/4]
Hash: 6451d3d3135ba72a4c50f40667ad893b2c944de6
Date: 2025-12-12 00:17:12 +0000
Message: GP-6224 Don't resolve pointer if cast still required

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh

[Commit 4/4]
Hash: 9692dd064064ee712d8a724984f1b6b2bec4bc75
Date: 2025-12-10 19:26:03 +0000
Message: GP-6201 Check for free varnodes in functionalEqualityLevel0

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
```
2025-12-22 08:48:25 -05:00
dependabot[bot] e4b6ddb926 build(deps): bump actions/upload-artifact from 5 to 6 (#383)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-15 12:28:09 -05:00
auto-updater[bot] 9248e9114b Update Ghidra HEAD to commit 7bed72e38 (#382)
Bump Ghidra HEAD commit 7bed72e38

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_block.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
M	Ghidra/Processors/68000/data/languages/68000.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
```

Commit details:

```
[Commit 1/5]
Hash: 0e658ae5b6a48fbd688ada2303ad7257f75370ea
Date: 2025-11-18 17:19:57 +0000
Message: GP-6133 INT_ADD correction for RuleStructOffset0 applied to offset pointer

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc

[Commit 2/5]
Hash: 35ac4cf37cd1e10b14e0e758124dcc5a5741df1f
Date: 2025-11-17 22:23:38 +0000
Message: GP-6130 Correct pointer offsets for buildStore and buildLoad

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc

[Commit 3/5]
Hash: f8d7b704df457fe5a10e6bb9766e7bb34db3e98e
Date: 2025-11-04 20:44:18 +0000
Message: GP-6090 Adjustment for duplicate inputs in pushMultiequal

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_block.cc

[Commit 4/5]
Hash: 27b06c83a6c3ee05bebe2c60df2cc8b59a16b842
Date: 2025-02-03 17:36:04 +0000
Message: GP-5334: Corrected operand count for m68k addressing modes

Files changed:
  M	Ghidra/Processors/68000/data/languages/68000.sinc

[Commit 5/5]
Hash: b54347759775a2b9a8bb50afe4ed3a6c082a1bfb
Date: 2025-11-13 18:59:44 +0000
Message: GP-6109: Fixed issue with PPC assembler not assembling some instructions

Files changed:
  M	Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
```
2025-12-15 12:27:40 -05:00
dependabot[bot] a020faccb5 build(deps): bump actions/cache from 4 to 5 (#381)
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-12 09:08:45 -05:00
dependabot[bot] d74e8e9414 build(deps): bump peter-evans/create-pull-request from 7 to 8 (#380)
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7 to 8.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v7...v8)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-10 09:18:54 -05:00
Eric Kilmer f8229f609d Ghidra 12.0 (#379)
- Copied patches directly from `HEAD` to use on `stable`
2025-12-08 18:18:45 -05:00
auto-updater[bot] 4edfcef82e Update Ghidra HEAD to commit d83ea1754 (#378)
Bump Ghidra HEAD commit d83ea1754

Changed files:

```
A	Ghidra/Processors/NDS32/Module.manifest
A	Ghidra/Processors/NDS32/build.gradle
A	Ghidra/Processors/NDS32/certification.manifest
A	Ghidra/Processors/NDS32/data/languages/lsmw.sinc
A	Ghidra/Processors/NDS32/data/languages/nds32.cspec
A	Ghidra/Processors/NDS32/data/languages/nds32.dwarf
A	Ghidra/Processors/NDS32/data/languages/nds32.ldefs
A	Ghidra/Processors/NDS32/data/languages/nds32.opinion
A	Ghidra/Processors/NDS32/data/languages/nds32.pspec
A	Ghidra/Processors/NDS32/data/languages/nds32.sinc
A	Ghidra/Processors/NDS32/data/languages/nds32be.slaspec
A	Ghidra/Processors/NDS32/data/languages/nds32le.slaspec
A	Ghidra/Processors/NDS32/data/patterns/nds32_patterns.xml
A	Ghidra/Processors/NDS32/data/patterns/patternconstraints.xml
M	Ghidra/Processors/RISCV/data/languages/andestar_v5.instr.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv.reg.sinc
```

Commit details:

```
[Commit 1/9]
Hash: d0f88bf9023ac412b50460fe9e0ac5fc76f14d90
Date: 2025-12-04 12:28:50 -0500
Message: GP-6007 Remove Decompiler dependency

Files changed:
  M	Ghidra/Processors/NDS32/build.gradle

[Commit 2/9]
Hash: 923ceb52d4727a2227a8b2512593ec4fb03ab0e2
Date: 2025-12-04 11:25:54 -0500
Message: GP-6007 use -l sleigh compile option with NDS32

Files changed:
  M	Ghidra/Processors/NDS32/build.gradle

[Commit 3/9]
Hash: ddf4ad1182577f759b1c0e7c40d8825abd65b357
Date: 2025-12-03 22:06:38 +0000
Message: GP-6007 minor fixes for Andestar v5

Files changed:
  M	Ghidra/Processors/RISCV/data/languages/andestar_v5.instr.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv.reg.sinc

[Commit 4/9]
Hash: 2efa886f5ca0996d3ea9f1865d952aa2708389b6
Date: 2025-12-03 21:36:18 +0000
Message: GP-6007 minor fixes for mfusr, mtusr and csreg space as global in cspec

Files changed:
  M	Ghidra/Processors/NDS32/data/languages/nds32.cspec
  M	Ghidra/Processors/NDS32/data/languages/nds32.sinc

[Commit 5/9]
Hash: df6e4049d4f91f8cb9c9ff3888bb5f2a15a411d8
Date: 2025-12-02 20:21:14 +0000
Message: GP-6007: Added additional floating point config instructions

Files changed:
  M	Ghidra/Processors/NDS32/data/languages/nds32.sinc

[Commit 6/9]
Hash: 9bdd19cc087f889a16421b7cda082e2a08653449
Date: 2025-12-02 15:30:45 +0000
Message: GP-6007: Added CSR space and CSRs

Files changed:
  M	Ghidra/Processors/NDS32/data/languages/lsmw.sinc
  M	Ghidra/Processors/NDS32/data/languages/nds32.pspec
  M	Ghidra/Processors/NDS32/data/languages/nds32.sinc

[Commit 7/9]
Hash: ed4ae8bfa1f6b5db8c7356b2a4253c4c647e65f4
Date: 2025-11-26 20:19:40 +0000
Message: GP-6007: Added stubs for nds32 FPU instructions

Files changed:
  M	Ghidra/Processors/NDS32/build.gradle
  M	Ghidra/Processors/NDS32/data/languages/nds32.ldefs
  M	Ghidra/Processors/NDS32/data/languages/nds32.sinc
  M	Ghidra/Processors/NDS32/data/patterns/nds32_patterns.xml

[Commit 8/9]
Hash: 71cd33572c873b1eebd322032506c259632d0d52
Date: 2025-09-22 14:37:16 +0000
Message: GP-6007: Updated NDS32 analyzer and elf relocation handler and test fixups

Files changed:
  M	Ghidra/Processors/NDS32/build.gradle
  A	Ghidra/Processors/NDS32/certification.manifest
  D	Ghidra/Processors/NDS32/data/buildLanguage.xml
  M	Ghidra/Processors/NDS32/data/languages/lsmw.sinc
  M	Ghidra/Processors/NDS32/data/languages/nds32.cspec
  M	Ghidra/Processors/NDS32/data/languages/nds32.sinc
  M	Ghidra/Processors/NDS32/data/languages/nds32be.slaspec
  M	Ghidra/Processors/NDS32/data/languages/nds32le.slaspec
  D	Ghidra/Processors/NDS32/data/sleighArgs.txt

[Commit 9/9]
Hash: fa7c3b1fec5e133f5147b6c541d023c646c0b170
Date: 2020-04-16 18:58:10 +0200
Message: [NDS32] Add support for the NDS32 Processor

Files changed:
  A	Ghidra/Processors/NDS32/Module.manifest
  A	Ghidra/Processors/NDS32/build.gradle
  A	Ghidra/Processors/NDS32/data/buildLanguage.xml
  A	Ghidra/Processors/NDS32/data/languages/lsmw.sinc
  A	Ghidra/Processors/NDS32/data/languages/nds32.cspec
  A	Ghidra/Processors/NDS32/data/languages/nds32.dwarf
  A	Ghidra/Processors/NDS32/data/languages/nds32.ldefs
  A	Ghidra/Processors/NDS32/data/languages/nds32.opinion
  A	Ghidra/Processors/NDS32/data/languages/nds32.pspec
  A	Ghidra/Processors/NDS32/data/languages/nds32.sinc
  A	Ghidra/Processors/NDS32/data/languages/nds32be.slaspec
  A	Ghidra/Processors/NDS32/data/languages/nds32le.slaspec
  A	Ghidra/Processors/NDS32/data/patterns/nds32_patterns.xml
  A	Ghidra/Processors/NDS32/data/patterns/patternconstraints.xml
  A	Ghidra/Processors/NDS32/data/sleighArgs.txt
```
2025-12-08 13:20:49 -05:00
Eric Kilmer 26c6b01b1f Ghidra 11.4.3 (#377) 2025-12-03 14:38:16 -05:00
dependabot[bot] 563adb57e9 build(deps): bump softprops/action-gh-release from 2.4.2 to 2.5.0 (#376)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.4.2 to 2.5.0.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.4.2...v2.5.0)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-02 10:26:03 -05:00
auto-updater[bot] 127d913bc9 Update Ghidra HEAD to commit 14ead1aab (#375)
Bump Ghidra HEAD commit 14ead1aab

Changed files:

```
M	Ghidra/Processors/AARCH64/data/languages/AARCH64neon.sinc
M	Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc
M	Ghidra/Processors/ARM/data/languages/ARMneon.sinc
M	Ghidra/Processors/PowerPC/certification.manifest
A	Ghidra/Processors/PowerPC/data/patterns/PPC_BE_prepatterns.xml
R060	Ghidra/Processors/PowerPC/data/ppc64-r2CallStubs.xml	Ghidra/Processors/PowerPC/data/patterns/PPC_LE_prepatterns.xml
A	Ghidra/Processors/PowerPC/data/patterns/prepatternconstraints.xml
```

Commit details:

```
[Commit 1/4]
Hash: 88ff4b2008051e2dced18b897d8b4bc280ba675d
Date: 2025-11-24 18:25:40 +0000
Message: GP-6120_emteere_FixThunkDetectionMarkupPPC64

Files changed:
  M	Ghidra/Processors/PowerPC/certification.manifest
  A	Ghidra/Processors/PowerPC/data/patterns/PPC_BE_prepatterns.xml
  A	Ghidra/Processors/PowerPC/data/patterns/PPC_LE_prepatterns.xml
  A	Ghidra/Processors/PowerPC/data/patterns/prepatternconstraints.xml
  D	Ghidra/Processors/PowerPC/data/ppc64-r2CallStubs.xml

[Commit 2/4]
Hash: 40c8aa60b1a4c2f0bb32e775e83557932ff40a05
Date: 2024-05-23 13:46:50 +0930
Message: AArch32: (Thumb32) fixed ldrsh.w & ldrsb.w (pc-relative)
Details:
* double memory load bug

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc

[Commit 3/4]
Hash: 0982753437eaa0a1015e56cd4d8fdd16a1310d63
Date: 2024-05-20 14:13:49 +0930
Message: AArch32: fixed vmvn
Details:
* fixed incorrect shift offset (bytes given in place of bits) and double word order

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARMneon.sinc

[Commit 4/4]
Hash: c4c7f11d1c310143adeabeb49dcb74313daf0746
Date: 2025-11-13 11:00:06 -0500
Message: fix AArch64 fmadd operand ordering for 32-bit case

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64neon.sinc
```
2025-12-01 10:44:29 -05:00
auto-updater[bot] 0ea6de2744 Update Ghidra HEAD to commit 7a5a9ea5d (#374)
Bump Ghidra HEAD commit 7a5a9ea5d

Changed files:

```
M	Ghidra/Processors/ARM/data/languages/ARMinstructions.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc_instructions.sinc
```

Commit details:

```
[Commit 1/2]
Hash: 22a5a22d824f68bff4db7d8c123661789f28ca61
Date: 2025-08-10 19:33:56 +0300
Message: PowerPC: fix condition check in bd*f* opcodes

Files changed:
  M	Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc
  M	Ghidra/Processors/PowerPC/data/languages/ppc_instructions.sinc

[Commit 2/2]
Hash: 5857e63741c54a2db54450f5bc32e56fe94b62a5
Date: 2025-11-13 20:31:53 +0000
Message: GP-6118 Fix for specialized ARM cpy pc,lr

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARMinstructions.sinc
```
2025-11-24 09:28:24 -05:00
dependabot[bot] 27072f1bca build(deps): bump actions/checkout from 5 to 6 (#372)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-21 09:04:43 -05:00
auto-updater[bot] 185e34f5e7 Update Ghidra HEAD to commit be482754a (#371)
Bump Ghidra HEAD commit be482754a

Changed files:

```
M	Ghidra/Processors/ARM/data/languages/ARM.ldefs
M	Ghidra/Processors/ARM/data/languages/ARMinstructions.sinc
M	Ghidra/Processors/ARM/data/patterns/ARM_BE_patterns.xml
M	Ghidra/Processors/ARM/data/patterns/ARM_LE_patterns.xml
M	Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml
M	Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml
M	Ghidra/Processors/RISCV/certification.manifest
A	Ghidra/Processors/RISCV/data/languages/RV32.pspec
D	Ghidra/Processors/RISCV/data/languages/RV32G.pspec
D	Ghidra/Processors/RISCV/data/languages/RV32GC.pspec
D	Ghidra/Processors/RISCV/data/languages/RV32I.pspec
D	Ghidra/Processors/RISCV/data/languages/RV32IC.pspec
D	Ghidra/Processors/RISCV/data/languages/RV32IMC.pspec
A	Ghidra/Processors/RISCV/data/languages/RV64.pspec
D	Ghidra/Processors/RISCV/data/languages/RV64G.pspec
D	Ghidra/Processors/RISCV/data/languages/RV64GC.pspec
D	Ghidra/Processors/RISCV/data/languages/RV64I.pspec
D	Ghidra/Processors/RISCV/data/languages/RV64IC.pspec
A	Ghidra/Processors/RISCV/data/languages/andestar_v5.instr.sinc
A	Ghidra/Processors/RISCV/data/languages/andestar_v5.ldefs
A	Ghidra/Processors/RISCV/data/languages/andestar_v5.slaspec
A	Ghidra/Processors/RISCV/data/languages/old/riscv_deprecated.ldefs
M	Ghidra/Processors/RISCV/data/languages/riscv.csr.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv.ilp32d.slaspec
M	Ghidra/Processors/RISCV/data/languages/riscv.instr.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv.ldefs
M	Ghidra/Processors/RISCV/data/languages/riscv.lp64d.slaspec
M	Ghidra/Processors/RISCV/data/languages/riscv.reg.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv.rvc.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv.rvv.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv.table.sinc
M	Ghidra/Processors/RISCV/data/languages/riscv32-fp.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv32.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv64-fp.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv64.cspec
M	Ghidra/Processors/SuperH/data/languages/superh.sinc
M	Ghidra/Processors/Xtensa/data/languages/xtensaArch.sinc
M	Ghidra/Processors/Xtensa/data/languages/xtensaInstructions.sinc
```

Commit details:

```
[Commit 1/6]
Hash: c3a2482e186185c86ba98b93044aa032fad48ce2
Date: 2025-11-05 14:39:41 -0500
Message: GP-5975 Eliminated unused NotFoundException from Memory methods. Revised import to always include pspec symbols within pcode-defined memory blocks.  Added label name check.  Revised language version upgrade to handle certain pspec-defined block and symbol changes. Corrected RISC-V 64-bit-fp cspec.

Files changed:
  M	Ghidra/Processors/RISCV/certification.manifest
  A	Ghidra/Processors/RISCV/data/languages/old/riscv_deprecated.ldefs
  M	Ghidra/Processors/RISCV/data/languages/riscv.ldefs
  M	Ghidra/Processors/RISCV/data/languages/riscv64-fp.cspec

[Commit 2/6]
Hash: ade1ad71ba5b80e910fcd98ad688f658439724a5
Date: 2025-09-30 17:08:48 +0000
Message: GP-5975 Refactored RISCV custom instruction, sinc file layout, simplified context, and moved csr register definitions to be in a special csreg ram space.  Deprecated all most RISCV variants other than default.  Added andestar V5 RISCV variant.

Files changed:
  M	Ghidra/Processors/RISCV/certification.manifest
  A	Ghidra/Processors/RISCV/data/languages/RV32.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV32G.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV32GC.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV32I.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV32IC.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV32IMC.pspec
  A	Ghidra/Processors/RISCV/data/languages/RV64.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV64G.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV64GC.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV64I.pspec
  D	Ghidra/Processors/RISCV/data/languages/RV64IC.pspec
  A	Ghidra/Processors/RISCV/data/languages/andestar_v5.instr.sinc
  A	Ghidra/Processors/RISCV/data/languages/andestar_v5.ldefs
  A	Ghidra/Processors/RISCV/data/languages/andestar_v5.slaspec
  M	Ghidra/Processors/RISCV/data/languages/riscv.csr.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv.ilp32d.slaspec
  M	Ghidra/Processors/RISCV/data/languages/riscv.instr.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv.ldefs
  M	Ghidra/Processors/RISCV/data/languages/riscv.lp64d.slaspec
  M	Ghidra/Processors/RISCV/data/languages/riscv.reg.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv.rvc.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv.rvv.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv.table.sinc
  M	Ghidra/Processors/RISCV/data/languages/riscv32-fp.cspec
  M	Ghidra/Processors/RISCV/data/languages/riscv32.cspec
  M	Ghidra/Processors/RISCV/data/languages/riscv64.cspec

[Commit 3/6]
Hash: 0b60036f8fd0dd3cc70233fd3294d38755b7b525
Date: 2025-10-19 17:36:58 +0300
Message: SuperH fix 'bclr' opcode

Files changed:
  M	Ghidra/Processors/SuperH/data/languages/superh.sinc

[Commit 4/6]
Hash: 2419b08085dbfdf9a0ae8934526ebc7c30abce87
Date: 2025-11-06 18:47:35 +0000
Message: GP-6072 Fixed thunk detection and thunk address for Position Independent Code thunks that call to load a link register that is turned into a jump.

Files changed:
  M	Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml
  M	Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml

[Commit 5/6]
Hash: 3a0736f2647e5c095222473cebbdcad6a25c13a4
Date: 2025-10-03 15:47:44 -0500
Message: Xtensa: BE: Corrected decoding of the following instructions: BBCI, BBSI, BEQZ.N, BNEZ.N, DEPBITS, EXTUI, LDDEC, LDINC, MOVI.N, MUL.AD.*, MULA.AD.*, MUL.DA.*, MUL.DD.*, MULA.DA.*, MULA.DD.*, SLLI, SRAI, SSAI (Closes #8544, Closes #8537)

Files changed:
  M	Ghidra/Processors/Xtensa/data/languages/xtensaArch.sinc
  M	Ghidra/Processors/Xtensa/data/languages/xtensaInstructions.sinc

[Commit 6/6]
Hash: 5924914b47881f5ab936b52ac7649493cb2268c9
Date: 2025-10-30 20:21:11 +0000
Message: GP-6079 ARM instruction CPY into PC with LR set before it is now a call. Also fixed a function start pattern, and spurious references placed on stack save of the PC.

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARM.ldefs
  M	Ghidra/Processors/ARM/data/languages/ARMinstructions.sinc
  M	Ghidra/Processors/ARM/data/patterns/ARM_BE_patterns.xml
  M	Ghidra/Processors/ARM/data/patterns/ARM_LE_patterns.xml
```
2025-11-17 09:25:49 -05:00
Klaus Kämpf 1ea24c8b8d Catch Sleigh exceptions (#282)
Signed-off-by: Klaus Kämpf <kkaempf@gmail.com>
2025-11-12 12:19:03 -05:00
dependabot[bot] 572082b008 build(deps): bump softprops/action-gh-release from 2.4.1 to 2.4.2 (#370)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.4.1...v2.4.2)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-10 08:57:18 -05:00
auto-updater[bot] a5496ad829 Update Ghidra HEAD to commit 4b1fd2254 (#369)
Bump Ghidra HEAD commit 4b1fd2254

Changed files:

```
M	Ghidra/Processors/PA-RISC/data/languages/pa-risc.opinion
M	Ghidra/Processors/x86/certification.manifest
A	Ghidra/Processors/x86/data/extensions/rust/unix32/cc.xml
R100	Ghidra/Processors/x86/data/extensions/rust/unix/probe_fixup.xml	Ghidra/Processors/x86/data/extensions/rust/unix32/probe_fixup.xml
A	Ghidra/Processors/x86/data/extensions/rust/unix32/try_fixup.xml
R100	Ghidra/Processors/x86/data/extensions/rust/unix/cc.xml	Ghidra/Processors/x86/data/extensions/rust/unix64/cc.xml
R100	Ghidra/Processors/x86/data/extensions/rust/windows/probe_fixup.xml	Ghidra/Processors/x86/data/extensions/rust/unix64/probe_fixup.xml
R100	Ghidra/Processors/x86/data/extensions/rust/unix/try_fixup.xml	Ghidra/Processors/x86/data/extensions/rust/unix64/try_fixup.xml
A	Ghidra/Processors/x86/data/extensions/rust/windows32/probe_fixup.xml
A	Ghidra/Processors/x86/data/extensions/rust/windows32/try_fixup.xml
A	Ghidra/Processors/x86/data/extensions/rust/windows64/probe_fixup.xml
R100	Ghidra/Processors/x86/data/extensions/rust/windows/try_fixup.xml	Ghidra/Processors/x86/data/extensions/rust/windows64/try_fixup.xml
```

Commit details:

```
[Commit 1/2]
Hash: bb63706226732c5f0c14cf01ae934a2cd6622fb6
Date: 2025-10-09 08:06:13 -0400
Message: GP-5942: Loader for "System Object Model" binaries

Files changed:
  M	Ghidra/Processors/PA-RISC/data/languages/pa-risc.opinion

[Commit 2/2]
Hash: 95ad48cdb371aeef15892767f4962ab1712db86f
Date: 2025-10-28 17:22:13 +0000
Message: GP-4711 Fix for import of 32-bit x86 Unix/Windows Rust binaries

Files changed:
  M	Ghidra/Processors/x86/certification.manifest
  D	Ghidra/Processors/x86/data/extensions/rust/unix/cc.xml
  D	Ghidra/Processors/x86/data/extensions/rust/unix/probe_fixup.xml
  D	Ghidra/Processors/x86/data/extensions/rust/unix/try_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/unix32/cc.xml
  A	Ghidra/Processors/x86/data/extensions/rust/unix32/probe_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/unix32/try_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/unix64/cc.xml
  A	Ghidra/Processors/x86/data/extensions/rust/unix64/probe_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/unix64/try_fixup.xml
  D	Ghidra/Processors/x86/data/extensions/rust/windows/probe_fixup.xml
  D	Ghidra/Processors/x86/data/extensions/rust/windows/try_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/windows32/probe_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/windows32/try_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/windows64/probe_fixup.xml
  A	Ghidra/Processors/x86/data/extensions/rust/windows64/try_fixup.xml
```

Co-authored-by: pgoodman <43664+pgoodman@users.noreply.github.com>
2025-11-03 11:18:43 -05:00
estr3llas 604cd282a6 Fixed URL to ghidra's SLEIGH page. (#368)
Update README.md
2025-10-29 15:39:54 -04:00
dependabot[bot] 14c9c408ca build(deps): bump actions/upload-artifact from 4 to 5 (#367)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-27 09:12:42 -04:00
dependabot[bot] 21ed4b78e5 build(deps): bump softprops/action-gh-release from 2.4.0 to 2.4.1 (#366)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.4.0 to 2.4.1.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.4.0...v2.4.1)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-13 22:11:13 -04:00
dependabot[bot] d2c42d19ed build(deps): bump softprops/action-gh-release from 2.3.4 to 2.4.0 (#365)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.3.4 to 2.4.0.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.3.4...v2.4.0)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-07 08:51:40 -04:00
auto-updater[bot] 97f7fd1faf Update Ghidra HEAD to commit 53cca61f8 (#363)
Bump Ghidra HEAD commit 53cca61f8

Changed files:

```
M	Ghidra/Processors/MIPS/data/languages/mips.sinc
M	Ghidra/Processors/MIPS/data/languages/mips16.sinc
M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc
```

Commit details:

```
[Commit 1/7]
Hash: 575dfa7572af0c726fa2d69c512ab486315559e6
Date: 2025-09-10 12:42:00 +0000
Message: GP-5902: Fixed gotos

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 2/7]
Hash: a6e9ea090022e9a97dd8411e51caad64dc80e63c
Date: 2025-08-30 15:46:00 +0100
Message: mips: Don't use reserved keywords for names

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 3/7]
Hash: a72a68c4612c368c8f9790e586a6246273714ed1
Date: 2025-08-30 14:47:57 +0100
Message: mips: Use & ~1 rather than & -2

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 4/7]
Hash: 3c095be95654fb333ea4c22ede44f096b8c341e2
Date: 2025-08-19 20:51:02 +0100
Message: Fix LI failing to match in some cases

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 5/7]
Hash: 63919665ec3d07639c6cbe30285640b775c8f099
Date: 2025-08-02 01:42:30 +0100
Message: mips: Correctly handle 64-bit regs in INS and EXT 16e2 instructions

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 6/7]
Hash: b31997bba0bcc7502d47060022f8173e42077365
Date: 2025-08-02 01:08:43 +0100
Message: mips: Add mips16e2 instructions

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips.sinc
  M	Ghidra/Processors/MIPS/data/languages/mips16.sinc

[Commit 7/7]
Hash: 4f3f1059dc67d10db6a82c2c29c93d0d11504401
Date: 2025-04-01 22:24:44 +0200
Message: Add eBPF instruction CALLX for indirect calls
Details:
When clang encounters indirect calls in eBPF programs, it emits a call
instruction with a register parameter (`BPF_X`) instead of an immediate
value (`BPF_K`). This encoding (`BPF_JMP | BPF_CALL | BPF_X = 0x8d`) is
decoded by llvm-objdump as `callx`.

For example, here is a simple C program with an indirect call:

    extern void (*ptr_to_some_function)(void);
    void call_ptr_to_some_function(void) {
        ptr_to_some_function();
    }

Compiling and disassembling it gives with clang 14.0 (and LLVM 14.0):

    $ clang -O2 -target bpf -c indirect_call.c -o indirect_call.ebpf
    $ llvm-objdump -rd indirect_call.ebpf

    indirect_call.ebpf:  file format elf64-bpf

    Disassembly of section .text:

    0000000000000000 <call_ptr_to_some_function>:
           0:  18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00  r1 = 0 ll
                    0000000000000000:  R_BPF_64_64  ptr_to_some_function
           2:  79 11 00 00 00 00 00 00  r1 = *(u64 *)(r1 + 0)
           3:  8d 00 00 00 01 00 00 00  callx r1
           4:  95 00 00 00 00 00 00 00  exit

Contrary to usual eBPF instructions, `callx`'s register operand is
encoded in the immediate field. This encoding is actually specific to
LLVM (and clang). GCC used the destination register to store the target
register.

LLVM 19.1 was modified to use GCC's encoding:
https://github.com/llvm/llvm-project/pull/81546 ("BPF: Change callx insn
encoding"). For example, in an Alpine Linux 3.21 system:

    $ clang -target bpf --version
    Alpine clang version 19.1.4
    Target: bpf
    Thread model: posix
    InstalledDir: /usr/lib/llvm19/bin

    $ clang -O2 -target bpf -c indirect_call.c -o indirect_call.ebpf
    $ llvm-objdump -rd indirect_call.ebpf

    indirect_call.ebpf:  file format elf64-bpf

    Disassembly of section .text:

    0000000000000000 <call_ptr_to_some_function>:
           0:  18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00  r1 = 0x0 ll
                    0000000000000000:  R_BPF_64_64  ptr_to_some_function
           2:  79 11 00 00 00 00 00 00  r1 = *(u64 *)(r1 + 0x0)
           3:  8d 01 00 00 00 00 00 00  callx r1
           4:  95 00 00 00 00 00 00 00  exit

The instruction is now encoded `8d 01 00...`.

For reference, here are similar commands using GCC showing it is using
the same encoding (here, compiler option `-mxbpf` is required to enable
several features including indirect calls, cf.
https://gcc.gnu.org/onlinedocs/gcc-12.4.0/gcc/eBPF-Options.html ).

    $ bpf-gcc --version
    bpf-gcc (12-20220319-1ubuntu1+2) 12.0.1 20220319 (experimental) [master r12-7719-g8ca61ad148f]

    $ bpf-gcc -O2 -c indirect_call.c -o indirect_call.ebpf -mxbpf
    $ bpf-objdump -mxbpf -rd indirect_call.ebpf

    indirect_call_gcc-12.ebpf:     file format elf64-bpfle

    Disassembly of section .text:

    0000000000000000 <call_ptr_to_some_function>:
       0:  18 00 00 00 00 00 00 00   lddw %r0,0
       8:  00 00 00 00 00 00 00 00
          0: R_BPF_INSN_64  ptr_to_some_function
      10:  79 01 00 00 00 00 00 00   ldxdw %r1,[%r0+0]
      18:  8d 01 00 00 00 00 00 00   call %r1
      20:  95 00 00 00 00 00 00 00   exit

Add both `callx` instruction encodings to eBPF processor.

By the way, the eBPF Verifier used by Linux kernel currently forbids
indirect calls (it fails when `BPF_SRC(insn->code) != BPF_K`, in
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf/verifier.c?h=v6.14#n19141
). But other deployments of eBPF may already support this feature.

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc
```
2025-10-06 09:15:44 -04:00
dependabot[bot] cf1dc2bb79 build(deps): bump softprops/action-gh-release from 2.3.3 to 2.3.4 (#364)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.3.3 to 2.3.4.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.3.3...v2.3.4)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.3.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-06 09:15:04 -04:00
auto-updater[bot] a732884632 Update Ghidra HEAD to commit 96506554e (#362)
Bump Ghidra HEAD commit 96506554e

Changed files:

```
M	Ghidra/Processors/AARCH64/certification.manifest
A	Ghidra/Processors/AARCH64/data/languages/AARCH64_apple.cspec
M	Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefs
M	Ghidra/Processors/x86/data/languages/x86-64-win.cspec
M	Ghidra/Processors/x86/data/languages/x86win.cspec
M	Ghidra/Processors/x86/data/patterns/x86-64gcc_patterns.xml
M	Ghidra/Processors/x86/data/patterns/x86-64win_patterns.xml
M	Ghidra/Processors/x86/data/patterns/x86gcc_patterns.xml
M	Ghidra/Processors/x86/data/patterns/x86gcc_prepatterns.xml
M	Ghidra/Processors/x86/data/patterns/x86win_patterns.xml
```

Commit details:

```
[Commit 1/4]
Hash: dc069a18c602b71dbbb3bb7d150adb5b39565b8f
Date: 2025-09-24 18:06:03 +0000
Message: GP-5287 Added ENDBR jump target checking instructions as function start patterns for x86 gcc binaries

Files changed:
  M	Ghidra/Processors/x86/data/patterns/x86-64gcc_patterns.xml
  M	Ghidra/Processors/x86/data/patterns/x86gcc_patterns.xml

[Commit 2/4]
Hash: 69ed84a069255d06e500691dfd9229067bb8b209
Date: 2025-09-24 18:03:10 +0000
Message: GP-5526 bug fix for .plt.sec and pattern matching optimization

Files changed:
  M	Ghidra/Processors/x86/data/patterns/x86gcc_prepatterns.xml

[Commit 3/4]
Hash: 0815f463f543e0f09e582de612e04b612460bc4d
Date: 2025-09-24 18:01:43 +0000
Message: GP-5998 Added security_check_cookie function patterns and callfixup for VS2022 based binaries.

Files changed:
  M	Ghidra/Processors/x86/data/languages/x86-64-win.cspec
  M	Ghidra/Processors/x86/data/languages/x86win.cspec
  M	Ghidra/Processors/x86/data/patterns/x86-64win_patterns.xml
  M	Ghidra/Processors/x86/data/patterns/x86win_patterns.xml

[Commit 4/4]
Hash: 6e81a370ce02a1e9e65fe7d9d02240e8773ec8bb
Date: 2025-09-11 17:36:37 +0000
Message: GP-3139 added cspec for AARCH64 apple silicon

Files changed:
  M	Ghidra/Processors/AARCH64/certification.manifest
  A	Ghidra/Processors/AARCH64/data/languages/AARCH64_apple.cspec
  M	Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefs
```
2025-09-29 09:02:40 -04:00
auto-updater[bot] 800a597ff6 Update Ghidra HEAD to commit 1ae4378cf (#361)
Bump Ghidra HEAD commit 1ae4378cf

Changed files:

```
M	Ghidra/Processors/Atmel/data/languages/avr32a_instruction_flow.sinc
M	Ghidra/Processors/tricore/data/languages/tricore.ldefs
M	Ghidra/Processors/x86/certification.manifest
M	Ghidra/Processors/x86/data/patterns/prepatternconstraints.xml
A	Ghidra/Processors/x86/data/patterns/x86gcc_prepatterns.xml
```

Commit details:

```
[Commit 1/4]
Hash: 24b2275c0b7bbdb30243d6b3877d0a5fb852243a
Date: 2023-09-05 10:03:20 -0400
Message: tmp assigned rd0 instead of LR

Files changed:
  M	Ghidra/Processors/Atmel/data/languages/avr32a_instruction_flow.sinc

[Commit 2/4]
Hash: be7458a4369e8b0ec0988f96d33a71b33912e750
Date: 2023-08-29 09:24:37 -0400
Message: Update avr32a_instruction_flow.sinc
Details:
The specification for avr32 says the LR register should be reserved for using return addresses, but in reality older compilers seem to use it to hold addresses for ICALL. When they do so without this fix the value in LR is immediately overwritten and during analysis only appears to be a function call to the opcode immediately after ICALL.

Files changed:
  M	Ghidra/Processors/Atmel/data/languages/avr32a_instruction_flow.sinc

[Commit 3/4]
Hash: 4b6d90366c8569b5d780dd14a74445957db55582
Date: 2025-09-10 22:55:14 +0000
Message: GP-5526 Added section tag to function start patterns. New thunk patterns in x86 gcc .plt section.  Changed priority of pre analyzer and disassembly.

Files changed:
  M	Ghidra/Processors/x86/certification.manifest
  M	Ghidra/Processors/x86/data/patterns/prepatternconstraints.xml
  A	Ghidra/Processors/x86/data/patterns/x86gcc_prepatterns.xml

[Commit 4/4]
Hash: 18a7f952c89be6951f4b3bf549a54daff5720cfd
Date: 2024-11-08 15:39:42 +0100
Message: Processors: Rename TriCore Siemens to Infineon

Files changed:
  M	Ghidra/Processors/tricore/data/languages/tricore.ldefs
```
2025-09-22 07:32:52 -04:00
auto-updater[bot] adcbfb179f Update Ghidra HEAD to commit 970c8fbdd (#360)
Bump Ghidra HEAD commit 970c8fbdd

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
M	Ghidra/Features/Decompiler/src/decompile/datatests/condexesub.xml
```

Commit details:

```
[Commit 1/1]
Hash: ce09332fcdd011758d23a2505eced5949ffcc253
Date: 2025-09-02 18:17:49 +0000
Message: GP-4214 Allow INT_ADD in the iblock

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
  M	Ghidra/Features/Decompiler/src/decompile/datatests/condexesub.xml
```
2025-09-14 21:00:45 -04:00
dependabot[bot] 64377586f8 build(deps): bump softprops/action-gh-release from 2.3.2 to 2.3.3 (#359)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.3.2 to 2.3.3.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2.3.2...v2.3.3)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-08 09:36:45 -04:00
auto-updater[bot] 19fcb07d42 Update Ghidra HEAD to commit f501ffccd (#358)
Bump Ghidra HEAD commit f501ffccd

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/double.cc
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/opbehavior.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.hh
A	Ghidra/Features/Decompiler/src/decompile/datatests/condconst2.xml
A	Ghidra/Features/Decompiler/src/decompile/datatests/condconstsub.xml
M	Ghidra/Processors/x86/data/languages/x86gcc.cspec
```

Commit details:

```
[Commit 1/2]
Hash: e412f13b30b54acdcfb85ae248f53edaac28598f
Date: 2025-08-25 19:09:30 +0000
Message: GP-5950 Add support for multipath conditional constants

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/double.cc
  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/opbehavior.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.hh
  A	Ghidra/Features/Decompiler/src/decompile/datatests/condconst2.xml
  A	Ghidra/Features/Decompiler/src/decompile/datatests/condconstsub.xml

[Commit 2/2]
Hash: 6229740f8b86198d5a32d881c852bc1d448be6ad
Date: 2025-08-27 19:15:30 +0000
Message: GP-5958 added callfixup for get_pc_thunk.di to x86gcc.cspec

Files changed:
  M	Ghidra/Processors/x86/data/languages/x86gcc.cspec
```
2025-09-07 20:47:44 -04:00
dependabot[bot] 24e7a85db6 build(deps): bump actions/setup-python from 5 to 6 (#357)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-04 17:03:51 -04:00
auto-updater[bot] 6b8620a8cf Update Ghidra HEAD to commit 7a4100d54 (#356)
* Add new source files

* Bump Ghidra HEAD commit 7a4100d54

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
M	Ghidra/Features/Decompiler/src/decompile/cpp/cast.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
A	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
A	Ghidra/Features/Decompiler/src/decompile/cpp/expression.hh
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/jumptable.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/marshal.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/merge.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.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/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/variable.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh
M	Ghidra/Features/Decompiler/src/decompile/unittests/testparamstore.cc
M	Ghidra/Features/Decompiler/src/decompile/unittests/testtypes.cc
M	Ghidra/Processors/MIPS/certification.manifest
M	Ghidra/Processors/MIPS/data/languages/mips.ldefs
R068	Ghidra/Processors/MIPS/data/languages/mips32be_eabi.cspec	Ghidra/Processors/MIPS/data/languages/mips32_eabi.cspec
M	Ghidra/Processors/MIPS/data/languages/mips32be.cspec
M	Ghidra/Processors/MIPS/data/languages/mips32le.cspec
D	Ghidra/Processors/MIPS/data/languages/mips32le_eabi.cspec
D	Ghidra/Processors/MIPS/data/languages/mips64.cspec
A	Ghidra/Processors/MIPS/data/languages/mips64be.cspec
A	Ghidra/Processors/MIPS/data/languages/mips64le.cspec
M	Ghidra/Processors/PowerPC/certification.manifest
M	Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc
M	Ghidra/Processors/PowerPC/data/languages/SPE_EFV.sinc
M	Ghidra/Processors/PowerPC/data/languages/evx.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc.ldefs
R070	Ghidra/Processors/PowerPC/data/languages/ppc_32_le.cspec	Ghidra/Processors/PowerPC/data/languages/ppc_32.cspec
D	Ghidra/Processors/PowerPC/data/languages/ppc_32_be.cspec
M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec
M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec
M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec
M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec
A	Ghidra/Processors/PowerPC/data/languages/ppc_64_be.cspec
R058	Ghidra/Processors/PowerPC/data/languages/ppc_64.cspec	Ghidra/Processors/PowerPC/data/languages/ppc_64_le.cspec
M	Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc_embedded.sinc
M	Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
M	Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml
M	Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml
M	Ghidra/Processors/x86/data/languages/ia.sinc
```

Commit details:

```
[Commit 1/6]
Hash: f6495e4146e7ae5bebe1d4258793618f196eb6fa
Date: 2025-07-15 23:09:23 +0000
Message: GP-5851 Fix tiling truncations for odd data-type sizes in MultiSlotAssign. Fix for big endian multi-slot return value.

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/cast.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/modelrules.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.hh
  M	Ghidra/Features/Decompiler/src/decompile/unittests/testparamstore.cc
  M	Ghidra/Features/Decompiler/src/decompile/unittests/testtypes.cc

[Commit 2/6]
Hash: f391ddb87c88e553b84cc34a696509a01b08e7f5
Date: 2025-08-26 11:59:06 -0400
Message: GP-5945 Fixed PowerPC e500 instruction extension issues and added function start pattern variants.

Files changed:
  M	Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc
  M	Ghidra/Processors/PowerPC/data/languages/SPE_EFV.sinc
  M	Ghidra/Processors/PowerPC/data/languages/evx.sinc
  M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_be.slaspec
  M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500_le.slaspec
  M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_be.slaspec
  M	Ghidra/Processors/PowerPC/data/languages/ppc_32_e500mc_le.slaspec
  M	Ghidra/Processors/PowerPC/data/languages/ppc_common.sinc
  M	Ghidra/Processors/PowerPC/data/languages/ppc_embedded.sinc
  M	Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc
  M	Ghidra/Processors/PowerPC/data/patterns/PPC_BE_patterns.xml
  M	Ghidra/Processors/PowerPC/data/patterns/PPC_LE_patterns.xml

[Commit 3/6]
Hash: 393e7935af660c07e2139f99468f0f32125fae99
Date: 2025-08-26 08:33:50 -0400
Message: GP-5906: Added x86 SSE4a instructions

Files changed:
  M	Ghidra/Processors/x86/data/languages/ia.sinc

[Commit 4/6]
Hash: d9a5ad2ed0bd888fa950ccf1bf16cf9b6f8211e4
Date: 2025-08-25 19:31:22 +0000
Message: GP-4029 updated mips and ppc language versions

Files changed:
  M	Ghidra/Processors/MIPS/data/languages/mips.ldefs
  M	Ghidra/Processors/PowerPC/data/languages/ppc.ldefs

[Commit 5/6]
Hash: d91aebe74e801d49bf9d37805256e60db465a8d3
Date: 2025-02-25 20:50:19 +0000
Message: GP-4030: Fix MIPS base and eabi 32/64-bit cspecs GP-4029: Update base PowerPC 32/64-bit cspecs

Files changed:
  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/marshal.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.hh
  M	Ghidra/Processors/MIPS/certification.manifest
  M	Ghidra/Processors/MIPS/data/languages/mips.ldefs
  A	Ghidra/Processors/MIPS/data/languages/mips32_eabi.cspec
  M	Ghidra/Processors/MIPS/data/languages/mips32be.cspec
  D	Ghidra/Processors/MIPS/data/languages/mips32be_eabi.cspec
  M	Ghidra/Processors/MIPS/data/languages/mips32le.cspec
  D	Ghidra/Processors/MIPS/data/languages/mips32le_eabi.cspec
  D	Ghidra/Processors/MIPS/data/languages/mips64.cspec
  A	Ghidra/Processors/MIPS/data/languages/mips64be.cspec
  A	Ghidra/Processors/MIPS/data/languages/mips64le.cspec
  M	Ghidra/Processors/PowerPC/certification.manifest
  M	Ghidra/Processors/PowerPC/data/languages/ppc.ldefs
  A	Ghidra/Processors/PowerPC/data/languages/ppc_32.cspec
  D	Ghidra/Processors/PowerPC/data/languages/ppc_32_be.cspec
  D	Ghidra/Processors/PowerPC/data/languages/ppc_32_le.cspec
  D	Ghidra/Processors/PowerPC/data/languages/ppc_64.cspec
  A	Ghidra/Processors/PowerPC/data/languages/ppc_64_be.cspec
  A	Ghidra/Processors/PowerPC/data/languages/ppc_64_le.cspec

[Commit 6/6]
Hash: 8217593e87635153066b8ea7a11d19e1ea02a555
Date: 2025-08-18 23:21:42 +0000
Message: GP-5934 Fix handling of integer minimum in SBORROW, SLESS rules, add SCARRY rule.

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
  M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
  A	Ghidra/Features/Decompiler/src/decompile/cpp/expression.cc
  A	Ghidra/Features/Decompiler/src/decompile/cpp/expression.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/merge.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/ruleaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/variable.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh
```

---------

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
2025-09-04 17:02:56 -04:00
Eric Kilmer f398228901 Ghidra 11.4.2 (#355)
* Update spec files list
2025-08-27 15:18:17 -04:00
auto-updater[bot] d0d9bf5a67 Update Ghidra HEAD to commit 4fcc1febd (#354)
Bump Ghidra HEAD commit 4fcc1febd

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
A	Ghidra/Features/Decompiler/src/decompile/datatests/condexesub.xml
M	Ghidra/Processors/8051/data/languages/80251.sinc
M	Ghidra/Processors/8051/data/languages/8051_main.sinc
M	Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec
M	Ghidra/Processors/MCS96/data/languages/MCS96.sinc
M	Ghidra/Processors/PIC/data/languages/PIC24.sinc
M	Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc
M	Ghidra/Processors/PowerPC/data/languages/altivec.sinc
M	Ghidra/Processors/SuperH/data/languages/superh.cspec
M	Ghidra/Processors/SuperH/data/languages/superh2a.cspec
M	Ghidra/Processors/x86/data/languages/x86-64-swift.cspec
```

Commit details:

```
[Commit 1/7]
Hash: 3abf7f765e6d045d152589a7f73c8b4fea6c35a5
Date: 2025-08-21 06:42:41 -0400
Message: GP-0: Updating Swift documentation links

Files changed:
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec
  M	Ghidra/Processors/x86/data/languages/x86-64-swift.cspec

[Commit 2/7]
Hash: 42115f6df02329a745a3878aafa96439088deaf0
Date: 2025-08-18 17:12:23 +0000
Message: GP-5581: Allow optimization by truncation of subpieced unique varnodes.

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
  M	Ghidra/Processors/MCS96/data/languages/MCS96.sinc
  M	Ghidra/Processors/PIC/data/languages/PIC24.sinc
  M	Ghidra/Processors/PowerPC/data/languages/SPE_APU.sinc
  M	Ghidra/Processors/PowerPC/data/languages/altivec.sinc

[Commit 3/7]
Hash: bb19782c35fd087d636f1dd5e41f9c5c02ac94ce
Date: 2025-08-11 20:27:21 +0000
Message: GP-5927 Add support for SUBPIECE removal in ConditionalExecution

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/condexe.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
  A	Ghidra/Features/Decompiler/src/decompile/datatests/condexesub.xml

[Commit 4/7]
Hash: 9c9938e0662fa3b5cb48a79a10bf5e53edddb19b
Date: 2025-07-30 19:32:34 +0000
Message: GP-5889 Check for common source in duplicated switch guard detection

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.hh

[Commit 5/7]
Hash: 28313c6574c61da69299fda185b884e2c785d7c1
Date: 2025-08-07 12:44:05 +0000
Message: GP-5912 Adding SH2 GBR register to the preserved by call list

Files changed:
  M	Ghidra/Processors/SuperH/data/languages/superh.cspec
  M	Ghidra/Processors/SuperH/data/languages/superh2a.cspec

[Commit 6/7]
Hash: e7cad294c9b0a19ec9d74ef733e31451fb47c468
Date: 2025-07-29 14:59:32 +0100
Message: Fix 80251 "ANL Rm,#data" showing as "ADD"
Details:
Should be self explanatory, looks like it was just a typo.

Files changed:
  M	Ghidra/Processors/8051/data/languages/80251.sinc

[Commit 7/7]
Hash: cca3fcc208f9f1f8f69f60ed58dd470f976bddf0
Date: 2025-07-29 14:57:07 +0100
Message: Fix ANL Areg,Data for 80251 in source mode
Details:
ANL Areg,Data should be GROUP1 rather than GROUP2, the incorrect group causes the instruction to fail to decode on source mode 80251

Files changed:
  M	Ghidra/Processors/8051/data/languages/8051_main.sinc
```
2025-08-26 17:05:38 -04:00
auto-updater[bot] 632fa35e36 Update Ghidra HEAD to commit 98b938cc6 (#353)
Bump Ghidra HEAD commit 98b938cc6

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/block.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
M	Ghidra/Processors/x86/data/languages/x86-64.dwarf
M	Ghidra/Processors/x86/data/languages/x86.dwarf
```

Commit details:

```
[Commit 1/2]
Hash: e908ab6fbf4311f99fa86d50b60aa4802a6e3fd6
Date: 2025-08-11 11:21:28 -0400
Message: DWARF expression handling refactor
Details:
Cleanup logic of expression evaluation, stub out resolution of register
values to a callback in case we want to use constant propagation to try
to allow successful calculations, and add support for default static
values for treating an arch's stack frame register (e.g. RBP) like the
static CFA value we already have support for.

Add option to decorate params and local vars with their DWARF storage
location info.

Handle arrays with unspecified element type.

Files changed:
  M	Ghidra/Processors/x86/data/languages/x86-64.dwarf
  M	Ghidra/Processors/x86/data/languages/x86.dwarf

[Commit 2/2]
Hash: 29b7cb655283c124b4d999e8b3d45c58e7004b69
Date: 2025-08-07 15:19:32 +0000
Message: GP-5915 Fix bug in ConditionalJoin

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/block.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/blockaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc
```
2025-08-18 09:24:31 -04:00
auto-updater[bot] e925db971d Update Ghidra HEAD to commit 42794bc3f (#351)
* Fix some patches and rename test binary

* Bump Ghidra HEAD commit 42794bc3f

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/.gitignore
M	Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
M	Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/heritage.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/transform.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
```

Commit details:

```
[Commit 1/1]
Hash: 943ccd322ddc280cd28cb7cb6ef8328941c3d574
Date: 2025-07-23 22:49:35 +0000
Message: GP-5869 Fix for some out of bounds array indices and shift amounts

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/.gitignore
  M	Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
  M	Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/heritage.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/jumptable.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/transform.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
```

---------

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
2025-08-12 21:29:48 -04:00
dependabot[bot] e590133fc7 build(deps): bump actions/checkout from 4 to 5 (#352)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 13:05:37 -04:00
auto-updater[bot] 760a315270 Update Ghidra HEAD to commit 0a97fd8fe (#350)
Bump Ghidra HEAD commit 0a97fd8fe

Changed files:

```
M	Ghidra/Processors/ARM/data/languages/ARMneon.sinc
M	Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc
M	Ghidra/Processors/MC6800/data/languages/6805.slaspec
M	Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc
M	Ghidra/Processors/SuperH4/data/languages/SuperH4_le.cspec
M	Ghidra/Processors/Toy/certification.manifest
M	Ghidra/Processors/Toy/data/languages/toy.ldefs
M	Ghidra/Processors/Toy/data/languages/toy.sinc
A	Ghidra/Processors/Toy/data/languages/toy64_be_harvard_rev.slaspec
M	Ghidra/Processors/eBPF/certification.manifest
M	Ghidra/Processors/eBPF/data/languages/eBPF.ldefs
M	Ghidra/Processors/eBPF/data/languages/eBPF.opinion
M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc
A	Ghidra/Processors/eBPF/data/languages/eBPF_be.slaspec
M	Ghidra/Processors/eBPF/data/languages/eBPF_le.slaspec
M	Ghidra/Processors/x86/data/languages/avx512.sinc
M	Ghidra/Processors/x86/data/languages/ia.sinc
```

Commit details:

```
[Commit 1/15]
Hash: 352fed0d953aacf3ee6304516b4679c134c9a0f5
Date: 2025-07-29 14:32:54 +0000
Message: GP-5853: Initial implementation of ARM Neon VLD/VSTn instructions.

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARMneon.sinc

[Commit 2/15]
Hash: 4abf6d55ad54a91afb9adf5e9e122302e4ca10f8
Date: 2025-07-29 07:12:56 -0400
Message: GP-5766: Fixed instruction AVX512 disassembly errors

Files changed:
  M	Ghidra/Processors/x86/data/languages/avx512.sinc
  M	Ghidra/Processors/x86/data/languages/ia.sinc

[Commit 3/15]
Hash: 24d19f6e8c31c038345fb33d3a957fe990222ea2
Date: 2025-04-04 17:54:31 +0200
Message: Add eBPF ISA v4 instructions
Details:
In 2023, the eBPF instruction set was modified to add several
instructions related to signed operations (load with sign-extension,
signed division, etc.), a 32-bit jump instruction and some byte-swap
instructions. This became version 4 of eBPF ISA.

Here are some references about this change:

- https://pchaigno.github.io/bpf/2021/10/20/ebpf-instruction-sets.html
  (a blog post about eBPF instruction set extensions)
- https://lore.kernel.org/bpf/4bfe98be-5333-1c7e-2f6d-42486c8ec039@meta.com/
  (documentation sent to Linux Kernel mailing list)
- https://www.rfc-editor.org/rfc/rfc9669.html#name-sign-extension-load-operati
  (IETF's BPF Instruction Set Architecture standard defined the new
  instructions)
- https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf/core.c?h=v6.14#n1859
  (implementation of signed division and remainder in Linux kernel.
  This shows that 32-bit signed DIV and signed MOD are zero-extending
  the result in DST)
- https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf/core.c?h=v6.14#n2135
  (implementation of signed memory load in Linux kernel)
- https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1f9a1ea821ff25353a0e80d971e7958cd55b47a3
  (commit which added signed memory load instructions in Linux kernel)

This can be tested with a recent enough version of clang and LLVM (this
works with clang 19.1.4 on Alpine 3.21).
For example for signed memory load instructions:

    signed int sext_8bit(signed char x) {
        return x;
    }

produces:

    $ clang -O0 -target bpf -mcpu=v4 -c test.c -o test.ebpf
    $ llvm-objdump -rd test.ebpf
    ...
    0000000000000000 <sext_8bit>:
           0:  73 1a ff ff 00 00 00 00  *(u8 *)(r10 - 0x1) = r1
           1:  91 a1 ff ff 00 00 00 00  r1 = *(s8 *)(r10 - 0x1)
           2:  bc 10 00 00 00 00 00 00  w0 = w1
           3:  95 00 00 00 00 00 00 00  exit

(The second instruction is a signed memory load)

Instruction MOVS (Sign extend register MOV) uses offset to encode the
conversion (whether the source register is to be considered as signed
8-bit, 16-bit or 32-bit integer). The mnemonic for these instructions is
quite unclear:

- They are all named MOVS in the proposal
  https://lore.kernel.org/bpf/4bfe98be-5333-1c7e-2f6d-42486c8ec039@meta.com/
- LLVM and Linux disassemblers only display pseudo-code (`r0 = (s8)r1`)
- RFC 9669 (https://datatracker.ietf.org/doc/rfc9669/) uses MOVSX for
  all instructions.
- GCC uses MOVS for all instructions:
  https://github.com/gcc-mirror/gcc/blob/releases/gcc-14.1.0/gcc/config/bpf/bpf.md?plain=1#L326-L365

To make the disassembled code clearer, decode such instructions with a
size suffix: MOVSB, MOVSH, MOVSW.

The decoding of instructions 32-bit JA, BSWAP16, BSWAP32 and BSWAP64 is
straightforward.

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc

[Commit 4/15]
Hash: 39c0a83c0c4540b0776ef2e8fd8c2c7fb966d55c
Date: 2025-07-28 15:48:40 +0000
Message: GP-5877: Fix Patch Instruction action in some Harvard architectures.

Files changed:
  M	Ghidra/Processors/Toy/certification.manifest
  M	Ghidra/Processors/Toy/data/languages/toy.ldefs
  M	Ghidra/Processors/Toy/data/languages/toy.sinc
  A	Ghidra/Processors/Toy/data/languages/toy64_be_harvard_rev.slaspec

[Commit 5/15]
Hash: e2de11d5b284d17828b5513678d2de2a1c775cfe
Date: 2025-04-03 16:48:48 +0200
Message: Fix eBPF zero-extend load instructions
Details:
When a loading less than 8 bytes to a register, the value is supposed to
be zero-extended. This is what the eBPF execution engine in the Linux
kernel does, in
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/bpf/core.c?h=v6.14#n2113
This is also what is specified in RFC 9669 which standardised BPF ISA:
https://www.rfc-editor.org/rfc/rfc9669.html#name-regular-load-and-store-oper

Add the missing `zext` calls in the semantic section of instructions
LDXW, LDXH and LDXB. While at it, add them to other load instructions.

For information, the issue can be seen when analyzing this C program:

    unsigned int div_by_1000(unsigned int value) {
        return value / 1000;
    }

Compiling it with clang gives:

    $ clang -O0 -target bpf -c division.c -o division.ebpf
    $ bpf-objdump -rd division.ebpf
    division.ebpf:     file format elf64-bpfle

    Disassembly of section .text:

    0000000000000000 <div_by_1000>:
       0:    63 1a fc ff 00 00 00 00     stxw [%fp+-4],%r1
       8:    61 a0 fc ff 00 00 00 00     ldxw %r0,[%fp+-4]
      10:    37 00 00 00 e8 03 00 00     div %r0,0x3e8
      18:    95 00 00 00 00 00 00 00     exit

Ghidra decompiles this program as:

    ulonglong div_by_1000(uint param_1)
    {
      undefined4 in_stack_00000000;
      return CONCAT44(in_stack_00000000,param_1) / 1000;
    }

This `in_stack_00000000` comes from the way the parameter is loaded from
the stack. The listing shows the following disassembly and p-code
operations:

    ram:00100008 61 a0 fc ff 00       LDXW       R0,[R10 + -0x4=>Stack[-0x4]]
                 00 00 00
                            $U3e00:8 = INT_ADD R10, -4:8
                            R0 = LOAD ram($U3e00:8)

This shows the value is indeed loaded from 8 bytes at `$U3e00:8` instead
of 4.

After adding `zext` calls, Ghidra decodes the same instruction as:

    ram:00100008 61 a0 fc ff 00       LDXW       R0,[R10 + -0x4=>local_4]
                 00 00 00
                            $U4100:8 = INT_ADD R10, -4:8
                            $U4180:4 = LOAD ram($U4100:8)
                            R0 = INT_ZEXT $U4180:4

This only loads 4 bytes from the stack, as expected.
Moreover the decompilation view is now correct:

    ulonglong div_by_1000(uint param_1)
    {
      return (ulonglong)param_1 / 1000;
    }

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc

[Commit 6/15]
Hash: c1d96a214049944549c6429f994907f19de72acb
Date: 2025-03-18 22:24:23 +0100
Message: Fix eBPF CALL operand decoding
Details:
The operand of the CALL instruction missed multiplying the immediate
value by 8. Without this, calls are not decoded correctly.

Such a CALL instruction can be emitted when compiling this simple
`single_call.c` program:

    static int one(void) {
        return 1;
    }

    int call_one(void) {
        return one();
    }

with:

    clang -O0 -target bpf -c single_call.c -o single_call.ebpf

Disassembling with LLVM shows:

    $ llvm-objdump -d single_call.ebpf
    single_call.ebpf:	file format elf64-bpf

    Disassembly of section .text:

    0000000000000000 <call_one>:
           0:	85 10 00 00 01 00 00 00	call 1
           1:	95 00 00 00 00 00 00 00	exit

    0000000000000010 <one>:
           2:	b7 00 00 00 01 00 00 00	r0 = 1
           3:	95 00 00 00 00 00 00 00	exit

The first instruction ("call 1") calls the function located at 0x10 (at
index `2:` in the listing). Ghidra considered the call to target
address 9 instead (as `inst_next = 8` and `imm = 1`). Fix this by
multiplying `imm` by 8 when encountering a `disp32` operand (which is
only used by instruction `CALL`).

Adjust ELF Relocation R_BPF_64_32 to take into account for this
multiplication by 8. Actually it is documented to compute (S + A) / 8 - 1
so the division by 8 was missing.

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc

[Commit 7/15]
Hash: adb0eac98aacb8b26d0f935e3f10974482d626a8
Date: 2025-05-07 15:40:24 +0200
Message: Add support for big endian eBPF programs

Files changed:
  M	Ghidra/Processors/eBPF/certification.manifest
  M	Ghidra/Processors/eBPF/data/languages/eBPF.ldefs
  M	Ghidra/Processors/eBPF/data/languages/eBPF.opinion
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc
  A	Ghidra/Processors/eBPF/data/languages/eBPF_be.slaspec

[Commit 8/15]
Hash: 52cb7a36e685af547f0e2cc9782dc46755764c51
Date: 2025-04-04 22:00:34 +0200
Message: Fix the semantics of eBPF byte swap instructions
Details:
eBPF byte swap operations (BE16, BE32, BE64, LE16, LE32, LE64) have
semantics that depend on the endianness of the host processor executing
the eBPF program. For example, on a Little-Endian CPU, BE16 swaps the 2
lowest significant bytes of the given destination register.

The semantic section of LE16 contains:

    { dst=((dst) >> 8) | ((dst) << 8); }

This contains several issues:

- It assumes the instruction always swaps the bytes. This should only
  happen on Big-Endian host CPU.
- If `dst` does not contain a 16-bit value (meaning `dst >> 16 != 0`),
  the computed value is wrong. The value should be properly masked. For
  example the Linux kernel defines in
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/swab.h?h=v6.14#L14

    #define ___constant_swab16(x) ((__u16)(             \
            (((__u16)(x) & (__u16)0x00ffU) << 8) |      \
            (((__u16)(x) & (__u16)0xff00U) >> 8)))

As the endianness of the CPU has to be the same as the eBPF program
(defined in the ELF header), introduce a macro `ENDIAN` and use it to
implement the byte swap operations.

Files changed:
  M	Ghidra/Processors/eBPF/data/languages/eBPF.sinc
  M	Ghidra/Processors/eBPF/data/languages/eBPF_le.slaspec

[Commit 9/15]
Hash: 997c64f6db8bc50c4f02f15a29d88f02a2dfeadc
Date: 2025-06-16 14:29:10 +0000
Message: GP-5759: Fixed token piece formatting

Files changed:
  M	Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc

[Commit 10/15]
Hash: 24c0699a38246fea7e32900d54d2cfa3ae42358a
Date: 2025-05-23 15:08:01 +0300
Message: SuperH4: fix FSCA opcode destination location

Files changed:
  M	Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc

[Commit 11/15]
Hash: 53d7e1608f5aeb680c53a08cf2a28ff932df5f19
Date: 2025-05-23 15:03:55 +0300
Message: SuperH4: fix fpu registers order

Files changed:
  M	Ghidra/Processors/SuperH4/data/languages/SuperH4_le.cspec

[Commit 12/15]
Hash: c86d9069c577f7a88f7ab59da1113fdd14ad7ff0
Date: 2024-10-29 19:31:21 +0000
Message: Update 6805.slaspec

Files changed:
  M	Ghidra/Processors/MC6800/data/languages/6805.slaspec

[Commit 13/15]
Hash: e04e47a7454df0c0e489e81311c8592ac418f279
Date: 2024-10-29 19:25:20 +0000
Message: Update HCS_HC.sinc
Details:
Incorporate fixes from PR

Files changed:
  M	Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc

[Commit 14/15]
Hash: 67bfea173fc03dae728c07cc468e51e360b14367
Date: 2024-10-17 01:24:10 +0100
Message: Update HCS_HC.sinc
Details:
Fixes https://github.com/NationalSecurityAgency/ghidra/issues/7064 for 68HC05

Files changed:
  M	Ghidra/Processors/HCS08/data/languages/HCS_HC.sinc

[Commit 15/15]
Hash: 270e6867dbd0c6767acadae4ceecfd1728afe88a
Date: 2024-10-17 00:10:26 +0100
Message: Update 6805.slaspec
Details:
Fix for https://github.com/NationalSecurityAgency/ghidra/issues/7064 (incorrect handling of X-indexed JMP and JSR)

Files changed:
  M	Ghidra/Processors/MC6800/data/languages/6805.slaspec
```
2025-08-04 13:36:05 -04:00
Eric Kilmer bf13fdebba Ghidra 11.4.1 (#349) 2025-08-01 17:59:24 +00:00
auto-updater[bot] a49bbcc9cf Update Ghidra HEAD to commit 7e6c01f28 (#348)
Bump Ghidra HEAD commit 7e6c01f28

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/flow.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/flow.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_op.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh
A	Ghidra/Features/Decompiler/src/decompile/datatests/inlinetarget.xml
M	Ghidra/Processors/MIPS/data/patterns/MIPS_BE_patterns.xml
M	Ghidra/Processors/MIPS/data/patterns/MIPS_LE_patterns.xml
```

Commit details:

```
[Commit 1/5]
Hash: fc4b7800251f59395e1ddc9bb85e932c69e00a65
Date: 2025-06-04 19:56:49 +0000
Message: GP-5736 prevent constant propagation from making RETURN inputs constant (Closes #8183)

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc

[Commit 2/5]
Hash: cc0203307d6b0347cae04f4794798633e36567af
Date: 2025-07-23 17:31:18 +0000
Message: GP-5863 Check for input intersection before creating unreferenced param

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh

[Commit 3/5]
Hash: c4c7aa5dad6eb651e76d86d0d1a7a5c2ad6ded61
Date: 2025-07-21 19:40:05 +0000
Message: Fix for infinite loop caused by RulePtrsubUndo

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/type.cc

[Commit 4/5]
Hash: 3468c4b5025ff936080e56163b4fc155a538ed83
Date: 2025-07-17 22:42:00 +0000
Message: GP-5843 Added MIPS64 function start patterns

Files changed:
  M	Ghidra/Processors/MIPS/data/patterns/MIPS_BE_patterns.xml
  M	Ghidra/Processors/MIPS/data/patterns/MIPS_LE_patterns.xml

[Commit 5/5]
Hash: 80d66023a974d775e97f770b826d800c1de42461
Date: 2025-07-16 18:29:53 +0000
Message: GP-5832 Update inline target op when inlining a subfunction

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/flow.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/flow.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_op.cc
  A	Ghidra/Features/Decompiler/src/decompile/datatests/inlinetarget.xml
```

Co-authored-by: pgoodman <43664+pgoodman@users.noreply.github.com>
2025-07-28 10:16:54 -04:00
auto-updater[bot] 1f41ff02e6 Update Ghidra HEAD to commit 12a8db619 (#347)
Bump Ghidra HEAD commit 12a8db619

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/marshal.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
M	Ghidra/Processors/ARM/data/languages/ARM.cspec
M	Ghidra/Processors/ARM/data/languages/ARM_win.cspec
M	Ghidra/Processors/Atmel/data/languages/avr8gcc.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv32-fp.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv32.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv64-fp.cspec
M	Ghidra/Processors/RISCV/data/languages/riscv64.cspec
```

Commit details:

```
[Commit 1/5]
Hash: 991a4b440c6fe2073ede634359afff2da8e174c8
Date: 2025-07-16 20:22:28 +0000
Message: GP-4356: fixes to avr8 cspec and elf extension, and additions to decompiler model rules

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/marshal.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.hh
  M	Ghidra/Processors/Atmel/data/languages/avr8gcc.cspec

[Commit 2/5]
Hash: f26d36c6bb961271fe7fd77a734bd4010c6a210c
Date: 2025-07-16 16:38:27 +0000
Message: GP-5211: Fix RISCV 32- and 64-bit compiler specifications and relocation handler

Files changed:
  M	Ghidra/Processors/RISCV/data/languages/riscv32-fp.cspec
  M	Ghidra/Processors/RISCV/data/languages/riscv32.cspec
  M	Ghidra/Processors/RISCV/data/languages/riscv64-fp.cspec
  M	Ghidra/Processors/RISCV/data/languages/riscv64.cspec

[Commit 3/5]
Hash: 3e117157787f79f842f72d82641426ab9d4b9a28
Date: 2025-07-14 18:38:17 +0000
Message: GP-4989: Fix ARM AAPCS cspec, add soft float calling convention

Files changed:
  M	Ghidra/Processors/ARM/data/languages/ARM.cspec
  M	Ghidra/Processors/ARM/data/languages/ARM_win.cspec

[Commit 4/5]
Hash: 3067d3e61f98d195060be8c2ee65922d16bd29f6
Date: 2025-07-14 17:21:02 +0000
Message: GP-5367: Filter by max_primitives on homogeneous aggregate types in cspec

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/marshal.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/modelrules.hh

[Commit 5/5]
Hash: b3f4609330128138f3246359bdb834ac7604e81d
Date: 2025-05-23 19:10:25 +0000
Message: GP-5718 fix for index issue

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
```
2025-07-21 09:02:43 -04:00
auto-updater[bot] 060f42d28c Update Ghidra HEAD to commit e63d97b11 (#346)
* ci: Enforce passing tests on HEAD

* Bump Ghidra HEAD commit e63d97b11

Changed files:

```
M	Ghidra/Features/Decompiler/src/decompile/cpp/Doxyfile
M	Ghidra/Features/Decompiler/src/decompile/cpp/inject_sleigh.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/inject_sleigh.hh
M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
M	Ghidra/Features/Decompiler/src/decompile/datatests/retstruct.xml
M	Ghidra/Processors/AARCH64/data/languages/AARCH64.cspec
M	Ghidra/Processors/AARCH64/data/languages/AARCH64_win.cspec
```

Commit details:

```
[Commit 1/1]
Hash: de842dbd32b0f27d9d7f222f039f6c8ebfa87598
Date: 2025-07-09 21:14:59 +0000
Message: GP-5816 Fix return recovery for AARCH64 and ARM

Files changed:
  M	Ghidra/Features/Decompiler/src/decompile/cpp/Doxyfile
  M	Ghidra/Features/Decompiler/src/decompile/cpp/inject_sleigh.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/inject_sleigh.hh
  M	Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
  M	Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
  M	Ghidra/Features/Decompiler/src/decompile/datatests/retstruct.xml
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64.cspec
  M	Ghidra/Processors/AARCH64/data/languages/AARCH64_win.cspec
```

---------

Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
2025-07-19 17:39:08 -04:00
37 changed files with 1726 additions and 426 deletions
+214
View File
@@ -0,0 +1,214 @@
---
name: debug-test-failures
version: "1.0.0"
description: >
This skill should be used when debugging test failures, build errors, runtime
crashes, or assertion failures in the Sleigh/Ghidra decompiler project. It
covers building with libc++ hardening assertions (ci-head-assertions preset),
running ctest, obtaining stack traces from SIGABRT or crash signals, narrowing
down which datatest triggers a failure, creating patch files for upstream Ghidra
source in src/patches/, and recognizing common C++ bug patterns such as
strict-weak ordering violations in comparators. Relevant when encountering
"the build is failing", "ctest fails", decompiler crashes, or libc++ assertion
errors.
---
# Debugging Test Failures in the Sleigh Project
This project builds the Ghidra decompiler as a standalone C++ library. Ghidra source
is fetched via CMake FetchContent and patches are applied via `git am`. The key
challenge is that bugs live in upstream Ghidra code and fixes must be packaged as
patch files.
## Quick Reference
```bash
# Build with libc++ assertions (catches strict-weak ordering, container misuse, etc.)
cmake --preset ci-head-assertions
cmake --build build/ci-head-assertions
ctest --test-dir build/ci-head-assertions --output-on-failure
# Clean cached Ghidra source (needed after adding/changing patches)
rm -rf build/ci-head-assertions/_deps/ghidrasource-*
# Where the Ghidra C++ source lives after fetch
build/ci-head-assertions/_deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/cpp/
```
## 0. Prerequisites
### Create `CMakeUserPresets.json`
The `ci-head-assertions` preset used throughout this workflow lives in
`CMakeUserPresets.json`, which is not version-controlled and does **not** exist on
a fresh checkout. You must create it in the repository root before any build
commands will work.
Create `/workspaces/sleigh/CMakeUserPresets.json` with this content:
```json
{
"version": 2,
"cmakeMinimumRequired": { "major": 3, "minor": 18, "patch": 0 },
"configurePresets": [
{
"name": "libcxx",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstrict-flex-arrays=3 -fstack-clash-protection -fstack-protector-strong",
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++ -lc++abi",
"CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++ -lc++abi"
}
},
{
"name": "ci-head",
"hidden": true,
"inherits": ["ci-ubuntu"],
"cacheVariables": { "sleigh_RELEASE_TYPE": "HEAD" }
},
{
"name": "ci-head-assertions",
"binaryDir": "${sourceDir}/build/${presetName}",
"inherits": ["libcxx", "ci-head"],
"generator": "Ninja",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
}
]
}
```
This file inherits from `ci-ubuntu` (defined in `CMakePresets.json`), so the
repo's version-controlled presets must also be present (they always are in a
normal checkout).
## 1. Build Presets
### The assertions preset
The `ci-head-assertions` preset (created in Section 0 above) links against libc++
with `_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG`. This enables runtime
checks that catch undefined behavior in STL usage — most importantly, it validates
that comparators passed to `std::sort` satisfy strict-weak ordering.
### Other useful presets
| Preset | Source | Purpose |
|--------|--------|---------|
| `ci-head-assertions` | `CMakeUserPresets.json` | HEAD build with libc++ debug assertions (primary debugging preset) |
| `ci-head` | `CMakeUserPresets.json` | HEAD build without assertions (faster, hidden/base preset) |
| `ci-sanitize` | `CMakePresets.json` | Stable build with ASan + UBSan (repo-controlled) |
Note: `ci-head-assertions` and `ci-head` are user-local presets created in
Section 0. `ci-sanitize` is the only sanitizer preset version-controlled in the
repo. Add your own sanitizer presets to `CMakeUserPresets.json` as needed.
## 2. Running Tests
```bash
# Run all tests
ctest --test-dir build/ci-head-assertions --output-on-failure
# Run a specific test
ctest --test-dir build/ci-head-assertions -R decomp_datatest --output-on-failure
```
There are typically 3 tests:
| Test | What it does |
|------|--------------|
| `sleigh_decomp_unittest` | Unit tests (fast) |
| `sleigh_decomp_datatest` | Decompiler data tests — runs XML test files from the `datatests/` directory |
| `sleigh_namespace_std_test` | Namespace compilation test |
The datatest exercises the most code paths and is the most likely to trigger
assertion failures from comparator bugs.
### How datatest works
The test binary loads XML files from the datatests directory in alphabetical order.
Each XML file contains binary data + expected decompiler output patterns. The test
decompiles each function and checks the output against `<stringmatch>` patterns.
The exact command ctest uses (check `tests/CTestTestfile.cmake` for the authoritative version):
```bash
./tests/sleigh_decomp_test \
-sleighpath <build-dir> \
-path <build-dir>/_deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/datatests \
datatests
```
## 3. Getting a Stack Trace from a Crash
When a test crashes (e.g., SIGABRT from an assertion), you need a stack trace to
identify which comparator or code path is the culprit. The test binaries may not
have full debug symbols, so multiple techniques may be needed.
See `references/stack-trace-techniques.md` for the full details on each method.
Here's the summary:
1. **gdb**: Use `gdb -batch` for full demangled backtraces — the simplest method
2. **lldb**: Use `lldb -b` with `-k` for crash-time backtrace commands
3. **LD_PRELOAD backtrace**: Build a small shared library that catches SIGABRT and
prints a backtrace — works when neither debugger can attach (containers)
4. **addr2line**: Resolve raw hex addresses from the backtrace to function names
and source lines
## 4. Narrowing Down Which Test Triggers a Crash
> **Tip**: Often the stack trace from Section 3 identifies the exact function and
> source line, making this step unnecessary. Use this binary search technique only
> when the stack trace is unclear or you need to isolate which specific test input
> triggers the crash.
When you know the test crashes but can't immediately identify the cause from the
stack trace, use binary search on the test XML files.
The idea: copy subsets of test files to a temporary directory and run the test
binary against that subset. Keep halving until you isolate the triggering file.
```bash
cd build/ci-head-assertions
# Copy a subset of test files to a temporary directory
mkdir -p /tmp/test_subset
SRC=_deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/datatests
for f in $(ls $SRC/*.xml | sort | sed -n '1,20p'); do cp "$f" /tmp/test_subset/; done
# Run just those tests
./tests/sleigh_decomp_test -sleighpath . -path /tmp/test_subset datatests
```
Important: some crashes only reproduce when specific files are processed together
(accumulated state from earlier tests), so start by splitting the full set in half
rather than testing individual files. If an individual file doesn't crash alone, try
combining it with files that ran before it in alphabetical order.
## 5. Creating Patches for Ghidra Source
Patches live in `src/patches/HEAD/` (for HEAD builds) and `src/patches/stable/`
(for stable builds). They are applied via `git am` during the CMake FetchContent
step. See `references/patching-workflow.md` for the full step-by-step.
### Quick workflow
1. **Edit the bug** in `build/<preset>/_deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/cpp/`
2. **Commit**: `cd` into the ghidrasource-src dir, `git add` + `git commit`
3. **Generate patches**: `git format-patch -o /workspaces/sleigh/src/patches/HEAD/ <base_commit>..HEAD`
4. **Register** the new patch in `src/setup-ghidra-source.cmake`
5. **Clean and rebuild**: `rm -rf build/<preset>/_deps/ghidrasource-*` then reconfigure
The base commit for HEAD is the `ghidra_head_git_tag` value in `src/setup-ghidra-source.cmake`.
## 6. Common Bug Patterns
The most common bugs are **strict-weak ordering violations** in comparators used
by `std::sort` or `std::set`. These are caught by libc++ assertions at runtime.
Key patterns include null pointer sentinels that don't check self-comparison,
special index early-returns without checking the other operand, and unsafe casts
in `compareDependency` methods of TypePartial* classes.
See `references/common-bug-patterns.md` for detailed before/after code examples,
real-world instances from the codebase (e.g., `PullRecord::operator<` in
`bitfield.cc`, `FlowBlock::compareFinalOrder` in `block.cc`), and a systematic
audit checklist for finding new comparator bugs.
@@ -0,0 +1,72 @@
# Common Bug Patterns in Ghidra Decompiler Source
## Strict-weak ordering violations
The most common class of bugs caught by libc++ assertions. A comparator for
`std::sort` or `std::set` must satisfy:
- **Irreflexivity**: `comp(a, a)` must return `false`
- **Asymmetry**: if `comp(a, b)` is true then `comp(b, a)` must be false
- **Transitivity**: if `comp(a, b)` and `comp(b, c)` then `comp(a, c)`
The libc++ assertion message looks like:
```
strict_weak_ordering_check.h:50: libc++ Hardening assertion
!__comp(*(__first + __a), *(__first + __b)) failed:
Your comparator is not a valid strict-weak ordering
```
### Pattern 1: Null pointer sentinel without self-check
```cpp
// BUG: when both are null, returns true (violates irreflexivity)
if (ptr == nullptr)
return true;
// FIX: only return true when the other is non-null
if (ptr == nullptr)
return (other.ptr != nullptr);
```
Real example: `PullRecord::operator<` in `bitfield.cc` — when both `readOp`
pointers were null, the comparator returned `true`.
### Pattern 2: Special index without self-check
```cpp
// BUG: when comparing the entry point with itself, returns true
if (bl1->getIndex() == 0) return true;
// FIX: check that the other is different
if (bl1->getIndex() == 0) return (bl2->getIndex() != 0);
```
Real example: `FlowBlock::compareFinalOrder` in `block.cc`.
### Pattern 3: Unsafe cast in compareDependency (TypePartial* classes)
The `TypePartialEnum`, `TypePartialStruct`, and `TypePartialUnion` classes have
`compareDependency` methods that cast `op` to their own type. If `op` is actually
the parent container type (not a partial), the cast accesses invalid memory.
```cpp
// BUG: casts op to TypePartialFoo without checking if op IS the container
TypePartialFoo *tp = (TypePartialFoo *) &op;
// FIX: add a guard before the cast
if (container == &op) return 1; // op is our container
TypePartialFoo *tp = (TypePartialFoo *) &op;
```
Real example: `TypePartialEnum::compareDependency` in `type.cc` (patched in 0005).
## How to audit comparators systematically
1. Search for all `operator<`, `::compare`, and `::compareDependency` functions
2. Search for all `sort(`, `stable_sort(`, and `std::set` usage to find which
comparators are actually used in sorting contexts
3. For each comparator, mentally trace the case where both arguments are identical
— does it return false?
4. Check for early-return branches that don't verify the other operand differs
5. For `compareDependency` methods in TypePartial* classes, check for the
container-guard pattern before unsafe casts
@@ -0,0 +1,153 @@
# Patching Workflow for Ghidra Source
## Overview
Ghidra source is fetched via CMake FetchContent from GitHub. Patches are applied
automatically during the configure step using `git am`. The patch files live in
the Sleigh repo and are version-controlled.
## Directory Structure
```
src/patches/
├── HEAD/ # Patches for the HEAD (development) Ghidra commit
│ ├── 0001-Fix-UBSAN-errors-in-decompiler.patch
│ ├── 0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch
│ └── ...
└── stable/ # Patches for the stable Ghidra release
├── 0001-Fix-UBSAN-errors-in-decompiler.patch
└── ...
```
## Key Configuration
The base commit and patch list are defined in `src/setup-ghidra-source.cmake`:
- `ghidra_head_git_tag`: The pinned HEAD commit hash
- `ghidra_version` / `ghidra_git_tag`: The stable version tag
- `ghidra_patches`: The ordered list of patch files to apply
## Step-by-Step: Creating a New Patch
### 1. Identify the build preset
Determine which build you're fixing. The Ghidra source checkout location depends
on the preset:
```
build/<preset>/_deps/ghidrasource-src/
```
For example:
```
build/ci-head-assertions/_deps/ghidrasource-src/
```
The C++ source files are in:
```
build/<preset>/_deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/cpp/
```
### 2. Make the fix
Edit the file directly in the Ghidra source checkout. The file already has all
existing patches applied, so you're working on top of the current patch stack.
### 3. Commit in the Ghidra source checkout
```bash
cd build/<preset>/_deps/ghidrasource-src
# In a fresh container, git may require identity configuration before committing:
# git config user.name "Your Name" && git config user.email "your@email.com"
git add Ghidra/Features/Decompiler/src/decompile/cpp/<file>.cc
git commit -m "decompiler: Short description
Longer explanation of the bug and fix. Mention what assertion or test
was failing and why."
```
Commit message conventions:
- Prefix with `decompiler:` for decompiler fixes
- First line should be concise (under 72 chars)
- Body explains the *why*, not just the *what*
### 4. Generate patch files
Use `git format-patch` to regenerate ALL patches from the base commit:
```bash
# Get the base commit from src/setup-ghidra-source.cmake
# For HEAD: it's the ghidra_head_git_tag value
# For stable: it's the Ghidra_X.Y.Z_build tag
git format-patch -o /workspaces/sleigh/src/patches/HEAD/ <base_commit>..HEAD
```
This regenerates patches 0001 through 000N. Existing patches will be regenerated
with updated numbering in the `[PATCH N/M]` subject line, but the content stays
the same. The new patch gets the next number.
### 5. Register in CMake
Edit `src/setup-ghidra-source.cmake` and add the new patch file to the appropriate
`ghidra_patches` list:
```cmake
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0006-your-new-patch-name.patch"
```
### 6. Verify from scratch
Clean the cached source so FetchContent re-fetches and applies all patches fresh:
```bash
rm -rf build/<preset>/_deps/ghidrasource-*
cmake --preset <preset>
cmake --build build/<preset>
ctest --test-dir build/<preset> --output-on-failure
```
Watch the configure output for:
```
Applying: <your commit message>
```
If a patch fails to apply, you'll see `Patch failed at NNNN ...` during configure.
## HEAD vs Stable
- **HEAD patches** (`src/patches/HEAD/`): Applied to the development commit. May
include fixes for newly added files (e.g., `bitfield.cc` is HEAD-only).
- **Stable patches** (`src/patches/stable/`): Applied to the release tag. These
are typically a subset of HEAD patches that also apply to stable.
Check `src/setup-ghidra-source.cmake` to see which files are HEAD-only (look for
`if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")` blocks).
## Troubleshooting
### Patch fails to apply
If `git am` fails during configure, the Ghidra source checkout may be in a dirty
state. Clean it:
```bash
rm -rf build/<preset>/_deps/ghidrasource-*
```
Then reconfigure. If the patch itself is wrong, fix it and try again.
### Patches conflict with new Ghidra commit
When updating the pinned Ghidra HEAD commit, existing patches may not apply cleanly.
See the [wiki](https://github.com/lifting-bits/sleigh/wiki/Patching-and-Updating)
for the full rebasing procedure.
### Source already patched from manual edits
If you edited files directly in the checkout and then try to reconfigure, CMake
may try to apply patches on top of already-patched code. Always clean the
`_deps/ghidrasource-*` directories before reconfiguring after generating new
patches.
@@ -0,0 +1,149 @@
# Stack Trace Techniques
When a test binary crashes (typically SIGABRT from a libc++ hardening assertion),
these techniques can be used to identify the exact function and source line.
## Method 1: gdb (simplest)
gdb in batch mode produces full demangled backtraces and works reliably in most
environments, including containers with default seccomp profiles.
```bash
cd build/ci-head-assertions
gdb -batch \
-ex "run -sleighpath . -path _deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/datatests datatests" \
-ex "bt" \
./tests/sleigh_decomp_test
```
gdb will run the program, and when it crashes (e.g., SIGABRT), it automatically
stops and prints the backtrace. The output includes fully demangled C++ function
names and source locations.
If gdb is unavailable, try lldb (Method 2). If neither debugger can attach
(restricted ptrace), fall back to Method 3.
## Method 2: lldb
Use lldb in batch mode with the full test arguments. The key is to handle SIGABRT
so it stops instead of terminating.
**Important**: Use `-k` (one-line-on-crash) for the backtrace command, not `-o`.
Commands passed via `-o` run sequentially after file load, but when lldb hits a
signal stop, it enters its event loop and won't execute subsequent `-o` commands.
The `-k` flag queues commands to run specifically when the target crashes.
```bash
cd build/ci-head-assertions
lldb -b \
-o "process handle SIGABRT --stop true --pass false" \
-o "run -sleighpath . -path _deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/datatests datatests" \
-k "thread backtrace" \
-k "quit" \
-- ./tests/sleigh_decomp_test
```
If lldb shows full symbol names (function + file + line), you're done.
If lldb fails with "personality set failed: Operation not permitted", this is
common in Docker containers where ptrace is restricted. Use Method 3 instead.
## Method 3: LD_PRELOAD Backtrace Library
Build a small shared library that intercepts SIGABRT and prints a backtrace:
```bash
cat > /tmp/bt_preload.c << 'BTEOF'
#include <signal.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void bt_handler(int sig) {
void *array[50];
int size = backtrace(array, 50);
fprintf(stderr, "=== BACKTRACE (signal %d) ===\n", sig);
backtrace_symbols_fd(array, size, STDERR_FILENO);
fprintf(stderr, "=== END BACKTRACE ===\n");
signal(sig, SIG_DFL);
raise(sig);
}
__attribute__((constructor))
void install_handler(void) {
signal(SIGABRT, bt_handler);
}
BTEOF
gcc -shared -fPIC -o /tmp/bt_preload.so /tmp/bt_preload.c -rdynamic
```
Run the test with the preloaded library:
```bash
cd build/ci-head-assertions
LD_PRELOAD=/tmp/bt_preload.so ./tests/sleigh_decomp_test \
-sleighpath . \
-path _deps/ghidrasource-src/Ghidra/Features/Decompiler/src/decompile/datatests \
datatests
```
The output will look like:
```
=== BACKTRACE (signal 6) ===
./tests/sleigh_decomp_test(+0xf1a64)[0x55c312f02a64]
./tests/sleigh_decomp_test(+0xf17ea)[0x55c312f027ea]
./tests/sleigh_decomp_test(+0xef732)[0x55c312f00732]
...
=== END BACKTRACE ===
```
The addresses in parentheses (like `+0xf1a64`) are the key — these are offsets
from the binary's load address.
## Method 4: addr2line
Resolve the hex offsets from the backtrace to function names and source lines:
```bash
for addr in 0xf1a64 0xf17ea 0xef732 0x31fbd9 0x31d536; do
echo -n "$addr: "
addr2line -e ./tests/sleigh_decomp_test -f -C "$addr"
echo "---"
done
```
Flags:
- `-e` specifies the executable
- `-f` prints function names
- `-C` demangles C++ names
Example output:
```
0xf1a64: void std::__1::__check_strict_weak_ordering_sorted<...>(...)
/usr/lib/llvm-21/bin/../include/c++/v1/__debug_utils/strict_weak_ordering_check.h:51
---
0x31fbd9: ghidra::BlockGraph::orderBlocks()
/path/to/block.hh:431
---
```
This tells you exactly which sort call and which comparator function triggered
the assertion.
## Putting It All Together
Typical debugging flow:
1. Run the test: `ctest --test-dir build/ci-head-assertions -R decomp_datatest --output-on-failure`
2. See assertion failure → need stack trace
3. Try gdb first (Method 1) — it typically gives the best output with full demangled symbols
4. If gdb is unavailable, try lldb (Method 2)
5. If neither debugger can attach → build LD_PRELOAD library (Method 3)
6. Resolve addresses with addr2line (Method 4) if the backtrace only has hex offsets
7. Now you know which comparator function and sort call is the problem
8. Read the comparator code and check for strict-weak ordering violations
+37
View File
@@ -0,0 +1,37 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV LLVM_VERSION=21
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
gnupg \
wget \
software-properties-common \
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-${LLVM_VERSION} main" \
> /etc/apt/sources.list.d/llvm.list \
&& apt-get update && apt-get install -y \
clang-${LLVM_VERSION} \
clangd-${LLVM_VERSION} \
lld-${LLVM_VERSION} \
llvm-${LLVM_VERSION}-dev \
libclang-${LLVM_VERSION}-dev \
libc++-${LLVM_VERSION}-dev \
libc++abi-${LLVM_VERSION}-dev \
lldb-${LLVM_VERSION} \
cmake \
ninja-build \
git \
zlib1g-dev \
ccache \
doxygen \
graphviz \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${LLVM_VERSION} 100 \
&& update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-${LLVM_VERSION} 100 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
+19
View File
@@ -0,0 +1,19 @@
{
"name": "sleigh",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt=seccomp=unconfined",
"--privileged"
],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"llvm-vs-code-extensions.vscode-clangd",
]
}
}
}
+161
View File
@@ -0,0 +1,161 @@
name: Documentation
on:
release:
types: [published]
workflow_dispatch: # manual trigger
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- name: Setup Git User for Applying Patches
# See this thread for more details https://github.community/t/github-actions-bot-email-address/17204/5
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz
# Build stable documentation
- name: Configure (stable)
run: cmake --preset=ci-ubuntu -Dsleigh_RELEASE_TYPE=stable
- name: Build documentation (stable)
run: cmake --build build --target docs
- name: Copy stable docs
run: |
mkdir -p docs-site/stable
cp -r build/docs/html/* docs-site/stable/
# Clean and build HEAD documentation
- name: Clean build directory
run: rm -rf build
- name: Configure (HEAD)
run: cmake --preset=ci-ubuntu -Dsleigh_RELEASE_TYPE=HEAD
- name: Build documentation (HEAD)
run: cmake --build build --target docs
- name: Copy HEAD docs
run: |
mkdir -p docs-site/HEAD
cp -r build/docs/html/* docs-site/HEAD/
# Create landing page
- name: Create landing page
run: |
cat > docs-site/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sleigh Documentation</title>
<style>
:root {
--bg-color: #f5f5f5;
--text-color: #333;
--text-muted: #666;
--card-bg: white;
--card-shadow: rgba(0,0,0,0.1);
--card-shadow-hover: rgba(0,0,0,0.15);
--link-color: #0066cc;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-color: #1a1a1a;
--text-color: #e0e0e0;
--text-muted: #a0a0a0;
--card-bg: #2d2d2d;
--card-shadow: rgba(0,0,0,0.3);
--card-shadow-hover: rgba(0,0,0,0.4);
--link-color: #4da6ff;
}
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 2rem;
background: var(--bg-color);
color: var(--text-color);
}
h1 {
color: var(--text-color);
}
.cards {
display: flex;
gap: 1rem;
margin-top: 2rem;
}
.card {
flex: 1;
background: var(--card-bg);
border-radius: 8px;
padding: 1.5rem;
text-decoration: none;
color: inherit;
box-shadow: 0 2px 4px var(--card-shadow);
transition: box-shadow 0.2s;
}
.card:hover {
box-shadow: 0 4px 8px var(--card-shadow-hover);
}
.card h2 {
margin-top: 0;
color: var(--link-color);
}
.card p {
color: var(--text-muted);
margin-bottom: 0;
}
</style>
</head>
<body>
<h1>Sleigh Documentation</h1>
<p>Select a documentation version:</p>
<div class="cards">
<a href="stable/" class="card">
<h2>Stable</h2>
<p>Documentation for the latest stable release.</p>
</a>
<a href="HEAD/" class="card">
<h2>HEAD</h2>
<p>Documentation for the latest Ghidra HEAD development version.</p>
</a>
</div>
</body>
</html>
EOF
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: docs-site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
+194 -9
View File
@@ -13,6 +13,9 @@ on:
branches:
- "*"
env:
LLVM_VERSION: 21
jobs:
build:
runs-on: ${{ matrix.os }}
@@ -23,9 +26,14 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
build_type: [RelWithDebInfo, Debug]
release: [stable, HEAD]
exclude:
- os: ubuntu-latest
build_type: Debug
- os: macos-latest
build_type: Debug
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup Git User for Applying Patches
# See this thread for more details https://github.community/t/github-actions-bot-email-address/17204/5
@@ -67,7 +75,7 @@ jobs:
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_TIMESTAMP=${current_date}\n")
- name: Update the cache (ccache)
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: "${{ github.workspace }}/ccache"
key: ${{ env.CACHE_KEY }}_ccache_${{ env.CACHE_TIMESTAMP }}
@@ -113,7 +121,7 @@ jobs:
- name: Test the project
working-directory: build
run: ctest -VV -C ${{ matrix.build_type }} ${{ matrix.release == 'HEAD' && '|| true' || '' }}
run: ctest -VV -C ${{ matrix.build_type }}
- name: Build the docs
run: cmake
@@ -214,13 +222,14 @@ jobs:
# DEB Package
- name: Upload the DEB package artifact (RelWithDebInfo only)
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: ${{ env.DEB_PACKAGE_NAME }}
path: ${{ env.DEB_PACKAGE_PATH }}
archive: false
- name: Release DEB package artifact (RelWithDebInfo only)
uses: softprops/action-gh-release@v2.3.2
uses: softprops/action-gh-release@v2.5.0
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
with:
files: ${{ env.DEB_PACKAGE_PATH }}
@@ -228,12 +237,13 @@ jobs:
# RPM Package
- name: Upload the RPM package artifact (RelWithDebInfo only)
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: ${{ env.RPM_PACKAGE_NAME }}
path: ${{ env.RPM_PACKAGE_PATH }}
archive: false
- name: Release RPM package artifact (RelWithDebInfo only)
uses: softprops/action-gh-release@v2.3.2
uses: softprops/action-gh-release@v2.5.0
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
with:
files: ${{ env.RPM_PACKAGE_PATH }}
@@ -241,16 +251,191 @@ jobs:
# TGZ Package
- name: Upload the TGZ package artifact (RelWithDebInfo only)
if: matrix.build_type == 'RelWithDebInfo'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: ${{ env.TGZ_PACKAGE_NAME }}
path: ${{ env.TGZ_PACKAGE_PATH }}
archive: false
- name: Release TGZ package artifact (RelWithDebInfo only)
uses: softprops/action-gh-release@v2.3.2
uses: softprops/action-gh-release@v2.5.0
if: matrix.build_type == 'RelWithDebInfo' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
with:
files: ${{ env.TGZ_PACKAGE_PATH }}
- name: ccache stats
run: ccache -s
sanitizer:
runs-on: ubuntu-latest
permissions:
contents: read
env:
ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_leaks=1
UBSAN_OPTIONS: print_stacktrace=1
strategy:
fail-fast: false
matrix:
release: [stable, HEAD]
steps:
- uses: actions/checkout@v6
- name: Setup Git User for Applying Patches
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Install LLVM
run: |
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh
chmod +x /tmp/llvm.sh
sudo /tmp/llvm.sh $LLVM_VERSION
echo "CXX=clang++-$LLVM_VERSION" >> "$GITHUB_ENV"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ccache
- 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=sanitizer_${{ matrix.release }}\n")
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_TIMESTAMP=${current_date}\n")
- name: Update the cache (ccache)
uses: actions/cache@v5
with:
path: "${{ github.workspace }}/ccache"
key: ${{ env.CACHE_KEY }}_ccache_${{ env.CACHE_TIMESTAMP }}
restore-keys: |
${{ env.CACHE_KEY }}_ccache_
- name: Setup ccache
working-directory: "${{ github.workspace }}"
shell: cmake -P {0}
run: |
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ccache")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_BASEDIR=${CMAKE_CURRENT_SOURCE_DIR}\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/ccache\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESS=true\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESSLEVEL=10\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n")
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_CXX_COMPILER_LAUNCHER=ccache\n")
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_C_COMPILER_LAUNCHER=ccache\n")
execute_process(COMMAND ccache -z)
- name: Configure the project
run: cmake --preset=ci-sanitize
-Dsleigh_RELEASE_TYPE=${{ matrix.release }}
-Dsleigh_BUILD_DOCUMENTATION=OFF
- name: Build the project
run: cmake
--build build/sanitize
-j 4
-v
- name: Test the project
working-directory: build/sanitize
run: ctest -VV
- name: Run the example
run: cmake
--build build/sanitize
-j 4
--target sleigh_example_runner
- name: Run the install target
run: cmake --install build/sanitize
--prefix install
- name: Smoketest sleigh lift
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: ccache stats
run: ccache -s
assertions:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
release: [stable, HEAD]
steps:
- uses: actions/checkout@v6
- name: Setup Git User for Applying Patches
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Install LLVM
run: |
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh
chmod +x /tmp/llvm.sh
sudo /tmp/llvm.sh $LLVM_VERSION
echo "CXX=clang++-$LLVM_VERSION" >> "$GITHUB_ENV"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y ccache libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev
- 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=assertions_${{ matrix.release }}\n")
file(APPEND "$ENV{GITHUB_ENV}" "CACHE_TIMESTAMP=${current_date}\n")
- name: Update the cache (ccache)
uses: actions/cache@v5
with:
path: "${{ github.workspace }}/ccache"
key: ${{ env.CACHE_KEY }}_ccache_${{ env.CACHE_TIMESTAMP }}
restore-keys: |
${{ env.CACHE_KEY }}_ccache_
- name: Setup ccache
working-directory: "${{ github.workspace }}"
shell: cmake -P {0}
run: |
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ccache")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_BASEDIR=${CMAKE_CURRENT_SOURCE_DIR}\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/ccache\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESS=true\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESSLEVEL=10\n")
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n")
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_CXX_COMPILER_LAUNCHER=ccache\n")
file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_C_COMPILER_LAUNCHER=ccache\n")
execute_process(COMMAND ccache -z)
- name: Configure the project
run: cmake --preset=ci-assertions
-Dsleigh_RELEASE_TYPE=${{ matrix.release }}
-Dsleigh_BUILD_DOCUMENTATION=OFF
- name: Build the project
run: cmake
--build build/assertions
-j 4
-v
- name: Test the project
working-directory: build/assertions
run: ctest -VV
- name: ccache stats
run: ccache -s
+77 -24
View File
@@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
# Use oldest supported version for maximum script compatibility
python-version: '3.10'
@@ -26,37 +26,90 @@ jobs:
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@v2
# See here for more details https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens
- uses: actions/create-github-app-token@v2
if: steps.head_update.outputs.did_update
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create PR
- name: Commit, push, and create PR
if: steps.head_update.outputs.did_update
uses: peter-evans/create-pull-request@v7
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 }}
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
BRANCH="cron/update-ghidra-${{ steps.head_update.outputs.short_sha }}"
Changed files:
# Check if PR already exists for this branch
if gh pr list --head "$BRANCH" --json number --jq '.[0].number' | grep -q .; then
echo "PR already exists for branch $BRANCH, skipping"
exit 0
fi
${{ steps.head_update.outputs.changed_files }}
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Commit details:
# Create branch and commit
git checkout -b "$BRANCH"
git add -A
git commit -m "$(cat <<'EOF'
Bump Ghidra HEAD commit ${{ steps.head_update.outputs.short_sha }}
${{ steps.head_update.outputs.commit_details }}
body: |
Changed files:
Changed files:
${{ steps.head_update.outputs.changed_files }}
${{ steps.head_update.outputs.changed_files }}
Commit details:
Commit details:
${{ steps.head_update.outputs.commit_details }}
branch: cron/update-ghidra-${{ steps.head_update.outputs.short_sha }}
delete-branch: true
token: ${{ steps.generate-token.outputs.token }}
${{ steps.head_update.outputs.commit_details }}
EOF
)"
# Push branch
git push -u origin "$BRANCH"
# Build PR body using heredoc with single-quoted delimiter to prevent
# bash from interpreting backticks in the markdown content as command
# substitution. GitHub Actions expressions are expanded before bash
# processes the script, so they still get substituted.
BASE_BODY=$(cat <<'PRBODY'
Changed files:
${{ steps.head_update.outputs.changed_files }}
Commit details:
${{ steps.head_update.outputs.commit_details }}
PRBODY
)
# Add intervention warning if needed
if [ "${{ steps.head_update.outputs.needs_manual_intervention }}" = "true" ]; then
INTERVENTION=$(cat <<'PRBODY'
## :warning: Manual Intervention Required
The following files were added or deleted and may require manual CMake configuration updates:
${{ steps.head_update.outputs.intervention_details }}
### Instructions
- **New C++ sources**: Add to appropriate list in `src/setup-ghidra-source.cmake`
- **Deleted C++ sources**: Remove from `src/setup-ghidra-source.cmake`
- **New spec files**: Review if `.slaspec` files are auto-generated; other types may need manual updates
- **Deleted spec files**: Verify no longer referenced
---
PRBODY
)
PR_BODY="${INTERVENTION}${BASE_BODY}"
else
PR_BODY="$BASE_BODY"
fi
# Create PR
gh pr create \
--title "Update Ghidra HEAD to commit ${{ steps.head_update.outputs.short_sha }}" \
--body "$PR_BODY"
+117
View File
@@ -0,0 +1,117 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Sleigh is a CMake-based build system for Ghidra's Sleigh/decompiler C++ libraries (by Trail of Bits). It wraps NSA's Ghidra source code — fetched via CMake FetchContent during configure — so the Sleigh disassembly and decompilation engines can be built as standalone C++ libraries for reuse outside Ghidra.
**The actual Ghidra C++ source is not in this repo.** It is cloned from GitHub automatically during CMake configuration.
## Build Commands
```sh
# Standard build (fetches Ghidra source on first configure)
cmake -B build -S .
cmake --build build -j$(nproc)
# CI-style build with developer mode (enables tests, docs, warnings)
cmake --preset=ci-ubuntu
cmake --build build -j$(nproc)
# Build with HEAD (bleeding-edge) Ghidra instead of stable
cmake -B build -S . -Dsleigh_RELEASE_TYPE=HEAD
# Use a local Ghidra checkout (avoids re-cloning)
cmake -B build -S . -Dsleigh_RELEASE_TYPE=HEAD \
-DFETCHCONTENT_SOURCE_DIR_GHIDRASOURCE=/path/to/ghidra
# Sanitizer build
cmake --preset=ci-sanitize
cmake --build build/sanitize -j$(nproc)
```
## Running Tests
Tests require `sleigh_DEVELOPER_MODE=ON` (enabled by all `ci-*` presets).
```sh
# Run all tests
cd build && ctest -VV
# Run specific test by name
cd build && ctest -VV -R sleigh_decomp_unittest # unit tests
cd build && ctest -VV -R sleigh_decomp_datatest # data-driven tests
cd build && ctest -VV -R sleigh_namespace_std_test # header hygiene check
```
Test binary: `sleigh_decomp_test` — wraps Ghidra's own test suite. Takes `-sleighpath` for compiled .sla files and a test mode (`unittests` or `datatests`).
## Architecture
### Library Targets
| Target | Library | C++ Std | Description |
|--------|---------|---------|-------------|
| `sleigh::sla` | `sla` | C++11 | Core sleigh: disassembly, encoding, p-code, emulation |
| `sleigh::decomp` | `decomp` | C++11 | Full decompiler (superset of sla) |
| `sleigh::support` | `slaSupport` | C++17 | Trail of Bits helpers: `FindSpecFile()`, version info |
Headers: `<ghidra/*.hh>` for upstream Ghidra headers, `<sleigh/*.h>` for ToB additions.
### Key Directories
- `src/setup-ghidra-source.cmake` — Pinned Ghidra versions, FetchContent, source file lists, patch application. **This is the central file for version bumps and source management.**
- `src/patches/{stable,HEAD}/` — Git-format patches applied to Ghidra source during fetch
- `src/spec_files_{stable,HEAD}.cmake` — Lists of ~148 .slaspec files to compile
- `tools/` — Ghidra executables (sleigh compiler, decompiler, ghidra service)
- `support/` — Trail of Bits support library (C++17)
- `extra-tools/sleigh-lift/` — Demo tool for disassembly/p-code lifting
- `cmake/modules/sleighCompile.cmake``sleigh_compile()` function exported for downstream users
### How Ghidra Source Integration Works
1. `src/setup-ghidra-source.cmake` pins a Ghidra git ref (tag for stable, commit hash for HEAD)
2. CMake FetchContent clones from `github.com/NationalSecurityAgency/ghidra`
3. Patches from `src/patches/` are applied via `git am`
4. Source file lists reference into `Ghidra/Features/Decompiler/src/decompile/cpp/`
5. Headers are copied into `build/include/ghidra/` for clean include paths
### Two Release Tracks
- **stable** (default): Pinned to a Ghidra release tag (e.g., `Ghidra_12.0.3_build`). Shallow clone.
- **HEAD**: Pinned to a specific commit on Ghidra main. Full clone. Updated weekly by CI via `scripts/update_ghidra_head.py`.
## Patch System
Patches fix upstream Ghidra bugs (UB sanitizer issues, portability, strict weak ordering violations) without changing Sleigh functionality. They are standard `git format-patch` files.
- `src/patches/stable/` — Patches for stable release
- `src/patches/HEAD/` — Superset of stable patches plus HEAD-specific fixes
- Custom patches via: `-Dsleigh_ADDITIONAL_PATCHES="path/to/patch1;path/to/patch2"`
When adding patches: create with `git format-patch`, number sequentially, and add to both directories if applicable. Patches in HEAD must be a superset of stable patches.
## Key Gotchas
- **In-source builds are forbidden** — enforced by `cmake/prelude.cmake`
- **First configure is slow** — Ghidra repo clone takes time (especially HEAD which can't shallow clone)
- **Core libraries are C++11** — the support library and extra tools are C++17, but `sleigh::sla` and `sleigh::decomp` must stay C++11
- **Source file lists are manual** — when Ghidra adds/removes .cc files, `src/setup-ghidra-source.cmake` must be updated; the `scripts/update_ghidra_head.py` script detects new files and flags them
- **Strict weak ordering** — a recurring class of upstream bugs in Ghidra comparators; several patches fix these
- **Spec files differ between releases** — `src/spec_files_stable.cmake` and `src/spec_files_HEAD.cmake` are separate lists and must be maintained independently
## CMake Presets Reference
| Preset | Use Case |
|--------|----------|
| `ci-ubuntu` | Linux dev build with warnings and tests |
| `ci-macos` | macOS dev build |
| `ci-windows` | Windows dev build (VS 2022, vcpkg) |
| `ci-sanitize` | ASan + UBSan (builds to `build/sanitize/`) |
| `ci-coverage` | Code coverage (builds to `build/coverage/`) |
## Code Style
- `.clang-format`: BasedOnStyle LLVM
- Compiler warnings are strict in CI (see `flags-unix`/`flags-windows` presets)
+6 -4
View File
@@ -146,11 +146,13 @@ set(public_include_header_list
"${library_root}/multiprecision.hh"
"${library_root}/slaformat.hh"
"${library_root}/constseq.hh"
"${library_root}/expression.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}/bitfield.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)
+11
View File
@@ -114,6 +114,17 @@
"CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common"
}
},
{
"name": "ci-assertions",
"binaryDir": "${sourceDir}/build/assertions",
"inherits": ["ci-unix", "dev-mode"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Assertions",
"CMAKE_CXX_FLAGS_ASSERTIONS": "-O0 -g -stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -fstack-protector-strong",
"CMAKE_EXE_LINKER_FLAGS_ASSERTIONS": "-stdlib=libc++ -lc++abi",
"CMAKE_SHARED_LINKER_FLAGS_ASSERTIONS": "-stdlib=libc++ -lc++abi"
}
},
{
"name": "ci-build",
"binaryDir": "${sourceDir}/build",
+1 -1
View File
@@ -1,6 +1,6 @@
# Sleigh Library
[Sleigh](https://ghidra.re/courses/languages/html/sleigh.html) is a language used to describe the semantics of instruction sets of general-purpose microprocessors, with enough detail to facilitate the reverse engineering of software compiled for these architectures. It is part of the [Ghidra reverse engineering platform](https://github.com/NationalSecurityAgency/ghidra) and underpins two of its major components: its disassembly and decompilation engines.
[Sleigh](https://ghidra.re/ghidra_docs/languages/html/sleigh.html) is a language used to describe the semantics of instruction sets of general-purpose microprocessors, with enough detail to facilitate the reverse engineering of software compiled for these architectures. It is part of the [Ghidra reverse engineering platform](https://github.com/NationalSecurityAgency/ghidra) and underpins two of its major components: its disassembly and decompilation engines.
This repository provides a CMake-based build project for Sleigh so that it can be built and packaged as a standalone library and be reused in projects other than Ghidra.
+24 -4
View File
@@ -123,8 +123,18 @@ static void PrintAssembly(ghidra::Sleigh &engine, uint64_t addr, size_t len) {
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);
cur_addr = cur_addr + instr_len;
try {
int32_t instr_len = engine.printAssembly(asm_emit, cur_addr);
cur_addr = cur_addr + instr_len;
}
catch(ghidra::UnimplError &err) {
std::cerr << "UnimplError @ " << cur_addr << " (addr 0x" << addr << ", len 0x" << len << "): " << err.explain << "\n";
break;
}
catch (ghidra::BadDataError &err) {
std::cerr << "BadDataError @ " << cur_addr << " (addr 0x" << addr << ", len 0x" << len << "): " << err.explain << "\n";
break;
}
}
}
@@ -157,8 +167,18 @@ static void PrintPcode(ghidra::Sleigh &engine, uint64_t addr, size_t len) {
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);
cur_addr = cur_addr + instr_len;
try {
int32_t instr_len = engine.oneInstruction(pcode_emit, cur_addr);
cur_addr = cur_addr + instr_len;
}
catch(ghidra::UnimplError &err) {
std::cerr << "UnimplError @ " << cur_addr << " (addr 0x" << addr << ", len 0x" << len << "): " << err.explain << "\n";
break;
}
catch(ghidra::BadDataError &err) {
std::cerr << "BadDataError @ " << cur_addr << " (addr 0x" << addr << ", len 0x" << len << "): " << err.explain << "\n";
break;
}
}
}
+210 -15
View File
@@ -8,6 +8,7 @@ import shutil
import subprocess
import sys
import tempfile
from dataclasses import dataclass, field
from pathlib import Path
from typing import List, Dict, Optional, Any, Tuple
@@ -23,12 +24,92 @@ SLEIGH_PATHS = [
"Ghidra/Processors", # Sleigh files
]
# File extensions requiring manual CMake intervention
CPP_EXTENSIONS = {".cc", ".hh"}
SPEC_EXTENSIONS = {".slaspec", ".cspec", ".pspec", ".ldefs", ".opinion", ".sinc"}
# File extensions to ignore (in addition to .java)
IGNORED_EXTENSIONS = {
".java",
".gradle",
".properties",
".txt",
".md",
".html",
".xml",
".png",
".gif",
".jpg",
".ico",
}
# Paths for categorizing files
CPP_PATH = "Ghidra/Features/Decompiler/src/decompile/cpp/"
SPEC_PATH_PREFIX = "Ghidra/Processors/"
# Regex patterns
HEAD_COMMIT_PATTERN = r"set\(ghidra_head_git_tag \"([0-9A-Fa-f]+)\"\)"
VERSION_PATTERN = r"set\(ghidra_head_version \"([0-9]+(\.[0-9]+)*)\"\)"
APP_VERSION_PATTERN = r"application.version=([0-9]+(\.[0-9]+)*)"
@dataclass
class CategorizedChanges:
"""Holds files categorized by change type and file type."""
added_cpp: List[str] = field(default_factory=list)
deleted_cpp: List[str] = field(default_factory=list)
added_spec: List[str] = field(default_factory=list)
deleted_spec: List[str] = field(default_factory=list)
def needs_manual_intervention(self) -> bool:
"""Check if any files need manual intervention."""
return bool(
self.added_cpp or self.deleted_cpp or self.added_spec or self.deleted_spec
)
def format_intervention_details(self) -> str:
"""Format the intervention details as markdown."""
sections = []
if self.added_cpp:
sections.append("### New C++ Source Files")
sections.append(
"These files need to be added to `src/setup-ghidra-source.cmake`:"
)
for f in self.added_cpp:
sections.append(f"- `{f}`")
sections.append("")
if self.deleted_cpp:
sections.append("### Deleted C++ Source Files")
sections.append(
"These files need to be removed from `src/setup-ghidra-source.cmake`:"
)
for f in self.deleted_cpp:
sections.append(f"- `{f}`")
sections.append("")
if self.added_spec:
sections.append("### New Spec Files")
sections.append(
"Review if these files need manual CMake updates (`.slaspec` files "
"are auto-generated; other types may need manual updates):"
)
for f in self.added_spec:
sections.append(f"- `{f}`")
sections.append("")
if self.deleted_spec:
sections.append("### Deleted Spec Files")
sections.append("Verify these files are no longer referenced:")
for f in self.deleted_spec:
sections.append(f"- `{f}`")
sections.append("")
return "\n".join(sections).rstrip()
class GitHelper:
"""Helper class for Git operations"""
@@ -70,6 +151,60 @@ class GitHelper:
except subprocess.CalledProcessError:
return False
@staticmethod
def _should_ignore_file(file_path: str) -> bool:
"""Check if a file should be ignored based on its extension."""
ext = Path(file_path).suffix.lower()
return ext in IGNORED_EXTENSIONS
@staticmethod
def _categorize_file(
status: str, file_path: str, categorized: CategorizedChanges
) -> None:
"""Categorize a file based on its status and type.
Args:
status: Git status code (A, D, M, R, etc.)
file_path: Path to the file
categorized: CategorizedChanges object to update
"""
ext = Path(file_path).suffix.lower()
# Only categorize added (A) or deleted (D) files
if status not in ("A", "D"):
return
# Check if it's a C++ file in the decompiler path
if ext in CPP_EXTENSIONS and CPP_PATH in file_path:
if status == "A":
categorized.added_cpp.append(file_path)
else: # status == "D"
categorized.deleted_cpp.append(file_path)
return
# Check if it's a spec file in the Processors path
if ext in SPEC_EXTENSIONS and file_path.startswith(SPEC_PATH_PREFIX):
if status == "A":
categorized.added_spec.append(file_path)
else: # status == "D"
categorized.deleted_spec.append(file_path)
@staticmethod
def _parse_git_status_line(line: str) -> Tuple[str, str, Optional[str]]:
"""Parse a git status line from --name-status output.
Returns:
Tuple of (status, file_path, new_path_for_rename)
"""
parts = line.split("\t")
status = parts[0]
# Handle rename (R100 or similar)
if status.startswith("R"):
return ("R", parts[1], parts[2])
return (status, parts[1], None)
def get_commit_info(
self, repo_dir: Path, old_commit: str, new_commit: str, paths: List[str]
) -> List[Dict[str, Any]]:
@@ -119,8 +254,21 @@ class GitHelper:
)
commit_files = files_result.stdout.strip().splitlines()
# Filter out Java files
commit_files = [f for f in commit_files if not f.endswith(".java")]
# Filter out ignored files
filtered_files = []
for line in commit_files:
if not line.strip():
continue
status, file_path, new_path = self._parse_git_status_line(line)
if status == "R":
# For renames, check both old and new paths
if not self._should_ignore_file(file_path):
filtered_files.append(f"D\t{file_path}")
if new_path and not self._should_ignore_file(new_path):
filtered_files.append(f"A\t{new_path}")
elif not self._should_ignore_file(file_path):
filtered_files.append(line)
commit_files = filtered_files
if commit_files:
commits.append(
@@ -137,8 +285,12 @@ class GitHelper:
def get_changed_files(
self, repo_dir: Path, old_commit: str, new_commit: str, paths: List[str]
) -> List[str]:
"""Get list of files changed between commits"""
) -> Tuple[List[str], CategorizedChanges]:
"""Get list of files changed between commits and categorize them.
Returns:
Tuple of (filtered_files_list, categorized_changes)
"""
result = self.run(
[
"diff",
@@ -151,11 +303,29 @@ class GitHelper:
capture_output=True,
)
changed_files = result.stdout.strip().splitlines()
# Filter out Java files
changed_files = [f for f in changed_files if not f.endswith(".java")]
raw_lines = result.stdout.strip().splitlines()
filtered_files = []
categorized = CategorizedChanges()
return changed_files
for line in raw_lines:
if not line.strip():
continue
status, file_path, new_path = self._parse_git_status_line(line)
if status == "R":
# For renames, treat as delete old + add new
if not self._should_ignore_file(file_path):
filtered_files.append(f"D\t{file_path}")
self._categorize_file("D", file_path, categorized)
if new_path and not self._should_ignore_file(new_path):
filtered_files.append(f"A\t{new_path}")
self._categorize_file("A", new_path, categorized)
elif not self._should_ignore_file(file_path):
filtered_files.append(line)
self._categorize_file(status, file_path, categorized)
return filtered_files, categorized
class GhidraUpdater:
@@ -205,16 +375,20 @@ class GhidraUpdater:
def display_changes(
self, repo_dir: Path, start_commit: str, end_commit: str
) -> Tuple[List[str], List[Dict[str, Any]]]:
"""Display changes between two commits and return the changed files and commit info"""
# Get changed files
changed_files = self.git.get_changed_files(
) -> Tuple[List[str], List[Dict[str, Any]], CategorizedChanges]:
"""Display changes between two commits and return the changed files and commit info.
Returns:
Tuple of (changed_files, commit_info, categorized_changes)
"""
# Get changed files and categorized changes
changed_files, categorized = self.git.get_changed_files(
repo_dir, start_commit, end_commit, SLEIGH_PATHS
)
if not changed_files:
print("No sleigh files were modified between these commits")
return [], []
return [], [], CategorizedChanges()
# Output changes for logging
num_changed = len(changed_files)
@@ -222,6 +396,18 @@ class GhidraUpdater:
for file in changed_files:
print(f" {file}")
# Display manual intervention warning if needed
if categorized.needs_manual_intervention():
print("\n** Manual intervention may be required **")
if categorized.added_cpp:
print(f" New C++ files: {len(categorized.added_cpp)}")
if categorized.deleted_cpp:
print(f" Deleted C++ files: {len(categorized.deleted_cpp)}")
if categorized.added_spec:
print(f" New spec files: {len(categorized.added_spec)}")
if categorized.deleted_spec:
print(f" Deleted spec files: {len(categorized.deleted_spec)}")
# Get detailed commit info for logging
commit_info = self.git.get_commit_info(
repo_dir, start_commit, end_commit, SLEIGH_PATHS
@@ -269,7 +455,16 @@ class GhidraUpdater:
self.log_github_multiline_output("commit_details", "\n".join(details))
return changed_files, commit_info
# Log manual intervention outputs
if categorized.needs_manual_intervention():
self.log_github_output("needs_manual_intervention", "true")
self.log_github_multiline_output(
"intervention_details", categorized.format_intervention_details()
)
else:
self.log_github_output("needs_manual_intervention", "false")
return changed_files, commit_info, categorized
def update_head_commit(
self, repo_dir: Path, setup_file: Path
@@ -298,7 +493,7 @@ class GhidraUpdater:
print(f"Found new commit: {latest_commit}")
# Check if sleigh files were updated and display changes
changed_files, commit_info = self.display_changes(
changed_files, commit_info, _ = self.display_changes(
repo_dir, current_commit, latest_commit
)
@@ -1,82 +1,22 @@
From 7c6e51dd1234387b98e1ad61d3f88a0565364b28 Mon Sep 17 00:00:00 2001
From 98769d3cd2f417a52559bf68700e2f9f3e7a0e4f Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Mon, 12 Aug 2024 12:02:35 -0400
Subject: [PATCH 1/6] Fix UBSAN errors in decompiler
Subject: [PATCH 1/7] Fix UBSAN errors in decompiler
Co-authored-by: Alex Cameron <asc@tetsuo.sh>
---
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
.../Decompiler/src/decompile/cpp/op.cc | 6 +++++-
.../Decompiler/src/decompile/cpp/opbehavior.cc | 8 +++++++-
.../src/decompile/cpp/pcodecompile.cc | 18 +++++++++++-------
.../Decompiler/src/decompile/cpp/ruleaction.cc | 12 +++++++++---
.../Decompiler/src/decompile/cpp/semantics.cc | 2 ++
.../Decompiler/src/decompile/cpp/semantics.hh | 2 +-
.../src/decompile/cpp/slgh_compile.cc | 2 +-
.../Decompiler/src/decompile/cpp/type.cc | 2 +-
.../src/decompile/unittests/testfloatemu.cc | 2 +-
10 files changed, 44 insertions(+), 18 deletions(-)
5 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
index d78b78731c..caf4b24d15 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
@@ -2868,8 +2868,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
modellist.push_back(mymodel);
}
decoder.closeElement(elemId);
- ((ParamListMerged *)input)->finalize();
- ((ParamListMerged *)output)->finalize();
+ if (input->getType() == ParamList::p_merged) {
+ ((ParamListMerged *)input)->finalize();
+ }
+ if (output->getType() == ParamList::p_merged) {
+ ((ParamListMerged *)output)->finalize();
+ }
}
void ParameterBasic::setTypeLock(bool val)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
index d51460be84..45bf394862 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
@@ -666,7 +666,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
break;
case CPUI_PIECE:
resmask = getIn(0)->getNZMask();
- resmask <<= 8*getIn(1)->getSize();
+ if (8*getIn(1)->getSize() < sizeof(resmask)) {
+ resmask <<= 8*getIn(1)->getSize();
+ } else {
+ resmask = 0;
+ }
resmask |= getIn(1)->getNZMask();
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 aebcfd9103..6c47e6eb15 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
@@ -746,7 +746,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
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 < sizeof(in1)) {
+ res >>= (in2*8);
+ } else {
+ res = 0;
+ }
+ res &= calc_mask(sizeout);
return res;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
index ca9d71ab99..85d4dd281d 100644
index a67a3de849..37ba4930e6 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
@@ -621,8 +621,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
@@ -618,8 +618,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;
@@ -89,7 +29,7 @@ index ca9d71ab99..85d4dd281d 100644
if (vn->getSize().getType()==ConstTpl::real) {
// If we know the size of the bitranged varnode, we can
@@ -726,9 +728,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
@@ -723,9 +725,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
}
}
@@ -99,7 +39,7 @@ index ca9d71ab99..85d4dd281d 100644
if (truncneeded && ((bitoffset % 8)==0)) {
truncshift = bitoffset/8;
bitoffset = 0;
@@ -751,8 +750,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
@@ -748,8 +747,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
appendOp(CPUI_INT_RIGHT,res,bitoffset,4);
if (truncneeded)
appendOp(CPUI_SUBPIECE,res,truncshift,4);
@@ -115,38 +55,8 @@ index ca9d71ab99..85d4dd281d 100644
force_size(res->outvn,ConstTpl(ConstTpl::real,finalsize),*res->ops);
return res;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
index 009570af71..72b2a10503 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
Varnode *outvn = op->getOut();
if (outvn->isPrecisLo()||outvn->isPrecisHi()) return 0; // Don't pull apart double precision object
- uintb consume = calc_mask(newSize) << 8 * minByte;
+ uintb consume = calc_mask(newSize);
+ if (8 * minByte < sizeof(consume)) {
+ consume <<= 8 * minByte;
+ } else {
+ consume = 0;
+ }
consume = ~consume;
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
@@ -7031,8 +7036,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
Varnode *sb = op->getIn(0);
Datatype *sbType = sb->getTypeReadFacing(op);
if (sbType->getMetatype() != TYPE_PTR) return 0;
- TypeSpacebase *sbtype = (TypeSpacebase *)((TypePointer *)sbType)->getPtrTo();
- if (sbtype->getMetatype() != TYPE_SPACEBASE) return 0;
+ Datatype *sbTypePtr = ((TypePointer *)sbType)->getPtrTo();
+ if (sbTypePtr->getMetatype() != TYPE_SPACEBASE) return 0;
+ TypeSpacebase *sbtype = (TypeSpacebase *)sbTypePtr;
Varnode *vn1 = op->getIn(1);
if (!vn1->isConstant()) return 0;
Varnode *outvn = op->getOut();
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
index cd9b9835b1..8a4616c3b9 100644
index 18e2ff8ba1..3bfe29f2ef 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)
@@ -166,7 +76,7 @@ index cd9b9835b1..8a4616c3b9 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 e0b069959d..9117a45c75 100644
index b53b18797d..b2f043e32d 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
@@ -47,7 +47,7 @@ class ConstTpl {
@@ -179,10 +89,10 @@ index e0b069959d..9117a45c75 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 50d85e22ba..9f3b456229 100644
index 75bebffcb0..bf5e7ce681 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
@@ -2164,8 +2164,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
@@ -2323,8 +2323,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
ostringstream msg;
SymbolTree::const_iterator iter;
for(iter=scope->begin();iter!=scope->end();++iter) {
@@ -192,20 +102,6 @@ index 50d85e22ba..9f3b456229 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/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
index fd0ab26fb4..7f654c220b 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
@@ -3728,8 +3728,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
top.submeta = sub; // Search on the incorrect submeta
iter = tree.lower_bound(&top);
while(iter != tree.end()) {
+ if ((*iter)->getMetatype() != TYPE_PTR) break;
TypePointer *ptr = (TypePointer *)*iter;
- if (ptr->getMetatype() != TYPE_PTR) break;
if (ptr->ptrto != base) break;
++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 2571f55f1a..fe40e22b1b 100644
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
@@ -220,5 +116,5 @@ index 2571f55f1a..fe40e22b1b 100644
uintb true_result = ((uintb)(int32_t)f) & 0xffffffff;
uintb encoding = format.getEncoding(f);
--
2.48.1
2.51.1
@@ -1,7 +1,7 @@
From 5e37c51ebc8a3ae0f32a3cb0049aaebafec48d7d Mon Sep 17 00:00:00 2001
From 4e6f277eae589c4f9bceb40337d43384248d272c Mon Sep 17 00:00:00 2001
From: Alex Cameron <asc@tetsuo.sh>
Date: Wed, 3 Aug 2022 20:01:18 +1000
Subject: [PATCH 2/6] Use `stroull` instead of `stroul` to parse address
Subject: [PATCH 2/7] Use `stroull` instead of `stroul` to parse address
offsets
---
@@ -34,5 +34,5 @@ index dbaa2e775f..72927bf379 100644
enddata = (const char *) tmpdata;
if (enddata - s.c_str() == s.size()) { // If no size or offset override
--
2.48.1
2.51.1
@@ -1,7 +1,7 @@
From 2a8f30f31c24ecc7bd499648b97bb8b0c2705b78 Mon Sep 17 00:00:00 2001
From 41eb6be342d29d6ff618d06b391bf33209fe8ade Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Tue, 29 Oct 2024 17:51:09 -0400
Subject: [PATCH 4/6] Ignore floating point test due to compilation differences
Subject: [PATCH 3/7] Ignore floating point test due to compilation differences
This test fails on macOS and Windows. I'm unsure whether it's an OS or
compiler issue.
@@ -24,5 +24,5 @@ index fe40e22b1b..91440e2510 100644
ASSERT_EQUALS(ff.printDecimal(f2, false), "0.33333334");
double f3 = doubleFromRawBits(0x3fd0000000000000);
--
2.48.1
2.51.1
@@ -1,36 +0,0 @@
From 0feb881ef1cbc9aa4639e16914b7d9ed863baadf Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Tue, 29 Oct 2024 15:30:57 -0400
Subject: [PATCH 3/6] Use string resize instead of reserve
assign will fix up the size to hold all of what's copied
---
Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
index 5f5fa0c7b3..4cd77156f2 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
@@ -67,7 +67,6 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
{
if (charsize == 1 && numChars < maximumChars) {
- data.byteData.reserve(size);
data.byteData.assign(buf,buf+size);
}
else {
@@ -77,9 +76,9 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
return;
string resString = s.str();
int4 newSize = resString.size();
- data.byteData.reserve(newSize + 1);
const uint1 *ptr = (const uint1 *)resString.c_str();
data.byteData.assign(ptr,ptr+newSize);
+ data.byteData.resize(newSize + 1, 0);
data.byteData[newSize] = 0; // Make sure there is a null terminator
}
data.isTruncated = (numChars >= maximumChars);
--
2.48.1
@@ -1,7 +1,7 @@
From 04cca72897d9088713a6e2dadb2774ad20ae7703 Mon Sep 17 00:00:00 2001
From 8aa8bf7a146ab43f5b1b27386667af52269720fd Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Wed, 30 Oct 2024 14:26:57 -0400
Subject: [PATCH 5/6] Allow positive or negative NAN in decompiler floating
Subject: [PATCH 4/7] Allow positive or negative NAN in decompiler floating
point test
At least on Apple Silicon, this test reports positive NAN.
@@ -33,5 +33,5 @@ index f8108d3d32..1060a3e193 100644
<stringmatch name="Float print #14" min="1" max="1">double7 = 3.1415926535897933e-06;</stringmatch>
</decompilertest>
--
2.48.1
2.51.1
@@ -1,7 +1,7 @@
From a7dee0fbb1838e4e22a1c970718b84976ffb2932 Mon Sep 17 00:00:00 2001
From d9242056b580cc994661c41344c9ad51b636b0e5 Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Sat, 8 Feb 2025 17:59:57 -0500
Subject: [PATCH 6/6] decompiler: Fix strict weak ordering TypePartialEnum
Subject: [PATCH 5/7] decompiler: Fix strict weak ordering TypePartialEnum
This fixes Windows Debug error encountered in testing where it was
complaining about lack of strict weak ordering.
@@ -10,10 +10,10 @@ complaining about lack of strict weak ordering.
1 file changed, 1 insertion(+)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
index 7f654c220b..3f10c78c2f 100644
index 2d48650e70..4a52633ebf 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
@@ -2300,6 +2300,7 @@ int4 TypePartialEnum::compareDependency(const Datatype &op) const
@@ -2703,6 +2703,7 @@ int4 TypePartialEnum::compareDependency(const Datatype &op) const
{
if (submeta != op.getSubMeta()) return (submeta < op.getSubMeta()) ? -1 : 1;
@@ -22,5 +22,5 @@ index 7f654c220b..3f10c78c2f 100644
if (parent != tp->parent) return (parent < tp->parent) ? -1 : 1; // Compare absolute pointers
if (offset != tp->offset) return (offset < tp->offset) ? -1 : 1;
--
2.48.1
2.51.1
@@ -0,0 +1,29 @@
From f2fdafbd981a441c35ab243bcb74872febd6bbd4 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Feb 2026 02:29:10 +0000
Subject: [PATCH 6/7] decompiler: Fix strict weak ordering PullRecord
When both readOp pointers are null, PullRecord::operator< incorrectly
returns true, violating strict weak ordering (irreflexivity). This is
caught by libc++ debug mode hardening assertions at pullList.sort().
---
Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc
index add61c741b..3e01d2e045 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/bitfield.cc
@@ -1058,7 +1058,7 @@ bool BitFieldPullTransform::PullRecord::operator<(const PullRecord &op2) const
return (readOp->getSeqNum() < op2.readOp->getSeqNum());
}
else if (readOp == (PcodeOp *)0)
- return true;
+ return (op2.readOp != (PcodeOp *)0);
else if (op2.readOp == (PcodeOp *)0)
return false;
return false;
--
2.51.1
@@ -0,0 +1,29 @@
From a44beeb3a2569887c33d2dfd509c0d103bd6c447 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Feb 2026 02:43:17 +0000
Subject: [PATCH 7/7] decompiler: Fix strict weak ordering compareFinalOrder
FlowBlock::compareFinalOrder returns true when both blocks have index 0,
violating strict weak ordering (irreflexivity). This is caught by libc++
debug mode hardening assertions during BlockGraph::orderBlocks sort.
---
Ghidra/Features/Decompiler/src/decompile/cpp/block.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
index bf7103d916..2e495d9c3f 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
@@ -709,7 +709,7 @@ string FlowBlock::typeToName(FlowBlock::block_type bt)
bool FlowBlock::compareFinalOrder(const FlowBlock *bl1,const FlowBlock *bl2)
{
- if (bl1->getIndex() == 0) return true; // Make sure the entry point comes first
+ if (bl1->getIndex() == 0) return (bl2->getIndex() != 0); // Make sure the entry point comes first
if (bl2->getIndex() == 0) return false;
PcodeOp *op1 = bl1->lastOp();
PcodeOp *op2 = bl2->lastOp();
--
2.51.1
@@ -0,0 +1,57 @@
From 8afa7d89a368b358a5493b87804985ed9ac70a2f Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Feb 2026 20:41:10 +0000
Subject: [PATCH] Fix UBSAN signed left shift errors
Cast signed values to unsigned before left shifting to avoid undefined
behavior when the signed value is negative or when the result cannot be
represented in the signed type.
Fixes runtime errors detected by UndefinedBehaviorSanitizer:
- address.hh sign_extend(): left shift of negative value
- address.hh sign_extend(): left shift cannot be represented in type 'intb'
- slghpatexpress.cc LeftShiftExpression: left shift of negative value
---
Ghidra/Features/Decompiler/src/decompile/cpp/address.hh | 2 +-
.../Features/Decompiler/src/decompile/cpp/slghpatexpress.cc | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
index 45144daf3..0e75c68b8 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
@@ -544,7 +544,7 @@ inline intb sign_extend(intb val,int4 bit)
{
int4 sa = 8*sizeof(intb) - (bit+1);
- val = (val << sa) >> sa;
+ val = static_cast<intb>(static_cast<uintb>(val) << sa) >> sa;
return val;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc
index 941097859..93cce378a 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc
@@ -969,7 +969,7 @@ intb LeftShiftExpression::getValue(ParserWalker &walker) const
{
intb leftval = getLeft()->getValue(walker);
intb rightval = getRight()->getValue(walker);
- return leftval << rightval;
+ return static_cast<intb>(static_cast<uintb>(leftval) << rightval);
}
intb LeftShiftExpression::getSubValue(const vector<intb> &replace,int4 &listpos) const
@@ -977,7 +977,7 @@ intb LeftShiftExpression::getSubValue(const vector<intb> &replace,int4 &listpos)
{
intb leftval = getLeft()->getSubValue(replace,listpos); // Must be left first
intb rightval = getRight()->getSubValue(replace,listpos);
- return leftval << rightval;
+ return static_cast<intb>(static_cast<uintb>(leftval) << rightval);
}
void LeftShiftExpression::encode(Encoder &encoder) const
--
2.51.1
@@ -1,77 +1,17 @@
From 54276cc9def6836b02a3f77471b84a7a096eb8ec Mon Sep 17 00:00:00 2001
From 9d1e7b00e8f5dca987038a78fbac400c835a78be Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Mon, 12 Aug 2024 12:02:35 -0400
Subject: [PATCH 1/7] Fix UBSAN errors in decompiler
Subject: [PATCH 1/5] Fix UBSAN errors in decompiler
Co-authored-by: Alex Cameron <asc@tetsuo.sh>
---
.../Decompiler/src/decompile/cpp/fspec.cc | 8 ++++++--
.../Decompiler/src/decompile/cpp/op.cc | 6 +++++-
.../Decompiler/src/decompile/cpp/opbehavior.cc | 8 +++++++-
.../src/decompile/cpp/pcodecompile.cc | 18 +++++++++++-------
.../Decompiler/src/decompile/cpp/ruleaction.cc | 12 +++++++++---
.../Decompiler/src/decompile/cpp/semantics.cc | 2 ++
.../Decompiler/src/decompile/cpp/semantics.hh | 2 +-
.../src/decompile/cpp/slgh_compile.cc | 2 +-
.../Decompiler/src/decompile/cpp/type.cc | 2 +-
.../src/decompile/unittests/testfloatemu.cc | 2 +-
10 files changed, 44 insertions(+), 18 deletions(-)
5 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
index cafce3f7ba..b696fe6879 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
@@ -2893,8 +2893,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
modellist.push_back(mymodel);
}
decoder.closeElement(elemId);
- ((ParamListMerged *)input)->finalize();
- ((ParamListMerged *)output)->finalize();
+ if (input->getType() == ParamList::p_merged) {
+ ((ParamListMerged *)input)->finalize();
+ }
+ if (output->getType() == ParamList::p_merged) {
+ ((ParamListMerged *)output)->finalize();
+ }
}
void ParameterBasic::setTypeLock(bool val)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
index a62ee56fc3..66bcd48db0 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
@@ -666,7 +666,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
break;
case CPUI_PIECE:
resmask = getIn(0)->getNZMask();
- resmask <<= 8*getIn(1)->getSize();
+ if (8*getIn(1)->getSize() < sizeof(resmask)) {
+ resmask <<= 8*getIn(1)->getSize();
+ } else {
+ resmask = 0;
+ }
resmask |= getIn(1)->getNZMask();
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 aebcfd9103..6c47e6eb15 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
@@ -746,7 +746,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
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 < sizeof(in1)) {
+ res >>= (in2*8);
+ } else {
+ res = 0;
+ }
+ res &= calc_mask(sizeout);
return res;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
index ca9d71ab99..85d4dd281d 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
@@ -115,36 +55,6 @@ index ca9d71ab99..85d4dd281d 100644
force_size(res->outvn,ConstTpl(ConstTpl::real,finalsize),*res->ops);
return res;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
index 2b4a9474e5..aa86e740b2 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)
Varnode *outvn = op->getOut();
if (outvn->isPrecisLo()||outvn->isPrecisHi()) return 0; // Don't pull apart double precision object
- uintb consume = calc_mask(newSize) << 8 * minByte;
+ uintb consume = calc_mask(newSize);
+ if (8 * minByte < sizeof(consume)) {
+ consume <<= 8 * minByte;
+ } else {
+ consume = 0;
+ }
consume = ~consume;
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
@@ -7298,8 +7303,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
Varnode *sb = op->getIn(0);
Datatype *sbType = sb->getTypeReadFacing(op);
if (sbType->getMetatype() != TYPE_PTR) return 0;
- TypeSpacebase *sbtype = (TypeSpacebase *)((TypePointer *)sbType)->getPtrTo();
- if (sbtype->getMetatype() != TYPE_SPACEBASE) return 0;
+ Datatype *sbTypePtr = ((TypePointer *)sbType)->getPtrTo();
+ if (sbTypePtr->getMetatype() != TYPE_SPACEBASE) return 0;
+ TypeSpacebase *sbtype = (TypeSpacebase *)sbTypePtr;
Varnode *vn1 = op->getIn(1);
if (!vn1->isConstant()) return 0;
Varnode *outvn = op->getOut();
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
index cd9b9835b1..8a4616c3b9 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
@@ -192,20 +102,6 @@ index 50d85e22ba..9f3b456229 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/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
index 88ca8e36c8..f25b019a4f 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
@@ -3728,8 +3728,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
top.submeta = sub; // Search on the incorrect submeta
iter = tree.lower_bound(&top);
while(iter != tree.end()) {
+ if ((*iter)->getMetatype() != TYPE_PTR) break;
TypePointer *ptr = (TypePointer *)*iter;
- if (ptr->getMetatype() != TYPE_PTR) break;
if (ptr->ptrto != base) break;
++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 2571f55f1a..fe40e22b1b 100644
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
@@ -1,7 +1,7 @@
From 69272257372c594e866b34150c436962be1fa3a4 Mon Sep 17 00:00:00 2001
From 729f72060849dc4f29e89b1c76a980563ffd3e2a 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/7] Use `stroull` instead of `stroul` to parse address
Subject: [PATCH 2/5] Use `stroull` instead of `stroul` to parse address
offsets
---
@@ -1,7 +1,7 @@
From 84384e8d472511bb20cf3ebfa67415dc6293cb80 Mon Sep 17 00:00:00 2001
From 39cfff6f08dad8a85f992e09b3e26716c9173bf7 Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Tue, 29 Oct 2024 17:51:09 -0400
Subject: [PATCH 4/7] Ignore floating point test due to compilation differences
Subject: [PATCH 3/5] Ignore floating point test due to compilation differences
This test fails on macOS and Windows. I'm unsure whether it's an OS or
compiler issue.
@@ -1,36 +0,0 @@
From afef7a58fc2eb987fea303fc06c6d290fe3aa8a5 Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Tue, 29 Oct 2024 15:30:57 -0400
Subject: [PATCH 3/7] Use string resize instead of reserve
assign will fix up the size to hold all of what's copied
---
Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
index 5f5fa0c7b3..4cd77156f2 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
@@ -67,7 +67,6 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
{
if (charsize == 1 && numChars < maximumChars) {
- data.byteData.reserve(size);
data.byteData.assign(buf,buf+size);
}
else {
@@ -77,9 +76,9 @@ void StringManager::assignStringData(StringData &data,const uint1 *buf,int4 size
return;
string resString = s.str();
int4 newSize = resString.size();
- data.byteData.reserve(newSize + 1);
const uint1 *ptr = (const uint1 *)resString.c_str();
data.byteData.assign(ptr,ptr+newSize);
+ data.byteData.resize(newSize + 1, 0);
data.byteData[newSize] = 0; // Make sure there is a null terminator
}
data.isTruncated = (numChars >= maximumChars);
--
2.50.1
@@ -1,7 +1,7 @@
From c5524b18432739e441c4347f2d836d56faa74c77 Mon Sep 17 00:00:00 2001
From 2aa4395ef8874ee9890126f4bdad0d71adf9eacc Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Wed, 30 Oct 2024 14:26:57 -0400
Subject: [PATCH 5/7] Allow positive or negative NAN in decompiler floating
Subject: [PATCH 4/5] Allow positive or negative NAN in decompiler floating
point test
At least on Apple Silicon, this test reports positive NAN.
@@ -1,7 +1,7 @@
From 3330b9d1de3370d933bf7c3063fd4ca3744d1630 Mon Sep 17 00:00:00 2001
From 2a6bd0a0ad7797160db887bba7137b77aa148ba5 Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Sat, 8 Feb 2025 17:59:57 -0500
Subject: [PATCH 6/7] decompiler: Fix strict weak ordering TypePartialEnum
Subject: [PATCH 5/5] decompiler: Fix strict weak ordering TypePartialEnum
This fixes Windows Debug error encountered in testing where it was
complaining about lack of strict weak ordering.
@@ -10,10 +10,10 @@ complaining about lack of strict weak ordering.
1 file changed, 1 insertion(+)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
index f25b019a4f..2f1337a740 100644
index 962c525b7f..7db5024b54 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
@@ -2300,6 +2300,7 @@ int4 TypePartialEnum::compareDependency(const Datatype &op) const
@@ -2303,6 +2303,7 @@ int4 TypePartialEnum::compareDependency(const Datatype &op) const
{
if (submeta != op.getSubMeta()) return (submeta < op.getSubMeta()) ? -1 : 1;
@@ -0,0 +1,29 @@
From c435df4c0dbab80d8ff85e364cea9b59bf7010a1 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Feb 2026 22:22:05 +0000
Subject: [PATCH] decompiler: Fix strict weak ordering compareFinalOrder
FlowBlock::compareFinalOrder returns true when both blocks have index 0,
violating strict weak ordering (irreflexivity). This is caught by libc++
debug mode hardening assertions during BlockGraph::orderBlocks sort.
---
Ghidra/Features/Decompiler/src/decompile/cpp/block.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
index bf7103d91..2e495d9c3 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
@@ -709,7 +709,7 @@ string FlowBlock::typeToName(FlowBlock::block_type bt)
bool FlowBlock::compareFinalOrder(const FlowBlock *bl1,const FlowBlock *bl2)
{
- if (bl1->getIndex() == 0) return true; // Make sure the entry point comes first
+ if (bl1->getIndex() == 0) return (bl2->getIndex() != 0); // Make sure the entry point comes first
if (bl2->getIndex() == 0) return false;
PcodeOp *op1 = bl1->lastOp();
PcodeOp *op2 = bl2->lastOp();
--
2.51.1
@@ -1,23 +0,0 @@
From 4750c32e2390bdabdf77fca54b4c4f6a06585b02 Mon Sep 17 00:00:00 2001
From: Eric Kilmer <eric.d.kilmer@gmail.com>
Date: Fri, 18 Jul 2025 12:01:13 -0400
Subject: [PATCH 7/7] Backport fix for datatests/retstruct.xml tests
---
.../Features/Decompiler/src/decompile/datatests/retstruct.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/datatests/retstruct.xml b/Ghidra/Features/Decompiler/src/decompile/datatests/retstruct.xml
index 4cc656af77..bbccfe65ee 100644
--- a/Ghidra/Features/Decompiler/src/decompile/datatests/retstruct.xml
+++ b/Ghidra/Features/Decompiler/src/decompile/datatests/retstruct.xml
@@ -1,5 +1,5 @@
<decompilertest>
-<binaryimage arch="x86:LE:32:default:gcc">
+<binaryimage arch="x86:LE:32:default:win">
<!--
Example function returning a structure stored across multiple registers
-->
--
2.50.1
@@ -0,0 +1,57 @@
From 8afa7d89a368b358a5493b87804985ed9ac70a2f Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Feb 2026 20:41:10 +0000
Subject: [PATCH] Fix UBSAN signed left shift errors
Cast signed values to unsigned before left shifting to avoid undefined
behavior when the signed value is negative or when the result cannot be
represented in the signed type.
Fixes runtime errors detected by UndefinedBehaviorSanitizer:
- address.hh sign_extend(): left shift of negative value
- address.hh sign_extend(): left shift cannot be represented in type 'intb'
- slghpatexpress.cc LeftShiftExpression: left shift of negative value
---
Ghidra/Features/Decompiler/src/decompile/cpp/address.hh | 2 +-
.../Features/Decompiler/src/decompile/cpp/slghpatexpress.cc | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
index 45144daf3..0e75c68b8 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.hh
@@ -544,7 +544,7 @@ inline intb sign_extend(intb val,int4 bit)
{
int4 sa = 8*sizeof(intb) - (bit+1);
- val = (val << sa) >> sa;
+ val = static_cast<intb>(static_cast<uintb>(val) << sa) >> sa;
return val;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc
index 941097859..93cce378a 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghpatexpress.cc
@@ -969,7 +969,7 @@ intb LeftShiftExpression::getValue(ParserWalker &walker) const
{
intb leftval = getLeft()->getValue(walker);
intb rightval = getRight()->getValue(walker);
- return leftval << rightval;
+ return static_cast<intb>(static_cast<uintb>(leftval) << rightval);
}
intb LeftShiftExpression::getSubValue(const vector<intb> &replace,int4 &listpos) const
@@ -977,7 +977,7 @@ intb LeftShiftExpression::getSubValue(const vector<intb> &replace,int4 &listpos)
{
intb leftval = getLeft()->getSubValue(replace,listpos); // Must be left first
intb rightval = getRight()->getSubValue(replace,listpos);
- return leftval << rightval;
+ return static_cast<intb>(static_cast<uintb>(leftval) << rightval);
}
void LeftShiftExpression::encode(Encoder &encoder) const
--
2.51.1
+20 -16
View File
@@ -22,7 +22,7 @@ set_property(CACHE sleigh_RELEASE_TYPE PROPERTY STRINGS "stable" "HEAD")
find_package(Git REQUIRED)
# Ghidra pinned stable version commit
set(ghidra_version "11.4")
set(ghidra_version "12.0.4")
set(ghidra_git_tag "Ghidra_${ghidra_version}_build")
set(ghidra_shallow TRUE)
@@ -40,20 +40,20 @@ set(ghidra_patches
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0001-Fix-UBSAN-errors-in-decompiler.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0003-Use-string-resize-instead-of-reserve.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0004-Ignore-floating-point-test-due-to-compilation-differ.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0005-Allow-positive-or-negative-NAN-in-decompiler-floatin.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0006-decompiler-Fix-strict-weak-ordering-TypePartialEnum.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0007-Backport-fix-for-datatests-retstruct.xml-tests.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0003-Ignore-floating-point-test-due-to-compilation-differ.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0004-Allow-positive-or-negative-NAN-in-decompiler-floatin.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0005-decompiler-Fix-strict-weak-ordering-TypePartialEnum.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0006-decompiler-Fix-strict-weak-ordering-compareFinalOrde.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/stable/0007-Fix-UBSAN-signed-left-shift-errors.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 "11.5")
set(ghidra_head_version "12.1")
set(ghidra_version "${ghidra_head_version}")
set(ghidra_head_git_tag "8c48d9f1168275a039d7803267399bf418d827dd")
set(ghidra_head_git_tag "fc73f70b9cb4523329b1629b2753f87ae734521d")
set(ghidra_git_tag "${ghidra_head_git_tag}")
set(ghidra_shallow FALSE)
set(ghidra_patches
@@ -62,10 +62,12 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Fix-UBSAN-errors-in-decompiler.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-Use-string-resize-instead-of-reserve.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0004-Ignore-floating-point-test-due-to-compilation-differ.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0005-Allow-positive-or-negative-NAN-in-decompiler-floatin.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0006-decompiler-Fix-strict-weak-ordering-TypePartialEnum.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-Ignore-floating-point-test-due-to-compilation-differ.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0004-Allow-positive-or-negative-NAN-in-decompiler-floatin.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0005-decompiler-Fix-strict-weak-ordering-TypePartialEnum.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0006-decompiler-Fix-strict-weak-ordering-PullRecord.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0007-decompiler-Fix-strict-weak-ordering-compareFinalOrde.patch"
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0008-Fix-UBSAN-signed-left-shift-errors.patch"
)
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
else()
@@ -175,11 +177,13 @@ set(sleigh_deccore_source_list
"${library_root}/signature.cc"
"${library_root}/multiprecision.cc"
"${library_root}/constseq.cc"
"${library_root}/expression.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
"${library_root}/bitfield.cc"
)
endif()
set(sleigh_extra_source_list
"${library_root}/callgraph.cc"
+5
View File
@@ -76,6 +76,8 @@ set(spec_file_list
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MIPS/data/languages/mips32le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MIPS/data/languages/mips64be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MIPS/data/languages/mips64le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/NDS32/data/languages/nds32be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/NDS32/data/languages/nds32le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PA-RISC/data/languages/pa-risc32be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PIC/data/languages/PIC24E.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PIC/data/languages/PIC24F.slaspec"
@@ -108,6 +110,7 @@ set(spec_file_list
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_64_isa_le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_64_isa_vle_be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_64_le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/RISCV/data/languages/andestar_v5.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/RISCV/data/languages/riscv.ilp32d.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/RISCV/data/languages/riscv.lp64d.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Sparc/data/languages/SparcV9_32.slaspec"
@@ -121,6 +124,7 @@ set(spec_file_list
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/TI_MSP430/data/languages/TI_MSP430X.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_be_harvard.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_be_harvard_rev.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_be_posStack.slaspec"
@@ -136,6 +140,7 @@ set(spec_file_list
"${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_be.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"
+5
View File
@@ -76,6 +76,8 @@ set(spec_file_list
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MIPS/data/languages/mips32le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MIPS/data/languages/mips64be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/MIPS/data/languages/mips64le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/NDS32/data/languages/nds32be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/NDS32/data/languages/nds32le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PA-RISC/data/languages/pa-risc32be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PIC/data/languages/PIC24E.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PIC/data/languages/PIC24F.slaspec"
@@ -108,6 +110,7 @@ set(spec_file_list
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_64_isa_le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_64_isa_vle_be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/PowerPC/data/languages/ppc_64_le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/RISCV/data/languages/andestar_v5.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/RISCV/data/languages/riscv.ilp32d.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/RISCV/data/languages/riscv.lp64d.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Sparc/data/languages/SparcV9_32.slaspec"
@@ -121,6 +124,7 @@ set(spec_file_list
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/TI_MSP430/data/languages/TI_MSP430X.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_be_harvard.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_be_harvard_rev.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy64_le.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_be.slaspec"
"${ghidrasource_SOURCE_DIR}/Ghidra/Processors/Toy/data/languages/toy_be_posStack.slaspec"
@@ -136,6 +140,7 @@ set(spec_file_list
"${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_be.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"
+11 -11
View File
@@ -10,7 +10,7 @@
# Tests from ghidra repo
#
add_executable(sleigh_ghidra_test
add_executable(sleigh_decomp_test
${sleigh_core_source_list}
${sleigh_deccore_source_list}
${sleigh_source_list}
@@ -27,31 +27,31 @@ add_executable(sleigh_ghidra_test
)
# if(sleigh_RELEASE_IS_HEAD)
# target_sources(sleigh_ghidra_test PRIVATE
# target_sources(sleigh_decomp_test PRIVATE
# )
# endif()
target_compile_features(sleigh_ghidra_test PRIVATE cxx_std_11)
target_include_directories(sleigh_ghidra_test PRIVATE "${library_root}")
target_compile_features(sleigh_decomp_test PRIVATE cxx_std_11)
target_include_directories(sleigh_decomp_test PRIVATE "${library_root}")
include(CheckIncludeFileCXX)
check_include_file_cxx(termios.h HAVE_TERMIOS_H)
if(HAVE_TERMIOS_H)
target_compile_definitions(sleigh_ghidra_test PRIVATE
target_compile_definitions(sleigh_decomp_test PRIVATE
__TERMINAL__
)
endif()
sleigh_add_optional_defines(sleigh_ghidra_test PRIVATE)
sleigh_add_optional_defines(sleigh_decomp_test PRIVATE)
target_link_libraries(sleigh_ghidra_test PRIVATE ZLIB::ZLIB)
target_link_libraries(sleigh_decomp_test PRIVATE ZLIB::ZLIB)
add_test(
NAME sleigh_ghidra_unittest
COMMAND sleigh_ghidra_test -sleighpath "${PROJECT_BINARY_DIR}" unittests
NAME sleigh_decomp_unittest
COMMAND sleigh_decomp_test -sleighpath "${PROJECT_BINARY_DIR}" unittests
)
add_test(
NAME sleigh_ghidra_datatest
COMMAND sleigh_ghidra_test -sleighpath "${PROJECT_BINARY_DIR}"
NAME sleigh_decomp_datatest
COMMAND sleigh_decomp_test -sleighpath "${PROJECT_BINARY_DIR}"
-path "${library_root}/../datatests"
datatests
)