Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 1 | //===- ELFAsmParser.cpp - ELF 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" |
Michael J. Spencer | e90ea13 | 2010-10-09 03:47:55 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/StringSwitch.h" |
Eli Friedman | dc1ad22 | 2010-07-17 06:27:28 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/Twine.h" |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCAsmInfo.h" |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCContext.h" |
Rafael Espindola | 8818213 | 2010-10-27 15:18:17 +0000 | [diff] [blame] | 15 | #include "llvm/MC/MCExpr.h" |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCParser/MCAsmLexer.h" |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCSectionELF.h" |
| 18 | #include "llvm/MC/MCStreamer.h" |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 19 | #include "llvm/Support/ELF.h" |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 20 | using namespace llvm; |
| 21 | |
| 22 | namespace { |
| 23 | |
| 24 | class ELFAsmParser : public MCAsmParserExtension { |
Daniel Dunbar | 1edf6ca | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 25 | template<bool (ELFAsmParser::*Handler)(StringRef, SMLoc)> |
| 26 | void AddDirectiveHandler(StringRef Directive) { |
| 27 | getParser().AddDirectiveHandler(this, Directive, |
| 28 | HandleDirective<ELFAsmParser, Handler>); |
| 29 | } |
| 30 | |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 31 | bool ParseSectionSwitch(StringRef Section, unsigned Type, |
| 32 | unsigned Flags, SectionKind Kind); |
Joerg Sonnenberger | a04663e | 2011-02-22 16:53:11 +0000 | [diff] [blame] | 33 | bool SeenIdent; |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 34 | |
| 35 | public: |
Joerg Sonnenberger | 93c65e6 | 2011-02-24 21:59:22 +0000 | [diff] [blame] | 36 | ELFAsmParser() : SeenIdent(false) { |
| 37 | BracketExpressionsSupported = true; |
| 38 | } |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 39 | |
| 40 | virtual void Initialize(MCAsmParser &Parser) { |
| 41 | // Call the base implementation. |
| 42 | this->MCAsmParserExtension::Initialize(Parser); |
| 43 | |
Daniel Dunbar | 1edf6ca | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 44 | AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveData>(".data"); |
| 45 | AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveText>(".text"); |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 46 | AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveBSS>(".bss"); |
| 47 | AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData>(".rodata"); |
| 48 | AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData>(".tdata"); |
| 49 | AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS>(".tbss"); |
Jim Grosbach | cc866d5 | 2011-07-25 17:11:29 +0000 | [diff] [blame] | 50 | AddDirectiveHandler< |
| 51 | &ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel"); |
| 52 | AddDirectiveHandler< |
| 53 | &ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro"); |
| 54 | AddDirectiveHandler< |
| 55 | &ELFAsmParser::ParseSectionDirectiveDataRelRoLocal>(".data.rel.ro.local"); |
| 56 | AddDirectiveHandler< |
| 57 | &ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame"); |
Daniel Dunbar | 1edf6ca | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 58 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSection>(".section"); |
Jim Grosbach | cc866d5 | 2011-07-25 17:11:29 +0000 | [diff] [blame] | 59 | AddDirectiveHandler< |
| 60 | &ELFAsmParser::ParseDirectivePushSection>(".pushsection"); |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 61 | AddDirectiveHandler<&ELFAsmParser::ParseDirectivePopSection>(".popsection"); |
Daniel Dunbar | 1edf6ca | 2010-07-18 22:22:07 +0000 | [diff] [blame] | 62 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size"); |
Benjamin Kramer | 1674b0b | 2010-09-02 18:53:37 +0000 | [diff] [blame] | 63 | AddDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous"); |
Michael J. Spencer | e90ea13 | 2010-10-09 03:47:55 +0000 | [diff] [blame] | 64 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type"); |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 65 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident"); |
Rafael Espindola | 8818213 | 2010-10-27 15:18:17 +0000 | [diff] [blame] | 66 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver"); |
Benjamin Kramer | 6a80f9d | 2012-05-12 14:30:47 +0000 | [diff] [blame] | 67 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion>(".version"); |
Rafael Espindola | 484291c | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 68 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref"); |
Jim Grosbach | f2a35fb | 2011-07-25 17:55:35 +0000 | [diff] [blame] | 69 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak"); |
| 70 | AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local"); |
| 71 | AddDirectiveHandler< |
| 72 | &ELFAsmParser::ParseDirectiveSymbolAttribute>(".protected"); |
| 73 | AddDirectiveHandler< |
| 74 | &ELFAsmParser::ParseDirectiveSymbolAttribute>(".internal"); |
| 75 | AddDirectiveHandler< |
| 76 | &ELFAsmParser::ParseDirectiveSymbolAttribute>(".hidden"); |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 79 | // FIXME: Part of this logic is duplicated in the MCELFStreamer. What is |
| 80 | // the best way for us to get access to it? |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 81 | bool ParseSectionDirectiveData(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 82 | return ParseSectionSwitch(".data", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 83 | ELF::SHF_WRITE |ELF::SHF_ALLOC, |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 84 | SectionKind::getDataRel()); |
| 85 | } |
| 86 | bool ParseSectionDirectiveText(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 87 | return ParseSectionSwitch(".text", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 88 | ELF::SHF_EXECINSTR | |
| 89 | ELF::SHF_ALLOC, SectionKind::getText()); |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 90 | } |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 91 | bool ParseSectionDirectiveBSS(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 92 | return ParseSectionSwitch(".bss", ELF::SHT_NOBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 93 | ELF::SHF_WRITE | |
| 94 | ELF::SHF_ALLOC, SectionKind::getBSS()); |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 95 | } |
| 96 | bool ParseSectionDirectiveRoData(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 97 | return ParseSectionSwitch(".rodata", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 98 | ELF::SHF_ALLOC, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 99 | SectionKind::getReadOnly()); |
| 100 | } |
| 101 | bool ParseSectionDirectiveTData(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 102 | return ParseSectionSwitch(".tdata", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 103 | ELF::SHF_ALLOC | |
| 104 | ELF::SHF_TLS | ELF::SHF_WRITE, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 105 | SectionKind::getThreadData()); |
| 106 | } |
| 107 | bool ParseSectionDirectiveTBSS(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 108 | return ParseSectionSwitch(".tbss", ELF::SHT_NOBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 109 | ELF::SHF_ALLOC | |
| 110 | ELF::SHF_TLS | ELF::SHF_WRITE, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 111 | SectionKind::getThreadBSS()); |
| 112 | } |
| 113 | bool ParseSectionDirectiveDataRel(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 114 | return ParseSectionSwitch(".data.rel", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 115 | ELF::SHF_ALLOC | |
| 116 | ELF::SHF_WRITE, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 117 | SectionKind::getDataRel()); |
| 118 | } |
| 119 | bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 120 | return ParseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 121 | ELF::SHF_ALLOC | |
| 122 | ELF::SHF_WRITE, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 123 | SectionKind::getReadOnlyWithRel()); |
| 124 | } |
| 125 | bool ParseSectionDirectiveDataRelRoLocal(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 126 | return ParseSectionSwitch(".data.rel.ro.local", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 127 | ELF::SHF_ALLOC | |
| 128 | ELF::SHF_WRITE, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 129 | SectionKind::getReadOnlyWithRelLocal()); |
| 130 | } |
| 131 | bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) { |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 132 | return ParseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 133 | ELF::SHF_ALLOC | |
| 134 | ELF::SHF_WRITE, |
Matt Fleming | f525c2a | 2010-07-20 21:12:46 +0000 | [diff] [blame] | 135 | SectionKind::getDataRel()); |
| 136 | } |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 137 | bool ParseDirectivePushSection(StringRef, SMLoc); |
| 138 | bool ParseDirectivePopSection(StringRef, SMLoc); |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 139 | bool ParseDirectiveSection(StringRef, SMLoc); |
| 140 | bool ParseDirectiveSize(StringRef, SMLoc); |
Benjamin Kramer | 1674b0b | 2010-09-02 18:53:37 +0000 | [diff] [blame] | 141 | bool ParseDirectivePrevious(StringRef, SMLoc); |
Michael J. Spencer | e90ea13 | 2010-10-09 03:47:55 +0000 | [diff] [blame] | 142 | bool ParseDirectiveType(StringRef, SMLoc); |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 143 | bool ParseDirectiveIdent(StringRef, SMLoc); |
Rafael Espindola | 8818213 | 2010-10-27 15:18:17 +0000 | [diff] [blame] | 144 | bool ParseDirectiveSymver(StringRef, SMLoc); |
Benjamin Kramer | 6a80f9d | 2012-05-12 14:30:47 +0000 | [diff] [blame] | 145 | bool ParseDirectiveVersion(StringRef, SMLoc); |
Rafael Espindola | 484291c | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 146 | bool ParseDirectiveWeakref(StringRef, SMLoc); |
Jim Grosbach | f2a35fb | 2011-07-25 17:55:35 +0000 | [diff] [blame] | 147 | bool ParseDirectiveSymbolAttribute(StringRef, SMLoc); |
Rafael Espindola | 34e3d0c | 2010-09-16 17:05:55 +0000 | [diff] [blame] | 148 | |
| 149 | private: |
| 150 | bool ParseSectionName(StringRef &SectionName); |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | } |
| 154 | |
Jim Grosbach | f2a35fb | 2011-07-25 17:55:35 +0000 | [diff] [blame] | 155 | /// ParseDirectiveSymbolAttribute |
| 156 | /// ::= { ".local", ".weak", ... } [ identifier ( , identifier )* ] |
| 157 | bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) { |
| 158 | MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Directive) |
| 159 | .Case(".weak", MCSA_Weak) |
| 160 | .Case(".local", MCSA_Local) |
| 161 | .Case(".hidden", MCSA_Hidden) |
| 162 | .Case(".internal", MCSA_Internal) |
| 163 | .Case(".protected", MCSA_Protected) |
| 164 | .Default(MCSA_Invalid); |
| 165 | assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!"); |
| 166 | if (getLexer().isNot(AsmToken::EndOfStatement)) { |
| 167 | for (;;) { |
| 168 | StringRef Name; |
| 169 | |
| 170 | if (getParser().ParseIdentifier(Name)) |
| 171 | return TokError("expected identifier in directive"); |
| 172 | |
| 173 | MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); |
| 174 | |
| 175 | getStreamer().EmitSymbolAttribute(Sym, Attr); |
| 176 | |
| 177 | if (getLexer().is(AsmToken::EndOfStatement)) |
| 178 | break; |
| 179 | |
| 180 | if (getLexer().isNot(AsmToken::Comma)) |
| 181 | return TokError("unexpected token in directive"); |
| 182 | Lex(); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | Lex(); |
| 187 | return false; |
| 188 | } |
| 189 | |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 190 | bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type, |
| 191 | unsigned Flags, SectionKind Kind) { |
| 192 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 193 | return TokError("unexpected token in section switching directive"); |
| 194 | Lex(); |
| 195 | |
| 196 | getStreamer().SwitchSection(getContext().getELFSection( |
| 197 | Section, Type, Flags, Kind)); |
| 198 | |
| 199 | return false; |
| 200 | } |
| 201 | |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 202 | bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) { |
Eli Friedman | f82ccf5 | 2010-07-17 03:09:18 +0000 | [diff] [blame] | 203 | StringRef Name; |
| 204 | if (getParser().ParseIdentifier(Name)) |
| 205 | return TokError("expected identifier in directive"); |
Dmitri Gribenko | 2de0572 | 2012-09-10 21:26:47 +0000 | [diff] [blame^] | 206 | MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); |
Eli Friedman | f82ccf5 | 2010-07-17 03:09:18 +0000 | [diff] [blame] | 207 | |
| 208 | if (getLexer().isNot(AsmToken::Comma)) |
| 209 | return TokError("unexpected token in directive"); |
| 210 | Lex(); |
| 211 | |
| 212 | const MCExpr *Expr; |
| 213 | if (getParser().ParseExpression(Expr)) |
| 214 | return true; |
| 215 | |
| 216 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 217 | return TokError("unexpected token in directive"); |
| 218 | |
| 219 | getStreamer().EmitELFSize(Sym, Expr); |
| 220 | return false; |
| 221 | } |
| 222 | |
Rafael Espindola | 34e3d0c | 2010-09-16 17:05:55 +0000 | [diff] [blame] | 223 | bool ELFAsmParser::ParseSectionName(StringRef &SectionName) { |
| 224 | // A section name can contain -, so we cannot just use |
| 225 | // ParseIdentifier. |
| 226 | SMLoc FirstLoc = getLexer().getLoc(); |
| 227 | unsigned Size = 0; |
| 228 | |
Rafael Espindola | 184640e | 2011-01-24 18:02:54 +0000 | [diff] [blame] | 229 | if (getLexer().is(AsmToken::String)) { |
| 230 | SectionName = getTok().getIdentifier(); |
| 231 | Lex(); |
| 232 | return false; |
| 233 | } |
| 234 | |
Rafael Espindola | 34e3d0c | 2010-09-16 17:05:55 +0000 | [diff] [blame] | 235 | for (;;) { |
| 236 | StringRef Tmp; |
| 237 | unsigned CurSize; |
| 238 | |
| 239 | SMLoc PrevLoc = getLexer().getLoc(); |
| 240 | if (getLexer().is(AsmToken::Minus)) { |
| 241 | CurSize = 1; |
| 242 | Lex(); // Consume the "-". |
Rafael Espindola | 184640e | 2011-01-24 18:02:54 +0000 | [diff] [blame] | 243 | } else if (getLexer().is(AsmToken::String)) { |
| 244 | CurSize = getTok().getIdentifier().size() + 2; |
| 245 | Lex(); |
| 246 | } else if (getLexer().is(AsmToken::Identifier)) { |
| 247 | CurSize = getTok().getIdentifier().size(); |
| 248 | Lex(); |
| 249 | } else { |
Rafael Espindola | 34e3d0c | 2010-09-16 17:05:55 +0000 | [diff] [blame] | 250 | break; |
Rafael Espindola | 184640e | 2011-01-24 18:02:54 +0000 | [diff] [blame] | 251 | } |
Rafael Espindola | 34e3d0c | 2010-09-16 17:05:55 +0000 | [diff] [blame] | 252 | |
| 253 | Size += CurSize; |
| 254 | SectionName = StringRef(FirstLoc.getPointer(), Size); |
| 255 | |
| 256 | // Make sure the following token is adjacent. |
| 257 | if (PrevLoc.getPointer() + CurSize != getTok().getLoc().getPointer()) |
| 258 | break; |
| 259 | } |
| 260 | if (Size == 0) |
| 261 | return true; |
| 262 | |
| 263 | return false; |
| 264 | } |
| 265 | |
Rafael Espindola | 2595873 | 2010-11-24 21:57:39 +0000 | [diff] [blame] | 266 | static SectionKind computeSectionKind(unsigned Flags) { |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 267 | if (Flags & ELF::SHF_EXECINSTR) |
Rafael Espindola | 2595873 | 2010-11-24 21:57:39 +0000 | [diff] [blame] | 268 | return SectionKind::getText(); |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 269 | if (Flags & ELF::SHF_TLS) |
Rafael Espindola | 2595873 | 2010-11-24 21:57:39 +0000 | [diff] [blame] | 270 | return SectionKind::getThreadData(); |
| 271 | return SectionKind::getDataRel(); |
| 272 | } |
| 273 | |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 274 | static int parseSectionFlags(StringRef flagsStr) { |
| 275 | int flags = 0; |
| 276 | |
| 277 | for (unsigned i = 0; i < flagsStr.size(); i++) { |
| 278 | switch (flagsStr[i]) { |
| 279 | case 'a': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 280 | flags |= ELF::SHF_ALLOC; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 281 | break; |
| 282 | case 'x': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 283 | flags |= ELF::SHF_EXECINSTR; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 284 | break; |
| 285 | case 'w': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 286 | flags |= ELF::SHF_WRITE; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 287 | break; |
| 288 | case 'M': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 289 | flags |= ELF::SHF_MERGE; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 290 | break; |
| 291 | case 'S': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 292 | flags |= ELF::SHF_STRINGS; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 293 | break; |
| 294 | case 'T': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 295 | flags |= ELF::SHF_TLS; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 296 | break; |
| 297 | case 'c': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 298 | flags |= ELF::XCORE_SHF_CP_SECTION; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 299 | break; |
| 300 | case 'd': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 301 | flags |= ELF::XCORE_SHF_DP_SECTION; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 302 | break; |
| 303 | case 'G': |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 304 | flags |= ELF::SHF_GROUP; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 305 | break; |
| 306 | default: |
| 307 | return -1; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | return flags; |
| 312 | } |
| 313 | |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 314 | bool ELFAsmParser::ParseDirectivePushSection(StringRef s, SMLoc loc) { |
| 315 | getStreamer().PushSection(); |
| 316 | |
| 317 | if (ParseDirectiveSection(s, loc)) { |
| 318 | getStreamer().PopSection(); |
| 319 | return true; |
| 320 | } |
| 321 | |
| 322 | return false; |
| 323 | } |
| 324 | |
| 325 | bool ELFAsmParser::ParseDirectivePopSection(StringRef, SMLoc) { |
| 326 | if (!getStreamer().PopSection()) |
| 327 | return TokError(".popsection without corresponding .pushsection"); |
| 328 | return false; |
| 329 | } |
| 330 | |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 331 | // FIXME: This is a work in progress. |
| 332 | bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { |
| 333 | StringRef SectionName; |
Rafael Espindola | 34e3d0c | 2010-09-16 17:05:55 +0000 | [diff] [blame] | 334 | |
| 335 | if (ParseSectionName(SectionName)) |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 336 | return TokError("expected identifier in directive"); |
| 337 | |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 338 | StringRef TypeName; |
| 339 | int64_t Size = 0; |
Rafael Espindola | 2ff9e83 | 2010-11-11 18:13:52 +0000 | [diff] [blame] | 340 | StringRef GroupName; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 341 | unsigned Flags = 0; |
| 342 | |
| 343 | // Set the defaults first. |
| 344 | if (SectionName == ".fini" || SectionName == ".init" || |
| 345 | SectionName == ".rodata") |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 346 | Flags |= ELF::SHF_ALLOC; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 347 | if (SectionName == ".fini" || SectionName == ".init") |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 348 | Flags |= ELF::SHF_EXECINSTR; |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 349 | |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 350 | if (getLexer().is(AsmToken::Comma)) { |
| 351 | Lex(); |
| 352 | |
| 353 | if (getLexer().isNot(AsmToken::String)) |
| 354 | return TokError("expected string in directive"); |
| 355 | |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 356 | StringRef FlagsStr = getTok().getStringContents(); |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 357 | Lex(); |
| 358 | |
Rafael Espindola | 6b8e435 | 2010-11-25 15:32:56 +0000 | [diff] [blame] | 359 | int extraFlags = parseSectionFlags(FlagsStr); |
| 360 | if (extraFlags < 0) |
| 361 | return TokError("unknown flag"); |
| 362 | Flags |= extraFlags; |
| 363 | |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 364 | bool Mergeable = Flags & ELF::SHF_MERGE; |
| 365 | bool Group = Flags & ELF::SHF_GROUP; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 366 | |
Rafael Espindola | f4b0f3e | 2010-10-28 21:33:33 +0000 | [diff] [blame] | 367 | if (getLexer().isNot(AsmToken::Comma)) { |
| 368 | if (Mergeable) |
| 369 | return TokError("Mergeable section must specify the type"); |
| 370 | if (Group) |
| 371 | return TokError("Group section must specify the type"); |
| 372 | } else { |
| 373 | Lex(); |
Rafael Espindola | d4a3526 | 2010-11-12 15:47:08 +0000 | [diff] [blame] | 374 | if (getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::At)) |
| 375 | return TokError("expected '@' or '%' before type"); |
Rafael Espindola | f4b0f3e | 2010-10-28 21:33:33 +0000 | [diff] [blame] | 376 | |
| 377 | Lex(); |
| 378 | if (getParser().ParseIdentifier(TypeName)) |
| 379 | return TokError("expected identifier in directive"); |
| 380 | |
| 381 | if (Mergeable) { |
| 382 | if (getLexer().isNot(AsmToken::Comma)) |
| 383 | return TokError("expected the entry size"); |
| 384 | Lex(); |
| 385 | if (getParser().ParseAbsoluteExpression(Size)) |
| 386 | return true; |
| 387 | if (Size <= 0) |
| 388 | return TokError("entry size must be positive"); |
| 389 | } |
| 390 | |
| 391 | if (Group) { |
| 392 | if (getLexer().isNot(AsmToken::Comma)) |
| 393 | return TokError("expected group name"); |
| 394 | Lex(); |
Rafael Espindola | f4b0f3e | 2010-10-28 21:33:33 +0000 | [diff] [blame] | 395 | if (getParser().ParseIdentifier(GroupName)) |
| 396 | return true; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 397 | if (getLexer().is(AsmToken::Comma)) { |
| 398 | Lex(); |
Rafael Espindola | f4b0f3e | 2010-10-28 21:33:33 +0000 | [diff] [blame] | 399 | StringRef Linkage; |
| 400 | if (getParser().ParseIdentifier(Linkage)) |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 401 | return true; |
Rafael Espindola | 2ff9e83 | 2010-11-11 18:13:52 +0000 | [diff] [blame] | 402 | if (Linkage != "comdat") |
| 403 | return TokError("Linkage must be 'comdat'"); |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 410 | return TokError("unexpected token in directive"); |
| 411 | |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 412 | unsigned Type = ELF::SHT_PROGBITS; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 413 | |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 414 | if (!TypeName.empty()) { |
| 415 | if (TypeName == "init_array") |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 416 | Type = ELF::SHT_INIT_ARRAY; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 417 | else if (TypeName == "fini_array") |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 418 | Type = ELF::SHT_FINI_ARRAY; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 419 | else if (TypeName == "preinit_array") |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 420 | Type = ELF::SHT_PREINIT_ARRAY; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 421 | else if (TypeName == "nobits") |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 422 | Type = ELF::SHT_NOBITS; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 423 | else if (TypeName == "progbits") |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 424 | Type = ELF::SHT_PROGBITS; |
Rafael Espindola | 9897661 | 2010-12-26 21:30:59 +0000 | [diff] [blame] | 425 | else if (TypeName == "note") |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 426 | Type = ELF::SHT_NOTE; |
Rafael Espindola | 0cf5e3d | 2011-01-23 05:43:40 +0000 | [diff] [blame] | 427 | else if (TypeName == "unwind") |
| 428 | Type = ELF::SHT_X86_64_UNWIND; |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 429 | else |
| 430 | return TokError("unknown section type"); |
| 431 | } |
| 432 | |
Rafael Espindola | 2595873 | 2010-11-24 21:57:39 +0000 | [diff] [blame] | 433 | SectionKind Kind = computeSectionKind(Flags); |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 434 | getStreamer().SwitchSection(getContext().getELFSection(SectionName, Type, |
Rafael Espindola | 2ff9e83 | 2010-11-11 18:13:52 +0000 | [diff] [blame] | 435 | Flags, Kind, Size, |
| 436 | GroupName)); |
Eli Friedman | 21444ef | 2010-07-17 04:29:04 +0000 | [diff] [blame] | 437 | return false; |
| 438 | } |
| 439 | |
Benjamin Kramer | 1674b0b | 2010-09-02 18:53:37 +0000 | [diff] [blame] | 440 | bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) { |
| 441 | const MCSection *PreviousSection = getStreamer().getPreviousSection(); |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 442 | if (PreviousSection == NULL) |
| 443 | return TokError(".previous without corresponding .section"); |
| 444 | getStreamer().SwitchSection(PreviousSection); |
Benjamin Kramer | 1674b0b | 2010-09-02 18:53:37 +0000 | [diff] [blame] | 445 | |
| 446 | return false; |
| 447 | } |
| 448 | |
Michael J. Spencer | e90ea13 | 2010-10-09 03:47:55 +0000 | [diff] [blame] | 449 | /// ParseDirectiveELFType |
| 450 | /// ::= .type identifier , @attribute |
| 451 | bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) { |
| 452 | StringRef Name; |
| 453 | if (getParser().ParseIdentifier(Name)) |
| 454 | return TokError("expected identifier in directive"); |
| 455 | |
| 456 | // Handle the identifier as the key symbol. |
| 457 | MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); |
| 458 | |
| 459 | if (getLexer().isNot(AsmToken::Comma)) |
| 460 | return TokError("unexpected token in '.type' directive"); |
| 461 | Lex(); |
| 462 | |
Rafael Espindola | d4a3526 | 2010-11-12 15:47:08 +0000 | [diff] [blame] | 463 | if (getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::At)) |
| 464 | return TokError("expected '@' or '%' before type"); |
Michael J. Spencer | e90ea13 | 2010-10-09 03:47:55 +0000 | [diff] [blame] | 465 | Lex(); |
| 466 | |
| 467 | StringRef Type; |
| 468 | SMLoc TypeLoc; |
| 469 | |
| 470 | TypeLoc = getLexer().getLoc(); |
| 471 | if (getParser().ParseIdentifier(Type)) |
| 472 | return TokError("expected symbol type in directive"); |
| 473 | |
| 474 | MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Type) |
| 475 | .Case("function", MCSA_ELF_TypeFunction) |
| 476 | .Case("object", MCSA_ELF_TypeObject) |
| 477 | .Case("tls_object", MCSA_ELF_TypeTLS) |
| 478 | .Case("common", MCSA_ELF_TypeCommon) |
| 479 | .Case("notype", MCSA_ELF_TypeNoType) |
Rafael Espindola | e13a0ff | 2010-11-13 04:51:02 +0000 | [diff] [blame] | 480 | .Case("gnu_unique_object", MCSA_ELF_TypeGnuUniqueObject) |
Roman Divacky | a0c17a4 | 2011-12-12 17:34:04 +0000 | [diff] [blame] | 481 | .Case("gnu_indirect_function", MCSA_ELF_TypeIndFunction) |
Michael J. Spencer | e90ea13 | 2010-10-09 03:47:55 +0000 | [diff] [blame] | 482 | .Default(MCSA_Invalid); |
| 483 | |
| 484 | if (Attr == MCSA_Invalid) |
| 485 | return Error(TypeLoc, "unsupported attribute in '.type' directive"); |
| 486 | |
| 487 | if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 488 | return TokError("unexpected token in '.type' directive"); |
| 489 | |
| 490 | Lex(); |
| 491 | |
| 492 | getStreamer().EmitSymbolAttribute(Sym, Attr); |
| 493 | |
| 494 | return false; |
| 495 | } |
| 496 | |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 497 | /// ParseDirectiveIdent |
| 498 | /// ::= .ident string |
| 499 | bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) { |
| 500 | if (getLexer().isNot(AsmToken::String)) |
| 501 | return TokError("unexpected token in '.ident' directive"); |
| 502 | |
| 503 | StringRef Data = getTok().getIdentifier(); |
| 504 | |
| 505 | Lex(); |
| 506 | |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 507 | const MCSection *Comment = |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 508 | getContext().getELFSection(".comment", ELF::SHT_PROGBITS, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 509 | ELF::SHF_MERGE | |
| 510 | ELF::SHF_STRINGS, |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 511 | SectionKind::getReadOnly(), |
Rafael Espindola | 2ff9e83 | 2010-11-11 18:13:52 +0000 | [diff] [blame] | 512 | 1, ""); |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 513 | |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 514 | getStreamer().PushSection(); |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 515 | getStreamer().SwitchSection(Comment); |
Joerg Sonnenberger | a04663e | 2011-02-22 16:53:11 +0000 | [diff] [blame] | 516 | if (!SeenIdent) { |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 517 | getStreamer().EmitIntValue(0, 1); |
Joerg Sonnenberger | a04663e | 2011-02-22 16:53:11 +0000 | [diff] [blame] | 518 | SeenIdent = true; |
| 519 | } |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 520 | getStreamer().EmitBytes(Data, 0); |
| 521 | getStreamer().EmitIntValue(0, 1); |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 522 | getStreamer().PopSection(); |
Rafael Espindola | 61e3b91 | 2010-10-26 19:35:47 +0000 | [diff] [blame] | 523 | return false; |
| 524 | } |
| 525 | |
Rafael Espindola | 8818213 | 2010-10-27 15:18:17 +0000 | [diff] [blame] | 526 | /// ParseDirectiveSymver |
| 527 | /// ::= .symver foo, bar2@zed |
| 528 | bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) { |
| 529 | StringRef Name; |
| 530 | if (getParser().ParseIdentifier(Name)) |
| 531 | return TokError("expected identifier in directive"); |
| 532 | |
| 533 | if (getLexer().isNot(AsmToken::Comma)) |
| 534 | return TokError("expected a comma"); |
| 535 | |
| 536 | Lex(); |
| 537 | |
| 538 | StringRef AliasName; |
| 539 | if (getParser().ParseIdentifier(AliasName)) |
| 540 | return TokError("expected identifier in directive"); |
| 541 | |
| 542 | if (AliasName.find('@') == StringRef::npos) |
| 543 | return TokError("expected a '@' in the name"); |
| 544 | |
| 545 | MCSymbol *Alias = getContext().GetOrCreateSymbol(AliasName); |
| 546 | MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); |
| 547 | const MCExpr *Value = MCSymbolRefExpr::Create(Sym, getContext()); |
| 548 | |
| 549 | getStreamer().EmitAssignment(Alias, Value); |
| 550 | return false; |
| 551 | } |
| 552 | |
Benjamin Kramer | 6a80f9d | 2012-05-12 14:30:47 +0000 | [diff] [blame] | 553 | /// ParseDirectiveVersion |
| 554 | /// ::= .version string |
| 555 | bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) { |
| 556 | if (getLexer().isNot(AsmToken::String)) |
| 557 | return TokError("unexpected token in '.version' directive"); |
| 558 | |
| 559 | StringRef Data = getTok().getIdentifier(); |
| 560 | |
| 561 | Lex(); |
| 562 | |
| 563 | const MCSection *Note = |
| 564 | getContext().getELFSection(".note", ELF::SHT_NOTE, 0, |
| 565 | SectionKind::getReadOnly()); |
| 566 | |
| 567 | getStreamer().PushSection(); |
| 568 | getStreamer().SwitchSection(Note); |
| 569 | getStreamer().EmitIntValue(Data.size()+1, 4); // namesz. |
| 570 | getStreamer().EmitIntValue(0, 4); // descsz = 0 (no description). |
| 571 | getStreamer().EmitIntValue(1, 4); // type = NT_VERSION. |
| 572 | getStreamer().EmitBytes(Data, 0); // name. |
| 573 | getStreamer().EmitIntValue(0, 1); // terminate the string. |
| 574 | getStreamer().EmitValueToAlignment(4); // ensure 4 byte alignment. |
| 575 | getStreamer().PopSection(); |
| 576 | return false; |
| 577 | } |
| 578 | |
Rafael Espindola | 484291c | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 579 | /// ParseDirectiveWeakref |
| 580 | /// ::= .weakref foo, bar |
| 581 | bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) { |
| 582 | // FIXME: Share code with the other alias building directives. |
| 583 | |
| 584 | StringRef AliasName; |
| 585 | if (getParser().ParseIdentifier(AliasName)) |
| 586 | return TokError("expected identifier in directive"); |
| 587 | |
| 588 | if (getLexer().isNot(AsmToken::Comma)) |
| 589 | return TokError("expected a comma"); |
| 590 | |
| 591 | Lex(); |
| 592 | |
| 593 | StringRef Name; |
| 594 | if (getParser().ParseIdentifier(Name)) |
| 595 | return TokError("expected identifier in directive"); |
| 596 | |
| 597 | MCSymbol *Alias = getContext().GetOrCreateSymbol(AliasName); |
| 598 | |
| 599 | MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); |
| 600 | |
| 601 | getStreamer().EmitWeakReference(Alias, Sym); |
| 602 | return false; |
| 603 | } |
| 604 | |
Daniel Dunbar | 5146a09 | 2010-07-12 21:23:32 +0000 | [diff] [blame] | 605 | namespace llvm { |
| 606 | |
| 607 | MCAsmParserExtension *createELFAsmParser() { |
| 608 | return new ELFAsmParser; |
| 609 | } |
| 610 | |
| 611 | } |