Skip to content

Commit 7fce274

Browse files
committed
Provide lief-patchelf: a LIEF-based implementation of NixOS's patchelf
Related: NixOS/patchelf#568 Support: NixOS/patchelf#596
1 parent 9599415 commit 7fce274

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3380
-98
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ lief.egg-info/
88
dist/
99
api/rust/cargo/target/*
1010
api/rust/examples/target/*
11+
tools/target/*
1112
plugins/ghidra/bin/

api/python/lief/ART/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def parse(filename: str) -> Optional[File]: ...
2222
def parse(raw: Sequence[int], name: str = '') -> Optional[File]: ...
2323

2424
@overload
25-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], name: str = '') -> Optional[File]: ...
25+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], name: str = '') -> Optional[File]: ...
2626

2727
class File(lief.Object):
2828
@property

api/python/lief/COFF/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class ParserConfig:
137137

138138
default_conf: ParserConfig = ...
139139

140-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[Binary]: ...
140+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[Binary]: ...
141141

142142
class String:
143143
string: str

api/python/lief/DEX/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def parse(filename: str) -> Optional[File]: ...
5555
def parse(raw: Sequence[int], name: str = '') -> Optional[File]: ...
5656

5757
@overload
58-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], name: str = '') -> Optional[File]: ...
58+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], name: str = '') -> Optional[File]: ...
5959

6060
class File(lief.Object):
6161
class it_classes:

api/python/lief/ELF/__init__.pyi

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class ParserConfig:
414414

415415
all: ParserConfig = ...
416416

417-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[Binary]: ...
417+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[Binary]: ...
418418

419419
class SymbolVersion(lief.Object):
420420
@overload
@@ -853,6 +853,10 @@ class Binary(lief.Binary):
853853

854854
def get_relocated_dynamic_array(self, array_tag: DynamicEntry.TAG) -> list[int]: ...
855855

856+
def find_version_requirement(self, libname: str) -> SymbolVersionRequirement: ...
857+
858+
def remove_version_requirement(self, libname: str) -> bool: ...
859+
856860
@overload
857861
def __iadd__(self, arg: Segment, /) -> Binary: ...
858862

@@ -4776,13 +4780,19 @@ class SysvHash(lief.Object):
47764780
def __str__(self) -> str: ...
47774781

47784782
class Builder:
4779-
def __init__(self, elf_binary: Binary) -> None: ...
4783+
@overload
4784+
def __init__(self, elf: Binary) -> None: ...
4785+
4786+
@overload
4787+
def __init__(self, elf: Binary, config: Builder.config_t) -> None: ...
47804788

47814789
class config_t:
47824790
def __init__(self) -> None: ...
47834791

47844792
force_relocate: bool
47854793

4794+
skip_dynamic: bool
4795+
47864796
dt_hash: bool
47874797

47884798
dyn_str: bool
@@ -4819,9 +4829,12 @@ class Builder:
48194829

48204830
coredump_notes: bool
48214831

4832+
keep_empty_version_requirement: bool
4833+
48224834
def build(self) -> None: ...
48234835

4824-
config: Builder.config_t
4836+
@property
4837+
def config(self) -> Builder.config_t: ...
48254838

48264839
def write(self, output: str) -> None: ...
48274840

api/python/lief/MachO/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class ParserConfig:
265265

266266
def parse_from_memory(address: int, config: ParserConfig = ...) -> Optional[FatBinary]: ...
267267

268-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[FatBinary]: ...
268+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[FatBinary]: ...
269269

270270
class ChainedPointerAnalysis:
271271
class dyld_chained_ptr_arm64e_rebase_t:

api/python/lief/OAT/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def parse(oat_file: str, vdex_file: str) -> Optional[Binary]: ...
105105
def parse(raw: Sequence[int]) -> Optional[Binary]: ...
106106

107107
@overload
108-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]]) -> Optional[Binary]: ...
108+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]]) -> Optional[Binary]: ...
109109

110110
class Binary(lief.ELF.Binary):
111111
class it_dex_files:

api/python/lief/PE/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ParserConfig:
100100

101101
def __str__(self) -> str: ...
102102

103-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[Binary]: ...
103+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], config: ParserConfig = ...) -> Optional[Binary]: ...
104104

105105
class DosHeader(lief.Object):
106106
@staticmethod

api/python/lief/VDEX/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import lief.OAT
1212
def parse(filename: str) -> Optional[File]: ...
1313

1414
@overload
15-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]], name: str = '') -> Optional[File]: ...
15+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]], name: str = '') -> Optional[File]: ...
1616

1717
class File(lief.Object):
1818
@property

api/python/lief/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class Symbol(Object):
466466

467467
def __str__(self) -> str: ...
468468

469-
def parse(obj: Union[io.IOBase | os.PathLike | bytes | list[int]]) -> PE.Binary | OAT.Binary | ELF.Binary | MachO.Binary | COFF.Binary | None: ...
469+
def parse(obj: Union[str | io.IOBase | os.PathLike | bytes | list[int]]) -> PE.Binary | OAT.Binary | ELF.Binary | MachO.Binary | COFF.Binary | None: ...
470470

471471
class Relocation(Object):
472472
address: int

0 commit comments

Comments
 (0)