File indexing completed on 2026-05-10 08:44:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_MC_MCSECTIONMACHO_H
0014 #define LLVM_MC_MCSECTIONMACHO_H
0015
0016 #include "llvm/ADT/StringRef.h"
0017 #include "llvm/BinaryFormat/MachO.h"
0018 #include "llvm/MC/MCSection.h"
0019
0020 namespace llvm {
0021
0022
0023
0024 class MCSectionMachO final : public MCSection {
0025 char SegmentName[16];
0026
0027
0028
0029 unsigned TypeAndAttributes;
0030
0031
0032
0033 unsigned Reserved2;
0034
0035
0036
0037 unsigned LayoutOrder = 0;
0038
0039
0040 SmallVector<const MCSymbol *, 0> Atoms;
0041
0042 MCSectionMachO(StringRef Segment, StringRef Section, unsigned TAA,
0043 unsigned reserved2, SectionKind K, MCSymbol *Begin);
0044 friend class MCContext;
0045 public:
0046
0047 StringRef getSegmentName() const {
0048
0049 if (SegmentName[15])
0050 return StringRef(SegmentName, 16);
0051 return StringRef(SegmentName);
0052 }
0053
0054 unsigned getTypeAndAttributes() const { return TypeAndAttributes; }
0055 unsigned getStubSize() const { return Reserved2; }
0056
0057 MachO::SectionType getType() const {
0058 return static_cast<MachO::SectionType>(TypeAndAttributes &
0059 MachO::SECTION_TYPE);
0060 }
0061 bool hasAttribute(unsigned Value) const {
0062 return (TypeAndAttributes & Value) != 0;
0063 }
0064
0065
0066
0067
0068
0069
0070
0071 static Error ParseSectionSpecifier(StringRef Spec,
0072 StringRef &Segment,
0073 StringRef &Section,
0074 unsigned &TAA,
0075 bool &TAAParsed,
0076 unsigned &StubSize);
0077
0078 void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
0079 raw_ostream &OS,
0080 uint32_t Subsection) const override;
0081 bool useCodeAlign() const override;
0082
0083 void allocAtoms();
0084 const MCSymbol *getAtom(size_t I) const;
0085 void setAtom(size_t I, const MCSymbol *Sym);
0086
0087 unsigned getLayoutOrder() const { return LayoutOrder; }
0088 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
0089
0090 static bool classof(const MCSection *S) {
0091 return S->getVariant() == SV_MachO;
0092 }
0093 };
0094
0095 }
0096
0097 #endif