From 5300d10cfc9927a30e525e8197dd9db2555d4819 Mon Sep 17 00:00:00 2001 From: ada-l0velace <9060550+ada-l0velace@users.noreply.github.com> Date: Sun, 5 Jul 2026 21:10:27 +0100 Subject: [PATCH] Fix ARM64 ADRP page-relative address calculation --- Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs b/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs index 6a433217..4dd67722 100644 --- a/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs +++ b/Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs @@ -217,7 +217,8 @@ void AddCall(MethodAnalysisContext context, object? returnRegister2, ulong addre case Arm64Mnemonic.ADRP: //Just handle as a move Add(address, OpCode.Move, ConvertOperand(instruction, 0), ConvertOperand(instruction, 1)); - adrpOffsets[instruction.Op0Reg] = (ulong)instruction.Op1Imm; + var pageAddress = address & ~0xFFFUL; + adrpOffsets[instruction.Op0Reg] = (ulong)((long)pageAddress + instruction.Op1Imm); break; case Arm64Mnemonic.LDP when instruction.Op2Kind == Arm64OperandKind.Memory: //LDP (dest1, dest2, [mem]) - basically just treat as two loads, with the second offset by the length of the first