diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2010-07-17 03:09:18 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2010-07-17 03:09:18 +0000 |
commit | f82ccf5a0db4df07354f80b8feca454ed90776d5 (patch) | |
tree | 9d1d369444334398f87e859743a665e6d37241da /lib/MC/MCParser/ELFAsmParser.cpp | |
parent | d1e3b44d6c0094eda2e2a854d5fdb6a0d7ba327e (diff) | |
download | external_llvm-f82ccf5a0db4df07354f80b8feca454ed90776d5.zip external_llvm-f82ccf5a0db4df07354f80b8feca454ed90776d5.tar.gz external_llvm-f82ccf5a0db4df07354f80b8feca454ed90776d5.tar.bz2 |
Add support for parsing .size directives for ELF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108606 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r-- | lib/MC/MCParser/ELFAsmParser.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index 7a54dd3..f870318 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -31,6 +31,8 @@ public: &ELFAsmParser::ParseSectionDirectiveData)); Parser.AddDirectiveHandler(this, ".text", MCAsmParser::DirectiveHandler( &ELFAsmParser::ParseSectionDirectiveText)); + Parser.AddDirectiveHandler(this, ".size", MCAsmParser::DirectiveHandler( + &ELFAsmParser::ParseSizeDirective)); } bool ParseSectionDirectiveData(StringRef, SMLoc) { @@ -43,6 +45,7 @@ public: MCSectionELF::SHF_EXECINSTR | MCSectionELF::SHF_ALLOC, SectionKind::getText()); } + bool ParseSizeDirective(StringRef, SMLoc); }; } @@ -59,6 +62,27 @@ bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type, return false; } +bool ELFAsmParser::ParseSizeDirective(StringRef, SMLoc) { + StringRef Name; + if (getParser().ParseIdentifier(Name)) + return TokError("expected identifier in directive"); + MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);; + + if (getLexer().isNot(AsmToken::Comma)) + return TokError("unexpected token in directive"); + Lex(); + + const MCExpr *Expr; + if (getParser().ParseExpression(Expr)) + return true; + + if (getLexer().isNot(AsmToken::EndOfStatement)) + return TokError("unexpected token in directive"); + + getStreamer().EmitELFSize(Sym, Expr); + return false; +} + namespace llvm { MCAsmParserExtension *createELFAsmParser() { |