[llvm] r264038 - [ELF][gcc compatibility]: support section names with special characters (e.g. "/")

Marina Yatsina via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 04:23:17 PDT 2016


Author: myatsina
Date: Tue Mar 22 06:23:15 2016
New Revision: 264038

URL: http://llvm.org/viewvc/llvm-project?rev=264038&view=rev
Log:
[ELF][gcc compatibility]: support section names with special characters (e.g. "/")

Adding support for section names with special characters in them (e.g. "/").
GCC successfully compiles such section names.
This also fixes PR24520.

Differential Revision: http://reviews.llvm.org/D15678


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=264038&r1=264037&r2=264038&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Tue Mar 22 06:23:15 2016
@@ -229,22 +229,23 @@ bool ELFAsmParser::ParseSectionName(Stri
   }
 
   for (;;) {
-    unsigned CurSize;
-
+    
     SMLoc PrevLoc = getLexer().getLoc();
-    if (getLexer().is(AsmToken::Minus)) {
-      CurSize = 1;
-      Lex(); // Consume the "-".
-    } else if (getLexer().is(AsmToken::String)) {
+    if (getLexer().is(AsmToken::Comma) ||
+      getLexer().is(AsmToken::EndOfStatement))
+      break;
+    
+    unsigned CurSize;
+    if (getLexer().is(AsmToken::String)) {
       CurSize = getTok().getIdentifier().size() + 2;
       Lex();
     } else if (getLexer().is(AsmToken::Identifier)) {
       CurSize = getTok().getIdentifier().size();
       Lex();
     } else {
-      break;
+      CurSize = getTok().getString().size();
+      Lex();
     }
-
     Size += CurSize;
     SectionName = StringRef(FirstLoc.getPointer(), Size);
 

Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=264038&r1=264037&r2=264038&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Tue Mar 22 06:23:15 2016
@@ -6,11 +6,15 @@
 .section	.note.GNU-stack2,"",%progbits
 .section	.note.GNU-,"", at progbits
 .section	-.note.GNU,"","progbits"
+.section	src/stack.c,"", at progbits
+.section	~!@$%^&*()_-+={[}]|\\:<>,"", at progbits
 
 // CHECK: Name: .note.GNU-stack
 // CHECK: Name: .note.GNU-stack2
 // CHECK: Name: .note.GNU-
 // CHECK: Name: -.note.GNU
+// CHECK: Name: src/stack.c
+// CHECK: Name: ~!@$%^&*()_-+={[}]|\\:<>
 
 // Test that the defaults are used
 




More information about the llvm-commits mailing list