2 # RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj
3 # RUN: lld-link %t.obj -guard:cf,nolongjmp -out:%t.exe -opt:noref -entry:main
4 # RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
5 # RUN: lld-link %t.obj -guard:cf,nolongjmp -out:%t.exe -opt:noref -entry:main -debug:dwarf
6 # RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
7 # RUN: lld-link %t.obj -guard:cf,nolongjmp -out:%t.exe -opt:ref -entry:main
8 # RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-GC
10 # This assembly is meant to mimic what CL emits for this kind of C code when
11 # /Gw (-fdata-sections) is enabled:
12 # int f() { return 42; }
13 # int g() { return 13; }
19 # Compile with 'cl -c -guard:cf -Gw -O1' and note the two associative .gfids$y
22 # Expect 3 entries: main, f, and g.
24 # CHECK-NOGC: ImageBase: 0x140000000
25 # CHECK-NOGC: LoadConfig [
26 # CHECK-NOGC: SEHandlerTable: 0x0
27 # CHECK-NOGC: SEHandlerCount: 0
28 # CHECK-NOGC: GuardCFCheckFunction: 0x0
29 # CHECK-NOGC: GuardCFCheckDispatch: 0x0
30 # CHECK-NOGC: GuardCFFunctionTable: 0x14000{{.*}}
31 # CHECK-NOGC: GuardCFFunctionCount: 3
32 # CHECK-NOGC: GuardFlags [ (0x500)
33 # CHECK-NOGC: CF_FUNCTION_TABLE_PRESENT (0x400)
34 # CHECK-NOGC: CF_INSTRUMENTED (0x100)
36 # CHECK-NOGC: GuardAddressTakenIatEntryTable: 0x0
37 # CHECK-NOGC: GuardAddressTakenIatEntryCount: 0
38 # CHECK-NOGC: GuardLongJumpTargetTable: 0x0
39 # CHECK-NOGC: GuardLongJumpTargetCount: 0
41 # CHECK-NOGC: GuardFidTable [
42 # CHECK-NOGC-NEXT: 0x14000{{.*}}
43 # CHECK-NOGC-NEXT: 0x14000{{.*}}
44 # CHECK-NOGC-NEXT: 0x14000{{.*}}
47 # Expect 2 entries: main and f. fp2 was discarded, so g was only used as a
50 # CHECK-GC: ImageBase: 0x140000000
51 # CHECK-GC: LoadConfig [
52 # CHECK-GC: SEHandlerTable: 0x0
53 # CHECK-GC: SEHandlerCount: 0
54 # CHECK-GC: GuardCFCheckFunction: 0x0
55 # CHECK-GC: GuardCFCheckDispatch: 0x0
56 # CHECK-GC: GuardCFFunctionTable: 0x14000{{.*}}
57 # CHECK-GC: GuardCFFunctionCount: 2
58 # CHECK-GC: GuardFlags [ (0x500)
59 # CHECK-GC: CF_FUNCTION_TABLE_PRESENT (0x400)
60 # CHECK-GC: CF_INSTRUMENTED (0x100)
62 # CHECK-GC: GuardAddressTakenIatEntryTable: 0x0
63 # CHECK-GC: GuardAddressTakenIatEntryCount: 0
64 # CHECK-GC: GuardLongJumpTargetTable: 0x0
65 # CHECK-GC: GuardLongJumpTargetCount: 0
67 # CHECK-GC: GuardFidTable [
68 # CHECK-GC-NEXT: 0x14000{{.*}}
69 # CHECK-GC-NEXT: 0x14000{{.*}}
73 # We need @feat.00 to have 0x800 to indicate .gfids are present.
85 .section .text,"xr",one_only,main
88 # Call g directly so that it is not dead stripped.
96 .section .text,"xr",one_only,f
101 .section .data,"dw",one_only,fp1
106 .section .gfids$y,"dr",associative,fp1
109 # Section GC will remove the following, so 'g' should not be present in the
116 .section .text,"xr",one_only,g
121 .section .data,"dw",one_only,fp2
126 .section .gfids$y,"dr",associative,fp2
130 .globl _load_config_used
134 .quad __guard_fids_table
135 .quad __guard_fids_count