You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.5 KiB
101 lines
3.5 KiB
# // a.cpp
|
|
# #include <iostream>
|
|
# #include <vector>
|
|
#
|
|
# template <int Magic> struct TemplatedObject {
|
|
# static std::vector<TemplatedObject<Magic> *> Instances;
|
|
# TemplatedObject() { Instances.push_back(this); }
|
|
# };
|
|
#
|
|
# using Object = TemplatedObject<0>;
|
|
# template <> std::vector<Object *> Object::Instances{};
|
|
# Object idle{};
|
|
#
|
|
# int main() {
|
|
# if (Object::Instances.size() == 0)
|
|
# std::cout << "It's broken" << std::endl;
|
|
# else
|
|
# std::cout << "It works!" << std::endl;
|
|
# return 0;
|
|
# }
|
|
# // using `clang-cl /c a.cpp | lld-link a.obj` works
|
|
# // using `cl /c a.cpp | lld-link a.obj` fails without lld/COFF/Writer.cpp/Writer::sortSectionChunks()
|
|
|
|
# RUN: yaml2obj %s -o %t.obj
|
|
# RUN: yaml2obj %S/Inputs/crt-dyn-initializer-order_1.yaml -o %t1.obj
|
|
# RUN: yaml2obj %S/Inputs/crt-dyn-initializer-order_2.yaml -o %t2.obj
|
|
|
|
# CHECK: Name: .CRT
|
|
# CHECK: Characteristics [
|
|
# CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
|
|
# CHECK-NEXT: IMAGE_SCN_MEM_READ
|
|
# CHECK-NEXT: ]
|
|
# CHECK-NEXT: SectionData (
|
|
|
|
# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t.obj %t1.obj %t2.obj
|
|
# RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE1
|
|
# CASE1-NEXT: 01020304 55701011 1205
|
|
|
|
# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t.obj %t2.obj %t1.obj
|
|
# RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE2
|
|
# CASE2-NEXT: 01020304 10111255 7005
|
|
|
|
# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t1.obj %t2.obj %t.obj
|
|
# RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE3
|
|
# CASE3-NEXT: 01557010 11120203 0405
|
|
|
|
# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t1.obj %t.obj %t2.obj
|
|
# RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE4
|
|
# CASE4-NEXT: 01557002 03041011 1205
|
|
|
|
# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t2.obj %t1.obj %t.obj
|
|
# RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE5
|
|
# CASE5-NEXT: 01101112 55700203 0405
|
|
|
|
# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t2.obj %t.obj %t1.obj
|
|
# RUN: llvm-readobj --sections --section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE6
|
|
# CASE6-NEXT: 01101112 02030455 7005
|
|
|
|
# CHECK-NEXT: )
|
|
|
|
--- !COFF
|
|
header:
|
|
Machine: IMAGE_FILE_MACHINE_AMD64
|
|
Characteristics: [ ]
|
|
sections:
|
|
- Name: '.CRT$XCA'
|
|
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
|
|
Alignment: 1
|
|
SectionData: 01
|
|
- Name: '.CRT$XCU'
|
|
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
|
|
Alignment: 1
|
|
SectionData: 02
|
|
- Name: '.CRT$XCU'
|
|
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_LNK_COMDAT ]
|
|
Alignment: 1
|
|
SectionData: 03
|
|
- Name: '.CRT$XCU'
|
|
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
|
|
Alignment: 1
|
|
SectionData: 04
|
|
- Name: '.CRT$XCZ'
|
|
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
|
|
Alignment: 1
|
|
SectionData: 05
|
|
symbols:
|
|
- Name: '.CRT$XCU'
|
|
Value: 0
|
|
SectionNumber: 3
|
|
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
ComplexType: IMAGE_SYM_DTYPE_NULL
|
|
StorageClass: IMAGE_SYM_CLASS_STATIC
|
|
SectionDefinition:
|
|
Length: 1
|
|
NumberOfRelocations: 0
|
|
NumberOfLinenumbers: 0
|
|
CheckSum: 1
|
|
Number: 2
|
|
Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE
|
|
...
|