|
7 | 7 | //@ [strong] compile-flags: -Z stack-protector=strong |
8 | 8 | //@ [basic] compile-flags: -Z stack-protector=basic |
9 | 9 | //@ [none] compile-flags: -Z stack-protector=none |
10 | | -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled |
| 10 | +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort |
11 | 11 |
|
12 | 12 | #![crate_type = "lib"] |
13 | 13 | #![feature(unsized_fn_params)] |
@@ -138,40 +138,17 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) { |
138 | 138 | // CHECK-LABEL: local_string_addr_taken |
139 | 139 | #[no_mangle] |
140 | 140 | pub fn local_string_addr_taken(f: fn(&String)) { |
141 | | - // CHECK-DAG: .seh_endprologue |
142 | 141 | let x = String::new(); |
143 | 142 | f(&x); |
144 | 143 |
|
145 | 144 | // Taking the address of the local variable `x` leads to stack smash |
146 | | - // protection with the `strong` heuristic, but not with the `basic` |
147 | | - // heuristic. It does not matter that the reference is not mut. |
148 | | - // |
149 | | - // An interesting note is that a similar function in C++ *would* be |
150 | | - // protected by the `basic` heuristic, because `std::string` has a char |
151 | | - // array internally as a small object optimization: |
152 | | - // ``` |
153 | | - // cat <<EOF | clang++ -O2 -fstack-protector -S -x c++ - -o - | grep stack_chk |
154 | | - // #include <string> |
155 | | - // void f(void (*g)(const std::string&)) { |
156 | | - // std::string x; |
157 | | - // g(x); |
158 | | - // } |
159 | | - // EOF |
160 | | - // ``` |
161 | | - // |
| 145 | + // protection. It does not matter that the reference is not mut. |
162 | 146 |
|
163 | | - // We should have a __security_check_cookie call in `all` and `strong` modes but |
164 | | - // LLVM does not support generating stack protectors in functions with funclet |
165 | | - // based EH personalities. |
166 | | - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 |
167 | | - // all-NOT: __security_check_cookie |
168 | | - // strong-NOT: __security_check_cookie |
169 | | - |
170 | | - // basic-NOT: __security_check_cookie |
| 147 | + // all: __security_check_cookie |
| 148 | + // strong: __security_check_cookie |
| 149 | + // basic: __security_check_cookie |
171 | 150 | // none-NOT: __security_check_cookie |
172 | 151 | // missing-NOT: __security_check_cookie |
173 | | - |
174 | | - // CHECK-DAG: .seh_endproc |
175 | 152 | } |
176 | 153 |
|
177 | 154 | pub trait SelfByRef { |
@@ -353,13 +330,8 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { |
353 | 330 | // alloca, and is therefore not protected by the `strong` or `basic` |
354 | 331 | // heuristics. |
355 | 332 |
|
356 | | - // We should have a __security_check_cookie call in `all` and `strong` modes but |
357 | | - // LLVM does not support generating stack protectors in functions with funclet |
358 | | - // based EH personalities. |
359 | | - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 |
360 | | - // all-NOT: __security_check_cookie |
361 | | - // strong-NOT: __security_check_cookie |
362 | | - |
| 333 | + // all: __security_check_cookie |
| 334 | + // strong: __security_check_cookie |
363 | 335 | // basic-NOT: __security_check_cookie |
364 | 336 | // none-NOT: __security_check_cookie |
365 | 337 | // missing-NOT: __security_check_cookie |
|
0 commit comments