[llvm] r298505 - Produce INIT_ARRAY for sections named .init_array.*
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 22 06:35:41 PDT 2017
Author: rafael
Date: Wed Mar 22 08:35:41 2017
New Revision: 298505
URL: http://llvm.org/viewvc/llvm-project?rev=298505&view=rev
Log:
Produce INIT_ARRAY for sections named .init_array.*
These sections are merged together by the linker, so they should have
the same time.
Modified:
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
llvm/trunk/test/MC/AsmParser/section_names.s
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=298505&r1=298504&r2=298505&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Wed Mar 22 08:35:41 2017
@@ -472,6 +472,10 @@ bool ELFAsmParser::maybeParseUniqueID(in
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;
Modified: llvm/trunk/test/MC/AsmParser/section_names.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/section_names.s?rev=298505&r1=298504&r2=298505&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/section_names.s (original)
+++ llvm/trunk/test/MC/AsmParser/section_names.s Wed Mar 22 08:35:41 2017
@@ -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
More information about the llvm-commits
mailing list