diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2018-08-01 16:13:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 16:13:42 +0300 |
commit | 697c70b9942f5b5c104f196b399e12dfb8a323bf (patch) | |
tree | 22ed77903d578039dbb503f40b132219c8e5a854 /src | |
parent | 624c08c152ea68e2d5a2ede3d68ec725bf3bed66 (diff) | |
parent | 9d2773ed9e1fb3dc13db678df3e2b24c446a24bd (diff) |
Merge pull request #6164 from dotnet/nmirror
Merge nmirror to master
Diffstat (limited to 'src')
4 files changed, 47 insertions, 5 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/MrtProcessedExportAddressTableNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/MrtProcessedExportAddressTableNode.cs index 2981c0381..40c60b8bd 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/MrtProcessedExportAddressTableNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/MrtProcessedExportAddressTableNode.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Linq; using System.Collections.Generic; using Internal.Text; @@ -24,7 +25,7 @@ namespace ILCompiler.DependencyAnalysis _factory = factory; } - public event Func<uint, IExportableSymbolNode, bool> ReportExportedItem; + public event Func<uint, IExportableSymbolNode, uint> ReportExportedItem; public event Func<uint> GetInitialExportOrdinal; public void AddExportableSymbol(IExportableSymbolNode exportableSymbol) @@ -69,6 +70,13 @@ namespace ILCompiler.DependencyAnalysis builder.RequireInitialPointerAlignment(); builder.AddSymbol(this); + // + // Entries in the export table need to be sorted by ordinals. When compiling using baseline TOC files, we reuse + // the ordinals from the baseline for sorting, otherwise we start assigning new sequential ordinals. Export entries that do + // not exist in the baseline will get new sequential ordinals, but for determinism, they are also pre-sorted using the + // CompilerComparer logic + // + ISortableSymbolNode[] symbolNodes = new ISortableSymbolNode[_exportableSymbols.Count]; _exportableSymbols.CopyTo(symbolNodes); Array.Sort(symbolNodes, new CompilerComparer()); @@ -77,12 +85,17 @@ namespace ILCompiler.DependencyAnalysis builder.EmitInt(symbolNodes.Length); // Count of exported symbols in this table uint index = GetInitialExportOrdinal == null ? 1 : GetInitialExportOrdinal(); + Dictionary<uint, ISortableSymbolNode> symbolsOridnalMap = new Dictionary<uint, ISortableSymbolNode>(); foreach (ISortableSymbolNode symbol in symbolNodes) { - builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_REL32); - bool? baselineOrdinalFound = ReportExportedItem?.Invoke(index, (IExportableSymbolNode)symbol); - if (baselineOrdinalFound.HasValue && !baselineOrdinalFound.Value) - index++; + uint indexUsed = ReportExportedItem.Invoke(index, (IExportableSymbolNode)symbol); + symbolsOridnalMap.Add(indexUsed, symbol); + index += (indexUsed == index ? (uint)1 : 0); + } + + foreach (uint ordinal in symbolsOridnalMap.Keys.OrderBy(o => o)) + { + builder.EmitReloc(symbolsOridnalMap[ordinal], RelocType.IMAGE_REL_BASED_REL32); } return builder.ToObjectData(); diff --git a/src/System.Private.CoreLib/src/Resources/Strings.resx b/src/System.Private.CoreLib/src/Resources/Strings.resx index 5b870d38b..1cfdaaa76 100644 --- a/src/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/System.Private.CoreLib/src/Resources/Strings.resx @@ -2392,6 +2392,9 @@ <data name="Serialization_DateTimeTicksOutOfRange" xml:space="preserve"> <value>Invalid serialized DateTime data. Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.</value> </data> + <data name="FeatureRemoved_Message" xml:space="preserve"> + <value>Code to support feature '{0}' was removed during publishing. If this is in error, update the project configuration to not disable feature '{0}'.</value> + </data> <data name="Arg_InvalidANSIString" xml:space="preserve"> <value>The ANSI string passed in could not be converted from the default ANSI code page to Unicode.</value> </data> diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj index 605b68f64..ee7b79f3b 100644 --- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -149,6 +149,7 @@ <Compile Include="Interop\Interop.manual.cs" /> <Compile Include="Interop\Interop.WinRT.cs" Condition="'$(EnableWinRT)' == 'true'" /> <Compile Include="System\Runtime\CompilerServices\CastableObject.cs" /> + <Compile Include="System\Runtime\CompilerServices\FeatureRemovedException.cs" /> <Compile Include="System\Reflection\AssemblyNameHelpers.StrongName.cs" /> <Compile Include="System\Reflection\AssemblyNameHelpers.cs" /> <Compile Include="System\Reflection\AssemblyNameLexer.cs" /> diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/FeatureRemovedException.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/FeatureRemovedException.cs new file mode 100644 index 000000000..fce17a87f --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/FeatureRemovedException.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Runtime.CompilerServices +{ + // Exception to be thrown when a feature was removed during publishing. + internal sealed class FeatureRemovedException : Exception + { + public string FeatureName { get; } + + public FeatureRemovedException(string featureName) + { + FeatureName = featureName; + } + + public override string Message + { + get + { + return SR.Format(SR.FeatureRemoved_Message, FeatureName); + } + } + } +} |