mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Remove unnecessary sign_extend patch (#194)
The issue was actually with the UBSAN patch to the `sign_extend` function and not the upstream commit itself. When NationalSecurityAgency/ghidra@3c08b44 landed, I had to regenerate the UBSAN patch but I botched the part of the patch that modifies `sign_extend` and introduced this bug. Now that the UBSAN patch no longer touches this function, I should just get rid of the new patch and things should "just work".
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
From df7483a5c86ebea356eea1fe833aa9fd6e9d44ff Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Wed, 12 Jul 2023 15:39:28 +1000
|
||||
Subject: [PATCH 3/3] Undo regression in `sign_extend`
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/address.cc | 18 +++++++++++++-----
|
||||
1 file changed, 13 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
index 40526a88f..af856f272 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
@@ -666,11 +666,19 @@ uintb uintb_negate(uintb in,int4 size)
|
||||
uintb sign_extend(uintb in,int4 sizein,int4 sizeout)
|
||||
|
||||
{
|
||||
- intb sval = in;
|
||||
- sval <<= (sizeof(intb) - sizein) * 8;
|
||||
- uintb res = (uintb)(sval >> (sizeout - sizein) * 8);
|
||||
- res >>= (sizeof(uintb) - sizeout)*8;
|
||||
- return res;
|
||||
+ int4 signbit;
|
||||
+ uintb mask;
|
||||
+
|
||||
+ signbit = sizein*8 - 1;
|
||||
+ in &= calc_mask(sizein);
|
||||
+ if (sizein >= sizeout) return in;
|
||||
+ if ((in>>signbit) != 0) {
|
||||
+ mask = calc_mask(sizeout);
|
||||
+ uintb tmp = mask << signbit; // Split shift into two pieces
|
||||
+ tmp = (tmp<<1) & mask; // In case, everything is shifted out
|
||||
+ in |= tmp;
|
||||
+ }
|
||||
+ return in;
|
||||
}
|
||||
|
||||
/// Swap the least significant \b size bytes in \b val
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
|
||||
@@ -57,7 +57,6 @@ 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-Undo-regression-in-sign_extend.patch"
|
||||
)
|
||||
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
|
||||
else()
|
||||
|
||||
Reference in New Issue
Block a user