2009-08-13 05:07:35 +00:00
|
|
|
//===- MCSectionELF.h - ELF Machine Code Sections ---------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the MCSectionELF class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSECTIONELF_H
|
|
|
|
#define LLVM_MC_MCSECTIONELF_H
|
|
|
|
|
|
|
|
#include "llvm/MC/MCSection.h"
|
2011-01-23 04:43:11 +00:00
|
|
|
#include "llvm/Support/ELF.h"
|
2009-08-13 05:07:35 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2010-11-11 18:13:52 +00:00
|
|
|
class MCSymbol;
|
|
|
|
|
2009-08-13 05:07:35 +00:00
|
|
|
/// MCSectionELF - This represents a section on linux, lots of unix variants
|
|
|
|
/// and some bare metal systems.
|
|
|
|
class MCSectionELF : public MCSection {
|
2010-03-15 06:23:52 +00:00
|
|
|
/// SectionName - This is the name of the section. The referenced memory is
|
|
|
|
/// owned by TargetLoweringObjectFileELF's ELFUniqueMap.
|
|
|
|
StringRef SectionName;
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2009-08-13 05:07:35 +00:00
|
|
|
/// Type - This is the sh_type field of a section, drawn from the enums below.
|
|
|
|
unsigned Type;
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2009-08-13 05:07:35 +00:00
|
|
|
/// Flags - This is the sh_flags field of a section, drawn from the enums.
|
|
|
|
/// below.
|
|
|
|
unsigned Flags;
|
|
|
|
|
2010-08-16 18:33:46 +00:00
|
|
|
/// 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;
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2010-11-11 18:13:52 +00:00
|
|
|
const MCSymbol *Group;
|
|
|
|
|
2010-04-08 21:26:26 +00:00
|
|
|
private:
|
|
|
|
friend class MCContext;
|
2009-11-06 10:58:06 +00:00
|
|
|
MCSectionELF(StringRef Section, unsigned type, unsigned flags,
|
2010-11-11 18:13:52 +00:00
|
|
|
SectionKind K, unsigned entrySize, const MCSymbol *group)
|
2010-05-17 21:54:26 +00:00
|
|
|
: MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags),
|
2010-11-11 18:13:52 +00:00
|
|
|
EntrySize(entrySize), Group(group) {}
|
2010-04-08 21:26:26 +00:00
|
|
|
~MCSectionELF();
|
2009-08-13 05:07:35 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
/// ShouldOmitSectionDirective - Decides whether a '.section' directive
|
|
|
|
/// should be printed before the section name
|
2010-01-22 18:21:23 +00:00
|
|
|
bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
|
2009-08-13 05:07:35 +00:00
|
|
|
|
2009-08-14 19:45:38 +00:00
|
|
|
/// HasCommonSymbols - True if this section holds common symbols, this is
|
2010-10-06 20:36:38 +00:00
|
|
|
/// indicated on the ELF object file by a symbol with SHN_COMMON section
|
2009-08-14 19:45:38 +00:00
|
|
|
/// header index.
|
|
|
|
bool HasCommonSymbols() const;
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2010-03-15 06:23:52 +00:00
|
|
|
StringRef getSectionName() const { return SectionName; }
|
2009-08-13 05:07:35 +00:00
|
|
|
unsigned getType() const { return Type; }
|
|
|
|
unsigned getFlags() const { return Flags; }
|
2010-08-16 18:35:43 +00:00
|
|
|
unsigned getEntrySize() const { return EntrySize; }
|
2010-11-11 18:13:52 +00:00
|
|
|
const MCSymbol *getGroup() const { return Group; }
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2010-04-08 21:26:26 +00:00
|
|
|
void PrintSwitchToSection(const MCAsmInfo &MAI,
|
|
|
|
raw_ostream &OS) const;
|
2010-10-04 17:32:41 +00:00
|
|
|
virtual bool UseCodeAlign() const;
|
2010-11-17 20:03:54 +00:00
|
|
|
virtual bool isVirtualSection() const;
|
2010-10-04 17:32:41 +00:00
|
|
|
|
2010-04-04 23:22:29 +00:00
|
|
|
/// isBaseAddressKnownZero - We know that non-allocatable sections (like
|
|
|
|
/// debug info) have a base of zero.
|
|
|
|
virtual bool isBaseAddressKnownZero() const {
|
2011-01-23 04:43:11 +00:00
|
|
|
return (getFlags() & ELF::SHF_ALLOC) == 0;
|
2010-04-04 23:22:29 +00:00
|
|
|
}
|
2010-05-17 21:54:26 +00:00
|
|
|
|
|
|
|
static bool classof(const MCSection *S) {
|
|
|
|
return S->getVariant() == SV_ELF;
|
|
|
|
}
|
|
|
|
static bool classof(const MCSectionELF *) { return true; }
|
2010-09-30 05:59:22 +00:00
|
|
|
|
|
|
|
// Return the entry size for sections with fixed-width data.
|
|
|
|
static unsigned DetermineEntrySize(SectionKind Kind);
|
|
|
|
|
2009-08-13 05:07:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|