unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: soeren@soeren-tempel.net
To: 69074@debbugs.gnu.org
Subject: [bug#69074] [PATCH] gnu: capstone: Backport upstream fix for Python bindings.
Date: Mon, 12 Feb 2024 15:58:28 +0100	[thread overview]
Message-ID: <efca3e3eabb1b9e6642ace59d388fba7fe745fdb.1707749005.git.soeren@soeren-tempel.net> (raw)
In-Reply-To: <cover.1707749005.git.soeren@soeren-tempel.net>

From: Sören Tempel <soeren@soeren-tempel.net>

* gnu/packages/engineering.scm (capstone): New patch.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/engineering.scm                  |  2 +
 ...python-capstone-fix-python-constants.patch | 84 +++++++++++++++++++
 3 files changed, 87 insertions(+)
 create mode 100644 gnu/packages/patches/python-capstone-fix-python-constants.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index ecbae4bb53..ce0f1994c5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1901,6 +1901,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-3-hurd-configure.patch		\
   %D%/packages/patches/python-aionotify-0.2.0-py3.8.patch	\
   %D%/packages/patches/python-argcomplete-1.11.1-fish31.patch	\
+  %D%/packages/patches/python-capstone-fix-python-constants.patch	\
   %D%/packages/patches/python-cross-compile.patch		\
   %D%/packages/patches/python-configobj-setuptools.patch	\
   %D%/packages/patches/python-dateutil-pytest-compat.patch	\
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 16f572909c..336c8b0e38 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -39,6 +39,7 @@
 ;;; Copyright © 2023 Theofilos Pechlivanis <theofilos.pechlivanis@gmail.com>
 ;;; Copyright © 2023 Sharlatan Hellseher <sharlatanus@gmail.com>
 ;;; Copyright © 2023 pinoaffe <pinoaffe@gmail.com>
+;;; Copyright © 2024 Sören Tempel <soeren@soeren-tempel.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1815,6 +1816,7 @@ (define-public capstone
     (version "5.0.1")
     (source (origin
               (method git-fetch)
+              (patches (search-patches "python-capstone-fix-python-constants.patch"))
               (uri (git-reference
                     (url "https://github.com/capstone-engine/capstone")
                     (commit version)))
diff --git a/gnu/packages/patches/python-capstone-fix-python-constants.patch b/gnu/packages/patches/python-capstone-fix-python-constants.patch
new file mode 100644
index 0000000000..75100c6652
--- /dev/null
+++ b/gnu/packages/patches/python-capstone-fix-python-constants.patch
@@ -0,0 +1,84 @@
+Backport upstream patch fixing various constants in the Python bindings.
+
+Taken from: https://github.com/capstone-engine/capstone/commit/f180e176de3efb060db62820ff981d0291ea8525
+
+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




  parent reply	other threads:[~2024-02-12 15:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 14:55 [bug#69074] [PATCH] Add python-angr soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-itanium-demangle soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-keystone-engine soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-mulpyplexer soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-nampa soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-rpyc soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-pysmt soeren
2024-02-12 14:58 ` Troy Figiel
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-claripy soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-archinfo soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-pyvex soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-cle soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-ailment soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: unicorn: Update to 2.0.1.post1 soeren
2024-02-12 14:58 ` soeren [this message]
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-angr Troy Figiel
2024-02-12 14:58 ` soeren
2024-02-12 22:53 ` [bug#69074] [PATCH] " Troy Figiel
2024-02-13  9:53   ` [bug#69074] " Sören Tempel
2024-02-13 11:52     ` Troy Figiel
2024-02-15 21:39       ` Troy Figiel
2024-02-15 22:09         ` Troy Figiel
2024-03-01 12:02 ` Sören Tempel
2024-03-10 20:09 ` [bug#69074] [PATCH v2 01/14] gnu: Add python-itanium-demangle soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 02/14] gnu: Add python-keystone-engine soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 03/14] gnu: Add python-mulpyplexer soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 04/14] gnu: Add python-nampa soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 05/14] gnu: Add python-rpyc soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 06/14] gnu: Add python-pysmt soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 07/14] gnu: Add python-claripy soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 08/14] gnu: Add python-archinfo soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 09/14] gnu: Add python-pyvex soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 10/14] gnu: Add python-cle soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 11/14] gnu: Add python-ailment soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 12/14] gnu: unicorn: Update to 2.0.1.post1 soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 13/14] gnu: capstone: Backport upstream fix for Python bindings soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 14/14] gnu: Add python-angr soeren
2024-03-10 20:12 ` [bug#69074] [PATCH] " Sören Tempel
2024-03-10 22:46   ` Troy Figiel
2024-03-11  8:50     ` Sören Tempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=efca3e3eabb1b9e6642ace59d388fba7fe745fdb.1707749005.git.soeren@soeren-tempel.net \
    --to=soeren@soeren-tempel.net \
    --cc=69074@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).