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:
authordotnet-bot <dotnet-bot@microsoft.com>2017-10-12 18:50:56 +0300
committerdotnet-bot <dotnet-bot@microsoft.com>2017-10-12 18:50:56 +0300
commit26170b1b8f1d63345fe38b9da2e48d9a787a7500 (patch)
tree7cbecf0a0e80752c3ac7126eba1463ffcd3855fa /src/ILCompiler.Compiler
parentf686aea070a295e7b66bc978420b83e280521467 (diff)
ProjectX: Ensure stable name uniqueness for read-only data blobs
The current naming scheme for data blobs is not deterministic. This is fixed in this change by using the sha256 hasher to ensure a high degree of stable uniqueness. However, this might be a chance the uniqueness is violated. Debug code is added to detect this. [tfs-changeset: 1677971]
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/UtcNameMangler.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/UtcNameMangler.cs b/src/ILCompiler.Compiler/src/Compiler/UtcNameMangler.cs
index 0388e3860..2ff113ac8 100644
--- a/src/ILCompiler.Compiler/src/Compiler/UtcNameMangler.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/UtcNameMangler.cs
@@ -611,6 +611,21 @@ namespace ILCompiler
return mangledName;
}
+ public string GetMangledDataBlobName(byte[] blob)
+ {
+ if (_sha256 == null)
+ {
+ // Use SHA256 hash here to provide a high degree of uniqueness to symbol names without requiring them to be long
+ // This hash function provides an exceedingly high likelihood that no two strings will be given equal symbol names
+ // This is not considered used for security purpose; however collisions would be highly unfortunate as they will cause compilation
+ // failure.
+ _sha256 = SHA256.Create();
+ }
+
+ var hash = _sha256.ComputeHash(blob);
+ return "__Data_" + BitConverter.ToString(hash).Replace("-", "");
+ }
+
public string GetImportedTlsIndexPrefix()
{
uint ordinal;