Mercurial > hg > CbC > CbC_llvm
comparison lld/test/COFF/gfids-icf.s @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children | 2e18cbf3894f |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
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:nolongjmp -out:%t.exe -opt:icf -entry:main | |
4 # RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK | |
5 | |
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 # } | |
15 | |
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. | |
18 | |
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: GuardAddressTakenIatEntryTable: 0x0 | |
29 # CHECK: GuardAddressTakenIatEntryCount: 0 | |
30 # CHECK: GuardLongJumpTargetTable: 0x0 | |
31 # CHECK: GuardLongJumpTargetCount: 0 | |
32 # CHECK: ] | |
33 # CHECK: GuardFidTable [ | |
34 # CHECK-NEXT: 0x14000{{.*}} | |
35 # CHECK-NEXT: 0x14000{{.*}} | |
36 # CHECK-NEXT: ] | |
37 | |
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 | |
43 | |
44 # NOGFIDSEC: Sections [ | |
45 # NOGFIDSEC: Section { | |
46 # NOGFIDSEC: Name: .text | |
47 # NOGFIDSEC-NOT: Name: .gfids | |
48 | |
49 # Indicate that gfids are present. | |
50 .def @feat.00; .scl 3; .type 0; .endef | |
51 .globl @feat.00 | |
52 @feat.00 = 0x800 | |
53 | |
54 .def icf1; .scl 2; .type 32; .endef | |
55 .section .text,"xr",one_only,icf1 | |
56 .global icf1 | |
57 icf1: | |
58 movl $42, %eax | |
59 retq | |
60 | |
61 .def icf2; .scl 2; .type 32; .endef | |
62 .section .text,"xr",one_only,icf2 | |
63 .global icf2 | |
64 icf2: | |
65 movl $42, %eax | |
66 retq | |
67 | |
68 # Take their two addresses. | |
69 .data | |
70 .globl fp1 | |
71 fp1: | |
72 .quad icf1 | |
73 .globl fp2 | |
74 fp2: | |
75 .quad icf2 | |
76 | |
77 .section .gfids$y,"dr" | |
78 .symidx icf1 | |
79 .symidx icf2 | |
80 | |
81 .def main; .scl 2; .type 32; .endef | |
82 .section .text,"xr",one_only,main | |
83 .globl main | |
84 main: | |
85 callq *fp1(%rip) | |
86 callq *fp2(%rip) | |
87 xor %eax, %eax | |
88 retq | |
89 | |
90 .section .rdata,"dr" | |
91 .globl _load_config_used | |
92 _load_config_used: | |
93 .long 256 | |
94 .fill 124, 1, 0 | |
95 .quad __guard_fids_table | |
96 .quad __guard_fids_count | |
97 .long __guard_flags | |
98 .fill 128, 1, 0 |