Skip to content

Commit

Permalink
universe/capstone: backport fix for wrongly defined Python constants
Browse files Browse the repository at this point in the history
[ commit 6a797fd5e1abc0cfb2443b809925467b9f046e52 ]

See: capstone-engine/capstone#2240
  • Loading branch information
nmeum authored and akodanev committed Jan 23, 2024
1 parent 9e43f27 commit d9c87a7
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
From f180e176de3efb060db62820ff981d0291ea8525 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <[email protected]>
Date: Thu, 18 Jan 2024 01:43:31 +0000
Subject: [PATCH] Revert "Update constants from ARM auto-sync patch" (#2240)

---
bindings/python/capstone/__init__.py | 42 +++++-----------------------
1 file changed, 7 insertions(+), 35 deletions(-)

diff --git a/bindings/python/capstone/__init__.py b/bindings/python/capstone/__init__.py
index bda2fdb6..52353c28 100755
--- a/bindings/python/capstone/__init__.py
+++ b/bindings/python/capstone/__init__.py
@@ -113,7 +113,6 @@ __all__ = [
'CS_OPT_SYNTAX_NOREGNAME',
'CS_OPT_SYNTAX_MASM',
'CS_OPT_SYNTAX_MOTOROLA',
- 'CS_OPT_SYNTAX_CS_REG_ALIAS',

'CS_OPT_DETAIL',
'CS_OPT_MODE',
@@ -152,19 +151,6 @@ __all__ = [
'CS_OP_REG',
'CS_OP_IMM',
'CS_OP_FP',
- 'CS_OP_PRED',
- 'CS_OP_RESERVED_5',
- 'CS_OP_RESERVED_6',
- 'CS_OP_RESERVED_7',
- 'CS_OP_RESERVED_8',
- 'CS_OP_RESERVED_9',
- 'CS_OP_RESERVED_10',
- 'CS_OP_RESERVED_11',
- 'CS_OP_RESERVED_12',
- 'CS_OP_RESERVED_13',
- 'CS_OP_RESERVED_14',
- 'CS_OP_RESERVED_15',
- 'CS_OP_SPECIAL',
'CS_OP_MEM',

'CS_GRP_INVALID',
@@ -298,26 +284,13 @@ CS_OPT_NO_BRANCH_OFFSET = 9 # ARM, prints branch immediates without offset.

# Capstone option value
CS_OPT_OFF = 0 # Turn OFF an option - default option of CS_OPT_DETAIL
-CS_OPT_ON = 1 << 0 # Turn ON an option (CS_OPT_DETAIL)
+CS_OPT_ON = 3 # Turn ON an option (CS_OPT_DETAIL)

# Common instruction operand types - to be consistent across all architectures.
CS_OP_INVALID = 0 # uninitialized/invalid operand.
CS_OP_REG = 1 # Register operand.
CS_OP_IMM = 2 # Immediate operand.
CS_OP_FP = 3 # Floating-Point operand.
-CS_OP_PRED = 4 # Predicate operand.
-CS_OP_RESERVED_5 = 5
-CS_OP_RESERVED_6 = 6
-CS_OP_RESERVED_7 = 7
-CS_OP_RESERVED_8 = 8
-CS_OP_RESERVED_9 = 9
-CS_OP_RESERVED_10 = 10
-CS_OP_RESERVED_11 = 11
-CS_OP_RESERVED_12 = 12
-CS_OP_RESERVED_13 = 13
-CS_OP_RESERVED_14 = 14
-CS_OP_RESERVED_15 = 15
-CS_OP_SPECIAL = 0x10 # Special operands from archs
CS_OP_MEM = 0x80 # Memory operand. Can be ORed with another operand type.

# Common instruction groups - to be consistent across all architectures.
@@ -336,13 +309,12 @@ CS_AC_READ = (1 << 0) # Operand that is read from.
CS_AC_WRITE = (1 << 1) # Operand that is written to.

# Capstone syntax value
-CS_OPT_SYNTAX_DEFAULT = 1 << 1 # Default assembly syntax of all platforms (CS_OPT_SYNTAX)
-CS_OPT_SYNTAX_INTEL = 1 << 2 # Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
-CS_OPT_SYNTAX_ATT = 1 << 3 # ATT asm syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
-CS_OPT_SYNTAX_NOREGNAME = 1 << 4 # Asm syntax prints register name with only number - (CS_OPT_SYNTAX, CS_ARCH_PPC, CS_ARCH_ARM)
-CS_OPT_SYNTAX_MASM = 1 << 5 # MASM syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
-CS_OPT_SYNTAX_MOTOROLA = 1 << 6 # MOS65XX use $ as hex prefix
-CS_OPT_SYNTAX_CS_REG_ALIAS = 1 << 7 # Prints common register alias which are not defined in LLVM (ARM: r9 = sb etc.)
+CS_OPT_SYNTAX_DEFAULT = 0 # Default assembly syntax of all platforms (CS_OPT_SYNTAX)
+CS_OPT_SYNTAX_INTEL = 1 # Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
+CS_OPT_SYNTAX_ATT = 2 # ATT asm syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
+CS_OPT_SYNTAX_NOREGNAME = 3 # Asm syntax prints register name with only number - (CS_OPT_SYNTAX, CS_ARCH_PPC, CS_ARCH_ARM)
+CS_OPT_SYNTAX_MASM = 4 # MASM syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
+CS_OPT_SYNTAX_MOTOROLA = 5 # MOS65XX use $ as hex prefix

# Capstone error type
CS_ERR_OK = 0 # No error: everything was fine
4 changes: 3 additions & 1 deletion universe/capstone/APKBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgname=capstone
pkgver=5.0.1
pkgrel=1
pkgrel=2
pkgdesc="The Ultimate Disassembler"
url="https://www.capstone-engine.org"
arch="all"
Expand All @@ -9,6 +9,7 @@ depends_dev="$pkgname"
makedepends="bash py3-setuptools cython python3-dev"
subpackages="$pkgname-static $pkgname-dev py3-$pkgname-pyc py3-${pkgname}:_py3 cstool"
source="$pkgname-$pkgver.tar.gz::https://github.com/aquynh/capstone/archive/$pkgver.tar.gz
0001-Revert-Update-constants-from-ARM-auto-sync-patch-224.patch
py-path-fix.patch
"
options="!check" # Testsuite fails
Expand Down Expand Up @@ -50,5 +51,6 @@ cstool() {

sha512sums="
350aba77ce2d96b5c25764913591ba80e4497177ae0a8b2c820c6755ee8310848fbfc54e7ccac27fafc2dbc6778118ad92c53d1b5cb601d4fa146dec7d7e11e5 capstone-5.0.1.tar.gz
86254e4f42107ceb29c65b227acdf2b4375ba8b7e076ee53fac649feddb478f08c7b23d61e63d0c96068e6d993116b96ec7c714dbe0247aa3458b63d0a2d3f94 0001-Revert-Update-constants-from-ARM-auto-sync-patch-224.patch
e9a2d7cb391285890872123fb3e5ae8f8cde6e4f858c31f5c815c110f6c6d5ec86cef4920b277d5630745a34a268e52b402855429b072f0b5a722d6a610366a8 py-path-fix.patch
"

0 comments on commit d9c87a7

Please sign in to comment.