From d730bf9587605e1097137866f2f1d7fad12c1410 Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Mon, 30 Mar 2020 21:36:28 -0700 Subject: [PATCH] link with "libssp" on *-sun-solaris systems LLVM will insert calls to the stack protector functions "__stack_chk_fail" and "__stack_chk_guard" into code in native object files. Some platforms include these symbols directly in libc, but at least historically these have been provided in libssp.so on illumos and Solaris systems. Include "-lssp" in the arguments to the linker when building for those targets. --- src/librustc_target/spec/solaris_base.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/librustc_target/spec/solaris_base.rs b/src/librustc_target/spec/solaris_base.rs index 98a2a0fbc9cc1..1b3ff630aab3f 100644 --- a/src/librustc_target/spec/solaris_base.rs +++ b/src/librustc_target/spec/solaris_base.rs @@ -1,7 +1,20 @@ -use crate::spec::TargetOptions; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { + let mut late_link_args = LinkArgs::new(); + late_link_args.insert( + LinkerFlavor::Gcc, + vec![ + // LLVM will insert calls to the stack protector functions + // "__stack_chk_fail" and "__stack_chk_guard" into code in native + // object files. Some platforms include these symbols directly in + // libc, but at least historically these have been provided in + // libssp.so on illumos and Solaris systems. + "-lssp".to_string(), + ], + ); + TargetOptions { dynamic_linking: true, executables: true, @@ -9,6 +22,7 @@ pub fn opts() -> TargetOptions { target_family: Some("unix".to_string()), is_like_solaris: true, limit_rdylib_exports: false, // Linker doesn't support this + late_link_args, ..Default::default() }