[XCOFF][llvm-objdump] Dump the debug type in `--section-headers` option.
authorEsme-Yi <esme.yi@ibm.com>
Thu, 10 Jun 2021 07:08:23 +0000 (07:08 +0000)
committerEsme-Yi <esme.yi@ibm.com>
Thu, 10 Jun 2021 07:08:23 +0000 (07:08 +0000)
Summary: Add XCOFF recognition of debug section types
under `--section-headers` option.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D103079

llvm/include/llvm/Object/XCOFFObjectFile.h
llvm/lib/Object/XCOFFObjectFile.cpp
llvm/test/tools/llvm-objdump/XCOFF/section-headers.test

index 0ce53ed..12d550f 100644 (file)
@@ -338,6 +338,7 @@ public:
   bool isSectionText(DataRefImpl Sec) const override;
   bool isSectionData(DataRefImpl Sec) const override;
   bool isSectionBSS(DataRefImpl Sec) const override;
+  bool isDebugSection(DataRefImpl Sec) const override;
 
   bool isSectionVirtual(DataRefImpl Sec) const override;
   relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
index 86e8c2e..8c2a0ea 100644 (file)
@@ -311,6 +311,11 @@ bool XCOFFObjectFile::isSectionBSS(DataRefImpl Sec) const {
   return Flags & (XCOFF::STYP_BSS | XCOFF::STYP_TBSS);
 }
 
+bool XCOFFObjectFile::isDebugSection(DataRefImpl Sec) const {
+  uint32_t Flags = getSectionFlags(Sec);
+  return Flags & (XCOFF::STYP_DEBUG | XCOFF::STYP_DWARF);
+}
+
 bool XCOFFObjectFile::isSectionVirtual(DataRefImpl Sec) const {
   return is64Bit() ? toSection64(Sec)->FileOffsetToRawData == 0
                    : toSection32(Sec)->FileOffsetToRawData == 0;
index a8832a2..fd75274 100644 (file)
@@ -11,6 +11,8 @@
 # CHECK-NEXT:   2 .bss          00000000 00000010 BSS
 # CHECK-NEXT:   3 .tdata        00000004 00000000 DATA
 # CHECK-NEXT:   4 .tbss         00000000 00000000 BSS
+# CHECK-NEXT:   5 .dwline       00000046 00000000 DEBUG
+# CHECK-NEXT:   6 .debug        00000046 00000000 DEBUG
 
 --- !XCOFF
 FileHeader:
@@ -33,6 +35,12 @@ Sections:
   - Name:    .tbss
     Size:    0x0
     Flags:   [ STYP_TBSS ]
+  - Name:    .dwline
+    Size:    0x46
+    Flags:   [ STYP_DWARF ]
+  - Name:    .debug
+    Size:    0x46
+    Flags:   [ STYP_DEBUG ]
 
 ## Check the -h/--section-headers option prints long section names.
 # RUN: yaml2obj %s --docnum=2 -o %t-longname.o