summary refs log tree commit diff
path: root/pkgs/build-support/bintools-wrapper/add-hardening.sh
Commit message (Collapse)AuthorAge
* build-support: Use response-expanded params in pie testPeter Waller2023-06-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a response file is in use, "$*" contains the response file and not the parameters; both the linker and compiler wrappers are updated to use the response-expanded params. The compiler driver likes to pass parameters to the linker via a response file, including -shared. LLD rejects the combination of (-shared -pie), whereas other linkers silently ignore the contradiction: ``` ld.lld: error: -shared and -pie may not be used together ``` This breaks certain configurations using LLD as a linker. Changing `add-hardening.sh` results in a full rebuild. To avoid the rebuild, here is a quick test case which shows the new hardening script allows the link to succeed: ``` { pkgs ? import <nixpkgs> {} }: let # gcc silently accepts -shared -pie together, lld does not. linker = pkgs.wrapBintoolsWith { bintools = pkgs.llvmPackages.lld; }; patchWrapper = prev: prev.overrideAttrs (final: prev: let prevScript = builtins.match (".*(/nix/store/[a-z0-9]+-add-hardening.sh).*") prev.postFixup; in { postFixup = (builtins.replaceStrings prevScript ["${./new-add-hardening.sh}"] prev.postFixup); }); in pkgs.stdenv.mkDerivation { name = "nixpkgs-hardening-bug"; src = pkgs.writeText "src.c" "int main(int argc, char* argv[]) { return 0; }"; NIX_HARDENING_ENABLE = "pie"; unpackPhase = ":"; buildPhase = '' $CC -c -o src.o $src bash -x ${patchWrapper linker}/bin/ld.lld -o $out @${pkgs.writeText "responsefile" "-shared"} src.o ''; } ``` Fixes: #178162 Signed-off-by: Peter Waller <p@pwaller.net>
* {cc,binutils}-wrapper: match leading/trailing argumentsRyan Burns2021-09-20
| | | | | | | | | | | 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
* bintools: disable -pie when -r or -Ur are used (#128674)Matthew Bauer2021-07-15
| | | | | | | | | | | | | | | * 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
* *-wrapper; Switch from `infixSalt` to `suffixSalt`John Ericson2020-05-12
| | | | | | | I hate the thing too even though I made it, and rather just get rid of it. But we can't do that yet. In the meantime, this brings us more inline with autoconf and will make it slightly easier for me to write a pkg-config wrapper, which we need.
* {cc,bintools}-wrapper: fix removal of unsupported hardening flagsPiotr Bogdan2018-04-14
|
* Revert "Revert "Merge pull request #28029 from cstrahan/hardening-fix""John Ericson2018-04-11
| | | | | This reverts commit 6c064e6b1f34a8416f990db0cc617a7195f71588, reapplying PR #28029 which was supposed to have gone to staging all along.
* bintools-wrapper: InitJohn Ericson2017-12-13
Factor a bintools (i.e. binutils / cctools) wrapper out of cc-wrapper. While only LD is wrapped, the setup hook defines environment variables on behalf of other utilites.