[clang-tidy][use-internal-linkage]fix false positives for global overloaded operator...
[llvm-project.git] / lld / test / COFF / guard-longjmp.s
blob86665aace67c982d2fbf4e51c077ba558f75fd24
1 # REQUIRES: x86
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
7 # CHECK: LoadConfig [
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)
18 # CHECK: ]
19 # CHECK: GuardAddressTakenIatEntryTable: 0x0
20 # CHECK: GuardAddressTakenIatEntryCount: 0
21 # CHECK: GuardLongJumpTargetTable: 0x14000{{.*}}
22 # CHECK: GuardLongJumpTargetCount: 1
23 # CHECK: ]
24 # CHECK: GuardLJmpTable [
25 # CHECK-NEXT: 0x14000{{.*}}
26 # CHECK-NEXT: ]
29 # This assembly is reduced from C code like:
30 # #include <setjmp.h>
31 # jmp_buf buf;
32 # void g() { longjmp(buf, 1); }
33 # void f() {
34 # if (setjmp(buf))
35 # return;
36 # g();
37 # }
38 # int main() { f(); }
40 # We need @feat.00 to have 0x800 to indicate /guard:cf.
41 .def @feat.00;
42 .scl 3;
43 .type 0;
44 .endef
45 .globl @feat.00
46 @feat.00 = 0x801
47 .def f; .scl 2; .type 32; .endef
48 .globl f
50 pushq %rbp
51 subq $32, %rsp
52 leaq 32(%rsp), %rbp
53 leaq buf(%rip), %rcx
54 leaq -32(%rbp), %rdx
55 callq _setjmp
56 .Lljmp1:
57 testl %eax, %eax
58 je .LBB1_1
59 addq $32, %rsp
60 popq %rbp
61 retq
62 .LBB1_1: # %if.end
63 leaq buf(%rip), %rcx
64 movl $1, %edx
65 callq longjmp
66 ud2
68 # Record the longjmp target.
69 .section .gljmp$y,"dr"
70 .symidx .Lljmp1
71 .text
73 # Provide setjmp/longjmp stubs.
74 .def _setjmp; .scl 2; .type 32; .endef
75 .globl _setjmp
76 _setjmp:
77 retq
79 .def longjmp; .scl 2; .type 32; .endef
80 .globl longjmp
81 longjmp:
82 retq
84 .def main; .scl 2; .type 32; .endef
85 .globl main # -- Begin function main
86 main: # @main
87 subq $40, %rsp
88 callq f
89 xorl %eax, %eax
90 addq $40, %rsp
91 retq
93 .comm buf,256,4 # @buf
95 .section .rdata,"dr"
96 .globl _load_config_used
97 _load_config_used:
98 .long 256
99 .fill 124, 1, 0
100 .quad __guard_fids_table
101 .quad __guard_fids_count
102 .long __guard_flags
103 .fill 12, 1, 0
104 .quad __guard_iat_table
105 .quad __guard_iat_count
106 .quad __guard_longjmp_table
107 .quad __guard_longjmp_count
108 .fill 84, 1, 0