[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / x86-64-split-stack-prologue-adjust-success.s
blob73fb4b386f4b5eb3733439dae0358c276f22c43f
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-extra.s -o %t2.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/x86-64-split-stack-main.s -o %t3.o
6 # RUN: ld.lld --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 %t1.o %t2.o %t3.o -o %t -z notext
7 # RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck %s
9 # Avoid duplicating the prologue for every test via macros.
11 .macro prologue1 function_to_call
12 .global prologue1_calls_\function_to_call
13 .type prologue1_calls_\function_to_call,@function
14 prologue1_calls_\function_to_call:
15 cmp %fs:0x70,%rsp
16 jae 1f
17 callq __morestack
18 retq
20 # Various and duplicate calls to ensure every code path is taken.
21 callq \function_to_call
22 callq \function_to_call
23 callq 1b
24 callq non_function_text_symbol
25 retq
26 .size prologue1_calls_\function_to_call,. - prologue1_calls_\function_to_call
27 .endm
29 .macro prologue2 function_to_call register compare_amount
30 .global prologue2_calls_\function_to_call\register
31 .type prologue2_calls_\function_to_call\register,@function
32 prologue2_calls_\function_to_call\register:
33 lea -\compare_amount(%rsp),%\register
34 cmp %fs:0x70,%\register
35 jae 1f
36 callq __morestack
37 retq
39 # Various and duplicate calls to ensure every code path is taken.
40 callq \function_to_call
41 callq \function_to_call
42 callq 1b
43 callq non_function_text_symbol
44 retq
45 .size prologue2_calls_\function_to_call\register,. - prologue2_calls_\function_to_call\register
46 .endm
48 .section .text,"ax",@progbits,unique,0
49 .local foo
50 foo:
51 .quad foo
53 .section .text,"ax",@progbits,unique,1
55 # For split-stack code calling split-stack code, ensure prologue v1 still
56 # calls plain __morestack, and that any raw bytes written to the prologue
57 # make sense.
58 # CHECK: <prologue1_calls_split>:
59 # CHECK-NEXT: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%rsp
60 # CHECK: jae{{.*$}}
61 # CHECK-NEXT: callq{{.*}}<__morestack>
63 prologue1 split
65 # For split-stack code calling split-stack code, ensure prologue v2 still
66 # calls plain __morestack, that any raw bytes written to the prologue
67 # make sense, and that the register number is preserved.
68 # CHECK: <prologue2_calls_splitr10>:
69 # CHECK-NEXT: lea{{.*}} -512(%rsp),{{.*}}%r10
70 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}
71 # CHECK: jae{{.*}}
72 # CHECK-NEXT: callq{{.*}}<__morestack>
74 prologue2 split r10 0x200
76 # CHECK: <prologue2_calls_splitr11>:
77 # CHECK-NEXT: lea{{.*}} -256(%rsp),{{.*}}%r11
78 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}
79 # CHECK: jae{{.*}}
80 # CHECK-NEXT: callq{{.*}}<__morestack>
82 prologue2 split r11 0x100
84 # For split-stack code calling non-split-stack code, ensure prologue v1
85 # calls __morestack_non_split, and that any raw bytes written to the prologue
86 # make sense.
87 # CHECK: <prologue1_calls_non_split>:
88 # CHECK-NEXT: stc{{.*$}}
89 # CHECK-NEXT: nopl{{.*$}}
90 # CHECK: jae{{.*$}}
91 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
93 prologue1 non_split
95 # For split-stack code calling non-split-stack code, ensure prologue v2
96 # calls __morestack_non_split, that any raw bytes written to the prologue
97 # make sense, and that the register number is preserved
98 # CHECK: <prologue2_calls_non_splitr10>:
99 # CHECK-NEXT: lea{{.*}} -16640(%rsp),{{.*}}%r10
100 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r10
101 # CHECK: jae{{.*$}}
102 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
104 prologue2 non_split r10 0x100
106 # CHECK: <prologue2_calls_non_splitr11>:
107 # CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11
108 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11
109 # CHECK: jae{{.*$}}
110 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
112 prologue2 non_split r11 0x200
114 # CHECK: <prologue2_calls_non_split_hiddenr11>:
115 # CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11
116 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11
117 # CHECK: jae{{.*$}}
118 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
120 prologue2 non_split_hidden r11 0x200
122 .section .note.GNU-stack,"",@progbits
123 .section .note.GNU-split-stack,"",@progbits