diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 32 | ||||
-rw-r--r-- | tools/llvm-mc/AsmParser.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index d94b7b3270..b4e0f5792a 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -528,6 +528,8 @@ bool AsmParser::ParseStatement() { return ParseDirectiveDarwinZerofill(); if (!strcmp(IDVal, ".desc")) return ParseDirectiveDarwinSymbolDesc(); + if (!strcmp(IDVal, ".lsym")) + return ParseDirectiveDarwinLsym(); if (!strcmp(IDVal, ".subsections_via_symbols")) return ParseDirectiveDarwinSubsectionsViaSymbols(); @@ -1126,3 +1128,33 @@ bool AsmParser::ParseDirectiveAbort() { return false; } + +/// ParseDirectiveLsym +/// ::= .lsym identifier , expression +bool AsmParser::ParseDirectiveDarwinLsym() { + if (Lexer.isNot(asmtok::Identifier)) + return TokError("expected identifier in directive"); + + // handle the identifier as the key symbol. + SMLoc IDLoc = Lexer.getLoc(); + MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal()); + Lexer.Lex(); + + if (Lexer.isNot(asmtok::Comma)) + return TokError("unexpected token in '.lsym' directive"); + Lexer.Lex(); + + MCValue Expr; + if (ParseRelocatableExpression(Expr)) + return true; + + if (Lexer.isNot(asmtok::EndOfStatement)) + return TokError("unexpected token in '.lsym' directive"); + + Lexer.Lex(); + + // Create the Sym with the value of the Expr + Out.EmitLocalSymbol(Sym, Expr); + + return false; +} diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h index b4f5e2d428..7d756376c5 100644 --- a/tools/llvm-mc/AsmParser.h +++ b/tools/llvm-mc/AsmParser.h @@ -110,6 +110,7 @@ private: /// accepts a single symbol (which should be a label or an external). bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr); bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc" + bool ParseDirectiveDarwinLsym(); // Darwin specific ".lsym" bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm" bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill" |