Handle strings in section names the same way as gas:
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 24 Jan 2011 18:02:54 +0000 (18:02 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 24 Jan 2011 18:02:54 +0000 (18:02 +0000)
* If the name is a single string, we remove the quotes
* If the name starts without a quote, we include any quotes in the name

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124127 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/ELFAsmParser.cpp
test/MC/ELF/section.s

index 39ff906ea7a7c912a79f4f0dc28698488fe9e41c..7b88ea2d1da39949d39bb511562c6d16562fcdbd 100644 (file)
@@ -168,6 +168,12 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
   SMLoc FirstLoc = getLexer().getLoc();
   unsigned Size = 0;
 
+  if (getLexer().is(AsmToken::String)) {
+    SectionName = getTok().getIdentifier();
+    Lex();
+    return false;
+  }
+
   for (;;) {
     StringRef Tmp;
     unsigned CurSize;
@@ -176,10 +182,15 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
     if (getLexer().is(AsmToken::Minus)) {
       CurSize = 1;
       Lex(); // Consume the "-".
-    } else if (!getParser().ParseIdentifier(Tmp))
-      CurSize = Tmp.size();
-    else
+    } else if (getLexer().is(AsmToken::String)) {
+      CurSize = getTok().getIdentifier().size() + 2;
+      Lex();
+    } else if (getLexer().is(AsmToken::Identifier)) {
+      CurSize = getTok().getIdentifier().size();
+      Lex();
+    } else {
       break;
+    }
 
     Size += CurSize;
     SectionName = StringRef(FirstLoc.getPointer(), Size);
index 427f125f1eb0db70df76c8848a59a5aa21639134..861dc4f057fe46e572a2b4833bb2bfea47b9eeeb 100644 (file)
@@ -101,3 +101,10 @@ bar:
 // CHECK-NEXT:   ('sh_addralign', 0x00000001)
 // CHECK-NEXT:   ('sh_entsize', 0x00000000)
 // CHECK-NEXT:  ),
+
+// Test that we handle the strings like gas
+.section bar-"foo"
+.section "foo"
+
+// CHECK: ('sh_name', 0x0000008a) # 'bar-"foo"'
+// CHECK: ('sh_name', 0x00000094) # 'foo'