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
|
|
|
|
|
2014-04-29 23:26:49 +00:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2009-08-13 05:07:35 +00:00
|
|
|
#include "llvm/MC/MCSection.h"
|
2015-06-02 21:30:13 +00:00
|
|
|
#include "llvm/MC/MCSymbolELF.h"
|
2013-01-02 10:22:59 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2011-01-23 04:43:11 +00:00
|
|
|
#include "llvm/Support/ELF.h"
|
2012-12-13 03:00:35 +00:00
|
|
|
#include "llvm/Support/raw_ostream.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;
|
|
|
|
|
2015-04-04 18:02:01 +00:00
|
|
|
unsigned UniqueID;
|
|
|
|
|
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
|
|
|
|
2015-06-02 21:30:13 +00:00
|
|
|
const MCSymbolELF *Group;
|
2010-11-11 18:13:52 +00:00
|
|
|
|
2015-04-06 03:09:30 +00:00
|
|
|
/// Depending on the type of the section this is sh_link or sh_info.
|
|
|
|
const MCSectionELF *Associated;
|
|
|
|
|
2010-04-08 21:26:26 +00:00
|
|
|
private:
|
|
|
|
friend class MCContext;
|
2015-02-17 20:48:01 +00:00
|
|
|
MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K,
|
2015-06-02 21:30:13 +00:00
|
|
|
unsigned entrySize, const MCSymbolELF *group, unsigned UniqueID,
|
2015-04-06 03:09:30 +00:00
|
|
|
MCSymbol *Begin, const MCSectionELF *Associated)
|
2015-04-04 18:02:01 +00:00
|
|
|
: MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
|
2015-04-06 03:09:30 +00:00
|
|
|
Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group),
|
2015-06-03 21:41:59 +00:00
|
|
|
Associated(Associated) {
|
|
|
|
if (Group)
|
|
|
|
Group->setIsSignature();
|
|
|
|
}
|
2015-04-11 02:11:45 +00:00
|
|
|
~MCSectionELF() override;
|
2014-04-10 21:53:53 +00:00
|
|
|
|
|
|
|
void setSectionName(StringRef Name) { SectionName = Name; }
|
2014-04-11 22:11:50 +00:00
|
|
|
|
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
|
|
|
|
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; }
|
2015-06-02 21:30:13 +00:00
|
|
|
const MCSymbolELF *getGroup() const { return Group; }
|
2010-10-06 20:36:38 +00:00
|
|
|
|
2014-03-07 09:26:03 +00:00
|
|
|
void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
|
|
|
|
const MCExpr *Subsection) const override;
|
|
|
|
bool UseCodeAlign() const override;
|
|
|
|
bool isVirtualSection() const override;
|
2010-10-04 17:32:41 +00:00
|
|
|
|
2015-04-04 18:02:01 +00:00
|
|
|
bool isUnique() const { return UniqueID != ~0U; }
|
|
|
|
unsigned getUniqueID() const { return UniqueID; }
|
|
|
|
|
2015-04-06 03:09:30 +00:00
|
|
|
const MCSectionELF *getAssociatedSection() const { return Associated; }
|
|
|
|
|
2010-05-17 21:54:26 +00:00
|
|
|
static bool classof(const MCSection *S) {
|
|
|
|
return S->getVariant() == SV_ELF;
|
|
|
|
}
|
2009-08-13 05:07:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|