1# REQUIRES: x86
2# RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj
3# RUN: lld-link %t.obj -opt:noref -guard:nolongjmp -out:%t.exe -entry:main 2>&1 | FileCheck %s --check-prefix=ERRS
4# RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s
5
6# ERRS: warning: ignoring .gfids$y symbol table index section in object {{.*}}gfids-corrupt{{.*}}
7# ERRS: warning: ignoring invalid symbol table index in section .gfids$y in object {{.*}}gfids-corrupt{{.*}}
8
9# The table is arbitrary, really.
10# CHECK: ImageBase: 0x140000000
11# CHECK: LoadConfig [
12# CHECK:   SEHandlerTable: 0x0
13# CHECK:   SEHandlerCount: 0
14# CHECK:   GuardCFCheckFunction: 0x0
15# CHECK:   GuardCFCheckDispatch: 0x0
16# CHECK:   GuardCFFunctionTable: 0x14000{{.*}}
17# CHECK:   GuardCFFunctionCount: 2
18# CHECK:   GuardFlags: 0x500
19# CHECK:   GuardAddressTakenIatEntryTable: 0x0
20# CHECK:   GuardAddressTakenIatEntryCount: 0
21# CHECK:   GuardLongJumpTargetTable: 0x0
22# CHECK:   GuardLongJumpTargetCount: 0
23# CHECK: ]
24# CHECK:      GuardFidTable [
25# CHECK-NEXT:   0x14000{{.*}}
26# CHECK-NEXT:   0x14000{{.*}}
27# CHECK-NEXT: ]
28
29
30# Indicate that gfids are present.
31        .def     @feat.00; .scl    3; .type   0; .endef
32        .globl  @feat.00
33@feat.00 = 0x800
34
35        .def     f1; .scl    2; .type   32; .endef
36        .section        .text,"xr",one_only,f1
37        .global f1
38f1:
39        movl $42, %eax
40        retq
41
42        .def     f2; .scl    2; .type   32; .endef
43        .section        .text,"xr",one_only,f2
44        .global f2
45f2:
46        movl $13, %eax
47        retq
48
49        .section        .data,"dw",one_only,fp1
50        .globl  fp1
51fp1:
52        .quad   f1
53
54        .section        .data,"dw",one_only,fp2
55        .globl  fp2
56fp2:
57        .quad   f2
58
59        .section        .gfids$y,"dr",associative,fp1
60        .symidx f1
61        .byte 0
62
63        .section        .gfids$y,"dr",associative,fp2
64        .symidx f2
65        .long 0x400
66
67        .def     main; .scl    2; .type   32; .endef
68        .section        .text,"xr",one_only,main
69        .globl  main
70main:
71        callq      *fp1(%rip)
72        callq      *fp2(%rip)
73        xor %eax, %eax
74        retq
75
76        .section .rdata,"dr"
77.globl _load_config_used
78_load_config_used:
79        .long 256
80        .fill 124, 1, 0
81        .quad __guard_fids_table
82        .quad __guard_fids_count
83        .long __guard_flags
84        .fill 128, 1, 0
85