5 # template <int Magic> struct TemplatedObject {
6 # static std::vector<TemplatedObject<Magic> *> Instances;
7 # TemplatedObject() { Instances.push_back(this); }
10 # using Object = TemplatedObject<0>;
11 # template <> std::vector<Object *> Object::Instances{};
15 # if (Object::Instances.size() == 0)
16 # std::cout << "It's broken" << std::endl;
18 # std::cout << "It works!" << std::endl;
21 # // using `clang-cl /c a.cpp | lld-link a.obj` works
22 # // using `cl /c a.cpp | lld-link a.obj` fails without lld/COFF/Writer.cpp/Writer::sortSectionChunks()
24 # RUN: yaml2obj %s -o %t.obj
25 # RUN: yaml2obj %S/Inputs/crt-dyn-initializer-order_1.yaml -o %t1.obj
26 # RUN: yaml2obj %S/Inputs/crt-dyn-initializer-order_2.yaml -o %t2.obj
29 # CHECK: Characteristics [
30 # CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
31 # CHECK-NEXT: IMAGE_SCN_MEM_READ
33 # CHECK-NEXT: SectionData (
35 # RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t.obj %t1.obj %t2.obj
36 # RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE1
37 # CASE1-NEXT: 01020304 55701011 1205
39 # RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t.obj %t2.obj %t1.obj
40 # RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE2
41 # CASE2-NEXT: 01020304 10111255 7005
43 # RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t1.obj %t2.obj %t.obj
44 # RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE3
45 # CASE3-NEXT: 01557010 11120203 0405
47 # RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t1.obj %t.obj %t2.obj
48 # RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE4
49 # CASE4-NEXT: 01557002 03041011 1205
51 # RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t2.obj %t1.obj %t.obj
52 # RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE5
53 # CASE5-NEXT: 01101112 55700203 0405
55 # RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t2.obj %t.obj %t1.obj
56 # RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE6
57 # CASE6-NEXT: 01101112 02030455 7005
63 Machine: IMAGE_FILE_MACHINE_AMD64
67 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
71 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
75 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_LNK_COMDAT ]
79 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
83 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
90 SimpleType: IMAGE_SYM_TYPE_NULL
91 ComplexType: IMAGE_SYM_DTYPE_NULL
92 StorageClass: IMAGE_SYM_CLASS_STATIC
95 NumberOfRelocations: 0
96 NumberOfLinenumbers: 0
99 Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE