329 lines · yaml
1## Test all members of 64-bit load config.2# RUN: yaml2obj --docnum=1 %s -o %t3# RUN: llvm-readobj --coff-load-config %t | FileCheck %s --check-prefix=ALL4 5# ALL: Format: COFF-x86-646# ALL-NEXT: Arch: x86_647# ALL-NEXT: AddressSize: 64bit8# ALL-NEXT: LoadConfig [9# ALL-NEXT: Size: 0x15010# ALL-NEXT: TimeDateStamp: 1970-01-01 00:00:01 (0x1)11# ALL-NEXT: MajorVersion: 0x212# ALL-NEXT: MinorVersion: 0x313# ALL-NEXT: GlobalFlagsClear: 0x414# ALL-NEXT: GlobalFlagsSet: 0x515# ALL-NEXT: CriticalSectionDefaultTimeout: 0x616# ALL-NEXT: DeCommitFreeBlockThreshold: 0x717# ALL-NEXT: DeCommitTotalFreeThreshold: 0x818# ALL-NEXT: LockPrefixTable: 0x919# ALL-NEXT: MaximumAllocationSize: 0x10000020# ALL-NEXT: VirtualMemoryThreshold: 0x200000021# ALL-NEXT: ProcessHeapFlags: 0x222# ALL-NEXT: ProcessAffinityMask: 0x123# ALL-NEXT: CSDVersion: 0x324# ALL-NEXT: DependentLoadFlags: 0x425# ALL-NEXT: EditList: 0x526# ALL-NEXT: SecurityCookie: 0x627# ALL-NEXT: SEHandlerTable: 0x028# ALL-NEXT: SEHandlerCount: 029# ALL-NEXT: GuardCFCheckFunction: 0x930# ALL-NEXT: GuardCFCheckDispatch: 0x131# ALL-NEXT: GuardCFFunctionTable: 0x032# ALL-NEXT: GuardCFFunctionCount: 033# ALL-NEXT: GuardFlags [ (0x4)34# ALL-NEXT: ]35# ALL-NEXT: GuardAddressTakenIatEntryTable: 0x036# ALL-NEXT: GuardAddressTakenIatEntryCount: 037# ALL-NEXT: GuardLongJumpTargetTable: 0x038# ALL-NEXT: GuardLongJumpTargetCount: 039# ALL-NEXT: DynamicValueRelocTable: 0x240# ALL-NEXT: CHPEMetadataPointer: 0x041# ALL-NEXT: GuardRFFailureRoutine: 0x442# ALL-NEXT: GuardRFFailureRoutineFunctionPointer: 0x543# ALL-NEXT: DynamicValueRelocTableOffset: 0x444# ALL-NEXT: DynamicValueRelocTableSection: 245# ALL-NEXT: GuardRFVerifyStackPointerFunctionPointer: 0x846# ALL-NEXT: HotPatchTableOffset: 0x947# ALL-NEXT: EnclaveConfigurationPointer: 0x148# ALL-NEXT: VolatileMetadataPointer: 0x249# ALL-NEXT: GuardEHContinuationTable: 0x050# ALL-NEXT: GuardEHContinuationCount: 051# ALL-NEXT: ]52 53--- !COFF54OptionalHeader:55 ImageBase: 0x18000000056 SectionAlignment: 409657 FileAlignment: 51258 DLLCharacteristics: [ ]59 LoadConfigTable:60 RelativeVirtualAddress: 0x100061 Size: 32062header:63 Machine: IMAGE_FILE_MACHINE_AMD6464 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]65sections:66 - Name: .rdata67 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]68 VirtualAddress: 0x100069 VirtualSize: 32070 StructuredData:71 - LoadConfig:72 Size: 0x15073 TimeDateStamp: 174 MajorVersion: 275 MinorVersion: 376 GlobalFlagsClear: 477 GlobalFlagsSet: 578 CriticalSectionDefaultTimeout: 679 DeCommitFreeBlockThreshold: 780 DeCommitTotalFreeThreshold: 881 LockPrefixTable: 982 MaximumAllocationSize: 0x10000083 VirtualMemoryThreshold: 0x200000084 ProcessAffinityMask: 185 ProcessHeapFlags: 286 CSDVersion: 387 DependentLoadFlags: 488 EditList: 589 SecurityCookie: 690 SEHandlerTable: 091 SEHandlerCount: 092 GuardCFCheckFunction: 993 GuardCFCheckDispatch: 194 GuardCFFunctionTable: 095 GuardCFFunctionCount: 096 GuardFlags: 497 CodeIntegrity:98 Flags: 0x10099 Catalog: 5100 CatalogOffset: 6101 GuardAddressTakenIatEntryTable: 0102 GuardAddressTakenIatEntryCount: 0103 GuardLongJumpTargetTable: 0104 GuardLongJumpTargetCount: 0105 DynamicValueRelocTable: 2106 CHPEMetadataPointer: 0107 GuardRFFailureRoutine: 4108 GuardRFFailureRoutineFunctionPointer: 5109 DynamicValueRelocTableOffset: 4110 DynamicValueRelocTableSection: 2111 GuardRFVerifyStackPointerFunctionPointer: 8112 HotPatchTableOffset: 9113 EnclaveConfigurationPointer: 1114 VolatileMetadataPointer: 2115 GuardEHContinuationTable: 0116 GuardEHContinuationCount: 0117 GuardXFGCheckFunctionPointer: 5118 GuardXFGDispatchFunctionPointer: 6119 GuardXFGTableDispatchFunctionPointer: 7120 CastGuardOsDeterminedFailureMode: 8121 - Name: .reloc122 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]123 VirtualAddress: 0x2000124 VirtualSize: 12125 StructuredData:126 - UInt32: 1 # pad127 - UInt32: 2 # Version128 - UInt32: 0 # Size129symbols: []130...131 132## Simple 32-bit load config.133# RUN: yaml2obj --docnum=2 %s -o %t134# RUN: llvm-readobj --coff-load-config %t | FileCheck %s --check-prefix=LOADCFG32135 136# LOADCFG32: LoadConfig [137# LOADCFG32: MaximumAllocationSize: 0x100000138# LOADCFG32: VirtualMemoryThreshold: 0x2000000139# LOADCFG32: CHPEMetadataPointer: 0140 141--- !COFF142OptionalHeader:143 ImageBase: 0x180000000144 SectionAlignment: 4096145 FileAlignment: 512146 DLLCharacteristics: [ ]147 LoadConfigTable:148 RelativeVirtualAddress: 0x1000149 Size: 320150header:151 Machine: IMAGE_FILE_MACHINE_I386152 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]153sections:154 - Name: .rdata155 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]156 VirtualAddress: 0x1000157 VirtualSize: 320158 StructuredData:159 - LoadConfig:160 MaximumAllocationSize: 0x100000161 VirtualMemoryThreshold: 0x2000000162symbols: []163...164 165## Create load config with all fields using default values.166# RUN: yaml2obj --docnum=3 %s -o %t167# RUN: llvm-readobj --coff-load-config %t | FileCheck %s --check-prefix=DEF168 169# DEF: Format: COFF-x86-64170# DEF: Arch: x86_64171# DEF: AddressSize: 64bit172# DEF: LoadConfig [173# DEF: Size: 0x138174# DEF: MajorVersion: 0x0175# DEF: MinorVersion: 0x0176# DEF: GuardEHContinuationCount: 0177# DEF: ]178 179--- !COFF180OptionalHeader:181 ImageBase: 0x180000000182 SectionAlignment: 4096183 FileAlignment: 512184 DLLCharacteristics: [ ]185 LoadConfigTable:186 RelativeVirtualAddress: 0x1000187 Size: 320188header:189 Machine: IMAGE_FILE_MACHINE_AMD64190 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]191sections:192 - Name: .rdata193 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]194 VirtualAddress: 0x1000195 VirtualSize: 320196 StructuredData:197 - LoadConfig:198symbols: []199...200 201## Create load config larger than coff_load_configuration32 struct.202# RUN: yaml2obj --docnum=4 %s -o %t203# RUN: llvm-readobj --hex-dump=.rdata %t | FileCheck %s --check-prefix=LARGE204 205# LARGE: 0x00401000 d0000000 00000000 00000000 00000000 ................206# LARGE-NEXT: 0x00401010 00000000 00000000 00000000 00000000 ................207# LARGE-NEXT: 0x00401020 00000000 00000000 00000000 00000000 ................208# LARGE-NEXT: 0x00401030 00000000 00000000 00000000 00000000 ................209# LARGE-NEXT: 0x00401040 00000000 00000000 00000000 00000000 ................210# LARGE-NEXT: 0x00401050 00000000 00000000 00000000 00000000 ................211# LARGE-NEXT: 0x00401060 00000000 00000000 00000000 00000000 ................212# LARGE-NEXT: 0x00401070 00000000 00000000 00000000 00000000 ................213# LARGE-NEXT: 0x00401080 00000000 00000000 00000000 00000000 ................214# LARGE-NEXT: 0x00401090 00000000 00000000 00000000 00000000 ................215# LARGE-NEXT: 0x004010a0 00000000 00000000 00000000 00000000 ................216# LARGE-NEXT: 0x004010b0 00000000 00000000 ff000000 00000000 ................217# LARGE-NEXT: 0x004010c0 00000000 00000000 00000000 00000000 ................218# LARGE-NEXT: 0x004010d0 aabbccdd ....219 220--- !COFF221OptionalHeader:222 ImageBase: 0x400000223 SectionAlignment: 4096224 FileAlignment: 512225 DLLCharacteristics: [ ]226 LoadConfigTable:227 RelativeVirtualAddress: 0x1000228 Size: 320229header:230 Machine: IMAGE_FILE_MACHINE_I386231 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]232sections:233 - Name: .rdata234 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]235 VirtualAddress: 0x1000236 VirtualSize: 0xd4237 StructuredData:238 - LoadConfig:239 Size: 0xd0240 CastGuardOsDeterminedFailureMode: 0xff241 - UInt32: 0xddccbbaa242symbols: []243...244 245## Try to specify load config field that barely fits the specified size.246# RUN: yaml2obj --docnum=5 %s -o %t247# RUN: llvm-readobj --hex-dump=.rdata %t | FileCheck %s --check-prefix=SMALL248# SMALL: 0x180001000 09000000 00000000 aaffffff ff249 250--- !COFF251OptionalHeader:252 ImageBase: 0x180000000253 SectionAlignment: 4096254 FileAlignment: 512255 DLLCharacteristics: [ ]256 LoadConfigTable:257 RelativeVirtualAddress: 0x1000258 Size: 320259header:260 Machine: IMAGE_FILE_MACHINE_AMD64261 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]262sections:263 - Name: .rdata264 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]265 VirtualAddress: 0x1000266 VirtualSize: 13267 StructuredData:268 - LoadConfig:269 Size: 9270 MajorVersion: 0xbbaa271 - UInt32: 0xffffffff272symbols: []273...274 275## Try to specify load config field that does not fit specified size.276# RUN: not yaml2obj --docnum=6 %s -o %t 2>&1 | FileCheck %s --check-prefix=TOOSMALL277# TOOSMALL: error: unknown key 'MajorVersion'278 279--- !COFF280OptionalHeader:281 ImageBase: 0x180000000282 SectionAlignment: 4096283 FileAlignment: 512284 DLLCharacteristics: [ ]285 LoadConfigTable:286 RelativeVirtualAddress: 0x1000287 Size: 320288header:289 Machine: IMAGE_FILE_MACHINE_AMD64290 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]291sections:292 - Name: .rdata293 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]294 VirtualAddress: 0x1000295 VirtualSize: 320296 StructuredData:297 - LoadConfig:298 Size: 8299 MajorVersion: 10300symbols: []301...302 303## Set load config size to 0.304# RUN: not yaml2obj --docnum=7 %s -o %t 2>&1 | FileCheck %s --check-prefix=ZERO305# ZERO: error: Size must be at least 4306 307--- !COFF308OptionalHeader:309 ImageBase: 0x180000000310 SectionAlignment: 4096311 FileAlignment: 512312 DLLCharacteristics: [ ]313 LoadConfigTable:314 RelativeVirtualAddress: 0x1000315 Size: 320316header:317 Machine: IMAGE_FILE_MACHINE_AMD64318 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]319sections:320 - Name: .rdata321 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]322 VirtualAddress: 0x1000323 VirtualSize: 320324 StructuredData:325 - LoadConfig:326 Size: 0327symbols: []328...329