Skip to content

Commit

Permalink
Apply fix for big endian hosts per unicorn-engine#1710
Browse files Browse the repository at this point in the history
  • Loading branch information
wtdcode committed Oct 28, 2022
1 parent 98980c9 commit 4b961a8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tests/unit/test_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ static void test_arm_thumb_ite(void)
OK(uc_reg_write(uc, UC_ARM_REG_R3, &r_r3));

OK(uc_mem_map(uc, r_sp, 0x1000, UC_PROT_ALL));
r_r2 = 0x68;
r_r2 = LEINT32(0x68);
OK(uc_mem_write(uc, r_sp, &r_r2, 4));
r_r2 = 0x4d;
r_r2 = LEINT32(0x4d);
OK(uc_mem_write(uc, r_sp + 4, &r_r2, 4));

OK(uc_hook_add(uc, &hook, UC_HOOK_CODE, test_arm_thumb_ite_count_callback,
Expand Down Expand Up @@ -396,7 +396,7 @@ static void test_arm_v8(void)
{
char code[] = "\xd0\xe8\xff\x17"; // LDAEXD.W R1, [R0]
uc_engine *uc;
uint32_t r_r1 = 0xdeadbeef;
uint32_t r_r1 = LEINT32(0xdeadbeef);
uint32_t r_r0;

uc_common_setup(&uc, UC_ARCH_ARM, UC_MODE_THUMB, code, sizeof(code) - 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void test_arm64_v8_pac(void)

OK(uc_mem_read(uc, 0x40000, (void *)&mem, 8));

TEST_CHECK(mem == r_x8);
TEST_CHECK(LEINT64(mem) == r_x8);

OK(uc_close(uc));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void test_mem_protect(void)
OK(uc_emu_start(qc, 0x1000, 0x1000 + sizeof(code) - 1, 0, 1));
OK(uc_mem_read(qc, 0x2000 + 4, &mem, 4));

TEST_CHECK(mem == 0xdeadbeef);
TEST_CHECK(LEINT32(mem) == 0xdeadbeef);

OK(uc_close(qc));
}
Expand Down Expand Up @@ -92,7 +92,7 @@ static void test_splitting_mmio_unmap(void)
// mov ebx, [0x4004] <-- mmio read
char code[] = "\x8b\x0d\x04\x30\x00\x00\x8b\x1d\x04\x40\x00\x00";
int r_ecx, r_ebx;
int bytes = 0xdeadbeef;
int bytes = LEINT32(0xdeadbeef);

OK(uc_open(UC_ARCH_X86, UC_MODE_32, &uc));

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void test_mips_lwx_exception_issue_1314(void)
reg = 0;
OK(uc_reg_write(uc, UC_MIPS_REG_1, &reg));
OK(uc_reg_write(uc, UC_MIPS_REG_T9, &reg));
reg = 0xdeadbeef;
reg = LEINT32(0xdeadbeef);
OK(uc_mem_write(uc, 0x10000, &reg, 4));
reg = 0x10000;
OK(uc_reg_write(uc, UC_MIPS_REG_S3, &reg));
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ static void test_x86_x87_fnstenv(void)

OK(uc_mem_read(uc, base, fnstenv, sizeof(fnstenv)));
// But update FCS:FIP for fld.
TEST_CHECK(fnstenv[3] == last_eip);
TEST_CHECK(LEINT32(fnstenv[3]) == last_eip);

OK(uc_close(uc));
}
Expand Down Expand Up @@ -530,7 +530,7 @@ static void test_x86_smc_xor(void)

OK(uc_mem_read(uc, code_start + 3, (void *)&result, 4));

TEST_CHECK(result == (0x3ea98b13 ^ 0xbc4177e6));
TEST_CHECK(LEINT32(result) == (0x3ea98b13 ^ 0xbc4177e6));

OK(uc_close(uc));
}
Expand Down Expand Up @@ -562,7 +562,7 @@ static void test_x86_mmio_uc_mem_rw_write_callback(uc_engine *uc,
static void test_x86_mmio_uc_mem_rw(void)
{
uc_engine *uc;
int data = 0xdeadbeef;
int data = LEINT32(0xdeadbeef);

OK(uc_open(UC_ARCH_X86, UC_MODE_32, &uc));

Expand All @@ -572,7 +572,7 @@ static void test_x86_mmio_uc_mem_rw(void)
OK(uc_mem_write(uc, 0x20004, (void *)&data, 4));
OK(uc_mem_read(uc, 0x20008, (void *)&data, 4));

TEST_CHECK(data == 0x19260817);
TEST_CHECK(LEINT32(data) == 0x19260817);

OK(uc_close(uc));
}
Expand Down

0 comments on commit 4b961a8

Please sign in to comment.