about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-18 11:28:01 +0100
committerGitHub <noreply@github.com>2021-12-18 11:28:01 +0100
commit069ffec6373af8ad7027b74e7b43b042d83308bf (patch)
treeb63574c9a1a8720ce24a54ae2e8726e749b70747 /compiler/rustc_codegen_ssa/src
parent208ced64db20bd947a2ba5c90f37936fd3ab352b (diff)
parentc3da28eade867f731d8169a8c143e33353006e29 (diff)
downloadrust-069ffec6373af8ad7027b74e7b43b042d83308bf.tar.gz
rust-069ffec6373af8ad7027b74e7b43b042d83308bf.zip
Rollup merge of #91858 - semarie:runpath, r=petrochenkov
pass -Wl,-z,origin to set DF_ORIGIN when using rpath

DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string.

Some implementations are just ignoring [DF_ORIGIN](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#df_flags) and do [substitution](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#substitution) for $ORIGIN if present (whatever DF_ORIGIN presence or not) like glibc. But some others mandate the present of DF_ORIGIN for the substitution (like OpenBSD).

Set the flag inconditionally if rpath is wanted.

One possible fallout is if the linker rejects `-z origin` option.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/rpath.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/rpath.rs b/compiler/rustc_codegen_ssa/src/back/rpath.rs
index 61c3ef62fb1..0b5656c9ad1 100644
--- a/compiler/rustc_codegen_ssa/src/back/rpath.rs
+++ b/compiler/rustc_codegen_ssa/src/back/rpath.rs
@@ -23,9 +23,12 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
     let rpaths = get_rpaths(config);
     let mut flags = rpaths_to_flags(&rpaths);
 
-    // Use DT_RUNPATH instead of DT_RPATH if available
     if config.linker_is_gnu {
+        // Use DT_RUNPATH instead of DT_RPATH if available
         flags.push("-Wl,--enable-new-dtags".to_owned());
+
+        // Set DF_ORIGIN for substitute $ORIGIN
+        flags.push("-Wl,-z,origin".to_owned());
     }
 
     flags