]> granicus.if.org Git - llvm/commitdiff
Produce INIT_ARRAY for sections named .init_array.*
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 22 Mar 2017 13:35:41 +0000 (13:35 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 22 Mar 2017 13:35:41 +0000 (13:35 +0000)
These sections are merged together by the linker, so they should have
the same time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298505 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/ELFAsmParser.cpp
test/MC/AsmParser/section_names.s

index 337cf16e86504263a4cae60203ae176795784394..5d24e3b350126277a34013ee9a22c6f5ee293ecf 100644 (file)
@@ -472,6 +472,10 @@ bool ELFAsmParser::maybeParseUniqueID(int64_t &UniqueID) {
   return false;
 }
 
+static bool hasPrefix(StringRef SectionName, StringRef Prefix) {
+  return SectionName.startswith(Prefix) || SectionName == Prefix.drop_back();
+}
+
 bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
   StringRef SectionName;
 
@@ -565,7 +569,7 @@ EndStmt:
   if (TypeName.empty()) {
     if (SectionName.startswith(".note"))
       Type = ELF::SHT_NOTE;
-    else if (SectionName == ".init_array")
+    else if (hasPrefix(SectionName, ".init_array."))
       Type = ELF::SHT_INIT_ARRAY;
     else if (SectionName == ".fini_array")
       Type = ELF::SHT_FINI_ARRAY;
index 3883e15880a58aaa0fe99109faf5e56a8f8120b1..d843e3cc5677b1bc9c8ded5119e4301d7bd35a3e 100644 (file)
@@ -8,6 +8,8 @@
 .byte 1
 .section .init_array
 .byte 1
+.section .init_array.42
+.byte 1
 .section .init_array2
 .byte 1
 .section .init_arrayfoo
@@ -38,6 +40,8 @@
 # CHECK-NEXT:   Type: SHT_PROGBITS
 # CHECK:        Name: .init_array
 # CHECK-NEXT:   Type:  SHT_INIT_ARRAY
+# CHECK:        Name: .init_array.42
+# CHECK-NEXT:   Type:  SHT_INIT_ARRAY
 # CHECK:        Name: .init_array2
 # CHECK-NEXT:   Type: SHT_PROGBITS
 # CHECK:        Name: .init_arrayfoo