aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCParser/ELFAsmParser.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-10-28 21:33:33 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-10-28 21:33:33 +0000
commitf4b0f3e616272556e8a94d86edd2e4e597183cd6 (patch)
tree06ee32eba0ca2f389ebba461a2fc88d3cfdaafee /lib/MC/MCParser/ELFAsmParser.cpp
parent94074a5e4dc8c8a4338a08a93f9d2d03e1bf0b00 (diff)
Improvements to .section parsing:
* If we have a M or a G, reject sections without the type * Only parse the flag specific arguments if we have M or G * Parse the corresponding arguments for M and G We ignore the G arguments and flag for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r--lib/MC/MCParser/ELFAsmParser.cpp48
1 files changed, 38 insertions, 10 deletions
diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp
index 83c562bf4a..62cf6c6e7a 100644
--- a/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/lib/MC/MCParser/ELFAsmParser.cpp
@@ -198,7 +198,7 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
if (ParseSectionName(SectionName))
return TokError("expected identifier in directive");
- std::string FlagsStr;
+ StringRef FlagsStr;
StringRef TypeName;
int64_t Size = 0;
if (getLexer().is(AsmToken::Comma)) {
@@ -216,21 +216,47 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
else
TypeStartToken = AsmToken::At;
- if (getLexer().is(AsmToken::Comma)) {
+ bool Mergeable = FlagsStr.find('M') != StringRef::npos;
+ bool Group = FlagsStr.find('G') != StringRef::npos;
+
+ if (getLexer().isNot(AsmToken::Comma)) {
+ if (Mergeable)
+ return TokError("Mergeable section must specify the type");
+ if (Group)
+ return TokError("Group section must specify the type");
+ } else {
+ Lex();
+ if (getLexer().isNot(TypeStartToken))
+ return TokError("expected the type");
+
Lex();
- if (getLexer().is(TypeStartToken)) {
+ if (getParser().ParseIdentifier(TypeName))
+ return TokError("expected identifier in directive");
+
+ if (Mergeable) {
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("expected the entry size");
Lex();
- if (getParser().ParseIdentifier(TypeName))
- return TokError("expected identifier in directive");
+ if (getParser().ParseAbsoluteExpression(Size))
+ return true;
+ if (Size <= 0)
+ return TokError("entry size must be positive");
+ }
+ if (Group) {
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("expected group name");
+ Lex();
+ StringRef GroupName;
+ if (getParser().ParseIdentifier(GroupName))
+ return true;
if (getLexer().is(AsmToken::Comma)) {
Lex();
-
- if (getParser().ParseAbsoluteExpression(Size))
+ StringRef Linkage;
+ if (getParser().ParseIdentifier(Linkage))
return true;
-
- if (Size <= 0)
- return TokError("section size must be positive");
+ if (Linkage != "comdat" && Linkage != ".gnu.linkonce")
+ return TokError("Linkage must be 'comdat' or '.gnu.linkonce'");
}
}
}
@@ -275,6 +301,8 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
case 'd':
Flags |= MCSectionELF::XCORE_SHF_DP_SECTION;
break;
+ case 'G':
+ break;
default:
return TokError("unknown flag");
}