[COFF] Implement llvm.global_ctors priorities for MSVC COFF targets
authorReid Kleckner <rnk@google.com>
Fri, 7 Sep 2018 23:07:55 +0000 (23:07 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 7 Sep 2018 23:07:55 +0000 (23:07 +0000)
commitf803b23879d9e1d9415ec1875713534dcc203df5
tree7694ed09cc37eb69d3dc59206ef755fe3580633d
parentc30dfb2dfc3dbe707a86c8aaf3b1cae79f3eb838
[COFF] Implement llvm.global_ctors priorities for MSVC COFF targets

Summary:
MSVC and LLD sort sections ASCII-betically, so we need to use section
names that sort between .CRT$XCA (the start) and .CRT$XCU (the default
priority).

In the general case, use .CRT$XCT12345 as the section name, and let the
linker sort the zero-padded digits.

Users with low priorities typically want to initialize as early as
possible, so use .CRT$XCA00199 for prioties less than 200. This number
is arbitrary.

Implements PR38552.

Reviewers: majnemer, mstorsjo

Subscribers: hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D51820

llvm-svn: 341727
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/X86/ctor-priority-coff.ll [new file with mode: 0644]