150
|
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
|
|
5
|
|
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 -d %t | FileCheck %s
|
|
8
|
|
9 # Avoid duplicating the prologue for every test via macros.
|
|
10
|
|
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
|
|
19 1:
|
|
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
|
|
28
|
|
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
|
|
38 1:
|
|
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
|
|
47
|
|
48 .local foo
|
|
49 foo:
|
|
50 .section .text,"ax",@progbits
|
|
51 .quad foo
|
|
52
|
|
53 .text
|
|
54
|
|
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.
|
173
|
58 # CHECK: <prologue1_calls_split>:
|
150
|
59 # CHECK-NEXT: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%rsp
|
|
60 # CHECK: jae{{.*$}}
|
|
61 # CHECK-NEXT: callq{{.*}}<__morestack>
|
|
62
|
|
63 prologue1 split
|
|
64
|
|
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.
|
173
|
68 # CHECK: <prologue2_calls_splitr10>:
|
150
|
69 # CHECK-NEXT: lea{{.*}} -512(%rsp),{{.*}}%r10
|
|
70 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}
|
|
71 # CHECK: jae{{.*}}
|
|
72 # CHECK-NEXT: callq{{.*}}<__morestack>
|
|
73
|
|
74 prologue2 split r10 0x200
|
|
75
|
173
|
76 # CHECK: <prologue2_calls_splitr11>:
|
150
|
77 # CHECK-NEXT: lea{{.*}} -256(%rsp),{{.*}}%r11
|
|
78 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r{{[0-9]+}}
|
|
79 # CHECK: jae{{.*}}
|
|
80 # CHECK-NEXT: callq{{.*}}<__morestack>
|
|
81
|
|
82 prologue2 split r11 0x100
|
|
83
|
|
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.
|
173
|
87 # CHECK: <prologue1_calls_non_split>:
|
150
|
88 # CHECK-NEXT: stc{{.*$}}
|
|
89 # CHECK-NEXT: nopl{{.*$}}
|
|
90 # CHECK: jae{{.*$}}
|
|
91 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
|
|
92
|
|
93 prologue1 non_split
|
|
94
|
|
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
|
173
|
98 # CHECK: <prologue2_calls_non_splitr10>:
|
150
|
99 # CHECK-NEXT: lea{{.*}} -16640(%rsp),{{.*}}%r10
|
|
100 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r10
|
|
101 # CHECK: jae{{.*$}}
|
|
102 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
|
|
103
|
|
104 prologue2 non_split r10 0x100
|
|
105
|
173
|
106 # CHECK: <prologue2_calls_non_splitr11>:
|
150
|
107 # CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11
|
|
108 # CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11
|
|
109 # CHECK: jae{{.*$}}
|
|
110 # CHECK-NEXT: callq{{.*}}<__morestack_non_split>
|
|
111
|
|
112 prologue2 non_split r11 0x200
|
|
113
|
|
114 .section .note.GNU-stack,"",@progbits
|
|
115 .section .note.GNU-split-stack,"",@progbits
|