diff options
Diffstat (limited to 'community/rust/static-pie.patch')
-rw-r--r-- | community/rust/static-pie.patch | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/community/rust/static-pie.patch b/community/rust/static-pie.patch index daee42f286..542dbffb88 100644 --- a/community/rust/static-pie.patch +++ b/community/rust/static-pie.patch @@ -1,5 +1,5 @@ From: Shiz <hi@shiz.me> -Date: Tue, 11 Apr 2017 04:37:00 +0200 +Last-Updated: Sun, 20 May 2018 00:05:00 +0200 Subject: [PATCH] Add support for static PIE executables Note that static PIE binaries are reported as dynamically linked by file(1): @@ -42,9 +42,9 @@ library, just like static binaries, but more secure. --- a/src/librustc_back/target/linux_musl_base.rs +++ b/src/librustc_back/target/linux_musl_base.rs -@@ -22,5 +22,8 @@ - // Except for on MIPS, these targets statically link libc by default. - base.crt_static_default = true; +@@ -25,5 +25,8 @@ + // These targets allow the user to choose between static and dynamic linking. + base.crt_static_respected = true; + // Static position-independent executables are supported. + base.static_position_independent_executables = true; @@ -53,7 +53,7 @@ library, just like static binaries, but more secure. } --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs -@@ -350,6 +350,8 @@ +@@ -388,6 +388,8 @@ /// the functions in the executable are not randomized and can be used /// during an exploit of a vulnerability in any code. pub position_independent_executables: bool, @@ -62,36 +62,36 @@ library, just like static binaries, but more secure. /// Either partial, full, or off. Full RELRO makes the dynamic linker /// resolve all symbols at startup and marks the GOT read-only before /// starting the program, preventing overwriting the GOT. -@@ -434,7 +436,8 @@ +@@ -519,7 +519,8 @@ has_rpath: false, no_default_libraries: true, position_independent_executables: false, + static_position_independent_executables: false, - relro_level: RelroLevel::Off, + relro_level: RelroLevel::None, pre_link_objects_exe: Vec::new(), pre_link_objects_dll: Vec::new(), post_link_objects: Vec::new(), --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs -@@ -914,13 +914,9 @@ +@@ -994,13 +994,9 @@ + let mut position_independent_executable = false; - if crate_type == config::CrateTypeExecutable && - t.options.position_independent_executables { -- let empty_vec = Vec::new(); -- let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec); -- let more_args = &sess.opts.cg.link_arg; -- let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter()); + if t.options.position_independent_executables { +- let empty_vec = Vec::new(); +- let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec); +- let more_args = &sess.opts.cg.link_arg; +- let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter()); - -+ let static_pie = t.options.static_position_independent_executables; - if get_reloc_model(sess) == llvm::RelocMode::PIC -- && !sess.crt_static() && !args.any(|x| *x == "-static") { -+ && (!sess.crt_static() || static_pie) { - cmd.position_independent_executable(); ++ let static_pie = t.options.static_position_independent_executables; + if get_reloc_model(sess) == llvm::RelocMode::PIC +- && !sess.crt_static() && !args.any(|x| *x == "-static") { ++ && (!sess.crt_static() || static_pie) { + position_independent_executable = true; + } } - } --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs -@@ -612,7 +612,8 @@ +@@ -778,7 +778,8 @@ key!(has_rpath, bool); key!(no_default_libraries, bool); key!(position_independent_executables, bool); @@ -100,7 +100,7 @@ library, just like static binaries, but more secure. key!(archive_format); key!(allow_asm, bool); key!(custom_unwind_resume, bool); -@@ -776,7 +777,8 @@ +@@ -981,7 +981,8 @@ target_option_val!(has_rpath); target_option_val!(no_default_libraries); target_option_val!(position_independent_executables); |