xref: /llvm-project/lld/test/COFF/gfids-fallback.s (revision 64fb629a06f1bd31ece19335b799eb17bff75a09)
1# REQUIRES: x86
2# RUN: grep -B99999 [S]PLITMARKER %s | llvm-mc -triple x86_64-windows-msvc -filetype=obj -o %t1.obj
3# RUN: grep -A99999 [S]PLITMARKER %s | llvm-mc -triple x86_64-windows-msvc -filetype=obj -o %t2.obj
4# RUN: lld-link %t1.obj %t2.obj -guard:cf,nolongjmp -out:%t.exe -entry:main -opt:noref
5# RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s
6
7# CHECK: ImageBase: 0x140000000
8# CHECK: LoadConfig [
9# CHECK:   SEHandlerTable: 0x0
10# CHECK:   SEHandlerCount: 0
11# CHECK:   GuardCFCheckFunction: 0x0
12# CHECK:   GuardCFCheckDispatch: 0x0
13# CHECK:   GuardCFFunctionTable: 0x14000{{.*}}
14# CHECK:   GuardCFFunctionCount: 3
15# CHECK:   GuardFlags [ (0x500)
16# CHECK:     CF_FUNCTION_TABLE_PRESENT (0x400)
17# CHECK:     CF_INSTRUMENTED (0x100)
18# CHECK:   ]
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:   0x14000{{.*}}
28# CHECK-NEXT: ]
29
30
31# Indicate that no gfids are present. All symbols used by relocations in this
32# file will be considered address-taken.
33        .def     @feat.00; .scl    3; .type   0; .endef
34        .globl  @feat.00
35@feat.00 = 0
36
37        .def     main; .scl    2; .type   32; .endef
38        .section        .text,"xr",one_only,main
39        .globl  main
40main:
41        subq $8, %rsp
42        leaq foo(%rip), %rdx
43        callq bar
44        movl $0, %eax
45        addq $8, %rsp
46        retq
47
48# Should not appear in gfids table.
49        .def     baz; .scl    2; .type   32; .endef
50        .section        .text,"xr",one_only,baz
51        .globl  baz
52baz:
53        mov $1, %eax
54        retq
55
56        .def     qux; .scl    2; .type   32; .endef
57        .section        .text,"xr",one_only,qux
58        .globl  qux
59qux:
60        mov $2, %eax
61        retq
62
63        .def     quxx; .scl    2; .type   32; .endef
64        .section        .text,"xr",one_only,quxx
65        .globl  quxx
66quxx:
67        mov $3, %eax
68        retq
69
70# Load config.
71        .section .rdata,"dr"
72.globl _load_config_used
73_load_config_used:
74        .long 256
75        .fill 124, 1, 0
76        .quad __guard_fids_table
77        .quad __guard_fids_count
78        .long __guard_flags
79        .fill 128, 1, 0
80
81# SPLITMARKER
82
83# Indicate that gfids are present. This file does not take any addresses.
84        .def     @feat.00; .scl    3; .type   0; .endef
85        .globl  @feat.00
86@feat.00 = 0x800
87
88        .def     foo; .scl    2; .type   32; .endef
89        .section        .text,"xr",one_only,foo
90        .global foo
91foo:
92        movl $42, %eax
93        retq
94
95        .def     bar; .scl    2; .type   32; .endef
96        .section        .text,"xr",one_only,bar
97        .global bar
98bar:
99        movl $13, %eax
100        retq
101