-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bump lief to most recent main * bump lief to most recent main (3414ded8cdcbd9705f7871c66c212b15cd74ea69) * created new nix directory and moved overlay there * had to copy lief derivation from nixpkg for now since lief changed how it is built. * Type annotation fixes Lot of changes to the types in the recent lief. * removed name from Binary * no name for section/symbol of type str (lief-project/LIEF#965) * created a proxy class Binary * added pyright to check tests folder
- Loading branch information
Showing
15 changed files
with
154 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ poetry2nix, poetryOverrides }: | ||
poetry2nix.mkPoetryApplication { | ||
projectDir = ./.; | ||
projectDir = ../.; | ||
overrides = poetry2nix.overrides.withDefaults poetryOverrides; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This is an unreleased version of Lief that fixes a bug when generates GNU notes | ||
# https://github.com/lief-project/LIEF/commit/3414ded8cdcbd9705f7871c66c212b15cd74ea69 | ||
# Nixpkgs derivation was updated to change how lief was built since it no longer has setup.py | ||
# in the root of the directory. | ||
# For now, we copy the derivation until it's merged into nixpkgs we are tracking. | ||
# https://github.com/NixOS/nixpkgs/pull/251414 | ||
{ fetchFromGitHub, python, stdenv, cmake, ninja }: | ||
let | ||
pyEnv = python.withPackages (ps: [ ps.setuptools ps.tomli ps.pip ps.setuptools ]); | ||
in | ||
stdenv.mkDerivation rec { | ||
pname = "lief"; | ||
version = "0.14.0-3414ded"; | ||
src = fetchFromGitHub { | ||
owner = "lief-project"; | ||
repo = "LIEF"; | ||
rev = "3414ded8cdcbd9705f7871c66c212b15cd74ea69"; | ||
sha256 = "sha256-GJTj4w8HhAiC2bQAjEIqPw9feaOHL4fmAfLACioW0Q0="; | ||
}; | ||
outputs = [ "out" "py" ]; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
]; | ||
|
||
# Not a propagatedBuildInput because only the $py output needs it; $out is | ||
# just the library itself (e.g. C/C++ headers). | ||
buildInputs = [ | ||
python | ||
]; | ||
|
||
postBuild = '' | ||
pushd /build/source/api/python | ||
${pyEnv.interpreter} setup.py build --parallel=$NIX_BUILD_CORES | ||
popd | ||
''; | ||
|
||
postInstall = '' | ||
pushd /build/source/api/python | ||
${pyEnv.interpreter} setup.py install --skip-build --root=/ --prefix=$py | ||
popd | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# pyright: strict | ||
from typing import TYPE_CHECKING, Any | ||
|
||
import lief | ||
|
||
# Let's make sure type checking works for this proxy class | ||
# https://stackoverflow.com/questions/71365594/how-to-make-a-proxy-object-with-typing-as-underlying-object-in-python | ||
if TYPE_CHECKING: | ||
base = lief.ELF.Binary | ||
else: | ||
base = object | ||
|
||
|
||
class Binary(base): | ||
"""Proxy the lief.Binary object to add a path attribute. | ||
As of https://github.com/lief-project/LIEF/issues/839 the name | ||
attribute in lief.Binary was removed. Rather than passing around | ||
a tuple let's create a nice proxy class. | ||
""" | ||
|
||
def __init__(self, path: str): | ||
self.path = path | ||
self.__binary = lief.parse(path) | ||
|
||
if not TYPE_CHECKING: | ||
|
||
def __getattr__(self, attr: str) -> Any: | ||
return getattr(self.__binary, attr) | ||
|
||
@staticmethod | ||
def is_elf(path: str): | ||
return lief.is_elf(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.