Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCSectionMachO.cpp - MachO Code Section Representation ------===// |
| 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 | #include "llvm/MC/MCSectionMachO.h" |
| 11 | #include "llvm/MC/MCContext.h" |
| 12 | #include "llvm/Support/raw_ostream.h" |
Nick Lewycky | 0de20af | 2010-12-19 20:43:38 +0000 | [diff] [blame] | 13 | #include <cctype> |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 14 | using namespace llvm; |
| 15 | |
| 16 | /// SectionTypeDescriptors - These are strings that describe the various section |
| 17 | /// types. This *must* be kept in order with and stay synchronized with the |
| 18 | /// section type list. |
| 19 | static const struct { |
| 20 | const char *AssemblerName, *EnumName; |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 21 | } SectionTypeDescriptors[MachO::LAST_KNOWN_SECTION_TYPE+1] = { |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 22 | { "regular", "S_REGULAR" }, // 0x00 |
| 23 | { 0, "S_ZEROFILL" }, // 0x01 |
| 24 | { "cstring_literals", "S_CSTRING_LITERALS" }, // 0x02 |
| 25 | { "4byte_literals", "S_4BYTE_LITERALS" }, // 0x03 |
| 26 | { "8byte_literals", "S_8BYTE_LITERALS" }, // 0x04 |
| 27 | { "literal_pointers", "S_LITERAL_POINTERS" }, // 0x05 |
| 28 | { "non_lazy_symbol_pointers", "S_NON_LAZY_SYMBOL_POINTERS" }, // 0x06 |
| 29 | { "lazy_symbol_pointers", "S_LAZY_SYMBOL_POINTERS" }, // 0x07 |
| 30 | { "symbol_stubs", "S_SYMBOL_STUBS" }, // 0x08 |
| 31 | { "mod_init_funcs", "S_MOD_INIT_FUNC_POINTERS" }, // 0x09 |
| 32 | { "mod_term_funcs", "S_MOD_TERM_FUNC_POINTERS" }, // 0x0A |
| 33 | { "coalesced", "S_COALESCED" }, // 0x0B |
| 34 | { 0, /*FIXME??*/ "S_GB_ZEROFILL" }, // 0x0C |
| 35 | { "interposing", "S_INTERPOSING" }, // 0x0D |
| 36 | { "16byte_literals", "S_16BYTE_LITERALS" }, // 0x0E |
| 37 | { 0, /*FIXME??*/ "S_DTRACE_DOF" }, // 0x0F |
Eric Christopher | bf79238 | 2010-05-17 21:02:07 +0000 | [diff] [blame] | 38 | { 0, /*FIXME??*/ "S_LAZY_DYLIB_SYMBOL_POINTERS" }, // 0x10 |
| 39 | { "thread_local_regular", "S_THREAD_LOCAL_REGULAR" }, // 0x11 |
Eric Christopher | 3dca28d | 2010-05-21 21:08:52 +0000 | [diff] [blame] | 40 | { "thread_local_zerofill", "S_THREAD_LOCAL_ZEROFILL" }, // 0x12 |
Eric Christopher | bf79238 | 2010-05-17 21:02:07 +0000 | [diff] [blame] | 41 | { "thread_local_variables", "S_THREAD_LOCAL_VARIABLES" }, // 0x13 |
| 42 | { "thread_local_variable_pointers", |
| 43 | "S_THREAD_LOCAL_VARIABLE_POINTERS" }, // 0x14 |
| 44 | { "thread_local_init_function_pointers", |
| 45 | "S_THREAD_LOCAL_INIT_FUNCTION_POINTERS"}, // 0x15 |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | |
| 49 | /// SectionAttrDescriptors - This is an array of descriptors for section |
| 50 | /// attributes. Unlike the SectionTypeDescriptors, this is not directly indexed |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 51 | /// by attribute, instead it is searched. |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 52 | static const struct { |
| 53 | unsigned AttrFlag; |
| 54 | const char *AssemblerName, *EnumName; |
| 55 | } SectionAttrDescriptors[] = { |
| 56 | #define ENTRY(ASMNAME, ENUM) \ |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 57 | { MachO::ENUM, ASMNAME, #ENUM }, |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 58 | ENTRY("pure_instructions", S_ATTR_PURE_INSTRUCTIONS) |
| 59 | ENTRY("no_toc", S_ATTR_NO_TOC) |
| 60 | ENTRY("strip_static_syms", S_ATTR_STRIP_STATIC_SYMS) |
| 61 | ENTRY("no_dead_strip", S_ATTR_NO_DEAD_STRIP) |
| 62 | ENTRY("live_support", S_ATTR_LIVE_SUPPORT) |
| 63 | ENTRY("self_modifying_code", S_ATTR_SELF_MODIFYING_CODE) |
| 64 | ENTRY("debug", S_ATTR_DEBUG) |
| 65 | ENTRY(0 /*FIXME*/, S_ATTR_SOME_INSTRUCTIONS) |
| 66 | ENTRY(0 /*FIXME*/, S_ATTR_EXT_RELOC) |
| 67 | ENTRY(0 /*FIXME*/, S_ATTR_LOC_RELOC) |
| 68 | #undef ENTRY |
Kevin Enderby | 818b6b9 | 2009-10-07 20:57:20 +0000 | [diff] [blame] | 69 | { 0, "none", 0 }, // used if section has no attributes but has a stub size |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
Chris Lattner | 5418dd5 | 2010-04-08 21:26:26 +0000 | [diff] [blame] | 72 | MCSectionMachO::MCSectionMachO(StringRef Segment, StringRef Section, |
| 73 | unsigned TAA, unsigned reserved2, SectionKind K) |
Daniel Dunbar | ce5e1bb | 2010-05-17 21:54:26 +0000 | [diff] [blame] | 74 | : MCSection(SV_MachO, K), TypeAndAttributes(TAA), Reserved2(reserved2) { |
Chris Lattner | 5418dd5 | 2010-04-08 21:26:26 +0000 | [diff] [blame] | 75 | assert(Segment.size() <= 16 && Section.size() <= 16 && |
| 76 | "Segment or section string too long"); |
| 77 | for (unsigned i = 0; i != 16; ++i) { |
| 78 | if (i < Segment.size()) |
| 79 | SegmentName[i] = Segment[i]; |
| 80 | else |
| 81 | SegmentName[i] = 0; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 82 | |
Chris Lattner | 5418dd5 | 2010-04-08 21:26:26 +0000 | [diff] [blame] | 83 | if (i < Section.size()) |
| 84 | SectionName[i] = Section[i]; |
| 85 | else |
| 86 | SectionName[i] = 0; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 87 | } |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Chris Lattner | e9a75a6 | 2009-08-22 21:43:10 +0000 | [diff] [blame] | 90 | void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI, |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 91 | raw_ostream &OS, |
| 92 | const MCExpr *Subsection) const { |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 93 | OS << "\t.section\t" << getSegmentName() << ',' << getSectionName(); |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 94 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 95 | // Get the section type and attributes. |
| 96 | unsigned TAA = getTypeAndAttributes(); |
| 97 | if (TAA == 0) { |
| 98 | OS << '\n'; |
| 99 | return; |
| 100 | } |
| 101 | |
David Majnemer | cd481d3 | 2014-03-07 18:49:54 +0000 | [diff] [blame] | 102 | MachO::SectionType SectionType = getType(); |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 103 | assert(SectionType <= MachO::LAST_KNOWN_SECTION_TYPE && |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 104 | "Invalid SectionType specified!"); |
| 105 | |
Stuart Hastings | b4863a4 | 2011-02-21 17:27:17 +0000 | [diff] [blame] | 106 | if (SectionTypeDescriptors[SectionType].AssemblerName) { |
| 107 | OS << ','; |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 108 | OS << SectionTypeDescriptors[SectionType].AssemblerName; |
Stuart Hastings | d7927e0 | 2011-02-21 21:07:07 +0000 | [diff] [blame] | 109 | } else { |
Stuart Hastings | b4863a4 | 2011-02-21 17:27:17 +0000 | [diff] [blame] | 110 | // If we have no name for the attribute, stop here. |
Stuart Hastings | d7927e0 | 2011-02-21 21:07:07 +0000 | [diff] [blame] | 111 | OS << '\n'; |
Stuart Hastings | b4863a4 | 2011-02-21 17:27:17 +0000 | [diff] [blame] | 112 | return; |
Stuart Hastings | d7927e0 | 2011-02-21 21:07:07 +0000 | [diff] [blame] | 113 | } |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 114 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 115 | // If we don't have any attributes, we're done. |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 116 | unsigned SectionAttrs = TAA & MachO::SECTION_ATTRIBUTES; |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 117 | if (SectionAttrs == 0) { |
| 118 | // If we have a S_SYMBOL_STUBS size specified, print it along with 'none' as |
| 119 | // the attribute specifier. |
| 120 | if (Reserved2 != 0) |
| 121 | OS << ",none," << Reserved2; |
| 122 | OS << '\n'; |
| 123 | return; |
| 124 | } |
| 125 | |
| 126 | // Check each attribute to see if we have it. |
| 127 | char Separator = ','; |
Stuart Hastings | b4863a4 | 2011-02-21 17:27:17 +0000 | [diff] [blame] | 128 | for (unsigned i = 0; |
| 129 | SectionAttrs != 0 && SectionAttrDescriptors[i].AttrFlag; |
| 130 | ++i) { |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 131 | // Check to see if we have this attribute. |
| 132 | if ((SectionAttrDescriptors[i].AttrFlag & SectionAttrs) == 0) |
| 133 | continue; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 134 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 135 | // Yep, clear it and print it. |
| 136 | SectionAttrs &= ~SectionAttrDescriptors[i].AttrFlag; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 137 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 138 | OS << Separator; |
| 139 | if (SectionAttrDescriptors[i].AssemblerName) |
| 140 | OS << SectionAttrDescriptors[i].AssemblerName; |
| 141 | else |
| 142 | OS << "<<" << SectionAttrDescriptors[i].EnumName << ">>"; |
| 143 | Separator = '+'; |
| 144 | } |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 145 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 146 | assert(SectionAttrs == 0 && "Unknown section attributes!"); |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 147 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 148 | // If we have a S_SYMBOL_STUBS size specified, print it. |
| 149 | if (Reserved2 != 0) |
| 150 | OS << ',' << Reserved2; |
| 151 | OS << '\n'; |
| 152 | } |
| 153 | |
Jan Wen Voung | 87f77b5 | 2010-10-04 17:32:41 +0000 | [diff] [blame] | 154 | bool MCSectionMachO::UseCodeAlign() const { |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 155 | return hasAttribute(MachO::S_ATTR_PURE_INSTRUCTIONS); |
Jan Wen Voung | 87f77b5 | 2010-10-04 17:32:41 +0000 | [diff] [blame] | 156 | } |
| 157 | |
Rafael Espindola | 7a2cd8b | 2010-11-17 20:03:54 +0000 | [diff] [blame] | 158 | bool MCSectionMachO::isVirtualSection() const { |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 159 | return (getType() == MachO::S_ZEROFILL || |
| 160 | getType() == MachO::S_GB_ZEROFILL || |
| 161 | getType() == MachO::S_THREAD_LOCAL_ZEROFILL); |
Rafael Espindola | 7a2cd8b | 2010-11-17 20:03:54 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 164 | /// ParseSectionSpecifier - Parse the section specifier indicated by "Spec". |
| 165 | /// This is a string that can appear after a .section directive in a mach-o |
| 166 | /// flavored .s file. If successful, this fills in the specified Out |
| 167 | /// parameters and returns an empty string. When an invalid section |
| 168 | /// specifier is present, this returns a string indicating the problem. |
| 169 | std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec, // In. |
| 170 | StringRef &Segment, // Out. |
| 171 | StringRef &Section, // Out. |
| 172 | unsigned &TAA, // Out. |
Stuart Hastings | 12d5312 | 2011-03-19 02:42:31 +0000 | [diff] [blame] | 173 | bool &TAAParsed, // Out. |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 174 | unsigned &StubSize) { // Out. |
Stuart Hastings | 12d5312 | 2011-03-19 02:42:31 +0000 | [diff] [blame] | 175 | TAAParsed = false; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 176 | |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 177 | SmallVector<StringRef, 5> SplitSpec; |
| 178 | Spec.split(SplitSpec, ","); |
| 179 | // Remove leading and trailing whitespace. |
| 180 | auto GetEmptyOrTrim = [&SplitSpec](size_t Idx) -> StringRef { |
| 181 | return SplitSpec.size() > Idx ? SplitSpec[Idx].trim() : StringRef(); |
| 182 | }; |
| 183 | Segment = GetEmptyOrTrim(0); |
| 184 | Section = GetEmptyOrTrim(1); |
| 185 | StringRef SectionType = GetEmptyOrTrim(2); |
| 186 | StringRef Attrs = GetEmptyOrTrim(3); |
| 187 | StringRef StubSizeStr = GetEmptyOrTrim(4); |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 188 | |
| 189 | // Verify that the segment is present and not too long. |
| 190 | if (Segment.empty() || Segment.size() > 16) |
| 191 | return "mach-o section specifier requires a segment whose length is " |
| 192 | "between 1 and 16 characters"; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 193 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 194 | // Verify that the section is present and not too long. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 195 | if (Section.empty()) |
| 196 | return "mach-o section specifier requires a segment and section " |
| 197 | "separated by a comma"; |
| 198 | |
| 199 | if (Section.size() > 16) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 200 | return "mach-o section specifier requires a section whose length is " |
| 201 | "between 1 and 16 characters"; |
| 202 | |
| 203 | // If there is no comma after the section, we're done. |
Stuart Hastings | 12d5312 | 2011-03-19 02:42:31 +0000 | [diff] [blame] | 204 | TAA = 0; |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 205 | StubSize = 0; |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 206 | if (SectionType.empty()) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 207 | return ""; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 208 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 209 | // Figure out which section type it is. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 210 | auto TypeDescriptor = std::find_if( |
| 211 | std::begin(SectionTypeDescriptors), std::end(SectionTypeDescriptors), |
| 212 | [&](const decltype(*SectionTypeDescriptors) &Descriptor) { |
| 213 | return Descriptor.AssemblerName && |
| 214 | SectionType == Descriptor.AssemblerName; |
| 215 | }); |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 216 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 217 | // If we didn't find the section type, reject it. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 218 | if (TypeDescriptor == std::end(SectionTypeDescriptors)) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 219 | return "mach-o section specifier uses an unknown section type"; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 220 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 221 | // Remember the TypeID. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 222 | TAA = TypeDescriptor - std::begin(SectionTypeDescriptors); |
Stuart Hastings | 12d5312 | 2011-03-19 02:42:31 +0000 | [diff] [blame] | 223 | TAAParsed = true; |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 224 | |
| 225 | // If we have no comma after the section type, there are no attributes. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 226 | if (Attrs.empty()) { |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 227 | // S_SYMBOL_STUBS always require a symbol stub size specifier. |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 228 | if (TAA == MachO::S_SYMBOL_STUBS) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 229 | return "mach-o section specifier of type 'symbol_stubs' requires a size " |
| 230 | "specifier"; |
| 231 | return ""; |
| 232 | } |
| 233 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 234 | // The attribute list is a '+' separated list of attributes. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 235 | SmallVector<StringRef, 1> SectionAttrs; |
| 236 | Attrs.split(SectionAttrs, "+", /*MaxSplit=*/-1, /*KeepEmpty=*/false); |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 237 | |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 238 | for (StringRef &SectionAttr : SectionAttrs) { |
| 239 | auto AttrDescriptorI = std::find_if( |
| 240 | std::begin(SectionAttrDescriptors), std::end(SectionAttrDescriptors), |
| 241 | [&](const decltype(*SectionAttrDescriptors) &Descriptor) { |
| 242 | return Descriptor.AssemblerName && |
| 243 | SectionAttr.trim() == Descriptor.AssemblerName; |
| 244 | }); |
| 245 | if (AttrDescriptorI == std::end(SectionAttrDescriptors)) |
| 246 | return "mach-o section specifier has invalid attribute"; |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 247 | |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 248 | TAA |= AttrDescriptorI->AttrFlag; |
| 249 | } |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 250 | |
| 251 | // Okay, we've parsed the section attributes, see if we have a stub size spec. |
David Majnemer | e500ec1 | 2014-03-10 00:55:07 +0000 | [diff] [blame^] | 252 | if (StubSizeStr.empty()) { |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 253 | // S_SYMBOL_STUBS always require a symbol stub size specifier. |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 254 | if (TAA == MachO::S_SYMBOL_STUBS) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 255 | return "mach-o section specifier of type 'symbol_stubs' requires a size " |
| 256 | "specifier"; |
| 257 | return ""; |
| 258 | } |
| 259 | |
| 260 | // If we have a stub size spec, we must have a sectiontype of S_SYMBOL_STUBS. |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 261 | if ((TAA & MachO::SECTION_TYPE) != MachO::S_SYMBOL_STUBS) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 262 | return "mach-o section specifier cannot have a stub size specified because " |
| 263 | "it does not have type 'symbol_stubs'"; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 264 | |
Chris Lattner | a15f004 | 2009-09-20 06:58:54 +0000 | [diff] [blame] | 265 | // Convert the stub size from a string to an integer. |
| 266 | if (StubSizeStr.getAsInteger(0, StubSize)) |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 267 | return "mach-o section specifier has a malformed stub size"; |
Jim Grosbach | 90600d3 | 2010-10-21 22:04:05 +0000 | [diff] [blame] | 268 | |
Chris Lattner | 6c20391 | 2009-08-10 18:15:01 +0000 | [diff] [blame] | 269 | return ""; |
| 270 | } |