[llvm] ab59aa6 - [XCOFF] XCOFF constants, MCObjectFileInfo placeholder code for DWARF; NFC

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Fri May 8 13:51:46 PDT 2020


Author: Hubert Tong
Date: 2020-05-08T16:51:34-04:00
New Revision: ab59aa6c6130e2eb632f79d4163a33c63c58b117

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

LOG: [XCOFF] XCOFF constants, MCObjectFileInfo placeholder code for DWARF; NFC

Summary:
This patch introduces the constants defined to identify DWARF sections
in XCOFF into `llvm/BinaryFormat/XCOFF.h` and adds (NFC) placeholder
code to `llvm/lib/MC/MCObjectFileInfo.cpp` where the DWARF sections for
XCOFF are to be set up.

Reviewers: jasonliu, sfertile, daltenty, DiggerLin, Xiangling_L

Reviewed By: jasonliu, sfertile, DiggerLin

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

Added: 
    

Modified: 
    llvm/include/llvm/BinaryFormat/XCOFF.h
    llvm/lib/MC/MCObjectFileInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/BinaryFormat/XCOFF.h b/llvm/include/llvm/BinaryFormat/XCOFF.h
index 130e1d8262b1..3a35b822643b 100644
--- a/llvm/include/llvm/BinaryFormat/XCOFF.h
+++ b/llvm/include/llvm/BinaryFormat/XCOFF.h
@@ -79,6 +79,24 @@ enum SectionTypeFlags : int32_t {
   STYP_OVRFLO = 0x8000
 };
 
+/// Values for defining the section subtype of sections of type STYP_DWARF as
+/// they would appear in the (signed, 32-bit) s_flags field of the section
+/// header structure, contributing to the 16 most significant bits. Defined in
+/// the system header `scnhdr.h`.
+enum DwarfSectionSubtypeFlags : int32_t {
+  SSUBTYP_DWINFO = 0x1'0000,  ///< DWARF info section
+  SSUBTYP_DWLINE = 0x2'0000,  ///< DWARF line section
+  SSUBTYP_DWPBNMS = 0x3'0000, ///< DWARF pubnames section
+  SSUBTYP_DWPBTYP = 0x4'0000, ///< DWARF pubtypes section
+  SSUBTYP_DWARNGE = 0x5'0000, ///< DWARF aranges section
+  SSUBTYP_DWABREV = 0x6'0000, ///< DWARF abbrev section
+  SSUBTYP_DWSTR = 0x7'0000,   ///< DWARF str section
+  SSUBTYP_DWRNGES = 0x8'0000, ///< DWARF ranges section
+  SSUBTYP_DWLOC = 0x9'0000,   ///< DWARF loc section
+  SSUBTYP_DWFRAME = 0xA'0000, ///< DWARF frame section
+  SSUBTYP_DWMAC = 0xB'0000    ///< DWARF macinfo section
+};
+
 // STORAGE CLASSES, n_sclass field of syment.
 // The values come from `storclass.h` and `dbxstclass.h`.
 enum StorageClass : uint8_t {

diff  --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 90e760f35627..f79b068349e3 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -833,6 +833,22 @@ void MCObjectFileInfo::initXCOFFMCObjectFileInfo(const Triple &T) {
 
   // The TOC-base always has 0 size, but 4 byte alignment.
   TOCBaseSection->setAlignment(Align(4));
+
+  // DWARF sections for XCOFF are not csects. They are special STYP_DWARF
+  // sections, and the individual DWARF sections are distinguished by their
+  // section subtype.
+  // TODO: Populate the DWARF sections appropriately.
+  DwarfAbbrevSection = nullptr;   // SSUBTYP_DWABREV
+  DwarfInfoSection = nullptr;     // SSUBTYP_DWINFO
+  DwarfLineSection = nullptr;     // SSUBTYP_DWLINE
+  DwarfFrameSection = nullptr;    // SSUBTYP_DWFRAME
+  DwarfPubNamesSection = nullptr; // SSUBTYP_DWPBNMS
+  DwarfPubTypesSection = nullptr; // SSUBTYP_DWPBTYP
+  DwarfStrSection = nullptr;      // SSUBTYP_DWSTR
+  DwarfLocSection = nullptr;      // SSUBTYP_DWLOC
+  DwarfARangesSection = nullptr;  // SSUBTYP_DWARNGE
+  DwarfRangesSection = nullptr;   // SSUBTYP_DWRNGES
+  DwarfMacinfoSection = nullptr;  // SSUBTYP_DWMAC
 }
 
 void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,


        


More information about the llvm-commits mailing list