Set default flags for .rodata.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 8 Nov 2010 02:47:59 +0000 (02:47 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 8 Nov 2010 02:47:59 +0000 (02:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118395 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 9883018dd1525eaf3daf9a0d251c549a90296825..d6c4e451259b62f945cc8872d8a3bb583a329ec2 100644 (file)
@@ -271,9 +271,11 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
   unsigned Type = MCSectionELF::SHT_NULL;
 
   // Set the defaults first.
-  if (SectionName == ".fini" || SectionName == ".init") {
+  if (SectionName == ".fini" || SectionName == ".init" || SectionName == ".rodata") {
     Type = MCSectionELF::SHT_PROGBITS;
     Flags |= MCSectionELF::SHF_ALLOC;
+  }
+  if (SectionName == ".fini" || SectionName == ".init") {
     Flags |= MCSectionELF::SHF_EXECINSTR;
   }
 
index 9c7288036dfaf6c97cd97c290843ab408329ff6e..74fd38eaf880f40abf6ca36dd90996cf5a6be3c8 100644 (file)
 // CHECK: ('sh_name', 0x00000022) # '.note.GNU-'
 // CHECK: ('sh_name', 0x0000002d) # '-.note.GNU'
 
-// Test that the dafults for init and fini are used
+// Test that the dafults are used
 
 .section       .init
 .section       .fini
+.section       .rodata
 
 // CHECK:      (('sh_name', 0x00000038) # '.init'
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_info', 0x00000000)
 // CHECK-NEXT:  ('sh_addralign', 0x00000001)
 // CHECK-NEXT:  ('sh_entsize', 0x00000000)
-
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Section 0x00000009
+// CHECK-NEXT: (('sh_name', 0x00000044) # '.rodata'
+// CHECK-NEXT:  ('sh_type', 0x00000001)
+// CHECK-NEXT:  ('sh_flags', 0x00000002)
+// CHECK-NEXT:  ('sh_addr', 0x00000000)
+// CHECK-NEXT:  ('sh_offset', 0x00000040)
+// 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
 .section        .text.foo,"axG",@progbits,foo,comdat