[llvm-commits] [llvm] r117608 - in /llvm/trunk: lib/MC/MCParser/ELFAsmParser.cpp test/MC/ELF/section.s
Rafael Espindola
rafael.espindola at gmail.com
Thu Oct 28 14:33:33 PDT 2010
Author: rafael
Date: Thu Oct 28 16:33:33 2010
New Revision: 117608
URL: http://llvm.org/viewvc/llvm-project?rev=117608&view=rev
Log:
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.
Modified:
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
llvm/trunk/test/MC/ELF/section.s
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=117608&r1=117607&r2=117608&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Thu Oct 28 16:33:33 2010
@@ -198,7 +198,7 @@
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 @@
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 @@
case 'd':
Flags |= MCSectionELF::XCORE_SHF_DP_SECTION;
break;
+ case 'G':
+ break;
default:
return TokError("unknown flag");
}
Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=117608&r1=117607&r2=117608&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Thu Oct 28 16:33:33 2010
@@ -37,3 +37,8 @@
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
+
+
+// Test that we can parse these
+.section .text.foo,"axG", at progbits,foo,comdat
+.section .text.bar,"axMG", at progbits,42,bar,.gnu.linkonce
More information about the llvm-commits
mailing list