Skip to content

Commit

Permalink
Clarify header format
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed May 1, 2017
1 parent ec9b2d4 commit b1ac2aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion docs/features/refout.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ When the compiler produces documentation, the contents produced will match the A

The compilation from the command-line will either produce both assemblies (implementation and ref) or neither. There is no "partial success" scenario.


### CscTask/CoreCompile
The `CoreCompile` target will support a new output, called `IntermediateRefAssembly`, which parallels the existing `IntermediateAssembly`.
The `Csc` task will support a new output, called `OutputRefAssembly`, which parallels the existing `OutputAssembly`.
Expand Down
17 changes: 11 additions & 6 deletions src/Compilers/Core/MSBuildTask/MvidReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ private static Guid ReadAssemblyMvidOrEmpty(BinaryReader reader)
return empty;
}

// DOS Header: PE (2)
if (reader.ReadUInt16() != 0x5a4d)
// DOS Header: Magic number (2)
if (reader.ReadUInt16() != 0x5a4d) // "MZ"
{
return empty;
}

// DOS Header: Start (58)
Skip(58, reader);
// DOS Header: Address of PE Signature (at 0x3C)
MoveTo(0x3C, reader);
uint lfanew = reader.ReadUInt32();

// DOS Header: Address of PE Signature
MoveTo(reader.ReadUInt32(), reader);
MoveTo(lfanew, reader); // jump over the MS DOS Stub to the PE Signature

// PE Signature ('P' 'E' null null)
if (reader.ReadUInt32() != 0x00004550)
Expand Down Expand Up @@ -65,6 +65,11 @@ private static Guid ReadAssemblyMvidOrEmpty(BinaryReader reader)

private static Guid FindMvidInSections(ushort count, BinaryReader reader)
{
if (count == 0)
{
return Guid.Empty;
}

// .mvid section must be first, if it's there
// Section: Name (8)
byte[] name = reader.ReadBytes(8);
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/PEWriter/ExtendedPEBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal sealed class ExtendedPEBuilder
private Blob _mvidSectionFixup = default(Blob);

// Only include the .mvid section in ref assemblies
private bool _withMvidSection;
private readonly bool _withMvidSection;

public ExtendedPEBuilder(
PEHeaderBuilder header,
Expand Down

0 comments on commit b1ac2aa

Please sign in to comment.