commit:     82db242778d09f29d7827e0399c5e83a58568864
Author:     Mario Haustein <mario.haustein <AT> hrz <DOT> tu-chemnitz <DOT> de>
AuthorDate: Thu Oct 16 17:07:57 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 16 19:03:17 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=82db2427

dev-util/unicorn: fix crash

Signed-off-by: Mario Haustein <mario.haustein <AT> hrz.tu-chemnitz.de>
Part-of: https://github.com/gentoo/gentoo/pull/44207
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../unicorn/files/unicorn-2.1.3-delay_slot_flag.patch   | 17 +++++++++++++++++
 .../{unicorn-2.1.3.ebuild => unicorn-2.1.3-r1.ebuild}   |  3 ++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/dev-util/unicorn/files/unicorn-2.1.3-delay_slot_flag.patch 
b/dev-util/unicorn/files/unicorn-2.1.3-delay_slot_flag.patch
new file mode 100644
index 000000000000..e9fe96482b16
--- /dev/null
+++ b/dev-util/unicorn/files/unicorn-2.1.3-delay_slot_flag.patch
@@ -0,0 +1,17 @@
+From 0bb1bbd93c9e821154845ba81b81e8a05c49c3b7 Mon Sep 17 00:00:00 2001
+From: mio <[email protected]>
+Date: Tue, 18 Mar 2025 21:20:37 +0800
+Subject: [PATCH] Initialize delay_slot_flag correctly
+Upstream: https://github.com/unicorn-engine/unicorn/issues/2134
+
+--- a/qemu/include/exec/gen-icount.h
++++ b/qemu/include/exec/gen-icount.h
+@@ -45,6 +45,8 @@ static inline void gen_tb_start(TCGContext *tcg_ctx, 
TranslationBlock *tb)
+     //    We CANT'T use brcondi_i32 here or we will fail liveness analysis
+     //    because it marks the end of BB
+     if (tcg_ctx->delay_slot_flag != NULL) {
++        // Initialize delay_slot_flag here
++        tcg_gen_movi_i32(tcg_ctx, tcg_ctx->delay_slot_flag, 0);
+         TCGv_i32 tmp = tcg_const_i32(tcg_ctx, 0);
+         // dest = (c1 cond c2 ? v1 : v2)
+         tcg_gen_movcond_i32(tcg_ctx, TCG_COND_GT, count, 
tcg_ctx->delay_slot_flag, tmp, tcg_ctx->delay_slot_flag, count);

diff --git a/dev-util/unicorn/unicorn-2.1.3.ebuild 
b/dev-util/unicorn/unicorn-2.1.3-r1.ebuild
similarity index 96%
rename from dev-util/unicorn/unicorn-2.1.3.ebuild
rename to dev-util/unicorn/unicorn-2.1.3-r1.ebuild
index dd0f2cf96f16..555b8c0e3604 100644
--- a/dev-util/unicorn/unicorn-2.1.3.ebuild
+++ b/dev-util/unicorn/unicorn-2.1.3-r1.ebuild
@@ -45,7 +45,8 @@ UNICORN_TARGETS="x86 arm aarch64 riscv mips sparc m68k ppc 
s390x tricore"
 export SETUPTOOLS_SCM_PRETEND_VERSION=${PV}
 
 PATCHES=(
-       "${FILESDIR}"/${PN}-2.1.3-strings.patch
+       "${FILESDIR}/${P}-strings.patch"
+       "${FILESDIR}/${P}-delay_slot_flag.patch"
 )
 
 wrap_python() {

Reply via email to