cc-wrapper: Check if ld supports -z, fixes darwin
This commit is contained in:
parent
b2b499e6c4
commit
baee91ec60
@ -2,11 +2,16 @@ hardeningFlags=(fortify stackprotector pic strictoverflow format relro bindnow)
|
|||||||
hardeningFlags+=("${hardeningEnable[@]}")
|
hardeningFlags+=("${hardeningEnable[@]}")
|
||||||
hardeningCFlags=()
|
hardeningCFlags=()
|
||||||
hardeningLDFlags=()
|
hardeningLDFlags=()
|
||||||
|
hardeningDisable=(${hardeningDisable[@]})
|
||||||
|
|
||||||
|
if [[ "$($LD -z 2>&1)" =~ "unknown option" ]]; then
|
||||||
|
hardeningDisable+=(bindnow relro)
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! $hardeningDisable == "all" ]]; then
|
if [[ ! $hardeningDisable == "all" ]]; then
|
||||||
for flag in "${hardeningFlags[@]}"
|
for flag in "${hardeningFlags[@]}"
|
||||||
do
|
do
|
||||||
if [[ ! "$hardeningDisable" =~ "$flag" ]]; then
|
if [[ ! "${hardeningDisable[@]}" =~ "$flag" ]]; then
|
||||||
case $flag in
|
case $flag in
|
||||||
fortify)
|
fortify)
|
||||||
hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2')
|
hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2')
|
||||||
|
@ -89,6 +89,7 @@ if [[ "@prog@" = *++ ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LD=@ldPath@/ld
|
||||||
source @out@/nix-support/add-hardening.sh
|
source @out@/nix-support/add-hardening.sh
|
||||||
|
|
||||||
# Add the flags for the C compiler proper.
|
# Add the flags for the C compiler proper.
|
||||||
|
@ -47,6 +47,7 @@ if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \
|
|||||||
params=("${rest[@]}")
|
params=("${rest[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LD=@prog@
|
||||||
source @out@/nix-support/add-hardening.sh
|
source @out@/nix-support/add-hardening.sh
|
||||||
|
|
||||||
extra=(${hardeningLDFlags[@]})
|
extra=(${hardeningLDFlags[@]})
|
||||||
|
@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
|
|||||||
nativeBuildInputs = [ m4 ];
|
nativeBuildInputs = [ m4 ];
|
||||||
|
|
||||||
# FIXME needs gcc 4.9 in bootstrap tools
|
# FIXME needs gcc 4.9 in bootstrap tools
|
||||||
hardeningDisable = [ "stackprotector" ];
|
hardeningDisable = [ "format" "stackprotector" ];
|
||||||
|
|
||||||
patches = if stdenv.isDarwin then [ ./need-size-t.patch ] else null;
|
patches = if stdenv.isDarwin then [ ./need-size-t.patch ] else null;
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ stdenv.mkDerivation rec {
|
|||||||
inherit sha256;
|
inherit sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hardeningDisable = [ "format" ];
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
outputs = [ "out" "doc" ];
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = ''
|
NIX_CFLAGS_COMPILE = ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user