[llvm-commits] [llvm] r118893 - in /llvm/trunk: lib/MC/MCParser/ELFAsmParser.cpp test/MC/ELF/section.s test/MC/ELF/type.s

Rafael Espindola rafael.espindola at gmail.com
Fri Nov 12 07:47:08 PST 2010


Author: rafael
Date: Fri Nov 12 09:47:08 2010
New Revision: 118893

URL: http://llvm.org/viewvc/llvm-project?rev=118893&view=rev
Log:
gnu as support both % and @ before types, do the same.

Added:
    llvm/trunk/test/MC/ELF/type.s
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=118893&r1=118892&r2=118893&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Fri Nov 12 09:47:08 2010
@@ -213,12 +213,6 @@
     FlagsStr = getTok().getStringContents();
     Lex();
 
-    AsmToken::TokenKind TypeStartToken;
-    if (getContext().getAsmInfo().getCommentString()[0] == '@')
-      TypeStartToken = AsmToken::Percent;
-    else
-      TypeStartToken = AsmToken::At;
-
     bool Mergeable = FlagsStr.find('M') != StringRef::npos;
     bool Group = FlagsStr.find('G') != StringRef::npos;
 
@@ -229,8 +223,8 @@
         return TokError("Group section must specify the type");
     } else {
       Lex();
-      if (getLexer().isNot(TypeStartToken))
-        return TokError("expected the type");
+      if (getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::At))
+        return TokError("expected '@' or '%' before type");
 
       Lex();
       if (getParser().ParseIdentifier(TypeName))
@@ -359,8 +353,8 @@
     return TokError("unexpected token in '.type' directive");
   Lex();
 
-  if (getLexer().isNot(AsmToken::At))
-    return TokError("expected '@' before type");
+  if (getLexer().isNot(AsmToken::Percent) && getLexer().isNot(AsmToken::At))
+    return TokError("expected '@' or '%' before type");
   Lex();
 
   StringRef Type;

Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=118893&r1=118892&r2=118893&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Fri Nov 12 09:47:08 2010
@@ -3,12 +3,14 @@
 // Test that these names are accepted.
 
 .section	.note.GNU-stack,"", at progbits
+.section	.note.GNU-stack2,"",%progbits
 .section	.note.GNU-,"", at progbits
 .section	-.note.GNU,"", at progbits
 
 // CHECK: ('sh_name', 0x00000012) # '.note.GNU-stack'
-// CHECK: ('sh_name', 0x00000022) # '.note.GNU-'
-// CHECK: ('sh_name', 0x0000002d) # '-.note.GNU'
+// CHECK: ('sh_name', 0x00000022) # '.note.GNU-stack2'
+// CHECK: ('sh_name', 0x00000033) # '.note.GNU-'
+// CHECK: ('sh_name', 0x0000003e) # '-.note.GNU'
 
 // Test that the dafults are used
 
@@ -16,7 +18,7 @@
 .section	.fini
 .section	.rodata
 
-// CHECK:      (('sh_name', 0x00000038) # '.init'
+// CHECK:      (('sh_name', 0x00000049) # '.init'
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_flags', 0x00000006)
 // CHECK-NEXT:  ('sh_addr', 0x00000000)
@@ -27,8 +29,8 @@
 // CHECK-NEXT:  ('sh_addralign', 0x00000001)
 // CHECK-NEXT:  ('sh_entsize', 0x00000000)
 // CHECK-NEXT: ),
-// CHECK-NEXT: # Section 0x0000000a
-// CHECK-NEXT: (('sh_name', 0x0000003e) # '.fini'
+// CHECK-NEXT: # Section 0x0000000b
+// CHECK-NEXT: (('sh_name', 0x0000004f) # '.fini'
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_flags', 0x00000006)
 // CHECK-NEXT:  ('sh_addr', 0x00000000)
@@ -39,8 +41,8 @@
 // CHECK-NEXT:  ('sh_addralign', 0x00000001)
 // CHECK-NEXT:  ('sh_entsize', 0x00000000)
 // CHECK-NEXT: ),
-// CHECK-NEXT: # Section 0x0000000b
-// CHECK-NEXT: (('sh_name', 0x00000044) # '.rodata'
+// CHECK-NEXT: # Section 0x0000000c
+// CHECK-NEXT: (('sh_name', 0x00000055) # '.rodata'
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_flags', 0x00000002)
 // CHECK-NEXT:  ('sh_addr', 0x00000000)

Added: llvm/trunk/test/MC/ELF/type.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/type.s?rev=118893&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/type.s (added)
+++ llvm/trunk/test/MC/ELF/type.s Fri Nov 12 09:47:08 2010
@@ -0,0 +1,29 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump  | FileCheck %s
+
+// Test that both % and @ are accepted.
+        .global foo
+        .type foo,%function
+foo:
+
+        .global bar
+        .type bar, at object
+bar:
+
+// CHECK:      # Symbol 0x00000004
+// CHECK-NEXT: (('st_name', 0x00000005) # 'bar'
+// CHECK-NEXT:  ('st_bind', 0x00000001)
+// CHECK-NEXT:  ('st_type', 0x00000001)
+// CHECK-NEXT:  ('st_other', 0x00000000)
+// CHECK-NEXT:  ('st_shndx', 0x00000001)
+// CHECK-NEXT:  ('st_value', 0x00000000)
+// CHECK-NEXT:  ('st_size', 0x00000000)
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Symbol 0x00000005
+// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
+// CHECK-NEXT:  ('st_bind', 0x00000001)
+// CHECK-NEXT:  ('st_type', 0x00000002)
+// CHECK-NEXT:  ('st_other', 0x00000000)
+// CHECK-NEXT:  ('st_shndx', 0x00000001)
+// CHECK-NEXT:  ('st_value', 0x00000000)
+// CHECK-NEXT:  ('st_size', 0x00000000)
+// CHECK-NEXT: ),





More information about the llvm-commits mailing list