1 //===- ELFAsmParser.cpp - ELF Assembly Parser -----------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCParser/MCAsmParserExtension.h"
11 #include "llvm/ADT/StringSwitch.h"
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/MC/MCAsmInfo.h"
14 #include "llvm/MC/MCContext.h"
15 #include "llvm/MC/MCExpr.h"
16 #include "llvm/MC/MCParser/MCAsmLexer.h"
17 #include "llvm/MC/MCSectionELF.h"
18 #include "llvm/MC/MCStreamer.h"
19 #include "llvm/MC/MCSymbolELF.h"
20 #include "llvm/Support/ELF.h"
25 class ELFAsmParser : public MCAsmParserExtension {
26 template<bool (ELFAsmParser::*HandlerMethod)(StringRef, SMLoc)>
27 void addDirectiveHandler(StringRef Directive) {
28 MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair(
29 this, HandleDirective<ELFAsmParser, HandlerMethod>);
31 getParser().addDirectiveHandler(Directive, Handler);
34 bool ParseSectionSwitch(StringRef Section, unsigned Type, unsigned Flags,
38 ELFAsmParser() { BracketExpressionsSupported = true; }
40 void Initialize(MCAsmParser &Parser) override {
41 // Call the base implementation.
42 this->MCAsmParserExtension::Initialize(Parser);
44 addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveData>(".data");
45 addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveText>(".text");
46 addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveBSS>(".bss");
47 addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData>(".rodata");
48 addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData>(".tdata");
49 addDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS>(".tbss");
51 &ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel");
53 &ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro");
55 &ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
56 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSection>(".section");
58 &ELFAsmParser::ParseDirectivePushSection>(".pushsection");
59 addDirectiveHandler<&ELFAsmParser::ParseDirectivePopSection>(".popsection");
60 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
61 addDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous");
62 addDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type");
63 addDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
64 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
65 addDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion>(".version");
66 addDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
67 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
68 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local");
70 &ELFAsmParser::ParseDirectiveSymbolAttribute>(".protected");
72 &ELFAsmParser::ParseDirectiveSymbolAttribute>(".internal");
74 &ELFAsmParser::ParseDirectiveSymbolAttribute>(".hidden");
75 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSubsection>(".subsection");
78 // FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
79 // the best way for us to get access to it?
80 bool ParseSectionDirectiveData(StringRef, SMLoc) {
81 return ParseSectionSwitch(".data", ELF::SHT_PROGBITS,
82 ELF::SHF_WRITE | ELF::SHF_ALLOC,
83 SectionKind::getData());
85 bool ParseSectionDirectiveText(StringRef, SMLoc) {
86 return ParseSectionSwitch(".text", ELF::SHT_PROGBITS,
88 ELF::SHF_ALLOC, SectionKind::getText());
90 bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
91 return ParseSectionSwitch(".bss", ELF::SHT_NOBITS,
93 ELF::SHF_ALLOC, SectionKind::getBSS());
95 bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
96 return ParseSectionSwitch(".rodata", ELF::SHT_PROGBITS,
98 SectionKind::getReadOnly());
100 bool ParseSectionDirectiveTData(StringRef, SMLoc) {
101 return ParseSectionSwitch(".tdata", ELF::SHT_PROGBITS,
103 ELF::SHF_TLS | ELF::SHF_WRITE,
104 SectionKind::getThreadData());
106 bool ParseSectionDirectiveTBSS(StringRef, SMLoc) {
107 return ParseSectionSwitch(".tbss", ELF::SHT_NOBITS,
109 ELF::SHF_TLS | ELF::SHF_WRITE,
110 SectionKind::getThreadBSS());
112 bool ParseSectionDirectiveDataRel(StringRef, SMLoc) {
113 return ParseSectionSwitch(".data.rel", ELF::SHT_PROGBITS,
114 ELF::SHF_ALLOC | ELF::SHF_WRITE,
115 SectionKind::getData());
117 bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) {
118 return ParseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS,
121 SectionKind::getReadOnlyWithRel());
123 bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) {
124 return ParseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS,
125 ELF::SHF_ALLOC | ELF::SHF_WRITE,
126 SectionKind::getData());
128 bool ParseDirectivePushSection(StringRef, SMLoc);
129 bool ParseDirectivePopSection(StringRef, SMLoc);
130 bool ParseDirectiveSection(StringRef, SMLoc);
131 bool ParseDirectiveSize(StringRef, SMLoc);
132 bool ParseDirectivePrevious(StringRef, SMLoc);
133 bool ParseDirectiveType(StringRef, SMLoc);
134 bool ParseDirectiveIdent(StringRef, SMLoc);
135 bool ParseDirectiveSymver(StringRef, SMLoc);
136 bool ParseDirectiveVersion(StringRef, SMLoc);
137 bool ParseDirectiveWeakref(StringRef, SMLoc);
138 bool ParseDirectiveSymbolAttribute(StringRef, SMLoc);
139 bool ParseDirectiveSubsection(StringRef, SMLoc);
142 bool ParseSectionName(StringRef &SectionName);
143 bool ParseSectionArguments(bool IsPush, SMLoc loc);
144 unsigned parseSunStyleSectionFlags();
149 /// ParseDirectiveSymbolAttribute
150 /// ::= { ".local", ".weak", ... } [ identifier ( , identifier )* ]
151 bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
152 MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Directive)
153 .Case(".weak", MCSA_Weak)
154 .Case(".local", MCSA_Local)
155 .Case(".hidden", MCSA_Hidden)
156 .Case(".internal", MCSA_Internal)
157 .Case(".protected", MCSA_Protected)
158 .Default(MCSA_Invalid);
159 assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!");
160 if (getLexer().isNot(AsmToken::EndOfStatement)) {
164 if (getParser().parseIdentifier(Name))
165 return TokError("expected identifier in directive");
167 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
169 getStreamer().EmitSymbolAttribute(Sym, Attr);
171 if (getLexer().is(AsmToken::EndOfStatement))
174 if (getLexer().isNot(AsmToken::Comma))
175 return TokError("unexpected token in directive");
184 bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
185 unsigned Flags, SectionKind Kind) {
186 const MCExpr *Subsection = nullptr;
187 if (getLexer().isNot(AsmToken::EndOfStatement)) {
188 if (getParser().parseExpression(Subsection))
192 getStreamer().SwitchSection(getContext().getELFSection(Section, Type, Flags),
198 bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
200 if (getParser().parseIdentifier(Name))
201 return TokError("expected identifier in directive");
202 MCSymbolELF *Sym = cast<MCSymbolELF>(getContext().getOrCreateSymbol(Name));
204 if (getLexer().isNot(AsmToken::Comma))
205 return TokError("unexpected token in directive");
209 if (getParser().parseExpression(Expr))
212 if (getLexer().isNot(AsmToken::EndOfStatement))
213 return TokError("unexpected token in directive");
215 getStreamer().emitELFSize(Sym, Expr);
219 bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
220 // A section name can contain -, so we cannot just use
222 SMLoc FirstLoc = getLexer().getLoc();
225 if (getLexer().is(AsmToken::String)) {
226 SectionName = getTok().getIdentifier();
234 SMLoc PrevLoc = getLexer().getLoc();
235 if (getLexer().is(AsmToken::Minus)) {
237 Lex(); // Consume the "-".
238 } else if (getLexer().is(AsmToken::String)) {
239 CurSize = getTok().getIdentifier().size() + 2;
241 } else if (getLexer().is(AsmToken::Identifier)) {
242 CurSize = getTok().getIdentifier().size();
249 SectionName = StringRef(FirstLoc.getPointer(), Size);
251 // Make sure the following token is adjacent.
252 if (PrevLoc.getPointer() + CurSize != getTok().getLoc().getPointer())
261 static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
264 for (unsigned i = 0; i < flagsStr.size(); i++) {
265 switch (flagsStr[i]) {
267 flags |= ELF::SHF_ALLOC;
270 flags |= ELF::SHF_EXCLUDE;
273 flags |= ELF::SHF_EXECINSTR;
276 flags |= ELF::SHF_WRITE;
279 flags |= ELF::SHF_MERGE;
282 flags |= ELF::SHF_STRINGS;
285 flags |= ELF::SHF_TLS;
288 flags |= ELF::XCORE_SHF_CP_SECTION;
291 flags |= ELF::XCORE_SHF_DP_SECTION;
294 flags |= ELF::SHF_GROUP;
297 *UseLastGroup = true;
307 unsigned ELFAsmParser::parseSunStyleSectionFlags() {
309 while (getLexer().is(AsmToken::Hash)) {
312 if (!getLexer().is(AsmToken::Identifier))
315 StringRef flagId = getTok().getIdentifier();
316 if (flagId == "alloc")
317 flags |= ELF::SHF_ALLOC;
318 else if (flagId == "execinstr")
319 flags |= ELF::SHF_EXECINSTR;
320 else if (flagId == "write")
321 flags |= ELF::SHF_WRITE;
322 else if (flagId == "tls")
323 flags |= ELF::SHF_TLS;
327 Lex(); // Eat the flag.
329 if (!getLexer().is(AsmToken::Comma))
331 Lex(); // Eat the comma.
337 bool ELFAsmParser::ParseDirectivePushSection(StringRef s, SMLoc loc) {
338 getStreamer().PushSection();
340 if (ParseSectionArguments(/*IsPush=*/true, loc)) {
341 getStreamer().PopSection();
348 bool ELFAsmParser::ParseDirectivePopSection(StringRef, SMLoc) {
349 if (!getStreamer().PopSection())
350 return TokError(".popsection without corresponding .pushsection");
354 // FIXME: This is a work in progress.
355 bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc loc) {
356 return ParseSectionArguments(/*IsPush=*/false, loc);
359 bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
360 StringRef SectionName;
362 if (ParseSectionName(SectionName))
363 return TokError("expected identifier in directive");
369 const MCExpr *Subsection = nullptr;
370 bool UseLastGroup = false;
372 int64_t UniqueID = ~0;
374 // Set the defaults first.
375 if (SectionName == ".fini" || SectionName == ".init" ||
376 SectionName == ".rodata")
377 Flags |= ELF::SHF_ALLOC;
378 if (SectionName == ".fini" || SectionName == ".init")
379 Flags |= ELF::SHF_EXECINSTR;
381 if (getLexer().is(AsmToken::Comma)) {
384 if (IsPush && getLexer().isNot(AsmToken::String)) {
385 if (getParser().parseExpression(Subsection))
387 if (getLexer().isNot(AsmToken::Comma))
394 if (getLexer().isNot(AsmToken::String)) {
395 if (!getContext().getAsmInfo()->usesSunStyleELFSectionSwitchSyntax()
396 || getLexer().isNot(AsmToken::Hash))
397 return TokError("expected string in directive");
398 extraFlags = parseSunStyleSectionFlags();
400 StringRef FlagsStr = getTok().getStringContents();
402 extraFlags = parseSectionFlags(FlagsStr, &UseLastGroup);
405 if (extraFlags == -1U)
406 return TokError("unknown flag");
409 bool Mergeable = Flags & ELF::SHF_MERGE;
410 bool Group = Flags & ELF::SHF_GROUP;
411 if (Group && UseLastGroup)
412 return TokError("Section cannot specifiy a group name while also acting "
413 "as a member of the last group");
415 if (getLexer().isNot(AsmToken::Comma)) {
417 return TokError("Mergeable section must specify the type");
419 return TokError("Group section must specify the type");
422 if (getLexer().is(AsmToken::At) || getLexer().is(AsmToken::Percent) ||
423 getLexer().is(AsmToken::String)) {
424 if (!getLexer().is(AsmToken::String))
427 return TokError("expected '@<type>', '%<type>' or \"<type>\"");
429 if (getParser().parseIdentifier(TypeName))
430 return TokError("expected identifier in directive");
433 if (getLexer().isNot(AsmToken::Comma))
434 return TokError("expected the entry size");
436 if (getParser().parseAbsoluteExpression(Size))
439 return TokError("entry size must be positive");
443 if (getLexer().isNot(AsmToken::Comma))
444 return TokError("expected group name");
446 if (getParser().parseIdentifier(GroupName))
448 if (getLexer().is(AsmToken::Comma)) {
451 if (getParser().parseIdentifier(Linkage))
453 if (Linkage != "comdat")
454 return TokError("Linkage must be 'comdat'");
457 if (getLexer().is(AsmToken::Comma)) {
459 if (getParser().parseIdentifier(UniqueStr))
460 return TokError("expected identifier in directive");
461 if (UniqueStr != "unique")
462 return TokError("expected 'unique'");
463 if (getLexer().isNot(AsmToken::Comma))
464 return TokError("expected commma");
466 if (getParser().parseAbsoluteExpression(UniqueID))
469 return TokError("unique id must be positive");
470 if (!isUInt<32>(UniqueID) || UniqueID == ~0U)
471 return TokError("unique id is too large");
477 if (getLexer().isNot(AsmToken::EndOfStatement))
478 return TokError("unexpected token in directive");
480 unsigned Type = ELF::SHT_PROGBITS;
482 if (TypeName.empty()) {
483 if (SectionName.startswith(".note"))
484 Type = ELF::SHT_NOTE;
485 else if (SectionName == ".init_array")
486 Type = ELF::SHT_INIT_ARRAY;
487 else if (SectionName == ".fini_array")
488 Type = ELF::SHT_FINI_ARRAY;
489 else if (SectionName == ".preinit_array")
490 Type = ELF::SHT_PREINIT_ARRAY;
492 if (TypeName == "init_array")
493 Type = ELF::SHT_INIT_ARRAY;
494 else if (TypeName == "fini_array")
495 Type = ELF::SHT_FINI_ARRAY;
496 else if (TypeName == "preinit_array")
497 Type = ELF::SHT_PREINIT_ARRAY;
498 else if (TypeName == "nobits")
499 Type = ELF::SHT_NOBITS;
500 else if (TypeName == "progbits")
501 Type = ELF::SHT_PROGBITS;
502 else if (TypeName == "note")
503 Type = ELF::SHT_NOTE;
504 else if (TypeName == "unwind")
505 Type = ELF::SHT_X86_64_UNWIND;
507 return TokError("unknown section type");
511 MCSectionSubPair CurrentSection = getStreamer().getCurrentSection();
512 if (const MCSectionELF *Section =
513 cast_or_null<MCSectionELF>(CurrentSection.first))
514 if (const MCSymbol *Group = Section->getGroup()) {
515 GroupName = Group->getName();
516 Flags |= ELF::SHF_GROUP;
520 MCSection *ELFSection = getContext().getELFSection(SectionName, Type, Flags,
521 Size, GroupName, UniqueID);
522 getStreamer().SwitchSection(ELFSection, Subsection);
524 if (getContext().getGenDwarfForAssembly()) {
525 bool InsertResult = getContext().addGenDwarfSection(ELFSection);
527 if (getContext().getDwarfVersion() <= 2)
528 Warning(loc, "DWARF2 only supports one section per compilation unit");
530 if (!ELFSection->getBeginSymbol()) {
531 MCSymbol *SectionStartSymbol = getContext().createTempSymbol();
532 getStreamer().EmitLabel(SectionStartSymbol);
533 ELFSection->setBeginSymbol(SectionStartSymbol);
541 bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) {
542 MCSectionSubPair PreviousSection = getStreamer().getPreviousSection();
543 if (PreviousSection.first == nullptr)
544 return TokError(".previous without corresponding .section");
545 getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second);
550 static MCSymbolAttr MCAttrForString(StringRef Type) {
551 return StringSwitch<MCSymbolAttr>(Type)
552 .Cases("STT_FUNC", "function", MCSA_ELF_TypeFunction)
553 .Cases("STT_OBJECT", "object", MCSA_ELF_TypeObject)
554 .Cases("STT_TLS", "tls_object", MCSA_ELF_TypeTLS)
555 .Cases("STT_COMMON", "common", MCSA_ELF_TypeCommon)
556 .Cases("STT_NOTYPE", "notype", MCSA_ELF_TypeNoType)
557 .Cases("STT_GNU_IFUNC", "gnu_indirect_function",
558 MCSA_ELF_TypeIndFunction)
559 .Case("gnu_unique_object", MCSA_ELF_TypeGnuUniqueObject)
560 .Default(MCSA_Invalid);
563 /// ParseDirectiveELFType
564 /// ::= .type identifier , STT_<TYPE_IN_UPPER_CASE>
565 /// ::= .type identifier , #attribute
566 /// ::= .type identifier , @attribute
567 /// ::= .type identifier , %attribute
568 /// ::= .type identifier , "attribute"
569 bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
571 if (getParser().parseIdentifier(Name))
572 return TokError("expected identifier in directive");
574 // Handle the identifier as the key symbol.
575 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
577 // NOTE the comma is optional in all cases. It is only documented as being
578 // optional in the first case, however, GAS will silently treat the comma as
579 // optional in all cases. Furthermore, although the documentation states that
580 // the first form only accepts STT_<TYPE_IN_UPPER_CASE>, in reality, GAS
581 // accepts both the upper case name as well as the lower case aliases.
582 if (getLexer().is(AsmToken::Comma))
585 if (getLexer().isNot(AsmToken::Identifier) &&
586 getLexer().isNot(AsmToken::Hash) &&
587 getLexer().isNot(AsmToken::Percent) &&
588 getLexer().isNot(AsmToken::String)) {
589 if (!getLexer().getAllowAtInIdentifier())
590 return TokError("expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', "
591 "'%<type>' or \"<type>\"");
592 else if (getLexer().isNot(AsmToken::At))
593 return TokError("expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', "
594 "'%<type>' or \"<type>\"");
597 if (getLexer().isNot(AsmToken::String) &&
598 getLexer().isNot(AsmToken::Identifier))
601 SMLoc TypeLoc = getLexer().getLoc();
604 if (getParser().parseIdentifier(Type))
605 return TokError("expected symbol type in directive");
607 MCSymbolAttr Attr = MCAttrForString(Type);
608 if (Attr == MCSA_Invalid)
609 return Error(TypeLoc, "unsupported attribute in '.type' directive");
611 if (getLexer().isNot(AsmToken::EndOfStatement))
612 return TokError("unexpected token in '.type' directive");
615 getStreamer().EmitSymbolAttribute(Sym, Attr);
620 /// ParseDirectiveIdent
621 /// ::= .ident string
622 bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
623 if (getLexer().isNot(AsmToken::String))
624 return TokError("unexpected token in '.ident' directive");
626 StringRef Data = getTok().getIdentifier();
630 getStreamer().EmitIdent(Data);
634 /// ParseDirectiveSymver
635 /// ::= .symver foo, bar2@zed
636 bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
638 if (getParser().parseIdentifier(Name))
639 return TokError("expected identifier in directive");
641 if (getLexer().isNot(AsmToken::Comma))
642 return TokError("expected a comma");
644 // ARM assembly uses @ for a comment...
645 // except when parsing the second parameter of the .symver directive.
646 // Force the next symbol to allow @ in the identifier, which is
647 // required for this directive and then reset it to its initial state.
648 const bool AllowAtInIdentifier = getLexer().getAllowAtInIdentifier();
649 getLexer().setAllowAtInIdentifier(true);
651 getLexer().setAllowAtInIdentifier(AllowAtInIdentifier);
654 if (getParser().parseIdentifier(AliasName))
655 return TokError("expected identifier in directive");
657 if (AliasName.find('@') == StringRef::npos)
658 return TokError("expected a '@' in the name");
660 MCSymbol *Alias = getContext().getOrCreateSymbol(AliasName);
661 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
662 const MCExpr *Value = MCSymbolRefExpr::create(Sym, getContext());
664 getStreamer().EmitAssignment(Alias, Value);
668 /// ParseDirectiveVersion
669 /// ::= .version string
670 bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
671 if (getLexer().isNot(AsmToken::String))
672 return TokError("unexpected token in '.version' directive");
674 StringRef Data = getTok().getIdentifier();
678 MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0);
680 getStreamer().PushSection();
681 getStreamer().SwitchSection(Note);
682 getStreamer().EmitIntValue(Data.size()+1, 4); // namesz.
683 getStreamer().EmitIntValue(0, 4); // descsz = 0 (no description).
684 getStreamer().EmitIntValue(1, 4); // type = NT_VERSION.
685 getStreamer().EmitBytes(Data); // name.
686 getStreamer().EmitIntValue(0, 1); // terminate the string.
687 getStreamer().EmitValueToAlignment(4); // ensure 4 byte alignment.
688 getStreamer().PopSection();
692 /// ParseDirectiveWeakref
693 /// ::= .weakref foo, bar
694 bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
695 // FIXME: Share code with the other alias building directives.
698 if (getParser().parseIdentifier(AliasName))
699 return TokError("expected identifier in directive");
701 if (getLexer().isNot(AsmToken::Comma))
702 return TokError("expected a comma");
707 if (getParser().parseIdentifier(Name))
708 return TokError("expected identifier in directive");
710 MCSymbol *Alias = getContext().getOrCreateSymbol(AliasName);
712 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
714 getStreamer().EmitWeakReference(Alias, Sym);
718 bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
719 const MCExpr *Subsection = nullptr;
720 if (getLexer().isNot(AsmToken::EndOfStatement)) {
721 if (getParser().parseExpression(Subsection))
725 if (getLexer().isNot(AsmToken::EndOfStatement))
726 return TokError("unexpected token in directive");
728 getStreamer().SubSection(Subsection);
734 MCAsmParserExtension *createELFAsmParser() {
735 return new ELFAsmParser;