No longer used hacked liveness_pass_1

This hack was introduced in issue#287 which later becomes endless maintainance pain.

=====

Our previous check_exit_request use `brcond` in the middle of a TranslationBlock which

breaks the assumptions and thus a hack to liveness_pass_1 is used for _all_ brcond instructions

which causes issues for MIPS and many other scenarios.

=====

This patch also resolves PC not sync-ed when no memory hooks are installed, finally. Now

Unicorn will always have correct PC no matter what happens.
This commit is contained in:
mio
2025-04-12 21:38:14 +08:00
parent e89eb87d04
commit 7f48b1dd4a
28 changed files with 80 additions and 63 deletions

View File

@@ -651,6 +651,24 @@ static void test_arm64_mem_hook_read_write(void)
OK(uc_close(uc));
}
static void test_arm64_pc_guarantee(void)
{
uc_engine *uc;
// ks.asm("mov x0, #1; mov x1, #2; ldr x0, [x1]")
const char code[] = "\x20\x00\x80\xd2\x41\x00\x80\xd2\x20\x00\x40\xf9";
uint64_t rip;
uc_common_setup(&uc, UC_ARCH_ARM64, UC_MODE_ARM, code, sizeof(code),
UC_CPU_ARM64_A72);
uc_assert_err(UC_ERR_READ_UNMAPPED, uc_emu_start(uc, code_start,
code_start + sizeof(code) - 1, 0, 0));
OK(uc_reg_read(uc, UC_ARM64_REG_PC, (void*)&rip));
TEST_CHECK(rip == code_start + 8);
OK(uc_close(uc));
}
TEST_LIST = {{"test_arm64_until", test_arm64_until},
{"test_arm64_code_patching", test_arm64_code_patching},
{"test_arm64_code_patching_count", test_arm64_code_patching_count},
@@ -668,4 +686,5 @@ TEST_LIST = {{"test_arm64_until", test_arm64_until},
{"test_arm64_pc_wrap", test_arm64_pc_wrap},
{"test_arm64_mem_prot_regress", test_arm64_mem_prot_regress},
{"test_arm64_mem_hook_read_write", test_arm64_mem_hook_read_write},
{"test_arm64_pc_guarantee", test_arm64_pc_guarantee},
{NULL, NULL}};