1
- //@ revisions: all strong basic none missing
1
+ //@ revisions: all rusty strong basic none missing
2
2
//@ assembly-output: emit-asm
3
3
//@ only-windows
4
4
//@ only-msvc
5
5
//@ ignore-32bit 64-bit table based SEH has slightly different behaviors than classic SEH
6
6
//@ [all] compile-flags: -Z stack-protector=all
7
+ //@ [rusty] compile-flags: -Z stack-protector=rusty
7
8
//@ [strong] compile-flags: -Z stack-protector=strong
8
9
//@ [basic] compile-flags: -Z stack-protector=basic
9
10
//@ [none] compile-flags: -Z stack-protector=none
16
17
#[ no_mangle]
17
18
pub fn emptyfn ( ) {
18
19
// all: __security_check_cookie
20
+ // rusty-NOT: __security_check_cookie
19
21
// strong-NOT: __security_check_cookie
20
22
// basic-NOT: __security_check_cookie
21
23
// none-NOT: __security_check_cookie
@@ -34,6 +36,7 @@ pub fn array_char(f: fn(*const char)) {
34
36
f ( & c as * const _ ) ;
35
37
36
38
// all: __security_check_cookie
39
+ // rusty: __security_check_cookie
37
40
// strong: __security_check_cookie
38
41
// basic: __security_check_cookie
39
42
// none-NOT: __security_check_cookie
@@ -50,6 +53,7 @@ pub fn array_u8_1(f: fn(*const u8)) {
50
53
// array variables regardless of their size.
51
54
52
55
// all: __security_check_cookie
56
+ // rusty: __security_check_cookie
53
57
// strong: __security_check_cookie
54
58
// basic-NOT: __security_check_cookie
55
59
// none-NOT: __security_check_cookie
@@ -67,6 +71,7 @@ pub fn array_u8_small(f: fn(*const u8)) {
67
71
// Small arrays do not lead to stack protection by the 'basic' heuristic.
68
72
69
73
// all: __security_check_cookie
74
+ // rusty: __security_check_cookie
70
75
// strong: __security_check_cookie
71
76
// basic-NOT: __security_check_cookie
72
77
// none-NOT: __security_check_cookie
@@ -83,6 +88,7 @@ pub fn array_u8_large(f: fn(*const u8)) {
83
88
// will also protect this function.
84
89
85
90
// all: __security_check_cookie
91
+ // rusty: __security_check_cookie
86
92
// strong: __security_check_cookie
87
93
// basic: __security_check_cookie
88
94
// none-NOT: __security_check_cookie
@@ -102,6 +108,7 @@ pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) {
102
108
// also protect this function.
103
109
104
110
// all: __security_check_cookie
111
+ // rusty: __security_check_cookie
105
112
// strong: __security_check_cookie
106
113
// basic: __security_check_cookie
107
114
// none-NOT: __security_check_cookie
@@ -129,6 +136,7 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
129
136
// ```
130
137
131
138
// all: __security_check_cookie
139
+ // rusty: __security_check_cookie
132
140
// strong: __security_check_cookie
133
141
// basic-NOT: __security_check_cookie
134
142
// none-NOT: __security_check_cookie
@@ -164,9 +172,10 @@ pub fn local_string_addr_taken(f: fn(&String)) {
164
172
// LLVM does not support generating stack protectors in functions with funclet
165
173
// based EH personalities.
166
174
// https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4
175
+
167
176
// all-NOT: __security_check_cookie
177
+ // rusty-NOT: __security_check_cookie
168
178
// strong-NOT: __security_check_cookie
169
-
170
179
// basic-NOT: __security_check_cookie
171
180
// none-NOT: __security_check_cookie
172
181
// missing-NOT: __security_check_cookie
@@ -197,6 +206,10 @@ pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32
197
206
// the `strong` heuristic.
198
207
199
208
// all: __security_check_cookie
209
+
210
+ // FIXME: rusty stack smash protection needs to support inline scenario detection
211
+ // rusty: __security_check_cookie
212
+
200
213
// strong-NOT: __security_check_cookie
201
214
// basic-NOT: __security_check_cookie
202
215
// none-NOT: __security_check_cookie
@@ -234,6 +247,10 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) {
234
247
// ```
235
248
236
249
// all: __security_check_cookie
250
+
251
+ // FIXME: How does the rust compiler handle moves of large structures?
252
+ // rusty-NOT: __security_check_cookie
253
+
237
254
// strong: __security_check_cookie
238
255
// basic: __security_check_cookie
239
256
// none-NOT: __security_check_cookie
@@ -263,6 +280,10 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
263
280
// ```
264
281
265
282
// all: __security_check_cookie
283
+
284
+ // FIXME: How does the rust compiler handle moves of large structures?
285
+ // rusty-NOT: __security_check_cookie
286
+
266
287
// strong: __security_check_cookie
267
288
// basic: __security_check_cookie
268
289
// none-NOT: __security_check_cookie
@@ -303,6 +324,12 @@ pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) {
303
324
f ( unsafe { alloca ( 8 ) } ) ;
304
325
305
326
// all: __security_check_cookie
327
+
328
+ // FIXME: Rusty thinks a function that returns a mutable raw pointer may
329
+ // be a stack memory allocation function, so it performs stack smash protection.
330
+ // Is it possible to optimize the heuristics?
331
+ // rusty: __security_check_cookie
332
+
306
333
// strong-NOT: __security_check_cookie
307
334
// basic-NOT: __security_check_cookie
308
335
// none-NOT: __security_check_cookie
@@ -315,6 +342,7 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
315
342
f ( unsafe { alloca ( 9 ) } ) ;
316
343
317
344
// all: __security_check_cookie
345
+ // rusty: __security_check_cookie
318
346
// strong-NOT: __security_check_cookie
319
347
// basic-NOT: __security_check_cookie
320
348
// none-NOT: __security_check_cookie
@@ -327,6 +355,7 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
327
355
f ( unsafe { alloca ( n) } ) ;
328
356
329
357
// all: __security_check_cookie
358
+ // rusty: __security_check_cookie
330
359
// strong-NOT: __security_check_cookie
331
360
// basic-NOT: __security_check_cookie
332
361
// none-NOT: __security_check_cookie
@@ -358,6 +387,7 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
358
387
// based EH personalities.
359
388
// https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4
360
389
// all-NOT: __security_check_cookie
390
+ // rusty-NOT: __security_check_cookie
361
391
// strong-NOT: __security_check_cookie
362
392
363
393
// basic-NOT: __security_check_cookie
0 commit comments