2 # RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj
3 # RUN: lld-link %t.obj -guard:cf -out:%t.exe -entry:main
4 # RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s
6 # CHECK: ImageBase: 0x140000000
8 # CHECK: SEHandlerTable: 0x0
9 # CHECK: SEHandlerCount: 0
10 # CHECK: GuardCFCheckFunction: 0x0
11 # CHECK: GuardCFCheckDispatch: 0x0
12 # CHECK: GuardCFFunctionTable: 0x14000{{.*}}
13 # CHECK: GuardCFFunctionCount: 1
14 # CHECK: GuardFlags [ (0x10500)
15 # CHECK: CF_FUNCTION_TABLE_PRESENT (0x400)
16 # CHECK: CF_INSTRUMENTED (0x100)
17 # CHECK: CF_LONGJUMP_TABLE_PRESENT (0x10000)
19 # CHECK: GuardAddressTakenIatEntryTable: 0x0
20 # CHECK: GuardAddressTakenIatEntryCount: 0
21 # CHECK: GuardLongJumpTargetTable: 0x14000{{.*}}
22 # CHECK: GuardLongJumpTargetCount: 1
24 # CHECK: GuardLJmpTable [
25 # CHECK-NEXT: 0x14000{{.*}}
29 # This assembly is reduced from C code like:
32 # void g() { longjmp(buf, 1); }
40 # We need @feat.00 to have 0x800 to indicate /guard:cf.
47 .def f; .scl 2; .type 32; .endef
68 # Record the longjmp target.
69 .section .gljmp$y,"dr"
73 # Provide setjmp/longjmp stubs.
74 .def _setjmp; .scl 2; .type 32; .endef
79 .def longjmp; .scl 2; .type 32; .endef
84 .def main; .scl 2; .type 32; .endef
85 .globl main # -- Begin function main
93 .comm buf,256,4 # @buf
96 .globl _load_config_used
100 .quad __guard_fids_table
101 .quad __guard_fids_count
104 .quad __guard_iat_table
105 .quad __guard_iat_count
106 .quad __guard_longjmp_table
107 .quad __guard_longjmp_count