LCOV - code coverage report
Current view: top level - include/llvm/MC - MCObjectFileInfo.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 2 2 100.0 %
Date: 2018-07-13 00:08:38 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file describes common object file formats.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_MC_MCOBJECTFILEINFO_H
      15             : #define LLVM_MC_MCOBJECTFILEINFO_H
      16             : 
      17             : #include "llvm/ADT/DenseMap.h"
      18             : #include "llvm/ADT/Triple.h"
      19             : #include "llvm/MC/MCSymbol.h"
      20             : #include "llvm/Support/CodeGen.h"
      21             : 
      22             : namespace llvm {
      23             : class MCContext;
      24             : class MCSection;
      25             : 
      26      120234 : class MCObjectFileInfo {
      27             : protected:
      28             :   /// True if .comm supports alignment.  This is a hack for as long as we
      29             :   /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
      30             :   bool CommDirectiveSupportsAlignment;
      31             : 
      32             :   /// True if target object file supports a weak_definition of constant 0 for an
      33             :   /// omitted EH frame.
      34             :   bool SupportsWeakOmittedEHFrame;
      35             : 
      36             :   /// True if the target object file supports emitting a compact unwind section
      37             :   /// without an associated EH frame section.
      38             :   bool SupportsCompactUnwindWithoutEHFrame;
      39             : 
      40             :   /// OmitDwarfIfHaveCompactUnwind - True if the target object file
      41             :   /// supports having some functions with compact unwind and other with
      42             :   /// dwarf unwind.
      43             :   bool OmitDwarfIfHaveCompactUnwind;
      44             : 
      45             :   /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
      46             :   /// for EH.
      47             :   unsigned PersonalityEncoding;
      48             :   unsigned LSDAEncoding;
      49             :   unsigned FDECFIEncoding;
      50             :   unsigned TTypeEncoding;
      51             : 
      52             :   /// Compact unwind encoding indicating that we should emit only an EH frame.
      53             :   unsigned CompactUnwindDwarfEHFrameOnly;
      54             : 
      55             :   /// Section directive for standard text.
      56             :   MCSection *TextSection;
      57             : 
      58             :   /// Section directive for standard data.
      59             :   MCSection *DataSection;
      60             : 
      61             :   /// Section that is default initialized to zero.
      62             :   MCSection *BSSSection;
      63             : 
      64             :   /// Section that is readonly and can contain arbitrary initialized data.
      65             :   /// Targets are not required to have a readonly section. If they don't,
      66             :   /// various bits of code will fall back to using the data section for
      67             :   /// constants.
      68             :   MCSection *ReadOnlySection;
      69             : 
      70             :   /// If exception handling is supported by the target, this is the section the
      71             :   /// Language Specific Data Area information is emitted to.
      72             :   MCSection *LSDASection;
      73             : 
      74             :   /// If exception handling is supported by the target and the target can
      75             :   /// support a compact representation of the CIE and FDE, this is the section
      76             :   /// to emit them into.
      77             :   MCSection *CompactUnwindSection;
      78             : 
      79             :   // Dwarf sections for debug info.  If a target supports debug info, these must
      80             :   // be set.
      81             :   MCSection *DwarfAbbrevSection;
      82             :   MCSection *DwarfInfoSection;
      83             :   MCSection *DwarfLineSection;
      84             :   MCSection *DwarfLineStrSection;
      85             :   MCSection *DwarfFrameSection;
      86             :   MCSection *DwarfPubTypesSection;
      87             :   const MCSection *DwarfDebugInlineSection;
      88             :   MCSection *DwarfStrSection;
      89             :   MCSection *DwarfLocSection;
      90             :   MCSection *DwarfARangesSection;
      91             :   MCSection *DwarfRangesSection;
      92             :   MCSection *DwarfMacinfoSection;
      93             :   // The pubnames section is no longer generated by default.  The generation
      94             :   // can be enabled by a compiler flag.
      95             :   MCSection *DwarfPubNamesSection;
      96             : 
      97             :   /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
      98             :   /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
      99             :   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
     100             :   /// extensions.
     101             :   MCSection *DwarfDebugNamesSection;
     102             :   MCSection *DwarfAccelNamesSection;
     103             :   MCSection *DwarfAccelObjCSection;
     104             :   MCSection *DwarfAccelNamespaceSection;
     105             :   MCSection *DwarfAccelTypesSection;
     106             : 
     107             :   // These are used for the Fission separate debug information files.
     108             :   MCSection *DwarfInfoDWOSection;
     109             :   MCSection *DwarfTypesDWOSection;
     110             :   MCSection *DwarfAbbrevDWOSection;
     111             :   MCSection *DwarfStrDWOSection;
     112             :   MCSection *DwarfLineDWOSection;
     113             :   MCSection *DwarfLocDWOSection;
     114             :   MCSection *DwarfStrOffDWOSection;
     115             : 
     116             :   /// The DWARF v5 string offset and address table sections.
     117             :   MCSection *DwarfStrOffSection;
     118             :   MCSection *DwarfAddrSection;
     119             : 
     120             :   // These are for Fission DWP files.
     121             :   MCSection *DwarfCUIndexSection;
     122             :   MCSection *DwarfTUIndexSection;
     123             : 
     124             :   /// Section for newer gnu pubnames.
     125             :   MCSection *DwarfGnuPubNamesSection;
     126             :   /// Section for newer gnu pubtypes.
     127             :   MCSection *DwarfGnuPubTypesSection;
     128             : 
     129             :   // Section for Swift AST
     130             :   MCSection *DwarfSwiftASTSection;
     131             : 
     132             :   MCSection *COFFDebugSymbolsSection;
     133             :   MCSection *COFFDebugTypesSection;
     134             :   MCSection *COFFGlobalTypeHashesSection;
     135             : 
     136             :   /// Extra TLS Variable Data section.
     137             :   ///
     138             :   /// If the target needs to put additional information for a TLS variable,
     139             :   /// it'll go here.
     140             :   MCSection *TLSExtraDataSection;
     141             : 
     142             :   /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
     143             :   MCSection *TLSDataSection; // Defaults to ".tdata".
     144             : 
     145             :   /// Section directive for Thread Local uninitialized data.
     146             :   ///
     147             :   /// Null if this target doesn't support a BSS section. ELF and MachO only.
     148             :   MCSection *TLSBSSSection; // Defaults to ".tbss".
     149             : 
     150             :   /// StackMap section.
     151             :   MCSection *StackMapSection;
     152             : 
     153             :   /// FaultMap section.
     154             :   MCSection *FaultMapSection;
     155             : 
     156             :   /// EH frame section.
     157             :   ///
     158             :   /// It is initialized on demand so it can be overwritten (with uniquing).
     159             :   MCSection *EHFrameSection;
     160             : 
     161             :   /// Section containing metadata on function stack sizes.
     162             :   MCSection *StackSizesSection;
     163             :   mutable DenseMap<const MCSymbol *, unsigned> StackSizesUniquing;
     164             : 
     165             :   // ELF specific sections.
     166             :   MCSection *DataRelROSection;
     167             :   MCSection *MergeableConst4Section;
     168             :   MCSection *MergeableConst8Section;
     169             :   MCSection *MergeableConst16Section;
     170             :   MCSection *MergeableConst32Section;
     171             : 
     172             :   // MachO specific sections.
     173             : 
     174             :   /// Section for thread local structure information.
     175             :   ///
     176             :   /// Contains the source code name of the variable, visibility and a pointer to
     177             :   /// the initial value (.tdata or .tbss).
     178             :   MCSection *TLSTLVSection; // Defaults to ".tlv".
     179             : 
     180             :   /// Section for thread local data initialization functions.
     181             :   const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
     182             : 
     183             :   MCSection *CStringSection;
     184             :   MCSection *UStringSection;
     185             :   MCSection *TextCoalSection;
     186             :   MCSection *ConstTextCoalSection;
     187             :   MCSection *ConstDataSection;
     188             :   MCSection *DataCoalSection;
     189             :   MCSection *ConstDataCoalSection;
     190             :   MCSection *DataCommonSection;
     191             :   MCSection *DataBSSSection;
     192             :   MCSection *FourByteConstantSection;
     193             :   MCSection *EightByteConstantSection;
     194             :   MCSection *SixteenByteConstantSection;
     195             :   MCSection *LazySymbolPointerSection;
     196             :   MCSection *NonLazySymbolPointerSection;
     197             :   MCSection *ThreadLocalPointerSection;
     198             : 
     199             :   /// COFF specific sections.
     200             :   MCSection *DrectveSection;
     201             :   MCSection *PDataSection;
     202             :   MCSection *XDataSection;
     203             :   MCSection *SXDataSection;
     204             :   MCSection *GFIDsSection;
     205             : 
     206             : public:
     207             :   void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
     208             :                             bool LargeCodeModel = false);
     209             : 
     210             :   bool getSupportsWeakOmittedEHFrame() const {
     211             :     return SupportsWeakOmittedEHFrame;
     212             :   }
     213             :   bool getSupportsCompactUnwindWithoutEHFrame() const {
     214             :     return SupportsCompactUnwindWithoutEHFrame;
     215             :   }
     216             :   bool getOmitDwarfIfHaveCompactUnwind() const {
     217             :     return OmitDwarfIfHaveCompactUnwind;
     218             :   }
     219             : 
     220             :   bool getCommDirectiveSupportsAlignment() const {
     221             :     return CommDirectiveSupportsAlignment;
     222             :   }
     223             : 
     224             :   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
     225             :   unsigned getLSDAEncoding() const { return LSDAEncoding; }
     226             :   unsigned getFDEEncoding() const { return FDECFIEncoding; }
     227             :   unsigned getTTypeEncoding() const { return TTypeEncoding; }
     228             : 
     229             :   unsigned getCompactUnwindDwarfEHFrameOnly() const {
     230             :     return CompactUnwindDwarfEHFrameOnly;
     231             :   }
     232             : 
     233             :   MCSection *getTextSection() const { return TextSection; }
     234             :   MCSection *getDataSection() const { return DataSection; }
     235             :   MCSection *getBSSSection() const { return BSSSection; }
     236             :   MCSection *getReadOnlySection() const { return ReadOnlySection; }
     237             :   MCSection *getLSDASection() const { return LSDASection; }
     238             :   MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
     239             :   MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
     240             :   MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
     241             :   MCSection *getDwarfLineSection() const { return DwarfLineSection; }
     242             :   MCSection *getDwarfLineStrSection() const { return DwarfLineStrSection; }
     243             :   MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
     244             :   MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
     245             :   MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
     246             :   MCSection *getDwarfGnuPubNamesSection() const {
     247             :     return DwarfGnuPubNamesSection;
     248             :   }
     249             :   MCSection *getDwarfGnuPubTypesSection() const {
     250             :     return DwarfGnuPubTypesSection;
     251             :   }
     252             :   const MCSection *getDwarfDebugInlineSection() const {
     253             :     return DwarfDebugInlineSection;
     254             :   }
     255             :   MCSection *getDwarfStrSection() const { return DwarfStrSection; }
     256             :   MCSection *getDwarfLocSection() const { return DwarfLocSection; }
     257             :   MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
     258             :   MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
     259             :   MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
     260             : 
     261             :   MCSection *getDwarfDebugNamesSection() const {
     262             :     return DwarfDebugNamesSection;
     263             :   }
     264             :   MCSection *getDwarfAccelNamesSection() const {
     265             :     return DwarfAccelNamesSection;
     266             :   }
     267             :   MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
     268             :   MCSection *getDwarfAccelNamespaceSection() const {
     269             :     return DwarfAccelNamespaceSection;
     270             :   }
     271             :   MCSection *getDwarfAccelTypesSection() const {
     272             :     return DwarfAccelTypesSection;
     273             :   }
     274             :   MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
     275             :   MCSection *getDwarfTypesSection(uint64_t Hash) const;
     276             :   MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
     277             :   MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
     278             :   MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
     279             :   MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
     280             :   MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
     281             :   MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
     282             :   MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
     283             :   MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
     284             :   MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
     285             :   MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
     286             :   MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
     287             : 
     288             :   MCSection *getCOFFDebugSymbolsSection() const {
     289             :     return COFFDebugSymbolsSection;
     290             :   }
     291             :   MCSection *getCOFFDebugTypesSection() const {
     292             :     return COFFDebugTypesSection;
     293             :   }
     294             :   MCSection *getCOFFGlobalTypeHashesSection() const {
     295             :     return COFFGlobalTypeHashesSection;
     296             :   }
     297             : 
     298             :   MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
     299             :   const MCSection *getTLSDataSection() const { return TLSDataSection; }
     300             :   MCSection *getTLSBSSSection() const { return TLSBSSSection; }
     301             : 
     302             :   MCSection *getStackMapSection() const { return StackMapSection; }
     303             :   MCSection *getFaultMapSection() const { return FaultMapSection; }
     304             : 
     305             :   MCSection *getStackSizesSection(const MCSection &TextSec) const;
     306             : 
     307             :   // ELF specific sections.
     308             :   MCSection *getDataRelROSection() const { return DataRelROSection; }
     309             :   const MCSection *getMergeableConst4Section() const {
     310             :     return MergeableConst4Section;
     311             :   }
     312             :   const MCSection *getMergeableConst8Section() const {
     313             :     return MergeableConst8Section;
     314             :   }
     315             :   const MCSection *getMergeableConst16Section() const {
     316             :     return MergeableConst16Section;
     317             :   }
     318             :   const MCSection *getMergeableConst32Section() const {
     319             :     return MergeableConst32Section;
     320             :   }
     321             : 
     322             :   // MachO specific sections.
     323             :   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
     324             :   const MCSection *getTLSThreadInitSection() const {
     325             :     return TLSThreadInitSection;
     326             :   }
     327             :   const MCSection *getCStringSection() const { return CStringSection; }
     328             :   const MCSection *getUStringSection() const { return UStringSection; }
     329             :   MCSection *getTextCoalSection() const { return TextCoalSection; }
     330             :   const MCSection *getConstTextCoalSection() const {
     331             :     return ConstTextCoalSection;
     332             :   }
     333             :   const MCSection *getConstDataSection() const { return ConstDataSection; }
     334             :   const MCSection *getDataCoalSection() const { return DataCoalSection; }
     335             :   const MCSection *getConstDataCoalSection() const {
     336             :     return ConstDataCoalSection;
     337             :   }
     338             :   const MCSection *getDataCommonSection() const { return DataCommonSection; }
     339             :   MCSection *getDataBSSSection() const { return DataBSSSection; }
     340             :   const MCSection *getFourByteConstantSection() const {
     341             :     return FourByteConstantSection;
     342             :   }
     343             :   const MCSection *getEightByteConstantSection() const {
     344             :     return EightByteConstantSection;
     345             :   }
     346             :   const MCSection *getSixteenByteConstantSection() const {
     347             :     return SixteenByteConstantSection;
     348             :   }
     349             :   MCSection *getLazySymbolPointerSection() const {
     350             :     return LazySymbolPointerSection;
     351             :   }
     352             :   MCSection *getNonLazySymbolPointerSection() const {
     353             :     return NonLazySymbolPointerSection;
     354             :   }
     355             :   MCSection *getThreadLocalPointerSection() const {
     356             :     return ThreadLocalPointerSection;
     357             :   }
     358             : 
     359             :   // COFF specific sections.
     360             :   MCSection *getDrectveSection() const { return DrectveSection; }
     361             :   MCSection *getPDataSection() const { return PDataSection; }
     362             :   MCSection *getXDataSection() const { return XDataSection; }
     363             :   MCSection *getSXDataSection() const { return SXDataSection; }
     364             :   MCSection *getGFIDsSection() const { return GFIDsSection; }
     365             : 
     366             :   MCSection *getEHFrameSection() {
     367             :     return EHFrameSection;
     368             :   }
     369             : 
     370             :   enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
     371             :   Environment getObjectFileType() const { return Env; }
     372             : 
     373             :   bool isPositionIndependent() const { return PositionIndependent; }
     374             : 
     375             : private:
     376             :   Environment Env;
     377             :   bool PositionIndependent;
     378             :   MCContext *Ctx;
     379             :   Triple TT;
     380             : 
     381             :   void initMachOMCObjectFileInfo(const Triple &T);
     382             :   void initELFMCObjectFileInfo(const Triple &T, bool Large);
     383             :   void initCOFFMCObjectFileInfo(const Triple &T);
     384             :   void initWasmMCObjectFileInfo(const Triple &T);
     385             : 
     386             : public:
     387      156493 :   const Triple &getTargetTriple() const { return TT; }
     388             : };
     389             : 
     390             : } // end namespace llvm
     391             : 
     392             : #endif

Generated by: LCOV version 1.13