2 # RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj
3 # RUN: lld-link %t.obj -guard:nolongjmp -out:%t.exe -opt:icf -entry:main
4 # RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK
6 # This assembly is meant to mimic what CL emits for this kind of C code:
7 # int icf1() { return 42; }
8 # int icf2() { return 42; }
9 # int (*fp1)() = &icf1;
10 # int (*fp2)() = &icf2;
16 # 'icf1' and 'icf2' are address taken, but should be merged into one entry.
17 # There are two entries in the table because 'main' is included.
19 # CHECK: ImageBase: 0x140000000
21 # CHECK: SEHandlerTable: 0x0
22 # CHECK: SEHandlerCount: 0
23 # CHECK: GuardCFCheckFunction: 0x0
24 # CHECK: GuardCFCheckDispatch: 0x0
25 # CHECK: GuardCFFunctionTable: 0x14000{{.*}}
26 # CHECK: GuardCFFunctionCount: 2
27 # CHECK: GuardFlags: 0x500
28 # CHECK: GuardAddressTakenIatEntryTable: 0x0
29 # CHECK: GuardAddressTakenIatEntryCount: 0
30 # CHECK: GuardLongJumpTargetTable: 0x0
31 # CHECK: GuardLongJumpTargetCount: 0
33 # CHECK: GuardFidTable [
34 # CHECK-NEXT: 0x14000{{.*}}
35 # CHECK-NEXT: 0x14000{{.*}}
38 # There should be no .gfids section in the output exectuable when we link with
39 # -guard:cf or with no -guard:cf/nolongjmp flag.
40 # RUN: llvm-readobj --sections %t.exe | FileCheck %s --check-prefix NOGFIDSEC
41 # RUN: lld-link %t.obj -out:%t.exe -opt:icf -entry:main
42 # RUN: llvm-readobj --sections %t.exe | FileCheck %s --check-prefix NOGFIDSEC
44 # NOGFIDSEC: Sections [
45 # NOGFIDSEC: Section {
46 # NOGFIDSEC: Name: .text
47 # NOGFIDSEC-NOT: Name: .gfids
49 # Indicate that gfids are present.
50 .def @feat.00; .scl 3; .type 0; .endef
54 .def icf1; .scl 2; .type 32; .endef
55 .section .text,"xr",one_only,icf1
61 .def icf2; .scl 2; .type 32; .endef
62 .section .text,"xr",one_only,icf2
68 # Take their two addresses.
77 .section .gfids$y,"dr"
81 .def main; .scl 2; .type 32; .endef
82 .section .text,"xr",one_only,main
91 .globl _load_config_used
95 .quad __guard_fids_table
96 .quad __guard_fids_count