Skip to content

Commit 2cbffd5

Browse files
author
Ali Clark
committed
actively disable stack execution on linux and bsd
1 parent 7dce32e commit 2cbffd5

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/librustc_back/target/dragonfly_base.rs

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub fn opts() -> TargetOptions {
2424
// libraries which follow this flag. Thus, use it before
2525
// specifying libraries to link to.
2626
"-Wl,--as-needed".to_string(),
27+
28+
// Always enable NX protection when it is available
29+
"-Wl,-z,noexecstack".to_string(),
2730
),
2831
position_independent_executables: true,
2932
archive_format: "gnu".to_string(),

src/librustc_back/target/freebsd_base.rs

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ pub fn opts() -> TargetOptions {
1717
dynamic_linking: true,
1818
executables: true,
1919
has_rpath: true,
20+
pre_link_args: vec![
21+
// We want to be able to strip as much executable code as possible
22+
// from the linker command line, and this flag indicates to the
23+
// linker that it can avoid linking in dynamic libraries that don't
24+
// actually satisfy any symbols up to that point (as with many other
25+
// resolutions the linker does). This option only applies to all
26+
// following libraries so we're sure to pass it as one of the first
27+
// arguments.
28+
"-Wl,--as-needed".to_string(),
29+
30+
// Always enable NX protection when it is available
31+
"-Wl,-z,noexecstack".to_string(),
32+
],
2033
archive_format: "gnu".to_string(),
2134
exe_allocation_crate: super::maybe_jemalloc(),
2235

src/librustc_back/target/linux_base.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ pub fn opts() -> TargetOptions {
2626
// following libraries so we're sure to pass it as one of the first
2727
// arguments.
2828
"-Wl,--as-needed".to_string(),
29+
30+
// Always enable NX protection when it is available
31+
"-Wl,-z,noexecstack".to_string(),
2932
],
3033
position_independent_executables: true,
3134
archive_format: "gnu".to_string(),

src/librustc_back/target/netbsd_base.rs

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub fn opts() -> TargetOptions {
2424
// libraries which follow this flag. Thus, use it before
2525
// specifying libraries to link to.
2626
"-Wl,--as-needed".to_string(),
27+
28+
// Always enable NX protection when it is available
29+
"-Wl,-z,noexecstack".to_string(),
2730
),
2831
position_independent_executables: true,
2932
archive_format: "gnu".to_string(),

src/librustc_back/target/openbsd_base.rs

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub fn opts() -> TargetOptions {
2424
// libraries which follow this flag. Thus, use it before
2525
// specifying libraries to link to.
2626
"-Wl,--as-needed".to_string(),
27+
28+
// Always enable NX protection when it is available
29+
"-Wl,-z,noexecstack".to_string(),
2730
),
2831
position_independent_executables: true,
2932
archive_format: "gnu".to_string(),

0 commit comments

Comments
 (0)