mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Update Ghidra HEAD to commit b211a07b5 and patch (#415)
* Bump Ghidra HEAD commit b211a07b5 Changed files: ``` M Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l ``` Commit details: ``` [Commit 1/1] Hash: 827ebe6a0529b6ed8c52b7186be43b55c57da48b Date: 2026-03-20 21:34:41 +0000 Message: GP-6608 Use std::stoul to unify to do all integer parsing Files changed: M Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc M Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l ``` * Patch Ghidra HEAD scan_number to use std::stoull for MSVC Upstream GP-6608 (Ghidra 827ebe6a0) replaced the hand-rolled integer parser in slghscan.l with std::stoul. std::stoul returns unsigned long, which is 64 bits on LP64 (Linux/macOS) but 32 bits on MSVC (LLP64), so any .slaspec integer literal wider than 0xFFFFFFFF throws out_of_range and sleigh rejects the spec. This broke the Windows HEAD CI job on the b211a07b5 bump (68000/PowerPC/Loongarch/coldfire/avr32a specs all have 64-bit immediates). Swap to std::stoull, which returns unsigned long long (64 bits on all platforms) and matches the uintb target in scan_number. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Eric Kilmer <eric.kilmer@trailofbits.com>
This commit is contained in:
committed by
GitHub
parent
8852ca2b09
commit
121c65a08b
@@ -0,0 +1,49 @@
|
||||
From eee198c1cc17bfc8b10609ddc8e03e254d0bac9a Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.kilmer@trailofbits.com>
|
||||
Date: Tue, 21 Apr 2026 10:32:17 -0400
|
||||
Subject: [PATCH] Use std::stoull instead of std::stoul in scan_number for MSVC
|
||||
|
||||
std::stoul returns `unsigned long`, which is 32 bits on MSVC (LLP64) but 64
|
||||
bits on POSIX LP64. scan_number assigns the result into a `uintb` (uint64_t),
|
||||
so on Windows any integer literal in a .slaspec file that exceeds 0xFFFFFFFF
|
||||
throws std::out_of_range, the catch-all returns BADINTEGER, and the sleigh
|
||||
compiler rejects the spec. Affected specs include 68000/PowerPC/Loongarch/
|
||||
coldfire/avr32a and others that use 64-bit immediates.
|
||||
|
||||
std::stoull returns `unsigned long long` (64 bits on all platforms), matching
|
||||
the uintb target and the pre-GP-6608 behavior. This mirrors the earlier fix
|
||||
applied to AddrSpace::read in space.cc.
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc | 2 +-
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc
|
||||
index f3c1e361..d0217389 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.cc
|
||||
@@ -1582,7 +1582,7 @@ int4 scan_number(char *numtext,SLEIGHSTYPE *lval,int4 radix,bool signednum)
|
||||
{
|
||||
uintb val;
|
||||
try {
|
||||
- val = std::stoul(numtext,(size_t *)0,radix);
|
||||
+ val = std::stoull(numtext,(size_t *)0,radix);
|
||||
}
|
||||
catch(...) {
|
||||
return BADINTEGER;
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l b/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l
|
||||
index 1c25962a..29db987b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghscan.l
|
||||
@@ -461,7 +461,7 @@ int4 scan_number(char *numtext,SLEIGHSTYPE *lval,int4 radix,bool signednum)
|
||||
{
|
||||
uintb val;
|
||||
try {
|
||||
- val = std::stoul(numtext,(size_t *)0,radix);
|
||||
+ val = std::stoull(numtext,(size_t *)0,radix);
|
||||
}
|
||||
catch(...) {
|
||||
return BADINTEGER;
|
||||
--
|
||||
2.54.0
|
||||
|
||||
@@ -53,7 +53,7 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# TODO: CMake only likes numeric characters in the version string....
|
||||
set(ghidra_head_version "12.2")
|
||||
set(ghidra_version "${ghidra_head_version}")
|
||||
set(ghidra_head_git_tag "43f4fcf954fb847714d769c5d4d1657204cb8cd8")
|
||||
set(ghidra_head_git_tag "b211a07b51e5098648d8f571130cf93448470d6a")
|
||||
set(ghidra_git_tag "${ghidra_head_git_tag}")
|
||||
set(ghidra_shallow FALSE)
|
||||
set(ghidra_patches
|
||||
@@ -68,6 +68,7 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
"${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"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0009-Use-std-stoull-instead-of-std-stoul-in-scan_number-f.patch"
|
||||
)
|
||||
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
|
||||
else()
|
||||
|
||||
Reference in New Issue
Block a user