[PATCH] D45824: [llvm-objdump] Print "..." instead of random data for virtual sections

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 10:06:14 PDT 2018


This revision was automatically updated to reflect the committed changes.
thegameg marked an inline comment as done.
Closed by commit rL330342: [llvm-objdump] Print "..." instead of random data for virtual sections (authored by thegameg, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45824?vs=143110&id=143115#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45824

Files:
  llvm/trunk/lib/Object/MachOObjectFile.cpp
  llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s
  llvm/trunk/test/tools/llvm-objdump/Inputs/zerofill.macho-x86_64.o
  llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp


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/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/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45824.143115.patch
Type: text/x-patch
Size: 1829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180419/15095ccb/attachment.bin>


More information about the llvm-commits mailing list