Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@monojenkins
Copy link
Contributor

Sometimes, ILasm apparently can produce images with a size 0 Blob heap. In cases where we're loading assembly references from such an image, the hash (which is optional) can be at index = 0 and the Blob heap size is also 0.

Also: add the hash value to the output of monodis --assemblyref

Also: patch PEAPI (used by mono's ilasm) to emit a size 0 Blob heap if no blobs are added. Previously it would unconditionally emit the index 0 entry (a single zero byte - required by ECMA 335 II.24.2.) Now it will only emit the index 0 entry only if the MetaDataStream.Add methods are called.

Related to #10332

Backport of #18313.

/cc @lambdageek

Sometimes ILasm can produce images with a Blob heap of size 0.  In cases where
we're loading assembly references from such an image, the hash (which is
optional) can be at index = 0 and the Blob heap size is also 0.

Also: add the hash value to the output of `monodis --assemblyref`
ECMA 335 II.24.2.4 says that the user string and blob heaps should have an
entry at index 0 consisting of the single byte 0.  However .NET Framework (and
.NET Core) ilasm will entirely omit the Blob heap (that is, create a blob heap
entry of size 0) if it is not needed.  This PR changes Mono's ILASM to emit the
initial byte on demand only if one of the MetaDataStream.Add() methods is
called. Otherwise we will also emit a stream of size 0.

This is needed to compile some test cases.
Depends on ILASM that can emit a size 0 Blob heap
And a comment explaining how it is likely to be triggered.  If the assembly is
reasonable the caller of mono_metadata_blob_heap should be updated to use
mono_metadata_blob_heap_null_ok instead
@lambdageek lambdageek merged commit 2faea92 into mono:2019-10 Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants