mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| efe3b7dcbd | |||
| d4b0316955 | |||
| 86f39ba60f | |||
| 0dd2d21bdc | |||
| d02e760030 | |||
| 42d2ee7457 | |||
| 0664b5c545 | |||
| cd6078bb22 | |||
| fc49d2340e | |||
| 1df5e051d3 | |||
| edc5fabd3a | |||
| 9316045354 | |||
| ec98f45ecf | |||
| e4b6ddb926 | |||
| 9248e9114b | |||
| a020faccb5 | |||
| d74e8e9414 | |||
| f8229f609d | |||
| 4edfcef82e | |||
| 26c6b01b1f | |||
| 563adb57e9 | |||
| 127d913bc9 | |||
| 0ea6de2744 | |||
| 27072f1bca | |||
| 185e34f5e7 | |||
| 1ea24c8b8d | |||
| 572082b008 | |||
| a5496ad829 | |||
| 604cd282a6 | |||
| 14c9c408ca | |||
| 21ed4b78e5 | |||
| d2c42d19ed | |||
| 97f7fd1faf | |||
| cf1dc2bb79 | |||
| a732884632 | |||
| 800a597ff6 | |||
| adcbfb179f | |||
| 64377586f8 | |||
| 19fcb07d42 | |||
| 24e7a85db6 | |||
| 6b8620a8cf | |||
| f398228901 | |||
| d0d9bf5a67 | |||
| 632fa35e36 | |||
| e925db971d | |||
| e590133fc7 | |||
| 760a315270 | |||
| bf13fdebba | |||
| a49bbcc9cf | |||
| 1f41ff02e6 | |||
| 060f42d28c |
@@ -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
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
release: [stable, HEAD]
|
||||
|
||||
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 +67,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 +113,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 +214,13 @@ jobs:
|
||||
# DEB Package
|
||||
- name: Upload the DEB package artifact (RelWithDebInfo only)
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ env.DEB_PACKAGE_NAME }}
|
||||
path: ${{ env.DEB_PACKAGE_PATH }}
|
||||
|
||||
- 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 +228,12 @@ jobs:
|
||||
# RPM Package
|
||||
- name: Upload the RPM package artifact (RelWithDebInfo only)
|
||||
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ env.RPM_PACKAGE_NAME }}
|
||||
path: ${{ env.RPM_PACKAGE_PATH }}
|
||||
- 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,13 +241,13 @@ 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@v6
|
||||
with:
|
||||
name: ${{ env.TGZ_PACKAGE_NAME }}
|
||||
path: ${{ env.TGZ_PACKAGE_PATH }}
|
||||
|
||||
- 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 }}
|
||||
|
||||
@@ -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,79 @@ 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 }}
|
||||
|
||||
- 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
|
||||
PR_BODY="Changed files:
|
||||
|
||||
${{ steps.head_update.outputs.changed_files }}
|
||||
|
||||
Commit details:
|
||||
|
||||
${{ steps.head_update.outputs.commit_details }}"
|
||||
|
||||
# Add intervention warning if needed
|
||||
if [ "${{ steps.head_update.outputs.needs_manual_intervention }}" = "true" ]; then
|
||||
PR_BODY="## :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
|
||||
|
||||
---
|
||||
|
||||
$PR_BODY"
|
||||
fi
|
||||
|
||||
# Create PR
|
||||
gh pr create \
|
||||
--title "Update Ghidra HEAD to commit ${{ steps.head_update.outputs.short_sha }}" \
|
||||
--body "$PR_BODY"
|
||||
|
||||
@@ -146,6 +146,7 @@ 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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
@@ -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,77 +1,17 @@
|
||||
From 7c6e51dd1234387b98e1ad61d3f88a0565364b28 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/6] 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 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
|
||||
--- 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 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
|
||||
--- 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 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.50.1
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 5e37c51ebc8a3ae0f32a3cb0049aaebafec48d7d 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/6] Use `stroull` instead of `stroul` to parse address
|
||||
Subject: [PATCH 2/5] 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.50.1
|
||||
|
||||
|
||||
+2
-2
@@ -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 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
|
||||
|
||||
+2
-2
@@ -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.
|
||||
+4
-4
@@ -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;
|
||||
@@ -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
|
||||
|
||||
---
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
From 2a8f30f31c24ecc7bd499648b97bb8b0c2705b78 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/6] 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.
|
||||
@@ -24,5 +24,5 @@ index fe40e22b1b..91440e2510 100644
|
||||
ASSERT_EQUALS(ff.printDecimal(f2, false), "0.33333334");
|
||||
double f3 = doubleFromRawBits(0x3fd0000000000000);
|
||||
--
|
||||
2.48.1
|
||||
2.50.1
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
From 04cca72897d9088713a6e2dadb2774ad20ae7703 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/6] 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.
|
||||
@@ -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.50.1
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
From a7dee0fbb1838e4e22a1c970718b84976ffb2932 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/6] 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 7f654c220b..3f10c78c2f 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;
|
||||
@@ -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.50.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
|
||||
|
||||
@@ -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.2")
|
||||
set(ghidra_git_tag "Ghidra_${ghidra_version}_build")
|
||||
set(ghidra_shallow TRUE)
|
||||
|
||||
@@ -40,20 +40,18 @@ 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"
|
||||
)
|
||||
|
||||
# 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 "ccbdd4f66eb92186b695b0f143b90e5ce714bf85")
|
||||
set(ghidra_git_tag "${ghidra_head_git_tag}")
|
||||
set(ghidra_shallow FALSE)
|
||||
set(ghidra_patches
|
||||
@@ -62,10 +60,9 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-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"
|
||||
)
|
||||
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
|
||||
else()
|
||||
@@ -175,6 +172,7 @@ 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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user