diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
index 28b87236e7046..df02a7cf24fea 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
@@ -112,6 +112,7 @@ The .NET Foundation licenses this file to you under the MIT license.
+
diff --git a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp
index 2c4cf852793e5..8ca31f5ae05bc 100644
--- a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp
+++ b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp
@@ -653,26 +653,11 @@ bool UnixNativeCodeManager::GetReturnAddressHijackInfo(MethodInfo * pMethodIn
GcInfoDecoderFlags flags = DECODE_RETURN_KIND;
#if defined(TARGET_ARM) || defined(TARGET_ARM64)
flags = (GcInfoDecoderFlags)(flags | DECODE_HAS_TAILCALLS);
-#elif defined(TARGET_AMD64) && defined(TARGET_OSX)
- flags = (GcInfoDecoderFlags)(flags | DECODE_PROLOG_LENGTH);
#endif // TARGET_ARM || TARGET_ARM64
GcInfoDecoder decoder(GCInfoToken(p), flags);
*pRetValueKind = GetGcRefKind(decoder.GetReturnKind());
-#if defined(TARGET_AMD64) && defined(TARGET_OSX)
- // Compact unwinding on macOS cannot properly handle unwinding the function prolog
- if ((PTR_VOID)pRegisterSet->IP == pNativeMethodInfo->pMethodStartAddress)
- {
- *ppvRetAddrLocation = (PTR_PTR_VOID)pRegisterSet->GetSP();
- return true;
- }
- else if ((PTR_UInt8)pRegisterSet->IP < (PTR_UInt8)pNativeMethodInfo->pMethodStartAddress + decoder.GetPrologSize())
- {
- return false;
- }
-#endif
-
int epilogueInstructions = TrailingEpilogueInstructionsCount((PTR_VOID)pRegisterSet->IP);
if (epilogueInstructions < 0)
{
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs
index fb1f38266fbb1..29ab4d6412e29 100644
--- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs
@@ -713,6 +713,21 @@ public void EmitCFICodes(int offset)
// Internal compiler error
Debug.Assert(false);
}
+
+ if (_targetPlatform.OperatingSystem == TargetOS.OSX)
+ {
+ // Emit a symbol for beginning of the frame. This is workaround for ld64
+ // linker bug which would produce DWARF with incorrect pcStart offsets for
+ // exception handling blocks if there is no symbol present for them.
+ //
+ // To make things simple we just reuse blobSymbolName and change `_lsda`
+ // prefix to `_fram`.
+ blobSymbolName[1] = (byte)'f';
+ blobSymbolName[2] = (byte)'r';
+ blobSymbolName[3] = (byte)'a';
+ blobSymbolName[4] = (byte)'m';
+ EmitSymbolDef(blobSymbolName);
+ }
}
// Emit individual cfi blob for the given offset