mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-21 23:01:03 +00:00
Add temporary patch to fix capstone x86-16 issue
This commit is contained in:
parent
4275bfc987
commit
8293f75ce9
@ -16,6 +16,7 @@ CS_TIP=0088d2a318ff0abc37005d508692e95c2011b24e
|
||||
# REVERT THIS COMMIT BECAUSE ITS WRONG
|
||||
CS_REV=
|
||||
#21b9b25e9dae4af0ef309d4089a54e53b8f5b479
|
||||
CS_PATCHES=1
|
||||
|
||||
.PHONY: capstone-sync capstone-build all clean mrproper libgdbr libwind
|
||||
|
||||
@ -203,6 +204,10 @@ capstone: capstone-sync
|
||||
|
||||
capstone-sync:
|
||||
"$(SHELL)" capstone.sh "${CS_URL}" "${CS_BRA}" "${CS_TIP}" "${CS_REV}"
|
||||
ifeq ($(CS_PATCHES),1)
|
||||
cd capstone ; git reset --hard
|
||||
cd capstone ; for a in ../capstone-patches/* ; do patch -p1 < $$a ; done
|
||||
endif
|
||||
|
||||
.PHONY: capstone
|
||||
else
|
||||
@ -216,7 +221,7 @@ capstone: capstone-$(CS_VER).tar.gz
|
||||
tar xzvf capstone-$(CS_VER).tar.gz
|
||||
rm -rf capstone
|
||||
mv capstone-$(CS_VER) capstone
|
||||
#cd capstone ; for a in ../capstone-patches/* ; do patch -p1 < $$a ; done
|
||||
cd capstone ; for a in ../capstone-patches/* ; do patch -p1 < $$a ; done
|
||||
|
||||
capstone-$(CS_VER).tar.gz:
|
||||
$(WGET) --no-check-certificate -O capstone-$(CS_VER).tar.gz -c $(CS_TAR)
|
||||
|
@ -1,52 +0,0 @@
|
||||
diff --git a/MathExtras.h b/MathExtras.h
|
||||
index 78150c8..484faf4 100644
|
||||
--- a/MathExtras.h
|
||||
+++ b/MathExtras.h
|
||||
@@ -87,7 +87,7 @@ static inline bool isPowerOf2_32(uint32_t Value) {
|
||||
/// bit. Ex. CountLeadingZeros_32(0x00F000FF) == 8.
|
||||
/// Returns 32 if the word is zero.
|
||||
static inline unsigned CountLeadingZeros_32(uint32_t Value) {
|
||||
- unsigned Count; // result
|
||||
+ unsigned Shift, Count; // result
|
||||
#if __GNUC__ >= 4
|
||||
// PowerPC is defined for __builtin_clz(0)
|
||||
#if !defined(__ppc__) && !defined(__ppc64__)
|
||||
@@ -98,7 +98,7 @@ static inline unsigned CountLeadingZeros_32(uint32_t Value) {
|
||||
if (!Value) return 32;
|
||||
Count = 0;
|
||||
// bisection method for count leading zeros
|
||||
- for (unsigned Shift = 32 >> 1; Shift; Shift >>= 1) {
|
||||
+ for (Shift = 32 >> 1; Shift; Shift >>= 1) {
|
||||
uint32_t Tmp = Value >> Shift;
|
||||
if (Tmp) {
|
||||
Value = Tmp;
|
||||
@@ -123,7 +123,7 @@ static inline unsigned CountLeadingOnes_32(uint32_t Value) {
|
||||
/// one bit (64 bit edition.)
|
||||
/// Returns 64 if the word is zero.
|
||||
static inline unsigned CountLeadingZeros_64(uint64_t Value) {
|
||||
- unsigned Count; // result
|
||||
+ unsigned Shift, Count; // result
|
||||
#if __GNUC__ >= 4
|
||||
// PowerPC is defined for __builtin_clzll(0)
|
||||
#if !defined(__ppc__) && !defined(__ppc64__)
|
||||
@@ -137,7 +137,7 @@ static inline unsigned CountLeadingZeros_64(uint64_t Value) {
|
||||
if (!Value) return 64;
|
||||
Count = 0;
|
||||
// bisection method for count leading zeros
|
||||
- for (unsigned Shift = 64 >> 1; Shift; Shift >>= 1) {
|
||||
+ for (Shift = 64 >> 1; Shift; Shift >>= 1) {
|
||||
uint64_t Tmp = Value >> Shift;
|
||||
if (Tmp) {
|
||||
Value = Tmp;
|
||||
@@ -242,7 +242,7 @@ static inline unsigned CountPopulation_32(uint32_t Value) {
|
||||
#else
|
||||
uint32_t v = Value - ((Value >> 1) & 0x55555555);
|
||||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
|
||||
- return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
|
||||
+ return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
|
||||
#endif
|
||||
}
|
||||
|
||||
--
|
||||
1.8.5.3
|
||||
|
32
shlr/capstone-patches/fix-x86-16.patch
Normal file
32
shlr/capstone-patches/fix-x86-16.patch
Normal file
@ -0,0 +1,32 @@
|
||||
diff --git a/arch/X86/X86ATTInstPrinter.c b/arch/X86/X86ATTInstPrinter.c
|
||||
index 12dfdae..134e182 100644
|
||||
--- a/arch/X86/X86ATTInstPrinter.c
|
||||
+++ b/arch/X86/X86ATTInstPrinter.c
|
||||
@@ -529,8 +529,10 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
|
||||
SStream_concat(O, "0x%"PRIx64, imm);
|
||||
} else {
|
||||
// handle 16bit segment bound
|
||||
- if (MI->csh->mode == CS_MODE_16)
|
||||
+ if (MI->csh->mode == CS_MODE_16) {
|
||||
imm = imm & 0xffff;
|
||||
+ imm |= (MI->address >> 16) << 16;
|
||||
+ }
|
||||
|
||||
if (imm > HEX_THRESHOLD)
|
||||
SStream_concat(O, "0x%"PRIx64, imm);
|
||||
diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c
|
||||
index 9854b98..9167b45 100644
|
||||
--- a/arch/X86/X86IntelInstPrinter.c
|
||||
+++ b/arch/X86/X86IntelInstPrinter.c
|
||||
@@ -693,8 +693,10 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
|
||||
imm = imm & 0xffffffff;
|
||||
}
|
||||
|
||||
- if (MI->csh->mode == CS_MODE_16)
|
||||
+ if (MI->csh->mode == CS_MODE_16) {
|
||||
imm = imm & 0xffff;
|
||||
+ imm |= (MI->address >> 16) << 16;
|
||||
+ }
|
||||
|
||||
printImm(MI->csh->syntax, O, imm, true);
|
||||
|
@ -14,7 +14,7 @@ else
|
||||
if [ -n "${CS_REV}" ]; then
|
||||
HEAD="`git log|grep ^commit | head -n2|tail -n1 | awk '{print $2}'`"
|
||||
else
|
||||
HEAD="`git log|head -n1 awk '{print $2}'`"
|
||||
HEAD="`git log|head -n1 | awk '{print $2}'`"
|
||||
fi
|
||||
if [ "${HEAD}" = "${CS_TIP}" ]; then
|
||||
echo "[capstone] Already in TIP, no need to update from git"
|
||||
|
Loading…
x
Reference in New Issue
Block a user