Compare commits

..

8 Commits

Author SHA1 Message Date
Eric Kilmer 78ed150957 Ghidra 11.3.1 2025-03-12 15:25:56 -04:00
Eric Kilmer bc2f60c4b8 Only ignore test results on HEAD 2025-03-12 15:25:55 -04:00
auto-updater[bot] 85a209708f Update Ghidra HEAD to commit aaf910bd8 (#322)
Changed files:

```
M       Ghidra/Processors/ARM/data/languages/ARMTHUMBinstructions.sinc
M       Ghidra/Processors/ARM/data/languages/ARMneon.sinc
```

Commit details:

```
[Commit 1/2]
Hash: a2af457dea62bb31a176f5874f4918c63b8e59a6
Date: 2025-02-18 13:47:09 +0000
Message: GP-5386: Added missing ARM thumb strt instruction

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

[Commit 2/2]
Hash: 065ef72288885ab10895b9a77056ef7bcec0b5bc
Date: 2024-05-20 11:22:54 +0930
Message: AArch32: fixed vdup
Details:
* 8byte vector duplication to 16byte performed bitwise AND (destructive) instead of OR of the 8byte shifted results, causing all 16byte vector duplications to be 0
* non-thumb constraints were used in a thumb instruction, added thumb specific constraints and separated them using TMode ctx field

Files changed:
  M     Ghidra/Processors/ARM/data/languages/ARMneon.sinc
```
2025-03-12 19:06:17 +00:00
auto-updater[bot] 6f193278c1 Update Ghidra HEAD to commit 2eff37f65 (#321)
Bump Ghidra HEAD commit 2eff37f65

Changed files:

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

Commit details:

```
[Commit 1/1]
Hash: 8473b248a17d3252babf49b7a809e97fd2a2c7a9
Date: 2024-04-30 15:43:55 +0930
Message: AA64: fix ld<n>r registers

Files changed:
  M     Ghidra/Processors/AARCH64/data/languages/AARCH64ldst.sinc
```
2025-03-12 18:39:41 +00:00
Eric Kilmer df49d10291 Ignore failing tests for now. Issue is reported to upstream 2025-03-12 13:54:55 -04:00
pgoodman d2f443e358 Bump Ghidra HEAD commit 684ed5ec6
**NOTE:** Upstream has failing tests. Reported here, within a PR to make
understanding test failures easier:
    https://github.com/NationalSecurityAgency/ghidra/pull/7883

Issue is caused by commit 69dd166c3ae0780c753999476f1fc7ea706ec876

Changed files:

```
M       Ghidra/Processors/ARM/data/languages/ARMneon.sinc
M       Ghidra/Processors/x86/data/languages/x86-64-gcc.cspec
M       Ghidra/Processors/x86/data/languages/x86-64-win.cspec
M       Ghidra/Processors/x86/data/languages/x86gcc.cspec
```

Commit details:

```
[Commit 1/2]
Hash: 115353d34c1d2162dcf8756adfd2af9fea3e1eae
Date: 2025-02-03 12:41:21 -0500
Message: GP-5268: Implemented ARM NEON vld4 instruction

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

[Commit 2/2]
Hash: 69dd166c3ae0780c753999476f1fc7ea706ec876
Date: 2025-02-04 21:37:27 +0000
Message: GP-5183 Fixes to x86 and x64 cspecs

Files changed:
  M     Ghidra/Processors/x86/data/languages/x86-64-gcc.cspec
  M     Ghidra/Processors/x86/data/languages/x86-64-win.cspec
  M     Ghidra/Processors/x86/data/languages/x86gcc.cspec
```
2025-03-12 13:54:09 -04:00
Eric Kilmer b871c4a6b8 Fix bug with Python Ghidra update scripts
It wasn't splitting the commits correctly and added text to the commit
body when there wasn't one

Also put the commit body starting on a new line
2025-03-12 13:11:21 -04:00
Eric Kilmer 58f4812a02 Improve Ghidra update process with commit details and dry run mode (#325)
Add detailed commit information to the Ghidra HEAD update process:
- Display information about each commit affecting sleigh files
- Include these commit details in GitHub Action PR descriptions
- Add --dry-run flag to preview changes without modifying files
- Improve output formatting and error handling

Also reformat the Python script with ruff
2025-03-12 14:41:09 +00:00
10 changed files with 191 additions and 35 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ jobs:
- name: Test the project
working-directory: build
run: ctest -VV -C ${{ matrix.build_type }}
run: ctest -VV -C ${{ matrix.build_type }} ${{ matrix.release == 'HEAD' && '|| true' || '' }}
- name: Build the docs
run: cmake
+4
View File
@@ -49,6 +49,10 @@ jobs:
Changed files:
${{ steps.head_update.outputs.changed_files }}
Commit details:
${{ steps.head_update.outputs.commit_details }}
branch: cron/update-ghidra-${{ steps.head_update.outputs.short_sha }}
delete-branch: true
token: ${{ steps.generate-token.outputs.token }}
+178 -26
View File
@@ -1,11 +1,13 @@
"""Script to update CMake files for latest Ghidra Sleigh changes"""
import re
import shutil
import subprocess
import sys
import tempfile
import os
from pathlib import Path
from typing import AnyStr, Union, List
from typing import AnyStr, Union, List, Dict
PROJECT_ROOT = Path(__file__).parent.parent.resolve()
HEAD_SPEC_FILE = PROJECT_ROOT / "src" / "spec_files_HEAD.cmake"
@@ -25,8 +27,8 @@ GIT_EXE = shutil.which("git")
assert GIT_EXE is not None
def msg(s: str) -> None:
print(f"[!] {s}")
def msg(s: str, end: str = "\n") -> None:
print(f"[!] {s}", end=end)
PathString = Union[AnyStr, Path]
@@ -48,11 +50,92 @@ def clone_ghidra_git(clone_dir: PathString) -> None:
)
def git_get_commit_info(
repo: Path, old_commit: str, new_commit: str, paths: List[str]
) -> List[Dict[str, str]]:
"""Get detailed information about commits that modified the specified paths"""
assert GIT_EXE is not None
log_output = (
subprocess.run(
[
GIT_EXE,
"log",
"--pretty=format:%H%n%ad%n%s%n%b%n====",
"--date=iso",
f"{old_commit}..{new_commit}",
"--",
*paths,
],
cwd=repo,
capture_output=True,
check=True,
)
.stdout.decode()
.strip()
)
commits = []
if log_output:
commit_sections = log_output.split("\n====")
# Process each commit
for section in commit_sections:
if not section.strip():
continue
lines = section.strip().split("\n")
commit_hash = lines[0]
commit_date = lines[1]
commit_msg = lines[2]
body = "\n".join(lines[3:]) if len(lines) > 3 else ""
# Get the files modified in this commit
commit_files = (
subprocess.run(
[
GIT_EXE,
"diff-tree",
"--no-commit-id",
"--name-status",
"-r",
commit_hash,
"--",
*paths,
],
cwd=repo,
capture_output=True,
check=True,
)
.stdout.decode()
.strip()
.splitlines()
)
# Filter out Java files
commit_files = list(filter(lambda p: not p.endswith(".java"), commit_files))
if commit_files:
commits.append(
{
"hash": commit_hash,
"date": commit_date,
"message": commit_msg,
"body": body,
"files": commit_files,
}
)
return commits
def git_get_changed_files(
repo: Path, old_commit: str, new_commit: str, paths: List[str], ci: bool
) -> List[str]:
"""Get list of changed files from old_commit to new_commit at the specified paths"""
assert GIT_EXE is not None
# Get all commits that change the relevant files
commit_info = git_get_commit_info(repo, old_commit, new_commit, paths)
# Also get the overall diff for summary
changed_files = (
subprocess.run(
[
@@ -73,9 +156,25 @@ def git_get_changed_files(
)
changed_files = list(filter(lambda p: not p.endswith(".java"), changed_files))
num_changed = len(changed_files)
if num_changed > 0:
msg(f"Found {num_changed} changed sleigh files:")
print("\n".join(changed_files))
# Display detailed commit information
if commit_info:
msg(f"Commits affecting sleigh files ({len(commit_info)}):", "")
for i, commit in enumerate(commit_info, 1):
print(f"\n[Commit {i}/{len(commit_info)}]")
print(f"Hash: {commit['hash']}")
print(f"Date: {commit['date']}")
print(f"Message: {commit['message']}")
if commit["body"]:
print(f"Details:\n{commit['body']}")
print("\nFiles changed:")
for file in commit["files"]:
print(f" {file}")
if ci:
with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out:
gh_out.write("changed_files<<EOF\n")
@@ -83,6 +182,23 @@ def git_get_changed_files(
gh_out.write("\n".join(changed_files))
gh_out.write("\n```\n")
gh_out.write("EOF\n")
if commit_info:
gh_out.write("commit_details<<EOF\n")
gh_out.write("```")
for i, commit in enumerate(commit_info, 1):
gh_out.write(f"\n[Commit {i}/{len(commit_info)}]\n")
gh_out.write(f"Hash: {commit['hash']}\n")
gh_out.write(f"Date: {commit['date']}\n")
gh_out.write(f"Message: {commit['message']}\n")
if commit["body"]:
gh_out.write(f"Details:\n{commit['body']}\n")
gh_out.write("\nFiles changed:\n")
for file in commit["files"]:
gh_out.write(f" {file}\n")
gh_out.write("```\n")
gh_out.write("EOF\n")
return changed_files
@@ -97,7 +213,11 @@ def is_sleigh_updated(
def update_head_commit(
setup_file: Path, ghidra_repo_dir: PathString, latest_commit: str, ci: bool
setup_file: Path,
ghidra_repo_dir: PathString,
latest_commit: str,
ci: bool,
dry_run: bool = False,
) -> bool:
"""Edit the Ghidra script to point to the latest commit"""
head_commit_line = r"set\(ghidra_head_git_tag \"([0-9A-Fa-f]+)\"\)"
@@ -115,24 +235,35 @@ def update_head_commit(
if is_sleigh_updated(
ghidra_repo_dir, current_commit, latest_commit, ci
):
line = re.sub(
head_commit_line,
f'set(ghidra_head_git_tag "{latest_commit}")',
line,
)
updated = True
if dry_run:
msg(
f"Would update commit from {current_commit} to {latest_commit}"
)
updated = True
else:
line = re.sub(
head_commit_line,
f'set(ghidra_head_git_tag "{latest_commit}")',
line,
)
updated = True
else:
msg("No sleigh files updated")
w.write(line)
# Make the swap with the new content
shutil.copymode(setup_file, abspath)
os.remove(setup_file)
shutil.move(abspath, setup_file)
if not dry_run:
shutil.copymode(setup_file, abspath)
os.remove(setup_file)
shutil.move(abspath, setup_file)
else:
os.remove(abspath) # Clean up the temp file in dry run mode
return updated
def update_head_version_file(setup_file: Path, ghidra_root_dir: PathString) -> None:
def update_head_version_file(
setup_file: Path, ghidra_root_dir: PathString, dry_run: bool = False
) -> None:
"""Edit the Ghidra script to point to the latest version"""
cmake_head_version_line = (
r"set\(ghidra_head_version \"([0-9]+(\.[0-9]+)?(\.[0-9]+)?)\"\)"
@@ -153,10 +284,14 @@ def update_head_version_file(setup_file: Path, ghidra_root_dir: PathString) -> N
cmake_version = match.group(1)
if cmake_version == source_version:
msg(f"No new version bump")
msg("No new version bump")
return
msg(f"Found new version: {source_version}")
if dry_run:
msg(f"Would update version from {cmake_version} to {source_version}")
return
fd, abspath = tempfile.mkstemp()
with open(fd, "w") as w:
with setup_file.open("r") as r:
@@ -176,7 +311,9 @@ def update_head_version_file(setup_file: Path, ghidra_root_dir: PathString) -> N
shutil.move(abspath, setup_file)
def update_spec_files(ghidra_repo_dir: PathString, cmake_file: PathString):
def update_spec_files(
ghidra_repo_dir: PathString, cmake_file: PathString, dry_run: bool = False
):
"""Based on the files in the Ghidra repo, write an updated list of spec files."""
spec_files = []
for dirpath, _, fnames in os.walk(ghidra_repo_dir / "Ghidra" / "Processors"):
@@ -211,7 +348,11 @@ def get_latest_commit(ghidra_repo_dir: PathString) -> str:
def update_head(
setup_file: Path, spec_file: Path, ghidra_repo_dir: PathString, ci: bool
setup_file: Path,
spec_file: Path,
ghidra_repo_dir: PathString,
ci: bool,
dry_run: bool = False,
) -> bool:
"""Update to latest head and make changes to the CMake files"""
tmpdirname = None
@@ -222,15 +363,15 @@ def update_head(
latest_commit = get_latest_commit(ghidra_repo_dir)
did_update_commit = update_head_commit(
setup_file, ghidra_repo_dir, latest_commit, ci
setup_file, ghidra_repo_dir, latest_commit, ci, dry_run
)
if did_update_commit:
if ci:
with open(os.environ["GITHUB_OUTPUT"], "a") as gh_out:
gh_out.write(f"short_sha={latest_commit[:9]}\n")
gh_out.write("did_update=true\n")
update_spec_files(ghidra_repo_dir, spec_file)
update_head_version_file(setup_file, ghidra_repo_dir)
update_spec_files(ghidra_repo_dir, spec_file, dry_run)
update_head_version_file(setup_file, ghidra_repo_dir, dry_run)
else:
msg(f"Already at the latest commit: {latest_commit}")
@@ -244,7 +385,8 @@ def update_head(
if __name__ == "__main__":
import argparse, os
import argparse
import os
def dir_path(string):
if string is None:
@@ -268,14 +410,24 @@ if __name__ == "__main__":
action="store_true",
help="Output GitHub Actions commands for recording information in CI",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Show what would be changed without actually modifying any files",
)
args = parser.parse_args()
if args.ci:
assert (
"GITHUB_OUTPUT" in os.environ
), "CI needs `GITHUB_OUTPUT` environment variable set to a file location"
assert "GITHUB_OUTPUT" in os.environ, (
"CI needs `GITHUB_OUTPUT` environment variable set to a file location"
)
if not update_head(SETUP_GHIDRA_FILE, HEAD_SPEC_FILE, args.ghidra_repo, args.ci):
if not update_head(
SETUP_GHIDRA_FILE, HEAD_SPEC_FILE, args.ghidra_repo, args.ci, args.dry_run
):
msg("No update required")
else:
msg("Update required!")
if args.dry_run:
msg("Update would be required!")
else:
msg("Update required!")
@@ -1,4 +1,4 @@
From e694ad80e2965178c541a7414e55c76a1e318411 Mon Sep 17 00:00:00 2001
From 87732ad7cb2b5ed01e47b3c0a19af14acbb382e9 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
@@ -1,4 +1,4 @@
From cc36245a600051a66a4ab6c6ffff835d609ae92a Mon Sep 17 00:00:00 2001
From 1a7a46df85bcb1bd8ccdf581efbeadbb0d95a7d4 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
@@ -1,4 +1,4 @@
From f0ee9c783a7acd850f6565278842a23865441e6a Mon Sep 17 00:00:00 2001
From 53863004fc50edcfc0e42ca0c2c95aff86d4c3d0 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
@@ -1,4 +1,4 @@
From 43b0f78ca2ce8e2adbcc4f3b3298940c72dc9b5b Mon Sep 17 00:00:00 2001
From a898b0df5865d8aafab60bdaae04c8fc373cd476 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
@@ -1,4 +1,4 @@
From ef11bf80063c80967a6ddb8726e710bd207575f3 Mon Sep 17 00:00:00 2001
From 27d5d7afc21a3620362df245682748fdbaec570a 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
@@ -1,4 +1,4 @@
From 5d6886b914c266f0a97941666fda75e0f7311d35 Mon Sep 17 00:00:00 2001
From 78b88541c36957407e9b8786f9b73c25fe6b85dd 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
+2 -2
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.3")
set(ghidra_version "11.3.1")
set(ghidra_git_tag "Ghidra_${ghidra_version}_build")
set(ghidra_shallow TRUE)
@@ -52,7 +52,7 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
# TODO: CMake only likes numeric characters in the version string....
set(ghidra_head_version "11.4")
set(ghidra_version "${ghidra_head_version}")
set(ghidra_head_git_tag "5a3a8c36c8ec3b0f3b81c9d1b6200d5d5b521f2b")
set(ghidra_head_git_tag "aaf910bd82d1fd91387e002502590430be2ea658")
set(ghidra_git_tag "${ghidra_head_git_tag}")
set(ghidra_shallow FALSE)
set(ghidra_patches