22 {
"regular",
"S_REGULAR" },
23 {
nullptr,
"S_ZEROFILL" },
24 {
"cstring_literals",
"S_CSTRING_LITERALS" },
25 {
"4byte_literals",
"S_4BYTE_LITERALS" },
26 {
"8byte_literals",
"S_8BYTE_LITERALS" },
27 {
"literal_pointers",
"S_LITERAL_POINTERS" },
28 {
"non_lazy_symbol_pointers",
"S_NON_LAZY_SYMBOL_POINTERS" },
29 {
"lazy_symbol_pointers",
"S_LAZY_SYMBOL_POINTERS" },
30 {
"symbol_stubs",
"S_SYMBOL_STUBS" },
31 {
"mod_init_funcs",
"S_MOD_INIT_FUNC_POINTERS" },
32 {
"mod_term_funcs",
"S_MOD_TERM_FUNC_POINTERS" },
33 {
"coalesced",
"S_COALESCED" },
34 {
nullptr,
"S_GB_ZEROFILL" },
35 {
"interposing",
"S_INTERPOSING" },
36 {
"16byte_literals",
"S_16BYTE_LITERALS" },
37 {
nullptr,
"S_DTRACE_DOF" },
38 {
nullptr,
"S_LAZY_DYLIB_SYMBOL_POINTERS" },
39 {
"thread_local_regular",
"S_THREAD_LOCAL_REGULAR" },
40 {
"thread_local_zerofill",
"S_THREAD_LOCAL_ZEROFILL" },
41 {
"thread_local_variables",
"S_THREAD_LOCAL_VARIABLES" },
42 {
"thread_local_variable_pointers",
43 "S_THREAD_LOCAL_VARIABLE_POINTERS" },
44 {
"thread_local_init_function_pointers",
45 "S_THREAD_LOCAL_INIT_FUNCTION_POINTERS"},
56 #define ENTRY(ASMNAME, ENUM) \
57 { MachO::ENUM, ASMNAME, #ENUM },
69 { 0,
"none",
nullptr },
75 :
MCSection(SV_MachO, K, Begin), TypeAndAttributes(TAA),
76 Reserved2(reserved2) {
77 assert(Segment.
size() <= 16 && Section.
size() <= 16 &&
78 "Segment or section string too long");
79 for (
unsigned i = 0; i != 16; ++i) {
80 if (i < Segment.
size())
81 SegmentName[i] = Segment[i];
85 if (i < Section.
size())
86 SectionName[i] = Section[i];
92 void MCSectionMachO::PrintSwitchToSection(
const MCAsmInfo &MAI,
94 const MCExpr *Subsection)
const {
106 "Invalid SectionType specified!");
119 if (SectionAttrs == 0) {
123 OS <<
",none," << Reserved2;
129 char Separator =
',';
148 assert(SectionAttrs == 0 &&
"Unknown section attributes!");
152 OS <<
',' << Reserved2;
176 unsigned &StubSize) {
180 Spec.
split(SplitSpec,
",");
182 auto GetEmptyOrTrim = [&SplitSpec](
size_t Idx) ->
StringRef {
183 return SplitSpec.
size() > Idx ? SplitSpec[Idx].trim() :
StringRef();
185 Segment = GetEmptyOrTrim(0);
186 Section = GetEmptyOrTrim(1);
189 StringRef StubSizeStr = GetEmptyOrTrim(4);
192 if (Segment.
empty() || Segment.
size() > 16)
193 return "mach-o section specifier requires a segment whose length is "
194 "between 1 and 16 characters";
198 return "mach-o section specifier requires a segment and section "
199 "separated by a comma";
201 if (Section.
size() > 16)
202 return "mach-o section specifier requires a section whose length is "
203 "between 1 and 16 characters";
208 if (SectionType.
empty())
212 auto TypeDescriptor = std::find_if(
215 return Descriptor.AssemblerName &&
216 SectionType == Descriptor.AssemblerName;
221 return "mach-o section specifier uses an unknown section type";
231 return "mach-o section specifier of type 'symbol_stubs' requires a size "
238 Attrs.
split(SectionAttrs,
"+", -1,
false);
240 for (
StringRef &SectionAttr : SectionAttrs) {
241 auto AttrDescriptorI = std::find_if(
244 return Descriptor.AssemblerName &&
245 SectionAttr.trim() == Descriptor.AssemblerName;
248 return "mach-o section specifier has invalid attribute";
250 TAA |= AttrDescriptorI->AttrFlag;
254 if (StubSizeStr.
empty()) {
257 return "mach-o section specifier of type 'symbol_stubs' requires a size "
264 return "mach-o section specifier cannot have a stub size specified because "
265 "it does not have type 'symbol_stubs'";
269 return "mach-o section specifier has a malformed stub size";
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const_iterator end(StringRef path)
Get end iterator over path.
S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in the Reserved2 field.
size_t size() const
size - Get the string size.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
const_iterator begin(StringRef path)
Get begin iterator over path.
Base class for the full range of assembler expressions which are needed for parsing.
#define ENTRY(ASMNAME, ENUM)
StringRef getSectionName() const
S_ATTR_EXT_RELOC - Section has external relocation entries.
This class is intended to be used as a base class for asm properties and features specific to the tar...
S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section in files with the MY_DYLDLINK f...
static std::string ParseSectionSpecifier(StringRef Spec, StringRef &Segment, StringRef &Section, unsigned &TAA, bool &TAAParsed, unsigned &StubSize)
ParseSectionSpecifier - Parse the section specifier indicated by "Spec".
S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine instructions.
S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4 gigabytes).
S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
bool hasAttribute(unsigned Value) const
SectionKind - This is a simple POD value that classifies the properties of a section.
bool UseCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
S_ATTR_NO_DEAD_STRIP - No dead stripping.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static const struct @220 SectionAttrDescriptors[]
SectionAttrDescriptors - This is an array of descriptors for section attributes.
MachO::SectionType getType() const
S_ATTR_LOC_RELOC - Section has local relocation entries.
StringRef getSegmentName() const
S_ATTR_DEBUG - A debug section.
S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by dyld.
const char * AssemblerName
bool isVirtualSection() const override
Check whether this section is "virtual", that is has no actual object file contents.
unsigned getTypeAndAttributes() const
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
static const struct @219 SectionTypeDescriptors[MachO::LAST_KNOWN_SECTION_TYPE+1]
SectionTypeDescriptors - These are strings that describe the various section types.
S_ZEROFILL - Zero fill on demand section.
SectionType
These are the section type and attributes fields.
S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be in a ranlib table of contents...
bool empty() const
empty - Check if the string is empty.