Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public GCRefMapNode(ImportSectionNode importSection)

public int Offset => 0;

public bool IsEmpty => _methods.Count == 0;

public void AddImport(Import import)
{
lock (_methods)
Expand All @@ -53,9 +55,9 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
if (_methods.Count == 0 || relocsOnly)
{
return new ObjectData(
data: Array.Empty<byte>(),
relocs: Array.Empty<Relocation>(),
alignment: 1,
data: Array.Empty<byte>(),
relocs: Array.Empty<Relocation>(),
alignment: 1,
definedSymbols: new ISymbolDefinitionNode[] { this });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ protected override int GetAlignmentRequirement(NodeFactory factory)
private readonly byte _entrySize;
private readonly string _name;
private readonly bool _emitPrecode;
private readonly bool _emitGCRefMap;

private bool _materializedSignature;

Expand All @@ -52,12 +51,11 @@ public ImportSectionNode(string name, ReadyToRunImportSectionType importType, Re
_flags = flags;
_entrySize = entrySize;
_emitPrecode = emitPrecode;
_emitGCRefMap = emitGCRefMap;

_imports = new ImportTable(_name + "_ImportBegin", entrySize);
_signatures = new ArrayOfEmbeddedPointersNode<Signature>(_name + "_SigBegin", new EmbeddedObjectNodeComparer(CompilerComparer.Instance));
_signatureList = new List<Signature>();
_gcRefMap = _emitGCRefMap ? new GCRefMapNode(this) : null;
_gcRefMap = emitGCRefMap ? new GCRefMapNode(this) : null;
}

public void MaterializeSignature(NodeFactory r2rFactory)
Expand Down Expand Up @@ -89,10 +87,7 @@ public void AddImport(NodeFactory factory, Import import)
_signatureList.Add(import.ImportSignature.Target);
}

if (_emitGCRefMap)
{
_gcRefMap.AddImport(import);
}
_gcRefMap?.AddImport(import);
}

public string Name => _name;
Expand Down Expand Up @@ -135,8 +130,10 @@ public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory f
dataBuilder.EmitUInt(0);
}

if (_emitGCRefMap)
// If we emit an Rva for an empty gcrefmap, it will have no size header and be impossible for r2rdump to read correctly
if (_gcRefMap?.IsEmpty == false)
{
// This indirectly generates the AuxiliaryDataRva by emitting a placeholder 0 which will be replaced later
dataBuilder.EmitReloc(_gcRefMap, RelocType.IMAGE_REL_BASED_ADDR32NB, 0);
}
else
Expand All @@ -149,7 +146,7 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
{
yield return new DependencyListEntry(_imports, "Import section fixup data");
yield return new DependencyListEntry(_signatures, "Import section signatures");
if (_emitGCRefMap)
if (_gcRefMap != null)
{
yield return new DependencyListEntry(_gcRefMap, "GC ref map");
}
Expand Down
3 changes: 1 addition & 2 deletions src/tests/Common/CLRTest.CrossGen.targets
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
done

echo -o:"$__OutputFile" >> "$__ResponseFile"
## Enable once #114504 is fixed
## echo -O >> "$__ResponseFile"
echo -O >> "$__ResponseFile"
echo --targetarch:$(TargetArchitecture) >> "$__ResponseFile"
echo --targetos:$(TargetOS) >> "$__ResponseFile"
echo --verify-type-and-field-layout >> "$__ResponseFile"
Expand Down
Loading