diff --git a/pkgs/build-support/bintools-wrapper/ld-wrapper.sh b/pkgs/build-support/bintools-wrapper/ld-wrapper.sh index 7ccf5510c88..e54dd6f4714 100644 --- a/pkgs/build-support/bintools-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/bintools-wrapper/ld-wrapper.sh @@ -102,6 +102,8 @@ declare -a libDirs declare -A libs declare -i relocatable=0 link32=0 +linkerOutput="a.out" + if [ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 1 ] \ || [ "$NIX_SET_BUILD_ID_@suffixSalt@" = 1 ] \ @@ -153,6 +155,24 @@ then done fi +# Determine linkerOutput +prev= +for p in \ + ${extraBefore+"${extraBefore[@]}"} \ + ${params+"${params[@]}"} \ + ${extraAfter+"${extraAfter[@]}"} +do + case "$prev" in + -o) + # Informational for post-link-hook + linkerOutput="$p" + ;; + *) + ;; + esac + prev="$p" +done + if [[ "$link32" = "1" && "$setDynamicLinker" = 1 && -e "@out@/nix-support/dynamic-linker-m32" ]]; then # We have an alternate 32-bit linker and we're producing a 32-bit ELF, let's # use it. @@ -223,7 +243,11 @@ fi PATH="$path_backup" # Old bash workaround, see above. -exec @prog@ \ +@prog@ \ ${extraBefore+"${extraBefore[@]}"} \ ${params+"${params[@]}"} \ ${extraAfter+"${extraAfter[@]}"} + +if [ -e "@out@/nix-support/post-link-hook" ]; then + source @out@/nix-support/post-link-hook +fi