From f9a1935c8ec07ed2eb269cafe53390d7f1e69c5e Mon Sep 17 00:00:00 2001 From: krcroft Date: Sat, 11 Apr 2020 13:47:41 -0700 Subject: [PATCH] Fix alignment when saving the branch value --- src/cpu/core_dyn_x86/risc_x64.h | 5 +++-- src/cpu/core_dyn_x86/risc_x86.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cpu/core_dyn_x86/risc_x64.h b/src/cpu/core_dyn_x86/risc_x64.h index f9ae3b75..1bdc257d 100644 --- a/src/cpu/core_dyn_x86/risc_x64.h +++ b/src/cpu/core_dyn_x86/risc_x64.h @@ -1150,8 +1150,9 @@ static Bit8u * gen_create_branch_long(BranchTypes type) { return (cache.pos-4); } -static void gen_fill_branch_long(Bit8u * data,Bit8u * from=cache.pos) { - *(Bit32u*)data=(Bit32u)(from-data-4); +static void gen_fill_branch_long(uint8_t *data, uint8_t *from = cache.pos) +{ + host_writed(data, from - data - sizeof(uint32_t)); } static Bit8u * gen_create_jump(Bit8u * to=0) { diff --git a/src/cpu/core_dyn_x86/risc_x86.h b/src/cpu/core_dyn_x86/risc_x86.h index 1f663c92..713b102e 100644 --- a/src/cpu/core_dyn_x86/risc_x86.h +++ b/src/cpu/core_dyn_x86/risc_x86.h @@ -983,8 +983,8 @@ static Bit8u * gen_create_branch_long(BranchTypes type) { return (cache.pos-4); } -static void gen_fill_branch_long(Bit8u * data,Bit8u * from=cache.pos) { - *(Bit32u*)data=(from-data-4); +static void gen_fill_branch_long(uint8_t *data, uint8_t *from = cache.pos) { + host_writed(data, from - data - sizeof(uint32_t)); } static Bit8u * gen_create_jump(Bit8u * to=0) {