default.nix (2398B)
1 # Spike 1: Penumbra's audit library under vestigia, on x86_64-linux. 2 # 3 # nix build --impure -f etc/spike/penumbra traces 4 # 5 # Two builds are traced. `audited` is the engagement's own library: 6 # the exact machine code audited, whose sites carry function names 7 # but no source lines. `lines` is the same build with line tables 8 # kept, so its sites name source lines. Keeping them perturbs the 9 # crate's symbol hashes and a few inlining decisions (16 of 546 10 # functions differ once names and addresses are normalised), so the 11 # two are compared by function. 12 let 13 system = "x86_64-linux"; 14 vestigia = builtins.getFlake (toString ../../..); 15 penumbra = builtins.getFlake 16 "path:/Users/jtobin/src/ppad/research/corpus/penumbra/harness"; 17 pkgs = import vestigia.inputs.nixpkgs { inherit system; }; 18 19 audited = penumbra.packages.${system}.audit; 20 21 lines = audited.overrideAttrs (o: { 22 pname = "penumbra-audit-lines"; 23 CARGO_PROFILE_RELEASE_DEBUG = "line-tables-only"; 24 dontStrip = true; 25 }); 26 27 harnessFor = lib: pkgs.runCommandCC "penumbra-vestigia-harness" { } '' 28 mkdir -p $out/bin 29 cc -O2 -g -o $out/bin/harness ${./harness.c} \ 30 ${vestigia.packages.${system}.include}/include/vestigia.c \ 31 -I${vestigia.packages.${system}.include}/include \ 32 -I${vestigia.lib.${system}.valgrindDev}/include \ 33 -L${lib}/lib -lpenumbra_audit -Wl,-rpath,${lib}/lib 34 ''; 35 36 traceOf = build: lib: root: vestigia.lib.${system}.traceOf { 37 name = "penumbra-${build}-${root}"; 38 harness = "${harnessFor lib}/bin/harness"; 39 runs = [ [ root "4" ] ]; 40 }; 41 42 roots = [ "public_key" "key_agreement" "spend_auth_sign" ]; 43 44 # three processes of two calls each, differing only in the secrets 45 seeds = [ "0000000000000001" "0000000000000002" "0000000000000003" ]; 46 diffOf = build: lib: root: vestigia.lib.${system}.diffOf { 47 name = "penumbra-${build}-${root}"; 48 harness = "${harnessFor lib}/bin/harness"; 49 runs = map (s: [ root "2" s ]) seeds; 50 objects = [ "libpenumbra_audit" ]; 51 }; 52 in 53 { 54 inherit audited lines; 55 56 diffs = pkgs.linkFarm "penumbra-diffs" ( 57 map (r: { name = "lines/${r}"; path = diffOf "lines" lines r; }) 58 roots); 59 60 traces = pkgs.linkFarm "penumbra-traces" ( 61 map (r: { name = "audited/${r}"; path = traceOf "audited" audited r; }) 62 roots 63 ++ map (r: { name = "lines/${r}"; path = traceOf "lines" lines r; }) 64 roots); 65 }