Skip to content

Commit d5ed2d4

Browse files
committed
Implement stack protector
1 parent 2453a68 commit d5ed2d4

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/gcc_util.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gccjit::Version;
77
use rustc_codegen_ssa::target_features;
88
use rustc_data_structures::smallvec::{SmallVec, smallvec};
99
use rustc_session::Session;
10-
use rustc_target::spec::{Arch, RelocModel};
10+
use rustc_target::spec::{Arch, RelocModel, StackProtector};
1111

1212
fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
1313
target_features::retpoline_features_by_flags(sess, features);
@@ -204,6 +204,13 @@ pub fn new_context<'gcc>(sess: &Session) -> Context<'gcc> {
204204
});
205205
}
206206

207+
match sess.stack_protector() {
208+
StackProtector::All => context.add_command_line_option("-fstack-protector-all"),
209+
StackProtector::Strong => context.add_command_line_option("-fstack-protector-strong"),
210+
StackProtector::Basic => context.add_command_line_option("-fstack-protector"),
211+
StackProtector::None => (),
212+
}
213+
207214
add_pic_option(&context, sess.relocation_model());
208215

209216
let target_cpu = target_cpu(sess);

tests/failing-ui-tests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,5 @@ tests/ui/eii/static/default_cross_crate_explicit.rs
106106
tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs
107107
tests/ui/abi/rust-tail-cc.rs
108108
tests/ui/abi/rust-preserve-none-cc.rs
109-
tests/ui/abi/stack-protector.rs
110109
tests/ui/extern/extern-types-field-offset.rs
111110
tests/ui/abi/stack-probes-lto.rs

0 commit comments

Comments
 (0)