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
:
20 # Various and duplicate calls to ensure every code path is taken.
21 callq
\function_to_call
22 callq
\function_to_call
24 callq non_function_text_symbol
26 .size prologue1_calls_\function_to_call,. - prologue1_calls_\function_to_call
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
39 # Various and duplicate calls to ensure every code path is taken.
40 callq
\function_to_call
41 callq
\function_to_call
43 callq non_function_text_symbol
45 .size prologue2_calls_\function_to_call\register,. - prologue2_calls_\function_to_call\register
48 .section .text,"ax",@progbits,unique,0
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
58 # CHECK: <prologue1_calls_split>:
59 # CHECK-NEXT: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%rsp
61 # CHECK-NEXT: callq{{.*}}<__morestack>
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]+}}
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]+}}
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
87 # CHECK: <prologue1_calls_non_split>:
88 # CHECK-NEXT: stc{{.*$}}
89 # CHECK-NEXT: nopl{{.*$}}
91 # CHECK-NEXT: callq{{.*}}<__morestack_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
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
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
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