Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFadi Hanna <fadim@microsoft.com>2018-07-30 22:15:55 +0300
committerFadi Hanna <fadim@microsoft.com>2018-07-30 22:15:55 +0300
commitc914d512544e88a31332af7e643efa01d43e5cbc (patch)
tree37ac526d99d41726d7834984b1588b833b8fd865 /src/ILCompiler.Compiler
parentd23b7f190431b216c45eed3444012a6565b45668 (diff)
Entries in the export table were not correctly sorted based on ordinals, but were emitted based on the ISortableNode sorting logic. This doesn't work with targeted patching
[tfs-changeset: 1709015]
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/MrtProcessedExportAddressTableNode.cs23
1 files changed, 18 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();