1- //@ revisions: all strong basic none missing
1+ //@ revisions: all rusty strong basic none missing
22//@ assembly-output: emit-asm
33//@ only-windows
44//@ only-msvc
55//@ ignore-32bit 64-bit table based SEH has slightly different behaviors than classic SEH
66//@ [all] compile-flags: -Z stack-protector=all
7+ //@ [rusty] compile-flags: -Z stack-protector=rusty
78//@ [strong] compile-flags: -Z stack-protector=strong
89//@ [basic] compile-flags: -Z stack-protector=basic
910//@ [none] compile-flags: -Z stack-protector=none
1617#[ no_mangle]
1718pub fn emptyfn ( ) {
1819 // all: __security_check_cookie
20+ // rusty-NOT: __security_check_cookie
1921 // strong-NOT: __security_check_cookie
2022 // basic-NOT: __security_check_cookie
2123 // none-NOT: __security_check_cookie
@@ -34,6 +36,7 @@ pub fn array_char(f: fn(*const char)) {
3436 f ( & c as * const _ ) ;
3537
3638 // all: __security_check_cookie
39+ // rusty: __security_check_cookie
3740 // strong: __security_check_cookie
3841 // basic: __security_check_cookie
3942 // none-NOT: __security_check_cookie
@@ -50,6 +53,7 @@ pub fn array_u8_1(f: fn(*const u8)) {
5053 // array variables regardless of their size.
5154
5255 // all: __security_check_cookie
56+ // rusty: __security_check_cookie
5357 // strong: __security_check_cookie
5458 // basic-NOT: __security_check_cookie
5559 // none-NOT: __security_check_cookie
@@ -67,6 +71,7 @@ pub fn array_u8_small(f: fn(*const u8)) {
6771 // Small arrays do not lead to stack protection by the 'basic' heuristic.
6872
6973 // all: __security_check_cookie
74+ // rusty: __security_check_cookie
7075 // strong: __security_check_cookie
7176 // basic-NOT: __security_check_cookie
7277 // none-NOT: __security_check_cookie
@@ -83,6 +88,7 @@ pub fn array_u8_large(f: fn(*const u8)) {
8388 // will also protect this function.
8489
8590 // all: __security_check_cookie
91+ // rusty: __security_check_cookie
8692 // strong: __security_check_cookie
8793 // basic: __security_check_cookie
8894 // none-NOT: __security_check_cookie
@@ -102,6 +108,7 @@ pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) {
102108 // also protect this function.
103109
104110 // all: __security_check_cookie
111+ // rusty: __security_check_cookie
105112 // strong: __security_check_cookie
106113 // basic: __security_check_cookie
107114 // none-NOT: __security_check_cookie
@@ -129,6 +136,7 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
129136 // ```
130137
131138 // all: __security_check_cookie
139+ // rusty: __security_check_cookie
132140 // strong: __security_check_cookie
133141 // basic-NOT: __security_check_cookie
134142 // none-NOT: __security_check_cookie
@@ -164,9 +172,10 @@ pub fn local_string_addr_taken(f: fn(&String)) {
164172 // LLVM does not support generating stack protectors in functions with funclet
165173 // based EH personalities.
166174 // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4
175+
167176 // all-NOT: __security_check_cookie
177+ // rusty-NOT: __security_check_cookie
168178 // strong-NOT: __security_check_cookie
169-
170179 // basic-NOT: __security_check_cookie
171180 // none-NOT: __security_check_cookie
172181 // missing-NOT: __security_check_cookie
@@ -197,6 +206,10 @@ pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32
197206 // the `strong` heuristic.
198207
199208 // all: __security_check_cookie
209+
210+ // FIXME: rusty stack smash protection needs to support inline scenario detection
211+ // rusty: __security_check_cookie
212+
200213 // strong-NOT: __security_check_cookie
201214 // basic-NOT: __security_check_cookie
202215 // none-NOT: __security_check_cookie
@@ -234,6 +247,10 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) {
234247 // ```
235248
236249 // all: __security_check_cookie
250+
251+ // FIXME: How does the rust compiler handle moves of large structures?
252+ // rusty-NOT: __security_check_cookie
253+
237254 // strong: __security_check_cookie
238255 // basic: __security_check_cookie
239256 // none-NOT: __security_check_cookie
@@ -263,6 +280,10 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
263280 // ```
264281
265282 // all: __security_check_cookie
283+
284+ // FIXME: How does the rust compiler handle moves of large structures?
285+ // rusty-NOT: __security_check_cookie
286+
266287 // strong: __security_check_cookie
267288 // basic: __security_check_cookie
268289 // none-NOT: __security_check_cookie
@@ -303,6 +324,12 @@ pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) {
303324 f ( unsafe { alloca ( 8 ) } ) ;
304325
305326 // 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+
306333 // strong-NOT: __security_check_cookie
307334 // basic-NOT: __security_check_cookie
308335 // none-NOT: __security_check_cookie
@@ -315,6 +342,7 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
315342 f ( unsafe { alloca ( 9 ) } ) ;
316343
317344 // all: __security_check_cookie
345+ // rusty: __security_check_cookie
318346 // strong-NOT: __security_check_cookie
319347 // basic-NOT: __security_check_cookie
320348 // none-NOT: __security_check_cookie
@@ -327,6 +355,7 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
327355 f ( unsafe { alloca ( n) } ) ;
328356
329357 // all: __security_check_cookie
358+ // rusty: __security_check_cookie
330359 // strong-NOT: __security_check_cookie
331360 // basic-NOT: __security_check_cookie
332361 // none-NOT: __security_check_cookie
@@ -358,6 +387,7 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
358387 // based EH personalities.
359388 // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4
360389 // all-NOT: __security_check_cookie
390+ // rusty-NOT: __security_check_cookie
361391 // strong-NOT: __security_check_cookie
362392
363393 // basic-NOT: __security_check_cookie
0 commit comments