-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 rust-lang/rust#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
- Loading branch information
Showing
2 changed files
with
36 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s -check-prefix=LINUX | ||
; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s | ||
|
||
declare i32 @foo() | ||
@G0 = global i32 ()* @foo, section ".init_array" | ||
|
||
; LINUX: .section .init_array,"aw" | ||
; LINUX: .globl G0 | ||
@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" | ||
|
||
@G1 = global i32 ()* @foo, section ".fini_array" | ||
; 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: | ||
|
||
; LINUX: .section .fini_array,"aw" | ||
; LINUX: .globl G1 | ||
@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" | ||
|
||
@G2 = global i32 ()* @foo, section ".preinit_array" | ||
; 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: | ||
|
||
; LINUX: .section .preinit_array,"aw" | ||
; LINUX: .globl G2 | ||
@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: |