Index: llvm/trunk/lib/Object/MachOObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp +++ llvm/trunk/lib/Object/MachOObjectFile.cpp @@ -1968,8 +1968,10 @@ } bool MachOObjectFile::isSectionVirtual(DataRefImpl Sec) const { - // FIXME: Unimplemented. - return false; + uint32_t Flags = getSectionFlags(*this, Sec); + unsigned SectionType = Flags & MachO::SECTION_TYPE; + return SectionType == MachO::S_ZEROFILL || + SectionType == MachO::S_GB_ZEROFILL; } bool MachOObjectFile::isSectionBitcode(DataRefImpl Sec) const { Index: llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s =================================================================== --- llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s +++ llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s @@ -0,0 +1,9 @@ +// RUN: llvm-mc < %s -triple aarch64-macho -filetype=obj | llvm-objdump -triple=aarch64-- -D - | FileCheck %s + + +// Check that we don't print garbage when we dump zerofill sections. + +.zerofill __DATA,__common,_data64unsigned,472,3 +// CHECK: Disassembly of section __DATA,__common: +// CHECK: ltmp1: +// CHECK-NEXT: ... Index: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp @@ -1494,6 +1494,13 @@ outs() << '\n' << std::get<1>(Symbols[si]) << ":\n"; + // Don't print raw contents of a virtual section. A virtual section + // doesn't have any contents in the file. + if (Section.isVirtual()) { + outs() << "...\n"; + continue; + } + #ifndef NDEBUG raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls(); #else