Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.1 KiB

  1. //===- MCSectionELF.h - ELF Machine Code Sections ---------------*- 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 declares the MCSectionELF class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCSECTIONELF_H
  14. #define LLVM_MC_MCSECTIONELF_H
  15. #include "llvm/ADT/StringRef.h"
  16. #include "llvm/MC/MCSection.h"
  17. #include "llvm/Support/Debug.h"
  18. #include "llvm/Support/ELF.h"
  19. #include "llvm/Support/raw_ostream.h"
  20. namespace llvm {
  21. class MCSymbol;
  22. /// MCSectionELF - This represents a section on linux, lots of unix variants
  23. /// and some bare metal systems.
  24. class MCSectionELF : public MCSection {
  25. /// SectionName - This is the name of the section. The referenced memory is
  26. /// owned by TargetLoweringObjectFileELF's ELFUniqueMap.
  27. StringRef SectionName;
  28. /// Type - This is the sh_type field of a section, drawn from the enums below.
  29. unsigned Type;
  30. /// Flags - This is the sh_flags field of a section, drawn from the enums.
  31. /// below.
  32. unsigned Flags;
  33. /// EntrySize - The size of each entry in this section. This size only
  34. /// makes sense for sections that contain fixed-sized entries. If a
  35. /// section does not contain fixed-sized entries 'EntrySize' will be 0.
  36. unsigned EntrySize;
  37. const MCSymbol *Group;
  38. private:
  39. friend class MCContext;
  40. MCSectionELF(StringRef Section, unsigned type, unsigned flags,
  41. SectionKind K, unsigned entrySize, const MCSymbol *group)
  42. : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags),
  43. EntrySize(entrySize), Group(group) {}
  44. ~MCSectionELF();
  45. public:
  46. /// ShouldOmitSectionDirective - Decides whether a '.section' directive
  47. /// should be printed before the section name
  48. bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
  49. StringRef getSectionName() const { return SectionName; }
  50. virtual std::string getLabelBeginName() const {
  51. return SectionName.str() + "_begin"; }
  52. virtual std::string getLabelEndName() const {
  53. return SectionName.str() + "_end";
  54. }
  55. unsigned getType() const { return Type; }
  56. unsigned getFlags() const { return Flags; }
  57. unsigned getEntrySize() const { return EntrySize; }
  58. const MCSymbol *getGroup() const { return Group; }
  59. void PrintSwitchToSection(const MCAsmInfo &MAI,
  60. raw_ostream &OS,
  61. const MCExpr *Subsection) const;
  62. virtual bool UseCodeAlign() const;
  63. virtual bool isVirtualSection() const;
  64. /// isBaseAddressKnownZero - We know that non-allocatable sections (like
  65. /// debug info) have a base of zero.
  66. virtual bool isBaseAddressKnownZero() const {
  67. return (getFlags() & ELF::SHF_ALLOC) == 0;
  68. }
  69. static bool classof(const MCSection *S) {
  70. return S->getVariant() == SV_ELF;
  71. }
  72. // Return the entry size for sections with fixed-width data.
  73. static unsigned DetermineEntrySize(SectionKind Kind);
  74. };
  75. } // end namespace llvm
  76. #endif