diff --git a/.gitignore b/.gitignore
index bf839aa91c86e1..221e4f4062486a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -144,6 +144,7 @@ tools/*/*.i.tmp
/deps/**/.github/
# Ignore dependencies fetched by tools/v8/fetch_deps.py
/deps/.cipd
+!deps/LIEF/**
# === Rules for Windows vcbuild.bat ===
/temp-vcbuild
diff --git a/LICENSE b/LICENSE
index 8090eacac19436..65f97b30e9b633 100644
--- a/LICENSE
+++ b/LICENSE
@@ -960,6 +960,212 @@ The externally maintained libraries used by Node.js are:
license.
"""
+- LIEF, located at deps/LIEF, is licensed as follows:
+ """
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2017 - 2025 R. Thomas
+ Copyright 2017 - 2025 Quarkslab
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ """
+
- llhttp, located at deps/llhttp, is licensed as follows:
"""
This software is licensed under the MIT License.
@@ -1022,7 +1228,8 @@ The externally maintained libraries used by Node.js are:
SOFTWARE.
"""
-- postject, located at test/fixtures/postject-copy, is licensed as follows:
+- postject, located at test/fixtures/postject-copy and used as a basis for
+ src/node_sea_bin.cc, is licensed as follows:
"""
Postject is licensed for use as follows:
diff --git a/configure.py b/configure.py
index 04a7db46856016..5506616a0deef2 100755
--- a/configure.py
+++ b/configure.py
@@ -835,6 +835,12 @@
default=None,
help='do not install the bundled Amaro (TypeScript utils)')
+parser.add_argument('--without-lief',
+ action='store_true',
+ dest='without_lief',
+ default=None,
+ help='build without LIEF (Library for instrumenting executable formats)')
+
parser.add_argument('--without-npm',
action='store_true',
dest='without_npm',
@@ -1701,6 +1707,12 @@ def configure_node(o):
o['variables']['single_executable_application'] = b(not options.disable_single_executable_application)
if options.disable_single_executable_application:
o['defines'] += ['DISABLE_SINGLE_EXECUTABLE_APPLICATION']
+ o['variables']['node_use_lief'] = 'false'
+ else:
+ if (options.without_lief is not None):
+ o['variables']['node_use_lief'] = b(not options.without_lief)
+ else:
+ o['variables']['node_use_lief'] = 'true'
o['variables']['node_with_ltcg'] = b(options.with_ltcg)
if flavor != 'win' and options.with_ltcg:
diff --git a/deps/LIEF/LICENSE b/deps/LIEF/LICENSE
new file mode 100644
index 00000000000000..0c225d7eeb8036
--- /dev/null
+++ b/deps/LIEF/LICENSE
@@ -0,0 +1,202 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2017 - 2025 R. Thomas
+ Copyright 2017 - 2025 Quarkslab
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/deps/LIEF/README.md b/deps/LIEF/README.md
new file mode 100644
index 00000000000000..0276c436d973d3
--- /dev/null
+++ b/deps/LIEF/README.md
@@ -0,0 +1,237 @@
+
+
+
+
+
+
+ Blog •
+ Documentation •
+ About
+
+
+
+# About
+
+The purpose of this project is to provide a cross-platform library to parse,
+modify and abstract ELF, PE and MachO formats.
+
+**Main features**:
+
+ * **Parsing**: LIEF can parse [ELF](https://lief.re/doc/latest/formats/elf/index.html), [PE](https://lief.re/doc/latest/formats/pe/index.html), [MachO](https://lief.re/doc/latest/formats/macho/index.html), [COFF](https://lief.re/doc/latest/formats/coff/index.html), OAT, DEX, VDEX, ART and provides an user-friendly API to access to internals.
+ * **Modify**: LIEF can use to modify some parts of these formats (adding a section, changing a symbol's name, ...)
+ * **Abstract**: Three formats have common features like sections, symbols, entry point... LIEF factors them.
+ * **API**: LIEF can be used in [C++](https://lief.re/doc/latest/doxygen/), Python, [Rust](https://lief-rs.s3.fr-par.scw.cloud/doc/latest/lief/index.html) and C
+
+**Extended features**:
+
+ * [**DWARF/PDB** Support](https://lief.re/doc/latest/extended/debug_info/index.html)
+ * [**Objective-C** Metadata](https://lief.re/doc/latest/extended/objc/index.html)
+ * [**Dyld Shared Cache**](https://lief.re/doc/latest/extended/dsc/index.html) with support for extracting Dylib
+ * [**Disassembler**](https://lief.re/doc/latest/extended/disassembler/index.html): AArch64, x86/x86-64, ARM, RISC-V, Mips, PowerPC, eBPF
+ * [**Assembler**](https://lief.re/doc/latest/extended/assembler/index.html): AArch64, x86/x86-64
+
+**Plugins**:
+
+ * [**Ghidra**](https://lief.re/doc/latest/plugins/ghidra/index.html)
+ * [**BinaryNinja**](https://lief.re/doc/latest/plugins/binaryninja/index.html)
+
+# Content
+
+- [About](#about)
+- [Download / Install](#downloads--install)
+- [Getting started](#getting-started)
+- [Blog](https://lief.re/blog/)
+- [Documentation](#documentation)
+ - [Rust](https://lief.re/doc/stable/rust/lief/)
+ - [Sphinx](https://lief.re/doc/latest/index.html)
+ - [Doxygen](https://lief.re/doc/latest/doxygen/index.html)
+ - Tutorials:
+ - [Parse and manipulate formats](https://lief.re/doc/latest/tutorials/01_play_with_formats.html)
+ - [Play with ELF symbols](https://lief.re/doc/latest/tutorials/03_elf_change_symbols.html)
+ - [PE Resources](https://lief.re/doc/latest/tutorials/07_pe_resource.html)
+ - [Transforming an ELF executable into a library](https://lief.re/doc/latest/tutorials/08_elf_bin2lib.html)
+ - [How to use frida on a non-rooted device](https://lief.re/doc/latest/tutorials/09_frida_lief.html)
+ - [Android formats](https://lief.re/doc/latest/tutorials/10_android_formats.html)
+ - [Mach-O modification](https://lief.re/doc/latest/tutorials/11_macho_modification.html)
+ - [ELF Coredump](https://lief.re/doc/latest/tutorials/12_elf_coredump.html)
+ - [PE Authenticode](https://lief.re/doc/latest/tutorials/13_pe_authenticode.html)
+- [Contact](#contact)
+- [About](#about)
+ - [Authors](#authors)
+ - [License](#license)
+ - [Bibtex](#bibtex)
+
+## Downloads / Install
+
+## C++
+
+```cmake
+find_package(LIEF REQUIRED)
+target_link_libraries(my-project LIEF::LIEF)
+```
+
+## Rust
+
+```toml
+[package]
+name = "my-awesome-project"
+version = "0.0.1"
+edition = "2021"
+
+[dependencies]
+lief = "0.17.1"
+```
+
+## Python
+
+To install the latest **version** (release):
+
+```console
+pip install lief
+```
+
+To install nightly build:
+
+```console
+pip install [--user] --force-reinstall --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief==1.0.0.dev0
+```
+
+### Packages
+
+- LIEF Extended: https://extended.lief.re (GitHub OAuth)
+- **Nightly**:
+ * SDK: https://lief.s3-website.fr-par.scw.cloud/latest/sdk
+ * Python Wheels: https://lief.s3-website.fr-par.scw.cloud/latest/lief
+- **v0.17.1**: https://github.com/lief-project/LIEF/releases/tag/0.17.1
+
+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)
+ * [CMake](https://lief.re/doc/latest/installation.html#cmake-integration)
+
+## Getting started
+
+### Python
+
+```python
+import lief
+
+# ELF
+binary = lief.parse("/usr/bin/ls")
+for section in binary.sections:
+ print(section.name, section.virtual_address)
+
+# PE
+binary = lief.parse("C:\\Windows\\explorer.exe")
+
+if rheader := pe.rich_header:
+ print(rheader.key)
+
+# Mach-O
+binary = lief.parse("/usr/bin/ls")
+for fixup in binary.dyld_chained_fixups:
+ print(fixup)
+```
+
+### Rust
+
+```rust
+use lief::Binary;
+use lief::pe::debug::Entries::CodeViewPDB;
+
+if let Some(Binary::PE(pe)) = Binary::parse(path.as_str()) {
+ for entry in pe.debug() {
+ if let CodeViewPDB(pdb_view) = entry {
+ println!("{}", pdb_view.filename());
+ }
+ }
+}
+```
+
+### C++
+
+```cpp
+#include
+
+int main(int argc, char** argv) {
+ // ELF
+ if (std::unique_ptr elf = LIEF::ELF::Parser::parse("/bin/ls")) {
+ for (const LIEF::ELF::Section& section : elf->sections()) {
+ std::cout << section->name() << ' ' << section->virtual_address() << '\n';
+ }
+ }
+
+ // PE
+ if (std::unique_ptr pe = LIEF::PE::Parser::parse("C:\\Windows\\explorer.exe")) {
+ if (const LIEF::PE::RichHeader* rheader : pe->rich_header()) {
+ std::cout << rheader->key() << '\n';
+ }
+ }
+
+ // Mach-O
+ if (std::unique_ptr macho = LIEF::MachO::Parser::parse("/bin/ls")) {
+ for (const LIEF::MachO::DyldChainedFixups& fixup : macho->dyld_chained_fixups()) {
+ std::cout << fixup << '\n';
+ }
+ }
+
+ return 0;
+}
+
+```
+
+### C (Limited API)
+
+```cpp
+#include
+
+int main(int argc, char** argv) {
+ Elf_Binary_t* elf = elf_parse("/usr/bin/ls");
+
+ Elf_Section_t** sections = elf->sections;
+
+ for (size_t i = 0; sections[i] != NULL; ++i) {
+ printf("%s\n", sections[i]->name);
+ }
+
+ elf_binary_destroy(elf);
+ return 0;
+}
+```
+
+## Documentation
+
+* [Main documentation](https://lief.re/doc/latest/index.html)
+* [Doxygen](https://lief.re/doc/latest/doxygen/index.html)
+* [Rust](https://lief.re/doc/stable/rust/lief/)
+
+## Contact
+
+* **Mail**: contact at lief re
+* **Discord**: [LIEF](https://discord.gg/7hRFGWYedu)
+
+## About
+
+### Authors
+
+Romain Thomas ([@rh0main](https://www.romainthomas.fr/)) - Formerly at [Quarkslab](https://www.quarkslab.com)
+
+### License
+
+LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.17.1/LICENSE).
+
+### Bibtex
+
+```bibtex
+@MISC {LIEF,
+ author = "Romain Thomas",
+ title = "LIEF - Library to Instrument Executable Formats",
+ howpublished = "https://lief.quarkslab.com/",
+ month = "apr",
+ year = "2017"
+}
+```
+
+
diff --git a/deps/LIEF/config/mbedtls/config.h b/deps/LIEF/config/mbedtls/config.h
new file mode 100644
index 00000000000000..1007c99aee06ab
--- /dev/null
+++ b/deps/LIEF/config/mbedtls/config.h
@@ -0,0 +1,5 @@
+#include "mbedtls/mbedtls_config.h"
+
+#if defined (MBEDTLS_ARCH_IS_X86)
+#undef MBEDTLS_AESNI_C
+#endif
diff --git a/deps/LIEF/include/LIEF/ART.hpp b/deps/LIEF/include/LIEF/ART.hpp
new file mode 100644
index 00000000000000..7d920b61be47c4
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART.hpp
@@ -0,0 +1,28 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_H
+#define LIEF_ART_H
+
+#include "LIEF/config.h"
+
+#if defined(LIEF_ART_SUPPORT)
+#include "LIEF/ART/Parser.hpp"
+#include "LIEF/ART/utils.hpp"
+#include "LIEF/ART/File.hpp"
+#include "LIEF/ART/EnumToString.hpp"
+#endif
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/EnumToString.hpp b/deps/LIEF/include/LIEF/ART/EnumToString.hpp
new file mode 100644
index 00000000000000..a377b91a35764b
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/EnumToString.hpp
@@ -0,0 +1,40 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_ENUM_TO_STRING_H
+#define LIEF_ART_ENUM_TO_STRING_H
+#include "LIEF/visibility.h"
+#include "LIEF/ART/enums.hpp"
+
+namespace LIEF {
+namespace ART {
+
+LIEF_API const char* to_string(STORAGE_MODES e);
+
+LIEF_API const char* to_string(ART_17::IMAGE_SECTIONS e);
+LIEF_API const char* to_string(ART_29::IMAGE_SECTIONS e);
+LIEF_API const char* to_string(ART_30::IMAGE_SECTIONS e);
+
+LIEF_API const char* to_string(ART_17::IMAGE_METHODS e);
+LIEF_API const char* to_string(ART_44::IMAGE_METHODS e);
+
+LIEF_API const char* to_string(ART_17::IMAGE_ROOTS e);
+LIEF_API const char* to_string(ART_44::IMAGE_ROOTS e);
+
+} // namespace ART
+} // namespace LIEF
+
+#endif
+
diff --git a/deps/LIEF/include/LIEF/ART/File.hpp b/deps/LIEF/include/LIEF/ART/File.hpp
new file mode 100644
index 00000000000000..ea00a53ac186da
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/File.hpp
@@ -0,0 +1,55 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_FILE_H
+#define LIEF_ART_FILE_H
+#include
+
+#include "LIEF/ART/Header.hpp"
+
+#include "LIEF/visibility.h"
+#include "LIEF/Object.hpp"
+
+namespace LIEF {
+namespace ART {
+class Parser;
+
+class LIEF_API File : public Object {
+ friend class Parser;
+
+ public:
+ File& operator=(const File& copy) = delete;
+ File(const File& copy) = delete;
+
+ const Header& header() const;
+ Header& header();
+
+ void accept(Visitor& visitor) const override;
+
+
+ ~File() override;
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const File& art_file);
+
+ private:
+ File();
+
+ Header header_;
+};
+
+}
+}
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/Header.hpp b/deps/LIEF/include/LIEF/ART/Header.hpp
new file mode 100644
index 00000000000000..3aef2eb4e20a9a
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/Header.hpp
@@ -0,0 +1,130 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_HEADER_H
+#define LIEF_ART_HEADER_H
+
+#include
+#include
+
+#include "LIEF/ART/types.hpp"
+#include "LIEF/ART/enums.hpp"
+
+#include "LIEF/visibility.h"
+#include "LIEF/Object.hpp"
+
+namespace LIEF {
+namespace ART {
+class Parser;
+
+class LIEF_API Header : public Object {
+ friend class Parser;
+
+ public:
+ using magic_t = std::array;
+
+ Header();
+
+ template
+ LIEF_LOCAL Header(const T* header);
+
+ Header(const Header&);
+ Header& operator=(const Header&);
+
+ magic_t magic() const;
+ art_version_t version() const;
+
+ uint32_t image_begin() const;
+ uint32_t image_size() const;
+
+ uint32_t oat_checksum() const;
+
+ uint32_t oat_file_begin() const;
+ uint32_t oat_file_end() const;
+
+ uint32_t oat_data_begin() const;
+ uint32_t oat_data_end() const;
+
+ int32_t patch_delta() const;
+
+ uint32_t image_roots() const;
+
+ uint32_t pointer_size() const;
+ bool compile_pic() const;
+
+ uint32_t nb_sections() const;
+ uint32_t nb_methods() const;
+
+ uint32_t boot_image_begin() const;
+ uint32_t boot_image_size() const;
+
+ uint32_t boot_oat_begin() const;
+ uint32_t boot_oat_size() const;
+
+ STORAGE_MODES storage_mode() const;
+
+ uint32_t data_size() const;
+
+ void accept(Visitor& visitor) const override;
+
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Header& hdr);
+
+ ~Header() override;
+
+ private:
+ magic_t magic_;
+ art_version_t version_;
+
+ uint32_t image_begin_;
+ uint32_t image_size_;
+
+ uint32_t oat_checksum_;
+
+ uint32_t oat_file_begin_;
+ uint32_t oat_file_end_;
+
+ uint32_t oat_data_begin_;
+ uint32_t oat_data_end_;
+
+ int32_t patch_delta_;
+ uint32_t image_roots_;
+
+ uint32_t pointer_size_;
+
+ bool compile_pic_;
+
+ uint32_t nb_sections_;
+ uint32_t nb_methods_;
+
+ bool is_pic_;
+
+ // From ART 29
+ // ===========
+ uint32_t boot_image_begin_;
+ uint32_t boot_image_size_;
+
+ uint32_t boot_oat_begin_;
+ uint32_t boot_oat_size_;
+
+ STORAGE_MODES storage_mode_;
+
+ uint32_t data_size_;
+};
+
+} // Namespace ART
+} // Namespace LIEF
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/Parser.hpp b/deps/LIEF/include/LIEF/ART/Parser.hpp
new file mode 100644
index 00000000000000..21d2250e4e92fa
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/Parser.hpp
@@ -0,0 +1,107 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_PARSER_H
+#define LIEF_ART_PARSER_H
+#include
+#include
+#include
+
+#include "LIEF/ART/types.hpp"
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+class BinaryStream;
+namespace ART {
+class File;
+
+
+/// Class which parses an ART file and transform into a ART::File object
+class LIEF_API Parser {
+ public:
+ static std::unique_ptr parse(const std::string& file);
+ static std::unique_ptr parse(std::vector data, const std::string& name = "");
+
+ Parser& operator=(const Parser& copy) = delete;
+ Parser(const Parser& copy) = delete;
+
+ private:
+ Parser();
+ Parser(const std::string& file);
+ Parser(std::vector data);
+ virtual ~Parser();
+
+ void init(const std::string& name, art_version_t version);
+
+ template
+ void parse_file();
+
+ template
+ size_t parse_header();
+
+ template
+ void parse_sections();
+
+ template
+ void parse_roots();
+
+ template
+ void parse_methods();
+
+ // Section parsing
+ template
+ void parse_objects(size_t offset, size_t size);
+
+ template
+ void parse_art_fields(size_t offset, size_t size);
+
+ template
+ void parse_art_methods(size_t offset, size_t size);
+
+ template
+ void parse_interned_strings(size_t offset, size_t size);
+
+ // Parse an **Array** of java.lang.DexCache objects
+ template
+ void parse_dex_caches(size_t offset, size_t size);
+
+ // Parse a **Single** java.lang.DexCache object
+ template
+ void parse_dex_cache(size_t object_offset);
+
+ // Parse an **Array** of java.lang.Class objects
+ template
+ void parse_class_roots(size_t offset, size_t size);
+
+ // Parse java.lang.Class objects
+ template
+ void parse_class(size_t offset);
+
+ // Parse java.lang.String objects
+ template
+ void parse_jstring(size_t offset);
+
+
+ //// Parse a **Single** java.lang.DexCache object
+ //template
+ //void parse_class_roots(size_t object_offset);
+
+ std::unique_ptr file_;
+ std::unique_ptr stream_;
+ uint32_t imagebase_ = 0;
+};
+} // namespace ART
+} // namespace LIEF
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/enums.hpp b/deps/LIEF/include/LIEF/ART/enums.hpp
new file mode 100644
index 00000000000000..2165ea497bd7ce
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/enums.hpp
@@ -0,0 +1,133 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_ENUMS_H
+#define LIEF_ART_ENUMS_H
+
+namespace LIEF {
+namespace ART {
+
+enum STORAGE_MODES {
+ STORAGE_UNCOMPRESSED = 0,
+ STORAGE_LZ4 = 1,
+ STORAGE_LZ4HC = 2,
+};
+
+namespace ART_17 {
+
+enum IMAGE_METHODS {
+ RESOLUTION_METHOD = 0,
+ IMT_CONFLICT_METHOD = 1,
+ IMT_UNIMPLEMENTED_METHOD = 2,
+ CALLEE_SAVE_METHOD = 3,
+ REFS_ONLY_SAVE_METHOD = 4,
+ REFS_AND_ARGS_SAVE_METHOD = 5,
+};
+
+enum IMAGE_SECTIONS {
+ SECTION_OBJECTS = 0,
+ SECTION_ART_FIELDS = 1,
+ SECTION_ART_METHODS = 2,
+ SECTION_INTERNED_STRINGS = 3,
+ SECTION_IMAGE_BITMAP = 4,
+};
+
+enum IMAGE_ROOTS {
+ DEX_CACHES = 0,
+ CLASS_ROOTS = 1,
+};
+
+
+} // Namespace ART_17
+
+
+namespace ART_29 {
+
+using ART_17::IMAGE_METHODS;
+using ART_17::IMAGE_ROOTS;
+
+enum IMAGE_SECTIONS {
+ SECTION_OBJECTS = 0,
+ SECTION_ART_FIELDS = 1,
+ SECTION_ART_METHODS = 2,
+ SECTION_RUNTIME_METHODS = 3, // New in ART 29
+ SECTION_IMT_CONFLICT_TABLES = 4, // New in ART 29
+ SECTION_DEX_CACHE_ARRAYS = 5, // New in ART 29
+ SECTION_INTERNED_STRINGS = 6,
+ SECTION_CLASS_TABLE = 7, // New in ART 29
+ SECTION_IMAGE_BITMAP = 8,
+};
+
+
+
+} // Namespace ART_29
+
+
+namespace ART_30 {
+
+using ART_29::IMAGE_METHODS;
+using ART_29::IMAGE_ROOTS;
+
+enum IMAGE_SECTIONS {
+ SECTION_OBJECTS = 0,
+ SECTION_ART_FIELDS = 1,
+ SECTION_ART_METHODS = 2,
+ SECTION_RUNTIME_METHODS = 3,
+ SECTION_IM_TABLES = 4, // New in ART 30
+ SECTION_IMT_CONFLICT_TABLES = 5,
+ SECTION_DEX_CACHE_ARRAYS = 6,
+ SECTION_INTERNED_STRINGS = 7,
+ SECTION_CLASS_TABLE = 8,
+ SECTION_IMAGE_BITMAP = 9,
+};
+
+} // Namespace ART_30
+
+namespace ART_44 {
+
+using ART_30::IMAGE_SECTIONS;
+
+enum IMAGE_METHODS {
+ RESOLUTION_METHOD = 0,
+ IMT_CONFLICT_METHOD = 1,
+ IMT_UNIMPLEMENTED_METHOD = 2,
+ SAVE_ALL_CALLEE_SAVES_METHOD = 3, // New in ART 44
+ SAVE_REFS_ONLY_METHOD = 4, // New in ART 44
+ SAVE_REFS_AND_ARGS_METHOD = 5, // New in ART 44
+ SAVE_EVERYTHING_METHOD = 6, // New in ART 44
+};
+
+
+enum IMAGE_ROOTS {
+ DEX_CACHES = 0,
+ CLASS_ROOTS = 1,
+ CLASS_LOADER = 2, // New in ART 44
+};
+
+} // Namespace ART_44
+
+
+namespace ART_46 {
+
+using ART_30::IMAGE_SECTIONS;
+using ART_30::IMAGE_METHODS;
+using ART_30::IMAGE_ROOTS;
+
+
+} // Namespace ART_46
+
+}
+}
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/hash.hpp b/deps/LIEF/include/LIEF/ART/hash.hpp
new file mode 100644
index 00000000000000..1aaa7d3acd9211
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/hash.hpp
@@ -0,0 +1,47 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_HASH_H
+#define LIEF_ART_HASH_H
+
+#include "LIEF/visibility.h"
+#include "LIEF/hash.hpp"
+
+namespace LIEF {
+class Object;
+
+namespace ART {
+class File;
+class Header;
+
+class LIEF_API Hash : public LIEF::Hash {
+ public:
+ static LIEF::Hash::value_type hash(const Object& obj);
+
+ public:
+ using LIEF::Hash::Hash;
+ using LIEF::Hash::visit;
+
+ public:
+ void visit(const File& file) override;
+ void visit(const Header& header) override;
+
+ ~Hash() override;
+};
+
+}
+}
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/java_structures.hpp b/deps/LIEF/include/LIEF/ART/java_structures.hpp
new file mode 100644
index 00000000000000..da3514aaffe6dc
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/java_structures.hpp
@@ -0,0 +1,397 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_JAVA_STRUCTURES_H
+#define LIEF_ART_JAVA_STRUCTURES_H
+
+#include
+#include
+
+#include "LIEF/types.hpp"
+#include "LIEF/ART/enums.hpp"
+#include "LIEF/ART/types.hpp"
+
+namespace LIEF {
+/// Namespace related to the LIEF's ART module
+namespace ART {
+
+namespace details {
+
+struct no_brooks_read_barrier_t {};
+
+// ======================
+// Android 6.0.1 - ART 17
+// ======================
+namespace ART_17 {
+
+/// Namespace related to the Java part of ART 17
+namespace Java {
+
+using heap_reference_t = uint32_t;
+
+struct brooks_read_barrier_t {
+ uint32_t x_rb_ptr;
+ uint32_t x_xpadding;
+};
+
+template
+struct jobject_t {
+ heap_reference_t klass;
+ uint32_t monitor;
+ T brooks_read_barrier;
+};
+
+template<>
+struct jobject_t {
+ heap_reference_t klass;
+ uint32_t monitor;
+};
+template
+struct ALIGNED_(4) jarray_t {
+ jobject_t object;
+ int32_t length;
+ uint32_t* elements;
+};
+
+template
+struct ALIGNED_(4) jclass_t {
+ jobject_t object;
+
+ heap_reference_t class_loader;
+ heap_reference_t component_type;
+ heap_reference_t dex_cache;
+ heap_reference_t dex_cache_strings;
+ heap_reference_t iftable;
+ heap_reference_t name;
+ heap_reference_t super_class;
+ heap_reference_t verify_error_class;
+ heap_reference_t vtable;
+
+ uint32_t access_flags;
+ uint64_t direct_methods;
+ uint64_t ifields;
+ uint64_t sfields;
+ uint64_t virtual_methods;
+ uint32_t class_size;
+ uint32_t clinit_thread_id;
+ int32_t dex_class_def_idx;
+ int32_t dex_type_idx;
+ uint32_t num_direct_methods;
+ uint32_t num_instance_fields;
+ uint32_t num_reference_instance_fields;
+ uint32_t num_reference_static_fields;
+ uint32_t num_static_fields;
+ uint32_t num_virtual_methods;
+ uint32_t object_size;
+ uint32_t primitive_type;
+ uint32_t reference_instance_offsets;
+ int32_t status;
+};
+
+template
+struct ALIGNED_(4) jstring_t {
+ jobject_t object;
+ int32_t count;
+ uint32_t hash_code;
+ uint16_t* value;
+};
+
+template
+struct ALIGNED_(4) jdex_cache_t {
+ jobject_t object;
+
+ heap_reference_t dex;
+ heap_reference_t location;
+ heap_reference_t resolved_fields;
+ heap_reference_t resolved_methods;
+ heap_reference_t resolved_types;
+ heap_reference_t strings;
+ uint64_t dex_file;
+};
+
+
+} // Namespace Java
+} // Namespace ART_17
+
+// ======================
+// Android 7.0.0 - ART 29
+// ======================
+namespace ART_29 {
+
+/// Namespace related to the Java part of ART 29
+namespace Java {
+using heap_reference_t = ART_17::Java::heap_reference_t;
+using brooks_read_barrier_t = ART_17::Java::brooks_read_barrier_t;
+
+template
+using jobject_t = ART_17::Java::jobject_t;
+
+template
+using jarray_t = ART_17::Java::jarray_t;
+
+template
+struct ALIGNED_(4) jclass_t {
+ jobject_t object;
+
+ heap_reference_t annotation_type; // ADDED in ART 29
+ heap_reference_t class_loader;
+ heap_reference_t component_type;
+ heap_reference_t dex_cache;
+ // heap_reference_t dex_cache_strings; // REMOVED in ART 29
+ heap_reference_t iftable;
+ heap_reference_t name;
+ heap_reference_t super_class;
+ heap_reference_t verify_error; // Type CHANGED from Class to Object
+ heap_reference_t vtable;
+
+ uint32_t access_flags;
+ uint64_t dex_cache_strings; // direct_methods REPLACED with dex_cache_string
+ uint64_t ifields;
+ uint64_t methods; // ADDED in ART 29
+ uint64_t sfields;
+ uint32_t class_flags; // virtual_methods REPLACED with class_flags
+ uint32_t class_size;
+ uint32_t clinit_thread_id;
+ int32_t dex_class_def_idx;
+ int32_t dex_type_idx;
+ // uint32_t num_direct_methods; // REMOVED in ART 29
+ // uint32_t num_instance_fields; // REMOVED in ART 29
+ uint32_t num_reference_instance_fields;
+ uint32_t num_reference_static_fields;
+ // uint32_t num_static_fields; // REMOVED in ART 29
+ // uint32_t num_virtual_methods; // REMOVED in ART 29
+ uint32_t object_size;
+ uint32_t primitive_type;
+ uint32_t reference_instance_offsets;
+ int32_t status;
+
+ uint16_t copied_methods_offset; // ADDED in ART 29
+ uint16_t virtual_methods_offset; // ADDED in ART 29
+};
+
+
+// No changes in jstring structure
+template
+using jstring_t = ART_17::Java::jstring_t;
+
+template
+struct ALIGNED_(4) jdex_cache_t {
+ jobject_t object;
+
+ heap_reference_t dex;
+ heap_reference_t location;
+ uint64_t dex_file; // LOCATION CHANGED
+ uint64_t resolved_fields; // TYPE CHANGED from heap_reference_t to uint64_t
+ uint64_t resolved_methods; // TYPE CHANGED from heap_reference_t to uint64_t
+ uint64_t resolved_types; // TYPE CHANGED from heap_reference_t to uint64_t
+ uint64_t strings; // TYPE CHANGED from heap_reference_t to uint64_t
+ uint32_t num_resolved_fields; // ADDED in ART 29
+ uint32_t num_resolved_methods; // ADDED in ART 29
+ uint32_t num_resolved_types; // ADDED in ART 29
+ uint32_t num_strings; // ADDED in ART 29
+};
+
+
+
+
+} // Namespace Java
+} // Namespace ART_29
+
+
+// ======================
+// Android 7.1.X - ART 30
+// ======================
+namespace ART_30 {
+
+/// Namespace related to the Java part of ART 30
+namespace Java {
+
+using heap_reference_t = ART_29::Java::heap_reference_t;
+using brooks_read_barrier_t = ART_29::Java::brooks_read_barrier_t;
+
+template
+using jobject_t = ART_29::Java::jobject_t;
+
+template
+using jarray_t = ART_29::Java::jarray_t;
+
+template
+using jclass_t = ART_29::Java::jclass_t;
+
+// No changes in jstring structure
+template
+using jstring_t = ART_29::Java::jstring_t;
+
+// No changes in jdex_cache structure
+template
+using jdex_cache_t = ART_29::Java::jdex_cache_t;
+
+} // Namespace Java
+} // Namespace ART_30
+
+// ======================
+// Android 8.0.0 - ART 44
+// ======================
+namespace ART_44 {
+
+/// Namespace related to the Java part of ART 44
+namespace Java {
+
+
+using heap_reference_t = ART_30::Java::heap_reference_t;
+using brooks_read_barrier_t = ART_30::Java::brooks_read_barrier_t;
+
+template
+using jobject_t = ART_30::Java::jobject_t;
+
+template
+using jarray_t = ART_30::Java::jarray_t;
+
+template
+struct ALIGNED_(4) jclass_t {
+ jobject_t object;
+
+ // heap_reference_t annotation_type; // REMOVED in ART 44
+ heap_reference_t class_loader;
+ heap_reference_t component_type;
+ heap_reference_t dex_cache;
+ heap_reference_t ext_data; // ADDED in ART 44
+ heap_reference_t iftable;
+ heap_reference_t name;
+ heap_reference_t super_class;
+ // heap_reference_t verify_error; // REMOVED in ART 44
+ heap_reference_t vtable;
+
+ // uint32_t access_flags; // REMOVED in ART 44
+ // uint64_t dex_cache_strings; // REMOVED in ART 44
+ uint64_t ifields;
+ uint64_t methods;
+ uint64_t sfields;
+ uint32_t access_flags; // ADDED in ART 44
+ uint32_t class_flags;
+ uint32_t class_size;
+ uint32_t clinit_thread_id;
+ int32_t dex_class_def_idx;
+ int32_t dex_type_idx;
+ uint32_t num_reference_instance_fields;
+ uint32_t num_reference_static_fields;
+ uint32_t object_size;
+ uint32_t object_size_alloc_fast_path; // ADDED in ART 44
+ uint32_t primitive_type;
+ uint32_t reference_instance_offsets;
+ int32_t status;
+ uint16_t copied_methods_offset;
+ uint16_t virtual_methods_offset;
+};
+
+
+// No changes in jstring structure but string can be
+// encoded as as char16_t or char (compressed)
+// count[0] (LSB) == 1 ----> compressed
+// count[0] (LSB) == 0 ----> chat16_t
+template
+using jstring_t = ART_30::Java::jstring_t;
+
+template
+struct ALIGNED_(4) jdex_cache_t {
+ jobject_t object;
+
+ // heap_reference_t dex; // REMOVED in ART 44
+ heap_reference_t location;
+ uint32_t num_resolved_call_sites; // ADDED in ART 44 (related to DEX38 format)
+ uint64_t dex_file;
+ uint64_t resolved_call_sites; // ADDED in ART 44 (related to DEX38 format)
+ uint64_t resolved_fields;
+ uint64_t resolved_method_types; // ADDED in ART 44
+ uint64_t resolved_methods;
+ uint64_t resolved_types;
+ uint64_t strings;
+ uint32_t num_resolved_fields;
+ uint32_t num_resolved_methods_types; // ADDED in ART 44
+ uint32_t num_resolved_methods;
+ uint32_t num_resolved_types;
+ uint32_t num_strings;
+};
+
+
+} // Namespace Java
+} // Namespace ART_44
+
+
+// ======================
+// Android 8.1.X - ART 46
+// ======================
+namespace ART_46 {
+
+/// Namespace related to the Java part of ART 46
+namespace Java {
+
+using heap_reference_t = ART_44::Java::heap_reference_t;
+using brooks_read_barrier_t = ART_44::Java::brooks_read_barrier_t;
+
+template
+using jobject_t = ART_44::Java::jobject_t;
+
+template
+using jarray_t = ART_44::Java::jarray_t;
+
+template
+using jclass_t = ART_44::Java::jclass_t;
+
+template
+using jstring_t = ART_44::Java::jstring_t;
+
+template
+using jdex_cache_t = ART_44::Java::jdex_cache_t;
+
+} // Namespace Java
+} // Namespace ART_46
+
+// ======================
+// Android 9.0.0 - ART 66
+// ======================
+namespace ART_56 {
+
+/// Namespace related to the Java part of ART 46
+namespace Java {
+
+using heap_reference_t = ART_46::Java::heap_reference_t;
+using brooks_read_barrier_t = ART_46::Java::brooks_read_barrier_t;
+
+template
+using jobject_t = ART_46::Java::jobject_t;
+
+template
+using jarray_t = ART_46::Java::jarray_t;
+
+template
+using jclass_t = ART_46::Java::jclass_t;
+
+template
+using jstring_t = ART_46::Java::jstring_t;
+
+template
+using jdex_cache_t = ART_46::Java::jdex_cache_t;
+
+} // Namespace Java
+} // Namespace ART_56
+
+} // namespace details
+} // Namespace ART
+} // Namespace LIEF
+
+
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/json.hpp b/deps/LIEF/include/LIEF/ART/json.hpp
new file mode 100644
index 00000000000000..3302272bd8c51a
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/json.hpp
@@ -0,0 +1,31 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_PUBLIC_JSON_H
+#define LIEF_ART_PUBLIC_JSON_H
+
+#include "LIEF/visibility.h"
+#include
+
+namespace LIEF {
+class Object;
+namespace ART {
+
+LIEF_API std::string to_json(const Object& v);
+
+}
+}
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/types.hpp b/deps/LIEF/include/LIEF/ART/types.hpp
new file mode 100644
index 00000000000000..706e4143d08fbc
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/types.hpp
@@ -0,0 +1,31 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_TYPE_TRAITS_H
+#define LIEF_ART_TYPE_TRAITS_H
+
+#include
+#include
+#include "LIEF/iterators.hpp"
+
+namespace LIEF {
+namespace ART {
+
+using art_version_t = uint32_t;
+
+} // Namesapce ART
+} // Namespace LIEF
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ART/utils.hpp b/deps/LIEF/include/LIEF/ART/utils.hpp
new file mode 100644
index 00000000000000..fc4bcd8e3eede0
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ART/utils.hpp
@@ -0,0 +1,51 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ART_UTILS_H
+#define LIEF_ART_UTILS_H
+
+#include
+#include
+
+#include "LIEF/ART/types.hpp"
+
+#include "LIEF/platforms/android.hpp"
+
+#include "LIEF/types.hpp"
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+namespace ART {
+
+/// Check if the given file is an ART one.
+LIEF_API bool is_art(const std::string& file);
+
+/// Check if the given raw data is an ART one.
+LIEF_API bool is_art(const std::vector& raw);
+
+/// Return the ART version of the given file
+LIEF_API art_version_t version(const std::string& file);
+
+/// Return the ART version of the raw data
+LIEF_API art_version_t version(const std::vector& raw);
+
+/// Return the ANDROID_VERSIONS associated with the given ART version
+LIEF_API LIEF::Android::ANDROID_VERSIONS android_version(art_version_t version);
+
+}
+}
+
+
+#endif
diff --git a/deps/LIEF/include/LIEF/ASM.hpp b/deps/LIEF/include/LIEF/ASM.hpp
new file mode 100644
index 00000000000000..5bc1a376b2c5ba
--- /dev/null
+++ b/deps/LIEF/include/LIEF/ASM.hpp
@@ -0,0 +1,28 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ASM_H
+#define LIEF_ASM_H
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract.hpp b/deps/LIEF/include/LIEF/Abstract.hpp
new file mode 100644
index 00000000000000..bc10e669486524
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract.hpp
@@ -0,0 +1,26 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_H
+#define LIEF_ABSTRACT_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/Binary.hpp b/deps/LIEF/include/LIEF/Abstract/Binary.hpp
new file mode 100644
index 00000000000000..8e4f738a76efdb
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Binary.hpp
@@ -0,0 +1,441 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_BINARY_H
+#define LIEF_ABSTRACT_BINARY_H
+
+#include
+#include
+#include
+
+#include "LIEF/visibility.h"
+#include "LIEF/Object.hpp"
+#include "LIEF/iterators.hpp"
+#include "LIEF/errors.hpp"
+#include "LIEF/span.hpp"
+
+#include "LIEF/Abstract/Header.hpp"
+#include "LIEF/Abstract/Function.hpp"
+
+#include "LIEF/asm/Instruction.hpp"
+#include "LIEF/asm/AssemblerConfig.hpp"
+
+namespace llvm {
+class MCInst;
+}
+
+/// LIEF namespace
+namespace LIEF {
+class Section;
+class Relocation;
+class Symbol;
+
+class DebugInfo;
+
+namespace assembly {
+class Engine;
+}
+
+/// Generic interface representing a binary executable.
+///
+/// This class provides a unified interface across multiple binary formats
+/// such as ELF, PE, Mach-O, and others. It enables users to access binary
+/// components like headers, sections, symbols, relocations,
+/// and functions in a format-agnostic way.
+///
+/// Subclasses like LIEF::PE::Binary implement format-specific API
+class LIEF_API Binary : public Object {
+ public:
+
+ /// Enumeration of virtual address types used for patching and memory access.
+ enum class VA_TYPES {
+ /// Automatically determine if the address is absolute or relative
+ /// (default behavior).
+ AUTO = 0,
+
+ /// Relative Virtual Address (RVA), offset from image base.
+ RVA = 1,
+
+ /// Absolute Virtual Address.
+ VA = 2
+ };
+
+ enum FORMATS {
+ UNKNOWN = 0,
+ ELF,
+ PE,
+ MACHO,
+ OAT,
+ };
+
+ using functions_t = std::vector;
+
+ /// Internal container
+ using sections_t = std::vector;
+
+ /// Iterator that outputs LIEF::Section&
+ using it_sections = ref_iterator;
+
+ /// Iterator that outputs const LIEF::Section&
+ using it_const_sections = const_ref_iterator;
+
+ /// Internal container
+ using symbols_t = std::vector;
+
+ /// Iterator that outputs LIEF::Symbol&
+ using it_symbols = ref_iterator;
+
+ /// Iterator that outputs const LIEF::Symbol&
+ using it_const_symbols = const_ref_iterator;
+
+ /// Internal container
+ using relocations_t = std::vector;
+
+ /// Iterator that outputs LIEF::Relocation&
+ using it_relocations = ref_iterator;
+
+ /// Iterator that outputs const LIEF::Relocation&
+ using it_const_relocations = const_ref_iterator;
+
+ /// Instruction iterator
+ using instructions_it = iterator_range;
+
+ public:
+ Binary();
+ Binary(FORMATS fmt);
+
+ ~Binary() override;
+
+ Binary& operator=(const Binary&) = delete;
+ Binary(const Binary&) = delete;
+
+ /// Executable format (ELF, PE, Mach-O) of the underlying binary
+ FORMATS format() const {
+ return format_;
+ }
+
+ /// Return the abstract header of the binary
+ Header header() const {
+ return get_abstract_header();
+ }
+
+ /// Return an iterator over the abstracted symbols in which the elements **can** be modified
+ it_symbols symbols() {
+ return get_abstract_symbols();
+ }
+
+ /// Return an iterator over the abstracted symbols in which the elements **can't** be modified
+ it_const_symbols symbols() const {
+ return const_cast(this)->get_abstract_symbols();
+ }
+
+ /// Check if a Symbol with the given name exists
+ bool has_symbol(const std::string& name) const {
+ return get_symbol(name) != nullptr;
+ }
+
+ /// Return the Symbol with the given name
+ /// If the symbol does not exist, return a nullptr
+ const Symbol* get_symbol(const std::string& name) const;
+
+ Symbol* get_symbol(const std::string& name) {
+ return const_cast(static_cast(this)->get_symbol(name));
+ }
+
+ /// Return an iterator over the binary's sections (LIEF::Section)
+ it_sections sections() {
+ return get_abstract_sections();
+ }
+
+ it_const_sections sections() const {
+ return const_cast(this)->get_abstract_sections();
+ }
+
+ /// Remove **all** the sections in the underlying binary
+ virtual void remove_section(const std::string& name, bool clear = false) = 0;
+
+ /// Return an iterator over the binary relocation (LIEF::Relocation)
+ it_relocations relocations() {
+ return get_abstract_relocations();
+ }
+
+ it_const_relocations relocations() const {
+ return const_cast(this)->get_abstract_relocations();
+ }
+
+ /// Binary's entrypoint (if any)
+ virtual uint64_t entrypoint() const = 0;
+
+ /// Binary's original size
+ uint64_t original_size() const {
+ return original_size_;
+ }
+
+ /// Return the functions exported by the binary
+ functions_t exported_functions() const {
+ return get_abstract_exported_functions();
+ }
+
+ /// Return libraries which are imported by the binary
+ std::vector imported_libraries() const {
+ return get_abstract_imported_libraries();
+ }
+
+ /// Return functions imported by the binary
+ functions_t imported_functions() const {
+ return get_abstract_imported_functions();
+ }
+
+ /// Return the address of the given function name
+ virtual result get_function_address(const std::string& func_name) const;
+
+ /// Method so that a ``visitor`` can visit us
+ void accept(Visitor& visitor) const override;
+
+ std::vector xref(uint64_t address) const;
+
+ /// Patch the content at virtual address @p address with @p patch_value
+ ///
+ /// @param[in] address Address to patch
+ /// @param[in] patch_value Patch to apply
+ /// @param[in] addr_type Specify if the address should be used as an
+ /// absolute virtual address or a RVA
+ virtual void patch_address(uint64_t address, const std::vector& patch_value,
+ VA_TYPES addr_type = VA_TYPES::AUTO) = 0;
+
+ /// Patch the address with the given value
+ ///
+ /// @param[in] address Address to patch
+ /// @param[in] patch_value Patch to apply
+ /// @param[in] size Size of the value in **bytes** (1, 2, ... 8)
+ /// @param[in] addr_type Specify if the address should be used as an absolute virtual address or an RVA
+ virtual void patch_address(uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
+ VA_TYPES addr_type = VA_TYPES::AUTO) = 0;
+
+ /// Return the content located at the given virtual address
+ virtual span
+ get_content_from_virtual_address(uint64_t virtual_address, uint64_t size,
+ VA_TYPES addr_type = VA_TYPES::AUTO) const = 0;
+
+ /// Get the integer value at the given virtual address
+ template
+ LIEF::result get_int_from_virtual_address(
+ uint64_t va, VA_TYPES addr_type = VA_TYPES::AUTO) const
+ {
+ T value;
+ static_assert(std::is_integral::value, "Require an integral type");
+ span raw = get_content_from_virtual_address(va, sizeof(T), addr_type);
+ if (raw.empty() || raw.size() < sizeof(T)) {
+ return make_error_code(lief_errors::read_error);
+ }
+
+ std::copy(raw.data(), raw.data() + sizeof(T),
+ reinterpret_cast(&value));
+ return value;
+ }
+
+ /// Change binary's original size.
+ ///
+ /// @warning
+ /// This function should be used carefully as some optimizations
+ /// can be performed with this value
+ void original_size(uint64_t size) {
+ original_size_ = size;
+ }
+
+ /// Check if the binary is position independent
+ virtual bool is_pie() const = 0;
+
+ /// Check if the binary uses ``NX`` protection
+ virtual bool has_nx() const = 0;
+
+ /// Default image base address if the ASLR is not enabled.
+ virtual uint64_t imagebase() const = 0;
+
+ /// Constructor functions that are called prior any other functions
+ virtual functions_t ctor_functions() const = 0;
+
+ /// Convert the given offset into a virtual address.
+ ///
+ /// @param[in] offset The offset to convert.
+ /// @param[in] slide If not 0, it will replace the default base address (if any)
+ virtual result offset_to_virtual_address(uint64_t offset, uint64_t slide = 0) const = 0;
+
+ virtual std::ostream& print(std::ostream& os) const {
+ return os;
+ }
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Binary& binary) {
+ binary.print(os);
+ return os;
+ }
+
+ /// Return the debug info if present. It can be either a
+ /// LIEF::dwarf::DebugInfo or a LIEF::pdb::DebugInfo
+ ///
+ /// For ELF and Mach-O binaries, it returns the given DebugInfo object **only**
+ /// if the binary embeds the DWARF debug info in the binary itself.
+ ///
+ /// For PE file, this function tries to find the **external** PDB using
+ /// the LIEF::PE::CodeViewPDB::filename() output (if present). One can also
+ /// use LIEF::pdb::load() or LIEF::pdb::DebugInfo::from_file() to get PDB debug
+ /// info.
+ ///
+ /// \warning This function requires LIEF's extended version otherwise it
+ /// **always** return a nullptr
+ DebugInfo* debug_info() const;
+
+ /// Disassemble code starting at the given virtual address and with the given
+ /// size.
+ ///
+ /// ```cpp
+ /// auto insts = binary->disassemble(0xacde, 100);
+ /// for (std::unique_ptr inst : insts) {
+ /// std::cout << inst->to_string() << '\n';
+ /// }
+ /// ```
+ ///
+ /// \see LIEF::assembly::Instruction
+ instructions_it disassemble(uint64_t address, size_t size) const;
+
+ /// Disassemble code starting at the given virtual address
+ ///
+ /// ```cpp
+ /// auto insts = binary->disassemble(0xacde);
+ /// for (std::unique_ptr inst : insts) {
+ /// std::cout << inst->to_string() << '\n';
+ /// }
+ /// ```
+ ///
+ /// \see LIEF::assembly::Instruction
+ instructions_it disassemble(uint64_t address) const;
+
+ /// Disassemble code for the given symbol name
+ ///
+ /// ```cpp
+ /// auto insts = binary->disassemble("__libc_start_main");
+ /// for (std::unique_ptr inst : insts) {
+ /// std::cout << inst->to_string() << '\n';
+ /// }
+ /// ```
+ ///
+ /// \see LIEF::assembly::Instruction
+ instructions_it disassemble(const std::string& function) const;
+
+ /// Disassemble code provided by the given buffer at the specified
+ /// `address` parameter.
+ ///
+ /// \see LIEF::assembly::Instruction
+ instructions_it disassemble(const uint8_t* buffer, size_t size,
+ uint64_t address = 0) const;
+
+
+ /// Disassemble code provided by the given vector of bytes at the specified
+ /// `address` parameter.
+ ///
+ /// \see LIEF::assembly::Instruction
+ instructions_it disassemble(const std::vector& buffer,
+ uint64_t address = 0) const {
+ return disassemble(buffer.data(), buffer.size(), address);
+ }
+
+ instructions_it disassemble(LIEF::span buffer,
+ uint64_t address = 0) const {
+ return disassemble(buffer.data(), buffer.size(), address);
+ }
+
+ instructions_it disassemble(LIEF::span buffer, uint64_t address = 0) const {
+ return disassemble(buffer.data(), buffer.size(), address);
+ }
+
+ /// Assemble **and patch** the provided assembly code at the specified address.
+ ///
+ /// The function returns the generated assembly bytes
+ ///
+ /// ```cpp
+ /// bin->assemble(0x12000440, R"asm(
+ /// xor rax, rbx;
+ /// mov rcx, rax;
+ /// )asm");
+ /// ```
+ ///
+ /// If you need to configure the assembly engine or to define addresses for
+ /// symbols, you can provide your own assembly::AssemblerConfig.
+ std::vector assemble(uint64_t address, const std::string& Asm,
+ assembly::AssemblerConfig& config = assembly::AssemblerConfig::default_config());
+
+ /// Assemble **and patch** the address with the given LLVM MCInst.
+ ///
+ /// \warning Because of ABI compatibility, this MCInst can **only be used**
+ /// with the **same** version of LLVM used by LIEF (see documentation)
+ std::vector assemble(uint64_t address, const llvm::MCInst& inst);
+
+ /// Assemble **and patch** the address with the given LLVM MCInst.
+ ///
+ /// \warning Because of ABI compatibility, this MCInst can **only be used**
+ /// with the **same** version of LLVM used by LIEF (see documentation)
+ std::vector assemble(uint64_t address,
+ const std::vector& insts);
+
+ /// Get the default memory page size according to the architecture and
+ /// the format of the current binary
+ virtual uint64_t page_size() const;
+
+ /// Load and associate an external debug file (e.g., DWARF or PDB) with this binary.
+ ///
+ /// This method attempts to load the debug information from the file located at the given path,
+ /// and binds it to the current binary instance. If successful, it returns a pointer to the
+ /// loaded DebugInfo object.
+ ///
+ /// \param path Path to the external debug file (e.g., `.dwarf`, `.pdb`)
+ /// \return Pointer to the loaded DebugInfo object on success, or `nullptr` on failure.
+ ///
+ /// \warning It is the caller's responsibility to ensure that the debug file is
+ /// compatible with the binary. Incorrect associations may lead to
+ /// inconsistent or invalid results.
+ ///
+ /// \note This function does not verify that the debug file matches the binary's unique
+ /// identifier (e.g., build ID, GUID).
+ DebugInfo* load_debug_info(const std::string& path);
+
+ protected:
+ FORMATS format_ = FORMATS::UNKNOWN;
+ mutable std::unique_ptr debug_info_;
+ mutable std::unordered_map> engines_;
+ uint64_t original_size_ = 0;
+
+ assembly::Engine* get_engine(uint64_t address) const;
+
+ template
+ LIEF_LOCAL assembly::Engine* get_cache_engine(uint64_t address, F&& f) const;
+
+ // These functions need to be overloaded by the object that claims to extend this Abstract Binary
+ virtual Header get_abstract_header() const = 0;
+ virtual symbols_t get_abstract_symbols() = 0;
+ virtual sections_t get_abstract_sections() = 0;
+ virtual relocations_t get_abstract_relocations() = 0;
+
+ virtual functions_t get_abstract_exported_functions() const = 0;
+ virtual functions_t get_abstract_imported_functions() const = 0;
+ virtual std::vector get_abstract_imported_libraries() const = 0;
+};
+
+LIEF_API const char* to_string(Binary::VA_TYPES e);
+LIEF_API const char* to_string(Binary::FORMATS e);
+
+}
+
+
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/DebugInfo.hpp b/deps/LIEF/include/LIEF/Abstract/DebugInfo.hpp
new file mode 100644
index 00000000000000..24961cf791341b
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/DebugInfo.hpp
@@ -0,0 +1,79 @@
+/* Copyright 2022 - 2025 R. Thomas
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_DEBUGINFO_H
+#define LIEF_DEBUGINFO_H
+#include
+#include
+#include
+
+#include "LIEF/visibility.h"
+#include "LIEF/optional.hpp"
+namespace LIEF {
+
+class Binary;
+
+namespace details {
+class DebugInfo;
+}
+
+/// This class provides a generic interface for accessing debug information
+/// from different formats such as DWARF and PDB.
+///
+/// Users can use this interface to access high-level debug features like
+/// resolving function addresses.
+///
+/// See: LIEF::pdb::DebugInfo, LIEF::dwarf::DebugInfo
+class LIEF_API DebugInfo {
+ public:
+ friend class Binary;
+ enum class FORMAT {
+ UNKNOWN = 0,
+ DWARF, PDB,
+ };
+ DebugInfo(std::unique_ptr impl);
+
+ virtual ~DebugInfo();
+
+ virtual FORMAT format() const {
+ return FORMAT::UNKNOWN;
+ }
+
+ /// This function can be used to **down cast** a DebugInfo instance:
+ ///
+ /// ```cpp
+ /// std::unique_ptr dbg = bin->debug_info();
+ /// if (const auto* dwarf = inst->as()) {
+ /// dwarf->find_function("main");
+ /// }
+ /// ```
+ template
+ const T* as() const {
+ static_assert(std::is_base_of::value,
+ "Require Instruction inheritance");
+ if (T::classof(this)) {
+ return static_cast(this);
+ }
+ return nullptr;
+ }
+
+ /// Attempt to resolve the address of the function specified by `name`.
+ virtual optional find_function_address(const std::string& name) const = 0;
+
+ protected:
+ std::unique_ptr impl_;
+};
+
+}
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/Function.hpp b/deps/LIEF/include/LIEF/Abstract/Function.hpp
new file mode 100644
index 00000000000000..66004763d6eca7
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Function.hpp
@@ -0,0 +1,121 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_FUNCTION_H
+#define LIEF_ABSTRACT_FUNCTION_H
+
+#include
+#include
+
+#include "LIEF/Abstract/Symbol.hpp"
+#include "LIEF/visibility.h"
+#include "LIEF/enums.hpp"
+
+namespace LIEF {
+
+/// Class that represents a function in the binary
+class LIEF_API Function : public Symbol {
+ public:
+ /// Flags used to characterize the semantics of the function
+ enum class FLAGS : uint32_t {
+ NONE = 0,
+ /// The function acts as a constructor.
+ ///
+ /// Usually this flag is associated with functions
+ /// that are located in the `.init_array`, `__mod_init_func` or `.tls` sections
+ CONSTRUCTOR = 1 << 0,
+
+ /// The function acts as a destructor.
+ ///
+ /// Usually this flag is associated with functions
+ /// that are located in the `.fini_array` or `__mod_term_func` sections
+ DESTRUCTOR = 1 << 1,
+
+ /// The function is associated with Debug information
+ DEBUG_INFO = 1 << 2,
+
+ /// The function is exported by the binary and the address() method
+ /// returns its virtual address in the binary
+ EXPORTED = 1 << 3,
+
+ /// The function is **imported** by the binary and the address() should return 0
+ IMPORTED = 1 << 4,
+ };
+
+ public:
+ Function() = default;
+ Function(const std::string& name) :
+ Symbol(name)
+ {}
+ Function(uint64_t address) :
+ Function("", address)
+ {}
+ Function(const std::string& name, uint64_t address) :
+ Symbol(name, address)
+ {}
+ Function(const std::string& name, uint64_t address, FLAGS flags) :
+ Function(name, address)
+ {
+ flags_ = flags;
+ }
+
+ Function(const Function&) = default;
+ Function& operator=(const Function&) = default;
+
+ ~Function() override = default;
+
+ /// List of FLAGS
+ std::vector flags_list() const;
+
+ FLAGS flags() const {
+ return flags_;
+ }
+
+ /// Add a flag to the current function
+ Function& add(FLAGS f) {
+ flags_ = (FLAGS)((uint32_t)flags_ | (uint32_t)f);
+ return *this;
+ }
+
+ /// Check if the function has the given flag
+ bool has(FLAGS f) const {
+ return ((uint32_t)flags_ & (uint32_t)f) != 0;
+ }
+
+ /// Address of the current function. For functions that are set with the FLAGS::IMPORTED flag,
+ /// this value is likely 0.
+ uint64_t address() const {
+ return value_;
+ }
+
+ void address(uint64_t address) {
+ value_ = address;
+ }
+
+ void accept(Visitor& visitor) const override;
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Function& entry);
+
+ protected:
+ FLAGS flags_ = FLAGS::NONE;
+};
+
+LIEF_API const char* to_string(Function::FLAGS e);
+}
+
+ENABLE_BITMASK_OPERATORS(LIEF::Function::FLAGS);
+
+#endif
+
diff --git a/deps/LIEF/include/LIEF/Abstract/Header.hpp b/deps/LIEF/include/LIEF/Abstract/Header.hpp
new file mode 100644
index 00000000000000..036e64cf5a5459
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Header.hpp
@@ -0,0 +1,147 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_HEADER_H
+#define LIEF_ABSTRACT_HEADER_H
+
+#include
+#include
+#include
+
+#include "LIEF/Object.hpp"
+#include "LIEF/visibility.h"
+#include "LIEF/enums.hpp"
+
+namespace LIEF {
+namespace ELF {
+class Binary;
+}
+
+namespace PE {
+class Binary;
+}
+
+namespace MachO {
+class Binary;
+}
+
+class LIEF_API Header : public Object {
+ public:
+ enum class ARCHITECTURES {
+ UNKNOWN = 0,
+ ARM,
+ ARM64,
+ MIPS,
+ X86,
+ X86_64,
+ PPC,
+ SPARC,
+ SYSZ,
+ XCORE,
+ RISCV,
+ LOONGARCH,
+ PPC64,
+ };
+
+ enum class ENDIANNESS {
+ UNKNOWN = 0,
+ BIG,
+ LITTLE,
+ };
+
+ enum MODES : uint64_t {
+ NONE = 0,
+
+ BITS_16 = 1LLU << 0, /// 16-bits architecture
+ BITS_32 = 1LLU << 1, /// 32-bits architecture
+ BITS_64 = 1LLU << 2, /// 64-bits architecture
+ THUMB = 1LLU << 3, /// Support ARM Thumb mode
+
+ ARM64E = 1LLU << 4, /// ARM64 with extended (security) features
+ };
+
+ enum class OBJECT_TYPES {
+ UNKNOWN = 0,
+ EXECUTABLE,
+ LIBRARY,
+ OBJECT,
+ };
+
+ static Header from(const LIEF::ELF::Binary& elf);
+ static Header from(const LIEF::PE::Binary& pe);
+ static Header from(const LIEF::MachO::Binary& macho);
+
+ Header() = default;
+ Header(const Header&) = default;
+ Header& operator=(const Header&) = default;
+ ~Header() override = default;
+
+ /// Target architecture
+ ARCHITECTURES architecture() const {
+ return architecture_;
+ }
+
+ /// Optional features for the given architecture
+ MODES modes() const {
+ return modes_;
+ }
+
+ /// MODES as a vector
+ std::vector modes_list() const;
+
+ bool is(MODES m) const {
+ return ((uint64_t)m & (uint64_t)modes_) != 0;
+ }
+
+ OBJECT_TYPES object_type() const {
+ return object_type_;
+ }
+ uint64_t entrypoint() const {
+ return entrypoint_;
+ }
+
+ ENDIANNESS endianness() const {
+ return endianness_;
+ }
+
+ bool is_32() const {
+ return ((uint64_t)modes_ & (uint64_t)MODES::BITS_32) != 0;
+ }
+
+ bool is_64() const {
+ return ((uint64_t)modes_ & (uint64_t)MODES::BITS_64) != 0;
+ }
+
+ void accept(Visitor& visitor) const override;
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Header& hdr);
+
+ protected:
+ ARCHITECTURES architecture_ = ARCHITECTURES::UNKNOWN;
+ OBJECT_TYPES object_type_ = OBJECT_TYPES::UNKNOWN;
+ uint64_t entrypoint_ = 0;
+ ENDIANNESS endianness_ = ENDIANNESS::UNKNOWN;
+ MODES modes_ = MODES::NONE;
+};
+
+LIEF_API const char* to_string(Header::ARCHITECTURES e);
+LIEF_API const char* to_string(Header::OBJECT_TYPES e);
+LIEF_API const char* to_string(Header::MODES e);
+LIEF_API const char* to_string(Header::ENDIANNESS e);
+}
+
+ENABLE_BITMASK_OPERATORS(LIEF::Header::MODES);
+
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/Parser.hpp b/deps/LIEF/include/LIEF/Abstract/Parser.hpp
new file mode 100644
index 00000000000000..9a3665192bb635
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Parser.hpp
@@ -0,0 +1,60 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_PARSER_H
+#define LIEF_ABSTRACT_PARSER_H
+
+#include
+#include
+#include
+
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+class BinaryStream;
+class Binary;
+
+/// Main interface to parse an executable regardless of its format
+class LIEF_API Parser {
+ public:
+ /// Construct an LIEF::Binary from the given filename
+ ///
+ /// @warning If the target file is a FAT Mach-O, it will return the **last** one
+ /// @see LIEF::MachO::Parser::parse
+ static std::unique_ptr parse(const std::string& filename);
+
+
+ /// Construct an LIEF::Binary from the given raw data
+ ///
+ /// @warning If the target file is a FAT Mach-O, it will return the **last** one
+ /// @see LIEF::MachO::Parser::parse
+ static std::unique_ptr parse(const std::vector& raw);
+
+ /// Construct an LIEF::Binary from the given stream
+ ///
+ /// @warning If the target file is a FAT Mach-O, it will return the **last** one
+ /// @see LIEF::MachO::Parser::parse
+ static std::unique_ptr parse(std::unique_ptr stream);
+
+ protected:
+ Parser(const std::string& file);
+ uint64_t binary_size_ = 0;
+
+ virtual ~Parser();
+ Parser();
+};
+}
+
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/Relocation.hpp b/deps/LIEF/include/LIEF/Abstract/Relocation.hpp
new file mode 100644
index 00000000000000..c22f8e7a508cf6
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Relocation.hpp
@@ -0,0 +1,98 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_RELOCATION_H
+#define LIEF_ABSTRACT_RELOCATION_H
+
+#include
+#include
+
+#include "LIEF/Object.hpp"
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+/// Class which represents an abstracted Relocation
+class LIEF_API Relocation : public Object {
+
+ public:
+ Relocation() = default;
+
+ /// Constructor from a relocation's address and size
+ Relocation(uint64_t address, uint8_t size) :
+ address_(address),
+ size_(size)
+ {}
+
+ ~Relocation() override = default;
+
+ Relocation& operator=(const Relocation&) = default;
+ Relocation(const Relocation&) = default;
+ void swap(Relocation& other) {
+ std::swap(address_, other.address_);
+ std::swap(size_, other.size_);
+ }
+
+ /// Relocation's address
+ virtual uint64_t address() const {
+ return address_;
+ }
+
+ /// Relocation size in **bits**
+ virtual size_t size() const {
+ return size_;
+ }
+
+ virtual void address(uint64_t address) {
+ address_ = address;
+ }
+
+ virtual void size(size_t size) {
+ size_ = (uint8_t)size;
+ }
+
+ /// Method so that the ``visitor`` can visit us
+ void accept(Visitor& visitor) const override;
+
+
+ /// Comparaison based on the Relocation's **address**
+ virtual bool operator<(const Relocation& rhs) const {
+ return address() < rhs.address();
+ }
+
+ /// Comparaison based on the Relocation's **address**
+ virtual bool operator<=(const Relocation& rhs) const {
+ return !(address() > rhs.address());
+ }
+
+ /// Comparaison based on the Relocation's **address**
+ virtual bool operator>(const Relocation& rhs) const {
+ return address() > rhs.address();
+ }
+
+ /// Comparaison based on the Relocation's **address**
+ virtual bool operator>=(const Relocation& rhs) const {
+ return !(address() < rhs.address());
+ }
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Relocation& entry);
+
+ protected:
+ uint64_t address_ = 0;
+ uint8_t size_ = 0;
+};
+
+
+}
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/Section.hpp b/deps/LIEF/include/LIEF/Abstract/Section.hpp
new file mode 100644
index 00000000000000..eb89b42ccc57a4
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Section.hpp
@@ -0,0 +1,131 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_SECTION_H
+#define LIEF_ABSTRACT_SECTION_H
+
+#include
+#include
+#include
+
+#include "LIEF/span.hpp"
+#include "LIEF/Object.hpp"
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+/// Class which represents an abstracted section
+class LIEF_API Section : public Object {
+ public:
+ static constexpr size_t npos = -1;
+
+ Section() = default;
+ Section(std::string name) :
+ name_(std::move(name))
+ {}
+
+ ~Section() override = default;
+
+ Section& operator=(const Section&) = default;
+ Section(const Section&) = default;
+
+ /// section's name
+ virtual std::string name() const {
+ return name_.c_str();
+ }
+
+ /// Return the **complete** section's name which might
+ /// trailing (``0``) bytes
+ virtual const std::string& fullname() const {
+ return name_;
+ }
+
+ /// section's content
+ virtual span content() const {
+ return {};
+ }
+
+ /// Change the section size
+ virtual void size(uint64_t size) {
+ size_ = size;
+ }
+
+ /// section's size (size in the binary, not the virtual size)
+ virtual uint64_t size() const {
+ return size_;
+ }
+
+ /// Offset in the binary
+ virtual uint64_t offset() const {
+ return offset_;
+ }
+
+ /// Address where the section should be mapped
+ virtual uint64_t virtual_address() const {
+ return virtual_address_;
+ }
+
+ virtual void virtual_address(uint64_t virtual_address) {
+ virtual_address_ = virtual_address;
+ }
+
+ /// Change the section's name
+ virtual void name(std::string name) {
+ name_ = std::move(name);
+ }
+
+ /// Change section content
+ virtual void content(const std::vector&) {}
+
+ virtual void offset(uint64_t offset) {
+ offset_ = offset;
+ }
+
+ /// Section's entropy
+ double entropy() const;
+
+ // Search functions
+ // ================
+ size_t search(uint64_t integer, size_t pos, size_t size) const;
+ size_t search(const std::vector& pattern, size_t pos = 0) const;
+ size_t search(const std::string& pattern, size_t pos = 0) const;
+ size_t search(uint64_t integer, size_t pos = 0) const;
+
+ // Search all functions
+ // ====================
+ std::vector search_all(uint64_t v, size_t size) const;
+
+ std::vector search_all(uint64_t v) const;
+
+ std::vector search_all(const std::string& v) const;
+
+ /// Method so that the ``visitor`` can visit us
+ void accept(Visitor& visitor) const override;
+
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Section& entry);
+
+ protected:
+ std::string name_;
+ uint64_t virtual_address_ = 0;
+ uint64_t size_ = 0;
+ uint64_t offset_ = 0;
+
+ private:
+ template
+ std::vector search_all_(const T& v) const;
+};
+}
+
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/Symbol.hpp b/deps/LIEF/include/LIEF/Abstract/Symbol.hpp
new file mode 100644
index 00000000000000..8d9802beec346c
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/Symbol.hpp
@@ -0,0 +1,97 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_SYMBOLS_H
+#define LIEF_ABSTRACT_SYMBOLS_H
+
+#include
+#include
+
+#include "LIEF/Object.hpp"
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+
+/// This class represents a symbol in an executable format.
+class LIEF_API Symbol : public Object {
+ public:
+ Symbol() = default;
+ Symbol(std::string name) :
+ name_(std::move(name))
+ {}
+
+ Symbol(std::string name, uint64_t value) :
+ name_(std::move(name)), value_(value)
+ {}
+
+ Symbol(std::string name, uint64_t value, uint64_t size) :
+ name_(std::move(name)), value_(value), size_(size)
+ {}
+
+ Symbol(const Symbol&) = default;
+ Symbol& operator=(const Symbol&) = default;
+
+ Symbol(Symbol&&) = default;
+ Symbol& operator=(Symbol&&) = default;
+
+ ~Symbol() override = default;
+
+ void swap(Symbol& other) noexcept;
+
+ /// Return the symbol's name
+ virtual const std::string& name() const {
+ return name_;
+ }
+
+ virtual std::string& name() {
+ return name_;
+ }
+
+ /// Set symbol name
+ virtual void name(std::string name) {
+ name_ = std::move(name);
+ }
+
+ // Symbol's value which is usually the **address** of the symbol
+ virtual uint64_t value() const {
+ return value_;
+ }
+ virtual void value(uint64_t value) {
+ value_ = value;
+ }
+
+ /// This size of the symbol (when applicable)
+ virtual uint64_t size() const {
+ return size_;
+ }
+
+ virtual void size(uint64_t value) {
+ size_ = value;
+ }
+
+ /// Method so that the ``visitor`` can visit us
+ void accept(Visitor& visitor) const override;
+
+ LIEF_API friend std::ostream& operator<<(std::ostream& os, const Symbol& entry);
+
+ protected:
+ std::string name_;
+ uint64_t value_ = 0;
+ uint64_t size_ = 0;
+};
+}
+
+#endif
+
diff --git a/deps/LIEF/include/LIEF/Abstract/hash.hpp b/deps/LIEF/include/LIEF/Abstract/hash.hpp
new file mode 100644
index 00000000000000..26f4a375f446e6
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/hash.hpp
@@ -0,0 +1,49 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_HASH_H
+#define LIEF_ABSTRACT_HASH_H
+
+#include "LIEF/visibility.h"
+#include "LIEF/hash.hpp"
+
+namespace LIEF {
+class Binary;
+class Header;
+class Relocation;
+class Object;
+
+class LIEF_API AbstractHash : public LIEF::Hash {
+ public:
+ static LIEF::Hash::value_type hash(const Object& obj);
+
+ public:
+ using LIEF::Hash::Hash;
+ using LIEF::Hash::visit;
+
+ public:
+ void visit(const Binary& binary) override;
+ void visit(const Header& header) override;
+ void visit(const Section& section) override;
+ void visit(const Symbol& symbol) override;
+ void visit(const Relocation& relocation) override;
+ void visit(const Function& function) override;
+
+ ~AbstractHash() override;
+};
+
+}
+
+#endif
diff --git a/deps/LIEF/include/LIEF/Abstract/json.hpp b/deps/LIEF/include/LIEF/Abstract/json.hpp
new file mode 100644
index 00000000000000..fa05cec3458482
--- /dev/null
+++ b/deps/LIEF/include/LIEF/Abstract/json.hpp
@@ -0,0 +1,30 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ABSTRACT_JSON_H
+#define LIEF_ABSTRACT_JSON_H
+
+#include "LIEF/visibility.h"
+#include
+
+namespace LIEF {
+class Object;
+
+LIEF_API std::string to_json_from_abstract(const Object& v);
+
+}
+
+#endif // LIEF_JSON_SUPPORT
+
diff --git a/deps/LIEF/include/LIEF/BinaryStream/ASN1Reader.hpp b/deps/LIEF/include/LIEF/BinaryStream/ASN1Reader.hpp
new file mode 100644
index 00000000000000..385bb35dd22c08
--- /dev/null
+++ b/deps/LIEF/include/LIEF/BinaryStream/ASN1Reader.hpp
@@ -0,0 +1,72 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_ASN1_READER_H
+#define LIEF_ASN1_READER_H
+
+#include
+#include
+#include
+#include
+
+#include "LIEF/errors.hpp"
+
+struct mbedtls_x509_crt;
+struct mbedtls_x509_time;
+
+namespace LIEF {
+class BinaryStream;
+
+class ASN1Reader {
+ public:
+ ASN1Reader() = delete;
+
+ ASN1Reader(BinaryStream& stream) :
+ stream_(stream)
+ {}
+
+ ASN1Reader(const ASN1Reader&) = delete;
+ ASN1Reader& operator=(const ASN1Reader&) = delete;
+
+
+ result is_tag(int tag);
+
+ result read_tag(int tag);
+ result read_len();
+ result read_alg();
+ result read_oid();
+ result read_bool();
+ result read_int();
+ result read_int64();
+ result> read_large_int();
+
+ result> read_bitstring();
+ result> read_octet_string();
+ result read_utf8_string();
+ result> read_cert();
+ result x509_read_names();
+ result> x509_read_serial();
+ result> x509_read_time();
+
+ std::string get_str_tag();
+
+ static std::string tag2str(int tag);
+
+ private:
+ BinaryStream& stream_;
+};
+
+}
+#endif
diff --git a/deps/LIEF/include/LIEF/BinaryStream/BinaryStream.hpp b/deps/LIEF/include/LIEF/BinaryStream/BinaryStream.hpp
new file mode 100644
index 00000000000000..48c16034e1df4f
--- /dev/null
+++ b/deps/LIEF/include/LIEF/BinaryStream/BinaryStream.hpp
@@ -0,0 +1,476 @@
+/* Copyright 2017 - 2025 R. Thomas
+ * Copyright 2017 - 2025 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIEF_BINARY_STREAM_H
+#define LIEF_BINARY_STREAM_H
+
+#include
+#include
+#include
+#include
+#include
+
+#include "LIEF/endianness_support.hpp"
+#include "LIEF/errors.hpp"
+#include "LIEF/visibility.h"
+
+namespace LIEF {
+class ASN1Reader;
+
+/// Class that is used to a read stream of data from different sources
+class LIEF_API BinaryStream {
+ public:
+ friend class ASN1Reader;
+
+ enum class STREAM_TYPE {
+ UNKNOWN = 0,
+ VECTOR,
+ MEMORY,
+ SPAN,
+ FILE,
+
+ ELF_DATA_HANDLER,
+ };
+
+ BinaryStream(STREAM_TYPE type) :
+ stype_(type)
+ {}
+ virtual ~BinaryStream() = default;
+ virtual uint64_t size() const = 0;
+
+ STREAM_TYPE type() const {
+ return stype_;
+ }
+
+ result read_uleb128(size_t* size = nullptr) const;
+ result read_sleb128(size_t* size = nullptr) const;
+
+ result read_dwarf_encoded(uint8_t encoding) const;
+
+ result read_string(size_t maxsize = ~static_cast(0)) const;
+ result peek_string(size_t maxsize = ~static_cast(0)) const;
+ result peek_string_at(size_t offset, size_t maxsize = ~static_cast(0)) const;
+
+ result read_u16string() const;
+ result peek_u16string() const;
+
+ result read_mutf8(size_t maxsize = ~static_cast(0)) const;
+
+ result read_u16string(size_t length) const;
+ result peek_u16string(size_t length) const;
+ result peek_u16string_at(size_t offset, size_t length) const;
+
+
+ virtual ok_error_t peek_data(std::vector& container,
+ uint64_t offset, uint64_t size,
+ uint64_t virtual_address = 0)
+ {
+ if (size == 0) {
+ return ok();
+ }
+ // Even though offset + size < ... => offset < ...
+ // the addition could overflow so it's worth checking both
+ const bool read_ok = offset <= this->size() && (offset + size) <= this->size()
+ /* Check for an overflow */
+ && (static_cast(offset) >= 0 && static_cast(size) >= 0)
+ && (static_cast(offset + size) >= 0);
+ if (!read_ok) {
+ return make_error_code(lief_errors::read_error);
+ }
+ container.resize(size);
+ if (peek_in(container.data(), offset, size, virtual_address)) {
+ return ok();
+ }
+ return make_error_code(lief_errors::read_error);
+ }
+
+ virtual ok_error_t read_data(std::vector& container, uint64_t size) {
+ if (!peek_data(container, pos(), size)) {
+ return make_error_code(lief_errors::read_error);
+ }
+
+ increment_pos(size);
+ return ok();
+ }
+
+ ok_error_t read_data(std::vector& container) {
+ const size_t size = this->size() - this->pos();
+ return read_data(container, size);
+ }
+
+ template
+ ok_error_t read_objects(std::vector& container, uint64_t count) {
+ if (count == 0) {
+ return ok();
+ }
+ const size_t size = count * sizeof(T);
+ auto ret = peek_objects(container, count);
+ if (!ret) {
+ return make_error_code(lief_errors::read_error);
+ }
+ increment_pos(size);
+ return ok();
+ }
+
+ template