mirror of
https://github.com/lief-project/LIEF.git
synced 2026-10-11 22:09:53 +00:00
lint: add Harper pre-commit hook
This commit is contained in:
@@ -70,7 +70,7 @@ modify and abstract ELF, PE and MachO formats.
|
||||
- [About](#about-1)
|
||||
- [Authors](#authors)
|
||||
- [License](#license)
|
||||
- [Bibtex](#bibtex)
|
||||
- [BibTeX](#bibtex)
|
||||
|
||||
## Downloads / Install
|
||||
|
||||
@@ -125,7 +125,7 @@ Here are guides to install or integrate LIEF:
|
||||
|
||||
* [Python](https://lief.re/doc/latest/installation.html#python)
|
||||
* [Visual Studio](https://lief.re/doc/latest/installation.html#visual-studio-integration)
|
||||
* [XCode](https://lief.re/doc/latest/installation.html#xcode-integration)
|
||||
* [Xcode](https://lief.re/doc/latest/installation.html#xcode-integration)
|
||||
* [CMake](https://lief.re/doc/latest/installation.html#cmake-integration)
|
||||
|
||||
## Getting started
|
||||
@@ -222,7 +222,7 @@ Romain Thomas ([@rh0main](https://www.romainthomas.fr/)) - Formerly at [Quarksla
|
||||
|
||||
[Apache 2.0](https://github.com/lief-project/LIEF/blob/1.0.0/LICENSE).
|
||||
|
||||
### Bibtex
|
||||
### BibTeX
|
||||
|
||||
```bibtex
|
||||
@MISC {LIEF,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# About
|
||||
|
||||
The purpose of this project is to provide a cross platform library that can parse, modify and
|
||||
The purpose of this project is to provide a cross-platform library that can parse, modify and
|
||||
abstract ELF, PE and MachO formats.
|
||||
|
||||
Main features:
|
||||
|
||||
> - **Parsing**: LIEF can parse ELF, PE, MachO, OAT, DEX, VDEX, ART and provides an user-friendly API to access to format internals.
|
||||
> - **Parsing**: LIEF can parse ELF, PE, MachO, OAT, DEX, VDEX, ART and provides a user-friendly API to access format internals.
|
||||
> - **Modify**: LIEF enables to modify some parts of these formats
|
||||
> - **Abstract**: Three formats have common features like sections, symbols, entry point... LIEF factors them.
|
||||
> - **API**: LIEF can be used in C++, Python and Rust
|
||||
|
||||
@@ -134,7 +134,7 @@ def _get_hooked_config(is_editable: bool) -> dict[str, str | list[str]] | None:
|
||||
def _get_build_requirements(is_editable: bool) -> list[str]:
|
||||
build_req_file = BINDING_DIR / "build-requirements.txt"
|
||||
if not build_req_file.is_file() and not (BINDING_DIR / "src").is_dir():
|
||||
# By convention this is an mocked sdist
|
||||
# By convention this is a mocked sdist
|
||||
impl = sys.implementation.name
|
||||
version = "{0.major}.{0.minor}.{0.micro}".format(sys.version_info)
|
||||
free_threaded = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
"""Create a companion DWARF file from a PE binary.
|
||||
|
||||
Demonstrates the DWARF editor API: loads a PE binary, synthesises a
|
||||
Demonstrates the DWARF editor API: loads a PE binary, synthesizes a
|
||||
compilation unit with one function returning a pointer to a
|
||||
structure and a stack variable, then writes the result to
|
||||
``/tmp/out.debug``.
|
||||
|
||||
@@ -144,7 +144,7 @@ def memory_example():
|
||||
""",
|
||||
)
|
||||
|
||||
# Ensure the assembly is correctly JITed at the beggining of the allocated
|
||||
# Ensure the assembly is correctly JITed at the beginning of the allocated
|
||||
# memory
|
||||
for inst in islice(lief.runtime.disassemble(chunk.addr), 7):
|
||||
print(inst)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# LIEF Rust Bindings
|
||||
|
||||
These are the offical rust bindings for LIEF.
|
||||
These are the official Rust bindings for LIEF.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ def parse_forms() -> lief.COFF.Binary | None:
|
||||
pathlib.Path(r"C:\Users\romain\test.obj")
|
||||
)
|
||||
|
||||
# Using a io object
|
||||
# Using an io object
|
||||
with open("/tmp/test.ob", "rb") as f:
|
||||
coff: lief.COFF.Binary | None = lief.COFF.parse(f)
|
||||
# lief-doc: parse-end
|
||||
|
||||
@@ -203,7 +203,7 @@ def parse_forms() -> lief.ELF.Binary | None:
|
||||
# Using a Path from pathlib
|
||||
elf: lief.ELF.Binary | None = lief.ELF.parse(pathlib.Path(r"C:\Users\test.elf"))
|
||||
|
||||
# Using a io object
|
||||
# Using an io object
|
||||
with open("/bin/ssh", "rb") as f:
|
||||
elf: lief.ELF.Binary | None = lief.ELF.parse(f)
|
||||
# lief-doc: parse-end
|
||||
|
||||
@@ -83,7 +83,7 @@ def parse_forms() -> lief.MachO.FatBinary | None:
|
||||
pathlib.Path(r"C:\Users\test.macho")
|
||||
)
|
||||
|
||||
# Using a io object
|
||||
# Using an io object
|
||||
with open("/bin/ssh", "rb") as f:
|
||||
macho: lief.MachO.FatBinary | None = lief.MachO.parse(f)
|
||||
# lief-doc: parse-end
|
||||
|
||||
@@ -1977,7 +1977,7 @@ LIEF 0.9 comes with new formats related to Android: OAT, DEX, VDEX and ART. It a
|
||||
|
||||
- Use [frozen](https://github.com/serge-sans-paille/frozen) for some internal `std::map` (If C++14 is supported by the compiler)
|
||||
|
||||
### Acknowledgements
|
||||
### Acknowledgments
|
||||
|
||||
- {github_user}`yd0b0N` for {pr}`162` and {pr}`166` (Endianness support and PPC relocations)
|
||||
- {github_user}`0xbf00` for {pr}`128` (`LC_RPATH` command)
|
||||
@@ -2301,7 +2301,7 @@ In the C++ API `get_XXX()` getters have been renamed into `XXX()` (e.g. `get_hea
|
||||
|
||||
### Build system
|
||||
|
||||
- Add [FindLIEF.cmake](https://github.com/lief-project/LIEF/blob/e8ac976c994f6612e8dcca994032403c2d6f580f/scripts/FindLIEF.cmake) - {commit}`6dd8b10325e832a7520bf5ae3a588b9e022d0345`
|
||||
- Add [`FindLIEF.cmake`](https://github.com/lief-project/LIEF/blob/e8ac976c994f6612e8dcca994032403c2d6f580f/scripts/FindLIEF.cmake) - {commit}`6dd8b10325e832a7520bf5ae3a588b9e022d0345`
|
||||
- Add ASAN, TSAN, USAN, LSAN - {commit}`7f6aeb0d0d74eae886f4b312e12e8f71e1d5da6a`
|
||||
- Add LibFuzzer - {commit}`7a0dc28ea29a30209e944ebcde27f7c0ab234651`
|
||||
|
||||
@@ -2314,7 +2314,7 @@ In the C++ API `get_XXX()` getters have been renamed into `XXX()` (e.g. `get_hea
|
||||
* recomposer, bearparser, IAT_patcher, PEframe, Manalyze, MachOView, elf-dissector
|
||||
```
|
||||
|
||||
### Acknowledgements
|
||||
### Acknowledgments
|
||||
|
||||
- {github_user}`alvarofe` for {pr}`47`
|
||||
- {github_user}`aguinet` for {pr}`55`, {pr}`61`, {pr}`65`, {pr}`77`
|
||||
@@ -2495,12 +2495,12 @@ In the C++ API `get_XXX()` getters have been renamed into `XXX()` (e.g. `get_hea
|
||||
* `XCode <installation.html#xcode-integration>`_, `CMake <installation.html#cmake-integration>`_
|
||||
```
|
||||
|
||||
### Acknowledgements
|
||||
### Acknowledgments
|
||||
|
||||
- [ek0](https://github.com/ek0): {pr}`24`
|
||||
- [ACSC-CyberLab](https://github.com/ACSC-CyberLab): {pr}`33`, {pr}`34`, {pr}`37`, {pr}`39`
|
||||
- Hyrum Anderson who pointed bugs in the PE parser
|
||||
- My collegues for the feedbacks and suggestions (Adrien, SebK, Pierrick)
|
||||
- My colleagues for the feedback and suggestions (Adrien, SebK, Pierrick)
|
||||
|
||||
## 0.6.1 - April 6, 2017
|
||||
|
||||
@@ -2532,7 +2532,7 @@ In the C++ API `get_XXX()` getters have been renamed into `XXX()` (e.g. `get_hea
|
||||
* `Visual Studio <installation.html#visual-studio-integration>`_
|
||||
```
|
||||
|
||||
### Acknowledgements
|
||||
### Acknowledgments
|
||||
|
||||
- [Philippe](https://github.com/doegox) for the proofreading.
|
||||
|
||||
|
||||
@@ -239,4 +239,4 @@ script, to see how LIEF is compiled (and cross-compiled) for these platforms.
|
||||
|
||||
## Docker
|
||||
|
||||
See [liefproject](https://hub.docker.com/u/liefproject) on Dockerhub
|
||||
See [liefproject](https://hub.docker.com/u/liefproject) on Docker Hub
|
||||
|
||||
@@ -404,7 +404,7 @@ ______________________________________________________________________
|
||||
|
||||
______________________________________________________________________
|
||||
|
||||
## Editor - TypeDef
|
||||
## Editor - `TypeDef`
|
||||
|
||||
```{eval-rst}
|
||||
.. doxygenclass:: LIEF::dwarf::editor::TypeDef
|
||||
|
||||
@@ -103,7 +103,7 @@ defined in the debug file previously loaded:
|
||||
Additionally, you may also want to explore the
|
||||
{ref}`BinaryNinja <plugins-binaryninja-dwarf>` and
|
||||
{ref}`Ghidra <plugins-ghidra-dwarf>` DWARF export plugins, which generate
|
||||
debug information based on the analyses performed by these frameworks.
|
||||
debug information based on the analysis performed by these frameworks.
|
||||
|
||||
(extended-dwarf-to-decl)=
|
||||
|
||||
|
||||
@@ -626,7 +626,7 @@ ______________________________________________________________________
|
||||
|
||||
______________________________________________________________________
|
||||
|
||||
## Editor - TypeDef
|
||||
## Editor - `TypeDef`
|
||||
|
||||
```{eval-rst}
|
||||
.. lief-inheritance:: lief._lief.dwarf.editor.TypeDef
|
||||
|
||||
@@ -72,7 +72,7 @@ Note that {sub-ref}`lief-abstract-binary-load_debug_info` can also attach an ext
|
||||
DWARF file to a PE binary, even though this is not a typical use case.
|
||||
For instance, the {ref}`BinaryNinja <plugins-binaryninja-dwarf>` and
|
||||
{ref}`Ghidra <plugins-ghidra-dwarf>` DWARF export plugins can generate
|
||||
a DWARF file for a PE binary based on analyses performed by these frameworks.
|
||||
a DWARF file for a PE binary based on analysis performed by these frameworks.
|
||||
|
||||
This external loading API is useful for adding debug information that might not
|
||||
already be present in the binary. For instance, the {sub-ref}`lief-disassemble` function
|
||||
|
||||
@@ -36,7 +36,7 @@ ______________________________________________________________________
|
||||
|
||||
______________________________________________________________________
|
||||
|
||||
## BigOject Header
|
||||
## BigObj Header
|
||||
|
||||
```{eval-rst}
|
||||
.. doxygenclass:: LIEF::COFF::BigObjHeader
|
||||
|
||||
@@ -332,8 +332,8 @@ These versioning requirements can be problematic when creating executables or
|
||||
libraries intended for a wide range of Linux distributions.
|
||||
|
||||
The **best way** to ensure maximum compatibility is to target the minimum
|
||||
supported version of Glibc. For instance, if you aim to support Linux
|
||||
distributions with at least Glibc version `2.28` (released in 2018), you
|
||||
supported version of glibc. For instance, if you aim to support Linux
|
||||
distributions with at least glibc version `2.28` (released in 2018), you
|
||||
should specifically provide that version of `libc.so` during linking:
|
||||
|
||||
```console
|
||||
|
||||
@@ -44,4 +44,4 @@ updated to expose the correct type in the first two arguments:
|
||||
|
||||
{{ cross_api }}
|
||||
|
||||
[^f1]: On a given function, right click: `Tags and Bookmarks > Add Tag ... > LIEF - Android JNI Function`
|
||||
[^f1]: On a given function, right-click: `Tags and Bookmarks > Add Tag ... > LIEF - Android JNI Function`
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
:class: strike
|
||||
```
|
||||
|
||||
- 2021-06-03: [QBDL: QuarkslaB Dynamic Loader](https://www.sstic.org/2021/presentation/qbdl_quarkslab_dynamic_loader/)
|
||||
- 2021-06-03: [QBDL: Quarkslab Dynamic Loader](https://www.sstic.org/2021/presentation/qbdl_quarkslab_dynamic_loader/)
|
||||
- 2021-04-27: [An Empirical Evaluation of Automated Machine Learning Techniques for Malware Detection - IWSPA 21](https://dl.acm.org/doi/pdf/10.1145/3445970.3451155)
|
||||
- 2021-01-25: [Static PE antimalware evasion - Francisco Javier Gomez Galvez](http://openaccess.uoc.edu/webapps/o2/bitstream/10609/127010/7/fgomezgalvezTFM0121memoria.pdf)
|
||||
- 2020-10-23: [[Write-up] Using a PIE binary as a Shared Library — HCSC-2020 CTF Writeup](https://medium.com/bugbountywriteup/using-a-pie-binary-as-a-shared-library-hcsc-2020-ctf-writeup-390a8a437f31) by [István Tóth](https://twitter.com/an0n_r0)
|
||||
- 2020-02-04: [x0rro — A PE/ELF/MachO Crypter for x86 and x86_64 Based on Radare2 by phra](https://iwantmore.pizza/posts/x0rro.html)
|
||||
- 2020-10-23: [[Write-up] Using a PIE binary as a Shared Library: HCSC-2020 CTF Writeup](https://medium.com/bugbountywriteup/using-a-pie-binary-as-a-shared-library-hcsc-2020-ctf-writeup-390a8a437f31) by [István Tóth](https://twitter.com/an0n_r0)
|
||||
- 2020-02-04: [x0rro: A PE/ELF/MachO Crypter for x86 and x86_64 Based on Radare2 by phra](https://iwantmore.pizza/posts/x0rro.html)
|
||||
- 2019-11-01: [Isolating the logic of an encrypted protocol with LIEF and kaitai](https://x-c3ll.github.io/posts/blackbox-lief-kaitai/) by [@TheXC3LL](https://twitter.com/THEXC3LL)
|
||||
- 2018-10-26: [[Write-up] HITCON 2018 - Unexecutable](https://github.com/pwning/public-writeup/tree/21b31d1aa916f07a16423a1c2944c498a29271fb/hitcon2018/unexecutable/) by [Andrew Wesie](https://github.com/awesie)
|
||||
- 2018-10-06: [[Write-up] Flare-on Challenge (Level 3)](https://bruce30262.github.io/flare-on-challenge-2018-write-up/)
|
||||
@@ -36,7 +36,7 @@
|
||||
| Datalog Disassembly | C++ | <https://github.com/GrammaTech/ddisasm> | Binary Analysis | DDisasm is a fast disassembler which is accurate enough for the resulting assembly code to be reassembled. DDisasm is implemented using the datalog (souffle) declarative logic programming language to compile disassembly rules and heuristics |
|
||||
| Mobile-Security-Framework-MobSF | Python | <https://github.com/MobSF/Mobile-Security-Framework-MobSF> | Mobile Analysis | Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis. |
|
||||
| checksec.py | Python | <https://github.com/Wenzel/checksec.py> | Static Analysis | A simple tool to verify the security properties of your binaries. These properties can be enabled by your compiler to enforce the security of your executables, and mitigate exploitation |
|
||||
| youarespecial | Python | <https://github.com/endgameinc/youarespecial> | Machine Learning | Machine learning models on malwares |
|
||||
| youarespecial | Python | <https://github.com/endgameinc/youarespecial> | Machine Learning | Machine learning models on malware |
|
||||
| gym-malware | Python | <https://github.com/endgameinc/gym-malware> | Machine Learning | Learn how to bypass AV through machine learning. |
|
||||
| MISP | Python | <https://github.com/MISP/MISP> | Malware | Malware Information Sharing Platform and Threat Sharing |
|
||||
| Virus Disinfector KIT | Python | <https://github.com/Fare9/Virus_Disinfector_KIT> | Malware | A tool for disinfecting PE files |
|
||||
@@ -154,5 +154,5 @@
|
||||
| insert_dylib | C | <https://github.com/Tyilo/insert_dylib> | Mach-O | Insert a dylib load command |
|
||||
| optool | Obj-C | <https://github.com/alexzielenski/optool> | Mach-O | Modify Mach-O commands: Resign, insert commands, ... |
|
||||
| reflective- polymorphism | C | <https://github.com/zeroSteiner/reflective-polymorphism> | PE | Transform PE files between EXE and DLL |
|
||||
| XELFViewer | C++/Qt | <https://github.com/horsicq/XELFViewer> | ELF | ELF file viewer/editor for Windows, Linux and MacOS. |
|
||||
| XELFViewer | C++/Qt | <https://github.com/horsicq/XELFViewer> | ELF | ELF file viewer/editor for Windows, Linux and macOS. |
|
||||
| strongarm | Python | <https://github.com/datatheorem/strongarm> | Mach-O | Cross-platform ARM64 Mach-O analysis library |
|
||||
|
||||
@@ -32,8 +32,8 @@ macOS to sign the binary after compilation by adding a custom command. The
|
||||
`LC_CODE_SIGNATURE` or `LC_DYLIB_CODE_SIGN_DRS` command in the padding
|
||||
area.
|
||||
|
||||
Since load commands are the base unit of the Mach-O format—segments, shared
|
||||
libraries, entry points, etc., are all *commands*—the ability to add arbitrary
|
||||
Since load commands are the base unit of the Mach-O format (segments, shared
|
||||
libraries, entry points, etc., are all *commands*), the ability to add arbitrary
|
||||
commands to a binary enables interesting possibilities such as code injection,
|
||||
anti-analysis, etc.
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ the [Triton](https://triton.quarkslab.com/) API:
|
||||
- [AArch64Cpu::setConcreteRegisterValue()](https://github.com/JonathanSalwan/Triton/blob/a61651ce331ac53ec09e1d8fef5eab744e98c9de/src/libtriton/arch/architecture.cpp#L343)
|
||||
- [AArch64Cpu::setConcreteMemoryAreaValue()](https://github.com/JonathanSalwan/Triton/blob/a61651ce331ac53ec09e1d8fef5eab744e98c9de/src/libtriton/arch/architecture.cpp#L329-L340)
|
||||
|
||||
to map the coredump into Triton and then utilize its engines for taint
|
||||
to map the coredump into Triton and then use its engines for taint
|
||||
analysis and symbolic execution.
|
||||
|
||||
```{rubric} References
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// Rename the first section name.
|
||||
// Ex: ./tools/ELFSectionRename /bin/ls ./lsRename
|
||||
//
|
||||
// ```
|
||||
// $ readelf -S /bin/ls
|
||||
//
|
||||
// [Nr] Nom Type Adresse Décalage
|
||||
@@ -44,8 +45,7 @@
|
||||
// [ 2] .note.ABI-tag NOTE 0000000000400254 00000254
|
||||
// 0000000000000020 0000000000000000 A 0 0 4
|
||||
// ....
|
||||
//
|
||||
//
|
||||
// ```
|
||||
//
|
||||
int main(int argc, char** argv) {
|
||||
std::cout << "ELF Section rename" << '\n';
|
||||
|
||||
@@ -293,7 +293,7 @@ struct ALIGNED_(4) jclass_t {
|
||||
|
||||
|
||||
// No changes in jstring structure but string can be
|
||||
// encoded as as char16_t or char (compressed)
|
||||
// encoded as char16_t or char (compressed)
|
||||
// count[0] (LSB) == 1 ----> compressed
|
||||
// count[0] (LSB) == 0 ----> chat16_t
|
||||
template<class T = no_brooks_read_barrier_t>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace LIEF::ART {
|
||||
|
||||
using art_version_t = uint32_t;
|
||||
|
||||
} // Namesapce ART
|
||||
} // Namespace ART
|
||||
// Namespace LIEF
|
||||
|
||||
#endif
|
||||
|
||||
@@ -97,7 +97,7 @@ class LIEF_API AuxiliarySectionDefinition : public AuxiliarySymbol {
|
||||
/// COMDAT_SELECTION::ASSOCIATIVE set.
|
||||
ASSOCIATIVE,
|
||||
|
||||
/// The linker chooses the largest definition from among all of the definitions
|
||||
/// The linker chooses the largest definition from among all the definitions
|
||||
/// for this symbol. If multiple definitions have this size, the choice
|
||||
/// between them is arbitrary.
|
||||
LARGEST,
|
||||
|
||||
@@ -119,7 +119,7 @@ class LIEF_API Symbol : public LIEF::Symbol {
|
||||
TY_FLOAT = 6, ///< A 4-byte floating-point number.
|
||||
TY_DOUBLE = 7, ///< An 8-byte floating-point number.
|
||||
TY_STRUCT = 8, ///< A structure.
|
||||
TY_UNION = 9, ///< An union.
|
||||
TY_UNION = 9, ///< A union.
|
||||
TY_ENUM = 10, ///< An enumerated type.
|
||||
TY_MOE = 11, ///< A member of enumeration (a specific value).
|
||||
TY_BYTE = 12, ///< A byte; unsigned 1-byte integer.
|
||||
|
||||
@@ -72,19 +72,19 @@ class LIEF_API Type : public Object {
|
||||
const PRIMITIVES& primitive() const;
|
||||
|
||||
/// **IF** the current type is a TYPES::CLASS, return the
|
||||
/// associated DEX::CLASS. Otherwise the returned value is **undefined**.
|
||||
/// associated DEX::CLASS. Otherwise, the returned value is **undefined**.
|
||||
Class& cls();
|
||||
|
||||
/// **IF** the current type is a TYPES::ARRAY, return the
|
||||
/// associated array. Otherwise the returned value is **undefined**.
|
||||
/// associated array. Otherwise, the returned value is **undefined**.
|
||||
array_t& array();
|
||||
|
||||
/// **IF** the current type is a TYPES::PRIMITIVE, return the
|
||||
/// associated PRIMITIVES. Otherwise the returned value is **undefined**.
|
||||
/// associated PRIMITIVES. Otherwise, the returned value is **undefined**.
|
||||
PRIMITIVES& primitive();
|
||||
|
||||
/// Return the array dimension if the current type is
|
||||
/// an array. Otherwise it returns 0
|
||||
/// an array. Otherwise, it returns 0
|
||||
size_t dim() const;
|
||||
|
||||
/// In the case of a TYPES::ARRAY, return the array's type
|
||||
|
||||
@@ -140,7 +140,7 @@ class LIEF_API DyldSharedCache {
|
||||
/// Name of the architecture targeted by this cache (`x86_64h`)
|
||||
std::string arch_name() const;
|
||||
|
||||
/// Platform targeted by this cache (e.g. vision-os)
|
||||
/// Platform targeted by this cache (e.g. visionOS)
|
||||
DYLD_TARGET_PLATFORM platform() const;
|
||||
|
||||
/// Architecture targeted by this cache
|
||||
@@ -167,7 +167,7 @@ class LIEF_API DyldSharedCache {
|
||||
/// Return an iterator over the libraries embedded in this dyld shared cache.
|
||||
///
|
||||
/// This iterator implements the *random access* trait. Thus, one can use
|
||||
/// iterator_range::size, iterator_range::at, iterator_range::operator[] to a
|
||||
/// iterator_range::size, iterator_range::at, iterator_range::operator[] to
|
||||
/// access Dylib at an arbitrary index:
|
||||
///
|
||||
/// ```cpp
|
||||
@@ -239,8 +239,8 @@ class LIEF_API DyldSharedCache {
|
||||
/// Return the stream associated with this dyld shared cache
|
||||
FileStream& stream() LIEF_LIFETIMEBOUND;
|
||||
|
||||
/// When enabled, this function allows to record and to keep in *cache*,
|
||||
/// dyld shared cache information that are costly to access.
|
||||
/// When enabled, this function records and keeps in *cache* the
|
||||
/// dyld shared cache information that is costly to access.
|
||||
///
|
||||
/// For instance, GOT symbols, rebases information, stub symbols, ...
|
||||
///
|
||||
@@ -273,7 +273,7 @@ class LIEF_API DyldSharedCache {
|
||||
///
|
||||
/// In the case where multiple architectures are
|
||||
/// available in the @p path directory, the @p arch parameter can be used to
|
||||
/// define which architecture should be prefered.
|
||||
/// define which architecture should be preferred.
|
||||
///
|
||||
/// **Example:**
|
||||
///
|
||||
|
||||
@@ -87,7 +87,7 @@ class LIEF_API Dylib {
|
||||
|
||||
public:
|
||||
/// This structure is used to tweak the extraction process while calling
|
||||
/// Dylib::get. These options allow to deoptimize the dylib and get an
|
||||
/// Dylib::get. These options allow deoptimizing the dylib to get an
|
||||
/// accurate representation of the origin Mach-O binary.
|
||||
struct LIEF_API extract_opt_t {
|
||||
extract_opt_t();
|
||||
|
||||
@@ -51,7 +51,7 @@ class LIEF_API DynamicEntryFlags : public DynamicEntry {
|
||||
TRANS = BASE + 0x000000200,
|
||||
INTERPOSE = BASE + 0x000000400, /**< Object is used to interpose. */
|
||||
NODEFLIB = BASE + 0x000000800, /**< Ignore default lib search path. */
|
||||
NODUMP = BASE + 0x000001000, /**< Object can't be dldump'ed. */
|
||||
NODUMP = BASE + 0x000001000, /**< Object can't be dumped with dldump(). */
|
||||
CONFALT = BASE + 0x000002000, /**< Configuration alternative created. */
|
||||
ENDFILTEE = BASE + 0x000004000, /**< Filtee terminates filters search. */
|
||||
DISPRELDNE = BASE + 0x000008000, /**< Disp reloc applied at build time. */
|
||||
|
||||
@@ -293,7 +293,7 @@ class LIEF_API Parser : public LIEF::Parser {
|
||||
/// @see http://dev.gentoo.org/~solar/elf/symbol-versioning
|
||||
LIEF_LOCAL ok_error_t parse_symbol_version(uint64_t symbol_version_offset);
|
||||
|
||||
/// Parse Symbols's GNU hash
|
||||
/// Parse the symbols' GNU hash
|
||||
///
|
||||
/// @see https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
|
||||
template<typename ELF_T>
|
||||
@@ -305,7 +305,7 @@ class LIEF_API Parser : public LIEF::Parser {
|
||||
LIEF_LOCAL std::unique_ptr<Note> get_note(uint32_t type, std::string name,
|
||||
std::vector<uint8_t> desc_bytes);
|
||||
|
||||
/// Parse Symbols's SYSV hash
|
||||
/// Parse the symbols' SYSV hash
|
||||
LIEF_LOCAL ok_error_t parse_symbol_sysv_hash(uint64_t offset);
|
||||
|
||||
LIEF_LOCAL ok_error_t parse_overlay();
|
||||
|
||||
@@ -103,7 +103,7 @@ class LIEF_API Section : public LIEF::Section {
|
||||
_AARCH64_ID_ = 5LLU,
|
||||
|
||||
ARM_EXIDX = 0x70000001U + (_ARM_ID_ << _ID_SHIFT_), /**< Exception Index table */
|
||||
ARM_PREEMPTMAP = 0x70000002U + (_ARM_ID_ << _ID_SHIFT_), /**< BPABI DLL dynamic linking pre-emption map */
|
||||
ARM_PREEMPTMAP = 0x70000002U + (_ARM_ID_ << _ID_SHIFT_), /**< BPABI DLL dynamic linking preemption map */
|
||||
ARM_ATTRIBUTES = 0x70000003U + (_ARM_ID_ << _ID_SHIFT_), /**< Object file compatibility attributes */
|
||||
ARM_DEBUGOVERLAY = 0x70000004U + (_ARM_ID_ << _ID_SHIFT_),
|
||||
ARM_OVERLAYSECTION = 0x70000005U + (_ARM_ID_ << _ID_SHIFT_),
|
||||
|
||||
@@ -144,7 +144,7 @@ class LIEF_API Symbol : public LIEF::Symbol {
|
||||
/// symbol. That is, `value` is an
|
||||
/// offset from the beginning of the section associated with this symbol.
|
||||
/// * In executable and shared object files, `value` holds a virtual address.
|
||||
/// To make these files's
|
||||
/// To make these files'
|
||||
/// symbols more useful for the dynamic linker, the section offset (file
|
||||
/// interpretation) gives way to a virtual address (memory interpretation)
|
||||
/// for which the section number is irrelevant.
|
||||
|
||||
@@ -194,7 +194,7 @@ class LIEF_API DyldInfo : public LoadCommand {
|
||||
/// <seg-index, seg-offset, type>
|
||||
/// The opcodes are a compressed way to encode the table by only
|
||||
/// encoding when a column changes. In addition simple patterns
|
||||
/// like "every n'th offset for m times" can be encoded in a few
|
||||
/// like "every nth offset for m times" can be encoded in a few
|
||||
/// bytes.
|
||||
///
|
||||
/// @see ``/usr/include/mach-o/loader.h``
|
||||
@@ -286,10 +286,10 @@ class LIEF_API DyldInfo : public LoadCommand {
|
||||
/// *Lazy Bind* information
|
||||
///
|
||||
/// Some uses of external symbols do not need to be bound immediately.
|
||||
/// Instead they can be lazily bound on first use. The lazy_bind
|
||||
/// Instead, they can be lazily bound on first use. The lazy_bind
|
||||
/// area contains a stream of BIND opcodes to bind all lazy symbols.
|
||||
/// Normal use is that dyld ignores the lazy_bind section when
|
||||
/// loading an image. Instead the static linker arranged for the
|
||||
/// loading an image. Instead, the static linker arranged for the
|
||||
/// lazy pointer to initially point to a helper function which
|
||||
/// pushes the offset into the lazy_bind area for the symbol
|
||||
/// needing to be bound, then jumps to dyld which simply adds
|
||||
|
||||
@@ -123,7 +123,7 @@ class LIEF_API Section : public LIEF::Section {
|
||||
/// Section contains coalesced symbols that are not to be in a ranlib
|
||||
/// table of contents.
|
||||
NO_TOC = 0x40000000u,
|
||||
/// Ok to strip static symbols in this section in files with the
|
||||
/// Okay to strip static symbols in this section in files with the
|
||||
/// MY_DYLDLINK flag.
|
||||
STRIP_STATIC_SYMS = 0x20000000u,
|
||||
/// No dead stripping.
|
||||
|
||||
@@ -83,7 +83,7 @@ class LIEF_API ThreadCommand : public LoadCommand {
|
||||
}
|
||||
|
||||
/// The actual thread state as a vector of bytes. Depending on the
|
||||
/// architecture(), these data can be casted into x86_thread_state_t,
|
||||
/// architecture(), these data can be cast into x86_thread_state_t,
|
||||
/// x86_thread_state64_t, ...
|
||||
span<const uint8_t> state() const LIEF_LIFETIMEBOUND {
|
||||
return state_;
|
||||
|
||||
@@ -613,7 +613,7 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
return imports_;
|
||||
}
|
||||
|
||||
/// Return the Import matching the provided name (case sensitive)
|
||||
/// Return the Import matching the provided name (case-sensitive)
|
||||
///
|
||||
/// If the import can't be found, it returns a nullptr
|
||||
Import* get_import(const std::string& import_name) LIEF_LIFETIMEBOUND {
|
||||
|
||||
@@ -32,7 +32,7 @@ class Relocation;
|
||||
|
||||
/// Class which represents an entry of the PE relocation table
|
||||
///
|
||||
/// It extends the LIEF::Relocation object to provide an uniform API across the
|
||||
/// It extends the LIEF::Relocation object to provide a uniform API across the
|
||||
/// file formats
|
||||
class LIEF_API RelocationEntry : public LIEF::Relocation {
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class LIEF_API ResourceNode : public Object {
|
||||
|
||||
/// `True` if the current entry is a ResourceDirectory.
|
||||
///
|
||||
/// It can be safely casted with:
|
||||
/// It can be safely cast with:
|
||||
///
|
||||
/// ```cpp
|
||||
/// const auto* dir_node = node.cast<ResourceDirectory>();
|
||||
@@ -146,7 +146,7 @@ class LIEF_API ResourceNode : public Object {
|
||||
|
||||
/// `True` if the current entry is a ResourceData.
|
||||
///
|
||||
/// It can be safely casted with:
|
||||
/// It can be safely cast with:
|
||||
///
|
||||
/// ```cpp
|
||||
/// const auto* data_node = node.cast<ResourceData>();
|
||||
|
||||
@@ -106,7 +106,7 @@ class LIEF_API UnpackedFunction : public RuntimeFunctionAArch64 {
|
||||
return E() == 1 ? epilog_offset_ : uint16_t(-1);
|
||||
}
|
||||
|
||||
/// Number of 32-bit words needed to contain all of the unwind codes
|
||||
/// Number of 32-bit words needed to contain all the unwind codes
|
||||
uint32_t code_words() const {
|
||||
return code_words_;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class LIEF_API RuntimeFunctionX64 : public ExceptionInfo {
|
||||
/// unwind operation code slots, as described in the note above.
|
||||
SAVE_NONVOL_FAR = 5,
|
||||
|
||||
/// This entry is only revelant for version 2. It describes the function
|
||||
/// This entry is only relevant for version 2. It describes the function
|
||||
/// epilog.
|
||||
EPILOG = 6,
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class LIEF_API Signature : public Object {
|
||||
/// [WTD_LIFETIME_SIGNING_FLAG](https://docs.microsoft.com/en-us/windows/win32/api/wintrust/ns-wintrust-wintrust_data#WTD_LIFETIME_SIGNING_FLAG)
|
||||
LIFETIME_SIGNING = 1 << 2,
|
||||
|
||||
/// Skip the verification of the certificates time validities so that even
|
||||
/// Skip the verification of the certificate validity periods so that even
|
||||
/// though a certificate expired, it returns VERIFICATION_FLAGS::OK
|
||||
SKIP_CERT_TIME = 1 << 3,
|
||||
};
|
||||
|
||||
@@ -129,7 +129,7 @@ class LIEF_API SignerInfo : public Object {
|
||||
return unauthenticated_attributes_;
|
||||
}
|
||||
|
||||
/// Return the authenticated or un-authenticated attribute matching the
|
||||
/// Return the authenticated or unauthenticated attribute matching the
|
||||
/// given PE::SIG_ATTRIBUTE_TYPES.
|
||||
///
|
||||
/// It returns **the first** entry that matches the given type. If it can't be
|
||||
@@ -144,7 +144,7 @@ class LIEF_API SignerInfo : public Object {
|
||||
const Attribute*
|
||||
get_auth_attribute(Attribute::TYPE type) const LIEF_LIFETIMEBOUND;
|
||||
|
||||
/// Return the un-authenticated attribute matching the given
|
||||
/// Return the unauthenticated attribute matching the given
|
||||
/// PE::SIG_ATTRIBUTE_TYPES.
|
||||
///
|
||||
/// It returns **the first** entry that matches the given type. If it can't be
|
||||
|
||||
@@ -64,7 +64,7 @@ class LIEF_API PKCS9MessageDigest : public Attribute {
|
||||
return std::unique_ptr<Attribute>(new PKCS9MessageDigest{*this});
|
||||
}
|
||||
|
||||
/// Message digeset as a blob of bytes as described in the RFC
|
||||
/// Message digest as a blob of bytes as described in the RFC
|
||||
span<const uint8_t> digest() const LIEF_LIFETIMEBOUND {
|
||||
return digest_;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class LIEF_API SpcSpOpusInfo : public Attribute {
|
||||
return program_name_;
|
||||
}
|
||||
|
||||
/// Other information such as an url
|
||||
/// Other information such as a URL
|
||||
std::string_view more_info() const LIEF_LIFETIMEBOUND {
|
||||
return more_info_;
|
||||
}
|
||||
|
||||
@@ -132,20 +132,20 @@ class LIEF_API x509 : public Object {
|
||||
/// The certificate is signed with an unacceptable hash.
|
||||
BADCERT_BAD_MD = 1 << 14,
|
||||
|
||||
/// The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA).
|
||||
/// The certificate is signed with an unacceptable PK alg (e.g. RSA vs ECDSA).
|
||||
BADCERT_BAD_PK = 1 << 15,
|
||||
|
||||
/// The certificate is signed with an unacceptable key (eg bad curve, RSA too
|
||||
/// The certificate is signed with an unacceptable key (e.g. bad curve, RSA too
|
||||
/// short).
|
||||
BADCERT_BAD_KEY = 1 << 16,
|
||||
|
||||
/// The CRL is signed with an unacceptable hash.
|
||||
BADCRL_BAD_MD = 1 << 17,
|
||||
|
||||
/// The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA).
|
||||
/// The CRL is signed with an unacceptable PK alg (e.g. RSA vs ECDSA).
|
||||
BADCRL_BAD_PK = 1 << 18,
|
||||
|
||||
/// The CRL is signed with an unacceptable key (eg bad curve, RSA too short).
|
||||
/// The CRL is signed with an unacceptable key (e.g. bad curve, RSA too short).
|
||||
BADCRL_BAD_KEY = 1 << 19,
|
||||
};
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ LIEF_LOCAL result<PE_TYPE> get_type_from_stream(BinaryStream& stream);
|
||||
|
||||
/// Compute the hash of imported functions
|
||||
///
|
||||
/// By default, it generates an hash with the following properties:
|
||||
/// By default, it generates a hash with the following properties:
|
||||
/// * Order agnostic
|
||||
/// * Casse agnostic
|
||||
/// * Case agnostic
|
||||
/// * Ordinal (**in some extent**) agnostic
|
||||
///
|
||||
/// If one needs the same output as Virus Total (i.e. pefile), you can pass
|
||||
@@ -85,7 +85,7 @@ LIEF_API std::string get_imphash(const Binary& binary,
|
||||
/// by ordinal.
|
||||
///
|
||||
/// The ``strict`` boolean parameter enables to throw an LIEF::not_found exception
|
||||
/// if the ordinal can't be resolved. Otherwise it skips the entry.
|
||||
/// if the ordinal can't be resolved. Otherwise, it skips the entry.
|
||||
///
|
||||
/// @param[in] import Import to resolve
|
||||
/// @param[in] strict If set to ``true``, throw an exception if the import can't be
|
||||
|
||||
@@ -712,7 +712,7 @@ namespace LIEF {
|
||||
/// methods:
|
||||
///
|
||||
/// Forward Iterators:
|
||||
/// (All of the following methods)
|
||||
/// (All the following methods)
|
||||
/// - DerivedT &operator=(const DerivedT &R);
|
||||
/// - bool operator==(const DerivedT &R) const;
|
||||
/// - T &operator*() const;
|
||||
@@ -773,7 +773,7 @@ class iterator_facade_base {
|
||||
/// A proxy object for computing a pointer via indirecting a copy of a
|
||||
/// reference. This is used in APIs which need to produce a pointer but for
|
||||
/// which the reference might be a temporary. The proxy preserves the
|
||||
/// reference internally and exposes the pointer via a arrow operator.
|
||||
/// reference internally and exposes the pointer via an arrow operator.
|
||||
class PointerProxy {
|
||||
friend iterator_facade_base;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class TypeBuilder : public analysis_plugin::TypeBuilder {
|
||||
get_or_create(const std::string& name) override;
|
||||
|
||||
// Currently BinaryNinja is not aware of RVA (i.e. creating the associated
|
||||
// xref/symbols) as Ghidra does but in the future this could change so let
|
||||
// xref/symbols) as Ghidra does but in the future this could change so let's
|
||||
// make an abstraction for that.
|
||||
BinaryNinja::Ref<BinaryNinja::Type> RVA() {
|
||||
using namespace BinaryNinja;
|
||||
|
||||
@@ -31,7 +31,7 @@ template<class T>
|
||||
decltype(static_cast<void>(*std::declval<T>()),
|
||||
std::true_type{}) can_be_dereferenced_impl(int);
|
||||
|
||||
// Otherwise the less specific function is selected,
|
||||
// Otherwise, the less specific function is selected,
|
||||
// and the return type is `std::false_type`
|
||||
template<class>
|
||||
std::false_type can_be_dereferenced_impl(...);
|
||||
|
||||
@@ -109,6 +109,31 @@ hooks = [
|
||||
#args = ["--fix"],
|
||||
files = { glob = ["doc/code/python/**/*.py"] },
|
||||
},
|
||||
{
|
||||
id = "harper-markdown",
|
||||
name = "lint(markdown) - Harper",
|
||||
language = "python",
|
||||
entry = "uv run internal/scripts/harper_lint.py",
|
||||
additional_dependencies = ["myst-parser==5.1.0"],
|
||||
files = "\\.md$",
|
||||
},
|
||||
{
|
||||
id = "harper-cpp",
|
||||
name = "lint(cpp) - Harper",
|
||||
language = "python",
|
||||
entry = "uv run internal/scripts/harper_lint.py",
|
||||
additional_dependencies = ["myst-parser==5.1.0"],
|
||||
files = "\\.(cpp|hpp|tcc|c)$",
|
||||
exclude = "(third-party/|nanobind/extra/|^src/frozen\\.hpp$)",
|
||||
},
|
||||
{
|
||||
id = "harper-python",
|
||||
name = "lint(python) - Harper",
|
||||
language = "python",
|
||||
entry = "uv run internal/scripts/harper_lint.py",
|
||||
additional_dependencies = ["myst-parser==5.1.0"],
|
||||
files = "\\.py$",
|
||||
},
|
||||
{
|
||||
id = "lint-doc-code-rust-clippy",
|
||||
name = "lint - doc code - clippy",
|
||||
|
||||
+2
-2
@@ -1525,7 +1525,7 @@ ok_error_t Builder::build_android_relocations() {
|
||||
}
|
||||
|
||||
/* The relocations might have been updated when adding the new segment
|
||||
* (->relocate()). Thus the cache might be invalidated.
|
||||
* (->relocate()). Thus, the cache might be invalidated.
|
||||
*/
|
||||
auto& layout = static_cast<ExeLayout&>(*layout_);
|
||||
const size_t computed_size = layout.android_relocations_size<ELF_T>();
|
||||
@@ -1564,7 +1564,7 @@ ok_error_t Builder::build_relative_relocations() {
|
||||
return ok();
|
||||
}
|
||||
/* The relocations might have been updated when adding the new segment
|
||||
* (->relocate()). Thus the cache might be invalidated.
|
||||
* (->relocate()). Thus, the cache might be invalidated.
|
||||
*/
|
||||
auto& layout = static_cast<ExeLayout&>(*layout_);
|
||||
const size_t computed_size = layout.relative_relocations_size<ELF_T>();
|
||||
|
||||
@@ -105,7 +105,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
return raw_dynstr_.size();
|
||||
}
|
||||
|
||||
// Start with dynamic entries: NEEDED / SONAME etc
|
||||
// Start with dynamic entries: NEEDED / SONAME etc.
|
||||
vector_iostream raw_dynstr(should_swap());
|
||||
raw_dynstr.write<uint8_t>(0);
|
||||
|
||||
@@ -291,7 +291,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
|
||||
template<class ELF_T>
|
||||
size_t symbol_gnu_hash_size() {
|
||||
// Mainly inspired from
|
||||
// Mainly inspired by
|
||||
// * https://github.com/llvm-mirror/lld/blob/master/ELF/SyntheticSections.cpp
|
||||
//
|
||||
// Checking is performed here:
|
||||
@@ -680,7 +680,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
|
||||
template<class ELF_T>
|
||||
size_t relative_relocations_size(bool force = false) {
|
||||
// This code is inspired from LLVM-lld:
|
||||
// This code is inspired by LLVM-lld:
|
||||
// lld/ELF/SyntheticSections.cpp - RelrSection<ELFT>::updateAllocSize
|
||||
// https://github.com/llvm/llvm-project/blob/754a8add57098ef71e4a51a9caa0cc175e94377d/lld/ELF/SyntheticSections.cpp#L1997-L2078
|
||||
using Elf_Addr = typename ELF_T::Elf_Addr;
|
||||
@@ -1058,7 +1058,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
|
||||
if (dynamic_size_ > 0) {
|
||||
// Update .dynamic / PT_DYNAMIC
|
||||
// Update relocations associated with .init_array etc
|
||||
// Update relocations associated with .init_array etc.
|
||||
Segment* dynamic_segment = binary_->get(Segment::TYPE::DYNAMIC);
|
||||
if (dynamic_segment == nullptr) {
|
||||
LIEF_ERR("Dynamic section/segment not found");
|
||||
@@ -1726,7 +1726,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
std::string sec_name = *section_res;
|
||||
|
||||
// If the binary has the note type but does not have
|
||||
// the section (likly because the user added the note manually)
|
||||
// the section (likely because the user added the note manually)
|
||||
// then, create the section
|
||||
if (const Section* nsec = binary_->get_section(*section_res);
|
||||
nsec == nullptr)
|
||||
|
||||
@@ -1318,13 +1318,14 @@ bool Binary::extend_section(Section& section, size_t size) {
|
||||
// it to the "left", so that we create a gap of at least `size` wide after the
|
||||
// current `section`. Finally, we assign new size to the `section`.
|
||||
//
|
||||
// Let's say we are extending section S.
|
||||
// There might be sections P that come prior S, and there might be sections A
|
||||
// that come after S. We try to keep relative relationships between sections in
|
||||
// groups P and A, such that relative offsets from one section to another one are
|
||||
// unchanged, however preserving the same relationship between sections from
|
||||
// different groups is impossible. We achieve this by shifting P and S to the
|
||||
// left by size rounded up to the maximum common alignment factor.
|
||||
// Let's say we are extending section `S`.
|
||||
// There might be sections `P` that come prior `S`, and there might be
|
||||
// sections `A` that come after `S`. We try to keep relative relationships
|
||||
// between sections in groups `P` and `A`, such that relative offsets from one
|
||||
// section to another one are unchanged, however preserving the same
|
||||
// relationship between sections from different groups is impossible. We
|
||||
// achieve this by shifting `P` and `S` to the left by size rounded up to the
|
||||
// maximum common alignment factor.
|
||||
|
||||
const uint64_t loadcommands_start =
|
||||
is64_ ? sizeof(details::mach_header_64) : sizeof(details::mach_header);
|
||||
@@ -1541,7 +1542,7 @@ Section* Binary::add_section(const SegmentCommand& segment,
|
||||
available_command_space_ = new_offset - loadcommands_end;
|
||||
}
|
||||
|
||||
// Compute offset, virtual address etc for the new section
|
||||
// Compute offset, virtual address etc. for the new section
|
||||
// =======================================================
|
||||
if (section.size() == 0) {
|
||||
new_section->size(content.size());
|
||||
|
||||
@@ -3480,7 +3480,7 @@ ok_error_t BinaryParser::do_chained_fixup(
|
||||
}
|
||||
|
||||
// ---------- !auth && !bind ----------
|
||||
// See comment for: dyld_chained_ptr_generic64
|
||||
// See the comment for: dyld_chained_ptr_generic64
|
||||
const uint64_t target = ptr_fmt == DYLD_CHAINED_PTR_FORMAT::PTR_64 ?
|
||||
fixup.unpack_target() :
|
||||
fixup.unpack_target() + imagebase;
|
||||
@@ -4437,7 +4437,7 @@ ok_error_t BinaryParser::post_process(LazyLoadDylibInfo& cmd) {
|
||||
|
||||
/* This method is needed since the C++ copy constructor of ChainedBindingInfo
|
||||
* does not (on purpose) copy the pointers associated with the object.
|
||||
* Thus we need this helper to make sure that in the context of the parser,
|
||||
* Thus, we need this helper to make sure that in the context of the parser,
|
||||
* the pointers are correctly copied.
|
||||
*/
|
||||
void BinaryParser::copy_from(ChainedBindingInfo& to, ChainedBindingInfo& from) {
|
||||
|
||||
@@ -1347,7 +1347,7 @@ ok_error_t Builder::build(DyldChainedFixups& fixups) {
|
||||
/*
|
||||
* Note(romain): Most of the logic that constructs this command
|
||||
* is located in ld64/src/ld/LinkEdit.hpp -
|
||||
* ChainedInfoAtom<A>::encode() The following code is highly inspired from the
|
||||
* ChainedInfoAtom<A>::encode() The following code is highly inspired by the
|
||||
* Apple ld64 code
|
||||
*/
|
||||
LIEF_DEBUG("[->] Writing DyldChainedFixups");
|
||||
|
||||
@@ -67,7 +67,7 @@ static_assert(sizeof(dyld_chained_starts_in_segment) == 22,
|
||||
// DYLD_CHAINED_PTR_ARM64E
|
||||
struct dyld_chained_ptr_arm64e_rebase {
|
||||
uint64_t target : 43, high8 : 8,
|
||||
next : 11, // 4 or 8-byte stide
|
||||
next : 11, // 4 or 8-byte stride
|
||||
bind : 1, // == 0
|
||||
auth : 1; // == 0
|
||||
};
|
||||
@@ -76,7 +76,7 @@ struct dyld_chained_ptr_arm64e_rebase {
|
||||
struct dyld_chained_ptr_arm64e_bind {
|
||||
uint64_t ordinal : 16, zero : 16,
|
||||
addend : 19, // +/-256K
|
||||
next : 11, // 4 or 8-byte stide
|
||||
next : 11, // 4 or 8-byte stride
|
||||
bind : 1, // == 1
|
||||
auth : 1; // == 0
|
||||
};
|
||||
@@ -85,7 +85,7 @@ struct dyld_chained_ptr_arm64e_bind {
|
||||
struct dyld_chained_ptr_arm64e_auth_rebase {
|
||||
uint64_t target : 32, // runtimeOffset
|
||||
diversity : 16, addr_div : 1, key : 2,
|
||||
next : 11, // 4 or 8-byte stide
|
||||
next : 11, // 4 or 8-byte stride
|
||||
bind : 1, // == 0
|
||||
auth : 1; // == 1
|
||||
};
|
||||
@@ -93,7 +93,7 @@ struct dyld_chained_ptr_arm64e_auth_rebase {
|
||||
// DYLD_CHAINED_PTR_ARM64E
|
||||
struct dyld_chained_ptr_arm64e_auth_bind {
|
||||
uint64_t ordinal : 16, zero : 16, diversity : 16, addr_div : 1, key : 2,
|
||||
next : 11, // 4 or 8-byte stide
|
||||
next : 11, // 4 or 8-byte stride
|
||||
bind : 1, // == 1
|
||||
auth : 1; // == 1
|
||||
};
|
||||
@@ -115,7 +115,7 @@ struct dyld_chained_ptr_64_rebase {
|
||||
struct dyld_chained_ptr_arm64e_bind24 {
|
||||
uint64_t ordinal : 24, zero : 8,
|
||||
addend : 19, // +/-256K
|
||||
next : 11, // 8-byte stide
|
||||
next : 11, // 8-byte stride
|
||||
bind : 1, // == 1
|
||||
auth : 1; // == 0
|
||||
};
|
||||
@@ -123,7 +123,7 @@ struct dyld_chained_ptr_arm64e_bind24 {
|
||||
// DYLD_CHAINED_PTR_ARM64E_USERLAND24
|
||||
struct dyld_chained_ptr_arm64e_auth_bind24 {
|
||||
uint64_t ordinal : 24, zero : 8, diversity : 16, addr_div : 1, key : 2,
|
||||
next : 11, // 8-byte stide
|
||||
next : 11, // 8-byte stride
|
||||
bind : 1, // == 1
|
||||
auth : 1; // == 1
|
||||
};
|
||||
@@ -143,7 +143,7 @@ struct dyld_chained_ptr_64_kernel_cache_rebase {
|
||||
cache_level
|
||||
: 2, // what level of cache to bind to (indexes a mach_header array)
|
||||
diversity : 16, addr_div : 1, key : 2,
|
||||
next : 12, // 1 or 4-byte stide
|
||||
next : 12, // 1 or 4-byte stride
|
||||
is_auth : 1; // 0 -> not authenticated. 1 -> authenticated
|
||||
};
|
||||
|
||||
@@ -184,7 +184,7 @@ struct dyld_chained_ptr_arm64e_segmented_rebase {
|
||||
uint32_t target_seg_offset : 28, // offset in segment
|
||||
target_seg_index : 4; // index into segment address table
|
||||
uint32_t padding : 19,
|
||||
next : 12, // 4-byte stide
|
||||
next : 12, // 4-byte stride
|
||||
auth : 1; // == 0
|
||||
};
|
||||
|
||||
@@ -193,7 +193,7 @@ struct dyld_chained_ptr_arm64e_auth_segmented_rebase {
|
||||
uint32_t target_seg_offset : 28, // offset in segment
|
||||
target_seg_index : 4; // index into segment address table
|
||||
uint32_t diversity : 16, addr_div : 1, key : 2,
|
||||
next : 12, // 4-byte stide
|
||||
next : 12, // 4-byte stride
|
||||
auth : 1; // == 1
|
||||
};
|
||||
|
||||
|
||||
@@ -1664,7 +1664,7 @@ DyldInfo& DyldInfo::update_standard_bindings_v1(
|
||||
const DyldInfo::bind_container_t& bindings, vector_iostream& stream
|
||||
) {
|
||||
// This function updates the standard bindings opcodes (i.e. not lazy and not
|
||||
// weak). The following code is mainly inspired from LinkEdit.hpp:
|
||||
// weak). The following code is mainly inspired by LinkEdit.hpp:
|
||||
// BindingInfoAtom<A>::encodeV1()
|
||||
|
||||
std::vector<details::binding_instruction> instructions;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
namespace LIEF::MachO {
|
||||
|
||||
|
||||
// Mainly inspired from LLVM:
|
||||
// Mainly inspired by LLVM:
|
||||
// lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
|
||||
TrieNode::node_list_t TrieNode::add_symbol(const ExportInfo& info) {
|
||||
node_list_t nodes;
|
||||
@@ -108,7 +108,7 @@ TrieNode::node_list_t TrieNode::add_symbol(const ExportInfo& info) {
|
||||
}
|
||||
|
||||
|
||||
// Mainly inspired from LLVM:
|
||||
// Mainly inspired by LLVM:
|
||||
// lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp - addOrderedNodes
|
||||
// Add info in nodes making sure every parent node is inserted before
|
||||
std::vector<TrieNode*> TrieNode::add_ordered_nodes(const ExportInfo& info) {
|
||||
@@ -138,7 +138,7 @@ std::vector<TrieNode*> TrieNode::add_ordered_nodes(const ExportInfo& info) {
|
||||
}
|
||||
|
||||
|
||||
// Mainly inspired from LLVM:
|
||||
// Mainly inspired by LLVM:
|
||||
// lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp - updateOffset
|
||||
bool TrieNode::update_offset(uint32_t& offset) {
|
||||
uint32_t node_size = 1;
|
||||
|
||||
+3
-3
@@ -693,7 +693,7 @@ uint32_t Binary::compute_checksum() const {
|
||||
span<const uint8_t> pad = sec->padding();
|
||||
span<const uint8_t> content = sec->content();
|
||||
if (/* overlapping */ sec->offset() < position) {
|
||||
// Trunc the beginning of the overlap
|
||||
// Truncate the beginning of the overlap
|
||||
if (position <= sec->offset() + content.size()) {
|
||||
const uint64_t start_p = position - sec->offset();
|
||||
const uint64_t size = content.size() - start_p;
|
||||
@@ -846,7 +846,7 @@ std::vector<uint8_t> Binary::authentihash(ALGORITHMS algo) const {
|
||||
pad.size(), sec->offset(),
|
||||
sec->offset() + content.size() + pad.size());
|
||||
if (/* overlapping */ sec->offset() < position) {
|
||||
// Trunc the beginning of the overlap
|
||||
// Truncate the beginning of the overlap
|
||||
if (position <= sec->offset() + content.size()) {
|
||||
const uint64_t start_p = position - sec->offset();
|
||||
const uint64_t size = content.size() - start_p;
|
||||
@@ -1481,4 +1481,4 @@ std::ostream& Binary::print(std::ostream& os) const {
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namesapce PE
|
||||
} // namespace PE
|
||||
|
||||
@@ -76,7 +76,7 @@ std::unique_ptr<DynamicRelocationV2>
|
||||
|
||||
{
|
||||
// Note(romain): As of now (2024-12) I couldn't find any PE that is using
|
||||
// the v2 format. Hence this part is incomplete/not working.
|
||||
// the v2 format. Hence, this part is incomplete/not working.
|
||||
stream.increment_pos(*HeaderSize).increment_pos(*FixupInfoSize);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -472,7 +472,7 @@ ok_error_t Parser::parse_data_directories() {
|
||||
// WARNING: The PE specifications require that the data directory table ends
|
||||
// with a null entry (RVA / Size, set to 0).
|
||||
//
|
||||
// Nevertheless it seems that this requirement is not enforced by the PE loader.
|
||||
// Nevertheless, it seems that this requirement is not enforced by the PE loader.
|
||||
// The binary bc203f2b6a928f1457e9ca99456747bcb7adbbfff789d1c47e9479aac11598af
|
||||
// contains a non-null final data directory (watermarking?)
|
||||
uint32_t nb_dir = binary_->optional_header().numberof_rva_and_size();
|
||||
|
||||
@@ -48,7 +48,7 @@ static_assert(sizeof(delay_imports) == 32, "Wrong sizeof(delay_imports)");
|
||||
|
||||
#include "structures.inc"
|
||||
|
||||
// From Virtualbox - include/iprt/formats/pecoff.h
|
||||
// From VirtualBox - include/iprt/formats/pecoff.h
|
||||
template<typename T>
|
||||
struct load_configuration {
|
||||
uint32_t Characteristics;
|
||||
@@ -236,7 +236,7 @@ class PE64 {
|
||||
}
|
||||
|
||||
|
||||
// end namesapce PE
|
||||
// end namespace PE
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -408,7 +408,7 @@ Signature::VERIFICATION_FLAGS Signature::check(VERIFICATION_CHECKS checks) const
|
||||
}
|
||||
if (should_check_cert_time) {
|
||||
/*
|
||||
* Verify certificate validities
|
||||
* Verify certificate validity periods
|
||||
*/
|
||||
if (x509::time_is_past(cert.valid_to())) {
|
||||
return flags | VERIFICATION_FLAGS::CERT_EXPIRED;
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ result<PE_TYPE> get_type_from_stream(BinaryStream& stream) {
|
||||
/*
|
||||
* We first try to determine PE's type from the OptionalHeader's Magic.
|
||||
* In some cases (cf. https://github.com/lief-project/LIEF/issues/644),
|
||||
* these magic bytes can be "corrupted" without afecting the executing.
|
||||
* these magic bytes can be "corrupted" without affecting the executing.
|
||||
* So the second test to determine the PE's type is to check the value
|
||||
* of SizeOfOptionalHeader we should match sizeof(pe32_optional_header)
|
||||
* for a 32 bits PE or sizeof(pe64_optional_header) for a 64 bits PE file
|
||||
|
||||
@@ -103,7 +103,7 @@ std::vector<std::string>
|
||||
string_table_optimized.reserve(container.size());
|
||||
|
||||
// reverse all symbol names and sort them so we can merge them in the linear
|
||||
// time: aaa, aadd, aaaa, cca, ca -> aaaa, aaa, acc, ac ddaa
|
||||
// time: `aaa, aadd, aaaa, cca, ca` -> `aaaa, aaa, acc, ac ddaa`
|
||||
std::transform(container.begin(), container.end(),
|
||||
std::inserter(string_table, string_table.end()), getter);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
namespace LIEF::runtime {
|
||||
|
||||
namespace details {
|
||||
// The concrete implementation of a Android module
|
||||
// The concrete implementation of an Android module
|
||||
class Module {
|
||||
public:
|
||||
virtual uint64_t imagebase() const = 0;
|
||||
|
||||
@@ -128,5 +128,5 @@ def test_show_field_offsets():
|
||||
assert "/* 0x00 */ int r_version;" in decorated
|
||||
assert "/* 0x08 */ struct link_map *r_map;" in decorated
|
||||
assert "/* 0x20 */ Elf64_Addr r_ldbase;" in decorated
|
||||
# The offset is emitted for every member which includes paddings
|
||||
# The offset is emitted for every member which includes padding
|
||||
assert decorated.count("/* 0x") >= 5
|
||||
|
||||
@@ -92,7 +92,7 @@ def test_simple(tmp_path: Path, flag: str):
|
||||
libadd_dynsym = libadd.dynamic_symbols
|
||||
binadd_dynsym = binadd.dynamic_symbols
|
||||
|
||||
# Change add in the libary
|
||||
# Change add in the library
|
||||
for sym in libadd_dynsym:
|
||||
if sym.name == "add":
|
||||
sym.name = "abc"
|
||||
|
||||
@@ -84,7 +84,7 @@ def process_crypt_and_hash(path: str, delta: int = 0):
|
||||
|
||||
def test_1():
|
||||
"""
|
||||
Simple test on the regular id binary comming from an Apple M1
|
||||
Simple test on the regular id binary coming from an Apple M1
|
||||
This sample does not contains rebase fixups
|
||||
"""
|
||||
fat = parse_macho(
|
||||
|
||||
@@ -315,7 +315,7 @@ def test_segment_index():
|
||||
assert data_seg is not None
|
||||
original_data_index = data_seg.index
|
||||
|
||||
# Add a new segment (it should be placed right beore __LINKEDIT)
|
||||
# Add a new segment (it should be placed right before __LINKEDIT)
|
||||
segment = lief.MachO.SegmentCommand("__LIEF", [0x60] * 0x100)
|
||||
segment = binary.add(segment) # type: ignore[assignment]
|
||||
assert isinstance(segment, lief.MachO.SegmentCommand)
|
||||
|
||||
@@ -153,7 +153,7 @@ def test_api():
|
||||
"39:83:81:6a:7d:1c:62:96:25:40:ec:66:fa:87:90:fa:45:d1:06:3c:b2:3e:93:36:77:de:45:9f:0b:73:c5:77"
|
||||
)
|
||||
|
||||
# Check un-authenticated attributes
|
||||
# Check unauthenticated attributes
|
||||
unauth_attrs = signer.unauthenticated_attributes
|
||||
assert len(unauth_attrs) == 1
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ def test_simple():
|
||||
assert len(binary.imported_functions) == 87
|
||||
assert len(binary.libraries) == 3
|
||||
|
||||
# Now check in depth the delay imports
|
||||
# Now check the delay imports in depth
|
||||
shlwapi = binary.delay_imports[0]
|
||||
assert shlwapi.name == "SHLWAPI.dll"
|
||||
assert shlwapi.attribute == 1
|
||||
|
||||
@@ -18,7 +18,7 @@ def test_without_imports():
|
||||
|
||||
def test_casse():
|
||||
"""
|
||||
Test that casse doesn't change the hash
|
||||
Test that case doesn't change the hash
|
||||
"""
|
||||
factory_lhs = lief.PE.Factory.create(lief.PE.PE_TYPE.PE32)
|
||||
assert factory_lhs is not None
|
||||
|
||||
@@ -11,7 +11,7 @@ def test_vdex06():
|
||||
telecom = lief.VDEX.parse(get_sample("VDEX/VDEX_06_AArch64_Telecom.vdex"))
|
||||
assert telecom is not None
|
||||
|
||||
# 1 Dex File registred
|
||||
# 1 Dex File registered
|
||||
assert len(telecom.dex_files) == 1
|
||||
|
||||
dex_file = telecom.dex_files[0]
|
||||
|
||||
@@ -11,7 +11,7 @@ def test_vdex10():
|
||||
telecom = lief.VDEX.parse(get_sample("VDEX/VDEX_10_AArch64_Telecom.vdex"))
|
||||
assert telecom is not None
|
||||
|
||||
# 1 Dex File registred
|
||||
# 1 Dex File registered
|
||||
assert len(telecom.dex_files) == 1
|
||||
|
||||
dex_file = telecom.dex_files[0]
|
||||
|
||||
Reference in New Issue
Block a user