From 8c9ab72f97c11f96c09e4be5dc75b01918a7cff7 Mon Sep 17 00:00:00 2001 From: "Denis Kuzmin [ GitHub/3F ]" Date: Wed, 11 Dec 2019 23:29:06 +0300 Subject: [PATCH] CoreCLR \ ILAsm 4.700.2 with an implemented `/REBASE` feature. Fixes #125 --- .../DllExportAppDomainIsolatedTask.cs | 6 +++ .../DllExportTask.cs | 6 +++ .../ExportTaskImplementation.cs | 6 +++ RGiesecke.DllExport/IInputValues.cs | 6 +++ RGiesecke.DllExport/InputValuesCore.cs | 6 +++ RGiesecke.DllExport/Parsing/ILAsm.cs | 42 +++++++++++++------ coreclr | 2 +- packages.config | 2 +- tools/net.r_eg.DllExport.targets | 2 + 9 files changed, 64 insertions(+), 14 deletions(-) diff --git a/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportAppDomainIsolatedTask.cs b/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportAppDomainIsolatedTask.cs index b4377d5..deab171 100644 --- a/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportAppDomainIsolatedTask.cs +++ b/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportAppDomainIsolatedTask.cs @@ -324,6 +324,12 @@ public string OurILAsmPath } } + public bool SysObjRebase + { + get => _ExportTaskImplementation.SysObjRebase; + set => _ExportTaskImplementation.SysObjRebase = value; + } + public string MetaLib { get { diff --git a/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportTask.cs b/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportTask.cs index 9116d89..dad9237 100644 --- a/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportTask.cs +++ b/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/DllExportTask.cs @@ -331,6 +331,12 @@ public string OurILAsmPath } } + public bool SysObjRebase + { + get => _ExportTaskImplementation.SysObjRebase; + set => _ExportTaskImplementation.SysObjRebase = value; + } + public string MetaLib { get { diff --git a/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/ExportTaskImplementation.cs b/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/ExportTaskImplementation.cs index d0053b0..ab0c534 100644 --- a/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/ExportTaskImplementation.cs +++ b/RGiesecke.DllExport.MSBuild/RGiesecke.DllExport.MSBuild/ExportTaskImplementation.cs @@ -258,6 +258,12 @@ public string OurILAsmPath } } + public bool SysObjRebase + { + get => _Values.SysObjRebase; + set => _Values.SysObjRebase = value; + } + public string MetaLib { get { diff --git a/RGiesecke.DllExport/IInputValues.cs b/RGiesecke.DllExport/IInputValues.cs index ee124fa..9b957e0 100644 --- a/RGiesecke.DllExport/IInputValues.cs +++ b/RGiesecke.DllExport/IInputValues.cs @@ -92,6 +92,12 @@ string OurILAsmPath set; } + bool SysObjRebase + { + get; + set; + } + string MetaLib { get; diff --git a/RGiesecke.DllExport/InputValuesCore.cs b/RGiesecke.DllExport/InputValuesCore.cs index 4c89750..e9c4849 100644 --- a/RGiesecke.DllExport/InputValuesCore.cs +++ b/RGiesecke.DllExport/InputValuesCore.cs @@ -95,6 +95,12 @@ public string OurILAsmPath set; } + public bool SysObjRebase + { + get; + set; + } + public string MetaLib { get; diff --git a/RGiesecke.DllExport/Parsing/ILAsm.cs b/RGiesecke.DllExport/Parsing/ILAsm.cs index fe51441..0577391 100644 --- a/RGiesecke.DllExport/Parsing/ILAsm.cs +++ b/RGiesecke.DllExport/Parsing/ILAsm.cs @@ -403,17 +403,8 @@ private string GetCommandLineArguments(CpuPlatform cpu, string fileName, string keyFile = "\"/Key=" + keyFile + '"'; } - string cvtres; - if(!String.IsNullOrWhiteSpace(InputValues.OurILAsmPath)) { - // https://github.com/3F/coreclr/issues/2 - // Only our new ILAsm 4.5.1+ may detect cvtres.exe automatically if the path is not presented at all. However, we can also provide CVR key - cvtres = String.IsNullOrWhiteSpace(InputValues.FrameworkPath) ? "" : $"/CVRES=\"{InputValues.FrameworkPath}/\""; - } - else { - cvtres = String.Empty; // original coreclr \ ILAsm does not support /CVRES - } - - return String.Format( + return string.Format + ( CultureInfo.InvariantCulture, "/nologo \"/out:{0}\" \"{1}.il\" {2} {3} {4} {5} {6} {7}", fileName, @@ -423,8 +414,35 @@ private string GetCommandLineArguments(CpuPlatform cpu, string fileName, string InputValues.EmitDebugSymbols ? "/debug" : "/optimize", cpu == CpuPlatform.X86 ? "" : (" /PE64 " + (cpu == CpuPlatform.Itanium ? " /ITANIUM" : " /X64")), keyFile, - cvtres + GetKeysToCustomILAsm() ); } + + /// + /// Keys to modified coreclr \ ILAsm + /// + private string GetKeysToCustomILAsm() + { + if(string.IsNullOrWhiteSpace(InputValues.OurILAsmPath)) + { + return string.Empty; + } + + var sb = new StringBuilder(); + + // https://github.com/3F/coreclr/issues/2 + // Our custom ILAsm 4.5.1+ may automatically detect cvtres if the path is not presented at all + if(!string.IsNullOrWhiteSpace(InputValues.FrameworkPath)) + { + sb.Append($" /CVRES=\"{InputValues.FrameworkPath}/\""); + } + + if(InputValues.SysObjRebase) + { + sb.Append(" /REBASE"); + } + + return sb.ToString(); + } } } diff --git a/coreclr b/coreclr index 04dc351..4fde65a 160000 --- a/coreclr +++ b/coreclr @@ -1 +1 @@ -Subproject commit 04dc351c1487a13773e2a85b749258e03d7c0fac +Subproject commit 4fde65a5695d8d4c2f73959e71fb38357ae02a28 diff --git a/packages.config b/packages.config index 902f6e3..da9a50b 100644 --- a/packages.config +++ b/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/tools/net.r_eg.DllExport.targets b/tools/net.r_eg.DllExport.targets index 124c0e0..18751d4 100644 --- a/tools/net.r_eg.DllExport.targets +++ b/tools/net.r_eg.DllExport.targets @@ -63,6 +63,7 @@ $(NoDllExportsForAnyCpu) true false + false 1 false @@ -95,6 +96,7 @@ OurILAsmPath="$(DllExportOurILAsmPath)" MetaLib="$(DllExportMetaLibFullPath)" PeCheckRaw="$(DllExportPeCheck)" + SysObjRebase="$(DllExportSysObjRebase)" />