From 7e07f083a6fcf988f288dcc2c40740cec8f32e85 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Wed, 1 Dec 2021 08:40:36 +0100 Subject: [PATCH] Fix native code jmp offsets for inline assembly --- oscar64/Linker.h | 1 + oscar64/NativeCodeGenerator.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/oscar64/Linker.h b/oscar64/Linker.h index 9229a4b..66ecd86 100644 --- a/oscar64/Linker.h +++ b/oscar64/Linker.h @@ -53,6 +53,7 @@ public: static const uint32 LREF_LOWBYTE = 0x00000001; static const uint32 LREF_HIGHBYTE = 0x00000002; static const uint32 LREF_TEMPORARY = 0x00000004; +static const uint32 LREF_INBLOCK = 0x00000008; class LinkerReference { diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 3cec456..14413b5 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -2375,6 +2375,7 @@ void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block) { rl.mRefObject = nullptr; rl.mRefOffset += pos; + rl.mFlags |= LREF_INBLOCK; } block->mRelocations.Push(rl); } @@ -11101,6 +11102,11 @@ void NativeCodeBasicBlock::CopyCode(NativeCodeProcedure * proc, uint8* target) { LinkerReference& rl(mRelocations[i]); rl.mOffset += mOffset; + if (rl.mFlags & LREF_INBLOCK) + { + rl.mRefOffset += mOffset; + rl.mFlags &= ~LREF_INBLOCK; + } proc->mRelocations.Push(rl); }