unicorn icon indicating copy to clipboard operation
unicorn copied to clipboard

Branch instruction "B" fails with an UC_ERR_EXCEPTION on aarch64

Open naveen126 opened this issue 1 year ago • 3 comments

Hi Sir, I have add some code into function "test_arm64" in the file "sample_arm64.c".

Some variables used in the test_arm64 can be instanced as bellow.

uint64_t mem_data = 0; uint64_t pc_addr = 0; uint32_t isa_word = 0; char isa_bytes[4];

The added code is here:

// 14000004 	b	200028 <main>
isa_word = 0x14000004;
pc_addr = 0x200018;
memcpy(isa_bytes, &isa_word, 4);
uc_mem_write(uc, pc_addr, isa_bytes, 4);
err = uc_emu_start(uc, pc_addr, pc_addr + 4, 0, 0);
if (err) {
    printf("B-inst Test Failed on uc_emu_start() with error returned: %u\n", err);
}

But when I have built the unicorn, I run the "sample_arm64", it turns out an error like this: B-inst Test Failed on uc_emu_start() with error returned: 21

So, I want to know if this is s bug. Why does this error turn out? And how can I test branch instructions of aarch64?

Thanks a lot!

naveen126 avatar Jul 28 '22 06:07 naveen126

Why pc_addr + 3 instead of pc_addr + 4?

wtdcode avatar Aug 07 '22 12:08 wtdcode

Why pc_addr + 3 instead of pc_addr + 4?

sorry, it is a handwriting error in this issue. Actually, it is 'pc_addr+4' in the code.

naveen126 avatar Aug 07 '22 23:08 naveen126

Why pc_addr + 3 instead of pc_addr + 4?

sorry, it is a handwriting error in this issue. Actually, it is 'pc_addr+4' in the code.

Please post a full and minimal reproduction script, thanks.

wtdcode avatar Aug 09 '22 10:08 wtdcode

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Oct 09 '22 05:10 github-actions[bot]