diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-12 14:30:47 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-12 14:30:47 +0000 |
commit | 6a80f9da8c2cb2cbf931ec8cf2a72b5f288c1bc6 (patch) | |
tree | 19280e379e52c162a7d86053590e04d7f05a799c /lib/MC | |
parent | bc3b27ccd964df7627ecff4a62715ff72f1c4a7f (diff) | |
download | external_llvm-6a80f9da8c2cb2cbf931ec8cf2a72b5f288c1bc6.zip external_llvm-6a80f9da8c2cb2cbf931ec8cf2a72b5f288c1bc6.tar.gz external_llvm-6a80f9da8c2cb2cbf931ec8cf2a72b5f288c1bc6.tar.bz2 |
ELF: Add support for the asm .version directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156712 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCParser/ELFAsmParser.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index ffc400b..9316bb1 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/lib/MC/MCParser/ELFAsmParser.cpp @@ -64,6 +64,7 @@ public: AddDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type"); AddDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident"); AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver"); + AddDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion>(".version"); AddDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref"); AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak"); AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local"); @@ -141,6 +142,7 @@ public: bool ParseDirectiveType(StringRef, SMLoc); bool ParseDirectiveIdent(StringRef, SMLoc); bool ParseDirectiveSymver(StringRef, SMLoc); + bool ParseDirectiveVersion(StringRef, SMLoc); bool ParseDirectiveWeakref(StringRef, SMLoc); bool ParseDirectiveSymbolAttribute(StringRef, SMLoc); @@ -548,6 +550,32 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) { return false; } +/// ParseDirectiveVersion +/// ::= .version string +bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) { + if (getLexer().isNot(AsmToken::String)) + return TokError("unexpected token in '.version' directive"); + + StringRef Data = getTok().getIdentifier(); + + Lex(); + + const MCSection *Note = + getContext().getELFSection(".note", ELF::SHT_NOTE, 0, + SectionKind::getReadOnly()); + + getStreamer().PushSection(); + getStreamer().SwitchSection(Note); + getStreamer().EmitIntValue(Data.size()+1, 4); // namesz. + getStreamer().EmitIntValue(0, 4); // descsz = 0 (no description). + getStreamer().EmitIntValue(1, 4); // type = NT_VERSION. + getStreamer().EmitBytes(Data, 0); // name. + getStreamer().EmitIntValue(0, 1); // terminate the string. + getStreamer().EmitValueToAlignment(4); // ensure 4 byte alignment. + getStreamer().PopSection(); + return false; +} + /// ParseDirectiveWeakref /// ::= .weakref foo, bar bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) { |