Skip to content

Commit

Permalink
bindiff: init at 8-unstable-2024-11-11
Browse files Browse the repository at this point in the history
  • Loading branch information
pluiedev committed Dec 23, 2024
1 parent a254a9e commit ff07c69
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkgs/by-name/bi/bindiff/allow-compilation-without-ida.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/cmake/BinDiffDeps.cmake b/cmake/BinDiffDeps.cmake
index 057b978..3db6749 100644
--- a/cmake/BinDiffDeps.cmake
+++ b/cmake/BinDiffDeps.cmake
@@ -29,6 +29,8 @@ if(NOT sqlite_POPULATED)
endif()

# Setup IDA SDK. Uses FindIdaSdk.cmake from BinExport
+if(BINEXPORT_ENABLE_IDAPRO)
find_package(IdaSdk)
+endif()

find_package(Protobuf 3.14 REQUIRED) # Make protobuf_generate_cpp available
94 changes: 94 additions & 0 deletions pkgs/by-name/bi/bindiff/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchzip,

cmake,
ninja,
git,

binexport,
boost183,

nix-update-script,

enableIDA ? false,
}:
let
binexport' = binexport.override { inherit enableIDA; };

# needs a fixed version:
# https://github.com/google/bindiff/blob/c8972f08a3438049f2f5e81439a70ee56f95c549/cmake/BinDiffDeps.cmake#L16-L19
sqlite = fetchzip {
url = "https://sqlite.org/2024/sqlite-amalgamation-3450100.zip";
hash = "sha256-bJoMjirsBjm2Qk9KPiy3yV3+8b/POlYe76/FQbciHro=";
};

inherit (stdenv.hostPlatform.extensions) sharedLibrary;
in
stdenv.mkDerivation (finalAttrs: {
pname = "bindiff";
version = "8-unstable-2024-11-11";

src = fetchFromGitHub {
owner = "google";
repo = "bindiff";
rev = "c8972f08a3438049f2f5e81439a70ee56f95c549";
hash = "sha256-5EVlrQqtzPPrjmoCJ/SlvSo2bRklvwveslPfeq8CN6A=";
};

patches = [ ./allow-compilation-without-ida.patch ];

nativeBuildInputs = [
cmake
ninja
git
];

buildInputs = [
boost183
];

cmakeFlags = [
(lib.cmakeFeature "BINDIFF_BINEXPORT_DIR" "${binexport'.src}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_SQLITE" "${sqlite}")
] ++ binexport'.cmakeFlags;

postInstall =
''
mkdir -p $out/bin
mv $out/bindiff-prefix/bindiff{,_config_setup} $out/bin
''
+ lib.optionalString enableIDA ''
mkdir -p $out/lib
mv $out/bindiff-prefix/bindiff*_ida*${sharedLibrary} $out/lib
''
+ ''
rmdir $out/bindiff-prefix
'';

passthru.updateScript = nix-update-script { };

meta = {
description = "Quickly find differences and similarities in disassembled code";
longDescription = ''
BinDiff doesn't compile the IDA plugin by default as it requires a copy
of the proprietary IDA SDK.
If you use IDA, you can override this package with `enableIDA` set to true:
```nix
bindiff.override { enableIDA = true; }
```
Note that this would render the entire package unfree and non-redistributable
due to the closed-source, proprietary nature of IDA and its SDK.
'';
homepage = "https://zynamics.com/bindiff.html";
license = with lib.licenses; [ asl20 ];
platforms = with lib.platforms; lib.intersectLists x86 (unix ++ windows);
maintainers = with lib.maintainers; [
pluiedev
BonusPlay
];
};
})

0 comments on commit ff07c69

Please sign in to comment.