Add support for @note. Patch by Jörg Sonnenberger.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 26 Dec 2010 21:30:59 +0000 (21:30 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 26 Dec 2010 21:30:59 +0000 (21:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122568 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ef6e0f14141c61d1d9b50570aa4cedf23e2e67d7..5ff12bc01f0b7da9ed1ac664399b262ef9e572bf 100644 (file)
@@ -1265,6 +1265,7 @@ void ELFObjectWriter::WriteSection(MCAssembler &Asm,
   case ELF::SHT_PROGBITS:
   case ELF::SHT_STRTAB:
   case ELF::SHT_NOBITS:
+  case ELF::SHT_NOTE:
   case ELF::SHT_NULL:
   case ELF::SHT_ARM_ATTRIBUTES:
     // Nothing to do.
index 0aa89c20a2f82de9008cce1a32da18d0d957af64..0456b4bac4c33dd0ad27d3bf7ad189594856ff11 100644 (file)
@@ -335,6 +335,8 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
       Type = MCSectionELF::SHT_NOBITS;
     else if (TypeName == "progbits")
       Type = MCSectionELF::SHT_PROGBITS;
+    else if (TypeName == "note")
+      Type = MCSectionELF::SHT_NOTE;
     else
       return TokError("unknown section type");
   }
index 59568adf7085e6d1d1463db7597b59e4aea37e2a..a53489790d28c3143149c4292803fbe30b7b3a4d 100644 (file)
@@ -92,6 +92,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
     OS << "preinit_array";
   else if (Type == MCSectionELF::SHT_NOBITS)
     OS << "nobits";
+  else if (Type == MCSectionELF::SHT_NOTE)
+    OS << "note";
   else if (Type == MCSectionELF::SHT_PROGBITS)
     OS << "progbits";
 
index 38cf8ad4356b580de6cf3972645a95e5e617490d..8e40ae8c04192be6e110f9d10e9e34a98e06259a 100644 (file)
@@ -12,7 +12,7 @@
 // CHECK: ('sh_name', 0x00000033) # '.note.GNU-'
 // CHECK: ('sh_name', 0x0000003e) # '-.note.GNU'
 
-// Test that the dafults are used
+// Test that the defaults are used
 
 .section       .init
 .section       .fini
 // CHECK-NEXT:  ('sh_entsize', 0x00000000)
 // CHECK-NEXT: ),
 
+.section       .note.test,"",@note
+// CHECK:       (('sh_name', 0x00000061) # '.note.test'
+// CHECK-NEXT:   ('sh_type', 0x00000007)
+// CHECK-NEXT:   ('sh_flags', 0x00000000)
+// CHECK-NEXT:   ('sh_addr', 0x00000000)
+// CHECK-NEXT:   ('sh_offset', 0x00000050)
+// CHECK-NEXT:   ('sh_size', 0x00000000)
+// CHECK-NEXT:   ('sh_link', 0x00000000)
+// CHECK-NEXT:   ('sh_info', 0x00000000)
+// CHECK-NEXT:   ('sh_addralign', 0x00000001)
+// CHECK-NEXT:   ('sh_entsize', 0x00000000)
+// CHECK-NEXT:  ),
+
 // Test that we can parse these
 foo:
 bar: