[llvm-commits] [llvm] r117471 - in /llvm/trunk: lib/MC/MCParser/ELFAsmParser.cpp test/MC/ELF/section.s
Rafael Espindola
rafael.espindola at gmail.com
Wed Oct 27 11:45:20 PDT 2010
Author: rafael
Date: Wed Oct 27 13:45:20 2010
New Revision: 117471
URL: http://llvm.org/viewvc/llvm-project?rev=117471&view=rev
Log:
Set default type and flags for .init and .fini.
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=117471&r1=117470&r2=117471&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Wed Oct 27 13:45:20 2010
@@ -240,6 +240,15 @@
return TokError("unexpected token in directive");
unsigned Flags = 0;
+ unsigned Type = MCSectionELF::SHT_NULL;
+
+ // Set the defaults first.
+ if (SectionName == ".fini" || SectionName == ".init") {
+ Type = MCSectionELF::SHT_PROGBITS;
+ Flags |= MCSectionELF::SHF_ALLOC;
+ Flags |= MCSectionELF::SHF_EXECINSTR;
+ }
+
for (unsigned i = 0; i < FlagsStr.size(); i++) {
switch (FlagsStr[i]) {
case 'a':
@@ -271,7 +280,6 @@
}
}
- unsigned Type = MCSectionELF::SHT_NULL;
if (!TypeName.empty()) {
if (TypeName == "init_array")
Type = MCSectionELF::SHT_INIT_ARRAY;
Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=117471&r1=117470&r2=117471&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Wed Oct 27 13:45:20 2010
@@ -9,3 +9,31 @@
// CHECK: ('sh_name', 0x00000012) # '.note.GNU-stack'
// CHECK: ('sh_name', 0x00000022) # '.note.GNU-'
// CHECK: ('sh_name', 0x0000002d) # '-.note.GNU'
+
+// Test that the dafults for init and fini are used
+
+.section .init
+.section .fini
+
+// CHECK: (('sh_name', 0x00000038) # '.init'
+// CHECK-NEXT: ('sh_type', 0x00000001)
+// CHECK-NEXT: ('sh_flags', 0x00000006)
+// 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: ),
+// CHECK-NEXT: # Section 0x00000008
+// CHECK-NEXT: (('sh_name', 0x0000003e) # '.fini'
+// CHECK-NEXT: ('sh_type', 0x00000001)
+// CHECK-NEXT: ('sh_flags', 0x00000006)
+// 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)
More information about the llvm-commits
mailing list