Skip to content

Commit 31e94ff

Browse files
committed
Set -Cpanic=abort in windows-msvc stack protector tests
1 parent daa77e6 commit 31e94ff

File tree

3 files changed

+14
-62
lines changed

3 files changed

+14
-62
lines changed

tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//@ [strong] compile-flags: -Z stack-protector=strong
88
//@ [basic] compile-flags: -Z stack-protector=basic
99
//@ [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
1111

1212
#![crate_type = "lib"]
1313
#![allow(internal_features)]
@@ -143,26 +143,11 @@ pub fn local_string_addr_taken(f: fn(&String)) {
143143
f(&x);
144144

145145
// 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-
//
146+
// protection. It does not matter that the reference is not mut.
162147

163148
// all: __security_check_cookie
164-
// strong-NOT: __security_check_cookie
165-
// basic-NOT: __security_check_cookie
149+
// strong: __security_check_cookie
150+
// basic: __security_check_cookie
166151
// none-NOT: __security_check_cookie
167152
// missing-NOT: __security_check_cookie
168153
}
@@ -346,13 +331,8 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
346331
// alloca, and is therefore not protected by the `strong` or `basic`
347332
// heuristics.
348333

349-
// We should have a __security_check_cookie call in `all` and `strong` modes but
350-
// LLVM does not support generating stack protectors in functions with funclet
351-
// based EH personalities.
352-
// https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4
353-
// all-NOT: __security_check_cookie
354-
// strong-NOT: __security_check_cookie
355-
334+
// all: __security_check_cookie
335+
// strong: __security_check_cookie
356336
// basic-NOT: __security_check_cookie
357337
// none-NOT: __security_check_cookie
358338
// missing-NOT: __security_check_cookie

tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//@ [strong] compile-flags: -Z stack-protector=strong
88
//@ [basic] compile-flags: -Z stack-protector=basic
99
//@ [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
1111

1212
#![crate_type = "lib"]
1313
#![feature(unsized_fn_params)]
@@ -138,40 +138,17 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
138138
// CHECK-LABEL: local_string_addr_taken
139139
#[no_mangle]
140140
pub fn local_string_addr_taken(f: fn(&String)) {
141-
// CHECK-DAG: .seh_endprologue
142141
let x = String::new();
143142
f(&x);
144143

145144
// 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.
162146

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
171150
// none-NOT: __security_check_cookie
172151
// missing-NOT: __security_check_cookie
173-
174-
// CHECK-DAG: .seh_endproc
175152
}
176153

177154
pub trait SelfByRef {
@@ -353,13 +330,8 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
353330
// alloca, and is therefore not protected by the `strong` or `basic`
354331
// heuristics.
355332

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
363335
// basic-NOT: __security_check_cookie
364336
// none-NOT: __security_check_cookie
365337
// missing-NOT: __security_check_cookie

tests/assembly-llvm/stack-protector/stack-protector-target-support.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
//@ [r84] needs-llvm-components: x86
174174
//@ [r85] compile-flags: --target x86_64-unknown-redox
175175
//@ [r85] needs-llvm-components: x86
176-
//@ compile-flags: -Z stack-protector=all
176+
//@ compile-flags: -Z stack-protector=all -Cpanic=abort
177177
//@ compile-flags: -C opt-level=2
178178

179179
#![crate_type = "lib"]

0 commit comments

Comments
 (0)