Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ obj/
launchsettings.json

artifacts/

.DS_Store
7 changes: 3 additions & 4 deletions Cpp2IL.Core/IlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,8 @@ private static List<CilInstruction> GenerateInstructions(Instruction instruction
}

// Load normal params
var callParams = instruction.Operands
.Skip(thisParamIndex + (targetMethod.IsStatic ? 0 : -1))
.Take(instruction.Operands.Count - 1 - thisParamIndex);
var callParamIndex = instruction.OpCode == OpCode.Call ? (targetMethod.IsStatic ? 2 : 3) : (targetMethod.IsStatic ? 1 : 2);
var callParams = instruction.Operands.Skip(callParamIndex);
foreach (var param in callParams)
LoadOperand(param, method, locals, writeLine, stringCtor);

Expand Down Expand Up @@ -501,7 +500,7 @@ private static void LoadOperand(object operand, MethodDefinition method,
break;
}
instructions.Add(CilOpCodes.Ldstr, "Unmanaged memory load: " + operand.ToString());
instructions.Add(CilOpCodes.Newobj, importer.ImportMethod(stringCtor));
instructions.Add(CilOpCodes.Call, importer.ImportMethod(writeLine));
break;
case RuntimeMethodInfoAnalysisContext:
//Not fully implemented, these basically shouldn't actually ever exist in the final IL.
Expand Down
14 changes: 13 additions & 1 deletion Cpp2IL.Core/InstructionSets/NewArmV8InstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,19 @@ void AddCall(MethodAnalysisContext context, object? returnRegister2, ulong addre
Add(address, OpCode.Move, dest2, mem2);
break;
case Arm64Mnemonic.BL:
AddCall(context, GetReturnRegisterForContext(context), address, instruction.BranchTarget);
if (context.AppContext.MethodsByAddress.TryGetValue(instruction.BranchTarget, out var possibleMethods))
{
if (possibleMethods.Count == 1)
AddCall(context, GetReturnRegisterForContext(possibleMethods[0]), address, instruction.BranchTarget);
else
// TODO: Properly fix this case where branch address is potentially more than 1 method
AddCall(context, GetReturnRegisterForContext(context), address, instruction.BranchTarget);
}
else
{
// TODO: properly handle unmanaged/API function
AddCall(context, GetReturnRegisterForContext(context), address, instruction.BranchTarget);
}
Comment thread
SamboyCoding marked this conversation as resolved.
break;
case Arm64Mnemonic.RET:
var returnRegister = GetReturnRegisterForContext(context);
Expand Down
Loading