Add a MCLineSectionOrder vector so that we produce the line tables in a
[oota-llvm.git] / include / llvm / MC / MCSectionELF.h
index 2dccf5c57286473c10d5f7ce96de1d22b1137e42..9463356db2bf955a16f863347b3851d211c069a8 100644 (file)
 #include "llvm/MC/MCSection.h"
 
 namespace llvm {
-  
+
+class MCSymbol;
+
 /// MCSectionELF - This represents a section on linux, lots of unix variants
 /// and some bare metal systems.
 class MCSectionELF : public MCSection {
-  std::string SectionName;
-  
+  /// SectionName - This is the name of the section.  The referenced memory is
+  /// owned by TargetLoweringObjectFileELF's ELFUniqueMap.
+  StringRef SectionName;
+
   /// Type - This is the sh_type field of a section, drawn from the enums below.
   unsigned Type;
-  
+
   /// Flags - This is the sh_flags field of a section, drawn from the enums.
   /// below.
   unsigned Flags;
 
-  /// IsExplicit - Indicates that this section comes from globals with an
-  /// explicit section specified.
-  bool IsExplicit;
-  
-protected:
+  /// EntrySize - The size of each entry in this section. This size only
+  /// makes sense for sections that contain fixed-sized entries. If a
+  /// section does not contain fixed-sized entries 'EntrySize' will be 0.
+  unsigned EntrySize;
+
+  const MCSymbol *Group;
+
+private:
+  friend class MCContext;
   MCSectionELF(StringRef Section, unsigned type, unsigned flags,
-               SectionKind K, bool isExplicit)
-    : MCSection(K), SectionName(Section.str()), Type(type), Flags(flags), 
-      IsExplicit(isExplicit) {}
+               SectionKind K, unsigned entrySize, const MCSymbol *group)
+    : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags),
+      EntrySize(entrySize), Group(group) {}
+  ~MCSectionELF();
 public:
-  
-  static MCSectionELF *Create(StringRef Section, unsigned Type, 
-                              unsigned Flags, SectionKind K, bool isExplicit,
-                              MCContext &Ctx);
 
   /// ShouldOmitSectionDirective - Decides whether a '.section' directive
   /// should be printed before the section name
   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
 
-  /// ShouldPrintSectionType - Only prints the section type if supported
-  bool ShouldPrintSectionType(unsigned Ty) const;
-
   /// HasCommonSymbols - True if this section holds common symbols, this is
-  /// indicated on the ELF object file by a symbol with SHN_COMMON section 
+  /// indicated on the ELF object file by a symbol with SHN_COMMON section
   /// header index.
   bool HasCommonSymbols() const;
-  
+
   /// These are the section type and flags fields.  An ELF section can have
   /// only one Type, but can have more than one of the flags specified.
   ///
@@ -79,7 +81,7 @@ public:
 
     // The section holds a symbol hash table.
     SHT_HASH             = 0x05U,
-    
+
     // Information for dynamic linking.
     SHT_DYNAMIC          = 0x06U,
 
@@ -92,7 +94,7 @@ public:
     // The section holds relocation entries without explicit addends.
     SHT_REL              = 0x09U,
 
-    // This section type is reserved but has unspecified semantics. 
+    // This section type is reserved but has unspecified semantics.
     SHT_SHLIB            = 0x0AU,
 
     // This section holds a symbol table.
@@ -116,8 +118,19 @@ public:
     // referenced symbol table contain the escape value SHN_XINDEX
     SHT_SYMTAB_SHNDX     = 0x12U,
 
-    LAST_KNOWN_SECTION_TYPE = SHT_SYMTAB_SHNDX
-  }; 
+    // Start of target-specific flags.
+
+    // Exception Index table
+    SHT_ARM_EXIDX           = 0x70000001U,
+    // BPABI DLL dynamic linking pre-emption map
+    SHT_ARM_PREEMPTMAP      = 0x70000002U,
+    //  Object file compatibility attributes
+    SHT_ARM_ATTRIBUTES      = 0x70000003U,
+    SHT_ARM_DEBUGOVERLAY    = 0x70000004U,
+    SHT_ARM_OVERLAYSECTION  = 0x70000005U,
+
+    LAST_KNOWN_SECTION_TYPE = SHT_ARM_OVERLAYSECTION
+  };
 
   /// Valid section flags.
   enum {
@@ -151,38 +164,46 @@ public:
 
     // This section holds Thread-Local Storage.
     SHF_TLS              = 0x400U,
-    
-    /// FIRST_TARGET_DEP_FLAG - This is the first flag that subclasses are
-    /// allowed to specify.
-    FIRST_TARGET_DEP_FLAG = 0x800U,
-
-    /// TARGET_INDEP_SHF - This is the bitmask for all the target independent
-    /// section flags.  Targets can define their own target flags above these.
-    /// If they do that, they should implement their own MCSectionELF subclasses
-    /// and implement the virtual method hooks below to handle printing needs.
-    TARGET_INDEP_SHF     = FIRST_TARGET_DEP_FLAG-1U
+
+
+    // Start of target-specific flags.
+
+    /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped
+    /// together by the linker to form the constant pool and the cp register is
+    /// set to the start of the constant pool by the boot code.
+    XCORE_SHF_CP_SECTION = 0x800U,
+
+    /// XCORE_SHF_DP_SECTION - All sections with the "d" flag are grouped
+    /// together by the linker to form the data section and the dp register is
+    /// set to the start of the section by the boot code.
+    XCORE_SHF_DP_SECTION = 0x1000U
   };
 
-  StringRef getSectionName() const {
-    return StringRef(SectionName);
-  }
-  
+  StringRef getSectionName() const { return SectionName; }
   unsigned getType() const { return Type; }
   unsigned getFlags() const { return Flags; }
-  
-  virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
-                                    raw_ostream &OS) const;
-  
-  
-  /// PrintTargetSpecificSectionFlags - Targets that define their own
-  /// MCSectionELF subclasses with target specific section flags should
-  /// implement this method if they end up adding letters to the attributes
-  /// list.
-  virtual void PrintTargetSpecificSectionFlags(const MCAsmInfo &MAI,
-                                               raw_ostream &OS) const {
+  unsigned getEntrySize() const { return EntrySize; }
+  const MCSymbol *getGroup() const { return Group; }
+
+  void PrintSwitchToSection(const MCAsmInfo &MAI,
+                            raw_ostream &OS) const;
+  virtual bool UseCodeAlign() const;
+  virtual bool isVirtualSection() const;
+
+  /// isBaseAddressKnownZero - We know that non-allocatable sections (like
+  /// debug info) have a base of zero.
+  virtual bool isBaseAddressKnownZero() const {
+    return (getFlags() & SHF_ALLOC) == 0;
+  }
+
+  static bool classof(const MCSection *S) {
+    return S->getVariant() == SV_ELF;
   }
-                                               
-  
+  static bool classof(const MCSectionELF *) { return true; }
+
+  // Return the entry size for sections with fixed-width data.
+  static unsigned DetermineEntrySize(SectionKind Kind);
+
 };
 
 } // end namespace llvm