[llvm] r330342 - [llvm-objdump] Print "..." instead of random data for virtual sections
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 19 10:02:57 PDT 2018
Author: thegameg
Date: Thu Apr 19 10:02:57 2018
New Revision: 330342
URL: http://llvm.org/viewvc/llvm-project?rev=330342&view=rev
Log:
[llvm-objdump] Print "..." instead of random data for virtual sections
When disassembling with -D, skip virtual sections by printing "..." for
each symbol.
This patch also implements `MachOObjectFile::isSectionVirtual`.
Test case comes from:
```
.zerofill __DATA,__common,_data64unsigned,472,3
```
Differential Revision: https://reviews.llvm.org/D45824
Added:
llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s
llvm/trunk/test/tools/llvm-objdump/Inputs/zerofill.macho-x86_64.o
Modified:
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=330342&r1=330341&r2=330342&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Apr 19 10:02:57 2018
@@ -1968,8 +1968,10 @@ unsigned MachOObjectFile::getSectionID(S
}
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 {
Added: llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s?rev=330342&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s (added)
+++ llvm/trunk/test/tools/llvm-objdump/AArch64/macho-zerofill.s Thu Apr 19 10:02:57 2018
@@ -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: ...
Added: llvm/trunk/test/tools/llvm-objdump/Inputs/zerofill.macho-x86_64.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/zerofill.macho-x86_64.o?rev=330342&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-objdump/Inputs/zerofill.macho-x86_64.o (added) and llvm/trunk/test/tools/llvm-objdump/Inputs/zerofill.macho-x86_64.o Thu Apr 19 10:02:57 2018 differ
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=330342&r1=330341&r2=330342&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Thu Apr 19 10:02:57 2018
@@ -1494,6 +1494,13 @@ static void DisassembleObject(const Obje
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
More information about the llvm-commits
mailing list