Files
clang-p2996/llvm/test/CodeGen/X86/attribute-sections.ll
Nikita Popov 4ef560ec60 [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 791523bae6/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
2022-01-04 09:42:58 +01:00

37 lines
1.4 KiB
LLVM

; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s
declare i32 @foo()
@init_array1 = global i32 ()* @foo, section ".init_array"
@init_array2 = global i32 ()* @foo, section ".init_array.00001"
@init_array3 = global i32 ()* @foo, section ".init_arrayfoo"
; CHECK-LABEL: .section .init_array,"aw",@init_array
; CHECK: init_array1:
; CHECK-LABEL: .section .init_array.00001,"aw",@init_array
; CHECK: init_array2:
; CHECK-LABEL: .section .init_arrayfoo,"aw",@progbits
; CHECK: init_array3:
@fini_array1 = global i32 ()* @foo, section ".fini_array"
@fini_array2 = global i32 ()* @foo, section ".fini_array.00001"
@fini_array3 = global i32 ()* @foo, section ".fini_arrayfoo"
; CHECK-LABEL: .section .fini_array,"aw",@fini_array
; CHECK: fini_array1:
; CHECK-LABEL: .section .fini_array.00001,"aw",@fini_array
; CHECK: fini_array2:
; CHECK-LABEL: .section .fini_arrayfoo,"aw",@progbits
; CHECK: fini_array3:
@preinit_array1 = global i32 ()* @foo, section ".preinit_array"
@preinit_array2 = global i32 ()* @foo, section ".preinit_array.00001"
@preinit_array3 = global i32 ()* @foo, section ".preinit_arrayfoo"
; CHECK-LABEL: .section .preinit_array,"aw",@preinit_array
; CHECK: preinit_array1:
; CHECK-LABEL: .section .preinit_array.00001,"aw",@preinit_array
; CHECK: preinit_array2:
; CHECK-LABEL: .section .preinit_arrayfoo,"aw",@progbits
; CHECK: preinit_array3: