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
This commit is contained in:
parent
ed4094a728
commit
f5074933b7
|
@ -37,7 +37,7 @@ fi
|
||||||
for flag in "${!hardeningEnableMap[@]}"; do
|
for flag in "${!hardeningEnableMap[@]}"; do
|
||||||
case $flag in
|
case $flag in
|
||||||
pie)
|
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
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi
|
||||||
hardeningLDFlags+=('-pie')
|
hardeningLDFlags+=('-pie')
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue