[vm] Skip appending Windows unwinding sections for relocatable objects.
Mach-O relocatable objects aren't a native shared object format on
Windows, can't be loaded by the non-native Mach-O loader, and aren't
required to have the same memory layout as the snapshot like separate
debugging information, so there's no reason to output these sections.
TEST=vm/dart/use_dwarf_stack_traces_flag_test on
vm-aot-win-debug-arm64
Fixes: https://github.com/dart-lang/sdk/issues/62057
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try
Change-Id: Ic85eedfda120fe4c8669678298d330146c9a036a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464181
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
This commit is contained in:
committed by
Commit Queue
parent
4f1f82f59e
commit
6230f5bd9d
+26
-19
@@ -2699,25 +2699,32 @@ void MachOHeader::GenerateUnwindingInformation() {
|
||||
#if defined(UNWINDING_RECORDS_WINDOWS_PRECOMPILER)
|
||||
// Append Windows unwinding instructions as a __unwind_info section at
|
||||
// the end of any executable segments.
|
||||
for (auto* const command : commands_) {
|
||||
if (auto* const segment = command->AsMachOSegment()) {
|
||||
if (segment->IsExecutable()) {
|
||||
// Only more zerofill sections can come after zerofill sections, and
|
||||
// the unwinding instructions cover the entire executable segment up
|
||||
// to the unwinding instructions including zerofill sections.
|
||||
ASSERT(use_zerofill || !segment->HasZerofillSections());
|
||||
const intptr_t records_size = UnwindingRecordsPlatform::SizeInBytes();
|
||||
ZoneWriteStream stream(zone(), /*initial_size=*/records_size);
|
||||
uint8_t* unwinding_instructions = zone()->Alloc<uint8_t>(records_size);
|
||||
const intptr_t section_start =
|
||||
Utils::RoundUp(segment->UnpaddedMemorySize(), alignment);
|
||||
stream.WriteBytes(UnwindingRecords::GenerateRecordsInto(
|
||||
section_start, unwinding_instructions),
|
||||
records_size);
|
||||
ASSERT_EQUAL(records_size, stream.Position());
|
||||
auto* const section = create_unwind_section(
|
||||
segment->name(), mach_o::SECT_UNWIND_INFO, stream);
|
||||
segment->AddContents(section);
|
||||
//
|
||||
// Don't do this for relocatable objects, because those can't be loaded
|
||||
// by the non-native loader and there's no way to link them into a
|
||||
// program since Mach-O is not a supported object type on Windows anyway.
|
||||
if (type_ != SnapshotType::Object) {
|
||||
for (auto* const command : commands_) {
|
||||
if (auto* const segment = command->AsMachOSegment()) {
|
||||
if (segment->IsExecutable()) {
|
||||
// Only more zerofill sections can come after zerofill sections, and
|
||||
// the unwinding instructions cover the entire executable segment up
|
||||
// to the unwinding instructions including zerofill sections.
|
||||
ASSERT(use_zerofill || !segment->HasZerofillSections());
|
||||
const intptr_t records_size = UnwindingRecordsPlatform::SizeInBytes();
|
||||
ZoneWriteStream stream(zone(), /*initial_size=*/records_size);
|
||||
uint8_t* unwinding_instructions =
|
||||
zone()->Alloc<uint8_t>(records_size);
|
||||
const intptr_t section_start =
|
||||
Utils::RoundUp(segment->UnpaddedMemorySize(), alignment);
|
||||
stream.WriteBytes(UnwindingRecords::GenerateRecordsInto(
|
||||
section_start, unwinding_instructions),
|
||||
records_size);
|
||||
ASSERT_EQUAL(records_size, stream.Position());
|
||||
auto* const section = create_unwind_section(
|
||||
segment->name(), mach_o::SECT_UNWIND_INFO, stream);
|
||||
segment->AddContents(section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user