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::ParseSectionDirectiveDataRelRoLocal>(".data.rel.ro.local");
57 &ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
58 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSection>(".section");
60 &ELFAsmParser::ParseDirectivePushSection>(".pushsection");
61 addDirectiveHandler<&ELFAsmParser::ParseDirectivePopSection>(".popsection");
62 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
63 addDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous");
64 addDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type");
65 addDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
66 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
67 addDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion>(".version");
68 addDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
69 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
70 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local");
72 &ELFAsmParser::ParseDirectiveSymbolAttribute>(".protected");
74 &ELFAsmParser::ParseDirectiveSymbolAttribute>(".internal");
76 &ELFAsmParser::ParseDirectiveSymbolAttribute>(".hidden");
77 addDirectiveHandler<&ELFAsmParser::ParseDirectiveSubsection>(".subsection");
80 // FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
81 // the best way for us to get access to it?
82 bool ParseSectionDirectiveData(StringRef, SMLoc) {
83 return ParseSectionSwitch(".data", ELF::SHT_PROGBITS,
84 ELF::SHF_WRITE |ELF::SHF_ALLOC,
85 SectionKind::getDataRel());
87 bool ParseSectionDirectiveText(StringRef, SMLoc) {
88 return ParseSectionSwitch(".text", ELF::SHT_PROGBITS,
90 ELF::SHF_ALLOC, SectionKind::getText());
92 bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
93 return ParseSectionSwitch(".bss", ELF::SHT_NOBITS,
95 ELF::SHF_ALLOC, SectionKind::getBSS());
97 bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
98 return ParseSectionSwitch(".rodata", ELF::SHT_PROGBITS,
100 SectionKind::getReadOnly());
102 bool ParseSectionDirectiveTData(StringRef, SMLoc) {
103 return ParseSectionSwitch(".tdata", ELF::SHT_PROGBITS,
105 ELF::SHF_TLS | ELF::SHF_WRITE,
106 SectionKind::getThreadData());
108 bool ParseSectionDirectiveTBSS(StringRef, SMLoc) {
109 return ParseSectionSwitch(".tbss", ELF::SHT_NOBITS,
111 ELF::SHF_TLS | ELF::SHF_WRITE,
112 SectionKind::getThreadBSS());
114 bool ParseSectionDirectiveDataRel(StringRef, SMLoc) {
115 return ParseSectionSwitch(".data.rel", ELF::SHT_PROGBITS,
118 SectionKind::getDataRel());
120 bool ParseSectionDirectiveDataRelRo(StringRef, SMLoc) {
121 return ParseSectionSwitch(".data.rel.ro", ELF::SHT_PROGBITS,
124 SectionKind::getReadOnlyWithRel());
126 bool ParseSectionDirectiveDataRelRoLocal(StringRef, SMLoc) {
127 return ParseSectionSwitch(".data.rel.ro.local", ELF::SHT_PROGBITS,
130 SectionKind::getReadOnlyWithRelLocal());
132 bool ParseSectionDirectiveEhFrame(StringRef, SMLoc) {
133 return ParseSectionSwitch(".eh_frame", ELF::SHT_PROGBITS,
136 SectionKind::getDataRel());
138 bool ParseDirectivePushSection(StringRef, SMLoc);
139 bool ParseDirectivePopSection(StringRef, SMLoc);
140 bool ParseDirectiveSection(StringRef, SMLoc);
141 bool ParseDirectiveSize(StringRef, SMLoc);
142 bool ParseDirectivePrevious(StringRef, SMLoc);
143 bool ParseDirectiveType(StringRef, SMLoc);
144 bool ParseDirectiveIdent(StringRef, SMLoc);
145 bool ParseDirectiveSymver(StringRef, SMLoc);
146 bool ParseDirectiveVersion(StringRef, SMLoc);
147 bool ParseDirectiveWeakref(StringRef, SMLoc);
148 bool ParseDirectiveSymbolAttribute(StringRef, SMLoc);
149 bool ParseDirectiveSubsection(StringRef, SMLoc);
152 bool ParseSectionName(StringRef &SectionName);
153 bool ParseSectionArguments(bool IsPush, SMLoc loc);
154 unsigned parseSunStyleSectionFlags();
159 /// ParseDirectiveSymbolAttribute
160 /// ::= { ".local", ".weak", ... } [ identifier ( , identifier )* ]
161 bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
162 MCSymbolAttr Attr = StringSwitch<MCSymbolAttr>(Directive)
163 .Case(".weak", MCSA_Weak)
164 .Case(".local", MCSA_Local)
165 .Case(".hidden", MCSA_Hidden)
166 .Case(".internal", MCSA_Internal)
167 .Case(".protected", MCSA_Protected)
168 .Default(MCSA_Invalid);
169 assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!");
170 if (getLexer().isNot(AsmToken::EndOfStatement)) {
174 if (getParser().parseIdentifier(Name))
175 return TokError("expected identifier in directive");
177 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
179 getStreamer().EmitSymbolAttribute(Sym, Attr);
181 if (getLexer().is(AsmToken::EndOfStatement))
184 if (getLexer().isNot(AsmToken::Comma))
185 return TokError("unexpected token in directive");
194 bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
195 unsigned Flags, SectionKind Kind) {
196 const MCExpr *Subsection = nullptr;
197 if (getLexer().isNot(AsmToken::EndOfStatement)) {
198 if (getParser().parseExpression(Subsection))
202 getStreamer().SwitchSection(getContext().getELFSection(Section, Type, Flags),
208 bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
210 if (getParser().parseIdentifier(Name))
211 return TokError("expected identifier in directive");
212 MCSymbolELF *Sym = cast<MCSymbolELF>(getContext().getOrCreateSymbol(Name));
214 if (getLexer().isNot(AsmToken::Comma))
215 return TokError("unexpected token in directive");
219 if (getParser().parseExpression(Expr))
222 if (getLexer().isNot(AsmToken::EndOfStatement))
223 return TokError("unexpected token in directive");
225 getStreamer().emitELFSize(Sym, Expr);
229 bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
230 // A section name can contain -, so we cannot just use
232 SMLoc FirstLoc = getLexer().getLoc();
235 if (getLexer().is(AsmToken::String)) {
236 SectionName = getTok().getIdentifier();
244 SMLoc PrevLoc = getLexer().getLoc();
245 if (getLexer().is(AsmToken::Minus)) {
247 Lex(); // Consume the "-".
248 } else if (getLexer().is(AsmToken::String)) {
249 CurSize = getTok().getIdentifier().size() + 2;
251 } else if (getLexer().is(AsmToken::Identifier)) {
252 CurSize = getTok().getIdentifier().size();
259 SectionName = StringRef(FirstLoc.getPointer(), Size);
261 // Make sure the following token is adjacent.
262 if (PrevLoc.getPointer() + CurSize != getTok().getLoc().getPointer())
271 static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
274 for (unsigned i = 0; i < flagsStr.size(); i++) {
275 switch (flagsStr[i]) {
277 flags |= ELF::SHF_ALLOC;
280 flags |= ELF::SHF_EXCLUDE;
283 flags |= ELF::SHF_EXECINSTR;
286 flags |= ELF::SHF_WRITE;
289 flags |= ELF::SHF_MERGE;
292 flags |= ELF::SHF_STRINGS;
295 flags |= ELF::SHF_TLS;
298 flags |= ELF::XCORE_SHF_CP_SECTION;
301 flags |= ELF::XCORE_SHF_DP_SECTION;
304 flags |= ELF::SHF_GROUP;
307 *UseLastGroup = true;
317 unsigned ELFAsmParser::parseSunStyleSectionFlags() {
319 while (getLexer().is(AsmToken::Hash)) {
322 if (!getLexer().is(AsmToken::Identifier))
325 StringRef flagId = getTok().getIdentifier();
326 if (flagId == "alloc")
327 flags |= ELF::SHF_ALLOC;
328 else if (flagId == "execinstr")
329 flags |= ELF::SHF_EXECINSTR;
330 else if (flagId == "write")
331 flags |= ELF::SHF_WRITE;
332 else if (flagId == "tls")
333 flags |= ELF::SHF_TLS;
337 Lex(); // Eat the flag.
339 if (!getLexer().is(AsmToken::Comma))
341 Lex(); // Eat the comma.
347 bool ELFAsmParser::ParseDirectivePushSection(StringRef s, SMLoc loc) {
348 getStreamer().PushSection();
350 if (ParseSectionArguments(/*IsPush=*/true, loc)) {
351 getStreamer().PopSection();
358 bool ELFAsmParser::ParseDirectivePopSection(StringRef, SMLoc) {
359 if (!getStreamer().PopSection())
360 return TokError(".popsection without corresponding .pushsection");
364 // FIXME: This is a work in progress.
365 bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc loc) {
366 return ParseSectionArguments(/*IsPush=*/false, loc);
369 bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
370 StringRef SectionName;
372 if (ParseSectionName(SectionName))
373 return TokError("expected identifier in directive");
379 const MCExpr *Subsection = nullptr;
380 bool UseLastGroup = false;
382 int64_t UniqueID = ~0;
384 // Set the defaults first.
385 if (SectionName == ".fini" || SectionName == ".init" ||
386 SectionName == ".rodata")
387 Flags |= ELF::SHF_ALLOC;
388 if (SectionName == ".fini" || SectionName == ".init")
389 Flags |= ELF::SHF_EXECINSTR;
391 if (getLexer().is(AsmToken::Comma)) {
394 if (IsPush && getLexer().isNot(AsmToken::String)) {
395 if (getParser().parseExpression(Subsection))
397 if (getLexer().isNot(AsmToken::Comma))
404 if (getLexer().isNot(AsmToken::String)) {
405 if (!getContext().getAsmInfo()->usesSunStyleELFSectionSwitchSyntax()
406 || getLexer().isNot(AsmToken::Hash))
407 return TokError("expected string in directive");
408 extraFlags = parseSunStyleSectionFlags();
410 StringRef FlagsStr = getTok().getStringContents();
412 extraFlags = parseSectionFlags(FlagsStr, &UseLastGroup);
415 if (extraFlags == -1U)
416 return TokError("unknown flag");
419 bool Mergeable = Flags & ELF::SHF_MERGE;
420 bool Group = Flags & ELF::SHF_GROUP;
421 if (Group && UseLastGroup)
422 return TokError("Section cannot specifiy a group name while also acting "
423 "as a member of the last group");
425 if (getLexer().isNot(AsmToken::Comma)) {
427 return TokError("Mergeable section must specify the type");
429 return TokError("Group section must specify the type");
432 if (getLexer().is(AsmToken::At) || getLexer().is(AsmToken::Percent) ||
433 getLexer().is(AsmToken::String)) {
434 if (!getLexer().is(AsmToken::String))
437 return TokError("expected '@<type>', '%<type>' or \"<type>\"");
439 if (getParser().parseIdentifier(TypeName))
440 return TokError("expected identifier in directive");
443 if (getLexer().isNot(AsmToken::Comma))
444 return TokError("expected the entry size");
446 if (getParser().parseAbsoluteExpression(Size))
449 return TokError("entry size must be positive");
453 if (getLexer().isNot(AsmToken::Comma))
454 return TokError("expected group name");
456 if (getParser().parseIdentifier(GroupName))
458 if (getLexer().is(AsmToken::Comma)) {
461 if (getParser().parseIdentifier(Linkage))
463 if (Linkage != "comdat")
464 return TokError("Linkage must be 'comdat'");
467 if (getLexer().is(AsmToken::Comma)) {
469 if (getParser().parseIdentifier(UniqueStr))
470 return TokError("expected identifier in directive");
471 if (UniqueStr != "unique")
472 return TokError("expected 'unique'");
473 if (getLexer().isNot(AsmToken::Comma))
474 return TokError("expected commma");
476 if (getParser().parseAbsoluteExpression(UniqueID))
479 return TokError("unique id must be positive");
480 if (!isUInt<32>(UniqueID) || UniqueID == ~0U)
481 return TokError("unique id is too large");
487 if (getLexer().isNot(AsmToken::EndOfStatement))
488 return TokError("unexpected token in directive");
490 unsigned Type = ELF::SHT_PROGBITS;
492 if (TypeName.empty()) {
493 if (SectionName.startswith(".note"))
494 Type = ELF::SHT_NOTE;
495 else if (SectionName == ".init_array")
496 Type = ELF::SHT_INIT_ARRAY;
497 else if (SectionName == ".fini_array")
498 Type = ELF::SHT_FINI_ARRAY;
499 else if (SectionName == ".preinit_array")
500 Type = ELF::SHT_PREINIT_ARRAY;
502 if (TypeName == "init_array")
503 Type = ELF::SHT_INIT_ARRAY;
504 else if (TypeName == "fini_array")
505 Type = ELF::SHT_FINI_ARRAY;
506 else if (TypeName == "preinit_array")
507 Type = ELF::SHT_PREINIT_ARRAY;
508 else if (TypeName == "nobits")
509 Type = ELF::SHT_NOBITS;
510 else if (TypeName == "progbits")
511 Type = ELF::SHT_PROGBITS;
512 else if (TypeName == "note")
513 Type = ELF::SHT_NOTE;
514 else if (TypeName == "unwind")
515 Type = ELF::SHT_X86_64_UNWIND;
517 return TokError("unknown section type");
521 MCSectionSubPair CurrentSection = getStreamer().getCurrentSection();
522 if (const MCSectionELF *Section =
523 cast_or_null<MCSectionELF>(CurrentSection.first))
524 if (const MCSymbol *Group = Section->getGroup()) {
525 GroupName = Group->getName();
526 Flags |= ELF::SHF_GROUP;
530 MCSection *ELFSection = getContext().getELFSection(SectionName, Type, Flags,
531 Size, GroupName, UniqueID);
532 getStreamer().SwitchSection(ELFSection, Subsection);
534 if (getContext().getGenDwarfForAssembly()) {
535 bool InsertResult = getContext().addGenDwarfSection(ELFSection);
537 if (getContext().getDwarfVersion() <= 2)
538 Warning(loc, "DWARF2 only supports one section per compilation unit");
540 if (!ELFSection->getBeginSymbol()) {
541 MCSymbol *SectionStartSymbol = getContext().createTempSymbol();
542 getStreamer().EmitLabel(SectionStartSymbol);
543 ELFSection->setBeginSymbol(SectionStartSymbol);
551 bool ELFAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) {
552 MCSectionSubPair PreviousSection = getStreamer().getPreviousSection();
553 if (PreviousSection.first == nullptr)
554 return TokError(".previous without corresponding .section");
555 getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second);
560 static MCSymbolAttr MCAttrForString(StringRef Type) {
561 return StringSwitch<MCSymbolAttr>(Type)
562 .Cases("STT_FUNC", "function", MCSA_ELF_TypeFunction)
563 .Cases("STT_OBJECT", "object", MCSA_ELF_TypeObject)
564 .Cases("STT_TLS", "tls_object", MCSA_ELF_TypeTLS)
565 .Cases("STT_COMMON", "common", MCSA_ELF_TypeCommon)
566 .Cases("STT_NOTYPE", "notype", MCSA_ELF_TypeNoType)
567 .Cases("STT_GNU_IFUNC", "gnu_indirect_function",
568 MCSA_ELF_TypeIndFunction)
569 .Case("gnu_unique_object", MCSA_ELF_TypeGnuUniqueObject)
570 .Default(MCSA_Invalid);
573 /// ParseDirectiveELFType
574 /// ::= .type identifier , STT_<TYPE_IN_UPPER_CASE>
575 /// ::= .type identifier , #attribute
576 /// ::= .type identifier , @attribute
577 /// ::= .type identifier , %attribute
578 /// ::= .type identifier , "attribute"
579 bool ELFAsmParser::ParseDirectiveType(StringRef, SMLoc) {
581 if (getParser().parseIdentifier(Name))
582 return TokError("expected identifier in directive");
584 // Handle the identifier as the key symbol.
585 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
587 // NOTE the comma is optional in all cases. It is only documented as being
588 // optional in the first case, however, GAS will silently treat the comma as
589 // optional in all cases. Furthermore, although the documentation states that
590 // the first form only accepts STT_<TYPE_IN_UPPER_CASE>, in reality, GAS
591 // accepts both the upper case name as well as the lower case aliases.
592 if (getLexer().is(AsmToken::Comma))
595 if (getLexer().isNot(AsmToken::Identifier) &&
596 getLexer().isNot(AsmToken::Hash) && getLexer().isNot(AsmToken::At) &&
597 getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::String))
598 return TokError("expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', "
599 "'%<type>' or \"<type>\"");
601 if (getLexer().isNot(AsmToken::String) &&
602 getLexer().isNot(AsmToken::Identifier))
605 SMLoc TypeLoc = getLexer().getLoc();
608 if (getParser().parseIdentifier(Type))
609 return TokError("expected symbol type in directive");
611 MCSymbolAttr Attr = MCAttrForString(Type);
612 if (Attr == MCSA_Invalid)
613 return Error(TypeLoc, "unsupported attribute in '.type' directive");
615 if (getLexer().isNot(AsmToken::EndOfStatement))
616 return TokError("unexpected token in '.type' directive");
619 getStreamer().EmitSymbolAttribute(Sym, Attr);
624 /// ParseDirectiveIdent
625 /// ::= .ident string
626 bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
627 if (getLexer().isNot(AsmToken::String))
628 return TokError("unexpected token in '.ident' directive");
630 StringRef Data = getTok().getIdentifier();
634 getStreamer().EmitIdent(Data);
638 /// ParseDirectiveSymver
639 /// ::= .symver foo, bar2@zed
640 bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
642 if (getParser().parseIdentifier(Name))
643 return TokError("expected identifier in directive");
645 if (getLexer().isNot(AsmToken::Comma))
646 return TokError("expected a comma");
648 // ARM assembly uses @ for a comment...
649 // except when parsing the second parameter of the .symver directive.
650 // Force the next symbol to allow @ in the identifier, which is
651 // required for this directive and then reset it to its initial state.
652 const bool AllowAtInIdentifier = getLexer().getAllowAtInIdentifier();
653 getLexer().setAllowAtInIdentifier(true);
655 getLexer().setAllowAtInIdentifier(AllowAtInIdentifier);
658 if (getParser().parseIdentifier(AliasName))
659 return TokError("expected identifier in directive");
661 if (AliasName.find('@') == StringRef::npos)
662 return TokError("expected a '@' in the name");
664 MCSymbol *Alias = getContext().getOrCreateSymbol(AliasName);
665 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
666 const MCExpr *Value = MCSymbolRefExpr::create(Sym, getContext());
668 getStreamer().EmitAssignment(Alias, Value);
672 /// ParseDirectiveVersion
673 /// ::= .version string
674 bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
675 if (getLexer().isNot(AsmToken::String))
676 return TokError("unexpected token in '.version' directive");
678 StringRef Data = getTok().getIdentifier();
682 MCSection *Note = getContext().getELFSection(".note", ELF::SHT_NOTE, 0);
684 getStreamer().PushSection();
685 getStreamer().SwitchSection(Note);
686 getStreamer().EmitIntValue(Data.size()+1, 4); // namesz.
687 getStreamer().EmitIntValue(0, 4); // descsz = 0 (no description).
688 getStreamer().EmitIntValue(1, 4); // type = NT_VERSION.
689 getStreamer().EmitBytes(Data); // name.
690 getStreamer().EmitIntValue(0, 1); // terminate the string.
691 getStreamer().EmitValueToAlignment(4); // ensure 4 byte alignment.
692 getStreamer().PopSection();
696 /// ParseDirectiveWeakref
697 /// ::= .weakref foo, bar
698 bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
699 // FIXME: Share code with the other alias building directives.
702 if (getParser().parseIdentifier(AliasName))
703 return TokError("expected identifier in directive");
705 if (getLexer().isNot(AsmToken::Comma))
706 return TokError("expected a comma");
711 if (getParser().parseIdentifier(Name))
712 return TokError("expected identifier in directive");
714 MCSymbol *Alias = getContext().getOrCreateSymbol(AliasName);
716 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
718 getStreamer().EmitWeakReference(Alias, Sym);
722 bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
723 const MCExpr *Subsection = nullptr;
724 if (getLexer().isNot(AsmToken::EndOfStatement)) {
725 if (getParser().parseExpression(Subsection))
729 if (getLexer().isNot(AsmToken::EndOfStatement))
730 return TokError("unexpected token in directive");
732 getStreamer().SubSection(Subsection);
738 MCAsmParserExtension *createELFAsmParser() {
739 return new ELFAsmParser;