From: Rafael Espindola Date: Wed, 22 Mar 2017 13:35:41 +0000 (+0000) Subject: Produce INIT_ARRAY for sections named .init_array.* X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=354d23526f503ee627c16cca4b8b670c7bfedffb;p=llvm Produce INIT_ARRAY for sections named .init_array.* 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 --- diff --git a/lib/MC/MCParser/ELFAsmParser.cpp b/lib/MC/MCParser/ELFAsmParser.cpp index 337cf16e865..5d24e3b3501 100644 --- a/lib/MC/MCParser/ELFAsmParser.cpp +++ b/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/test/MC/AsmParser/section_names.s b/test/MC/AsmParser/section_names.s index 3883e15880a..d843e3cc567 100644 --- a/test/MC/AsmParser/section_names.s +++ b/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