summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp6
-rw-r--r--llvm/test/MC/AsmParser/section_names.s4
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 337cf16e865..5d24e3b3501 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -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;
diff --git a/llvm/test/MC/AsmParser/section_names.s b/llvm/test/MC/AsmParser/section_names.s
index 3883e15880a..d843e3cc567 100644
--- a/llvm/test/MC/AsmParser/section_names.s
+++ b/llvm/test/MC/AsmParser/section_names.s
@@ -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
OpenPOWER on IntegriCloud