[ELF] Handle .init_array prefix consistently
authorNikita Popov <npopov@redhat.com>
Mon, 3 Jan 2022 10:21:05 +0000 (11:21 +0100)
committerNikita Popov <npopov@redhat.com>
Tue, 4 Jan 2022 08:42:58 +0000 (09:42 +0100)
commit4ef560ec6026a2cef71748852c68cd4a79c0ac0a
tree705ab4d7cac8971ec527319ec388f148b18904cb
parentbbeaf2aac678633749e7385466da10a1c0120b3b
[ELF] Handle .init_array prefix consistently

Currently, the code in TargetLoweringObjectFile only assigns
@init_array section type to plain .init_array sections, but not
prioritized sections like .init_array.00001.

This is inconsistent with the interpretation in the AsmParser
(see https://github.com/llvm/llvm-project/blob/791523bae6153b13bb41ba05c9fc89e502cc4a1a/llvm/lib/MC/MCParser/ELFAsmParser.cpp#L621-L632)
and upcoming expectations in LLD
(see https://github.com/rust-lang/rust/issues/92181 for context).

This patch assigns @init_array section type to all sections with an
.init_array prefix. The same is done for .fini_array and
.preinit_array as well. With that, the logic matches the AsmParser.

Differential Revision: https://reviews.llvm.org/D116528
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/X86/attribute-sections.ll