Skip to content

Commit e478823

Browse files
filipnavaratmds
authored andcommitted
[NativeAOT] ObjWriter: Produce COMDAT sections for .xdata unwinding data (dotnet#96686)
1 parent a332260 commit e478823

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream,
5959
private readonly HashSet<string> _referencedMethods = new();
6060

6161
// Exception handling
62-
private SectionWriter _xdataSectionWriter;
6362
private SectionWriter _pdataSectionWriter;
6463

6564
// Debugging
@@ -386,17 +385,15 @@ private protected override void EmitUnwindInfo(
386385

387386
if (shareSymbol)
388387
{
389-
// Ideally we would use `currentSymbolName` here and produce an
390-
// associative COMDAT symbol but link.exe cannot always handle that
391-
// and produces errors about duplicate symbols that point into the
392-
// associative section, so we are stuck with one section per each
393-
// unwind symbol.
388+
// Produce an associative COMDAT symbol.
394389
xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection, currentSymbolName, unwindSymbolName);
395390
pdataSectionWriter = GetOrCreateSection(PDataSection, currentSymbolName, null);
396391
}
397392
else
398393
{
399-
xdataSectionWriter = _xdataSectionWriter;
394+
// Produce a COMDAT section for each unwind symbol and let linker
395+
// do the deduplication across the ones with identical content.
396+
xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection, unwindSymbolName, unwindSymbolName);
400397
pdataSectionWriter = _pdataSectionWriter;
401398
}
402399

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

566563
private protected override void CreateEhSections()
567564
{
568-
// Create .xdata and .pdata
569-
_xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection);
565+
// Create .pdata
570566
_pdataSectionWriter = GetOrCreateSection(PDataSection);
571567
}
572568

0 commit comments

Comments
 (0)