This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Handle .init_array prefix consistently
ClosedPublic

Authored by nikic on Jan 3 2022, 2:26 AM.

Details

Summary

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.

Diff Detail

Event Timeline

nikic created this revision.Jan 3 2022, 2:26 AM
nikic requested review of this revision.Jan 3 2022, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2022, 2:26 AM
nikic edited the summary of this revision. (Show Details)Jan 3 2022, 2:31 AM
MaskRay accepted this revision.Jan 3 2022, 1:56 PM

Thanks!

llvm/test/CodeGen/X86/attribute-sections.ll
10

.globl can appear anywhere. The position of label definition is what matters.

This revision is now accepted and ready to land.Jan 3 2022, 1:56 PM
MaskRay added inline comments.Jan 3 2022, 6:15 PM
llvm/test/CodeGen/X86/attribute-sections.ll
9–14

-LABEL is even better. A regression will lead to a better FileCheck. diagnostic.

This revision was landed with ongoing or failed builds.Jan 4 2022, 12:45 AM
This revision was automatically updated to reflect the committed changes.
nikic marked 2 inline comments as done.