Skip to content

Commit

Permalink
[NativeAOT] ObjWriter: Produce COMDAT sections for .xdata unwinding d…
Browse files Browse the repository at this point in the history
…ata (#96686)
  • Loading branch information
filipnavara authored Jan 10, 2024
1 parent fdb03ca commit 6db9acf
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream,
private readonly HashSet<string> _referencedMethods = new();

// Exception handling
private SectionWriter _xdataSectionWriter;
private SectionWriter _pdataSectionWriter;

// Debugging
Expand Down Expand Up @@ -386,17 +385,15 @@ private protected override void EmitUnwindInfo(

if (shareSymbol)
{
// Ideally we would use `currentSymbolName` here and produce an
// associative COMDAT symbol but link.exe cannot always handle that
// and produces errors about duplicate symbols that point into the
// associative section, so we are stuck with one section per each
// unwind symbol.
// Produce an associative COMDAT symbol.
xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection, currentSymbolName, unwindSymbolName);
pdataSectionWriter = GetOrCreateSection(PDataSection, currentSymbolName, null);
}
else
{
xdataSectionWriter = _xdataSectionWriter;
// Produce a COMDAT section for each unwind symbol and let linker
// do the deduplication across the ones with identical content.
xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection, unwindSymbolName, unwindSymbolName);
pdataSectionWriter = _pdataSectionWriter;
}

Expand Down Expand Up @@ -565,8 +562,7 @@ private protected override void EmitObjectFile(string objectFilePath)

private protected override void CreateEhSections()
{
// Create .xdata and .pdata
_xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection);
// Create .pdata
_pdataSectionWriter = GetOrCreateSection(PDataSection);
}

Expand Down

0 comments on commit 6db9acf

Please sign in to comment.