From d88ec17d8238308f9e79e0daa26b7196ea25e33d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 5 Feb 2024 08:08:18 +0100 Subject: [PATCH 1/2] ObjWriter: Place unboxing section along other TEXT sections --- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 0de7f8214e5095..1c30005d678089 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -346,10 +346,12 @@ private void EmitObject(string objectFilePath, IReadOnlyCollection Date: Tue, 20 Feb 2024 18:22:08 +0100 Subject: [PATCH 2/2] Add comment --- .../Compiler/ObjectWriter/ObjectWriter.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 1c30005d678089..5cec78cb52daf3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -343,6 +343,16 @@ private protected abstract void EmitDebugFunctionInfo( private void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) { // Pre-create some of the sections + // + // The order of the sections should not necessarily matter. The old LLVM-based + // ObjWriter used to place the "text" and "managed code" sections first. Some + // versions of Apple's ld-prime linker (default linker for Xcode 15+) produce + // incorrect unwind tables when the TEXT sections are intertwined with other + // sections. In order to workaround that issue we also place the "unbox" section + // in a pre-defined order. + // + // See https://github.com/dotnet/runtime/issues/97745#issuecomment-1925915381 + // Reported to Apple as FB13584275 and acknowledged as a bug in their linker. GetOrCreateSection(ObjectNodeSection.TextSection); if (_nodeFactory.Target.OperatingSystem == TargetOS.Windows) {