MCSectionELF.h revision 218893
1198090Srdivacky//===- MCSectionELF.h - ELF Machine Code Sections ---------------*- C++ -*-===// 2198090Srdivacky// 3198090Srdivacky// The LLVM Compiler Infrastructure 4198090Srdivacky// 5198090Srdivacky// This file is distributed under the University of Illinois Open Source 6198090Srdivacky// License. See LICENSE.TXT for details. 7198090Srdivacky// 8198090Srdivacky//===----------------------------------------------------------------------===// 9198090Srdivacky// 10198090Srdivacky// This file declares the MCSectionELF class. 11198090Srdivacky// 12198090Srdivacky//===----------------------------------------------------------------------===// 13198090Srdivacky 14198090Srdivacky#ifndef LLVM_MC_MCSECTIONELF_H 15198090Srdivacky#define LLVM_MC_MCSECTIONELF_H 16198090Srdivacky 17198090Srdivacky#include "llvm/MC/MCSection.h" 18218893Sdim#include "llvm/Support/ELF.h" 19198090Srdivacky 20198090Srdivackynamespace llvm { 21218893Sdim 22218893Sdimclass MCSymbol; 23218893Sdim 24198090Srdivacky/// MCSectionELF - This represents a section on linux, lots of unix variants 25198090Srdivacky/// and some bare metal systems. 26198090Srdivackyclass MCSectionELF : public MCSection { 27205218Srdivacky /// SectionName - This is the name of the section. The referenced memory is 28205218Srdivacky /// owned by TargetLoweringObjectFileELF's ELFUniqueMap. 29205218Srdivacky StringRef SectionName; 30218893Sdim 31198090Srdivacky /// Type - This is the sh_type field of a section, drawn from the enums below. 32198090Srdivacky unsigned Type; 33218893Sdim 34198090Srdivacky /// Flags - This is the sh_flags field of a section, drawn from the enums. 35198090Srdivacky /// below. 36198090Srdivacky unsigned Flags; 37198090Srdivacky 38212904Sdim /// EntrySize - The size of each entry in this section. This size only 39212904Sdim /// makes sense for sections that contain fixed-sized entries. If a 40212904Sdim /// section does not contain fixed-sized entries 'EntrySize' will be 0. 41212904Sdim unsigned EntrySize; 42218893Sdim 43218893Sdim const MCSymbol *Group; 44218893Sdim 45207618Srdivackyprivate: 46207618Srdivacky friend class MCContext; 47199481Srdivacky MCSectionELF(StringRef Section, unsigned type, unsigned flags, 48218893Sdim SectionKind K, unsigned entrySize, const MCSymbol *group) 49208599Srdivacky : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags), 50218893Sdim EntrySize(entrySize), Group(group) {} 51207618Srdivacky ~MCSectionELF(); 52198090Srdivackypublic: 53198090Srdivacky 54198090Srdivacky /// ShouldOmitSectionDirective - Decides whether a '.section' directive 55198090Srdivacky /// should be printed before the section name 56202878Srdivacky bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; 57198090Srdivacky 58205218Srdivacky StringRef getSectionName() const { return SectionName; } 59198090Srdivacky unsigned getType() const { return Type; } 60198090Srdivacky unsigned getFlags() const { return Flags; } 61212904Sdim unsigned getEntrySize() const { return EntrySize; } 62218893Sdim const MCSymbol *getGroup() const { return Group; } 63218893Sdim 64207618Srdivacky void PrintSwitchToSection(const MCAsmInfo &MAI, 65207618Srdivacky raw_ostream &OS) const; 66218893Sdim virtual bool UseCodeAlign() const; 67218893Sdim virtual bool isVirtualSection() const; 68218893Sdim 69206274Srdivacky /// isBaseAddressKnownZero - We know that non-allocatable sections (like 70206274Srdivacky /// debug info) have a base of zero. 71206274Srdivacky virtual bool isBaseAddressKnownZero() const { 72218893Sdim return (getFlags() & ELF::SHF_ALLOC) == 0; 73206274Srdivacky } 74208599Srdivacky 75208599Srdivacky static bool classof(const MCSection *S) { 76208599Srdivacky return S->getVariant() == SV_ELF; 77208599Srdivacky } 78208599Srdivacky static bool classof(const MCSectionELF *) { return true; } 79218893Sdim 80218893Sdim // Return the entry size for sections with fixed-width data. 81218893Sdim static unsigned DetermineEntrySize(SectionKind Kind); 82218893Sdim 83198090Srdivacky}; 84198090Srdivacky 85198090Srdivacky} // end namespace llvm 86198090Srdivacky 87198090Srdivacky#endif 88