Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 1 | //===- DarwinAsmParser.cpp - Darwin (Mach-O) Assembly Parser --------------===// |
| 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/MCParser/MCAsmParserExtension.h" |
Rafael Espindola | c49ac5e | 2015-12-16 23:49:14 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/STLExtras.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/StringRef.h" |
| 13 | #include "llvm/ADT/StringSwitch.h" |
Akira Hatanaka | 8ad7399 | 2015-10-15 05:28:38 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/Triple.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/Twine.h" |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCContext.h" |
Akira Hatanaka | 8ad7399 | 2015-10-15 05:28:38 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCObjectFileInfo.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCParser/MCAsmLexer.h" |
| 19 | #include "llvm/MC/MCParser/MCAsmParser.h" |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCSectionMachO.h" |
| 21 | #include "llvm/MC/MCStreamer.h" |
| 22 | #include "llvm/MC/MCSymbol.h" |
Benjamin Kramer | d59664f | 2014-04-29 23:26:49 +0000 | [diff] [blame] | 23 | #include "llvm/Support/FileSystem.h" |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 24 | #include "llvm/Support/MemoryBuffer.h" |
| 25 | #include "llvm/Support/SourceMgr.h" |
| 26 | using namespace llvm; |
| 27 | |
| 28 | namespace { |
| 29 | |
| 30 | /// \brief Implementation of directive handling which is shared across all |
| 31 | /// Darwin targets. |
| 32 | class DarwinAsmParser : public MCAsmParserExtension { |
Eli Bendersky | 29b9f47 | 2013-01-16 00:50:52 +0000 | [diff] [blame] | 33 | template<bool (DarwinAsmParser::*HandlerMethod)(StringRef, SMLoc)> |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 34 | void addDirectiveHandler(StringRef Directive) { |
Eli Bendersky | 29b9f47 | 2013-01-16 00:50:52 +0000 | [diff] [blame] | 35 | MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair( |
| 36 | this, HandleDirective<DarwinAsmParser, HandlerMethod>); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 37 | getParser().addDirectiveHandler(Directive, Handler); |
Daniel Dunbar | 8897d47 | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Mehdi Amini | 215ff8d | 2016-10-05 01:02:22 +0000 | [diff] [blame] | 40 | bool parseSectionSwitch(StringRef Segment, StringRef Section, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 41 | unsigned TAA = 0, unsigned ImplicitAlign = 0, |
| 42 | unsigned StubSize = 0); |
| 43 | |
Tim Northover | 2d4d161 | 2015-10-28 22:36:05 +0000 | [diff] [blame] | 44 | SMLoc LastVersionMinDirective; |
| 45 | |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 46 | public: |
| 47 | DarwinAsmParser() {} |
| 48 | |
Craig Topper | 59be68f | 2014-03-08 07:14:16 +0000 | [diff] [blame] | 49 | void Initialize(MCAsmParser &Parser) override { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 50 | // Call the base implementation. |
| 51 | this->MCAsmParserExtension::Initialize(Parser); |
| 52 | |
Lang Hames | f9033bb | 2016-04-11 18:33:45 +0000 | [diff] [blame] | 53 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveAltEntry>(".alt_entry"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 54 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveDesc>(".desc"); |
| 55 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveIndirectSymbol>( |
Kevin Enderby | 3aeada2 | 2013-08-28 17:50:59 +0000 | [diff] [blame] | 56 | ".indirect_symbol"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 57 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveLsym>(".lsym"); |
| 58 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveSubsectionsViaSymbols>( |
Daniel Dunbar | 8897d47 | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 59 | ".subsections_via_symbols"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 60 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveDumpOrLoad>(".dump"); |
| 61 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveDumpOrLoad>(".load"); |
| 62 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveSection>(".section"); |
| 63 | addDirectiveHandler<&DarwinAsmParser::parseDirectivePushSection>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 64 | ".pushsection"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 65 | addDirectiveHandler<&DarwinAsmParser::parseDirectivePopSection>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 66 | ".popsection"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 67 | addDirectiveHandler<&DarwinAsmParser::parseDirectivePrevious>(".previous"); |
| 68 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveSecureLogUnique>( |
Daniel Dunbar | 8897d47 | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 69 | ".secure_log_unique"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 70 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveSecureLogReset>( |
Daniel Dunbar | 8897d47 | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 71 | ".secure_log_reset"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 72 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveTBSS>(".tbss"); |
| 73 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveZerofill>(".zerofill"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 74 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 75 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveDataRegion>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 76 | ".data_region"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 77 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveDataRegionEnd>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 78 | ".end_data_region"); |
Jim Grosbach | 4b63d2a | 2012-05-18 19:12:01 +0000 | [diff] [blame] | 79 | |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 80 | // Special section directives. |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 81 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveBss>(".bss"); |
| 82 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveConst>(".const"); |
| 83 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveConstData>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 84 | ".const_data"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 85 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveConstructor>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 86 | ".constructor"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 87 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveCString>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 88 | ".cstring"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 89 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveData>(".data"); |
| 90 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveDestructor>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 91 | ".destructor"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 92 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveDyld>(".dyld"); |
| 93 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveFVMLibInit0>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 94 | ".fvmlib_init0"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 95 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveFVMLibInit1>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 96 | ".fvmlib_init1"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 97 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 98 | &DarwinAsmParser::parseSectionDirectiveLazySymbolPointers>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 99 | ".lazy_symbol_pointer"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 100 | addDirectiveHandler<&DarwinAsmParser::parseDirectiveLinkerOption>( |
Daniel Dunbar | 16004b8 | 2013-01-18 01:25:48 +0000 | [diff] [blame] | 101 | ".linker_option"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 102 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveLiteral16>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 103 | ".literal16"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 104 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveLiteral4>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 105 | ".literal4"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 106 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveLiteral8>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 107 | ".literal8"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 108 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveModInitFunc>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 109 | ".mod_init_func"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 110 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveModTermFunc>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 111 | ".mod_term_func"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 112 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 113 | &DarwinAsmParser::parseSectionDirectiveNonLazySymbolPointers>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 114 | ".non_lazy_symbol_pointer"); |
Tim Northover | 5c3140f | 2016-04-25 21:12:04 +0000 | [diff] [blame] | 115 | addDirectiveHandler< |
| 116 | &DarwinAsmParser::parseSectionDirectiveThreadLocalVariablePointers>( |
| 117 | ".thread_local_variable_pointer"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 118 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCCatClsMeth>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 119 | ".objc_cat_cls_meth"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 120 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCCatInstMeth>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 121 | ".objc_cat_inst_meth"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 122 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCCategory>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 123 | ".objc_category"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 124 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClass>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 125 | ".objc_class"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 126 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClassNames>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 127 | ".objc_class_names"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 128 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClassVars>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 129 | ".objc_class_vars"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 130 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClsMeth>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 131 | ".objc_cls_meth"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 132 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClsRefs>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 133 | ".objc_cls_refs"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 134 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCInstMeth>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 135 | ".objc_inst_meth"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 136 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 137 | &DarwinAsmParser::parseSectionDirectiveObjCInstanceVars>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 138 | ".objc_instance_vars"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 139 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCMessageRefs>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 140 | ".objc_message_refs"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 141 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCMetaClass>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 142 | ".objc_meta_class"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 143 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 144 | &DarwinAsmParser::parseSectionDirectiveObjCMethVarNames>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 145 | ".objc_meth_var_names"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 146 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 147 | &DarwinAsmParser::parseSectionDirectiveObjCMethVarTypes>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 148 | ".objc_meth_var_types"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 149 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCModuleInfo>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 150 | ".objc_module_info"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 151 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCProtocol>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 152 | ".objc_protocol"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 153 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 154 | &DarwinAsmParser::parseSectionDirectiveObjCSelectorStrs>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 155 | ".objc_selector_strs"); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 156 | addDirectiveHandler< |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 157 | &DarwinAsmParser::parseSectionDirectiveObjCStringObject>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 158 | ".objc_string_object"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 159 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCSymbols>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 160 | ".objc_symbols"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 161 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectivePICSymbolStub>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 162 | ".picsymbol_stub"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 163 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveStaticConst>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 164 | ".static_const"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 165 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveStaticData>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 166 | ".static_data"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 167 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveSymbolStub>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 168 | ".symbol_stub"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 169 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveTData>(".tdata"); |
| 170 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveText>(".text"); |
| 171 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveThreadInitFunc>( |
Daniel Dunbar | b94c578 | 2013-01-18 01:25:25 +0000 | [diff] [blame] | 172 | ".thread_init_func"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 173 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveTLV>(".tlv"); |
Jim Grosbach | 14be61a | 2011-03-08 19:17:19 +0000 | [diff] [blame] | 174 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 175 | addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveIdent>(".ident"); |
Tim Northover | 2d4d161 | 2015-10-28 22:36:05 +0000 | [diff] [blame] | 176 | addDirectiveHandler<&DarwinAsmParser::parseVersionMin>( |
| 177 | ".watchos_version_min"); |
| 178 | addDirectiveHandler<&DarwinAsmParser::parseVersionMin>(".tvos_version_min"); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 179 | addDirectiveHandler<&DarwinAsmParser::parseVersionMin>(".ios_version_min"); |
| 180 | addDirectiveHandler<&DarwinAsmParser::parseVersionMin>( |
Jim Grosbach | 448334a | 2014-03-18 22:09:05 +0000 | [diff] [blame] | 181 | ".macosx_version_min"); |
Tim Northover | 2d4d161 | 2015-10-28 22:36:05 +0000 | [diff] [blame] | 182 | |
| 183 | LastVersionMinDirective = SMLoc(); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 184 | } |
| 185 | |
Lang Hames | f9033bb | 2016-04-11 18:33:45 +0000 | [diff] [blame] | 186 | bool parseDirectiveAltEntry(StringRef, SMLoc); |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 187 | bool parseDirectiveDesc(StringRef, SMLoc); |
| 188 | bool parseDirectiveIndirectSymbol(StringRef, SMLoc); |
| 189 | bool parseDirectiveDumpOrLoad(StringRef, SMLoc); |
| 190 | bool parseDirectiveLsym(StringRef, SMLoc); |
| 191 | bool parseDirectiveLinkerOption(StringRef, SMLoc); |
| 192 | bool parseDirectiveSection(StringRef, SMLoc); |
| 193 | bool parseDirectivePushSection(StringRef, SMLoc); |
| 194 | bool parseDirectivePopSection(StringRef, SMLoc); |
| 195 | bool parseDirectivePrevious(StringRef, SMLoc); |
| 196 | bool parseDirectiveSecureLogReset(StringRef, SMLoc); |
| 197 | bool parseDirectiveSecureLogUnique(StringRef, SMLoc); |
| 198 | bool parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc); |
| 199 | bool parseDirectiveTBSS(StringRef, SMLoc); |
| 200 | bool parseDirectiveZerofill(StringRef, SMLoc); |
| 201 | bool parseDirectiveDataRegion(StringRef, SMLoc); |
| 202 | bool parseDirectiveDataRegionEnd(StringRef, SMLoc); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 203 | |
| 204 | // Named Section Directive |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 205 | bool parseSectionDirectiveBss(StringRef, SMLoc) { |
| 206 | return parseSectionSwitch("__DATA", "__bss"); |
Rafael Espindola | 3402c05 | 2013-10-02 14:09:29 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 209 | bool parseSectionDirectiveConst(StringRef, SMLoc) { |
| 210 | return parseSectionSwitch("__TEXT", "__const"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 211 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 212 | bool parseSectionDirectiveStaticConst(StringRef, SMLoc) { |
| 213 | return parseSectionSwitch("__TEXT", "__static_const"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 214 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 215 | bool parseSectionDirectiveCString(StringRef, SMLoc) { |
| 216 | return parseSectionSwitch("__TEXT","__cstring", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 217 | MachO::S_CSTRING_LITERALS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 218 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 219 | bool parseSectionDirectiveLiteral4(StringRef, SMLoc) { |
| 220 | return parseSectionSwitch("__TEXT", "__literal4", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 221 | MachO::S_4BYTE_LITERALS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 222 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 223 | bool parseSectionDirectiveLiteral8(StringRef, SMLoc) { |
| 224 | return parseSectionSwitch("__TEXT", "__literal8", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 225 | MachO::S_8BYTE_LITERALS, 8); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 226 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 227 | bool parseSectionDirectiveLiteral16(StringRef, SMLoc) { |
| 228 | return parseSectionSwitch("__TEXT","__literal16", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 229 | MachO::S_16BYTE_LITERALS, 16); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 230 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 231 | bool parseSectionDirectiveConstructor(StringRef, SMLoc) { |
| 232 | return parseSectionSwitch("__TEXT","__constructor"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 233 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 234 | bool parseSectionDirectiveDestructor(StringRef, SMLoc) { |
| 235 | return parseSectionSwitch("__TEXT","__destructor"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 236 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 237 | bool parseSectionDirectiveFVMLibInit0(StringRef, SMLoc) { |
| 238 | return parseSectionSwitch("__TEXT","__fvmlib_init0"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 239 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 240 | bool parseSectionDirectiveFVMLibInit1(StringRef, SMLoc) { |
| 241 | return parseSectionSwitch("__TEXT","__fvmlib_init1"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 242 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 243 | bool parseSectionDirectiveSymbolStub(StringRef, SMLoc) { |
| 244 | return parseSectionSwitch("__TEXT","__symbol_stub", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 245 | MachO::S_SYMBOL_STUBS | |
| 246 | MachO::S_ATTR_PURE_INSTRUCTIONS, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 247 | // FIXME: Different on PPC and ARM. |
| 248 | 0, 16); |
| 249 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 250 | bool parseSectionDirectivePICSymbolStub(StringRef, SMLoc) { |
| 251 | return parseSectionSwitch("__TEXT","__picsymbol_stub", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 252 | MachO::S_SYMBOL_STUBS | |
| 253 | MachO::S_ATTR_PURE_INSTRUCTIONS, 0, 26); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 254 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 255 | bool parseSectionDirectiveData(StringRef, SMLoc) { |
| 256 | return parseSectionSwitch("__DATA", "__data"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 257 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 258 | bool parseSectionDirectiveStaticData(StringRef, SMLoc) { |
| 259 | return parseSectionSwitch("__DATA", "__static_data"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 260 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 261 | bool parseSectionDirectiveNonLazySymbolPointers(StringRef, SMLoc) { |
| 262 | return parseSectionSwitch("__DATA", "__nl_symbol_ptr", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 263 | MachO::S_NON_LAZY_SYMBOL_POINTERS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 264 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 265 | bool parseSectionDirectiveLazySymbolPointers(StringRef, SMLoc) { |
| 266 | return parseSectionSwitch("__DATA", "__la_symbol_ptr", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 267 | MachO::S_LAZY_SYMBOL_POINTERS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 268 | } |
Tim Northover | 5c3140f | 2016-04-25 21:12:04 +0000 | [diff] [blame] | 269 | bool parseSectionDirectiveThreadLocalVariablePointers(StringRef, SMLoc) { |
| 270 | return parseSectionSwitch("__DATA", "__thread_ptr", |
| 271 | MachO::S_THREAD_LOCAL_VARIABLE_POINTERS, 4); |
| 272 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 273 | bool parseSectionDirectiveDyld(StringRef, SMLoc) { |
| 274 | return parseSectionSwitch("__DATA", "__dyld"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 275 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 276 | bool parseSectionDirectiveModInitFunc(StringRef, SMLoc) { |
| 277 | return parseSectionSwitch("__DATA", "__mod_init_func", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 278 | MachO::S_MOD_INIT_FUNC_POINTERS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 279 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 280 | bool parseSectionDirectiveModTermFunc(StringRef, SMLoc) { |
| 281 | return parseSectionSwitch("__DATA", "__mod_term_func", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 282 | MachO::S_MOD_TERM_FUNC_POINTERS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 283 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 284 | bool parseSectionDirectiveConstData(StringRef, SMLoc) { |
| 285 | return parseSectionSwitch("__DATA", "__const"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 286 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 287 | bool parseSectionDirectiveObjCClass(StringRef, SMLoc) { |
| 288 | return parseSectionSwitch("__OBJC", "__class", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 289 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 290 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 291 | bool parseSectionDirectiveObjCMetaClass(StringRef, SMLoc) { |
| 292 | return parseSectionSwitch("__OBJC", "__meta_class", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 293 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 294 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 295 | bool parseSectionDirectiveObjCCatClsMeth(StringRef, SMLoc) { |
| 296 | return parseSectionSwitch("__OBJC", "__cat_cls_meth", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 297 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 298 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 299 | bool parseSectionDirectiveObjCCatInstMeth(StringRef, SMLoc) { |
| 300 | return parseSectionSwitch("__OBJC", "__cat_inst_meth", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 301 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 302 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 303 | bool parseSectionDirectiveObjCProtocol(StringRef, SMLoc) { |
| 304 | return parseSectionSwitch("__OBJC", "__protocol", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 305 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 306 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 307 | bool parseSectionDirectiveObjCStringObject(StringRef, SMLoc) { |
| 308 | return parseSectionSwitch("__OBJC", "__string_object", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 309 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 310 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 311 | bool parseSectionDirectiveObjCClsMeth(StringRef, SMLoc) { |
| 312 | return parseSectionSwitch("__OBJC", "__cls_meth", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 313 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 314 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 315 | bool parseSectionDirectiveObjCInstMeth(StringRef, SMLoc) { |
| 316 | return parseSectionSwitch("__OBJC", "__inst_meth", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 317 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 318 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 319 | bool parseSectionDirectiveObjCClsRefs(StringRef, SMLoc) { |
| 320 | return parseSectionSwitch("__OBJC", "__cls_refs", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 321 | MachO::S_ATTR_NO_DEAD_STRIP | |
| 322 | MachO::S_LITERAL_POINTERS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 323 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 324 | bool parseSectionDirectiveObjCMessageRefs(StringRef, SMLoc) { |
| 325 | return parseSectionSwitch("__OBJC", "__message_refs", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 326 | MachO::S_ATTR_NO_DEAD_STRIP | |
| 327 | MachO::S_LITERAL_POINTERS, 4); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 328 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 329 | bool parseSectionDirectiveObjCSymbols(StringRef, SMLoc) { |
| 330 | return parseSectionSwitch("__OBJC", "__symbols", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 331 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 332 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 333 | bool parseSectionDirectiveObjCCategory(StringRef, SMLoc) { |
| 334 | return parseSectionSwitch("__OBJC", "__category", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 335 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 336 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 337 | bool parseSectionDirectiveObjCClassVars(StringRef, SMLoc) { |
| 338 | return parseSectionSwitch("__OBJC", "__class_vars", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 339 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 340 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 341 | bool parseSectionDirectiveObjCInstanceVars(StringRef, SMLoc) { |
| 342 | return parseSectionSwitch("__OBJC", "__instance_vars", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 343 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 344 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 345 | bool parseSectionDirectiveObjCModuleInfo(StringRef, SMLoc) { |
| 346 | return parseSectionSwitch("__OBJC", "__module_info", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 347 | MachO::S_ATTR_NO_DEAD_STRIP); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 348 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 349 | bool parseSectionDirectiveObjCClassNames(StringRef, SMLoc) { |
| 350 | return parseSectionSwitch("__TEXT", "__cstring", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 351 | MachO::S_CSTRING_LITERALS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 352 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 353 | bool parseSectionDirectiveObjCMethVarTypes(StringRef, SMLoc) { |
| 354 | return parseSectionSwitch("__TEXT", "__cstring", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 355 | MachO::S_CSTRING_LITERALS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 356 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 357 | bool parseSectionDirectiveObjCMethVarNames(StringRef, SMLoc) { |
| 358 | return parseSectionSwitch("__TEXT", "__cstring", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 359 | MachO::S_CSTRING_LITERALS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 360 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 361 | bool parseSectionDirectiveObjCSelectorStrs(StringRef, SMLoc) { |
| 362 | return parseSectionSwitch("__OBJC", "__selector_strs", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 363 | MachO::S_CSTRING_LITERALS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 364 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 365 | bool parseSectionDirectiveTData(StringRef, SMLoc) { |
| 366 | return parseSectionSwitch("__DATA", "__thread_data", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 367 | MachO::S_THREAD_LOCAL_REGULAR); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 368 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 369 | bool parseSectionDirectiveText(StringRef, SMLoc) { |
| 370 | return parseSectionSwitch("__TEXT", "__text", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 371 | MachO::S_ATTR_PURE_INSTRUCTIONS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 372 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 373 | bool parseSectionDirectiveTLV(StringRef, SMLoc) { |
| 374 | return parseSectionSwitch("__DATA", "__thread_vars", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 375 | MachO::S_THREAD_LOCAL_VARIABLES); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 376 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 377 | bool parseSectionDirectiveIdent(StringRef, SMLoc) { |
Jim Grosbach | 14be61a | 2011-03-08 19:17:19 +0000 | [diff] [blame] | 378 | // Darwin silently ignores the .ident directive. |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 379 | getParser().eatToEndOfStatement(); |
Jim Grosbach | 14be61a | 2011-03-08 19:17:19 +0000 | [diff] [blame] | 380 | return false; |
| 381 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 382 | bool parseSectionDirectiveThreadInitFunc(StringRef, SMLoc) { |
| 383 | return parseSectionSwitch("__DATA", "__thread_init", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 384 | MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 385 | } |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 386 | bool parseVersionMin(StringRef, SMLoc); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 387 | |
| 388 | }; |
| 389 | |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 390 | } // end anonymous namespace |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 391 | |
Mehdi Amini | 215ff8d | 2016-10-05 01:02:22 +0000 | [diff] [blame] | 392 | bool DarwinAsmParser::parseSectionSwitch(StringRef Segment, StringRef Section, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 393 | unsigned TAA, unsigned Align, |
| 394 | unsigned StubSize) { |
| 395 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 396 | return TokError("unexpected token in section switching directive"); |
| 397 | Lex(); |
| 398 | |
| 399 | // FIXME: Arch specific. |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 400 | bool isText = TAA & MachO::S_ATTR_PURE_INSTRUCTIONS; |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 401 | getStreamer().SwitchSection(getContext().getMachOSection( |
Rafael Espindola | 449711c | 2015-11-18 06:02:15 +0000 | [diff] [blame] | 402 | Segment, Section, TAA, StubSize, |
| 403 | isText ? SectionKind::getText() : SectionKind::getData())); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 404 | |
| 405 | // Set the implicit alignment, if any. |
| 406 | // |
| 407 | // FIXME: This isn't really what 'as' does; I think it just uses the implicit |
| 408 | // alignment on the section (e.g., if one manually inserts bytes into the |
Bill Wendling | 5391eb6 | 2010-10-19 10:18:23 +0000 | [diff] [blame] | 409 | // section, then just issuing the section switch directive will not realign |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 410 | // the section. However, this is arguably more reasonable behavior, and there |
| 411 | // is no good reason for someone to intentionally emit incorrectly sized |
| 412 | // values into the implicitly aligned sections. |
| 413 | if (Align) |
Rafael Espindola | 7b51496 | 2014-02-04 18:34:04 +0000 | [diff] [blame] | 414 | getStreamer().EmitValueToAlignment(Align); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 415 | |
| 416 | return false; |
| 417 | } |
| 418 | |
Lang Hames | f9033bb | 2016-04-11 18:33:45 +0000 | [diff] [blame] | 419 | /// parseDirectiveAltEntry |
| 420 | /// ::= .alt_entry identifier |
| 421 | bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) { |
| 422 | StringRef Name; |
| 423 | if (getParser().parseIdentifier(Name)) |
| 424 | return TokError("expected identifier in directive"); |
| 425 | |
| 426 | // Look up symbol. |
| 427 | MCSymbol *Sym = getContext().getOrCreateSymbol(Name); |
| 428 | |
| 429 | if (Sym->isDefined()) |
| 430 | return TokError(".alt_entry must preceed symbol definition"); |
| 431 | |
| 432 | if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_AltEntry)) |
| 433 | return TokError("unable to emit symbol attribute"); |
| 434 | |
| 435 | Lex(); |
| 436 | return false; |
| 437 | } |
| 438 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 439 | /// parseDirectiveDesc |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 440 | /// ::= .desc identifier , expression |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 441 | bool DarwinAsmParser::parseDirectiveDesc(StringRef, SMLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 442 | StringRef Name; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 443 | if (getParser().parseIdentifier(Name)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 444 | return TokError("expected identifier in directive"); |
| 445 | |
| 446 | // Handle the identifier as the key symbol. |
Jim Grosbach | 6f48200 | 2015-05-18 18:43:14 +0000 | [diff] [blame] | 447 | MCSymbol *Sym = getContext().getOrCreateSymbol(Name); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 448 | |
| 449 | if (getLexer().isNot(AsmToken::Comma)) |
| 450 | return TokError("unexpected token in '.desc' directive"); |
| 451 | Lex(); |
| 452 | |
| 453 | int64_t DescValue; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 454 | if (getParser().parseAbsoluteExpression(DescValue)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 455 | return true; |
| 456 | |
| 457 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 458 | return TokError("unexpected token in '.desc' directive"); |
| 459 | |
| 460 | Lex(); |
| 461 | |
| 462 | // Set the n_desc field of this Symbol to this DescValue |
| 463 | getStreamer().EmitSymbolDesc(Sym, DescValue); |
| 464 | |
| 465 | return false; |
| 466 | } |
| 467 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 468 | /// parseDirectiveIndirectSymbol |
Kevin Enderby | 3aeada2 | 2013-08-28 17:50:59 +0000 | [diff] [blame] | 469 | /// ::= .indirect_symbol identifier |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 470 | bool DarwinAsmParser::parseDirectiveIndirectSymbol(StringRef, SMLoc Loc) { |
Eric Christopher | 445c952 | 2016-10-14 05:47:37 +0000 | [diff] [blame] | 471 | const MCSectionMachO *Current = static_cast<const MCSectionMachO *>( |
| 472 | getStreamer().getCurrentSectionOnly()); |
David Majnemer | cd481d3 | 2014-03-07 18:49:54 +0000 | [diff] [blame] | 473 | MachO::SectionType SectionType = Current->getType(); |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 474 | if (SectionType != MachO::S_NON_LAZY_SYMBOL_POINTERS && |
| 475 | SectionType != MachO::S_LAZY_SYMBOL_POINTERS && |
Tim Northover | 5c3140f | 2016-04-25 21:12:04 +0000 | [diff] [blame] | 476 | SectionType != MachO::S_THREAD_LOCAL_VARIABLE_POINTERS && |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 477 | SectionType != MachO::S_SYMBOL_STUBS) |
Kevin Enderby | 3aeada2 | 2013-08-28 17:50:59 +0000 | [diff] [blame] | 478 | return Error(Loc, "indirect symbol not in a symbol pointer or stub " |
| 479 | "section"); |
| 480 | |
| 481 | StringRef Name; |
| 482 | if (getParser().parseIdentifier(Name)) |
| 483 | return TokError("expected identifier in .indirect_symbol directive"); |
| 484 | |
Jim Grosbach | 6f48200 | 2015-05-18 18:43:14 +0000 | [diff] [blame] | 485 | MCSymbol *Sym = getContext().getOrCreateSymbol(Name); |
Kevin Enderby | 3aeada2 | 2013-08-28 17:50:59 +0000 | [diff] [blame] | 486 | |
| 487 | // Assembler local symbols don't make any sense here. Complain loudly. |
| 488 | if (Sym->isTemporary()) |
| 489 | return TokError("non-local symbol required in directive"); |
| 490 | |
| 491 | if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_IndirectSymbol)) |
| 492 | return TokError("unable to emit indirect symbol attribute for: " + Name); |
| 493 | |
| 494 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 495 | return TokError("unexpected token in '.indirect_symbol' directive"); |
| 496 | |
| 497 | Lex(); |
| 498 | |
| 499 | return false; |
| 500 | } |
| 501 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 502 | /// parseDirectiveDumpOrLoad |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 503 | /// ::= ( .dump | .load ) "filename" |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 504 | bool DarwinAsmParser::parseDirectiveDumpOrLoad(StringRef Directive, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 505 | SMLoc IDLoc) { |
| 506 | bool IsDump = Directive == ".dump"; |
| 507 | if (getLexer().isNot(AsmToken::String)) |
| 508 | return TokError("expected string in '.dump' or '.load' directive"); |
| 509 | |
| 510 | Lex(); |
| 511 | |
| 512 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 513 | return TokError("unexpected token in '.dump' or '.load' directive"); |
| 514 | |
| 515 | Lex(); |
| 516 | |
| 517 | // FIXME: If/when .dump and .load are implemented they will be done in the |
| 518 | // the assembly parser and not have any need for an MCStreamer API. |
| 519 | if (IsDump) |
Joerg Sonnenberger | 74ba262 | 2011-05-19 18:00:13 +0000 | [diff] [blame] | 520 | return Warning(IDLoc, "ignoring directive .dump for now"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 521 | else |
Joerg Sonnenberger | 74ba262 | 2011-05-19 18:00:13 +0000 | [diff] [blame] | 522 | return Warning(IDLoc, "ignoring directive .load for now"); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 523 | } |
| 524 | |
Daniel Dunbar | 16004b8 | 2013-01-18 01:25:48 +0000 | [diff] [blame] | 525 | /// ParseDirectiveLinkerOption |
| 526 | /// ::= .linker_option "string" ( , "string" )* |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 527 | bool DarwinAsmParser::parseDirectiveLinkerOption(StringRef IDVal, SMLoc) { |
Daniel Dunbar | 16004b8 | 2013-01-18 01:25:48 +0000 | [diff] [blame] | 528 | SmallVector<std::string, 4> Args; |
| 529 | for (;;) { |
| 530 | if (getLexer().isNot(AsmToken::String)) |
| 531 | return TokError("expected string in '" + Twine(IDVal) + "' directive"); |
| 532 | |
| 533 | std::string Data; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 534 | if (getParser().parseEscapedString(Data)) |
Daniel Dunbar | 16004b8 | 2013-01-18 01:25:48 +0000 | [diff] [blame] | 535 | return true; |
| 536 | |
| 537 | Args.push_back(Data); |
| 538 | |
Daniel Dunbar | 16004b8 | 2013-01-18 01:25:48 +0000 | [diff] [blame] | 539 | if (getLexer().is(AsmToken::EndOfStatement)) |
| 540 | break; |
| 541 | |
| 542 | if (getLexer().isNot(AsmToken::Comma)) |
| 543 | return TokError("unexpected token in '" + Twine(IDVal) + "' directive"); |
| 544 | Lex(); |
| 545 | } |
| 546 | |
| 547 | getStreamer().EmitLinkerOptions(Args); |
| 548 | return false; |
| 549 | } |
| 550 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 551 | /// parseDirectiveLsym |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 552 | /// ::= .lsym identifier , expression |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 553 | bool DarwinAsmParser::parseDirectiveLsym(StringRef, SMLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 554 | StringRef Name; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 555 | if (getParser().parseIdentifier(Name)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 556 | return TokError("expected identifier in directive"); |
| 557 | |
| 558 | // Handle the identifier as the key symbol. |
Jim Grosbach | 6f48200 | 2015-05-18 18:43:14 +0000 | [diff] [blame] | 559 | MCSymbol *Sym = getContext().getOrCreateSymbol(Name); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 560 | |
| 561 | if (getLexer().isNot(AsmToken::Comma)) |
| 562 | return TokError("unexpected token in '.lsym' directive"); |
| 563 | Lex(); |
| 564 | |
| 565 | const MCExpr *Value; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 566 | if (getParser().parseExpression(Value)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 567 | return true; |
| 568 | |
| 569 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 570 | return TokError("unexpected token in '.lsym' directive"); |
| 571 | |
| 572 | Lex(); |
| 573 | |
| 574 | // We don't currently support this directive. |
| 575 | // |
| 576 | // FIXME: Diagnostic location! |
| 577 | (void) Sym; |
| 578 | return TokError("directive '.lsym' is unsupported"); |
| 579 | } |
| 580 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 581 | /// parseDirectiveSection: |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 582 | /// ::= .section identifier (',' identifier)* |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 583 | bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 584 | SMLoc Loc = getLexer().getLoc(); |
| 585 | |
| 586 | StringRef SectionName; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 587 | if (getParser().parseIdentifier(SectionName)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 588 | return Error(Loc, "expected identifier after '.section' directive"); |
| 589 | |
| 590 | // Verify there is a following comma. |
| 591 | if (!getLexer().is(AsmToken::Comma)) |
| 592 | return TokError("unexpected token in '.section' directive"); |
| 593 | |
| 594 | std::string SectionSpec = SectionName; |
| 595 | SectionSpec += ","; |
| 596 | |
| 597 | // Add all the tokens until the end of the line, ParseSectionSpecifier will |
| 598 | // handle this. |
| 599 | StringRef EOL = getLexer().LexUntilEndOfStatement(); |
| 600 | SectionSpec.append(EOL.begin(), EOL.end()); |
| 601 | |
| 602 | Lex(); |
| 603 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 604 | return TokError("unexpected token in '.section' directive"); |
| 605 | Lex(); |
| 606 | |
| 607 | |
| 608 | StringRef Segment, Section; |
Daniel Dunbar | f1d62cf | 2011-03-17 16:25:24 +0000 | [diff] [blame] | 609 | unsigned StubSize; |
Stuart Hastings | 12d5312 | 2011-03-19 02:42:31 +0000 | [diff] [blame] | 610 | unsigned TAA; |
| 611 | bool TAAParsed; |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 612 | std::string ErrorStr = |
| 613 | MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section, |
Stuart Hastings | 12d5312 | 2011-03-19 02:42:31 +0000 | [diff] [blame] | 614 | TAA, TAAParsed, StubSize); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 615 | |
| 616 | if (!ErrorStr.empty()) |
Malcolm Parsons | 06ac79c | 2016-11-02 16:43:50 +0000 | [diff] [blame] | 617 | return Error(Loc, ErrorStr); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 618 | |
Akira Hatanaka | 8ad7399 | 2015-10-15 05:28:38 +0000 | [diff] [blame] | 619 | // Issue a warning if the target is not powerpc and Section is a *coal* section. |
| 620 | Triple TT = getParser().getContext().getObjectFileInfo()->getTargetTriple(); |
| 621 | Triple::ArchType ArchTy = TT.getArch(); |
| 622 | |
| 623 | if (ArchTy != Triple::ppc && ArchTy != Triple::ppc64) { |
| 624 | StringRef NonCoalSection = StringSwitch<StringRef>(Section) |
| 625 | .Case("__textcoal_nt", "__text") |
| 626 | .Case("__const_coal", "__const") |
| 627 | .Case("__datacoal_nt", "__data") |
| 628 | .Default(Section); |
| 629 | |
| 630 | if (!Section.equals(NonCoalSection)) { |
| 631 | StringRef SectionVal(Loc.getPointer()); |
| 632 | size_t B = SectionVal.find(',') + 1, E = SectionVal.find(',', B); |
| 633 | SMLoc BLoc = SMLoc::getFromPointer(SectionVal.data() + B); |
| 634 | SMLoc ELoc = SMLoc::getFromPointer(SectionVal.data() + E); |
| 635 | getParser().Warning(Loc, "section \"" + Section + "\" is deprecated", |
| 636 | SMRange(BLoc, ELoc)); |
| 637 | getParser().Note(Loc, "change section name to \"" + NonCoalSection + |
| 638 | "\"", SMRange(BLoc, ELoc)); |
| 639 | } |
| 640 | } |
| 641 | |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 642 | // FIXME: Arch specific. |
| 643 | bool isText = Segment == "__TEXT"; // FIXME: Hack. |
| 644 | getStreamer().SwitchSection(getContext().getMachOSection( |
Rafael Espindola | 449711c | 2015-11-18 06:02:15 +0000 | [diff] [blame] | 645 | Segment, Section, TAA, StubSize, |
| 646 | isText ? SectionKind::getText() : SectionKind::getData())); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 647 | return false; |
| 648 | } |
| 649 | |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 650 | /// ParseDirectivePushSection: |
| 651 | /// ::= .pushsection identifier (',' identifier)* |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 652 | bool DarwinAsmParser::parseDirectivePushSection(StringRef S, SMLoc Loc) { |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 653 | getStreamer().PushSection(); |
| 654 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 655 | if (parseDirectiveSection(S, Loc)) { |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 656 | getStreamer().PopSection(); |
| 657 | return true; |
| 658 | } |
| 659 | |
| 660 | return false; |
| 661 | } |
| 662 | |
| 663 | /// ParseDirectivePopSection: |
| 664 | /// ::= .popsection |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 665 | bool DarwinAsmParser::parseDirectivePopSection(StringRef, SMLoc) { |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 666 | if (!getStreamer().PopSection()) |
| 667 | return TokError(".popsection without corresponding .pushsection"); |
| 668 | return false; |
| 669 | } |
| 670 | |
| 671 | /// ParseDirectivePrevious: |
| 672 | /// ::= .previous |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 673 | bool DarwinAsmParser::parseDirectivePrevious(StringRef DirName, SMLoc) { |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 674 | MCSectionSubPair PreviousSection = getStreamer().getPreviousSection(); |
Craig Topper | 353eda4 | 2014-04-24 06:44:33 +0000 | [diff] [blame] | 675 | if (!PreviousSection.first) |
| 676 | return TokError(".previous without corresponding .section"); |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 677 | getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second); |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 678 | return false; |
| 679 | } |
| 680 | |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 681 | /// ParseDirectiveSecureLogUnique |
Daniel Dunbar | 40a564f | 2010-07-18 20:15:59 +0000 | [diff] [blame] | 682 | /// ::= .secure_log_unique ... message ... |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 683 | bool DarwinAsmParser::parseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) { |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 684 | StringRef LogMessage = getParser().parseStringToEndOfStatement(); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 685 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 686 | return TokError("unexpected token in '.secure_log_unique' directive"); |
| 687 | |
David Blaikie | dc3f01e | 2015-03-09 01:57:13 +0000 | [diff] [blame] | 688 | if (getContext().getSecureLogUsed()) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 689 | return Error(IDLoc, ".secure_log_unique specified multiple times"); |
| 690 | |
Daniel Dunbar | 40a564f | 2010-07-18 20:15:59 +0000 | [diff] [blame] | 691 | // Get the secure log path. |
| 692 | const char *SecureLogFile = getContext().getSecureLogFile(); |
Craig Topper | 353eda4 | 2014-04-24 06:44:33 +0000 | [diff] [blame] | 693 | if (!SecureLogFile) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 694 | return Error(IDLoc, ".secure_log_unique used but AS_SECURE_LOG_FILE " |
| 695 | "environment variable unset."); |
| 696 | |
Daniel Dunbar | 40a564f | 2010-07-18 20:15:59 +0000 | [diff] [blame] | 697 | // Open the secure log file if we haven't already. |
Rafael Espindola | c49ac5e | 2015-12-16 23:49:14 +0000 | [diff] [blame] | 698 | raw_fd_ostream *OS = getContext().getSecureLog(); |
Craig Topper | 353eda4 | 2014-04-24 06:44:33 +0000 | [diff] [blame] | 699 | if (!OS) { |
Rafael Espindola | 3fd1e99 | 2014-08-25 18:16:47 +0000 | [diff] [blame] | 700 | std::error_code EC; |
Rafael Espindola | c49ac5e | 2015-12-16 23:49:14 +0000 | [diff] [blame] | 701 | auto NewOS = llvm::make_unique<raw_fd_ostream>( |
Mehdi Amini | 215ff8d | 2016-10-05 01:02:22 +0000 | [diff] [blame] | 702 | StringRef(SecureLogFile), EC, sys::fs::F_Append | sys::fs::F_Text); |
Rafael Espindola | c49ac5e | 2015-12-16 23:49:14 +0000 | [diff] [blame] | 703 | if (EC) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 704 | return Error(IDLoc, Twine("can't open secure log file: ") + |
Rafael Espindola | 3fd1e99 | 2014-08-25 18:16:47 +0000 | [diff] [blame] | 705 | SecureLogFile + " (" + EC.message() + ")"); |
Rafael Espindola | c49ac5e | 2015-12-16 23:49:14 +0000 | [diff] [blame] | 706 | OS = NewOS.get(); |
| 707 | getContext().setSecureLog(std::move(NewOS)); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 708 | } |
| 709 | |
Daniel Dunbar | 40a564f | 2010-07-18 20:15:59 +0000 | [diff] [blame] | 710 | // Write the message. |
Alp Toker | a55b95b | 2014-07-06 10:33:31 +0000 | [diff] [blame] | 711 | unsigned CurBuf = getSourceManager().FindBufferContainingLoc(IDLoc); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 712 | *OS << getSourceManager().getBufferInfo(CurBuf).Buffer->getBufferIdentifier() |
| 713 | << ":" << getSourceManager().FindLineNumber(IDLoc, CurBuf) << ":" |
| 714 | << LogMessage + "\n"; |
| 715 | |
| 716 | getContext().setSecureLogUsed(true); |
| 717 | |
| 718 | return false; |
| 719 | } |
| 720 | |
| 721 | /// ParseDirectiveSecureLogReset |
| 722 | /// ::= .secure_log_reset |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 723 | bool DarwinAsmParser::parseDirectiveSecureLogReset(StringRef, SMLoc IDLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 724 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 725 | return TokError("unexpected token in '.secure_log_reset' directive"); |
| 726 | |
| 727 | Lex(); |
| 728 | |
| 729 | getContext().setSecureLogUsed(false); |
| 730 | |
| 731 | return false; |
| 732 | } |
| 733 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 734 | /// parseDirectiveSubsectionsViaSymbols |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 735 | /// ::= .subsections_via_symbols |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 736 | bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 737 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 738 | return TokError("unexpected token in '.subsections_via_symbols' directive"); |
| 739 | |
| 740 | Lex(); |
| 741 | |
| 742 | getStreamer().EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); |
| 743 | |
| 744 | return false; |
| 745 | } |
| 746 | |
| 747 | /// ParseDirectiveTBSS |
| 748 | /// ::= .tbss identifier, size, align |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 749 | bool DarwinAsmParser::parseDirectiveTBSS(StringRef, SMLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 750 | SMLoc IDLoc = getLexer().getLoc(); |
| 751 | StringRef Name; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 752 | if (getParser().parseIdentifier(Name)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 753 | return TokError("expected identifier in directive"); |
| 754 | |
| 755 | // Handle the identifier as the key symbol. |
Jim Grosbach | 6f48200 | 2015-05-18 18:43:14 +0000 | [diff] [blame] | 756 | MCSymbol *Sym = getContext().getOrCreateSymbol(Name); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 757 | |
| 758 | if (getLexer().isNot(AsmToken::Comma)) |
| 759 | return TokError("unexpected token in directive"); |
| 760 | Lex(); |
| 761 | |
| 762 | int64_t Size; |
| 763 | SMLoc SizeLoc = getLexer().getLoc(); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 764 | if (getParser().parseAbsoluteExpression(Size)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 765 | return true; |
| 766 | |
| 767 | int64_t Pow2Alignment = 0; |
| 768 | SMLoc Pow2AlignmentLoc; |
| 769 | if (getLexer().is(AsmToken::Comma)) { |
| 770 | Lex(); |
| 771 | Pow2AlignmentLoc = getLexer().getLoc(); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 772 | if (getParser().parseAbsoluteExpression(Pow2Alignment)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 773 | return true; |
| 774 | } |
| 775 | |
| 776 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 777 | return TokError("unexpected token in '.tbss' directive"); |
| 778 | |
| 779 | Lex(); |
| 780 | |
| 781 | if (Size < 0) |
| 782 | return Error(SizeLoc, "invalid '.tbss' directive size, can't be less than" |
| 783 | "zero"); |
| 784 | |
| 785 | // FIXME: Diagnose overflow. |
| 786 | if (Pow2Alignment < 0) |
| 787 | return Error(Pow2AlignmentLoc, "invalid '.tbss' alignment, can't be less" |
| 788 | "than zero"); |
| 789 | |
| 790 | if (!Sym->isUndefined()) |
| 791 | return Error(IDLoc, "invalid symbol redefinition"); |
| 792 | |
| 793 | getStreamer().EmitTBSSSymbol(getContext().getMachOSection( |
| 794 | "__DATA", "__thread_bss", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 795 | MachO::S_THREAD_LOCAL_ZEROFILL, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 796 | 0, SectionKind::getThreadBSS()), |
| 797 | Sym, Size, 1 << Pow2Alignment); |
| 798 | |
| 799 | return false; |
| 800 | } |
| 801 | |
| 802 | /// ParseDirectiveZerofill |
| 803 | /// ::= .zerofill segname , sectname [, identifier , size_expression [ |
| 804 | /// , align_expression ]] |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 805 | bool DarwinAsmParser::parseDirectiveZerofill(StringRef, SMLoc) { |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 806 | StringRef Segment; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 807 | if (getParser().parseIdentifier(Segment)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 808 | return TokError("expected segment name after '.zerofill' directive"); |
| 809 | |
| 810 | if (getLexer().isNot(AsmToken::Comma)) |
| 811 | return TokError("unexpected token in directive"); |
| 812 | Lex(); |
| 813 | |
| 814 | StringRef Section; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 815 | if (getParser().parseIdentifier(Section)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 816 | return TokError("expected section name after comma in '.zerofill' " |
| 817 | "directive"); |
| 818 | |
| 819 | // If this is the end of the line all that was wanted was to create the |
| 820 | // the section but with no symbol. |
| 821 | if (getLexer().is(AsmToken::EndOfStatement)) { |
| 822 | // Create the zerofill section but no symbol |
| 823 | getStreamer().EmitZerofill(getContext().getMachOSection( |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 824 | Segment, Section, MachO::S_ZEROFILL, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 825 | 0, SectionKind::getBSS())); |
| 826 | return false; |
| 827 | } |
| 828 | |
| 829 | if (getLexer().isNot(AsmToken::Comma)) |
| 830 | return TokError("unexpected token in directive"); |
| 831 | Lex(); |
| 832 | |
| 833 | SMLoc IDLoc = getLexer().getLoc(); |
| 834 | StringRef IDStr; |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 835 | if (getParser().parseIdentifier(IDStr)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 836 | return TokError("expected identifier in directive"); |
| 837 | |
| 838 | // handle the identifier as the key symbol. |
Jim Grosbach | 6f48200 | 2015-05-18 18:43:14 +0000 | [diff] [blame] | 839 | MCSymbol *Sym = getContext().getOrCreateSymbol(IDStr); |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 840 | |
| 841 | if (getLexer().isNot(AsmToken::Comma)) |
| 842 | return TokError("unexpected token in directive"); |
| 843 | Lex(); |
| 844 | |
| 845 | int64_t Size; |
| 846 | SMLoc SizeLoc = getLexer().getLoc(); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 847 | if (getParser().parseAbsoluteExpression(Size)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 848 | return true; |
| 849 | |
| 850 | int64_t Pow2Alignment = 0; |
| 851 | SMLoc Pow2AlignmentLoc; |
| 852 | if (getLexer().is(AsmToken::Comma)) { |
| 853 | Lex(); |
| 854 | Pow2AlignmentLoc = getLexer().getLoc(); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 855 | if (getParser().parseAbsoluteExpression(Pow2Alignment)) |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 856 | return true; |
| 857 | } |
| 858 | |
| 859 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 860 | return TokError("unexpected token in '.zerofill' directive"); |
| 861 | |
| 862 | Lex(); |
| 863 | |
| 864 | if (Size < 0) |
| 865 | return Error(SizeLoc, "invalid '.zerofill' directive size, can't be less " |
| 866 | "than zero"); |
| 867 | |
| 868 | // NOTE: The alignment in the directive is a power of 2 value, the assembler |
| 869 | // may internally end up wanting an alignment in bytes. |
| 870 | // FIXME: Diagnose overflow. |
| 871 | if (Pow2Alignment < 0) |
| 872 | return Error(Pow2AlignmentLoc, "invalid '.zerofill' directive alignment, " |
| 873 | "can't be less than zero"); |
| 874 | |
| 875 | if (!Sym->isUndefined()) |
| 876 | return Error(IDLoc, "invalid symbol redefinition"); |
| 877 | |
| 878 | // Create the zerofill Symbol with Size and Pow2Alignment |
| 879 | // |
| 880 | // FIXME: Arch specific. |
| 881 | getStreamer().EmitZerofill(getContext().getMachOSection( |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 882 | Segment, Section, MachO::S_ZEROFILL, |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 883 | 0, SectionKind::getBSS()), |
| 884 | Sym, Size, 1 << Pow2Alignment); |
| 885 | |
| 886 | return false; |
| 887 | } |
| 888 | |
Jim Grosbach | 4b63d2a | 2012-05-18 19:12:01 +0000 | [diff] [blame] | 889 | /// ParseDirectiveDataRegion |
| 890 | /// ::= .data_region [ ( jt8 | jt16 | jt32 ) ] |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 891 | bool DarwinAsmParser::parseDirectiveDataRegion(StringRef, SMLoc) { |
Jim Grosbach | 4b63d2a | 2012-05-18 19:12:01 +0000 | [diff] [blame] | 892 | if (getLexer().is(AsmToken::EndOfStatement)) { |
| 893 | Lex(); |
| 894 | getStreamer().EmitDataRegion(MCDR_DataRegion); |
| 895 | return false; |
| 896 | } |
| 897 | StringRef RegionType; |
| 898 | SMLoc Loc = getParser().getTok().getLoc(); |
Jim Grosbach | d2037eb | 2013-02-20 22:21:35 +0000 | [diff] [blame] | 899 | if (getParser().parseIdentifier(RegionType)) |
Jim Grosbach | 4b63d2a | 2012-05-18 19:12:01 +0000 | [diff] [blame] | 900 | return TokError("expected region type after '.data_region' directive"); |
| 901 | int Kind = StringSwitch<int>(RegionType) |
| 902 | .Case("jt8", MCDR_DataRegionJT8) |
| 903 | .Case("jt16", MCDR_DataRegionJT16) |
| 904 | .Case("jt32", MCDR_DataRegionJT32) |
| 905 | .Default(-1); |
| 906 | if (Kind == -1) |
| 907 | return Error(Loc, "unknown region type in '.data_region' directive"); |
| 908 | Lex(); |
| 909 | |
| 910 | getStreamer().EmitDataRegion((MCDataRegionType)Kind); |
| 911 | return false; |
| 912 | } |
| 913 | |
| 914 | /// ParseDirectiveDataRegionEnd |
| 915 | /// ::= .end_data_region |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 916 | bool DarwinAsmParser::parseDirectiveDataRegionEnd(StringRef, SMLoc) { |
Jim Grosbach | 4b63d2a | 2012-05-18 19:12:01 +0000 | [diff] [blame] | 917 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 918 | return TokError("unexpected token in '.end_data_region' directive"); |
| 919 | |
| 920 | Lex(); |
| 921 | getStreamer().EmitDataRegion(MCDR_DataRegionEnd); |
| 922 | return false; |
| 923 | } |
| 924 | |
Jim Grosbach | 319026d | 2014-03-18 22:09:10 +0000 | [diff] [blame] | 925 | /// parseVersionMin |
Jim Grosbach | 448334a | 2014-03-18 22:09:05 +0000 | [diff] [blame] | 926 | /// ::= .ios_version_min major,minor[,update] |
| 927 | /// ::= .macosx_version_min major,minor[,update] |
Tim Northover | 2d4d161 | 2015-10-28 22:36:05 +0000 | [diff] [blame] | 928 | bool DarwinAsmParser::parseVersionMin(StringRef Directive, SMLoc Loc) { |
Jim Grosbach | 448334a | 2014-03-18 22:09:05 +0000 | [diff] [blame] | 929 | int64_t Major = 0, Minor = 0, Update = 0; |
| 930 | int Kind = StringSwitch<int>(Directive) |
Tim Northover | 2d4d161 | 2015-10-28 22:36:05 +0000 | [diff] [blame] | 931 | .Case(".watchos_version_min", MCVM_WatchOSVersionMin) |
| 932 | .Case(".tvos_version_min", MCVM_TvOSVersionMin) |
Jim Grosbach | 448334a | 2014-03-18 22:09:05 +0000 | [diff] [blame] | 933 | .Case(".ios_version_min", MCVM_IOSVersionMin) |
| 934 | .Case(".macosx_version_min", MCVM_OSXVersionMin); |
| 935 | // Get the major version number. |
| 936 | if (getLexer().isNot(AsmToken::Integer)) |
| 937 | return TokError("invalid OS major version number"); |
| 938 | Major = getLexer().getTok().getIntVal(); |
| 939 | if (Major > 65535 || Major <= 0) |
| 940 | return TokError("invalid OS major version number"); |
| 941 | Lex(); |
| 942 | if (getLexer().isNot(AsmToken::Comma)) |
| 943 | return TokError("minor OS version number required, comma expected"); |
| 944 | Lex(); |
| 945 | // Get the minor version number. |
| 946 | if (getLexer().isNot(AsmToken::Integer)) |
| 947 | return TokError("invalid OS minor version number"); |
| 948 | Minor = getLexer().getTok().getIntVal(); |
| 949 | if (Minor > 255 || Minor < 0) |
| 950 | return TokError("invalid OS minor version number"); |
| 951 | Lex(); |
| 952 | // Get the update level, if specified |
| 953 | if (getLexer().isNot(AsmToken::EndOfStatement)) { |
| 954 | if (getLexer().isNot(AsmToken::Comma)) |
| 955 | return TokError("invalid update specifier, comma expected"); |
| 956 | Lex(); |
| 957 | if (getLexer().isNot(AsmToken::Integer)) |
| 958 | return TokError("invalid OS update number"); |
| 959 | Update = getLexer().getTok().getIntVal(); |
Davide Italiano | a8d89f3 | 2016-07-05 16:56:09 +0000 | [diff] [blame] | 960 | if (Update > 255 || Update < 0) |
| 961 | return TokError("invalid OS update number"); |
Jim Grosbach | 448334a | 2014-03-18 22:09:05 +0000 | [diff] [blame] | 962 | Lex(); |
| 963 | } |
| 964 | |
Tim Northover | 2d4d161 | 2015-10-28 22:36:05 +0000 | [diff] [blame] | 965 | const Triple &T = getContext().getObjectFileInfo()->getTargetTriple(); |
| 966 | Triple::OSType ExpectedOS = Triple::UnknownOS; |
| 967 | switch ((MCVersionMinType)Kind) { |
| 968 | case MCVM_WatchOSVersionMin: ExpectedOS = Triple::WatchOS; break; |
| 969 | case MCVM_TvOSVersionMin: ExpectedOS = Triple::TvOS; break; |
| 970 | case MCVM_IOSVersionMin: ExpectedOS = Triple::IOS; break; |
| 971 | case MCVM_OSXVersionMin: ExpectedOS = Triple::MacOSX; break; |
| 972 | } |
| 973 | if (T.getOS() != ExpectedOS) |
| 974 | Warning(Loc, Directive + " should only be used for " + |
| 975 | Triple::getOSTypeName(ExpectedOS) + " targets"); |
| 976 | |
| 977 | if (LastVersionMinDirective.isValid()) { |
| 978 | Warning(Loc, "overriding previous version_min directive"); |
| 979 | Note(LastVersionMinDirective, "previous definition is here"); |
| 980 | } |
| 981 | LastVersionMinDirective = Loc; |
| 982 | |
Jim Grosbach | 448334a | 2014-03-18 22:09:05 +0000 | [diff] [blame] | 983 | // We've parsed a correct version specifier, so send it to the streamer. |
| 984 | getStreamer().EmitVersionMin((MCVersionMinType)Kind, Major, Minor, Update); |
| 985 | |
| 986 | return false; |
| 987 | } |
| 988 | |
Daniel Dunbar | 0cb91cf | 2010-07-12 20:51:51 +0000 | [diff] [blame] | 989 | namespace llvm { |
| 990 | |
| 991 | MCAsmParserExtension *createDarwinAsmParser() { |
| 992 | return new DarwinAsmParser; |
| 993 | } |
| 994 | |
Bill Wendling | ce4fe41 | 2012-08-08 06:30:30 +0000 | [diff] [blame] | 995 | } // end llvm namespace |