[clang-tidy][use-internal-linkage]fix false positives for global overloaded operator...
[llvm-project.git] / lld / test / COFF / gfids-icf.s
blob62ffd615e0837747353b5bc5acd6b285ac430e72
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,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;
11 # int main() {
12 # return fp1();
13 # return fp2();
14 # }
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
20 # CHECK: LoadConfig [
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: CF_FUNCTION_TABLE_PRESENT (0x400)
29 # CHECK: CF_INSTRUMENTED (0x100)
30 # CHECK: ]
31 # CHECK: GuardAddressTakenIatEntryTable: 0x0
32 # CHECK: GuardAddressTakenIatEntryCount: 0
33 # CHECK: GuardLongJumpTargetTable: 0x0
34 # CHECK: GuardLongJumpTargetCount: 0
35 # CHECK: ]
36 # CHECK: GuardFidTable [
37 # CHECK-NEXT: 0x14000{{.*}}
38 # CHECK-NEXT: 0x14000{{.*}}
39 # CHECK-NEXT: ]
41 # There should be no .gfids section in the output executable when we link with
42 # -guard:cf or with no -guard:cf/nolongjmp flag.
43 # RUN: llvm-readobj --sections %t.exe | FileCheck %s --check-prefix NOGFIDSEC
44 # RUN: lld-link %t.obj -out:%t.exe -opt:icf -entry:main
45 # RUN: llvm-readobj --sections %t.exe | FileCheck %s --check-prefix NOGFIDSEC
47 # NOGFIDSEC: Sections [
48 # NOGFIDSEC: Section {
49 # NOGFIDSEC: Name: .text
50 # NOGFIDSEC-NOT: Name: .gfids
52 # Indicate that gfids are present.
53 .def @feat.00; .scl 3; .type 0; .endef
54 .globl @feat.00
55 @feat.00 = 0x800
57 .def icf1; .scl 2; .type 32; .endef
58 .section .text,"xr",one_only,icf1
59 .global icf1
60 icf1:
61 movl $42, %eax
62 retq
64 .def icf2; .scl 2; .type 32; .endef
65 .section .text,"xr",one_only,icf2
66 .global icf2
67 icf2:
68 movl $42, %eax
69 retq
71 # Take their two addresses.
72 .data
73 .globl fp1
74 fp1:
75 .quad icf1
76 .globl fp2
77 fp2:
78 .quad icf2
80 .section .gfids$y,"dr"
81 .symidx icf1
82 .symidx icf2
84 .def main; .scl 2; .type 32; .endef
85 .section .text,"xr",one_only,main
86 .globl main
87 main:
88 callq *fp1(%rip)
89 callq *fp2(%rip)
90 xor %eax, %eax
91 retq
93 .section .rdata,"dr"
94 .globl _load_config_used
95 _load_config_used:
96 .long 256
97 .fill 124, 1, 0
98 .quad __guard_fids_table
99 .quad __guard_fids_count
100 .long __guard_flags
101 .fill 128, 1, 0