[llvm] c8e980a - [XCOFF][llvm-objdump] Dump the debug type in `--section-headers` option.

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 00:08:59 PDT 2021


Author: Esme-Yi
Date: 2021-06-10T07:08:23Z
New Revision: c8e980ab4accf6faa404d2650785cb2f6a7ac20a

URL: https://github.com/llvm/llvm-project/commit/c8e980ab4accf6faa404d2650785cb2f6a7ac20a
DIFF: https://github.com/llvm/llvm-project/commit/c8e980ab4accf6faa404d2650785cb2f6a7ac20a.diff

LOG: [XCOFF][llvm-objdump] Dump the debug type in `--section-headers` option.

Summary: Add XCOFF recognition of debug section types
under `--section-headers` option.

Reviewed By: jhenderson

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Object/XCOFFObjectFile.h b/llvm/include/llvm/Object/XCOFFObjectFile.h
index 0ce53ed50e60..12d550f69d59 100644
--- a/llvm/include/llvm/Object/XCOFFObjectFile.h
+++ b/llvm/include/llvm/Object/XCOFFObjectFile.h
@@ -338,6 +338,7 @@ class XCOFFObjectFile : public ObjectFile {
   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;

diff  --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index 86e8c2eabaab..8c2a0ead45c8 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -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;

diff  --git a/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test b/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
index a8832a2e2248..fd7527423eb1 100644
--- a/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
+++ b/llvm/test/tools/llvm-objdump/XCOFF/section-headers.test
@@ -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


        


More information about the llvm-commits mailing list