[clang-tidy][use-internal-linkage]fix false positives for global overloaded operator...
[llvm-project.git] / lld / test / COFF / crt-dyn-initializer-order.test
blob1c00da5b9d8aba0769b677d71cdb9c751b79abb1
1 # // a.cpp
2 # #include <iostream>
3 # #include <vector>
5 # template <int Magic> struct TemplatedObject {
6 #   static std::vector<TemplatedObject<Magic> *> Instances;
7 #   TemplatedObject() { Instances.push_back(this); }
8 # };
10 # using Object = TemplatedObject<0>;
11 # template <> std::vector<Object *> Object::Instances{};
12 # Object idle{};
14 # int main() {
15 #   if (Object::Instances.size() == 0)
16 #     std::cout << "It's broken" << std::endl;
17 #   else
18 #     std::cout << "It works!" << std::endl;
19 #   return 0;
20 # }
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
28 # CHECK: Name: .CRT
29 # CHECK: Characteristics [
30 # CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
31 # CHECK-NEXT: IMAGE_SCN_MEM_READ
32 # CHECK-NEXT: ]
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
59 # CHECK-NEXT: )
61 --- !COFF
62 header:
63   Machine:         IMAGE_FILE_MACHINE_AMD64
64   Characteristics: [  ]
65 sections:
66   - Name:            '.CRT$XCA'
67     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
68     Alignment:       1
69     SectionData:     01
70   - Name:            '.CRT$XCU'
71     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
72     Alignment:       1
73     SectionData:     02
74   - Name:            '.CRT$XCU'
75     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_LNK_COMDAT ]
76     Alignment:       1
77     SectionData:     03
78   - Name:            '.CRT$XCU'
79     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
80     Alignment:       1
81     SectionData:     04
82   - Name:            '.CRT$XCZ'
83     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
84     Alignment:       1
85     SectionData:     05
86 symbols:
87   - Name:            '.CRT$XCU'
88     Value:           0
89     SectionNumber:   3
90     SimpleType:      IMAGE_SYM_TYPE_NULL
91     ComplexType:     IMAGE_SYM_DTYPE_NULL
92     StorageClass:    IMAGE_SYM_CLASS_STATIC
93     SectionDefinition:
94       Length:          1
95       NumberOfRelocations: 0
96       NumberOfLinenumbers: 0
97       CheckSum:        1
98       Number:          2
99       Selection:       IMAGE_COMDAT_SELECT_ASSOCIATIVE