Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -50,20 +52,22 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)

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,
definedSymbols: new ISymbolDefinitionNode[] { this });
}
if (relocsOnly)
return new ObjectData(Array.Empty<byte>(), Array.Empty<Relocation>(), 1, new ISymbolDefinitionNode[] { this });

_methods.MergeSort(CompilerComparer.Instance);
GCRefMapBuilder builder = new GCRefMapBuilder(factory.Target, relocsOnly);

builder.Builder.RequireInitialAlignment(4);
builder.Builder.AddSymbol(this);

if (_methods.Count == 0)
{
// Always generate a size header
builder.Builder.EmitInt(0);
return builder.Builder.ToObjectData();
}

// First, emit the initial ref map offset and reserve the offset map entries
int offsetCount = _methods.Count / GCREFMAP_LOOKUP_STRIDE;
builder.Builder.EmitInt((offsetCount + 1) * sizeof(int));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory f
dataBuilder.EmitUInt(0);
}

if (_emitGCRefMap)
if (_emitGCRefMap && !_gcRefMap.IsEmpty)
{
// 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 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