blob: 42cd91947267d0008637f3981c6f6408e68e9a78 [file] [log] [blame]
Daniel Dunbar5146a092010-07-12 21:23:32 +00001//===- 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. Spencere90ea132010-10-09 03:47:55 +000011#include "llvm/ADT/StringSwitch.h"
Eli Friedmandc1ad222010-07-17 06:27:28 +000012#include "llvm/ADT/Twine.h"
Eli Friedman21444ef2010-07-17 04:29:04 +000013#include "llvm/MC/MCAsmInfo.h"
Daniel Dunbar5146a092010-07-12 21:23:32 +000014#include "llvm/MC/MCContext.h"
Rafael Espindola88182132010-10-27 15:18:17 +000015#include "llvm/MC/MCExpr.h"
Daniel Dunbar5146a092010-07-12 21:23:32 +000016#include "llvm/MC/MCParser/MCAsmLexer.h"
Eli Friedman21444ef2010-07-17 04:29:04 +000017#include "llvm/MC/MCSectionELF.h"
18#include "llvm/MC/MCStreamer.h"
Daniel Dunbar5146a092010-07-12 21:23:32 +000019using namespace llvm;
20
21namespace {
22
23class ELFAsmParser : public MCAsmParserExtension {
Daniel Dunbar1edf6ca2010-07-18 22:22:07 +000024 template<bool (ELFAsmParser::*Handler)(StringRef, SMLoc)>
25 void AddDirectiveHandler(StringRef Directive) {
26 getParser().AddDirectiveHandler(this, Directive,
27 HandleDirective<ELFAsmParser, Handler>);
28 }
29
Daniel Dunbar5146a092010-07-12 21:23:32 +000030 bool ParseSectionSwitch(StringRef Section, unsigned Type,
31 unsigned Flags, SectionKind Kind);
32
33public:
34 ELFAsmParser() {}
35
36 virtual void Initialize(MCAsmParser &Parser) {
37 // Call the base implementation.
38 this->MCAsmParserExtension::Initialize(Parser);
39
Daniel Dunbar1edf6ca2010-07-18 22:22:07 +000040 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveData>(".data");
41 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveText>(".text");
Matt Flemingf525c2a2010-07-20 21:12:46 +000042 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveBSS>(".bss");
43 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData>(".rodata");
44 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData>(".tdata");
45 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS>(".tbss");
46 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel");
47 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro");
48 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRelRoLocal>(".data.rel.ro.local");
49 AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
Daniel Dunbar1edf6ca2010-07-18 22:22:07 +000050 AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSection>(".section");
51 AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
Benjamin Kramer1674b0b2010-09-02 18:53:37 +000052 AddDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous");
Michael J. Spencere90ea132010-10-09 03:47:55 +000053 AddDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type");
Rafael Espindola61e3b912010-10-26 19:35:47 +000054 AddDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
Rafael Espindola88182132010-10-27 15:18:17 +000055 AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
Rafael Espindola484291c2010-11-01 14:28:48 +000056 AddDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
Daniel Dunbar5146a092010-07-12 21:23:32 +000057 }
58
Rafael Espindolad80781b2010-09-15 21:48:40 +000059 // FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
60 // the best way for us to get access to it?
Daniel Dunbar5146a092010-07-12 21:23:32 +000061 bool ParseSectionDirectiveData(StringRef, SMLoc) {
Rafael Espindola0453dd92010-09-27 21:40:27 +000062 return ParseSectionSwitch(".data", MCSectionELF::SHT_PROGBITS,
Daniel Dunbar5146a092010-07-12 21:23:32 +000063 MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
64 SectionKind::getDataRel());
65 }
66 bool ParseSectionDirectiveText(StringRef, SMLoc) {
Rafael Espindola0453dd92010-09-27 21:40:27 +000067 return ParseSectionSwitch(".text", MCSectionELF::SHT_PROGBITS,
Daniel Dunbar5146a092010-07-12 21:23:32 +000068 MCSectionELF::SHF_EXECINSTR |
69 MCSectionELF::SHF_ALLOC, SectionKind::getText());
70 }
Matt Flemingf525c2a2010-07-20 21:12:46 +000071 bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
Rafael Espindola0453dd92010-09-27 21:40:27 +000072 return ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS,
Matt Flemingf525c2a2010-07-20 21:12:46 +000073 MCSectionELF::SHF_WRITE |
74 MCSectionELF::SHF_ALLOC, SectionKind::getBSS());
75 }
76 bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
77 return ParseSectionSwitch(".rodata", MCSectionELF::SHT_PROGBITS,
78 MCSectionELF::SHF_ALLOC,
79 SectionKind::getReadOnly());
80 }
81 bool ParseSectionDirectiveTData(StringRef, SMLoc) {
82 return ParseSectionSwitch(".tdata", MCSectionELF::SHT_PROGBITS,
83 MCSectionELF::SHF_ALLOC |
84 MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE,
85 SectionKind::getThreadData());
86 }
87 bool ParseSectionDirectiveTBSS(StringRef, SMLoc) {
88 return ParseSectionSwitch(".tbss", MCSectionELF::SHT_NOBITS,
89 MCSectionELF::SHF_ALLOC |
90 MCSectionELF::SHF_TLS | MCSectionELF::SHF_WRITE,
91 SectionKind::getThreadBSS());
92 }
93 bool ParseSectionDirectiveDataRel(StringRef, SMLoc) {
94 return ParseSectionSwitch(".data.rel", MCSectionELF::SHT_PROGBITS,
95 MCSectionELF::SHF_ALLOC |
96 MCSectionELF::SHF_WRITE,
97 SectionKind::getDataRel());
98 }
99 bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) {
100 return ParseSectionSwitch(".data.rel.ro", MCSectionELF::SHT_PROGBITS,
101 MCSectionELF::SHF_ALLOC |
102 MCSectionELF::SHF_WRITE,
103 SectionKind::getReadOnlyWithRel());
104 }
105 bool ParseSectionDirectiveDataRelRoLocal(StringRef, SMLoc) {
106 return ParseSectionSwitch(".data.rel.ro.local", MCSectionELF::SHT_PROGBITS,
107 MCSectionELF::SHF_ALLOC |
108 MCSectionELF::SHF_WRITE,
109 SectionKind::getReadOnlyWithRelLocal());
110 }
111 bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) {
112 return ParseSectionSwitch(".eh_frame", MCSectionELF::SHT_PROGBITS,
113 MCSectionELF::SHF_ALLOC |
114 MCSectionELF::SHF_WRITE,
115 SectionKind::getDataRel());
116 }
Eli Friedman21444ef2010-07-17 04:29:04 +0000117 bool ParseDirectiveSection(StringRef, SMLoc);
118 bool ParseDirectiveSize(StringRef, SMLoc);
Benjamin Kramer1674b0b2010-09-02 18:53:37 +0000119 bool ParseDirectivePrevious(StringRef, SMLoc);
Michael J. Spencere90ea132010-10-09 03:47:55 +0000120 bool ParseDirectiveType(StringRef, SMLoc);
Rafael Espindola61e3b912010-10-26 19:35:47 +0000121 bool ParseDirectiveIdent(StringRef, SMLoc);
Rafael Espindola88182132010-10-27 15:18:17 +0000122 bool ParseDirectiveSymver(StringRef, SMLoc);
Rafael Espindola484291c2010-11-01 14:28:48 +0000123 bool ParseDirectiveWeakref(StringRef, SMLoc);
Rafael Espindola34e3d0c2010-09-16 17:05:55 +0000124
125private:
126 bool ParseSectionName(StringRef &SectionName);
Daniel Dunbar5146a092010-07-12 21:23:32 +0000127};
128
129}
130
131bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
132 unsigned Flags, SectionKind Kind) {
133 if (getLexer().isNot(AsmToken::EndOfStatement))
134 return TokError("unexpected token in section switching directive");
135 Lex();
136
137 getStreamer().SwitchSection(getContext().getELFSection(
138 Section, Type, Flags, Kind));
139
140 return false;
141}
142
Eli Friedman21444ef2010-07-17 04:29:04 +0000143bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
Eli Friedmanf82ccf52010-07-17 03:09:18 +0000144 StringRef Name;
145 if (getParser().ParseIdentifier(Name))
146 return TokError("expected identifier in directive");
147 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);;
148
149 if (getLexer().isNot(AsmToken::Comma))
150 return TokError("unexpected token in directive");
151 Lex();
152
153 const MCExpr *Expr;
154 if (getParser().ParseExpression(Expr))
155 return true;
156
157 if (getLexer().isNot(AsmToken::EndOfStatement))
158 return TokError("unexpected token in directive");
159
160 getStreamer().EmitELFSize(Sym, Expr);
161 return false;
162}
163
Rafael Espindola34e3d0c2010-09-16 17:05:55 +0000164bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
165 // A section name can contain -, so we cannot just use
166 // ParseIdentifier.
167 SMLoc FirstLoc = getLexer().getLoc();
168 unsigned Size = 0;
169
170 for (;;) {
171 StringRef Tmp;
172 unsigned CurSize;
173
174 SMLoc PrevLoc = getLexer().getLoc();
175 if (getLexer().is(AsmToken::Minus)) {
176 CurSize = 1;
177 Lex(); // Consume the "-".
178 } else if (!getParser().ParseIdentifier(Tmp))
179 CurSize = Tmp.size();
180 else
181 break;
182
183 Size += CurSize;
184 SectionName = StringRef(FirstLoc.getPointer(), Size);
185
186 // Make sure the following token is adjacent.
187 if (PrevLoc.getPointer() + CurSize != getTok().getLoc().getPointer())
188 break;
189 }
190 if (Size == 0)
191 return true;
192
193 return false;
194}
195
Rafael Espindola25958732010-11-24 21:57:39 +0000196static SectionKind computeSectionKind(unsigned Flags) {
197 if (Flags & MCSectionELF::SHF_EXECINSTR)
198 return SectionKind::getText();
199 if (Flags & MCSectionELF::SHF_TLS)
200 return SectionKind::getThreadData();
201 return SectionKind::getDataRel();
202}
203
Eli Friedman21444ef2010-07-17 04:29:04 +0000204// FIXME: This is a work in progress.
205bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
206 StringRef SectionName;
Rafael Espindola34e3d0c2010-09-16 17:05:55 +0000207
208 if (ParseSectionName(SectionName))
Eli Friedman21444ef2010-07-17 04:29:04 +0000209 return TokError("expected identifier in directive");
210
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000211 StringRef FlagsStr;
Eli Friedman21444ef2010-07-17 04:29:04 +0000212 StringRef TypeName;
213 int64_t Size = 0;
Rafael Espindola2ff9e832010-11-11 18:13:52 +0000214 StringRef GroupName;
Eli Friedman21444ef2010-07-17 04:29:04 +0000215 if (getLexer().is(AsmToken::Comma)) {
216 Lex();
217
218 if (getLexer().isNot(AsmToken::String))
219 return TokError("expected string in directive");
220
221 FlagsStr = getTok().getStringContents();
222 Lex();
223
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000224 bool Mergeable = FlagsStr.find('M') != StringRef::npos;
225 bool Group = FlagsStr.find('G') != StringRef::npos;
Eli Friedman21444ef2010-07-17 04:29:04 +0000226
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000227 if (getLexer().isNot(AsmToken::Comma)) {
228 if (Mergeable)
229 return TokError("Mergeable section must specify the type");
230 if (Group)
231 return TokError("Group section must specify the type");
232 } else {
233 Lex();
Rafael Espindolad4a35262010-11-12 15:47:08 +0000234 if (getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::At))
235 return TokError("expected '@' or '%' before type");
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000236
237 Lex();
238 if (getParser().ParseIdentifier(TypeName))
239 return TokError("expected identifier in directive");
240
241 if (Mergeable) {
242 if (getLexer().isNot(AsmToken::Comma))
243 return TokError("expected the entry size");
244 Lex();
245 if (getParser().ParseAbsoluteExpression(Size))
246 return true;
247 if (Size <= 0)
248 return TokError("entry size must be positive");
249 }
250
251 if (Group) {
252 if (getLexer().isNot(AsmToken::Comma))
253 return TokError("expected group name");
254 Lex();
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000255 if (getParser().ParseIdentifier(GroupName))
256 return true;
Eli Friedman21444ef2010-07-17 04:29:04 +0000257 if (getLexer().is(AsmToken::Comma)) {
258 Lex();
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000259 StringRef Linkage;
260 if (getParser().ParseIdentifier(Linkage))
Eli Friedman21444ef2010-07-17 04:29:04 +0000261 return true;
Rafael Espindola2ff9e832010-11-11 18:13:52 +0000262 if (Linkage != "comdat")
263 return TokError("Linkage must be 'comdat'");
Eli Friedman21444ef2010-07-17 04:29:04 +0000264 }
265 }
266 }
267 }
268
269 if (getLexer().isNot(AsmToken::EndOfStatement))
270 return TokError("unexpected token in directive");
271
272 unsigned Flags = 0;
Rafael Espindola4fa34782010-10-27 18:45:20 +0000273 unsigned Type = MCSectionELF::SHT_NULL;
274
275 // Set the defaults first.
Rafael Espindola4faf7c72010-11-08 02:47:59 +0000276 if (SectionName == ".fini" || SectionName == ".init" || SectionName == ".rodata") {
Rafael Espindola4fa34782010-10-27 18:45:20 +0000277 Type = MCSectionELF::SHT_PROGBITS;
278 Flags |= MCSectionELF::SHF_ALLOC;
Rafael Espindola4faf7c72010-11-08 02:47:59 +0000279 }
280 if (SectionName == ".fini" || SectionName == ".init") {
Rafael Espindola4fa34782010-10-27 18:45:20 +0000281 Flags |= MCSectionELF::SHF_EXECINSTR;
282 }
283
Eli Friedman21444ef2010-07-17 04:29:04 +0000284 for (unsigned i = 0; i < FlagsStr.size(); i++) {
285 switch (FlagsStr[i]) {
286 case 'a':
287 Flags |= MCSectionELF::SHF_ALLOC;
288 break;
289 case 'x':
290 Flags |= MCSectionELF::SHF_EXECINSTR;
291 break;
292 case 'w':
293 Flags |= MCSectionELF::SHF_WRITE;
294 break;
295 case 'M':
296 Flags |= MCSectionELF::SHF_MERGE;
297 break;
298 case 'S':
299 Flags |= MCSectionELF::SHF_STRINGS;
300 break;
301 case 'T':
302 Flags |= MCSectionELF::SHF_TLS;
303 break;
304 case 'c':
305 Flags |= MCSectionELF::XCORE_SHF_CP_SECTION;
306 break;
307 case 'd':
308 Flags |= MCSectionELF::XCORE_SHF_DP_SECTION;
309 break;
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000310 case 'G':
Rafael Espindola2ff9e832010-11-11 18:13:52 +0000311 Flags |= MCSectionELF::SHF_GROUP;
Rafael Espindolaf4b0f3e2010-10-28 21:33:33 +0000312 break;
Eli Friedman21444ef2010-07-17 04:29:04 +0000313 default:
314 return TokError("unknown flag");
315 }
316 }
317
Eli Friedman21444ef2010-07-17 04:29:04 +0000318 if (!TypeName.empty()) {
319 if (TypeName == "init_array")
320 Type = MCSectionELF::SHT_INIT_ARRAY;
321 else if (TypeName == "fini_array")
322 Type = MCSectionELF::SHT_FINI_ARRAY;
323 else if (TypeName == "preinit_array")
324 Type = MCSectionELF::SHT_PREINIT_ARRAY;
325 else if (TypeName == "nobits")
326 Type = MCSectionELF::SHT_NOBITS;
327 else if (TypeName == "progbits")
328 Type = MCSectionELF::SHT_PROGBITS;
329 else
330 return TokError("unknown section type");
331 }
332
Rafael Espindola25958732010-11-24 21:57:39 +0000333 SectionKind Kind = computeSectionKind(Flags);
Eli Friedman21444ef2010-07-17 04:29:04 +0000334 getStreamer().SwitchSection(getContext().getELFSection(SectionName, Type,
Rafael Espindola2ff9e832010-11-11 18:13:52 +0000335 Flags, Kind, Size,
336 GroupName));
Eli Friedman21444ef2010-07-17 04:29:04 +0000337 return false;
338}
339
Benjamin Kramer1674b0b2010-09-02 18:53:37 +0000340bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) {
341 const MCSection *PreviousSection = getStreamer().getPreviousSection();
342 if (PreviousSection != NULL)
343 getStreamer().SwitchSection(PreviousSection);
344
345 return false;
346}
347
Michael J. Spencere90ea132010-10-09 03:47:55 +0000348/// ParseDirectiveELFType
349/// ::= .type identifier , @attribute
350bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
351 StringRef Name;
352 if (getParser().ParseIdentifier(Name))
353 return TokError("expected identifier in directive");
354
355 // Handle the identifier as the key symbol.
356 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
357
358 if (getLexer().isNot(AsmToken::Comma))
359 return TokError("unexpected token in '.type' directive");
360 Lex();
361
Rafael Espindolad4a35262010-11-12 15:47:08 +0000362 if (getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::At))
363 return TokError("expected '@' or '%' before type");
Michael J. Spencere90ea132010-10-09 03:47:55 +0000364 Lex();
365
366 StringRef Type;
367 SMLoc TypeLoc;
368
369 TypeLoc = getLexer().getLoc();
370 if (getParser().ParseIdentifier(Type))
371 return TokError("expected symbol type in directive");
372
373 MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Type)
374 .Case("function", MCSA_ELF_TypeFunction)
375 .Case("object", MCSA_ELF_TypeObject)
376 .Case("tls_object", MCSA_ELF_TypeTLS)
377 .Case("common", MCSA_ELF_TypeCommon)
378 .Case("notype", MCSA_ELF_TypeNoType)
Rafael Espindolae13a0ff2010-11-13 04:51:02 +0000379 .Case("gnu_unique_object", MCSA_ELF_TypeGnuUniqueObject)
Michael J. Spencere90ea132010-10-09 03:47:55 +0000380 .Default(MCSA_Invalid);
381
382 if (Attr == MCSA_Invalid)
383 return Error(TypeLoc, "unsupported attribute in '.type' directive");
384
385 if (getLexer().isNot(AsmToken::EndOfStatement))
386 return TokError("unexpected token in '.type' directive");
387
388 Lex();
389
390 getStreamer().EmitSymbolAttribute(Sym, Attr);
391
392 return false;
393}
394
Rafael Espindola61e3b912010-10-26 19:35:47 +0000395/// ParseDirectiveIdent
396/// ::= .ident string
397bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
398 if (getLexer().isNot(AsmToken::String))
399 return TokError("unexpected token in '.ident' directive");
400
401 StringRef Data = getTok().getIdentifier();
402
403 Lex();
404
405 const MCSection *OldSection = getStreamer().getCurrentSection();
406 const MCSection *Comment =
407 getContext().getELFSection(".comment", MCSectionELF::SHT_PROGBITS,
408 MCSectionELF::SHF_MERGE |
409 MCSectionELF::SHF_STRINGS,
410 SectionKind::getReadOnly(),
Rafael Espindola2ff9e832010-11-11 18:13:52 +0000411 1, "");
Rafael Espindola61e3b912010-10-26 19:35:47 +0000412
413 static bool First = true;
414
415 getStreamer().SwitchSection(Comment);
416 if (First)
417 getStreamer().EmitIntValue(0, 1);
418 First = false;
419 getStreamer().EmitBytes(Data, 0);
420 getStreamer().EmitIntValue(0, 1);
421 getStreamer().SwitchSection(OldSection);
422 return false;
423}
424
Rafael Espindola88182132010-10-27 15:18:17 +0000425/// ParseDirectiveSymver
426/// ::= .symver foo, bar2@zed
427bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
428 StringRef Name;
429 if (getParser().ParseIdentifier(Name))
430 return TokError("expected identifier in directive");
431
432 if (getLexer().isNot(AsmToken::Comma))
433 return TokError("expected a comma");
434
435 Lex();
436
437 StringRef AliasName;
438 if (getParser().ParseIdentifier(AliasName))
439 return TokError("expected identifier in directive");
440
441 if (AliasName.find('@') == StringRef::npos)
442 return TokError("expected a '@' in the name");
443
444 MCSymbol *Alias = getContext().GetOrCreateSymbol(AliasName);
445 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
446 const MCExpr *Value = MCSymbolRefExpr::Create(Sym, getContext());
447
448 getStreamer().EmitAssignment(Alias, Value);
449 return false;
450}
451
Rafael Espindola484291c2010-11-01 14:28:48 +0000452/// ParseDirectiveWeakref
453/// ::= .weakref foo, bar
454bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
455 // FIXME: Share code with the other alias building directives.
456
457 StringRef AliasName;
458 if (getParser().ParseIdentifier(AliasName))
459 return TokError("expected identifier in directive");
460
461 if (getLexer().isNot(AsmToken::Comma))
462 return TokError("expected a comma");
463
464 Lex();
465
466 StringRef Name;
467 if (getParser().ParseIdentifier(Name))
468 return TokError("expected identifier in directive");
469
470 MCSymbol *Alias = getContext().GetOrCreateSymbol(AliasName);
471
472 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
473
474 getStreamer().EmitWeakReference(Alias, Sym);
475 return false;
476}
477
Daniel Dunbar5146a092010-07-12 21:23:32 +0000478namespace llvm {
479
480MCAsmParserExtension *createELFAsmParser() {
481 return new ELFAsmParser;
482}
483
484}