Skip to content
Closed
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 @@ -151,6 +151,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="-Wl,-segprot,__THUNKS,rx,rx" Condition="'$(_IsiOSLikePlatform)' == 'true'" />
<LinkerArg Include="@(NativeFramework->'-framework %(Identity)')" Condition="'$(_IsApplePlatform)' == 'true'" />
<LinkerArg Include="-Wl,--eh-frame-hdr" Condition="'$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="-Wl,--icf=all" Condition="'$(LinkerFlavor)' == 'lld' or '$(LinkerFlavor)' == 'gold'" />
Copy link
Member

@am11 am11 Jun 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<LinkerArg Include="-Wl,--icf=all" Condition="'$(LinkerFlavor)' == 'lld' or '$(LinkerFlavor)' == 'gold'" />
<LinkerArg Include="-Wl,--icf=all" Condition="'$(_IsApplePlatform)' != 'true' and '$(LinkerFlavor)' != 'bfd'" />

as mold also supports it.

</ItemGroup>

<Exec Command="command -v &quot;$(CppLinker)&quot;" IgnoreExitCode="true" StandardOutputImportance="Low">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ public bool IsStandardSection
{
get
{
return this == DataSection || this == ReadOnlyDataSection || this == FoldableReadOnlyDataSection || this == TextSection || this == XDataSection || this == BssSection;
return this == DataSection
|| this == ReadOnlyDataSection
|| this == FoldableReadOnlyDataSection
|| this == TextSection
|| this == FoldableTextSection
|| this == XDataSection
|| this == BssSection;
}
}

Expand All @@ -46,6 +52,7 @@ public bool IsStandardSection
public static readonly ObjectNodeSection ReadOnlyDataSection = new ObjectNodeSection("rdata", SectionType.ReadOnly);
public static readonly ObjectNodeSection FoldableReadOnlyDataSection = new ObjectNodeSection("rdata", SectionType.ReadOnly);
public static readonly ObjectNodeSection TextSection = new ObjectNodeSection("text", SectionType.Executable);
public static readonly ObjectNodeSection FoldableTextSection = new ObjectNodeSection("text", SectionType.Executable);
public static readonly ObjectNodeSection TLSSection = new ObjectNodeSection("TLS", SectionType.Writeable);
public static readonly ObjectNodeSection BssSection = new ObjectNodeSection("bss", SectionType.Uninitialized);
public static readonly ObjectNodeSection HydrationTargetSection = new ObjectNodeSection("hydrated", SectionType.Uninitialized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,21 @@ private void Validate()

public virtual ObjectNodeSection DictionarySection(NodeFactory factory)
{
if (factory.Target.IsWindows)
(ObjectNodeSection foldableSection, ObjectNodeSection unfoldableSection) = factory.Target.OperatingSystem switch
{
if (_owningMethodOrType is TypeDesc)
{
return ObjectNodeSection.FoldableReadOnlyDataSection;
}
else
{
// Method dictionary serves as an identity at runtime which means they are not foldable.
Debug.Assert(_owningMethodOrType is MethodDesc);
return ObjectNodeSection.ReadOnlyDataSection;
}
TargetOS.Windows => (ObjectNodeSection.FoldableReadOnlyDataSection, ObjectNodeSection.ReadOnlyDataSection),
_ => (ObjectNodeSection.FoldableTextSection, ObjectNodeSection.TextSection),
};

if (_owningMethodOrType is TypeDesc)
{
return foldableSection;
}
else
{
return ObjectNodeSection.DataSection;
// Method dictionary serves as an identity at runtime which means they are not foldable.
Debug.Assert(_owningMethodOrType is MethodDesc);
return unfoldableSection;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override ObjectNodeSection GetSection(NodeFactory factory)
if (factory.Target.IsWindows)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract this piece of logic into a helper method on ObjectNodeSection or NodeFactory so that we do not need to fix up a bunch of places everytime a new right way to do foldable readonly data sections shows up?

return ObjectNodeSection.FoldableReadOnlyDataSection;
else
return ObjectNodeSection.DataSection;
return ObjectNodeSection.FoldableTextSection;
}

public override bool StaticDependenciesAreComputed => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override ObjectNodeSection GetSection(NodeFactory factory)
if (factory.Target.IsWindows)
return ObjectNodeSection.FoldableReadOnlyDataSection;
else
return ObjectNodeSection.DataSection;
return ObjectNodeSection.FoldableTextSection;
}

public override bool IsShareable => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override ObjectNodeSection GetSection(NodeFactory factory)
if (factory.Target.IsWindows)
return ObjectNodeSection.FoldableReadOnlyDataSection;
else
return ObjectNodeSection.DataSection;
return ObjectNodeSection.FoldableTextSection;
}

public override bool IsShareable => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override ObjectNodeSection GetSection(NodeFactory factory)
if (factory.Target.IsWindows)
return ObjectNodeSection.FoldableReadOnlyDataSection;
else
return ObjectNodeSection.DataSection;
return ObjectNodeSection.FoldableTextSection;
}

protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFactory factory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public MethodExceptionHandlingInfoNode(MethodDesc owningMethod, ObjectData data)

public override ObjectNodeSection GetSection(NodeFactory factory) => _owningMethod.Context.Target.IsWindows
? ObjectNodeSection.FoldableReadOnlyDataSection
: ObjectNodeSection.DataSection;
: ObjectNodeSection.FoldableTextSection;

public override bool StaticDependenciesAreComputed => true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public class ObjectWriter : IDisposable, ITypesDebugInfoWriter
private NodeFactory _nodeFactory;
private readonly bool _isSingleFileCompilation;

// Unix section containing LSDA data, like EH Info and GC Info
public static readonly ObjectNodeSection LsdaSection = new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly);

private UserDefinedTypeDescriptor _userDefinedTypeDescriptor;

#if DEBUG
Expand Down Expand Up @@ -610,7 +607,7 @@ public void BuildCFIMap(NodeFactory factory, ObjectNode node)
int len = frameInfo.BlobData.Length;
byte[] blob = frameInfo.BlobData;

ObjectNodeSection lsdaSection = LsdaSection;
ObjectNodeSection lsdaSection = ObjectNodeSection.TextSection;
if (ShouldShareSymbol(node))
{
lsdaSection = GetSharedSection(lsdaSection, ((ISymbolNode)node).GetMangledName(_nodeFactory.NameMangler));
Expand Down Expand Up @@ -900,7 +897,8 @@ private bool ShouldShareSymbol(ObjectNode node)
ObjectNodeSection section = node.GetSection(_nodeFactory);
if (section == ObjectNodeSection.FoldableManagedCodeUnixContentSection ||
section == ObjectNodeSection.FoldableManagedCodeWindowsContentSection ||
section == ObjectNodeSection.FoldableReadOnlyDataSection)
section == ObjectNodeSection.FoldableReadOnlyDataSection ||
section == ObjectNodeSection.FoldableTextSection)
return true;

if (_isSingleFileCompilation)
Expand Down Expand Up @@ -959,7 +957,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection<Depende
managedCodeSection = ObjectNodeSection.ManagedCodeUnixContentSection;
// TODO 2916: managed code section has to be created here, switch is not necessary.
objectWriter.SetSection(ObjectNodeSection.ManagedCodeUnixContentSection);
objectWriter.SetSection(LsdaSection);
objectWriter.SetSection(ObjectNodeSection.TextSection);
}
objectWriter.SetCodeSectionAttribute(managedCodeSection);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public SealedVTableNode(TypeDesc type)

protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler);

public override ObjectNodeSection GetSection(NodeFactory factory) => _type.Context.Target.IsWindows ? ObjectNodeSection.FoldableReadOnlyDataSection : ObjectNodeSection.DataSection;
public override ObjectNodeSection GetSection(NodeFactory factory) => _type.Context.Target.IsWindows ? ObjectNodeSection.FoldableReadOnlyDataSection : ObjectNodeSection.FoldableTextSection;

public virtual void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
Expand Down