-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[mono][wasm] Bundle assemblies as WebCIL #79416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
c55c696
Implement WebCIL loader; on by default
lambdageek 45bc3c9
Checkpoint works on wasm sample; add design doc
lambdageek c2739da
Remove unused fields
lambdageek c58670b
fixup markdown
lambdageek 851ebde
remove unused var
lambdageek fa812be
specify FileAccess
lambdageek 6a7b411
FileShare
lambdageek 708368b
Push .dll->.webcil probing lower in the bundle logic
lambdageek 509c219
Also convert satellite assemblies
lambdageek 79d0770
satellite matching
lambdageek 38ddc99
fixup asset entry
lambdageek 91bbbce
[wasm] don't leak .webcil image names to the debugger
lambdageek c2650d2
fix one other PE file check
lambdageek b045d04
Add PE DebugTableDirectory to webcil
lambdageek 7eb3231
fix windows build
lambdageek 599500b
Implement a WebcilReader for BorwserDebugProxy like PEReader
lambdageek 7d5aa77
REVERT ME: temporarily don't try to read codeview data for webcil
lambdageek 68905aa
[debug] Match bundled pdbs if we're looking up .webcil files
lambdageek 68da344
be less verbose
lambdageek 1db11d1
Adjust debug directory entries when writing webcil files
lambdageek 784f809
Fix bug in WebcilWriter
lambdageek 111d398
bugfix: the debug directory is at pe_debug_rva not at the CLI header
lambdageek 5541a3b
skip debug fixups if there's no debug directory
lambdageek c0bb6c6
WebcilReader: implement CodeView and Emebedded PPDB support
lambdageek e44841c
[WBT] Add UseWebcil option (default to true)
lambdageek 96b6a1d
rename WebcilWriter -> WebcilConverter [NFC]
lambdageek 2cd2c92
fixup AssemblyLoadedEventTest
lambdageek c3b7726
hack: no extension on assembly for breakpoint
lambdageek 4f25760
pass normal .dll name for MainAssemblyName in config
lambdageek d82140f
Wasm.Debugger.Tests: give CI 10 more minutes
lambdageek c1d5169
Add Microsoft.NET.WebAssembly.Webcil assembly project
lambdageek 3a07787
Move WebcilConverter to Microsoft.NET.WebAssembly.Webcil
lambdageek d507f64
Move WebcilReader to Microsoft.NET.WebAssembly.Webcil
lambdageek 6c6cae5
make the webcil magic and version longer
lambdageek d9a4d25
fixups
lambdageek ac0404b
Code style improvements from review
lambdageek 0cedacc
Improve some exception messages, when possible
lambdageek dadbf4a
Suggestings from code review
lambdageek 73d57a4
Add WasmEnableWebcil msbuild property. Off by default
lambdageek f0f6340
Build non-wasm runtimes without .webcil support
lambdageek a2d4cbb
XXX HACK - Remove - turn on webcil by default on browser-wasm
lambdageek 388dc2c
Run WBT twice: with and without webcil
lambdageek 1abe30a
do the cartesian product correctly in msbuild
lambdageek 29c5234
Revert "XXX HACK - Remove - turn on webcil by default on browser-wasm"
lambdageek 3b6bef2
also add webcil to template projects
lambdageek 4ab4f8f
environment variable has to be non-null and "true"
lambdageek 5741cb8
Fix wasm work items
lambdageek 61fef73
Update src/libraries/sendtohelix-wasm.targets
lambdageek 81b8bce
FIXME: why is this crashing in MetadataLoadContext
lambdageek a795f9e
PInvokeTableGeneratorTests: don't try to use the net472 WasmAppBuilder
lambdageek 0473ec1
PInvokeTableGeneratorTests: Add more diagnostic output if tasksDir is…
lambdageek 56addec
nullability
lambdageek 52b195a
simplify prefix comparison in bundled_assembly_match
lambdageek a176400
WasmAppBuilder improve logging
lambdageek 67d64e3
Add missing using
lewing 5983e65
XXX REVERT ME - temporarily disable dedup
lambdageek d7b3640
Revert "XXX REVERT ME - temporarily disable dedup"
lambdageek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# WebCIL assembly format | ||
|
||
## Version | ||
|
||
This is version 0.0 of the Webcil format. | ||
|
||
## Motivation | ||
|
||
When deploying the .NET runtime to the browser using WebAssembly, we have received some reports from | ||
customers that certain users are unable to use their apps because firewalls and anti-virus software | ||
may prevent browsers from downloading or caching assemblies with a .DLL extension and PE contents. | ||
|
||
This document defines a new container format for ECMA-335 assemblies | ||
that uses the `.webcil` extension and uses a new WebCIL container | ||
format. | ||
|
||
|
||
## Specification | ||
|
||
As our starting point we take section II.25.1 "Structure of the | ||
runtime file format" from ECMA-335 6th Edition. | ||
|
||
| | | ||
|--------| | ||
| PE Headers | | ||
| CLI Header | | ||
| CLI Data | | ||
| Native Image Sections | | ||
| | | ||
|
||
|
||
|
||
A Webcil file follows a similar structure | ||
|
||
|
||
| | | ||
|--------| | ||
| Webcil Headers | | ||
| CLI Header | | ||
| CLI Data | | ||
| | | ||
|
||
## Webcil Headers | ||
|
||
The Webcil headers consist of a Webcil header followed by a sequence of section headers. | ||
(All multi-byte integers are in little endian format). | ||
|
||
### Webcil Header | ||
|
||
``` c | ||
struct WebcilHeader { | ||
uint8_t id[4]; // 'W' 'b' 'I' 'L' | ||
// 4 bytes | ||
uint16_t version_major; // 0 | ||
uint16_t version_minor; // 0 | ||
// 8 bytes | ||
uint16_t coff_sections; | ||
uint16_t reserved0; // 0 | ||
// 12 bytes | ||
|
||
uint32_t pe_cli_header_rva; | ||
uint32_t pe_cli_header_size; | ||
// 20 bytes | ||
|
||
uint32_t pe_debug_rva; | ||
uint32_t pe_debug_size; | ||
// 28 bytes | ||
}; | ||
``` | ||
|
||
The Webcil header starts with the magic characters 'W' 'b' 'I' 'L' followed by the version in major | ||
minor format (must be 0 and 0). Then a count of the section headers and two reserved bytes. | ||
|
||
The next pairs of integers are a subset of the PE Header data directory specifying the RVA and size | ||
of the CLI header, as well as the directory entry for the PE debug directory. | ||
|
||
|
||
### Section header table | ||
|
||
Immediately following the Webcil header is a sequence (whose length is given by `coff_sections` | ||
above) of section headers giving their virtual address and virtual size, as well as the offset in | ||
the Webcil file and the size in the file. This is a subset of the PE section header that includes | ||
enough information to correctly interpret the RVAs from the webcil header and from the .NET | ||
metadata. Other information (such as the section names) are not included. | ||
|
||
``` c | ||
struct SectionHeader { | ||
uint32_t st_virtual_size; | ||
uint32_t st_virtual_address; | ||
uint32_t st_raw_data_size; | ||
uint32_t st_raw_data_ptr; | ||
}; | ||
``` | ||
|
||
### Sections | ||
|
||
Immediately following the section table are the sections. These are copied verbatim from the PE file. | ||
|
||
## Rationale | ||
|
||
The intention is to include only the information necessary for the runtime to locate the metadata | ||
root, and to resolve the RVA references in the metadata (for locating data declarations and method IL). | ||
|
||
A goal is for the files not to be executable by .NET Framework. | ||
|
||
Unlike PE files, mixing native and managed code is not a goal. | ||
|
||
Lossless conversion from Webcil back to PE is not intended to be supported. The format is being | ||
documented in order to support diagnostic tooling and utilities such as decompilers, disassemblers, | ||
file identification utilities, dependency analyzers, etc. | ||
|
11 changes: 11 additions & 0 deletions
11
src/libraries/Microsoft.NET.WebAssembly.Webcil/Directory.Build.props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project> | ||
<Import Project="..\Directory.Build.props" /> | ||
<PropertyGroup> | ||
<IsShipping>true</IsShipping> | ||
<!-- this assembly should not produce a public package, rather it's meant to be shipped by the | ||
WasmAppBuilder task and the BrowserDebugProxy --> | ||
<IsShippingPackage>false</IsShippingPackage> | ||
<!-- This isn't a public API in a public package, don't ship documentation xml in the nugets that consume this assembly --> | ||
<GenerateDocumentationFile>false</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
</Project> |
7 changes: 7 additions & 0 deletions
7
src/libraries/Microsoft.NET.WebAssembly.Webcil/src/Common/IsExternalInit.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
internal sealed class IsExternalInit { } | ||
} |
24 changes: 24 additions & 0 deletions
24
src/libraries/Microsoft.NET.WebAssembly.Webcil/src/Microsoft.NET.WebAssembly.Webcil.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>$(NetCoreAppToolCurrent);$(NetFrameworkToolCurrent)</TargetFrameworks> | ||
radical marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
<Description>Abstractions for modifying .NET webcil binary images</Description> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<Serviceable>true</Serviceable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLSCompliant>false</CLSCompliant> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- we need to keep the version of System.Reflection.Metadata in sync with dotnet/msbuild and dotnet/sdk --> | ||
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" /> | ||
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Webcil\**\*.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'"> | ||
<Compile Include="Common\IsExternalInit.cs" /> | ||
</ItemGroup> | ||
radical marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
</Project> |
10 changes: 10 additions & 0 deletions
10
src/libraries/Microsoft.NET.WebAssembly.Webcil/src/Webcil/Internal/Constants.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.NET.WebAssembly.Webcil.Internal; | ||
|
||
internal static unsafe class Constants | ||
{ | ||
public const int WC_VERSION_MAJOR = 0; | ||
public const int WC_VERSION_MINOR = 0; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/libraries/Microsoft.NET.WebAssembly.Webcil/src/Webcil/WebciHeader.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
namespace Microsoft.NET.WebAssembly.Webcil; | ||
|
||
/// <summary> | ||
/// The header of a WebCIL file. | ||
/// </summary> | ||
/// | ||
/// <remarks> | ||
/// The header is a subset of the PE, COFF and CLI headers that are needed by the mono runtime to load managed assemblies. | ||
/// </remarks> | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
public unsafe struct WebcilHeader | ||
{ | ||
public fixed byte id[4]; // 'W' 'b' 'I' 'L' | ||
// 4 bytes | ||
public ushort version_major; // 0 | ||
public ushort version_minor; // 0 | ||
// 8 bytes | ||
|
||
public ushort coff_sections; | ||
public ushort reserved0; // 0 | ||
// 12 bytes | ||
public uint pe_cli_header_rva; | ||
public uint pe_cli_header_size; | ||
// 20 bytes | ||
public uint pe_debug_rva; | ||
public uint pe_debug_size; | ||
// 28 bytes | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.