From b4dd8f0df87aa75d24d0c9c509ef57b75aa99df6 Mon Sep 17 00:00:00 2001 From: jfrijters Date: Sat, 12 Jan 2013 12:07:40 +0000 Subject: [PATCH] Implemented ARM unmanaged exports. --- reflect/Emit/ModuleBuilder.cs | 1 + reflect/Writer/TextSection.cs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/reflect/Emit/ModuleBuilder.cs b/reflect/Emit/ModuleBuilder.cs index 39c723d8..7e058929 100644 --- a/reflect/Emit/ModuleBuilder.cs +++ b/reflect/Emit/ModuleBuilder.cs @@ -941,6 +941,7 @@ namespace IKVM.Reflection.Emit switch (imageFileMachine) { case ImageFileMachine.I386: + case ImageFileMachine.ARM: type = 0x05; size = 4; break; diff --git a/reflect/Writer/TextSection.cs b/reflect/Writer/TextSection.cs index 0fc1f2bf..b0c0fe3e 100644 --- a/reflect/Writer/TextSection.cs +++ b/reflect/Writer/TextSection.cs @@ -516,6 +516,7 @@ namespace IKVM.Reflection.Writer stubLength = 8; break; case IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_AMD64: + case IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_ARM: stubLength = 16; break; default: @@ -569,7 +570,7 @@ namespace IKVM.Reflection.Writer { if (text.moduleBuilder.unmanagedExports[pos].ordinal == i + ordinalBase) { - mw.Write(stubsRVA + (uint)pos * stubLength); + mw.Write(text.peWriter.Thumb + stubsRVA + (uint)pos * stubLength); pos++; } else @@ -649,6 +650,15 @@ namespace IKVM.Reflection.Writer mw.Write((byte)0xE0); mw.Write(0); // alignment break; + case IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_ARM: + mw.Write((ushort)0xF8DF); + mw.Write((ushort)0xC008); + mw.Write((ushort)0xF8DC); + mw.Write((ushort)0xC000); + mw.Write((ushort)0x4760); + mw.Write((ushort)0xDEFE); + mw.Write((uint)text.peWriter.Headers.OptionalHeader.ImageBase + text.moduleBuilder.unmanagedExports[pos].rva.initializedDataOffset + sdataRVA); + break; default: throw new NotSupportedException(); } @@ -689,6 +699,10 @@ namespace IKVM.Reflection.Writer type = 0xA000; rva = stubsRVA + 2; break; + case IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_ARM: + type = 0x3000; + rva = stubsRVA + 12; + break; default: throw new NotSupportedException(); }