From d434b06bfadf8fc805bf0d1f3fdede15922c7671 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leon=20Wei=C3=9F?= <leon.weiss@rub.de>
Date: Fri, 28 Apr 2023 16:47:14 +0200
Subject: [PATCH] Move base ID into original instruction in order to keep the
 annotation mapping intact

Otherwise annotations would now belong to the newly inserted instruction
---
 irdb-libs/libIRDB-transform/src/rewrite_util.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/irdb-libs/libIRDB-transform/src/rewrite_util.cpp b/irdb-libs/libIRDB-transform/src/rewrite_util.cpp
index 268f57d8b..3fdf0456a 100644
--- a/irdb-libs/libIRDB-transform/src/rewrite_util.cpp
+++ b/irdb-libs/libIRDB-transform/src/rewrite_util.cpp
@@ -52,6 +52,9 @@ Instruction_t* IRDB_SDK::insertAssemblyBefore(FileIR_t* virp, Instruction_t* fir
 	next->setOriginalAddressID(first->getOriginalAddressID());
 	//"Null" out the original address (it should be as if the instruction was not in the database).
 	first->setOriginalAddressID(BaseObj_t::NOT_IN_DATABASE);
+	// Keep Base ID in the original instruction
+	next->setBaseID(first->getBaseID());
+	first->setBaseID(BaseObj_t::NOT_IN_DATABASE);
 	auto real_first=dynamic_cast<libIRDB::Instruction_t*>(first);
 	assert(real_first);
 	real_first->GetRelocations().clear();
@@ -121,6 +124,9 @@ Instruction_t* IRDB_SDK::insertDataBitsBefore(FileIR_t* virp, Instruction_t* fir
         next->setOriginalAddressID(first->getOriginalAddressID());
         //"Null" out the original address (it should be as if the instruction was not in the database).
         first->setOriginalAddressID(BaseObj_t::NOT_IN_DATABASE);
+		// Keep Base ID in the original instruction
+		next->setBaseID(first->getBaseID());
+		first->setBaseID(BaseObj_t::NOT_IN_DATABASE);
 	auto real_first=dynamic_cast<libIRDB::Instruction_t*>(first);
 	assert(real_first);
         real_first->GetRelocations().clear();
-- 
GitLab