[PATCH] D103495: [static initializers] Don't put ordered dynamic initializers of static variables into global_ctors
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 7 23:58:05 PDT 2021
MaskRay added a comment.
Thanks for tagging us.
glibc has supported DT_INIT_ARRAY/DT_FINI_ARRAY since 1999. GCC 4.7 defaulted to .init_array/.fini_array on glibc >= 2.4 and most Linux distributions have thus made the switch for many years. Actually, most ELF operating systems have switched to .init_array/.fini_array (FreeBSD added the support in 2012, OpenBSD in 2016, NetBSD in 2018.
.ctors doesn't have aren't many users now, but my users are unfortunately still using .ctors:(
Our tests can pass with .init_array + ld.lld --shuffle-sections=.init_array=-1, so I think we don't have code relying on the buggy .ctors order
(i.e. we don't have problems due to the shuffled dynamic initialization order *within* a TU).
This patch improves the situation for other users and we should do it.
Can you check whether clang/lib/CodeGen/CGDeclCXX.cpp:507 needs any comment update?
The subject "Don't put ordered dynamic initializers of static variables into global_ctors" needs an update as well.
================
Comment at: llvm/test/CodeGen/X86/constructor.ll:61
; INIT-ARRAY-NEXT: .p2align 3
; INIT-ARRAY-NEXT: .quad f
+; INIT-ARRAY-NEXT: .quad i
----------------
Worth a comment that we check f/i/j are in order.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103495/new/
https://reviews.llvm.org/D103495
More information about the llvm-commits
mailing list