brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.7 KiB · 0928715 Raw
228 lines · plain
1# REQUIRES: x862# Make a DLL that exports exportfn1.3# RUN: yaml2obj %p/Inputs/export.yaml -o %basename_t-exp.obj4# RUN: lld-link /out:%basename_t-exp.dll /dll %basename_t-exp.obj /export:exportfn1 /implib:%basename_t-exp.lib5# RUN: split-file %s %t6# RUN: llvm-mc -triple x86_64-windows-msvc %t/main.s -filetype=obj -o %t/main.obj7 8# RUN: lld-link %t/main.obj -guard:cf,longjmp,ehcont -out:%t-missing.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_MISSING9# WARN_MISSING: warning: Control Flow Guard is enabled but '_load_config_used' is missing10 11# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-invalid.s -filetype=obj -o %t/loadcfg-invalid.obj12# RUN: lld-link %t/main.obj %t/loadcfg-invalid.obj -guard:cf,longjmp,ehcont -out:%t-invalid.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_INVALID13# WARN_INVALID:      warning: GuardCFFunctionTable not set correctly in '_load_config_used'14# WARN_INVALID-NEXT: warning: GuardCFFunctionCount not set correctly in '_load_config_used'15# WARN_INVALID-NEXT: warning: GuardFlags not set correctly in '_load_config_used'16# WARN_INVALID-NEXT: warning: GuardAddressTakenIatEntryTable not set correctly in '_load_config_used'17# WARN_INVALID-NEXT: warning: GuardAddressTakenIatEntryCount not set correctly in '_load_config_used'18# WARN_INVALID-NEXT: warning: GuardLongJumpTargetTable not set correctly in '_load_config_used'19# WARN_INVALID-NEXT: warning: GuardLongJumpTargetCount not set correctly in '_load_config_used'20# WARN_INVALID-NEXT: warning: GuardEHContinuationTable not set correctly in '_load_config_used'21# WARN_INVALID-NEXT: warning: GuardEHContinuationCount not set correctly in '_load_config_used'22 23# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-small112.s -filetype=obj -o %t/loadcfg-small112.obj24# RUN: lld-link %t/main.obj %t/loadcfg-small112.obj -guard:cf,longjmp -out:%t-small112.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_SMALL_11225# WARN_SMALL_112: warning: '_load_config_used' structure too small to include GuardFlags26 27# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-small148.s -filetype=obj -o %t/loadcfg-small148.obj28# RUN: lld-link %t/main.obj %t/loadcfg-small148.obj -guard:cf,longjmp -out:%t-small148.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_SMALL_14829# WARN_SMALL_148: warning: '_load_config_used' structure too small to include GuardLongJumpTargetCount30 31# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-small244.s -filetype=obj -o %t/loadcfg-small244.obj32# RUN: lld-link %t/main.obj %t/loadcfg-small244.obj -guard:cf,longjmp,ehcont -out:%t-small244.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_SMALL_24433# WARN_SMALL_244: warning: '_load_config_used' structure too small to include GuardEHContinuationCount34 35# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-misaligned1.s -filetype=obj -o %t/loadcfg-misaligned1.obj36# RUN: lld-link %t/main.obj %t/loadcfg-misaligned1.obj -guard:cf,longjmp,ehcont -out:%t-misaligned1.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_ALIGN137# WARN_ALIGN1: warning: '_load_config_used' is misaligned (expected alignment to be 8 bytes, got 4 instead)38 39# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-misaligned2.s -filetype=obj -o %t/loadcfg-misaligned2.obj40# RUN: lld-link %t/main.obj %t/loadcfg-misaligned2.obj -guard:cf,longjmp,ehcont -out:%t-misaligned2.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=WARN_ALIGN241# WARN_ALIGN2: warning: '_load_config_used' is misaligned (section offset is 0x{{[0-9A-F]*}}2 not aligned to 8 bytes)42 43# RUN: llvm-mc -triple x86_64-windows-msvc %t/loadcfg-full.s -filetype=obj -o %t/loadcfg-full.obj44# RUN: lld-link %t/main.obj %t/loadcfg-full.obj -guard:cf,longjmp,ehcont -out:%t.exe -entry:main %basename_t-exp.lib 2>&1 | FileCheck %s --check-prefix=NOWARN --allow-empty45# NOWARN-NOT: warning46 47# Sanity check to make sure the no-warn version has the expected data.48# RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck --check-prefix=CHECK %s49# CHECK: ImageBase: 0x14000000050# CHECK: LoadConfig [51# CHECK:   SEHandlerTable: 0x052# CHECK:   SEHandlerCount: 053# CHECK:   GuardCFCheckFunction: 0x054# CHECK:   GuardCFCheckDispatch: 0x055# CHECK:   GuardCFFunctionTable: 0x14000{{([0-9A-F]{4})}}56# CHECK:   GuardCFFunctionCount: 157# CHECK:   GuardFlags [ (0x410500)58# CHECK:     CF_FUNCTION_TABLE_PRESENT (0x400)59# CHECK:     CF_INSTRUMENTED (0x100)60# CHECK:     CF_LONGJUMP_TABLE_PRESENT (0x10000)61# CHECK:     EH_CONTINUATION_TABLE_PRESENT (0x400000)62# CHECK:   ]63# CHECK:   GuardAddressTakenIatEntryTable: 0x14000{{([0-9A-F]{4})}}64# CHECK:   GuardAddressTakenIatEntryCount: 165# CHECK:   GuardLongJumpTargetTable: 0x14000{{([0-9A-F]{4})}}66# CHECK:   GuardLongJumpTargetCount: 167# CHECK:   GuardEHContinuationTable: 0x14000{{([0-9A-F]{4})}}68# CHECK:   GuardEHContinuationCount: 169# CHECK: ]70# CHECK-NEXT: GuardFidTable [71# CHECK-NEXT:   0x14000{{([0-9A-F]{4})}}72# CHECK-NEXT: ]73# CHECK-NEXT: GuardIatTable [74# CHECK-NEXT:   0x14000{{([0-9A-F]{4})}}75# CHECK-NEXT: ]76# CHECK-NEXT: GuardLJmpTable [77# CHECK-NEXT:   0x14000{{([0-9A-F]{4})}}78# CHECK-NEXT: ]79# CHECK-NEXT: GuardEHContTable [80# CHECK-NEXT:   0x14000{{([0-9A-F]{4})}}81# CHECK-NEXT: ]82 83 84#--- main.s85 86# We need @feat.00 to have 0x4000 | 0x800 to indicate /guard:cf and /guard:ehcont.87        .def     @feat.00;88        .scl    3;89        .type   0;90        .endef91        .globl  @feat.0092@feat.00 = 0x480093        .def     main; .scl    2; .type   32; .endef94        .globl	main                            # -- Begin function main95        .p2align	4, 0x9096main:97        mov %eax, %eax98	movq __imp_exportfn1(%rip), %rax99        callq *%rax100        nop101# Fake setjmp target102$cfgsj_main0:103        mov %ebx, %ebx104        nop105# Fake ehcont target106$ehgcr_0_1:107        mov %ecx, %ecx108        nop109        retq110                                        # -- End function111        .section	.gfids$y,"dr"112        .symidx main113        .section	.giats$y,"dr"114        .symidx __imp_exportfn1115        .section	.gljmp$y,"dr"116        .symidx $cfgsj_main0117        .section	.gehcont$y,"dr"118        .symidx	$ehgcr_0_1119        .addrsig_sym main120        .addrsig_sym __imp_exportfn1121        .section  .rdata,"dr"122 123#--- loadcfg-invalid.s124 125.globl _load_config_used126        .p2align 3127_load_config_used:128        .long 312129        .fill 308, 1, 0130 131#--- loadcfg-small112.s132 133.globl _load_config_used134        .p2align 3135_load_config_used:136        .long 112137        .fill 108, 1, 0138 139#--- loadcfg-small148.s140 141.globl _load_config_used142        .p2align 3143_load_config_used:144        .long 148145        .fill 124, 1, 0146        .quad __guard_fids_table147        .quad __guard_fids_count148        .long __guard_flags149 150#--- loadcfg-small244.s151 152.globl _load_config_used153        .p2align 3154_load_config_used:155        .long 244156        .fill 124, 1, 0157        .quad __guard_fids_table158        .quad __guard_fids_count159        .long __guard_flags160        .fill 12, 1, 0161        .quad __guard_iat_table162        .quad __guard_iat_count163        .quad __guard_longjmp_table164        .quad __guard_longjmp_count165        .fill 52, 1, 0          # Up to HotPatchTableOffset166 167#--- loadcfg-misaligned1.s168 169.globl _load_config_used170        .fill 2, 1, 0           # offset by 2171        .p2align 2              # then align to 0x04172_load_config_used:173        .long 312174        .fill 124, 1, 0175        .quad __guard_fids_table176        .quad __guard_fids_count177        .long __guard_flags178        .fill 12, 1, 0179        .quad __guard_iat_table180        .quad __guard_iat_count181        .quad __guard_longjmp_table182        .quad __guard_longjmp_count183        .fill 72, 1, 0184        .quad __guard_eh_cont_table185        .quad __guard_eh_cont_count186        .fill 32, 1, 0187 188#--- loadcfg-misaligned2.s189 190.globl _load_config_used191        .p2align 4              # align to 0x10192        .fill 2, 1, 0           # then offset by 2193_load_config_used:194        .long 312195        .fill 124, 1, 0196        .quad __guard_fids_table197        .quad __guard_fids_count198        .long __guard_flags199        .fill 12, 1, 0200        .quad __guard_iat_table201        .quad __guard_iat_count202        .quad __guard_longjmp_table203        .quad __guard_longjmp_count204        .fill 72, 1, 0205        .quad __guard_eh_cont_table206        .quad __guard_eh_cont_count207        .fill 32, 1, 0208 209#--- loadcfg-full.s210 211.globl _load_config_used212        .p2align 3213_load_config_used:214        .long 312215        .fill 124, 1, 0216        .quad __guard_fids_table217        .quad __guard_fids_count218        .long __guard_flags219        .fill 12, 1, 0220        .quad __guard_iat_table221        .quad __guard_iat_count222        .quad __guard_longjmp_table223        .quad __guard_longjmp_count224        .fill 72, 1, 0225        .quad __guard_eh_cont_table226        .quad __guard_eh_cont_count227        .fill 32, 1, 0228