22 {
"regular",
"S_REGULAR" },
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 { 0,
"S_GB_ZEROFILL" },
35 {
"interposing",
"S_INTERPOSING" },
36 {
"16byte_literals",
"S_16BYTE_LITERALS" },
37 { 0,
"S_DTRACE_DOF" },
38 { 0,
"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"},
57 #define ENTRY(ASMNAME, ENUM) \
58 { MCSectionMachO::ENUM, ASMNAME, #ENUM },
59 ENTRY(
"pure_instructions", S_ATTR_PURE_INSTRUCTIONS)
60 ENTRY(
"no_toc", S_ATTR_NO_TOC)
61 ENTRY(
"strip_static_syms", S_ATTR_STRIP_STATIC_SYMS)
62 ENTRY(
"no_dead_strip", S_ATTR_NO_DEAD_STRIP)
63 ENTRY(
"live_support", S_ATTR_LIVE_SUPPORT)
64 ENTRY(
"self_modifying_code", S_ATTR_SELF_MODIFYING_CODE)
65 ENTRY(
"debug", S_ATTR_DEBUG)
66 ENTRY(0 , S_ATTR_SOME_INSTRUCTIONS)
67 ENTRY(0 , S_ATTR_EXT_RELOC)
68 ENTRY(0 , S_ATTR_LOC_RELOC)
71 #define AttrFlagEnd 0xffffffff // non legal value, multiple attribute bits set
77 :
MCSection(SV_MachO, K), TypeAndAttributes(TAA), Reserved2(reserved2) {
78 assert(Segment.
size() <= 16 && Section.
size() <= 16 &&
79 "Segment or section string too long");
80 for (
unsigned i = 0; i != 16; ++i) {
81 if (i < Segment.
size())
82 SegmentName[i] = Segment[i];
86 if (i < Section.
size())
87 SectionName[i] = Section[i];
93 void MCSectionMachO::PrintSwitchToSection(
const MCAsmInfo &MAI,
95 const MCExpr *Subsection)
const {
105 unsigned SectionType = TAA & MCSectionMachO::SECTION_TYPE;
106 assert(SectionType <= MCSectionMachO::LAST_KNOWN_SECTION_TYPE &&
107 "Invalid SectionType specified!");
119 unsigned SectionAttrs = TAA & MCSectionMachO::SECTION_ATTRIBUTES;
120 if (SectionAttrs == 0) {
124 OS <<
",none," << Reserved2;
130 char Separator =
',';
149 assert(SectionAttrs == 0 &&
"Unknown section attributes!");
153 OS <<
',' << Reserved2;
158 return hasAttribute(MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS);
169 while (!Str.
empty() && isspace(static_cast<unsigned char>(Str[0])))
171 while (!Str.
empty() && isspace(static_cast<unsigned char>(Str.
back())))
185 unsigned &StubSize) {
188 std::pair<StringRef, StringRef> Comma = Spec.
split(
',');
191 if (Comma.second.empty())
192 return "mach-o section specifier requires a segment and section "
193 "separated by a comma";
196 Segment = Comma.first;
200 if (Segment.
empty() || Segment.
size() > 16)
201 return "mach-o section specifier requires a segment whose length is "
202 "between 1 and 16 characters";
205 Comma = Comma.second.split(
',');
208 Section = Comma.first;
212 if (Section.
empty() || Section.
size() > 16)
213 return "mach-o section specifier requires a section whose length is "
214 "between 1 and 16 characters";
219 if (Comma.second.empty())
223 Comma = Comma.second.split(
',');
231 for (TypeID = 0; TypeID !=MCSectionMachO::LAST_KNOWN_SECTION_TYPE+1; ++
TypeID)
237 if (TypeID > MCSectionMachO::LAST_KNOWN_SECTION_TYPE)
238 return "mach-o section specifier uses an unknown section type";
245 if (Comma.second.empty()) {
248 return "mach-o section specifier of type 'symbol_stubs' requires a size "
255 Comma = Comma.second.split(
',');
259 std::pair<StringRef, StringRef> Plus = Attrs.
split(
'+');
266 for (
unsigned i = 0; ; ++i) {
268 return "mach-o section specifier has invalid attribute";
277 if (Plus.second.empty())
break;
278 Plus = Plus.second.split(
'+');
282 if (Comma.second.empty()) {
285 return "mach-o section specifier of type 'symbol_stubs' requires a size "
292 return "mach-o section specifier cannot have a stub size specified because "
293 "it does not have type 'symbol_stubs'";
301 return "mach-o section specifier has a malformed stub size";
size_t size() const
size - Get the string size.
std::pair< StringRef, StringRef > split(char Separator) const
StringRef substr(size_t Start, size_t N=npos) const
virtual bool UseCodeAlign() const
#define ENTRY(ASMNAME, ENUM)
StringRef getSectionName() const
static std::string ParseSectionSpecifier(StringRef Spec, StringRef &Segment, StringRef &Section, unsigned &TAA, bool &TAAParsed, unsigned &StubSize)
static void StripSpaces(StringRef &Str)
StripSpaces - This removes leading and trailing spaces from the StringRef.
bool hasAttribute(unsigned Value) const
char back() const
back - Get the last character in the string.
virtual bool isVirtualSection() const
enable_if_c< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
static const struct @166 SectionTypeDescriptors[MCSectionMachO::LAST_KNOWN_SECTION_TYPE+1]
StringRef getSegmentName() const
const char * AssemblerName
unsigned getTypeAndAttributes() const
static const struct @167 SectionAttrDescriptors[]
bool empty() const
empty - Check if the string is empty.