{cc,binutils}-wrapper: match leading/trailing arguments

fixes e.g.:
pkgsMusl.libfsm
pkgsMusl.libiscsi
pkgsMusl.nsjail
pkgsMusl.pv

match strings have whitespace on either side, which wasn't
matching leading/trailing arguments previously
This commit is contained in:
Ryan Burns 2021-09-20 17:24:04 -07:00
parent bd8258a389
commit 37d089c1af
2 changed files with 6 additions and 2 deletions

View file

@ -37,7 +37,11 @@ fi
for flag in "${!hardeningEnableMap[@]}"; do
case $flag in
pie)
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static " || "$*" =~ " -r " || "$*" =~ " -Ur " || "$*" =~ " -i ") ]]; then
if [[ ! (" $* " =~ " -shared " \
|| " $* " =~ " -static " \
|| " $* " =~ " -r " \
|| " $* " =~ " -Ur " \
|| " $* " =~ " -i ") ]]; then
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi
hardeningLDFlags+=('-pie')
fi

View file

@ -48,7 +48,7 @@ for flag in "${!hardeningEnableMap[@]}"; do
# NB: we do not use `+=` here, because PIE flags must occur before any PIC flags
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling CFlags -fPIE >&2; fi
hardeningCFlags=('-fPIE' "${hardeningCFlags[@]}")
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
if [[ ! (" $* " =~ " -shared " || " $* " =~ " -static ") ]]; then
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi
hardeningCFlags=('-pie' "${hardeningCFlags[@]}")
fi