summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2021-07-15 20:08:33 -0500
committerGitHub <noreply@github.com>2021-07-15 20:08:33 -0500
commitf5074933b7280ce32e1a756e6468a5321cb885de (patch)
tree8d68e13fea601333a86f788809b53d01210af3d6 /pkgs/build-support
parented4094a728ae4b2465a154057a3b05a46625e9c4 (diff)
downloadnixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.tar
nixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.tar.gz
nixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.tar.bz2
nixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.tar.lz
nixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.tar.xz
nixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.tar.zst
nixpkgs-f5074933b7280ce32e1a756e6468a5321cb885de.zip
bintools: disable -pie when -r or -Ur are used (#128674)
* bintools: disable -pie when -r or -Ur are used

ld’s -r allows you to partially link object files. When -pie is passed with -r, though, we get:

  ld: -r and -pie may not be used together

Most build systems are intelligent enough to pass -no-pie before -r, but we might as well support those that
don’t.

Note: -pie is not enabled by default in Nixpkgs, but it is when you are using musl. So this solution is really
only useful for musl toolchains.

* bintools-wrapper: Add incremental -i check for pie
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/bintools-wrapper/add-hardening.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/build-support/bintools-wrapper/add-hardening.sh b/pkgs/build-support/bintools-wrapper/add-hardening.sh
index 5e49b7bd905..4d289a334b7 100644
--- a/pkgs/build-support/bintools-wrapper/add-hardening.sh
+++ b/pkgs/build-support/bintools-wrapper/add-hardening.sh
@@ -37,7 +37,7 @@ fi
 for flag in "${!hardeningEnableMap[@]}"; do
   case $flag in
     pie)
-      if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
+      if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static " || "$*" =~ " -r " || "$*" =~ " -Ur " || "$*" =~ " -i ") ]]; then
         if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi
         hardeningLDFlags+=('-pie')
       fi