Compare commits

...
881 Commits
Author SHA1 Message Date
Romain Thomas 6f3594f270 Fix title 2026-03-18 07:27:04 +01:00
Romain Thomas 08dc3b7fa8 Bump version 2026-03-18 06:41:57 +01:00
Romain Thomas c027a792c9 Update changelog 2026-03-18 06:40:42 +01:00
Romain Thomas b165c5241c Skip NOBITS sections in layout calculations and improve index retrieval
Skips `NOBITS` sections (like `.bss` and `.tbss`) when determining the last
section offset in `LIEF::ELF::Binary::last_offset_section()`.
Since these sections do not occupy space in the file, including them could lead to an unnecessary
increase in the final binary size.
2026-03-17 14:18:36 +01:00
Romain Thomas cb47b28c0b Fix alignment for PHDR/SHDR and improve TLS/RELR handling
This change addresses several issues related to ELF reconstruction.
It ensures compatibility with stricter loaders (like Android's linker)
and fix and issue with `STT_TLS` symbols

Resolve #1315
2026-03-17 14:17:31 +01:00
Itamar GafniandClaude Opus 4.6 418c55f1a8 fix(PE): Add bounds to import thunk parsing to prevent hangs
The import thunk loop in Parser.tcc has no iteration limit and calls
peek_string_at() with no max length. A malformed PE with an unterminated
IAT causes the loop to process hundreds of thousands of fake entries,
each triggering multi-megabyte string reads — hanging indefinitely.

This is a DoS vector against any system using LIEF for PE analysis.

Fixes:
1. Cap the thunk loop at MAX_IMPORT_ENTRIES (65536) per DLL
2. Bound peek_string_at to MAX_IMPORT_NAME_SIZE (4096) bytes
3. Warn when the limit is hit so users know the IAT was truncated

Follows the existing pattern used by MAX_TLS_CALLBACKS and
MAX_RELOCATION_ENTRIES.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 14:15:09 +01:00
Romain Thomas b9134341c7 Bump version 2026-03-08 09:13:36 +01:00
Romain Thomas 98e0a77dbf Update changelog 2026-03-08 09:03:13 +01:00
Romain Thomas 8ff9a881e0 Fix dynamic entry shifting for Android relocations
Android-specific relocation dynamic entry tags (`ANDROID_REL`, `ANDROID_RELA`,
`ANDROID_RELR`) were missing in `Binary::shift_dynamic_entries()`

Resolve #1309
2026-03-08 08:52:51 +01:00
Charles BousseauandRomain Thomas 6ff6b3f92c Add TLSDESC_PLT and TLSDESC_GOT to ELF dynamic tags (#1311)
* Add TLSDESC_PLT and TLSDESC_GOT to ELF dynamic tags

---------

Co-authored-by: Romain Thomas <me@romainthomas.fr>
2026-03-07 21:00:02 +01:00
a7a223c443 Add missing segments in X86_64 coredump parser (#1278)
* Add missing segments in x86_64 coredump parser

* Add missing x86_64 segments in Python bindings

* Add typing

---------

Co-authored-by: Lo <llaubin@quarkslab.com>
Co-authored-by: Romain Thomas <me@romainthomas.fr>
2026-03-07 20:45:07 +01:00
Romain Thomas 4ca17d6538 Fix #1313 2026-03-07 20:43:25 +01:00
Romain Thomas 2b7d2a1904 ensures we correctly handle nullptr return value 2026-02-21 20:58:25 +01:00
Romain Thomas 5a837f7023 Fix version 2026-02-21 10:26:29 +01:00
Romain Thomas 45d0e6cdcb Update doc 2026-02-21 08:42:31 +01:00
Romain Thomas c5ad372702 Bump version 2026-02-21 08:38:39 +01:00
Romain Thomas b240acbb00 Update changelog 2026-02-21 08:36:49 +01:00
Romain Thomas f58a30dfc6 Update wheel to 0.46.3 2026-02-21 08:17:04 +01:00
Romain Thomas 7900739500 Update Python backend dependencies 2026-02-21 08:16:56 +01:00
Romain Thomas 4c6715b653 Fix typing 2026-02-21 08:09:33 +01:00
Romain Thomas 0bac402d49 Fix version 2026-02-21 08:09:19 +01:00
Romain Thomas 21da75fb8a Add LIEF_DOC_MINIFY to driver the doc minification 2026-02-21 08:09:03 +01:00
sigewinnefish d2b0c03d14 cmake: LIEFCompilerFlags problems on Windows clang-cl (#1306)
* ignore add clang warning flags if msvc clang

* clang-cl use same as msvc warning flags
2026-02-21 08:08:24 +01:00
Romain Thomas d7e4fb5f98 Fix missing file 2026-02-14 09:56:13 +01:00
Romain Thomas 61df87d20f Fix Windows #define issue
`std::numeric_limits<uint16_t>::max()` can conflict with `#define max`
defined by Windows in `minwindef.h`. Since we are in a public header,
forcing `NOMINMAX` should not be considered.
2026-02-14 09:56:04 +01:00
Romain Thomas 4e921072e6 Update deps
close #1295, #1294
2026-02-14 09:55:51 +01:00
Immortale 896fe42698 Fix address type (#1296) 2026-02-14 09:55:41 +01:00
Javier Lopez-Gomez abb4968e2c Fix LIEF::MachO::Binary::patch_relocation() for tagged pointers (#1302)
Fixes #1300.
2026-02-14 09:55:31 +01:00
Javier Lopez-Gomez 9e429042e2 Fix MachO::Binary::virtual_address_to_offset() for non-file-backed segment (#1301)
Fix #1299.
2026-02-14 09:55:22 +01:00
Romain Thomas 03aca30b53 Bump version 2026-01-24 11:22:30 +01:00
Romain Thomas 1cb571053b Update changelog 2026-01-24 10:40:27 +01:00
Romain Thomas dc95e9c513 Raise an error if we don't provide wheels for a given platform 2026-01-24 10:36:37 +01:00
Romain Thomas 3ab17a5625 Fix iterator typo 2026-01-24 10:36:27 +01:00
Romain Thomas cb115a7165 Resolve #1284 - explicitly provides RVA/VA 2026-01-24 10:36:17 +01:00
Alex KieckerandRomain Thomas a54e5b27b7 Fix bug with PE resources (#1281)
* Fix bug with PE resources, where the PE builder will refuse to create a resources section if there are new resources but one does not exist

* Add test

---------

Co-authored-by: Romain Thomas <me@romainthomas.fr>
2026-01-11 21:00:54 +01:00
Romain Thomas aa2b617f47 Bump version 2026-01-03 09:25:18 +01:00
Romain Thomas b7f367451a Add changelog 2026-01-02 21:04:09 +01:00
fc1cdcd9aa Fix #1273 Infinite loop (#1274)
Fix #1273

---------

Co-authored-by: chengyongru <chengyongru@huorong.cn>
Co-authored-by: Romain Thomas <me@romainthomas.fr>
2026-01-01 20:19:10 +01:00
Romain Thomas 8bba61609f Fix #1277 2026-01-01 20:19:03 +01:00
Trevor Elkins 9698ea666d Fix #1262 2026-01-01 20:18:54 +01:00
Tim SchumacherandThomas Wachter 8ac5c8693c Ensure that added DYN ELF sections are properly aligned (#1266)
The in-page offset from the source segment is now kept, since changing
it may change the semantics of certain types of contents (e.g. ARM64
executable code relying on ADRP instructions).

Additionally, the virtual address of a segment is now properly aligned
in accordance with p_align instead of being hardcoded at the page size.


Fixes: d717340c9 ("Improve the logic of sections insertion in ELF binaries")

Co-authored-by: Thomas Wachter <thomas.wachter@huawei.com>
2025-11-11 17:44:58 +01:00
Romain Thomas 9dff397f38 Decrease the size by the number of relocations removed 2025-11-11 17:44:33 +01:00
Romain Thomas ff27238d4e Resolve #1261 2025-11-11 17:44:22 +01:00
TheBrokenRail dabbb72483 Fix MinGW Build When Some Formats Are Disabled (#1264) 2025-11-11 17:44:08 +01:00
Romain Thomas 2714146f0e Some refactoring and add tests 2025-11-11 17:44:00 +01:00
Wangmo Tenzing 60c3e88777 differentiate between macho fat and java class files 2025-11-11 17:43:49 +01:00
Romain Thomas fe54643fe3 Bump version 2025-10-25 08:43:43 +02:00
Antoine Prouvost 00f3322411 Add missing visibility (#1254) 2025-10-18 05:47:25 +02:00
Romain Thomas 562eacc974 Reorder includes 2025-10-05 07:32:23 +02:00
Romain Thomas 76c54de0e7 Resolve #1251 2025-10-05 07:32:09 +02:00
Romain Thomas 3507c8fefc Fix paging compilation issue 2025-09-21 10:26:06 +02:00
Romain Thomas a416fddb52 Specify version 2025-09-14 16:02:39 +02:00
Romain Thomas 038b60671f Fix version 2025-09-14 11:42:47 +02:00
Romain Thomas 167842ed32 Enable static build 2025-09-13 16:25:25 +02:00
Romain Thomas ae506a509d Add API to access spdlog's sink 2025-09-13 16:25:18 +02:00
Romain Thomas 215a8dd6b2 Fix visibility 2025-09-13 16:25:09 +02:00
Romain Thomas 2b5aebbeff Setup logcat name empty as default 2025-09-13 16:24:48 +02:00
Romain Thomas 2313755619 Resolve #1238 2025-09-07 15:41:15 +02:00
Romain Thomas 86c3e2c19f Add support for custom import suffix (resolve #1239) 2025-09-07 15:40:13 +02:00
Romain Thomas 2f750acf42 Add support for i686-unknown-linux-gnu 2025-08-31 17:03:50 +02:00
Romain Thomas 28573db03a Bootstrap relocations 2025-08-31 16:43:58 +02:00
Romain Thomas 499503d1bd Make sure the Analyzer can run on the given program 2025-08-31 16:43:20 +02:00
Romain Thomas 8cc8535344 Improve binaryninja support for recent relocation formats.
* Android packed (`DT_ANDROID_REL/DT_ANDROID_RELA`)
* Relative (`DT_RELR`)

Could be related to Vector35/binaryninja-api#6535
2025-08-31 16:42:10 +02:00
Romain Thomas 95a26efe1f Resolve #1241 2025-08-31 13:39:11 +02:00
Romain Thomas 1af33bffe9 Bootstrap LIEF-based analyzers 2025-08-24 19:47:45 +02:00
Romain Thomas 6ef787c91a Fix deps 2025-08-24 13:17:41 +02:00
Romain Thomas 227a88282c Fix doc 2025-08-24 10:27:30 +02:00
Romain Thomas 82cedfe516 Fix type 2025-08-24 10:27:30 +02:00
Romain Thomas f6c9cbfe78 Update PE's ImageGuard flags 2025-08-19 09:21:01 +02:00
Romain Thomas 2e7a95844c Update changelog 2025-08-10 14:55:42 +02:00
Romain Thomas c719c4e6ba Add extended info 2025-08-10 13:20:46 +02:00
Romain Thomas e4b4091cba Move to public headers 2025-08-10 13:20:45 +02:00
Romain Thomas c4255935e4 Add offset information 2025-08-10 13:20:44 +02:00
Romain Thomas 1f208904e9 Enhance support for IMAGE_ARM64EC_CODE_RANGE_ENTRY_POINT 2025-08-10 13:20:43 +02:00
Romain Thomas 19eefd9e08 Add 'all' helper 2025-08-10 13:20:42 +02:00
Romain Thomas db6074d00e Add is_shared_cache 2025-08-10 13:20:41 +02:00
Romain Thomas a27b986882 Improve get_function_address 2025-08-10 13:20:40 +02:00
Romain Thomas ff03a9d3e7 Add generic support for Path 2025-08-10 13:20:39 +02:00
Romain Thomas 33bfcead27 Add support to load an external debug file (DWARF/PDB) 2025-08-10 13:20:38 +02:00
Romain Thomas 5787c0f57c Cleanup 2025-08-10 13:20:37 +02:00
Romain Thomas adf7266284 Add is_pdb helper 2025-08-10 13:20:36 +02:00
Romain Thomas f1c908976b Update ARM64 unwind processing.
This commit is essentially a backport of llvm/llvm-project#137895
2025-08-10 13:20:35 +02:00
Romain Thomas f808da8400 Add new UmaFunctionPointers 2025-08-10 13:20:34 +02:00
Romain Thomas 6374b6b11c Add enums for dyld 1284.13 2025-08-10 13:20:33 +02:00
Romain Thomas d12f5710ca Avoid nodiscard warning 2025-08-10 13:20:32 +02:00
Romain Thomas 6310d4a06c Update tl-expected 1.2.0 2025-08-10 13:20:31 +02:00
Romain Thomas f90dc14753 Update utfcpp 4.0.6 2025-08-10 13:20:30 +02:00
Romain Thomas f0b254cb47 Update mbedtls 3.6.4 2025-08-10 13:20:29 +02:00
Romain Thomas 8f808d447d Update spdlog 2025-08-10 13:20:28 +02:00
Romain Thomas a7743d72b4 Update nanobind version 2025-08-10 13:20:27 +02:00
Romain Thomas 5b851c9839 LLVM 21 update 2025-08-10 13:20:26 +02:00
alcontre 013ea34be8 Remove unused json-3.11.2.zip dependency (#1240) 2025-08-10 13:20:04 +02:00
Romain Thomas 08df4324b8 Fix type 2025-07-26 13:24:47 +02:00
Romain Thomas 5fb4f0cfa0 Add support for LC_FUNCTION_VARIANTS/LC_FUNCTION_VARIANT_FIXUPS
Note that this support is partially incomplete especially for writing
back Mach-O binaries.
2025-07-26 13:03:39 +02:00
Romain Thomas f999e49345 Bootstrap new MachO segmented chained fixups 2025-07-26 11:26:14 +02:00
Romain Thomas 6afae6c314 Enhance Mach-O support 2025-07-26 07:33:04 +02:00
Romain Thomas b4e598c447 Fix max number of commands 2025-07-26 06:29:10 +02:00
Romain Thomas 1f0dff6c67 Add additional constants 2025-07-26 06:05:04 +02:00
Romain Thomas 2ff359890e Resolve #1236 2025-07-20 20:03:53 +02:00
Romain Thomas ad1d344654 Fix printing 2025-07-20 17:23:43 +02:00
Romain Thomas e1b54248b0 Fix casting error 2025-07-13 21:22:24 +02:00
Romain Thomas 6dba6d8a2f Remove override 2025-07-13 18:27:40 +02:00
Romain Thomas c40dcea762 Add support for contextual assembly patching 2025-07-13 18:09:50 +02:00
Romain Thomas 5c7c8222ce Improve Rust API to remove dynamic entries 2025-07-12 20:38:50 +02:00
Romain Thomas aa5c6378f2 Install LIEF core as an option 2025-07-12 17:07:09 +02:00
Romain Thomas 6f48fb1216 Update doc 2025-07-12 12:39:57 +02:00
Romain Thomas 0762ca3cf4 Resolve #1233 2025-07-12 11:39:49 +02:00
Romain Thomas 7fce27408a Provide lief-patchelf: a LIEF-based implementation of NixOS's patchelf
Related: NixOS/patchelf#568
Support: NixOS/patchelf#596
2025-07-12 10:01:33 +02:00
Romain Thomas 9599415297 Fix typing 2025-07-12 06:06:25 +02:00
Romain Thomas baa063c823 Add support to remove version from .gnu.version_r 2025-06-29 19:05:06 +02:00
Romain Thomas 836620bfbb Add API to remove a version requirement from a symbol 2025-06-29 17:34:58 +02:00
Romain Thomas 22d994946d Fix aligment 2025-06-29 09:48:31 +02:00
Romain Thomas a1e0155007 Enhance support for endian and s390x support 2025-06-29 09:07:45 +02:00
Romain Thomas 8d33da12d9 Enhance support for modifying Linux loader 2025-06-29 08:46:46 +02:00
Romain Thomas f4d7a9bbf3 Fix BinaryNinja api 2025-06-28 16:30:27 +02:00
Romain Thomas 500115fd00 Add support for x32 (ILP32) ELF (resolve #1225) 2025-06-28 11:29:33 +02:00
Romain Thomas 497b95e3de Add support for SH4 2025-06-28 09:35:21 +02:00
Romain Thomas 7e70586046 Improve LIEF Rust bindings 2025-06-24 18:39:47 +02:00
Romain Thomas 8e0c432655 Pass by ref instead of move 2025-06-24 16:55:09 +02:00
Romain Thomas e661bb7422 Improve page size support 2025-06-24 16:48:02 +02:00
Romain Thomas 3e8fa7f946 Enable constexpr 2025-06-24 16:28:53 +02:00
Romain Thomas 543085258b Bump LLVM version 2025-06-24 16:05:18 +02:00
Romain Thomas d585c1e5ae API updates 2025-06-24 16:03:34 +02:00
Romain Thomas 6369464dc5 Fix ; warnings 2025-06-24 16:01:35 +02:00
Romain Thomas c302d3f9b3 Fix typo 2025-06-24 07:53:25 +02:00
Romain Thomas 6bc35d818c Fix constexpr issue 2025-06-24 07:27:44 +02:00
Romain Thomas 6877ce7aba Resolve #1228 2025-06-24 07:27:23 +02:00
Romain Thomas 1b18d17a7e Add doc about Mach-O library/rpath modification 2025-06-24 06:05:26 +02:00
Romain Thomas 0dc02df3ef Update changelog (#1219, #1226) 2025-06-15 16:33:54 +02:00
SquiblydooandRomain Thomas 8f4e011544 Handle non-roman characters and extend OID To String support. (#1226)
* Remove upper character print restriction

* Extend OID support

Previous fallback for unknown OID was to print ??, now it falls back to the OID to String table.

* Update x509.cpp

Update variable names

* Return OID Numeric String if not found

After more testing, I confirmed that if the OID string is not found in either mbedtls or LIEF's table, it would return a non-human-readable string. This change will return the numeric string that could be investigated.

* Revert `OIDToString` changes and add tests

---------

Co-authored-by: Romain Thomas <me@romainthomas.fr>
2025-06-15 16:30:33 +02:00
Romain Thomas 75e359bec0 Update documentation 2025-06-15 10:13:55 +02:00
Romain Thomas a8097e5def Export write_to_bytes for ELF & Mach-O 2025-06-14 20:08:08 +02:00
Romain Thomas 0ad68c228b Fix typo 2025-06-14 10:47:48 +02:00
Romain Thomas 9d97cc0e2d Cast fix 2025-06-14 07:54:32 +02:00
Romain Thomas 81c2a633b2 Add API to assemble a LLVM MCInst 2025-06-14 07:55:10 +02:00
Romain Thomas 024916cf18 Use pointers instead of plain objects 2025-06-14 07:50:01 +02:00
Romain Thomas 2babf12d93 Add support to access and disassemble COFF functions 2025-06-14 07:32:21 +02:00
Romain Thomas b9829e2142 Add generic::Relocation trait for Mach-O relocations (#1222) 2025-06-09 06:41:33 +02:00
Romain Thomas d9e949a463 Fix typing 2025-06-09 06:31:22 +02:00
Romain Thomas 84f963a716 Initial support for the COFF format
Resolve #1091
2025-06-08 20:01:21 +02:00
Romain Thomas 3d4ff6fedf Bump version 2025-06-08 11:55:12 +02:00
Romain Thomas 9260bae262 Fix #define conflicts 2025-06-07 11:50:27 +02:00
Romain Thomas 14bbcabac8 Rename enum to avoid compilation issue 2025-06-07 10:14:23 +02:00
Romain Thomas 223fcbeb37 Fix typo 2025-06-07 06:44:56 +02:00
Romain Thomas d864b91780 Remove C++17 feature in public headers 2025-06-07 06:34:56 +02:00
Saikari 93bc909d42 Add #include "visitors/json.hpp" to json_api.cpp 2025-06-07 07:05:11 +02:00
Romain Thomas c678f6bdfb Make sure commands are within in the correct range 2025-05-30 10:59:40 +02:00
Romain Thomas 55209582b0 Update latest version 2025-05-30 10:59:39 +02:00
Romain Thomas 968d9c24ab Support Mach-O modifications that need to extend commands size
Resolve #1204, resolve #1125
2025-05-30 10:59:35 +02:00
Romain Thomas 065752b757 Fix documentation (related to #1218) 2025-05-30 08:02:32 +02:00
David Gumberg 43afe84570 bugfix: has_nx is inverted for macho binaries 2025-05-30 07:59:13 +02:00
Romain Thomas a1ec0f815f Fix missing PPC64 (resolve #1217) 2025-05-29 13:27:52 +02:00
Romain Thomas 553b927219 Improve tests 2025-05-28 14:26:00 +02:00
Romain Thomas 9b950314bd Accept user's input hint 2025-05-28 06:01:36 +02:00
Romain Thomas 6a3eadcbd4 Update doc 2025-05-27 16:41:09 +02:00
Romain Thomas 38ded048e9 Update changelog 2025-05-27 16:18:51 +02:00
Romain Thomas 149a6d18b3 Fix missing quote 2025-05-27 14:56:07 +02:00
Romain Thomas 5a19dc9d73 Add support for creating DWARF files
This commit also bootstraps plugin for Ghidra and BinaryNinja

Related to NationalSecurityAgency/ghidra#2687
2025-05-27 14:48:07 +02:00
Romain Thomas 6df39ede51 Allow to skip sdk upload 2025-05-27 14:46:50 +02:00
Romain Thomas 4575a6632f Disable GHA wheel upload 2025-05-26 07:42:18 +02:00
Romain Thomas 5bc816c29b Bump LLVM version 2025-05-26 07:39:48 +02:00
dealer.lazy b447488189 Fixed issue with explicit constructor compilation when old (GCC 9.0) compilers used 2025-05-26 07:31:13 +02:00
Romain Thomas 488876d0b5 Make sure libraries are installed in lib/ 2025-05-17 16:44:16 +02:00
Romain Thomas 0bf18b8c24 Fix typo 2025-05-17 16:21:14 +02:00
Romain Thomas 625d84ca1e Fix typo 2025-05-17 14:57:26 +02:00
Romain Thomas 7058c31e2c Fix cast issue 2025-05-17 06:22:52 +02:00
Romain Thomas 851366cec4 Consider the .dynsym table 2025-05-17 06:14:08 +02:00
Romain Thomas 60363f283c Resolve #1206 2025-05-17 06:08:53 +02:00
Romain Thomas ebb2b966ba Housekeeping: remove unused files (from #1211) 2025-05-17 06:05:19 +02:00
Emmanuel Ferdman f409d0c35c Resolve Python Logger warnings
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-05-17 05:56:02 +02:00
Romain Thomas 971a8deac4 Resolve #1210 2025-05-17 05:54:02 +02:00
Romain Thomas bb75e178cc OSX fix 2025-05-10 06:15:17 +02:00
Romain Thomas dc66460141 Make SOVERSION optional (related to #1201) 2025-05-10 06:15:16 +02:00
Cristian Le 494f116c6b Add SOVERSION 2025-05-06 07:34:08 +02:00
Cristian Le 0e72c53729 Include GNUInstallDirs unconditionally 2025-05-06 07:34:08 +02:00
Romain Thomas 8a9c4021ed Move to json 3.12.0 2025-05-04 10:19:16 +02:00
Romain Thomas 8df6f13e41 Resolve #1203 2025-05-03 15:09:21 +02:00
Cristian Le 39a2acd259 Gate Melkor build by option (#1202) 2025-05-03 11:18:01 +02:00
Romain Thomas c4069b6b81 Resolve #1200 2025-05-02 16:46:28 +02:00
kovalev0 c93ee79b2a Hash 9d9cfbb3 fix build warnings (#1195)
* Remove unused variables

Remove unused variables is_arithmetic, is_flag and size
from various files to address compiler warnings.

```
/usr/src/RPM/BUILD/liblief-0.17.0/api/python/src/enums_wrapper.hpp:42:20:
warning: unused variable ‘is_arithmetic’ [-Wunused-variable]
   42 |     constexpr bool is_arithmetic = (std::is_same_v<nanobind::is_arithmetic, Extra> || ...);
      |                    ^~~~~~~~~~~~~

/usr/src/RPM/BUILD/liblief-0.17.0/api/python/src/enums_wrapper.hpp:43:20:
warning: unused variable ‘is_flag’ [-Wunused-variable]
   43 |     constexpr bool is_flag = (std::is_same_v<nanobind::is_flag, Extra> || ...);
      |                    ^~~~~~~

/usr/src/RPM/BUILD/liblief-0.17.0/api/python/src/nanobind/extra/stl/u16string.h:15:20:
warning: unused variable ‘size’ [-Wunused-variable]
   15 |         Py_ssize_t size;
      |                    ^~~~
```

* Fix(asm): Provide namespace-scope declarations for Operand::Iterator op==

Resolves compiler warnings by adding forward declarations for
`LIEF::assembly::{arch}::operator==(const Operand::Iterator&, const Operand::Iterator&)`
in the corresponding header files. The operators were previously only
declared via `friend` declarations inside the Iterator class.

```
[646/872] Building CXX object CMakeFiles/LIB_LIEF.dir/src/asm/asm.cpp.o
/usr/src/RPM/BUILD/liblief-0.17.0/src/asm/asm.cpp:395:6:
warning: ‘bool LIEF::assembly::x86::operator==(const Operand::Iterator&, const Operand::Iterator&)’
	 has not been declared within ‘LIEF::assembly::x86’
  395 | bool x86::operator==(const x86::Operand::Iterator&, const x86::Operand::Iterator&) {
      |      ^~~
In file included from /usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/asm/x86/Instruction.hpp:21,
                 from /usr/src/RPM/BUILD/liblief-0.17.0/src/asm/asm.cpp:27:
/usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/asm/x86/Operand.hpp:60:26: note: only here as a ‘friend’
   60 |     friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
      |                          ^~~~~~~~
/usr/src/RPM/BUILD/liblief-0.17.0/src/asm/asm.cpp:490:6:
warning: ‘bool LIEF::assembly::aarch64::operator==(const Operand::Iterator&, const Operand::Iterator&)’
	 has not been declared within ‘LIEF::assembly::aarch64’
  490 | bool aarch64::operator==(const aarch64::Operand::Iterator&, const aarch64::Operand::Iterator&) {
      |      ^~~~~~~
In file included from /usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/asm/aarch64/Instruction.hpp:21,
                 from /usr/src/RPM/BUILD/liblief-0.17.0/src/asm/asm.cpp:18:
/usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/asm/aarch64/Operand.hpp:60:26: note: only here as a ‘friend’
   60 |     friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
      |                          ^~~~~~~~
```

* Fix MachO ChainedPointerAnalysis pointer interpretation issues

Addresses strict aliasing warnings in getter methods by replacing
`reinterpret_cast` with `memcpy` and returning structures by value.

```
/usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/MachO/ChainedPointerAnalysis.hpp:
In member function ‘const LIEF::MachO::ChainedPointerAnalysis::dyld_chained_ptr_arm64e_rebase_t
	LIEF::MachO::ChainedPointerAnalysis::dyld_chained_ptr_arm64e_rebase() const’:
/usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/MachO/ChainedPointerAnalysis.hpp:307:13:
warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  307 |     return *reinterpret_cast<const dyld_chained_ptr_arm64e_rebase_t*>(&value_);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

...

/usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/MachO/ChainedPointerAnalysis.hpp:
In member function ‘const LIEF::MachO::ChainedPointerAnalysis::dyld_chained_ptr_32_firmware_rebase_t
	LIEF::MachO::ChainedPointerAnalysis::dyld_chained_ptr_32_firmware_rebase() const’:
/usr/src/RPM/BUILD/liblief-0.17.0/include/LIEF/MachO/ChainedPointerAnalysis.hpp:355:13:
warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  355 |     return *reinterpret_cast<const dyld_chained_ptr_32_firmware_rebase_t*>(&value_);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

* Fix PE layout check sign comparison for section index

Addresses Werror=sign-compare in LayoutChecker::check_load_config by
correctly handling potentially negative section index value when
comparing with vector size.

```
/usr/src/RPM/BUILD/liblief-0.17.0/src/PE/layout_check.cpp:447:22:
warning: comparison of integer expressions of different signedness:
  ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  447 |     if ((*value - 1) >= pe.sections().size()) {
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
```

* Fix PE: Rename conflicting local reloc_t structs

Renames local struct 'reloc_t' in DynamicFixupARM64Kernel.cpp and
DynamicFixupControlTransfer.cpp to 'arm64e_kernel_reloc_t' and
'control_transfer_reloc_t' respectively to fix One Definition Rule violations.

```
/usr/src/RPM/BUILD/liblief-0.17.0/src/PE/LoadConfigurations/DynamicRelocation/DynamicFixupARM64Kernel.cpp:35:
warning: type ‘struct reloc_t’ violates the C++ One Definition Rule [-Wodr]
   35 | struct reloc_t {
/usr/src/RPM/BUILD/liblief-0.17.0/src/PE/LoadConfigurations/DynamicRelocation/DynamicFixupControlTransfer.cpp:31:
note: a different type is defined in another translation unit
   31 | struct reloc_t {
```
2025-05-01 17:16:55 +02:00
Romain Thomas 9d9cfbb306 Update changelog 2025-04-30 10:50:52 +02:00
Romain Thomas 5d35ebfbef Fix missing header (resolve #1192) 2025-04-25 07:14:18 +02:00
Romain Thomas 48917ef526 Fix missing initialized field 2025-04-25 07:14:13 +02:00
Romain Thomas abcf929efb Skip if llvm-strip is not found 2025-04-19 23:03:23 +02:00
Romain Thomas 803c7e63a3 Bump version 2025-04-19 19:27:00 +02:00
Romain Thomas a5faa5927e Remove python 3.8 2025-04-19 09:06:46 +02:00
Romain Thomas 8fc5137b3d Add i686-unknown-linux-musl and aarch64-unknown-linux-musl 2025-04-19 08:53:23 +02:00
Romain Thomas 03a61fe300 Fix bug in ELF builder (related to #1175) 2025-04-19 08:32:41 +02:00
Romain Thomas e07ac780dc Update metrics requirements 2025-04-19 08:32:40 +02:00
Romain Thomas f23ced2f4f Update build deps 2025-04-19 08:32:39 +02:00
Romain Thomas 58d1e79b7e Skip for non-linux runner 2025-04-19 08:32:38 +02:00
Romain Thomas d717340c92 Improve the logic of sections insertion in ELF binaries 2025-04-19 08:32:37 +02:00
Romain Thomas cd37b09a52 Update sphinx 2025-04-19 08:32:36 +02:00
Romain Thomas 3133df09d2 Add CI utilities 2025-04-19 08:32:35 +02:00
Romain Thomas e4b453bfcf Specify the architecture 2025-04-15 21:23:19 +02:00
Romain Thomas c87188341f Fix #1189 2025-04-15 21:22:01 +02:00
Romain Thomas 940d5009cb Fix warning 2025-04-12 06:31:03 +02:00
Romain Thomas 6b0446b16e Update nanobind 2025-04-12 06:30:44 +02:00
Romain Thomas 682abb0264 Resolve #1173 2025-04-12 05:49:51 +02:00
Romain Thomas 238ce93ecf Fix #1177 2025-04-12 05:43:48 +02:00
Romain Thomas 9bfe8b1c37 Remove rc 2025-04-06 10:01:24 +02:00
Romain Thomas a22ebad74f Remove beta 2025-04-06 09:38:00 +02:00
Romain Thomas 294cdc0808 Resolve #1186 2025-04-06 09:38:00 +02:00
Khem Raj aecae14f07 Add cstdio include (#1184)
This is needed for uintXX_t types, GCC-15 is defauling to C23 and will error
about it.

e.g.

include/LIEF/PE/LoadConfigurations/VolatileMetadata.hpp:145:3: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-04-05 16:34:34 +02:00
Romain Thomas 1e9b12bd14 Add support for Windows ARM64 2025-03-30 18:10:12 +02:00
Romain Thomas f8b5dc5232 Fix typo 2025-03-30 09:44:27 +02:00
Romain Thomas 0d217ef67b Update enums 2025-03-30 09:43:56 +02:00
LoveSy 5b60645b8c Add remove_dynamic_entries_by_tag and add_dynamic_entry 2025-03-29 14:31:43 +01:00
Romain Thomas 56a2e2294f Update changelog 2025-03-29 11:23:17 +01:00
Romain Thomas 62435492f0 Missing fix for Python bindings 2025-03-29 11:20:18 +01:00
Romain Thomas e1e92aefea Fix unicode issue 2025-03-29 11:06:47 +01:00
Romain Thomas fc7cc1c8a3 Update to LLVM 20.1.2 2025-03-29 05:28:19 +01:00
Romain Thomas 68738194c9 Fix whitespace warning 2025-03-29 05:27:20 +01:00
Romain Thomas 14ab0a9657 Update spdlog 2025-03-29 05:26:18 +01:00
Romain Thomas afee334c6d Add lock file 2025-03-15 11:34:17 +01:00
Romain Thomas 927d5593d1 Update default features 2025-03-15 10:59:40 +01:00
Romain Thomas 0783b74c54 Add support for external fmt 2025-03-15 06:52:56 +01:00
Romain Thomas 0b386c22ba Add named logger API 2025-03-15 06:32:18 +01:00
Romain Thomas 8ae7dc4cf9 MSVC Fix: can't be default because of the RelocationEntry forwarding 2025-03-15 06:13:00 +01:00
Romain Thomas 1de8788c3c CI Update 2025-03-15 06:12:28 +01:00
Romain Thomas dd291ae174 Update latest release 2025-02-23 13:06:30 +01:00
Romain Thomas 2cdd2ae8ff Fix truncated nlist_t.n_type in Mach-O rewriting 2025-02-22 08:03:50 +01:00
Romain Thomas 0397b96569 Update typing 2025-02-22 08:01:56 +01:00
Romain Thomas 3f35394efa Make sure we raise an exception if the value is not valid 2025-02-22 07:42:10 +01:00
Romain Thomas 23d37113a2 Update typing 2025-02-22 07:41:02 +01:00
Romain Thomas 841d02e241 Add 0.16.4 changelog 2025-02-22 07:19:29 +01:00
Romain Thomas 266868cae3 Update nanobind 2025-02-22 07:18:23 +01:00
Romain Thomas 99d540edc2 Improve support for Nanobind external version 2025-02-22 06:20:19 +01:00
Romain Thomas 45ddb0ecf7 Fix enum conflict with Windows 2025-02-22 06:10:09 +01:00
Romain Thomas 5bb039128f Fix issue with AArch64 toolchain 2025-02-22 05:49:49 +01:00
Romain Thomas 055e3c41c3 Fix visibility 2025-02-22 05:45:11 +01:00
Romain Thomas e1eeada181 Remove undef workaround 2025-02-22 05:38:07 +01:00
Romain Thomas c97ec00f8e Fix missing header 2025-02-22 05:12:44 +01:00
Romain Thomas 0614b7f2cf Add support for PDB build metadata 2025-02-22 04:45:58 +01:00
Romain Thomas c1489422bd Update ELF fuzzer 2025-02-22 04:16:15 +01:00
Romain Thomas 0e5db4ea90 Update changelog 2025-02-15 20:50:36 +01:00
Romain Thomas 86760c53d8 Fix Windows conflict 2025-02-15 18:06:55 +01:00
willbokaandwillboka f97627cd58 Dex: add getter for registers count (#1171)
* Add getters for the register count

* Add tests for the getter for the number of registers

* Fix: use const ref to avoid unecessary copy

---------

Co-authored-by: willboka <willbaka>
2025-02-15 17:56:36 +01:00
Romain Thomas eb8fd41011 Fix reference issue 2025-02-15 17:49:52 +01:00
Romain Thomas d69111b359 Fix inputs 2025-02-15 17:49:43 +01:00
Romain Thomas 175c7f4f60 Make sure to link against LLVM's asan version 2025-02-15 17:49:17 +01:00
Romain Thomas ff370cc72c Windows fixes 2025-02-15 10:35:34 +01:00
Romain Thomas 8b2df0d4ad Fix tests 2025-02-15 09:32:04 +01:00
Romain Thomas 913a2c8cea Fix 2025-02-15 08:52:56 +01:00
Romain Thomas 7f338c324d Fix include 2025-02-15 08:26:45 +01:00
Romain Thomas aee7f1e00b MSVC fix 2025-02-15 07:51:07 +01:00
Romain Thomas 25f593be71 Fix missing include 2025-02-15 07:48:02 +01:00
Romain Thomas 9ca593a482 Other fixes 2025-02-15 07:42:26 +01:00
Romain Thomas 1f8d43edb2 MSVC fails without AuxiliarySymbol 2025-02-15 07:33:38 +01:00
Romain Thomas d38d4038de Fix missing ostream 2025-02-15 07:22:37 +01:00
Romain Thomas 2520288b3a Mix missing explicit type 2025-02-15 07:20:10 +01:00
Romain Thomas af3536f7c9 Windows & ARM32 build fixes 2025-02-15 07:13:41 +01:00
Romain Thomas 6761851b5f Minor fixes 2025-02-15 05:44:46 +01:00
Romain Thomas c000b17be0 Enhance PE parser/builder
close #1021
close #1118
close #192
close #276
close #358
close #642
close #746
close #777
resolve #1043
resolve #109
resolve #114
resolve #1167
resolve #124
resolve #137
resolve #140
resolve #277
resolve #472
resolve #473
resolve #517
resolve #523
resolve #528
resolve #530
resolve #546
resolve #69
resolve #876
2025-02-15 05:33:25 +01:00
Romain Thomas cc288c7215 Add support for pretty printing PDB debug info 2025-02-15 04:15:03 +01:00
Romain Thomas 930310d4bd Resolve #1168 2025-02-08 05:45:51 +01:00
Romain Thomas 646af9f6ce Update version 2025-02-04 13:14:50 +01:00
Romain Thomas 8cae0420d9 Make sure ELF, PE, and Mach-O parser can consume bytes.
Related to #1167
2025-02-04 12:40:32 +01:00
Romain Thomas e2ef1ea659 Fix verbosity 2025-02-02 11:15:28 +01:00
Romain Thomas b086796f43 Resolve #1165 2025-02-01 20:45:31 +01:00
Romain Thomas dde9a3ca80 Resolve #1166 2025-02-01 13:08:05 +01:00
Romain Thomas 94275484bd Resolve #1164 and resolve #1163 2025-01-25 06:16:11 +01:00
Romain Thomas 7d369634cb Resolve #1155 2025-01-25 05:48:59 +01:00
bhoehl ac3b57deb1 add support for spc link / urls in spc indirect data 2025-01-25 05:16:29 +01:00
Richard Dzenis 9a4f609aa6 MachO::Binary::extend_section fill gap by default
The previous implementation extended section by strictly requested
amount, possibly creating a gap in case we needed to satisfy alignment
requirements.

However, information about the size of the gap is lost, and not trivial
to recover. This patch changes `extend_section` to extend section by
more than requested to avoid creating the gap.
2025-01-11 16:19:25 +01:00
Richard Dzenis 60de925b10 MachO::Binary::extend_section fix sorting order
If there are empty sections and non-empty section at the same offset, we
want to shift only empty sections.

The expected behavior is that we sort sections in ascending order, and
then `sections_to_shift` is trimmed, such that the last element becomes
`section`.

Previously, we were sorting in descending order, while keeping empty
sections in the same order. Due to this we were doing trimming
incorrectly.

Rework macho/test_builder.py::test_extend_section

The previous implementation of the test was expecting unsupported
behavior from LIEF.

LIEF currently does not support arbitrary calls to add_section and
extend_section and keeping the layout of the binary correct.
Currently it is responsibility of a user to ensure that the final layout
of the binary is well-formed.

This patch splits test into two cases:
1. Repeated calls to add_section followed by extend_section using
   different alignment values.
2. Multiple calls to add_section and then multiple calls to
   extend_section using the same alignment values.
2025-01-11 16:14:39 +01:00
Romain Thomas ca6068a002 fix(rust,cargo): fix exact version 2025-01-11 15:42:40 +01:00
Romain Thomas d29052e7ff fix(spdlog): Handle SPDLOG_WCHAR_FILENAMES. Fix #1147 2025-01-11 05:45:47 +01:00
Romain Thomas 60cb785431 fix(elf,parser): don't rely on the PT_DYNAMIC file offset
As demonstrated by @lebr0nli in the sample `ELF/issue_dynamic_table.elf`,
the PT_DYNAMIC segment can have an "invalid" offset while still running
correctly.
This commit changes the logic of the dynamic table processing by using
the PT_LOAD segment that wraps this table
2025-01-11 05:15:34 +01:00
Romain Thomas d3ad812008 Bump version 2025-01-01 18:20:28 +01:00
Romain Thomas 2c0bf31cc0 ++year 2025-01-01 09:49:21 +01:00
Romain Thomas 4eaff7bc80 Update version 2024-12-31 13:47:48 +01:00
Romain Thomas cb43b6ec59 Add mutex 2024-12-31 10:01:04 +01:00
Romain Thomas 63418db430 Restore atexit 2024-12-31 09:10:58 +01:00
Romain Thomas 6ceddad9cc Update changelog 2024-12-31 07:28:23 +01:00
Romain Thomas 9281f6a699 Fix missing tl-expected 2024-12-31 07:08:11 +01:00
Romain Thomas 327abf6ad5 Avoid static constructor related to logging 2024-12-31 07:08:07 +01:00
Romain Thomas 0abb0b30a5 Code cleanup 2024-12-28 09:30:10 +01:00
Romain Thomas a9542aa24a Update changelog 2024-12-27 14:06:26 +01:00
Romain Thomas 3bc18f4906 Add 0.16.1 changelog 2024-12-26 18:41:04 +01:00
Romain Thomas 1de204ada8 Update stubs 2024-12-25 07:04:13 +01:00
Romain Thomas 09c2a30eb9 Fix tests 2024-12-25 06:13:57 +01:00
Richard Dzenis 259bf7091f MachO::binary: add extend_section (#1137)
* MachO::Binary::add_section: respect alignment of empty sections

* MachO/layout_check: relax offset continuity requirement for __text section

Sections in MachO are prepended, but __text section is not moved.
Due to this there might be redundant gap between __text section and a
section that comes before __text.

Note: we don't want to alter distance between __DATA and __text, because
there might be position relative references in metadata.

* tests/macho: use lief.MachO.check_layout

* MachO::binary: add extend_section

This commit adds member function MachO::Binary::extend_section that is
able to extend sections from the first segment in MachO.

* macho/test_builder: add test_extend_section
2024-12-24 09:58:47 +01:00
Saikari 41166332a2 Fix missing headers (#1143) 2024-12-23 07:23:06 +01:00
1e425fc3c5 MachO::Binary::shift_command: fix exports of dyld (#1133)
* MachO::Binary::shift_command: fix shift of dyld exports

Despite the field name `address` it stores a file offset.

Co-authored-by: Richard Dzenis <rdzenis@whitecryption.com>

* MachO::Binary::shift_command: fix comparison in DyldExportsTrie update

`ExportInfo` is meant to be updated if `info.address()` is beyond the
point where shift happens; however, offset comparison was reversed.

Additionally, compare with `from_offset`, because despite the field name
`address` it stores a file offset.

Co-authored-by: Richard Dzenis <rdzenis@whitecryption.com>

* Add macho/test_exports_after_shift

This test checks that exports in dyld_info are shifted correctly.

* Add macho/test_chained_exports_after_shift

This test checks that exports in dyld_exports_trie
are shifted correctly.

---------

Co-authored-by: Peteris Ledins <peteris.ledins@zimperium.com>
Co-authored-by: Javier Lopez-Gomez <javier.lopez-gomez@zimperium.com>
2024-12-21 06:14:29 +01:00
Richard Dzenis 1c46aed72e MachO::Binary: treat all sections in the same way during shift (#1134)
Previously there were exceptions for zerofill sections because offset
checks were not correct. After fixing checks for offsets/va, special
handling of zerofill sections is no longer needed.
2024-12-21 06:13:42 +01:00
Romain Thomas a2f0f26ab9 Fix typo 2024-12-21 05:37:47 +01:00
Romain Thomas 5c5d524a92 Change autocxx-build version to 0.27.0
The minimal Rust version for the bindings is `1.74.0`.
Recently, the `home` [^1] package raised its minimal supported rust version
to `v1.81.0` which breaks our min-rust requirement.

Before this commit, `lief-ffigen` was depending on this package via the
following dependency tree:

```
lief-ffigen v0.17.0 (/src/api/rust/cargo/lief-ffigen)
├── autocxx-build v0.26.0
│   ├── autocxx-engine v0.26.0
│   │   ├── autocxx-bindgen v0.65.1
│   │   │   └── which v4.4.2
│   │   │       └── home v0.5.11
```

It turns out that `which` is no longer a dependency of `autocxx-bindgen`
since this commit: c03964c0257b03ad4762b57f3ffb96d32d49c0ce[^2].

This commit is part of the `0.27.0` release of `autocxx-engine`.

[^1]: https://crates.io/crates/home
[^2]: https://github.com/adetaylor/rust-bindgen/commit/c03964c0257b03ad4762b57f3ffb96d32d49c0ce
2024-12-21 05:34:23 +01:00
Romain Thomas 573ea6a2f3 Fix tests 2024-12-15 09:46:29 +01:00
Romain Thomas 2cd4d99fc6 Enhance Mach-O layout checks 2024-12-15 08:04:34 +01:00
Romain Thomas a5cf726667 Add more architectures 2024-12-14 19:48:04 +01:00
Romain Thomas dd02054bb5 Update README 2024-12-14 05:22:26 +01:00
Romain Thomas 535375ff7e Add enums for DYLD_CHAINED_PTR_ARM64E_SHARED_CACHE 2024-12-13 16:58:22 +01:00
Romain Thomas 9e8f30cd23 Add TVOS and WATCHOS to the VersionMin command 2024-12-13 16:51:36 +01:00
Richard Dzenis 3c25311b17 MachO::Binary: improve code related to shift method (#1136)
* MachO::Binary: improve code related to shift method

This commit outlines common pattern in the code into
`ensure_command_space` method that checks if there is enough space
between the command table and the first section.

Additionally this commit changes `add_section` alignment from a size of
a page to the section alignment requested by user.

* Add LIEF utility function align_down

* Rework MachO::Binary::add_section

- respect requested section.alignment

- allocate minimum amount of space for a section:
  do not reserve page size

* macho/test_builder: check that add_section acts continuously

* fixup! Add LIEF utility function align_down
2024-12-13 16:51:13 +01:00
Romain Thomas 29b79cbece Add more platforms 2024-12-13 10:36:33 +01:00
Romain Thomas 80fec167b0 Fix use-after-move 2024-12-13 09:55:28 +01:00
Romain Thomas 35ae8dc742 Don't fail on a .x versioning 2024-12-12 21:06:18 +01:00
Romain Thomas 531377b388 Add support for LC_ATOM_INFO 2024-12-12 20:34:50 +01:00
844df9d340 Fix MachO::Binary::shift_command (#1131)
* Fix MachO::Binary::shift_command virtual_address

Function argument `from_offset` is a file offset that we need to adjust
before adding to VA of segment.

Co-authored-by: Richard Dzenis <rdzenis@whitecryption.com>

* Fix symbols shift in MachO::Binary::shift_command

Fix adjustments of symbols: their values should be compared
to VA instead of file offset.

Co-authored-by: Richard Dzenis <rdzenis@whitecryption.com>

* Add test for shift of symbols in MachO

* Cleanup tests/macho/test_symbols.py

---------

Co-authored-by: Uldis Kalnins <ukalnins@whitecryption.com>
Co-authored-by: Romain Thomas <me@romainthomas.fr>
2024-12-12 11:27:31 +01:00
Romain Thomas 1cc49b2f3e Code cleaning 2024-12-12 06:24:57 +01:00
Richard Dzenis 339c92121c MachO::Binary::remove(Symbol): search symbol by ptr instead of name
The previous implementation was searching symbol by name, due to this it
could delete other symbol with the same name, instead of `sym` that was
passed to the function.
2024-12-11 18:16:37 +01:00
3439a448e6 Update segment offsets in MachO::Binary::extend_segment (#1132)
* Update segment offsets in MachO::Binary::extend_segment

Co-authored-by: Richard Dzenis <rdzenis@whitecryption.com>

* Add test to check MachO::Binary::offset_seg_ cache is updated

---------

Co-authored-by: Uldis Kalnins <ukalnins@whitecryption.com>
2024-12-11 18:06:40 +01:00
Romain Thomas 738f60b555 Update Rich headers variables 2024-12-11 18:00:56 +01:00
Uwe L. Korn d4fa8d18c3 Move destructor of ChainedBindingInfo out of the header 2024-12-11 17:59:50 +01:00
Romain Thomas 81b8b6fb01 Add support for std::u16string strings 2024-12-11 16:06:30 +01:00
Romain Thomas 2eab480a15 Update dyld shared cache support (resolve #1127) 2024-12-11 11:40:53 +01:00
Romain Thomas 7eebe97298 Fix missing visibility 2024-12-11 11:10:46 +01:00
Romain Thomas db5b5f93e9 Bump version 2024-12-11 05:49:25 +01:00
Romain Thomas 37176a49b2 Bootstrap changelog 2024-12-10 20:47:36 +01:00
Romain Thomas 1abc368975 Fix missing write() API 2024-12-10 20:22:23 +01:00
Romain Thomas 6ce389cae9 Resolve #1138 2024-12-10 18:32:20 +01:00
Romain Thomas 3fcdbdc74d Nightly only 2024-12-10 15:27:29 +01:00
Romain Thomas f8f4bb77a1 Make sure the documentation is aware of env variables 2024-12-10 15:21:03 +01:00
Romain Thomas e9862f4e85 Bump version 2024-12-10 12:33:38 +01:00
Romain Thomas 441bb4620b Bump version 2024-12-10 10:58:04 +01:00
Romain Thomas 793657de4a Update doc 2024-12-10 10:51:47 +01:00
Romain Thomas 0ff950c080 Update nanobind 2024-12-10 05:30:37 +01:00
Romain Thomas e54ef047c5 Update README 2024-12-09 20:57:40 +01:00
Romain Thomas 11c4d4de16 Add bindings to add a Mach-O library 2024-12-09 18:24:51 +01:00
Romain Thomas 9448caf756 Rust: Add add_library for ELF binaries 2024-12-09 17:18:29 +01:00
Romain Thomas a11b1b72a9 Expose write() operation in Rust 2024-12-09 16:58:29 +01:00
Romain Thomas f7171b620f Update README 2024-12-09 16:57:36 +01:00
Romain Thomas c84c8f04f9 Add --force-reinstall flag 2024-12-09 16:27:47 +01:00
Romain Thomas 52a5d5dcc9 Additional fixes for #1130 2024-12-09 16:18:59 +01:00
Romain Thomas f1b35862c8 Make sure segment's offset is not null when refreshing cache
Related to #1130
2024-12-09 14:46:50 +01:00
Romain Thomas bd6f6272a5 Resolve #1130 2024-12-09 11:59:14 +01:00
Romain Thomas b5df89fbd6 Update discord link 2024-12-09 10:46:36 +01:00
Romain Thomas 68caa323ea Reduce binary size while adding segments or relocating PHDR
Commit based on the work of @Miniman2718

Resolve: #1085
2024-12-09 05:46:17 +01:00
Romain Thomas 426b2406bb Fix wording 2024-12-08 21:00:12 +01:00
Romain Thomas 7ebe5fd8cf Update doc 2024-12-08 20:46:03 +01:00
Romain Thomas 68fa8898fb Add support for user-provided flags 2024-12-08 13:42:51 +01:00
Romain Thomas 28552b543b Disable AESNI for x86 target 2024-12-08 09:47:44 +01:00
Romain Thomas deffb40fab Cleanup GHA 2024-12-08 08:18:28 +01:00
Romain Thomas 5aa3d72c09 Add aarch64 testing 2024-12-08 05:16:35 +01:00
Romain Thomas 9c0c01a7bc Add LLVM version 2024-12-07 20:36:22 +01:00
Romain Thomas 40245aef53 Disable test 2024-12-07 19:34:51 +01:00
Romain Thomas e1bd74698e Expose llvm::MCInst as a (forwarded) reference 2024-12-07 18:51:22 +01:00
Romain Thomas c1a7332233 Add support for AArch64 operands 2024-12-07 18:27:27 +01:00
Romain Thomas 8dc62e85e7 Remove beta notice 2024-12-07 09:14:16 +01:00
Romain Thomas 8d244837cf Add LLVM PR 2024-12-07 07:58:08 +01:00
Romain Thomas 69d777e4c0 Add support for x86/x86-64 operands 2024-12-07 06:01:28 +01:00
Romain Thomas 917a118769 Fix documentation 2024-12-07 05:41:44 +01:00
Romain Thomas fbe2640c44 Disable code-check 2024-11-30 09:21:47 +01:00
Romain Thomas de58725db9 Initial assembler 2024-11-30 07:54:08 +01:00
Romain Thomas 7c1d66da6e Disable doc 2024-11-30 07:48:16 +01:00
Romain Thomas fd7f68258e Fix GHA test 2024-11-30 07:02:51 +01:00
Romain Thomas 1e7b4beb00 Minor updates 2024-11-30 05:40:00 +01:00
Romain Thomas de49dceba9 Update nanobind
Resolve: #1128
2024-11-30 05:30:21 +01:00
Romain Thomas b0366b3388 Add support to send metrics 2024-11-30 05:01:14 +01:00
Romain Thomas efd36faa80 Avoid (auto)generating opcodes 2024-11-23 10:12:07 +01:00
Kursat Aktas 56dab60d5a Introducing LIEF Guru on Gurubase.io
Signed-off-by: Kursat Aktas <kursat.ce@gmail.com>
2024-11-23 08:08:33 +01:00
Romain Thomas 6d88ded3da Fix type 2024-11-23 07:46:40 +01:00
Romain Thomas 102a6171a7 Some updates 2024-11-23 07:45:56 +01:00
Romain Thomas dacd4cd1f5 Fix symbol visibility 2024-11-23 07:32:03 +01:00
Romain Thomas 33a8e16976 Improve disassembler support 2024-11-23 07:31:41 +01:00
Romain Thomas d75f90d8dd Update doc 2024-11-23 06:58:33 +01:00
Romain Thomas a07a8b83d2 Update tests 2024-11-23 06:58:32 +01:00
Romain Thomas 4e8838a5a7 Improve the documentation 2024-11-23 06:56:34 +01:00
Romain Thomas 313343b681 Add extended version helper 2024-11-23 06:15:39 +01:00
Romain Thomas a2100f9aeb Update typing 2024-11-23 05:47:09 +01:00
Romain Thomas 8b8b84d180 Add support to disassemble DWARF Function 2024-11-23 05:46:27 +01:00
Romain Thomas fb86a0a103 Add default constructor 2024-11-23 05:33:26 +01:00
Romain Thomas c58b8dbf09 Update tests 2024-11-23 05:30:25 +01:00
Romain Thomas b4c96c41c1 Export LIEF_CORE_EXTENDED to know whether this is an extended build 2024-11-23 04:36:14 +01:00
Romain Thomas 590eb2626f Fix visibility 2024-11-17 19:51:10 +01:00
Romain Thomas 7b6f8484ee Fix typo 2024-11-17 12:20:19 +01:00
Romain Thomas e573911098 Fix memleak 2024-11-17 06:29:16 +01:00
Romain Thomas 4479894a07 Lint code 2024-11-17 04:58:12 +01:00
Romain Thomas b63dca262f Add nanobind custom type caster for LIEF::span 2024-11-16 18:35:35 +01:00
Romain Thomas 36106937d1 Fix with normalize_path 2024-11-16 12:22:09 +01:00
Romain Thomas ca6ddf5cdd Enhance DWARF types support 2024-11-16 10:16:16 +01:00
Romain Thomas ca485c3921 Return an empty stream when the size is 0 2024-11-16 09:12:30 +01:00
Romain Thomas c796782a1f Fix visibility 2024-11-10 20:30:29 +01:00
Romain Thomas 5fc182b1d5 Update changelog 2024-11-10 10:04:52 +01:00
Jevin Sweval e81ae09f77 Fix ELF/MachO to point empty symbol names to offet 0, required to be NUL
ELF/MachO symtab entries with NUL name should use zero offset into strtab
2024-11-10 10:02:26 +01:00
Romain Thomas ccd41bb820 Remove C enums 2024-11-09 16:15:08 +01:00
Philippe Ombredanne b06aa7ae7b Fix minor typo (#1122)
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
2024-11-09 09:22:47 +01:00
Romain Thomas 7a4291bcf1 Improve relocation support 2024-11-09 06:30:58 +01:00
Romain Thomas 94aa4db095 Explicitly specify index.html 2024-11-09 06:02:02 +01:00
Romain Thomas 3f233e5a95 Add support for eBPF relocations 2024-11-09 06:01:04 +01:00
Romain Thomas c6a6471cbf Clean object relocation processing 2024-11-09 05:39:58 +01:00
Romain Thomas 72e7f8178c Add get_section_idx helpers 2024-11-09 05:23:15 +01:00
Romain Thomas 3e951ba3f7 Update documentation 2024-11-09 05:06:01 +01:00
Romain Thomas 86c2d48512 Update tests 2024-11-09 05:05:38 +01:00
Romain Thomas a0ffe4592b Fix missing attribute 2024-11-09 05:01:20 +01:00
Romain Thomas 5cf93ae26d Add DWARF support for DW_TAG_typedef support 2024-11-09 04:59:44 +01:00
Romain Thomas f2c54ee5cf Add DWARF imported function iterator 2024-11-09 04:55:27 +01:00
Romain Thomas 89ad5b378a Add DWARF is_external API (matching DW_AT_external) 2024-11-09 04:48:28 +01:00
Romain Thomas 445083677d Add comment 2024-11-03 18:06:24 +01:00
Romain Thomas d3ae4debe7 Code cleaning 2024-11-02 18:04:28 +01:00
Romain Thomas f7a127eac3 Initial disassembler support 2024-11-02 16:42:41 +01:00
Romain Thomas 86e1769fb0 Enable creating a RPathCommand
Resolve #1078
2024-11-02 10:47:50 +01:00
Romain Thomas ee4e12a442 Make sure project() is at the top 2024-11-01 06:45:19 +01:00
Romain Thomas 699ae7ed96 Change Doxygen comment style 2024-11-01 06:45:19 +01:00
Romain Thomas 8c7b2911a3 Rust ELF enhancement 2024-11-01 06:45:19 +01:00
Romain Thomas 0f8bea0275 Enhance logging API 2024-11-01 06:45:19 +01:00
Romain Thomas 0459322666 Resolve #1121 2024-11-01 06:45:19 +01:00
Romain Thomas ccaca6028b Update documentation 2024-11-01 06:45:19 +01:00
Romain Thomas 94d0e05697 Fix ordinal check error
Credit: @kkent030315 m4b/goblin#428
2024-11-01 06:33:18 +01:00
Romain Thomas e81492631f Silent warning when accessing entrypoint for abstraction 2024-11-01 06:17:42 +01:00
Romain Thomas 0120636b12 Better PPC/PPC64 support for the LC_THREAD_COMMAND 2024-11-01 06:15:52 +01:00
Romain Thomas 19dd162314 Add RISC-V processor flags 2024-11-01 06:01:26 +01:00
Romain Thomas f00553ec14 Add C-SKY architecture 2024-11-01 05:58:37 +01:00
Romain Thomas 538b6a5ebf Add support for x86_64-unknown-linux-musl Rust target 2024-10-27 12:54:44 +01:00
Romain Thomas 27be4e6b2d Add support for GNU_PROPERTY_AARCH64_FEATURE_PAUTH 2024-10-26 15:46:14 +02:00
Romain Thomas 086c49fb7a Add is_targeting_android to determine if an ELF targets Android 2024-10-26 08:48:08 +02:00
Emmanuel FerdmanandRomain Thomas ec233a499f Update authenticode reader reference (#1120)
* Fix memory issues raised by GHSA-xpwf-7qj6-m6r4 & GHSA-c2f3-2xpq-pjj9

* Update authenticode reader reference

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>

---------

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: Romain Thomas <me@romainthomas.fr>
2024-10-26 06:15:53 +02:00
Romain Thomas 7908c18a72 Fix visibility 2024-10-26 06:11:57 +02:00
Romain Thomas 42207c97ed Lower C++ standard 2024-10-26 06:10:46 +02:00
Romain Thomas 11b5d7ce9e Rust: lower minimal Linux requirement 2024-10-26 06:01:45 +02:00
Romain Thomas 4cc1dd26be Refactor and clean code in LIEF's abstract layer
Resolve #1119
2024-10-26 05:36:49 +02:00
Romain Thomas 8784fb5aa5 Refactor LIEF's Abstract Function 2024-10-26 05:03:52 +02:00
Romain Thomas c56dfab748 Fix memory issues raised by GHSA-xpwf-7qj6-m6r4 & GHSA-c2f3-2xpq-pjj9 2024-10-20 15:36:18 +02:00
Romain Thomas 7559d2d0e8 Update changelog 2024-10-19 16:50:09 +02:00
Romain Thomas 864bf8180c Update links 2024-10-19 16:45:44 +02:00
Romain Thomas b8e7216f1f Move Android formats doc in an Android/ dedicated section 2024-10-19 06:30:28 +02:00
Romain Thomas 442fb46395 Initial support for Apple's dyld shared cache 2024-10-19 06:29:24 +02:00
Romain Thomas 91a4710fc5 Make sure nlohmann/json is only using C++11 standard 2024-10-19 05:11:29 +02:00
Romain Thomas 07b3241fe1 Improve objc support
- Add `LIEF::objc::DeclOpt` to tweak the generated output
- Add `objc::Class:to_decl` & `objc::Class::to_decl`
- Improve the documentation
- Fix issue with Small method address
2024-10-19 04:45:13 +02:00
Romain Thomas b6de8801b2 Improve documentation 2024-10-19 04:39:01 +02:00
Romain Thomas e45dfb71bb Fix infinite loop while processing PE resource tree
Resolve #1115
2024-10-12 20:47:51 +02:00
Romain Thomas e98d6e7d0a #1114 follow up 2024-10-12 06:31:57 +02:00
Romain Thomas 17b86f8b37 Make sure the Mach-O parsing depth matches C++
Resolve #1114
2024-10-08 05:10:39 +02:00
Romain Thomas 11f65a051e Cleanup 2024-10-07 21:15:34 +02:00
Romain Thomas 6cdc09388c Make sure the pos does not change
Resolve #1113
2024-10-07 21:12:25 +02:00
Romain Thomas 0dc889591e Fix missing quotes 2024-10-06 13:29:09 +02:00
Romain Thomas 1090999cc0 Update README 2024-10-06 13:27:44 +02:00
Romain Thomas ba294bd181 Make sure we have a correct visibility 2024-10-05 05:49:38 +02:00
Romain Thomas b11bc1ebd2 Add rustls-tls to the changelog 2024-10-05 05:33:20 +02:00
Romain Thomas 6dfe3870a7 Fix link 2024-10-05 05:31:49 +02:00
Romain Thomas a3f034d767 Fix clash with Windows's header #define 2024-10-05 05:29:00 +02:00
Romain Thomas 3def579f75 Add support for creating and analyzing chained fixups & bindings 2024-10-05 05:23:39 +02:00
Romain Thomas 78dec19bbd Add method to accept a std::unique_ptr 2024-10-05 04:49:42 +02:00
Romain Thomas 8d65798590 Define CPU_SUBTYPE_ARM64E into the Header object 2024-10-05 04:39:39 +02:00
Romain Thomas 4fb6145bd3 Fix missing operator= 2024-10-05 04:24:43 +02:00
Romain Thomas d0fb24a2a8 Fix typo 2024-10-05 04:19:32 +02:00
Romain Thomas 0127c29e09 Fix scope 2024-10-05 04:18:52 +02:00
Romain Thomas f8d30efa17 Remove unused header 2024-10-05 04:16:19 +02:00
Romain Thomas e4f23d14d3 Fix Mach-O endianness support (resolve #1110) 2024-09-29 11:12:11 +02:00
Romain Thomas cf14dae8a8 Update spdlog 2024-09-28 18:30:16 +02:00
Romain Thomas 0913977621 Fix error from 201a87e25c 2024-09-28 18:30:15 +02:00
Romain Thomas 0f4ed10aba Fix logging 2024-09-28 18:30:10 +02:00
Manuel Zabelt b8b2ae0b02 Adjusted authenticode_reader.py to use Attribute.TYPE instead of SIG_ATTRIBUTE_TYPES (#1111)
Inspired by this change: 8dd8a255a8
2024-09-28 06:19:15 +02:00
Romain Thomas 0fa2d49924 Update logging interface 2024-09-28 06:13:38 +02:00
Romain Thomas 68f51a7708 Improve virtual_size computation 2024-09-28 04:52:34 +02:00
Romain Thomas a526c52233 Fix missing ostream 2024-09-21 07:41:18 +02:00
Mike Nawrocki 165b9f6535 Python: mark add_relocation return value reference (#1108)
Makes the return value from the PE::Binary add_relocation method an
internal reference.
2024-09-21 07:18:12 +02:00
Romain Thomas 388fc5e46f Fix missing relationship between Mach-O's symbol & libraries 2024-09-21 07:15:49 +02:00
Romain Thomas 77c633cc22 Add missing bindings 2024-09-21 07:13:46 +02:00
Romain Thomas 7115533c1e Fix va_ranges issue 2024-09-21 06:32:44 +02:00
Romain Thomas 3cca7ba4b2 Add cast helpers 2024-09-21 06:32:40 +02:00
Romain Thomas 144e5fe76d Resolve #1107 2024-09-19 11:50:07 +02:00
Romain Thomas 201a87e25c Disable mbedtls platform entropy 2024-09-19 11:47:14 +02:00
HuntragonandRadu Bloch 2b5a5eb339 Add rustls-tls feature to reqwest (#1105)
Co-authored-by: Radu Bloch <radu.bloch@n3uron.com>
2024-09-19 11:23:50 +02:00
Mike Nawrocki 53ea6eae0b Python: mark add_entry return value as reference (#1106)
Makes the return value from the PE::Reference add_entry method an
internal reference.
2024-09-19 11:17:30 +02:00
Romain Thomas 5c1f3613cb More values for BuildVersion::PLATFORMS 2024-09-19 10:43:26 +02:00
Romain Thomas 544332db2c Add helpers to determine the platform targeted by a Mach-O 2024-09-19 10:35:42 +02:00
Romain Thomas 33276acad7 Fix bound checking 2024-09-19 10:21:40 +02:00
Romain Thomas 06df59cefe Fix PKCS#1 1.5 padding (resolve #1101) 2024-09-19 10:20:16 +02:00
Romain Thomas ca0b20aa74 Shrink final buffer 2024-09-19 09:48:50 +02:00
Romain Thomas c8cc69c77e Make sure we support buffer larger than 1000.
See: https://github.com/python/cpython/blob/453da532fee26dc4f83d4cab77eb9bdb17b941e6/Python/sysmodule.c#L4001
2024-09-19 09:44:49 +02:00
Romain Thomas d1906ad2d5 Upgrade MbedTLS from 3.2.1 to 3.6.1 2024-09-19 09:18:36 +02:00
Romain Thomas 02327492c8 Fix test 2024-09-14 08:22:43 +02:00
Romain Thomas 94adbf5f2a Fix types (from #1100) 2024-09-14 08:07:29 +02:00
Romain Thomas e5285687d0 Only print warning if the original is not 0 2024-09-14 08:05:37 +02:00
ShallowFeatherandRomain Thomas dbc9d9f9fa Fix type (#1100)
Fix the function type of security_cookie

Co-authored-by: Romain Thomas <7450402+romainthomas@users.noreply.github.com>
2024-09-14 07:30:36 +02:00
Romain Thomas bf931df303 Fix error when rewriting an ELF with DT_RELR relocations 2024-09-14 06:31:20 +02:00
Romain Thomas cd81ed3ba6 Add get_int_from_virtual_address in the abstract layer 2024-09-14 05:57:08 +02:00
Romain Thomas 1bcd416433 Update log message 2024-09-14 05:30:07 +02:00
Romain Thomas 27261eb427 Make sure the pointer is valid when accessing the array 2024-09-14 05:11:01 +02:00
Romain Thomas 3581c8e3bf Add helper to check the permission 2024-09-14 05:10:57 +02:00
Romain Thomas 155febcb77 Expose the chained's next value 2024-09-14 05:01:01 +02:00
Romain Thomas 24c3295a4c Use chain_address 2024-09-14 04:40:22 +02:00
Romain Thomas f3abf22971 Fix support for 'weird' layout 2024-09-14 04:36:54 +02:00
Romain Thomas fa41703c1a Add payload helper to access the raw content of the command 2024-09-14 04:23:18 +02:00
Romain Thomas fae9ae78d6 Add slice/to_vector helpers 2024-09-08 14:48:20 +02:00
Romain Thomas e8811ec19f Fix error 2024-09-08 14:41:30 +02:00
Romain Thomas f27947b8e0 Resolve #1097 2024-09-07 06:20:43 +02:00
Romain Thomas 8da28da98e Fix enum class error 2024-09-07 05:40:55 +02:00
Romain Thomas 6a40c07614 Add 'contains' helper 2024-09-07 05:36:52 +02:00
Romain Thomas 48cf0dbd41 Fix typo 2024-09-07 05:30:49 +02:00
Romain Thomas c59a66ade1 Add stream interface for sections/segments 2024-09-07 05:23:06 +02:00
Romain Thomas 3ee28a5079 Allow SpanStream to be copyable 2024-09-07 05:15:39 +02:00
Romain Thomas 92305cfa2c Use stride 2024-09-07 04:49:45 +02:00
Romain Thomas 77330160ea Fallback on the virtual address if the offset is corrupted 2024-09-07 04:31:54 +02:00
Romain Thomas 39b21e4319 Add NONE entry 2024-09-01 14:18:11 +02:00
Romain Thomas 8a32bcb963 Add operator== / operator!= 2024-08-31 19:15:28 +02:00
Romain Thomas c31361c188 Add test case for #1090 2024-08-31 18:10:08 +02:00
Romain Thomas 5584fdf129 Fix error 2024-08-31 10:19:04 +02:00
Romain Thomas 88cadfdb3b Fix new line 2024-08-31 10:01:07 +02:00
Romain Thomas d574f58004 Update position 2024-08-31 09:53:43 +02:00
Aiden-Isik 93e2e65a6f Add PowerPC Big Endian 0x1F2 (found on Xbox 360) (#1090) 2024-08-31 09:25:22 +02:00
Romain Thomas 2001d8c9b7 Resolve #1093 2024-08-31 09:19:27 +02:00
Romain Thomas 9b2bd35380 Add move constructor 2024-08-31 07:40:14 +02:00
Romain Thomas 0e04b4a44e Fix doc 2024-08-31 07:36:25 +02:00
Romain Thomas 993f24bdc1 Add Mach-O symbol stubs iterator 2024-08-31 07:35:26 +02:00
Romain Thomas 990dbcaa77 Fix typo 2024-08-31 07:07:01 +02:00
Romain Thomas 5915877834 Add require_extended_version error type 2024-08-31 07:06:47 +02:00
Romain Thomas 32b5234cf9 Perfect forwarding compliance 2024-08-31 07:04:03 +02:00
Romain Thomas 0ff2f093c0 Enhance demangling support (especially with LIEF extended) 2024-08-31 07:01:05 +02:00
Romain Thomas e31dfeb3cc Support for C++20 2024-08-31 06:00:08 +02:00
Romain Thomas 5e70549e0f Support parsing commands from a different binary stream 2024-08-31 05:51:58 +02:00
Romain Thomas 1921d282aa Remove new line 2024-08-31 05:14:42 +02:00
Romain Thomas 222a160cf5 Add the attribute from_dyld_shared_cache 2024-08-31 05:13:36 +02:00
Romain Thomas 81f8792e8c Remove unused variables 2024-08-31 05:11:22 +02:00
Romain Thomas d28e879ad3 Fix support for Mach-O indirect symbols indexed with 0xc0000000 (LOCAL and ABS) 2024-08-31 05:10:36 +02:00
Romain Thomas ce0ba58a54 Add function to read *objects* into vector 2024-08-31 04:59:34 +02:00
Romain Thomas eeebbaf819 Remove unwanted new lines 2024-08-31 04:47:36 +02:00
Romain Thomas 0ad4b8c5c0 Use the space given by the PE's FileAlignment
Resolve #1088
2024-08-25 14:02:53 +02:00
Romain Thomas ecbedb4d09 Resolve: #1089 2024-08-24 15:57:32 +02:00
Romain Thomas 47d707f3a5 Fix missing include 2024-08-24 09:43:02 +02:00
Romain Thomas d7e7fcce18 Fix typo 2024-08-24 08:17:29 +02:00
Romain Thomas b39d4e330e Fix missing <string> header 2024-08-24 08:11:26 +02:00
Romain Thomas ea4a6b299f Add support for binding operation infered from indirect symbol table 2024-08-24 07:30:25 +02:00
Romain Thomas 62929828ce Expose a bindings iterator 2024-08-24 07:01:27 +02:00
Romain Thomas 5c21a22cde Fix missing header guard 2024-08-24 06:04:21 +02:00
Romain Thomas bc31ee5dce Expose an iterator over the indirect symbols located in DynamicSymbolCommand 2024-08-24 06:02:46 +02:00
Romain Thomas 7bd0c8aa6f Resolve #1087 2024-08-24 05:45:06 +02:00
Romain Thomas cd7a7e1240 Fix function 2024-08-24 05:33:58 +02:00
Romain Thomas 01867d52ed Update parsing trie function to support a BinaryStream as input 2024-08-24 05:23:11 +02:00
Romain Thomas 2de226dcd9 Expose function to add a symbol 2024-08-24 04:56:56 +02:00
Romain Thomas 919c52597f Improve output 2024-08-24 04:46:37 +02:00
Romain Thomas f979004437 Resolve #1086 2024-08-24 04:44:44 +02:00
Romain Thomas 932f58cbf4 Add virtual address info so that content can be read from VA (or offset) 2024-08-24 04:30:29 +02:00
Romain Thomas ce3ff3f573 Update layout & comments 2024-08-18 12:54:24 +02:00
Romain Thomas b267a99cb8 Update LIEF Python package README 2024-08-18 12:34:38 +02:00
Romain Thomas de60b62424 Update changelog 2024-08-17 18:00:23 +02:00
Romain Thomas beb49468ff Fix OSX version 2024-08-17 14:03:32 +02:00
Romain Thomas 7c3b4a3f9f Add demangle utility (resolve: #1054) 2024-08-17 05:30:57 +02:00
Romain Thomas f864b71d02 Cleanup utils.hpp header 2024-08-17 05:03:25 +02:00
Romain Thomas ab85865f27 Improve support for RISC-V architecture
Resolve: #1082
2024-08-17 04:57:30 +02:00
Peter Meerwald-Stadler 42df4964f0 Fix some more typos (#1084) 2024-08-02 21:28:08 +02:00
Peter Meerwald-Stadler b29613f4e9 Fix some typos in the PE Authenticode tutorial (#1083) 2024-08-02 21:27:00 +02:00
Romain Thomas 24d48ad0b5 Fix Mach-O issue 2024-07-27 21:01:04 +02:00
f4bf30dfbc Support new Dynamic tags for X86_64 (#1081)
* Add new X86_64 specific Dynamic Tag

See https://sourceware.org/git/?p=glibc.git;a=commit;h=848746e88ec2aa22e8dea25f2110e2b2c59c712e

* Add missing Dynamic Tag in C api

---------

Co-authored-by: Romain Thomas <me@romainthomas.fr>
Co-authored-by: Romain Thomas <7450402+romainthomas@users.noreply.github.com>
2024-07-27 11:00:43 +02:00
f954c50e74 Fix header when compile with LIEF_EXTERNAL_SPDLOG=ON (#1080)
* Fix header when compile with LIEF_EXTERNAL_SPDLOG

The header <algorithm> can be missing and std::remove_if may not be found
in DynamicEntryArray.cpp and DynamicEntryRunPath.cpp.
This is the case when compiled with LIEF_EXTERNAL_SPDLOG=ON
and fetch spdlog using FetchContent with the option OVERRIDE_FIND_PACKAGE.

---------

Co-authored-by: Romain Thomas <me@romainthomas.fr>
Co-authored-by: Romain Thomas <7450402+romainthomas@users.noreply.github.com>
2024-07-27 10:59:10 +02:00
Romain Thomas 9673580c5a Fix formatting 2024-07-27 10:54:37 +02:00
Romain Thomas dfb67f2a2d Cleanup Mach-O build engine 2024-07-27 07:49:34 +02:00
Romain Thomas ff72aa9242 Fix warnings 2024-07-27 05:31:44 +02:00
Romain Thomas 8a2ec4eeae Fix typo 2024-07-27 05:28:30 +02:00
Romain Thomas 2f7620f527 Add support for LC_ROUTINE/LC_ROUTINE64 2024-07-27 05:27:10 +02:00
Romain Thomas 4800a80769 Add support for Mach-O LC_SUBCLIENT command 2024-07-27 05:01:30 +02:00
Romain Thomas 999daa3ce7 More inline helpers 2024-07-27 04:31:10 +02:00
Romain Thomas ff8bc78393 Update changelog 2024-07-23 18:03:50 +02:00
Romain Thomas cb7132c776 Bump macos runner version 2024-07-23 18:00:26 +02:00
Romain Thomas 3d1663f31c Bump version 2024-07-23 17:45:54 +02:00
Romain Thomas fa10efc138 Fix expired certificates 2024-07-23 17:30:23 +02:00
Romain Thomas ab1387add8 Add utilities 2024-07-23 16:58:13 +02:00
Romain Thomas d4e767b3d9 Add OFF level and the API to get the current level 2024-07-23 16:58:12 +02:00
Romain Thomas fd1cc42b6d Add support for Mach-O .hwx files 2024-07-23 16:58:08 +02:00
Romain Thomas 3eac86c9e6 Add documentation link 2024-07-21 21:18:44 +02:00
Romain Thomas 8e2964f722 Add stable doc info 2024-07-21 21:12:31 +02:00
Romain Thomas 38b7f9279b Add warning about Rust documentation 2024-07-21 21:06:29 +02:00
Romain Thomas ad4e824b97 Bump version 2024-07-21 19:10:00 +02:00
Romain Thomas 339a08fa60 Fix typo 2024-07-21 10:11:59 +02:00
Romain Thomas 9f7230eeb0 Update doc 2024-07-21 09:30:22 +02:00
Romain Thomas a3660898af Update changelog 2024-07-21 09:17:22 +02:00
Romain Thomas a9210e5af3 Cleanup 2024-07-20 07:31:26 +02:00
Romain Thomas 16508f9426 Fix version 2024-07-20 07:21:32 +02:00
Romain Thomas fec7d0190f Various updates 2024-07-20 07:20:05 +02:00
Romain Thomas 4c67c5b5de Enable versioning from 'LIEF_VERSION_ENV' 2024-07-20 07:10:00 +02:00
Romain Thomas 27d406be96 Resolve #1026 2024-07-20 07:01:19 +02:00
Romain Thomas 3d44a66cf9 Support more PKCS7 attributes for PE Authenticode 2024-07-20 06:04:31 +02:00
Romain Thomas 469c799e56 Update documentation 2024-07-20 05:10:01 +02:00
Romain Thomas bd138c5f3c Fix missing doc 2024-07-20 05:04:41 +02:00
Romain Thomas 3af17efa70 Fix typo 2024-07-15 06:52:16 +02:00
Romain Thomas c10e90df15 Fix missing operator 2024-07-13 12:43:40 +02:00
Romain Thomas b0e4bdb99d Fix windows build 2024-07-13 08:06:59 +02:00
Romain Thomas 306f34e992 Fix missing <string> 2024-07-13 07:53:52 +02:00
Romain Thomas b2b7fb96ec Add support for extensions. 2024-07-13 07:51:52 +02:00
Romain Thomas f31c8ff58d Remove personal account 2024-07-13 06:47:39 +02:00
Romain Thomas da6ca93e7d Avoid polluting compilation units with static initializer 2024-07-13 06:45:30 +02:00
Romain Thomas 9c7b9aa81c Add helper to provide a relocated view of **array** dynamic entries.
Close #1058, related to #626
2024-07-13 06:36:39 +02:00
Romain Thomas b441c2862d Cleanup 2024-07-13 06:10:34 +02:00
Romain Thomas 402e7a9b02 Add support for re-building Mach-O LC_RPATH commands
Resolve issue #1074
2024-07-13 06:01:54 +02:00
Romain Thomas f7acc24723 Add helper to check if the binary is supporting ARM64 ptr auth 2024-07-13 05:28:36 +02:00
Romain Thomas c23cccb7f9 Add Python 3.13 2024-07-06 07:14:52 +02:00
Romain Thomas 33703bc4d1 Cleanup: simplify interfaces 2024-06-29 06:35:21 +02:00
Romain Thomas e6ec359a3d Fix missing include (close #1071) 2024-06-29 06:11:06 +02:00
Romain Thomas 59332990ac More inlining & use move operator 2024-06-29 06:10:37 +02:00
Romain Thomas 4d5d2a4f0d Avoid parsing too many notes with errors 2024-06-29 06:04:05 +02:00
Romain Thomas f763b51274 Fix binary's original_size 2024-06-29 05:15:32 +02:00
Romain Thomas 525a870011 Add helper to *dyn_cast* a load config 2024-06-29 04:56:17 +02:00
Romain Thomas d2d9839af8 Cleanup enums 2024-06-29 04:50:09 +02:00
Romain Thomas fa57fa69e5 Fix headers 2024-06-29 04:22:55 +02:00
Romain Thomas 2b68ae5383 Cleanup 2024-06-22 10:09:29 +02:00
Romain Thomas 93245d3c7f Fix WARN/WARNING 2024-06-22 07:09:17 +02:00
Romain Thomas 62499ca1ab Add support for QNX Notes (QNT_STACK)
Resolve: #1065
2024-06-22 07:08:28 +02:00
Romain Thomas 2646cf042b Fix typo 2024-06-22 06:12:45 +02:00
Romain Thomas 5f0cec2167 Add trait on the enum when all elements implement this trait 2024-06-22 06:10:13 +02:00
Romain Thomas 2a31841aec Update logging interface 2024-06-22 05:49:59 +02:00
Romain Thomas 35b201bdf0 Cleaup examples 2024-06-22 05:26:42 +02:00
Romain Thomas 393fc9cabb Cleanup CMake 2024-06-22 05:19:20 +02:00
Romain Thomas 9906e2a024 Add sphinx_tabs.tabs 2024-06-16 13:24:56 +02:00
Romain Thomas 221bf8792e Cleanup 2024-06-15 06:32:10 +02:00
Romain Thomas 3f82c9ef82 Resolve #1070 2024-06-15 06:04:13 +02:00
Romain Thomas bca2738a33 Enhance Rust API 2024-06-15 05:40:32 +02:00
Romain Thomas e300b98120 Update changelog 2024-06-09 15:29:59 +02:00
Romain Thomas 69b6d53723 Bump requests version (close #1059) 2024-06-09 15:23:24 +02:00
Romain Thomas 7c3f631948 Fix performance issue (resolve #1069) 2024-06-09 15:16:58 +02:00
Romain Thomas fe10cd9fd7 Relax the condition about export name (resolve #1061) 2024-06-08 17:28:15 +02:00
Romain Thomas 4d2e96a0bf Fix platform 2024-06-08 07:37:26 +02:00
Emmanuel Ferdman a78251c92c Update linux-sdk-x64 reference (#1066)
* Update run_linux_sdk reference

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>

---------

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2024-06-08 07:21:51 +02:00
Romain Thomas 588ad8e2a6 Fix AArch64 wheel tag 2024-06-08 07:00:37 +02:00
Romain Thomas 839ef18dc0 Fix typo 2024-06-01 05:50:30 +02:00
Romain Thomas 0fd4757351 Fix enum values 2024-06-01 05:49:51 +02:00
Romain Thomas 318aab9690 Fix warnings 2024-06-01 05:33:01 +02:00
Romain Thomas c80b627484 Add range structure 2024-05-25 07:12:43 +02:00
Romain Thomas a0b33d7e7d Cleanup 2024-05-25 06:59:01 +02:00
Romain Thomas 8316dacf0b Add Mach-O UnknownCommand.
This command is a placeholder when LIEF does not a Mach-O load command
2024-05-25 06:45:08 +02:00
Romain Thomas f21b38f0c6 Fix missing UNKNOWN command 2024-05-25 06:33:34 +02:00
Romain Thomas 3f18682c61 Fix 2024-05-25 06:32:16 +02:00
Romain Thomas 3e11bf782b Update doc & cleanup 2024-05-25 06:31:37 +02:00
Romain Thomas b51dc15964 Code cleaning & doc update 2024-05-25 06:11:56 +02:00
Romain Thomas 9d3e02b6db Update doc & cleanup 2024-05-25 05:31:38 +02:00
Romain Thomas 2c54bd6930 Cleanup 2024-05-25 05:19:46 +02:00
Romain Thomas 221ba21f15 MSVC fix 2024-05-19 20:41:00 +02:00
Romain Thomas 122b86199f Cleanup headers 2024-05-19 19:38:20 +02:00
Romain Thomas 7911cddb64 Forward platform to arch 2024-05-18 11:29:05 +02:00
Romain Thomas ac880b2e82 Fix warnings 2024-05-18 11:20:32 +02:00
Romain Thomas a8b5f85917 Update profiling options 2024-05-18 11:02:02 +02:00
Romain Thomas 572d79537e Cleanup 2024-05-18 10:59:34 +02:00
Romain Thomas 93614a089b Move the PE's checksum computing in an dedicated function 2024-05-18 10:33:08 +02:00
Romain Thomas 93bb5926ec Add profiling utils 2024-05-18 08:59:25 +02:00
Romain Thomas bf557275a9 Cleaning 2024-05-18 06:33:59 +02:00
Romain Thomas 022f1636d7 Export functions when building a shared library 2024-05-18 06:30:36 +02:00
Romain Thomas f614400193 Add --skip-compilation option 2024-05-18 05:51:18 +02:00
Romain Thomas 0fb0368ed3 Compile without rtti & exceptions 2024-05-18 05:34:33 +02:00
Romain Thomas c0e988e571 Cleanup 2024-05-12 20:12:35 +02:00
Romain Thomas b88f20e04f Cleanup 2024-05-12 20:12:35 +02:00
Romain Thomas 0b75c6fe7c Remove unused include 2024-05-11 10:41:53 +02:00
Romain Thomas 0b73a52700 Add new targets for Rust bindings
- `aarch64-unknown-linux-gnu`
- `aarch64-apple-ios`
2024-05-10 17:54:15 +02:00
Romain Thomas 235be8ea65 Update tcb-span 2024-05-10 05:06:46 +02:00
Romain Thomas 4c4a82a6f4 Fix missing main 2024-05-09 21:53:37 +02:00
Romain Thomas 1dfa26fa12 More cl.exe fixes 2024-05-09 21:50:33 +02:00
Romain Thomas 3c76f67038 Windows fix 2024-05-09 21:39:31 +02:00
Romain Thomas fc8aa9aadd Disable warning 2024-05-09 21:25:50 +02:00
Romain Thomas c533aeffe3 Remove inline default ctor 2024-05-09 21:25:00 +02:00
Romain Thomas 51cad8a2a4 Disable C++ exceptions by default 2024-05-09 21:18:07 +02:00
Romain Thomas d4faafa481 Code lint 2024-05-09 21:18:03 +02:00
Romain Thomas e46074212d Re-scope Mach-O enums 2024-05-09 06:02:00 +02:00
Romain Thomas 9aec6c0570 Add forward declaration 2024-05-08 06:16:55 +02:00
Romain Thomas b014790b10 noexcept 2024-05-07 18:40:18 +02:00
Romain Thomas 807b257acd Resolve #1055 2024-05-06 16:57:27 +02:00
Romain Thomas 132ac2d971 Add musl config 2024-05-06 16:33:38 +02:00
Leland Jansen ef824c71bc Rename DEBUG enum variants 2024-05-06 16:18:48 +02:00
Romain Thomas b2b56a7107 Replace std::endl with \n 2024-05-05 23:31:23 +02:00
Romain Thomas 2a26324093 Fix const-ness 2024-05-04 09:02:51 +02:00
Romain Thomas be3fc43c72 Add support for extrapoling variables in config 2024-05-04 09:01:17 +02:00
Romain Thomas 465475f5f4 Bump scikit-build-core to v0.9.3
Note:

We are affected by the 0.9.0 update on `wheel.exclude`:

> The meaning of wheel.exclude has been changed to match on the wheel path, rather than the source path

So we had to revert to `sdist.exclude`

[1]: https://github.com/scikit-build/scikit-build-core/releases/tag/v0.9.0
2024-05-04 09:00:10 +02:00
Romain Thomas 6314d2b8f7 Disable exceptions from nlohmann/json 2024-05-04 08:48:50 +02:00
Romain Thomas 7faf45f80c Add support for Mach-O overlay
Resolve: #1028
2024-05-04 08:46:56 +02:00
Romain Thomas 97d96daa09 Inline overlay 2024-05-04 08:12:45 +02:00
Romain Thomas 5330d36aea Infer the page size from the binary instead of the host 2024-05-04 07:03:46 +02:00
Romain Thomas 6d18b3b062 Add support for other CI 2024-05-04 06:34:20 +02:00
Romain Thomas 393500d2cc Update utfcpp-3.2.1 to utfcpp-4.0.5 2024-05-04 05:19:34 +02:00
Romain Thomas cc11e22206 Update Catch2 from 3.5.2 to 3.5.4 2024-05-04 05:09:54 +02:00
Romain Thomas 73d91dd66d Update spdlog from 1.12.0 to 1.14.0 2024-05-04 05:03:32 +02:00
Romain Thomas f7698825a7 Cleanup 2024-04-28 17:30:25 +02:00
Romain Thomas 96240ed47b Add testcase for #1049
Close #1049
2024-04-28 17:16:04 +02:00
Romain Thomas d078438b87 cleanup 2024-04-28 17:10:07 +02:00
Romain Thomas 9c5c513dd5 Fix heap-buffer-overflow as described in issue #1049 2024-04-28 16:52:24 +02:00
Romain Thomas acd253fcd7 Make sure ContentInfo::value_ is not null.
This addresses the segfault case in the issue #1049
2024-04-28 16:12:21 +02:00
Romain Thomas 41a9730d33 Update changelog 2024-04-27 15:57:26 +02:00
Romain Thomas a09b9ac78e Update README 2024-04-27 15:44:57 +02:00
Romain Thomas d447511a64 Add rust bindings 2024-04-27 10:25:58 +02:00
Romain Thomas 6d1a230da2 Rename master branch into main 2024-04-27 06:19:02 +02:00
Romain Thomas 54d0a72c8e Merge pull request #1047 from FFRI/fix-out-of-range
fix ASN1Reader::tag2str
2024-04-27 06:02:08 +02:00
Romain Thomas 4d8211a2bd Remove ARM_UNWIND (in conflict with ARM_EXIDX) 2024-04-27 05:27:03 +02:00
yuki-mogi-ffri 10fa404f5e fix ASN1Reader::tag2str
Now ASN1Reader::tag2str function returns MBEDTLS_ASN1_UNKNOWN instead of throwing an out-of-range exception if the size of  is less than 3.
2024-04-23 15:08:08 +09:00
Romain Thomas 573c885de5 Fix non printable char 2024-04-06 07:30:28 +02:00
Romain Thomas 307e113f8e Resolve #1038 2024-03-30 07:14:40 +01:00
Romain Thomas 8d46eafe14 Remove ref 2024-03-17 05:52:14 +01:00
Romain Thomas 6dbb551af3 Resolve #1034 2024-03-17 05:50:45 +01:00
Romain Thomas ec17282da3 Update documentation 2024-03-17 05:45:45 +01:00
Romain Thomas a996621de2 Use /MD for the DLL 2024-03-17 03:38:00 +01:00
Romain Thomas 1c9c8522b6 Remove reference 2024-03-10 16:25:42 +01:00
Romain Thomas d30b870715 Fix missing entry 2024-03-02 11:14:05 +01:00
Romain Thomas 2b7b21aec0 Merge pull request #1029 from wonderkun/master
fix the bug in symbol.section_number to section
2024-03-02 11:12:23 +01:00
逸程 e0086cef46 fix the bug in symbol.section_number to section 2024-02-28 12:54:22 +08:00
Romain Thomas 5f0ff7094d Add doc 2024-02-25 16:41:47 +01:00
Romain Thomas 9d627769f0 Refactor LIEFApi.cmake 2024-02-25 10:49:42 +01:00
Romain Thomas 690d9f9987 Fix Python 2024-02-24 17:34:22 +01:00
Romain Thomas d62d481a7f Fix const-ness 2024-02-24 17:14:18 +01:00
Romain Thomas 630929ee2d Add const version 2024-02-24 17:11:02 +01:00
Romain Thomas 27f32e9060 Add icons 2024-02-24 16:56:22 +01:00
Romain Thomas a3a7a933ff Simplify the config 2024-02-24 16:56:18 +01:00
Romain Thomas 3f056100a4 Merge pull request #1025 from jevinskie/jev/dylibify
Add usable constructor for MachO::BuildVersion
2024-02-24 11:55:07 +01:00
Jevin Sweval a076f51d51 Add usable constructor to MachO::BuildVersion 2024-02-23 10:40:20 -05:00
Romain Thomas 5aba7e8bf5 Update catch2 2024-02-18 18:45:33 +01:00
Romain Thomas 88c28b16f4 Fix gcc(?) issue 2024-02-18 10:55:00 +01:00
Romain Thomas fe432fe881 Update Python backend dependencies 2024-02-18 06:20:38 +01:00
Romain Thomas 78fad9758e Add helper to disable nanobind warnings 2024-02-17 06:44:10 +01:00
Romain Thomas 129e542ab3 Resolve #1023 2024-02-17 06:30:02 +01:00
Romain Thomas b9b0adf65a Add CodeViewPDB GUID
Resolve #480
2024-02-17 06:01:02 +01:00
Romain Thomas 082fc725fe Init from a dedicated function 2024-02-17 05:29:15 +01:00
Romain Thomas b0f421bd5e Allow a static install of the Python bindings (internal usage) 2024-02-17 05:23:58 +01:00
Romain Thomas 638aa18708 Bump nanobind to 1.8.0.r43.g45c2a74 2024-02-17 05:03:04 +01:00
Romain Thomas 5087d6f1e4 Remove _lief in the type 2024-02-17 04:51:32 +01:00
Romain Thomas a4af271cc0 Add 0.14.1 2024-02-11 21:14:39 +01:00
Romain Thomas 1c112ee57c Resolve #1017 2024-02-11 17:01:51 +01:00
Romain Thomas dee8ad2d88 Fix performance issue: unwanted copy
Resolve #1022
2024-02-11 17:01:50 +01:00
Romain Thomas 480b92574c Merge pull request #1020 from ncatlin/master
fix pe relocations presence getter
2024-02-04 05:51:37 +01:00
Romain Thomas 9502c2b7ec Update copyrights 2024-02-04 05:50:39 +01:00
Romain Thomas 00e4a684a3 Add support for DT_RELR/DT_ANDROID_RELA relocations
This commit adds the support for the (new) relative relocations
as well as the Android packed relocation format.

Resolve: #111 #991
2024-02-03 15:52:54 +01:00
Romain Thomas 0fe1a8452b Fix name 2024-02-03 12:55:16 +01:00
Romain Thomas 6217d70643 Resolve #1019 2024-02-03 12:54:32 +01:00
Romain Thomas 737f2a9394 Fix MSVC issue 2024-02-03 12:54:28 +01:00
Romain Thomas 9d28a065df Disable rtti 2024-02-03 07:30:27 +01:00
Romain Thomas 979d0ec661 Resolve #1018 2024-02-03 07:02:36 +01:00
Romain Thomas cddd8dd076 Rename the static_symbol API into symtab_symbol 2024-02-03 06:31:30 +01:00
Romain Thomas acadc088ed Fix missing AArch64 2024-02-03 05:13:23 +01:00
Romain Thomas 7f02b5084d Handle empty container 2024-02-03 04:56:25 +01:00
Nia Catlin d1e095e194 fix pe relocations presence getter 2024-02-02 19:14:40 +00:00
Romain Thomas 7a62df9b58 Re-scope ELF enums 2024-01-28 22:54:25 +01:00
Romain Thomas 6b49ec5807 (yet) another @v4 fix 2024-01-27 21:45:42 +01:00
Romain Thomas a228ad308d v4 fix 2024-01-27 21:15:44 +01:00
Romain Thomas fb983d1764 Bump artifacts version 2024-01-27 15:15:41 +01:00
Romain Thomas 16c987247e Bump versions 2024-01-27 14:00:15 +01:00
Romain Thomas 3ec4d301aa Fix path 2024-01-27 11:27:06 +01:00
Romain Thomas f5ed2dff32 Fix EXCLUDE_FROM_ALL 2024-01-27 09:52:00 +01:00
Romain Thomas 21efe57265 LIEFConfig.cmake is now installed in lib/cmake/ 2024-01-27 08:28:35 +01:00
Romain Thomas 7cd186ddfa Fix #1016 -- Create aliases: ContentInfo::{digest,digest_algorithm} to SpcIndirectData::{digest,digest_algorithm} 2024-01-27 06:11:39 +01:00
Romain Thomas 0808283f8b Resolve #1014 2024-01-27 05:34:26 +01:00
Romain Thomas bb2bd6c679 CMake tweak 2024-01-21 16:04:19 +01:00
Romain Thomas 90a25eda22 Welcome 0.15.0 2024-01-21 15:43:33 +01:00
Romain Thomas 7c6a474387 Support release/ branches 2024-01-21 15:38:47 +01:00
Romain Thomas 0384b53478 Fix date 2024-01-20 18:19:29 +01:00
Romain Thomas 16962f2f36 Fix script 2024-01-20 06:20:34 +01:00
Romain Thomas 58f499a222 Update typing 2024-01-14 10:22:45 +01:00
Romain Thomas d87dfb24ac Fix test 2024-01-14 10:21:13 +01:00
Romain Thomas cea9fc5ca9 Fix enum conflict 2024-01-13 20:34:05 +01:00
Romain Thomas 6f74de8095 Fix tests 2024-01-13 11:56:06 +01:00
Romain Thomas ada25284df Refactor PE's relocation API 2024-01-13 11:53:58 +01:00
Romain Thomas 03e923030c Merge pull request #1011 from ch4mchi/fix/rsainfo_bignum_wrapper_t_size
Fix the size of bignum_wrapper_t returned from LIEF::PE::RsaInfo methods
2024-01-13 11:21:55 +01:00
ch4mchi ca50c91301 Fix the size of bignum_wrapper_t returned from LIEF::PE::RsaInfo methods 2024-01-11 17:54:17 +09:00
Romain Thomas bcd9b27df3 Address feedback from #1009
Add `has_nx_stack` and `has_nx_heap`
2024-01-07 10:23:37 +01:00
Romain Thomas c01dc6af49 Update PE's ResourcesManager 2024-01-07 10:11:57 +01:00
Romain Thomas 66fcfcc4e7 Add tests 2023-12-25 12:49:45 +01:00
Romain Thomas e13f2d5157 Merge pull request #1007 from yype/master
Another Fix to the `write` Templates
2023-12-24 17:09:32 +01:00
yype 2b13595323 another fix to the write templates 2023-12-24 01:57:05 +00:00
Romain Thomas 78d2f4b9d3 Cleanup PE LoadConfiguration interfaces 2023-12-23 05:06:26 +01:00
Romain Thomas a900afb238 Enhance #952 based on the feedback from @yype 2023-12-17 16:18:51 +01:00
Romain Thomas e6d3f28e7b Resolve #1003 2023-12-17 15:22:34 +01:00
Romain Thomas 3f2046e221 Merge pull request #1002 from ergrelet/fix_elf_has_nx
Fix LIEF::ELF::Binary::has_nx
2023-12-09 10:19:46 +01:00
Romain Thomas 8dd8a255a8 Narrow the scope of SIG_ATTRIBUTE_TYPES to LIEF::PE::Attribute::TYPE 2023-12-09 05:02:47 +01:00
ergrelet 0c7c79bea2 Fix LIEF::ELF::Binary::has_nx
The result boolean expression has been inverted in a previous commit
2023-12-07 23:29:50 +01:00
Romain Thomas 3aa5497b5e Cleanup 2023-12-03 10:02:46 +01:00
Romain Thomas fac0e7840e Add support for ELF NT_GNU_PROPERTY_TYPE_0 (read-only)
See: `tests/elf/test_notes.py` for API usage

Resolve: #975
2023-12-02 08:03:12 +01:00
Romain Thomas e6503fe74e Add compiler macro attributes 2023-12-02 05:30:47 +01:00
Romain Thomas 47a78077b4 Add helpers for cross-compilation 2023-11-26 15:48:58 +01:00
Romain Thomas 6ddc7e4145 Resolve #956 2023-11-25 11:46:31 +01:00
Romain Thomas e082255c32 Resolve #998 2023-11-20 06:12:25 +01:00
Romain Thomas df97777811 Fix typo and update the changelog 2023-11-18 12:33:36 +01:00
Romain Thomas 529d5a8679 Implement classof for Binary object 2023-11-18 09:00:39 +01:00
Romain Thomas ded37c5b92 Expose non-const iterators 2023-11-18 09:00:38 +01:00
Romain Thomas 002f356ed0 More span 2023-11-11 09:53:44 +01:00
Romain Thomas 879c4c5b3b More span 2023-11-10 18:38:29 +01:00
Romain Thomas 3ec79f96b0 Fix inline 2023-11-10 16:22:52 +01:00
Romain Thomas b113795dbb Impl classof() 2023-11-10 16:07:25 +01:00
Romain Thomas 5280c511ec Split files 2023-11-10 16:07:06 +01:00
Romain Thomas ad50afbdbf More span 2023-11-10 10:59:28 +01:00
Romain Thomas 1a1d2ec9e7 Update typing 2023-11-10 07:43:09 +01:00
Romain Thomas 262ad9735a Cleanup std::vector with span when it's suitable 2023-11-10 07:41:31 +01:00
Romain Thomas e25dcc3f90 Add timeout 2023-11-10 06:00:14 +01:00
Romain Thomas 1e0bc5d522 Simplify CMake 2023-11-10 05:33:41 +01:00
Romain Thomas 87cc6f8d4b Remove script no longer needed 2023-11-09 21:15:07 +01:00
Romain Thomas 9044fb6fc2 Fix typo 2023-11-09 21:13:44 +01:00
Romain Thomas 8eaf0669e1 Split fuzzing 2023-11-09 21:10:42 +01:00
Romain Thomas 77b94c0a4e Fix warnings 2023-11-09 20:52:44 +01:00
Romain Thomas fcf5daea07 Update fuzzing 2023-11-09 20:26:28 +01:00
Romain Thomas a9759992cc Add colored output 2023-11-09 20:09:15 +01:00
Romain Thomas af3040dcd6 Force color 2023-11-09 19:39:23 +01:00
Romain Thomas 67dac6bd8a Relax timeout 2023-11-09 19:09:30 +01:00
Romain Thomas 874b4c2512 Outline linux-py-x64 2023-11-09 19:04:48 +01:00
Romain Thomas be2be83eb6 Fix ccache 2023-11-09 16:23:35 +01:00
Romain Thomas e907b5989d Fix typo 2023-11-09 14:22:46 +01:00
Romain Thomas 98a08fc18e Remove script call 2023-11-09 14:22:45 +01:00
Romain Thomas 94f35ef40d Fix endless loop 2023-11-09 14:22:41 +01:00
Romain Thomas 2f61f29e84 Fix typo 2023-11-09 13:26:23 +01:00
Romain Thomas 5fe14ae8ae Split test step 2023-11-09 13:19:34 +01:00
Romain Thomas 1c0df938db Fix error 2023-11-09 09:07:53 +01:00
Romain Thomas c9c3b79334 Resize images 2023-11-09 09:07:37 +01:00
Romain Thomas 78c3196d67 Refactor the ELF Note support 2023-11-09 06:26:56 +01:00
Romain Thomas a7270ae577 Resolve #995 2023-11-09 06:16:50 +01:00
Romain Thomas 07df2f030f Resolve #994 2023-11-09 06:02:39 +01:00
Romain Thomas 267bab415a Update deployment script 2023-11-09 05:54:40 +01:00
Romain Thomas 0c472ca906 Replace str | None with Optional 2023-11-07 13:39:57 +01:00
Romain Thomas 23546d4bad Resolve #996
Usage:

```toml
[lief.build]
cxx-compiler = "/path/to/cxx"
c-compiler = "/path/to/c"
```
2023-11-07 11:43:12 +01:00
Romain Thomas d0ed158094 Update Sphinx C documentation 2023-11-07 10:47:02 +01:00
Romain Thomas 1c3e1d05b4 Fix missing include 2023-11-07 09:42:01 +01:00
Romain Thomas 05168d085a Update Doxygen 2023-11-07 07:20:24 +01:00
Romain Thomas 6b737986ba Fix alignement issue identified by @AvenGeeker
Resolve #993
2023-11-07 05:43:30 +01:00
Romain Thomas 6a98c63b06 Fix tests 2023-11-04 06:06:59 +01:00
Romain Thomas 2ed2b61c09 Speed-up compilation flags detection 2023-11-04 05:39:29 +01:00
Romain Thomas 1eb2df6e47 Use a CMakeLists.txt in the src/ directory 2023-11-04 05:31:13 +01:00
Romain Thomas 78006bc772 New build backend based on scikit-build-core 2023-11-04 04:06:51 +01:00
Romain Thomas 9961f6629d Resolve 984 2023-10-28 15:09:15 +02:00
Romain Thomas 8bd5e5824a Relax git versioning condition 2023-10-28 07:11:34 +02:00
Romain Thomas 1a44327d19 Fix Windows version 2023-10-28 05:47:36 +02:00
Romain Thomas 29f7e9d86f Python 3.12 support 2023-10-28 05:39:27 +02:00
Romain Thomas 00a00150d0 Fix EOL (NIX vs Windows) 2023-10-28 05:37:57 +02:00
Romain Thomas 021705297d Remove unused section 2023-10-22 20:07:31 +02:00
Romain Thomas e5ef1da160 Fix typing 2023-10-22 14:00:04 +02:00
Romain Thomas c6db72896f Add languages 2023-10-21 06:37:05 +02:00
Romain Thomas 2a2c56a173 Make typing stubs more accurate 2023-10-21 06:36:59 +02:00
Romain Thomas a27bd6a644 Add support for os.PathLike inputs in the parsers
Resolve: #974
2023-10-21 05:23:42 +02:00
Romain Thomas dffcff5df7 Fix logging 2023-10-15 23:03:20 +02:00
Romain Thomas 3ade2736c0 Improve typing stubs 2023-10-15 22:14:28 +02:00
Romain Thomas b8409a73c2 Fix missing include 2023-10-15 16:48:57 +02:00
Romain Thomas befbf6b4a0 Merge pull request #978 from adrianherrera/bugfix/cmake_add_subdirectory
Prefer CMAKE_CURRENT_BINARY_DIR over CMAKE_BINARY_DIR
2023-10-14 06:17:23 +02:00
Romain Thomas 5c43eadcd1 Use Python sys.stderr for LIEF's logger
By default, LIEF's logger uses `stderr` to emit log messages which
is not catchable in Python. This commit makes use of `sys.stderr` for
the Python bindings.
2023-10-14 05:36:41 +02:00
Romain Thomas 04b2fb88ac Move to spdlog 1.12.0 2023-10-14 05:01:25 +02:00
Adrian Herrera f4281b07e6 cmake: prefer CMAKE_CURRENT_BINARY_DIR over CMAKE_BINARY_DIR
Using CMAKE_BINARY_DIR breaks nesting LIEF within another cmake project
via add_subdirectory (as described
[here](https://lief-project.github.io/doc/latest/installation.html#add-subdirectory-or-fetchcontent)).
This is because CMAKE_BINARY_DIR will return the top-level of the build
tree, but if LIEF is nested within another cmake project this will not
correspond to LIEF's actual location.

Instead, CMAKE_CURRENT_BINARY_DIR will use the correct location.
2023-10-09 16:02:46 +11:00
Romain Thomas 293500897d Update issue template 2023-10-08 17:13:59 +02:00
Romain Thomas 068512c331 Bump nanobind to 1.6.2.r7.gb4c5af0 2023-10-07 12:48:52 +02:00
Romain Thomas b5b845a076 Cleanup cmake 2023-10-07 06:45:00 +02:00
Romain Thomas e8be94770c Fix temp path 2023-10-07 06:26:35 +02:00
Romain Thomas d1c16a2f8f Resolve #968 2023-10-07 06:07:47 +02:00
Romain Thomas d5dc7fdda0 Resolve #976 2023-10-07 05:39:30 +02:00
Romain Thomas d7b962d782 Fix 2023-10-01 10:35:08 +02:00
Romain Thomas dd95b2fbab Fix list vs tuple 2023-10-01 09:20:55 +02:00
Romain Thomas 9de43ed301 Set build temp 2023-10-01 09:14:08 +02:00
Romain Thomas a807fecf91 Fix path 2023-09-30 22:18:27 +02:00
Romain Thomas beb05cae8d Fix path 2023-09-30 21:44:10 +02:00
Romain Thomas 84b053793c Overload setuptools commands 2023-09-30 21:13:51 +02:00
Romain Thomas dd96f0129c pip wheel update 2023-09-30 15:56:10 +02:00
Romain Thomas b4c2f47563 Get rid of setup.py (deprecated) 2023-09-30 10:48:42 +02:00
Romain Thomas f8b7dd7031 Fix include 2023-09-30 06:44:49 +02:00
Romain Thomas db0bf3e794 Remove typing info 2023-09-30 06:40:03 +02:00
Romain Thomas 8e9eb84785 Resolve #970 2023-09-30 06:04:29 +02:00
Romain Thomas ad312da094 Add option for a custom build dir 2023-09-30 04:39:37 +02:00
Romain Thomas 6e4722624a Fix typo 2023-09-23 06:49:27 +02:00
Romain Thomas 8e9a68aded Merge pull request #971 from su-vikas/master
ELF Python - fixing utf-8 encoding issue
2023-09-21 21:41:48 +02:00
Vikas 84d1388e5e ELF Python - fixing utf-8 encoding issue 2023-09-21 20:08:13 +05:30
Romain Thomas c0a05dc6ec Fix test 2023-09-16 07:21:20 +02:00
Romain Thomas b3d6b20085 Fix return type (#965) 2023-09-16 06:00:21 +02:00
Romain Thomas e89db0c1c9 Update references 2023-09-16 05:49:54 +02:00
Romain Thomas 3c959daa58 Resolve #965 2023-09-16 05:49:26 +02:00
Romain Thomas 3414ded8cd Fix doc (#962) 2023-09-10 20:54:36 +02:00
Romain Thomas 1f52f26c13 Add requirement file 2023-09-10 13:33:28 +02:00
Romain Thomas b820df0bd7 Fix space 2023-09-10 13:11:23 +02:00
Romain Thomas ed4f9b5bb6 Merge pull request #961 from starseeker/master
Adjust file listings for Ninja Multi-Config build
2023-09-09 05:44:32 +02:00
Clifford Yapp c36120abdb Adjust file listings for Ninja Multi-Config build
For CMake's Ninja Multi-Config generator, we need to list all the
mbedtls files explicitly as BUILD_BYPRODUCTS for ExternalProject_Add
rather than just the directory.
2023-09-08 10:48:28 -04:00
Romain Thomas 8ef47cd979 Resolve #959 2023-09-02 11:55:23 +02:00
Romain Thomas 0030630df4 Resolve #958 2023-09-02 06:03:44 +02:00
Romain Thomas 88030da9a8 Remove unused field 2023-08-27 23:12:45 +02:00
Romain Thomas 1ecfbf1fd8 Add new ELF DT_ enums.
This commit resolves the `UNDEFINED` output mentioned in #954, whilst
not supporting yet the packed relocations.
2023-08-27 21:33:23 +02:00
Romain Thomas 2ad31be179 Merge pull request #953 from gvalkov/docfix
Use list comprehension instead of map/filter in tutorial
2023-08-20 16:40:19 +00:00
Georgi Valkov 02ecdd12b3 Use list comprehension instead of map/filter 2023-08-20 10:49:21 +02:00
Romain Thomas 660f26ebf4 Resolve #952 2023-08-19 05:09:20 +02:00
Romain Thomas 1f3b19ea21 Merge pull request #949 from rdbo/rdbo-iterator-windows-fix
Removed _ITERATOR_DEBUG_LEVEL override on Windows builds
2023-08-12 15:34:47 +00:00
Rdbo 71f64b9dab updated CMakeLists
Removed override of `_ITERATOR_DEBUG_LEVEL` variable on Windows.
2023-08-07 00:33:32 +00:00
Romain Thomas bab28ae062 Merge pull request #947 from Biswa96/cmake-fix-win32
CMake: Fix checking Windows platform
2023-08-06 15:41:17 +00:00
Biswapriyo Nath 2b6b2d488e CMake: Fix checking Windows platform
In CMake, WIN32 is true for any toolchain targeting Windows platform.
See https://cmake.org/cmake/help/latest/variable/WIN32.html
2023-08-06 19:23:24 +05:30
Romain Thomas 5b6eefbe9c Resolve #945 2023-08-05 21:28:36 +02:00
Romain Thomas 65d6b150d6 Cleanup 2023-07-30 22:31:11 +02:00
Romain Thomas 9e9d26f70b Fix static_assert 2023-07-30 12:35:21 +02:00
Romain Thomas 3185d59870 Clean header 2023-07-30 12:33:10 +02:00
Romain Thomas 73e23deb60 Clean doc 2023-07-30 12:27:45 +02:00
Romain Thomas 752ab8a3ce Udpate cmake 2023-07-30 11:14:59 +02:00
Romain Thomas f70b2371b9 Clean cmake 2023-07-30 08:26:11 +02:00
Romain Thomas c6381bbcc1 Update doc 2023-07-30 06:24:47 +02:00
Romain Thomas f999ea6456 Clean and refactor the PE SignatureParser 2023-07-30 06:07:41 +02:00
Romain Thomas ac939a645f Update 2023-07-28 17:30:28 +02:00
Romain Thomas cc165d2aba Refactor and clean LIEF::PE::Section 2023-07-28 17:15:14 +02:00
Romain Thomas 5b8ef83022 Clean conf 2023-07-28 07:12:44 +02:00
Romain Thomas 6a90b3457f Refactor and clean LIEF::PE::DataDirectory 2023-07-27 21:14:38 +02:00
Romain Thomas d34d20c198 Refactor and clean LIEF::PE::Header 2023-07-27 18:33:09 +02:00
Romain Thomas 22a6ffa0bd Refactor and clean LIEF::PE::OptionHeader 2023-07-27 18:30:11 +02:00
Romain Thomas 1781ba0f61 Clean DosHeader interface 2023-07-27 18:23:43 +02:00
Romain Thomas 6e328569fb Clean TLS interface 2023-07-27 07:48:08 +02:00
Romain Thomas 00d9cc7c25 Fix test 2023-07-27 07:16:53 +02:00
Romain Thomas bff5411884 Fix reserved identifier 2023-07-27 07:16:40 +02:00
Romain Thomas c225890973 Inline functions that are suitable for inlining 2023-07-26 21:58:48 +02:00
Romain Thomas 96193a0488 Add memory profiler 2023-07-26 21:28:17 +02:00
Romain Thomas 5936e85d02 Fix typo 2023-07-26 07:30:18 +02:00
Romain Thomas e41c3280ec Improve API 2023-07-26 06:09:56 +02:00
Romain Thomas e4a7f679a8 Add code-check action 2023-07-26 06:07:22 +02:00
Romain Thomas 97bf8b65ff Clean and simplify code 2023-07-25 18:41:39 +02:00
2977 changed files with 589260 additions and 73894 deletions
+1 -1
View File
@@ -1 +1 @@
github: [romainthomas]
github: [lief-project]
+9 -1
View File
@@ -4,7 +4,6 @@ about: You identified a bug or a problem in LIEF
title: ''
labels: ''
assignees: romainthomas
---
**Describe the bug**
@@ -23,3 +22,12 @@ A clear and concise description of what you expected to happen (if applicable)
**Additional context**
Add any other context about the problem here.
**NOTICE**
If the issue does not contain enough information to be reproduced,
it will be flagged as [incomplete](https://github.com/lief-project/LIEF/issues?q=is%3Aissue+is%3Aclosed+label%3AIncomplete)
and closed.
**/NOTICE**
+2 -2
View File
@@ -4,6 +4,6 @@ bucket = "lief"
endpoint = "https://s3.fr-par.scw.cloud"
[lief.deploy]
branches = ["master", "deploy", "devel"]
main-branches = ["master", "main"]
branches = ["main", "master", "deploy", "devel"]
main-branches = ["main", "master"]
default-dir = "latest"
+39 -28
View File
@@ -12,17 +12,18 @@ import os
import sys
import tempfile
import tomli
import re
LOG_LEVEL = logging.INFO
CURRENTDIR = Path(__file__).resolve().parent
REPODIR = CURRENTDIR.parent
ASSET_DIR = CURRENTDIR / "assets"
CONFIG_DIR = CURRENTDIR / "config"
LIEF_S3_KEY = os.getenv("LIEF_S3_KEY", None)
LIEF_S3_SECRET = os.getenv("LIEF_S3_SECRET", None)
OWNED_ORGS = ["lief-project/", "romainthomas/"]
RELEASE_KEYWRD = "release-"
CURRENTDIR = Path(__file__).resolve().parent
REPODIR = CURRENTDIR.parent
ASSET_DIR = CURRENTDIR / "assets"
CONFIG_DIR = CURRENTDIR / "config"
LIEF_S3_KEY = os.getenv("LIEF_S3_KEY", None)
LIEF_S3_SECRET = os.getenv("LIEF_S3_SECRET", None)
OWNED_ORGS = ["lief-project/", "romainthomas/"]
RELEASE_KEYWORD = ["release-", "release/"]
DEFAULT_CONFIG = CONFIG_DIR / "gh-ci.toml"
DEFAULT_TEMPLATE = (ASSET_DIR / "index.j2").read_text()
@@ -122,7 +123,8 @@ class S3Manager:
self._s3_push(index, dst)
def process_sdk_wheels(self, directory: Path, maxdepth: int = 0,
depth: int = 0, recurse: bool = True):
depth: int = 0, recurse: bool = True,
skip_sdk: bool = False):
logger.info("Processing directory: %s", directory)
for item in directory.iterdir():
if item.is_dir() and recurse:
@@ -132,7 +134,7 @@ class S3Manager:
self.process_sdk_wheels(item, maxdepth, depth + 1, recurse)
elif item.is_file():
extension = item.suffix
if extension in (".zip", ".gz"):
if extension in (".zip", ".gz") and not skip_sdk:
logger.info("[SDK ] Uploading '%s'", item.as_posix())
self.push_sdk(item.as_posix())
elif extension in (".whl", ):
@@ -140,9 +142,10 @@ class S3Manager:
self.push_wheel(item.as_posix())
def upload_wheels_sdk(self, src_dir: Path, maxdepth: int):
def upload_wheels_sdk(self, src_dir: Path, maxdepth: int, skip_sdk: bool):
logger.info("Looking for wheels and sdk from: %s", src_dir)
self.process_sdk_wheels(src_dir, maxdepth=maxdepth, recurse=True)
self.process_sdk_wheels(src_dir, maxdepth=maxdepth, recurse=True,
skip_sdk=skip_sdk)
wheels_index = self.generate_index(self.s3_lief_wheel,
DEFAULT_TEMPLATE,
@@ -248,35 +251,43 @@ class GithubDeploy:
def is_main_branch(self, name: str) -> bool:
return name in self._main_branches
def deploy(self, directories: list[str]):
def should_be_deployed(self, branch: str) -> bool:
if any(re.match(s, branch) for s in self._branches):
return True
return False
def deploy(self, directories: list[str], skip_sdk: bool = False):
s3dir = None
if GithubDeploy.is_tagged():
s3dir = GithubDeploy.tag_name()
else:
branch = GithubDeploy.branch()
if branch is None:
logger.warning("Can't resolve the branch name")
sys.exit(1)
branch = GithubDeploy.branch()
if branch is None:
logger.warning("Can't resolve the branch name")
sys.exit(1)
s3dir = self._default_dir
if not self.should_be_deployed(branch):
logger.info("Skipping deployment for branch: %s", branch)
return
if branch.startswith(RELEASE_KEYWRD):
_, s3dir = branch.split(RELEASE_KEYWRD)
elif self.is_main_branch(branch):
s3dir = self._default_dir
else:
s3dir = branch.replace("/", "-").replace("_", "-")
if s3dir is None:
logger.error("Target directory is not set")
sys.exit(1)
logger.info("s3dir: %s", s3dir)
self.s3_manager.change_dir(s3dir)
for dirname in directories:
dirpath = Path(dirname).resolve().absolute().expanduser()
self.s3_manager.upload_wheels_sdk(dirpath, maxdepth=1)
self.s3_manager.upload_wheels_sdk(dirpath, maxdepth=1,
skip_sdk=skip_sdk)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--config", "-c")
parser.add_argument("--dry-run", "-n", action="store_true", default=False)
parser.add_argument("--skip-sdk", action="store_true", default=False)
parser.add_argument("directories", nargs="+")
args = parser.parse_args()
@@ -291,7 +302,7 @@ def main():
sys.exit(1)
gh_deploy = GithubDeploy.from_config(config_path)
gh_deploy.deploy(args.directories)
gh_deploy.deploy(args.directories, args.skip_sdk)
if __name__ == "__main__":
main()
+7
View File
@@ -0,0 +1,7 @@
setuptools
boto3
requests
twine
tomli
mako
wheel
+6 -6
View File
@@ -9,7 +9,7 @@ jobs:
arch: ['arm', 'arm64']
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
@@ -18,7 +18,7 @@ jobs:
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.ccache
key: android-${{ runner.os }}-${{ matrix.arch }}-${{ steps.get-date.outputs.date }}
@@ -36,9 +36,9 @@ jobs:
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-${ARCH}.sh
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-sdk-${ARCH}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: android-sdk-${{ matrix.arch }}
path: build/*.tar.gz
@@ -48,11 +48,11 @@ jobs:
runs-on: ubuntu-latest
needs: build-sdk
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
+8 -15
View File
@@ -1,24 +1,16 @@
name: 'iOS'
on: push
env:
python-version: '3.10'
jobs:
ios-sdk:
runs-on: macos-11.0
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ env.python-version }}
- name: Install system dependencies
run: |
brew install cmake ninja ccache
python -m pip install --upgrade pip setuptools wheel
- name: Get Date
id: get-date
run: |
@@ -29,7 +21,7 @@ jobs:
run: |
mkdir -p ~/.ccache
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/.ccache
key: ios-${{ runner.os }}-${{ steps.get-date.outputs.date }}
@@ -45,7 +37,7 @@ jobs:
run: |
bash scripts/osx/package_ios.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ios-sdk
path: build/*.tar.gz
@@ -55,11 +47,11 @@ jobs:
if: ${{ always() }}
needs: ios-sdk
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
@@ -80,7 +72,8 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
liefproject/deploy \
python3 /src/.github/deploy.py /runner_tmp/artifacts
+44 -31
View File
@@ -5,7 +5,7 @@ jobs:
linux-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
@@ -14,7 +14,7 @@ jobs:
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.ccache
key: linux-aarch64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
@@ -24,22 +24,27 @@ jobs:
shell: bash
run: |
mkdir -p $RUNNER_TEMP/lief-install
docker run --name lief_sdk --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-aarch64.sh
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
docker run --name lief-sdk -u 1001:1001 --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux2014-aarch64 \
bash /src/scripts/docker/linux-sdk-aarch64
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-aarch64-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload Install Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-aarch64-install
path: ${{ runner.temp }}/lief-install
@@ -49,9 +54,9 @@ jobs:
needs: linux-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.9, '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
@@ -60,14 +65,14 @@ jobs:
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.ccache
key: linux-aarch64-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-aarch64-${{ runner.os }}-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: linux-aarch64-install
path: ${{ runner.temp }}/lief-install
@@ -76,20 +81,25 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
mkdir -p $HOME/.ccache
chmod -R 777 $HOME/.ccache
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION} \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/manylinux2014-aarch64.sh
PYTHON_BINARY="/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}"
docker run -u 1001:1001 --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=$PYTHON_BINARY \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux2014-aarch64 \
bash /src/scripts/docker/linux-py-aarch64
- name: 'Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-aarch64-python${{ matrix.python-version }}-wheel
path: dist/*.whl
@@ -99,12 +109,14 @@ jobs:
if: ${{ always() }}
needs: [linux-sdk, wheels]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
pattern: linux-aarch64-*
merge-multiple: true
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
@@ -124,6 +136,7 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
liefproject/deploy \
python3 /src/.github/deploy.py /runner_tmp/artifacts
+167 -72
View File
@@ -4,8 +4,22 @@ on: push
jobs:
linux-sdk:
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
CCACHE_DIR: "/home/pylief/.ccache"
CXXFLAGS: "-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libstdc++ -static-libgcc"
CFLAGS: "-ffunction-sections -fdata-sections -static-libstdc++ -static-libgcc"
LDFLAGS: "-Wl,--gc-sections -Wl,--exclude-libs,ALL"
BUILD_DIR_STATIC: "/tmp/build/linux-x86-64/static-release"
BUILD_DIR_SHARED: "/tmp/build/linux-x86-64/shared-release"
CLICOLOR_FORCE: "1"
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
ACTIONS_RUNTIME_TOKEN: "${{ env.ACTIONS_RUNTIME_TOKEN }}"
ACTIONS_CACHE_URL: "${{ env.ACTIONS_CACHE_URL }}"
options: --user 1001:1001
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
@@ -13,42 +27,76 @@ jobs:
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Prepare ccache
shell: bash
run: |
mkdir -p /home/pylief/.ccache/tmp
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.ccache
path: /home/pylief/.ccache
key: linux-x86-64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-sdk
- name: Build SDK
- name: CMake - Static
shell: bash
run: |
mkdir -p $RUNNER_TEMP/lief-install
docker run --name lief_sdk --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_sdk.sh
mkdir -p ${BUILD_DIR_STATIC}
cmake -S $GITHUB_WORKSPACE -B ${BUILD_DIR_STATIC} -GNinja \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=off \
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
-DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_BUILD_TYPE=Release
- name: Compile - Static
shell: bash
run: |
cmake --build ${BUILD_DIR_STATIC} --target install
- name: CMake - Shared
shell: bash
run: |
mkdir -p ${BUILD_DIR_SHARED}
cmake -S $GITHUB_WORKSPACE -B ${BUILD_DIR_SHARED} -GNinja \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCMAKE_LINK_WHAT_YOU_USE=on \
-DBUILD_SHARED_LIBS=on \
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
-DCMAKE_BUILD_TYPE=Release
- name: Compile - Shared
run: |
cmake --build ${BUILD_DIR_SHARED} --target all
- name: Package
run: |
cd /tmp/build/linux-x86-64
cpack --config $GITHUB_WORKSPACE/cmake/cpack.config.cmake
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-x86-64-sdk
path: build/*.tar.gz
path: /tmp/build/linux-x86-64/*.tar.gz
retention-days: 3
- name: 'Upload Install Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-x86-64-install
path: ${{ runner.temp }}/lief-install
path: /install
retention-days: 1
testing:
if: "!contains(github.event.commits[0].message, '[skip-test]')"
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
PYTHON_BINARY: "/opt/python/cp312-cp312/bin/python3.12"
LIEF_SAMPLES_DIR: "/tmp/samples"
LIEF_BUILD_DIR: "/tmp/lief-build"
LIEF_VENV: "/tmp/venv"
CLICOLOR_FORCE: "1"
PYTEST_ADDOPTS: "--color=yes"
options: --user 1001:1001
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
@@ -57,35 +105,90 @@ jobs:
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.ccache
key: linux-x86-64-${{ runner.os }}-test-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-test
- name: Python 3.8 -- Wheel & Test
- name: Prepare Python virtual env
shell: bash
env:
PYTHON_VERSION: 38
run: |
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=/opt/python/cp38-cp38/bin/python3.8 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_test.sh
$PYTHON_BINARY -m venv ${LIEF_VENV}
source ${LIEF_VENV}/bin/activate
python -m pip install \
-r tests/requirements.txt \
-r api/python/build-requirements.txt
- name: Build & install LIEF
shell: bash
run: |
source ${LIEF_VENV}/bin/activate
export PYLIEF_CONF="${GITHUB_WORKSPACE}/scripts/docker/config/pylinux-test-x64.toml"
python -m pip -vvv install api/python
- name: Prepare test samples
shell: bash
run: |
source ${LIEF_VENV}/bin/activate
mkdir -p ${LIEF_SAMPLES_DIR}
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
- name: Run tests
timeout-minutes: 5
shell: bash
run: |
source ${LIEF_VENV}/bin/activate
python tests/run_pytest.py
python tests/run_tools_check.py ${LIEF_BUILD_DIR}/
ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/
- name: Fuzzing [ls x86-64]
shell: bash
timeout-minutes: 20
run: |
source ${LIEF_VENV}/bin/activate
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
python tests/elf/fuzzing.py \
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_ls.bin -n 100
- name: Fuzzing [openssl x86-64]
shell: bash
timeout-minutes: 20
run: |
source ${LIEF_VENV}/bin/activate
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
python tests/elf/fuzzing.py \
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_openssl.bin -n 100
- name: Fuzzing [nm x86-64]
shell: bash
timeout-minutes: 20
run: |
source ${LIEF_VENV}/bin/activate
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
python tests/elf/fuzzing.py \
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_nm.bin -n 100
pywheels:
runs-on: ubuntu-latest
needs: linux-sdk
container:
image: liefproject/manylinux_2_28_x86_64
env:
CCACHE_DIR: "/home/pylief/.ccache"
CXXFLAGS: "-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc"
CFLAGS: "-ffunction-sections -fdata-sections -static-libgcc"
LDFLAGS: "-Wl,--gc-sections -Wl,--exclude-libs,ALL"
CLICOLOR_FORCE: "1"
FORCE_COLOR: "1"
LIEF_BUILD_DIR: "/tmp/lief-build"
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
ACTIONS_RUNTIME_TOKEN: "${{ env.ACTIONS_RUNTIME_TOKEN }}"
ACTIONS_CACHE_URL: "${{ env.ACTIONS_CACHE_URL }}"
options: --user 1001:1001
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Date
@@ -93,37 +196,42 @@ jobs:
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Prepare ccache
shell: bash
run: |
mkdir -p /home/pylief/.ccache/tmp
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.ccache
path: /home/pylief/.ccache
key: linux-x86-64-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: linux-x86-64-install
path: ${{ runner.temp }}/lief-install
- name: Python ${{ matrix.python-version }} -- Wheel
shell: bash
path: /install
- name: Generate wheel
env:
PYTHON_VERSION: ${{ matrix.python-version }}
shell: bash
run: |
export PYLIEF_CONF=$GITHUB_WORKSPACE/scripts/docker/config/pylinux-x64.toml
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION_ALT \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION} \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux.sh
PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}
$PYTHON_BINARY -m pip -vvv wheel --disable-pip-version-check \
--wheel-dir=$GITHUB_WORKSPACE/wheel_stage \
$GITHUB_WORKSPACE/api/python
- name: Run auditwheel
shell: bash
run: |
ls -alh $GITHUB_WORKSPACE/wheel_stage
find $GITHUB_WORKSPACE/wheel_stage -exec \
auditwheel repair -w $GITHUB_WORKSPACE/dist {} \;
ls -alh $GITHUB_WORKSPACE/dist
- name: 'Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-x86-64-python${{ matrix.python-version }}-wheel
path: dist/*.whl
@@ -131,14 +239,16 @@ jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [linux-sdk, pywheels]
needs: [pywheels]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
pattern: linux-x86-64-*
merge-multiple: true
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
@@ -158,20 +268,5 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
documentation:
needs: [deploy]
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
CIRCLE_CI_URL: "https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline"
CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
steps:
- name: Trigger documentation
if: github.ref == 'refs/heads/master'
run: |
curl --request POST --url ${CIRCLE_CI_URL} \
--header "Circle-Token: ${CIRCLE_CI_TOKEN}" \
--header 'content-type: application/json' \
--data '{"parameters":{"lief-branch":"master"}}'
liefproject/deploy \
python3 /src/.github/deploy.py --skip-sdk /runner_tmp/artifacts
+45 -38
View File
@@ -6,9 +6,9 @@ env:
jobs:
osx-sdk:
runs-on: macos-11.0
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
@@ -24,7 +24,7 @@ jobs:
run: |
mkdir -p $RUNNER_TEMP/.ccache
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/.ccache
key: osx-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
@@ -33,6 +33,7 @@ jobs:
- name: Build SDK
shell: bash
env:
CLICOLOR_FORCE: "1"
MACOSX_DEPLOYMENT_TARGET: "11.0"
CCACHE_DIR: ${{ runner.temp }}/.ccache
CCACHE_MAXSIZE: 10.0G
@@ -41,38 +42,37 @@ jobs:
run: |
bash scripts/osx/package_sdk.sh
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: osx-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload install artifact [arm64]'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: osx-arm64-install
path: install/arm64
retention-days: 1
- name: 'Upload install artifact [x64]'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: osx-x64-install
path: install/x64
retention-days: 1
osx-testing:
runs-on: macos-11.0
runs-on: macos-13
if: "!contains(github.event.commits[0].message, '[skip-test]')"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-test-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-test-version }}
- name: Install system dependencies
run: |
brew install cmake ninja ccache
python -m pip install --upgrade pip setuptools wheel
- name: Get Date
id: get-date
run: |
@@ -83,7 +83,7 @@ jobs:
run: |
mkdir -p $RUNNER_TEMP/.ccache
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/.ccache
key: osx-${{ runner.os }}-test-${{ steps.get-date.outputs.date }}
@@ -92,12 +92,16 @@ jobs:
- name: Upgrade pip
shell: bash
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade pip
- name: Build Python 3.10 with tests
shell: bash
env:
LIEF_SAMPLES_DIR: "/tmp/samples"
BUILD_DIR: "/tmp/lief-build"
LIEF_BUILD_DIR: "/tmp/lief-build"
PYLIEF_CONF: "${{ github.workspace }}/scripts/osx/osx-testing-x64.toml"
CLICOLOR_FORCE: "1"
PYTEST_ADDOPTS: "--color=yes"
FORCE_COLOR: "1"
MACOSX_TARGET: "11.7"
MACOSX_DEPLOYMENT_TARGET: "11.0"
CCACHE_DIR: ${{ runner.temp }}/.ccache
@@ -106,37 +110,39 @@ jobs:
CCACHE_COMPRESS: 1
run: |
python -m pip install -r tests/requirements.txt
python -m pip -vvv install api/python
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
cd api/python
PYLIEF_CONF=${GITHUB_WORKSPACE}/scripts/osx/osx-testing-x64.toml \
python ./setup.py build \
--build-base=${BUILD_DIR}/base \
--build-temp=${BUILD_DIR}/temp \
install --user
cd ${GITHUB_WORKSPACE}
- name: Run tests
shell: bash
timeout-minutes: 20
env:
LIEF_SAMPLES_DIR: "/tmp/samples"
LIEF_BUILD_DIR: "/tmp/lief-build"
PYTEST_ADDOPTS: "--color=yes"
run: |
python tests/run_pytest.py
python tests/run_tools_check.py ${BUILD_DIR}/temp
ctest --output-on-failure --test-dir ${BUILD_DIR}/temp
python tests/run_tools_check.py ${LIEF_BUILD_DIR}/
ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/
wheels:
runs-on: macos-11.0
runs-on: macos-13
needs: osx-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']
arch: ['x64', 'arm64']
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
brew install cmake ninja ccache
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
- name: Get Date
id: get-date
run: |
@@ -147,18 +153,14 @@ jobs:
run: |
mkdir -p $RUNNER_TEMP/.ccache
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/.ccache
key: osx-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
osx-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}
- name: Upgrade pip
shell: bash
run: |
python -m pip install --upgrade pip setuptools
- name: Download LIEF install dir
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: osx-${{ matrix.arch }}-install
path: ~/lief-${{ matrix.arch }}-install
@@ -166,6 +168,8 @@ jobs:
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
FORCE_COLOR: "1"
CLICOLOR_FORCE: "1"
CCACHE_DIR: ${{ runner.temp }}/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
@@ -174,7 +178,7 @@ jobs:
run: |
python -m pip -vv wheel --wheel-dir=dist/ api/python
- name: 'Upload Python wheel artifact - ${{ matrix.python-version }}'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: osx-wheel-${{ matrix.arch }}-${{ matrix.python-version }}
path: dist/*.whl
@@ -182,14 +186,16 @@ jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [osx-sdk, wheels]
needs: [wheels]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
pattern: osx-*
merge-multiple: true
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
@@ -209,6 +215,7 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
liefproject/deploy \
python3 /src/.github/deploy.py --skip-sdk /runner_tmp/artifacts
+24 -31
View File
@@ -9,39 +9,34 @@ jobs:
osx:
runs-on: macos-11.0
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-osx-version }}
- name: Install system dependencies
run: |
brew install cmake ninja ccache
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
- name: Build with Python ${{ env.python-osx-version }} & Test
shell: bash
env:
LIEF_SAMPLES_DIR: "/tmp/samples"
BUILD_DIR: "/tmp/lief-build"
LIEF_BUILD_DIR: "/tmp/lief-build"
PYLIEF_CONF: "${{ github.workspace }}/scripts/osx/osx-testing-x64.toml"
run: |
python -m pip install -r tests/requirements.txt
python -m pip install -e api/python
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
cd api/python
PYLIEF_CONF=${GITHUB_WORKSPACE}/scripts/osx/osx-testing-x64.toml \
python ./setup.py build \
--build-base=${BUILD_DIR}/base \
--build-temp=${BUILD_DIR}/temp \
install --user
cd ${GITHUB_WORKSPACE}
python tests/run_pytest.py
python tests/run_tools_check.py ${BUILD_DIR}/temp
ctest --output-on-failure --test-dir ${BUILD_DIR}/temp
python tests/run_tools_check.py ${BUILD_DIR}
ctest --output-on-failure --test-dir ${BUILD_DIR}
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build & Test
@@ -49,48 +44,46 @@ jobs:
env:
PYTHON_VERSION: 39
run: |
docker run --rm \
-e PYTHON_VERSION=$PYTHON_VERSION \
docker run --rm \
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
-v $GITHUB_WORKSPACE:/src \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_test.sh
-v $GITHUB_WORKSPACE:/src \
liefproject/manylinux_2_28_x86_64 \
bash /src/scripts/docker/test-linux-x64
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ env.python-win-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-win-version }}
architecture: x64
- name: Install system dependencies
run: |
choco install ninja
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade pip
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Set env variables
run: |
chcp 65001 #set code page to utf-8
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
echo ("BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
echo ("LIEF_BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
echo ("PYLIEF_CONF=" + $env:GITHUB_WORKSPACE + "/scripts/windows/py-x64-test.toml") >> $env:GITHUB_ENV
- name: Build Python ${{ env.python-win-version }}
shell: cmd
run: |
python -m pip install -r tests/requirements.txt
python -m pip install api/python
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
cd api/python
python ./setup.py build ^
--build-base=%BUILD_DIR%/base ^
--build-temp=%BUILD_DIR%/temp ^
install --user
shell: cmd
- name: Run tests
timeout-minutes: 20
shell: cmd
run: |
cd %GITHUB_WORKSPACE%
python tests/run_pytest.py
ctest --output-on-failure --test-dir %BUILD_DIR%/temp/Release
shell: cmd
ctest --output-on-failure --test-dir %BUILD_DIR%
-44
View File
@@ -1,44 +0,0 @@
name: 'sanitize'
on: workflow_dispatch
jobs:
gcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: compile
shell: bash
run: |
docker run --rm \
-e BUILD_DIR=/tmp/build_gcc \
-e SRC_DIR=/src \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/gcc.sh
clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: compile
shell: bash
run: |
docker run --rm \
-e BUILD_DIR=/tmp/build_clang \
-e SRC_DIR=/src \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/clang.sh
asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: compile
shell: bash
run: |
docker run --rm \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/asan_check.sh
+41 -38
View File
@@ -2,8 +2,10 @@ name: LIEF Windows
on:
push:
branches:
- 'main'
- 'master'
- 'release-**'
- 'release/**'
tags:
- '**'
@@ -13,7 +15,7 @@ env:
jobs:
build-sdk:
runs-on: windows-2019
runs-on: windows-2022
strategy:
matrix:
arch: ['x64', 'x86']
@@ -22,11 +24,11 @@ jobs:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
architecture: ${{ matrix.arch }}
@@ -36,14 +38,14 @@ jobs:
choco install sccache
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup sccache
uses: actions/cache@v3
uses: actions/cache@v4
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
@@ -56,13 +58,13 @@ jobs:
run: |
python ./scripts/windows/package_sdk.py
- name: 'Upload SDK artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}-sdk
path: build/*.zip
retention-days: 3
- name: 'Upload install artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}-install
path: ${{ runner.temp }}/lief-install
@@ -72,7 +74,7 @@ jobs:
- name: stop sccache server
run: sccache --stop-server || true
tests:
runs-on: windows-2019
runs-on: windows-2022
if: "!contains(github.event.commits[0].message, '[skip-test]')"
strategy:
matrix:
@@ -82,11 +84,11 @@ jobs:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-test-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-test-version }}
architecture: ${{ matrix.arch }}
@@ -96,14 +98,14 @@ jobs:
choco install sccache
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup sccache
uses: actions/cache@v3
uses: actions/cache@v4
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
@@ -127,44 +129,46 @@ jobs:
run: |
chcp 65001 #set code page to utf-8
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
echo ("BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
echo ("LIEF_BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
- name: Build Python ${{ env.python-test-version }}
shell: cmd
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
cd api/python
python ./setup.py build ^
--build-base=%BUILD_DIR%/base ^
--build-temp=%BUILD_DIR%/temp ^
install --user
python -m pip -vvv install --user api/python
- name: Download samples
shell: cmd
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
- name: Run tests
timeout-minutes: 20
shell: cmd
run: |
cd %GITHUB_WORKSPACE%
python tests/run_pytest.py
ctest --output-on-failure --test-dir %BUILD_DIR%/temp/Release
shell: cmd
ctest --output-on-failure --test-dir %LIEF_BUILD_DIR%/
- name: sccache stats
run: sccache --show-stats
- name: stop sccache server
run: sccache --stop-server || true
wheels:
runs-on: windows-2019
runs-on: windows-2022
needs: build-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12-dev']
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']
arch: ['x86', 'x64']
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.arch }}
@@ -172,17 +176,17 @@ jobs:
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Save sccache
uses: actions/cache@v3
uses: actions/cache@v4
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
@@ -190,16 +194,12 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-sccache-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: windows-${{ matrix.arch }}-install
path: ~/lief-${{ matrix.arch }}-install
- name: Start sccache server
run: sccache --start-server
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
shell: cmd
- name: Set arch specific env
if: matrix.arch == 'x64'
run: |
@@ -216,10 +216,10 @@ jobs:
chcp 65001 #set code page to utf-8
- name: Build Python ${{ matrix.python-version }}
run: |
python -m pip -vv wheel --wheel-dir=dist/ api/python
python -m pip -vvv wheel --wheel-dir=dist/ ./api/python
shell: cmd
- name: 'Upload Python artifacts [${{ matrix.python-version }}]'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}-wheel-${{ matrix.python-version }}
path: dist/*.whl
@@ -227,14 +227,17 @@ jobs:
deploy:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [build-sdk, wheels]
#needs: [build-sdk, wheels]
needs: [wheels]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
pattern: windows-*
merge-multiple: true
path: ${{ runner.temp }}/artifacts
- name: Deploy
env:
@@ -251,5 +254,5 @@ jobs:
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
liefproject/deploy python3 /src/.github/deploy.py --skip-sdk /runner_tmp/artifacts
+16 -14
View File
@@ -4,16 +4,18 @@ on:
branches:
- '**'
- '!master'
- '!main'
- '!release-**'
- '!release/**'
tags-ignore:
- "**"
env:
python-version: '3.9'
python-version: '3.12'
jobs:
quick-test:
runs-on: windows-2019
runs-on: windows-2022
strategy:
matrix:
arch: [x64, x86]
@@ -22,11 +24,11 @@ jobs:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
architecture: ${{ matrix.python-version }}
@@ -34,17 +36,17 @@ jobs:
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
vsversion: "2022"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Save sccache
uses: actions/cache@v3
uses: actions/cache@v4
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
@@ -57,20 +59,20 @@ jobs:
run: |
chcp 65001 #set code page to utf-8
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
shell: cmd
- name: Build Python ${{ env.python-version }}
shell: cmd
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
python -m pip -vv install api/python
python -m pip -vvv install api/python
- name: Download samples
shell: cmd
run: |
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
- name: Run tests
shell: cmd
timeout-minutes: 20
run: |
python ./tests/run_pytest.py
shell: cmd
- name: sccache stats
run: sccache --show-stats
- name: sccache server
+7
View File
@@ -1,5 +1,12 @@
build/
*.so
*.whl
*.dll
*.dylib
*.lib
lief.egg-info/
dist/
api/rust/cargo/target/*
api/rust/examples/target/*
tools/target/*
plugins/ghidra/bin/
+4
View File
@@ -0,0 +1,4 @@
include:
- project: 'LIEF/ci'
ref: main
file: 'main.yml'
+101 -283
View File
@@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.24)
project(LIEF LANGUAGES C CXX)
enable_language(C)
enable_language(CXX)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
@@ -18,56 +22,38 @@ include(CheckCCompilerFlag)
include(ExternalProject)
include(CMakePackageConfigHelpers)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
find_package(Git REQUIRED)
# Information from git
# ====================
find_package(Git)
if (DEFINED ENV{LIEF_VERSION_ENV})
string(REGEX MATCHALL "([0-9]+)" VERSION_STRING "$ENV{LIEF_VERSION_ENV}")
if (NOT VERSION_STRING)
message(FATAL_ERROR "Invalid version")
endif()
list(GET VERSION_STRING 0 LIEF_VERSION_MAJOR)
list(GET VERSION_STRING 1 LIEF_VERSION_MINOR)
list(GET VERSION_STRING 2 LIEF_VERSION_PATCH)
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND Git_FOUND)
include(LIEFGit)
else()
set(LIEF_VERSION_MAJOR "0")
set(LIEF_VERSION_MINOR "14")
set(LIEF_VERSION_PATCH "0")
set(LIEF_VERSION_MAJOR 0)
set(LIEF_VERSION_MINOR 17)
set(LIEF_VERSION_PATCH 6)
endif()
if (DEFINED ENV{LIEF_COMMIT})
set(LIEF_COMMIT_HASH "$ENV{LIEF_COMMIT}")
endif()
if (DEFINED ENV{LIEF_BRANCH})
set(LIEF_GIT_BRANCH "$ENV{LIEF_BRANCH}")
endif()
# LIEF Project
# ============
project(
LIEF
VERSION ${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH})
project(LIEF VERSION
${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH})
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION}")
# Select the MSVC runtime based on the LIEF_USE_CRT_XXX variable
if(MSVC)
foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
string(TOUPPER "${build_type}" build)
if(DEFINED "LIEF_USE_CRT_${build}")
set(runtime "${LIEF_USE_CRT_${build}}")
if(build_type STREQUAL Debug)
set(default_runtime MDd)
else()
set(default_runtime MD)
endif()
if(runtime AND NOT "${runtime}" STREQUAL "${default_runtime}")
if(runtime STREQUAL "MT")
set(runtime_library "MultiThreaded")
elseif(runtime STREQUAL "MD")
set(runtime_library "MultiThreadedDLL")
elseif(runtime STREQUAL "MTd")
set(runtime_library "MultiThreadedDebug")
elseif(runtime STREQUAL "MDd")
set(runtime_library "MultiThreadedDebugDLL")
else()
message(FATAL_ERROR "Unsupported value LIEF_USE_CRT_${build}=${runtime}")
endif()
message(STATUS "LIEF_CRT_${build}: ${runtime}")
set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}$<$<CONFIG:${build_type}>:${runtime_library}>")
endif()
endif()
endforeach()
endif()
# LIEF options
# =============
include(LIEFOptions)
@@ -111,6 +97,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
endif()
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_LINK_EXECUTABLE: ${CMAKE_CXX_LINK_EXECUTABLE}")
message(STATUS "CMAKE_CXX_LINK_FLAGS: ${CMAKE_CXX_LINK_FLAGS}")
@@ -123,131 +111,51 @@ message(STATUS "CMAKE_LINK_LIBRARY_FILE_FLAG: ${CMAKE_LINK_LIBRARY_FILE_FLA
message(STATUS "CMAKE_LINK_INTERFACE_LIBRARIES: ${CMAKE_LINK_INTERFACE_LIBRARIES}")
message(STATUS "CMAKE_CXX_IMPLICIT_LINK_LIBRARIES: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
include(GNUInstallDirs)
# LIEF Source definition
# ======================
set(LIEF_PRIVATE_INCLUDE_DIR)
set(LIEF_PUBLIC_INCLUDE_DIR)
set(LIEF_PUBLIC_INCLUDE_FILES)
set(LIEF_PRIVATE_INCLUDE_FILES)
set(LIBLIEF_SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/errors.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_stream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/logging.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/iostream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal_utils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Object.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Object.tcc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Visitor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/BinaryStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/VectorStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/FileStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/MemoryStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/SpanStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/Convert.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/hash.cpp")
# Grouping basic headers together
# ===============================
set(LIEF_INC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/errors.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/span.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iostream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iterators.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/LIEF.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/logging.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/MachO.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/PE.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/types.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/visibility.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Object.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Visitor.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/visitor_macros.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/BinaryStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/VectorStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/FileStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/MemoryStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/SpanStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/Convert.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal_utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_stream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/frozen.hpp"
)
set(LIEF_VISITOR_INCLUDE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/hash.hpp")
set(LIEF_INCLUDE_FILES ${LIEF_INC_FILES} ${LIEF_VISITOR_INCLUDE_FILES})
set(LIEF_JSON_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/json.cpp")
set(LIEF_JSON_HDR "${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/json.hpp")
list(APPEND LIEF_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/json.hpp")
list(APPEND LIBLIEF_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/json_api.cpp")
if(LIEF_ENABLE_JSON)
list(APPEND LIBLIEF_SOURCE_FILES "${LIEF_JSON_SRC}")
list(APPEND LIEF_INC_FILES "${LIEF_JSON_HDR}")
endif()
source_group("Header Files" FILES ${LIEF_INC_FILES})
source_group("Source Files" FILES ${LIBLIEF_SOURCE_FILES})
source_group("Header Files\\visitors" FILES ${LIEF_VISITOR_INCLUDE_FILES})
add_library(LIB_LIEF ${LIBLIEF_SOURCE_FILES} ${LIEF_INCLUDE_FILES})
add_library(LIB_LIEF src/Object.cpp)
add_subdirectory(src)
if(NOT LIEF_PY_LIEF_EXT)
add_library(LIEF::LIEF ALIAS LIB_LIEF)
endif()
if(NOT LIEF_OPT_MBEDTLS_EXTERNAL)
set_source_files_properties(${mbedtls_src_crypto} PROPERTIES GENERATED TRUE)
set_source_files_properties(${mbedtls_src_x509} PROPERTIES GENERATED TRUE)
set_source_files_properties(${mbedtls_src_tls} PROPERTIES GENERATED TRUE)
target_sources(LIB_LIEF PRIVATE
"${mbedtls_src_crypto}"
"${mbedtls_src_x509}"
"${mbedtls_src_tls}")
set_source_files_properties(${mbedtls_src_files} PROPERTIES GENERATED TRUE)
target_sources(LIB_LIEF PRIVATE ${mbedtls_src_files})
target_compile_definitions(LIB_LIEF PRIVATE -DMBEDTLS_NO_PLATFORM_ENTROPY)
source_group("mbedtls\\crypto" FILES ${mbedtls_src_crypto})
source_group("mbedtls\\x509" FILES ${mbedtls_src_x509})
source_group("mbedtls\\tls" FILES ${mbedtls_src_tls})
target_include_directories(
LIB_LIEF SYSTEM PRIVATE
"${MBEDTLS_INCLUDE_DIRS}"
"${MBEDTLS_SOURCE_DIR}/library"
target_include_directories(LIB_LIEF SYSTEM PRIVATE
${MBEDTLS_INCLUDE_DIRS}
"${MBEDTLS_SOURCE_DIR}/library"
)
add_dependencies(LIB_LIEF lief_mbed_tls)
else()
find_package(MbedTLS REQUIRED)
target_link_libraries(LIB_LIEF PRIVATE
MbedTLS::mbedcrypto
MbedTLS::mbedx509)
MbedTLS::mbedcrypto MbedTLS::mbedx509)
endif()
if(WINDOWS AND BUILD_SHARED_LIBS)
target_link_libraries(LIB_LIEF ws2_32)
target_compile_definitions(LIB_LIEF PRIVATE
-DMBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_SOURCE_DIR}/config/mbedtls/config.h"
)
if(WIN32 AND BUILD_SHARED_LIBS)
target_link_libraries(LIB_LIEF PRIVATE ws2_32)
if (LIEF_IMPORT_SUFFIX)
set_target_properties(LIB_LIEF PROPERTIES IMPORT_SUFFIX "${LIEF_IMPORT_SUFFIX}")
endif()
endif()
if(MSVC)
add_compile_options(/bigobj)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug AND WINDOWS)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0 -D_SECURE_SCL=0
-D_HAS_ITERATOR_DEBUGGING=0)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug AND UNIX)
target_compile_options(LIB_LIEF PRIVATE -g -O0)
endif()
@@ -258,88 +166,30 @@ else()
target_compile_definitions(LIB_LIEF PRIVATE -DLIEF_STATIC)
endif()
# Abstract part
include("${CMAKE_CURRENT_SOURCE_DIR}/src/Abstract/CMakeLists.txt")
# ELF Part
# ========
include("${CMAKE_CURRENT_SOURCE_DIR}/src/ELF/CMakeLists.txt")
if(LIEF_ELF)
set(ENABLE_ELF_SUPPORT 1)
else()
set(ENABLE_ELF_SUPPORT 0)
endif()
# PE Part
# =======
include("${CMAKE_CURRENT_SOURCE_DIR}/src/PE/CMakeLists.txt")
if(LIEF_PE)
set(ENABLE_PE_SUPPORT 1)
else()
set(ENABLE_PE_SUPPORT 0)
endif()
# MachO part
# ==========
include("${CMAKE_CURRENT_SOURCE_DIR}/src/MachO/CMakeLists.txt")
if(LIEF_MACHO)
set(ENABLE_MACHO_SUPPORT 1)
else()
set(ENABLE_MACHO_SUPPORT 0)
if(LIEF_ENABLE_JSON)
# Make nlohmann/json is only using C++11 API.
# Especially, MSVC[14.37.32822] is buggy with (no)rtti & std::any
# Ref:
# - https://github.com/nlohmann/json/issues/3900
# - https://github.com/microsoft/STL/issues/4349#issuecomment-1920093172
target_compile_definitions(LIB_LIEF PRIVATE JSON_HAS_CPP_11)
endif()
# Logging Configuration
# =====================
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_DISABLE_DEFAULT_LOGGER
SPDLOG_NO_EXCEPTIONS
SPDLOG_FUNCTION=)
if (MSVC AND NOT CLANG_CL AND NOT LIEF_EXTERNAL_SPDLOG)
target_compile_definitions(LIB_LIEF PRIVATE FMT_UNICODE=0)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_NO_THREAD_ID)
endif()
# OAT part
# ========
if(LIEF_OAT)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/OAT/CMakeLists.txt)
set(ENABLE_OAT_SUPPORT 1)
else()
set(ENABLE_OAT_SUPPORT 0)
endif()
# DEX part
# ========
if(LIEF_DEX)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/DEX/CMakeLists.txt)
set(ENABLE_DEX_SUPPORT 1)
else()
set(ENABLE_DEX_SUPPORT 0)
endif()
# VDEX part
# =========
if(LIEF_VDEX)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/VDEX/CMakeLists.txt)
set(ENABLE_VDEX_SUPPORT 1)
else()
set(ENABLE_VDEX_SUPPORT 0)
endif()
# ART part
# ========
if(LIEF_ART)
include(${CMAKE_CURRENT_SOURCE_DIR}/src/ART/CMakeLists.txt)
set(ENABLE_ART_SUPPORT 1)
else()
set(ENABLE_ART_SUPPORT 0)
endif()
# Platforms
# =========
include(${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/CMakeLists.txt)
# LIEF includes
# =============
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/version.h.in"
@@ -348,16 +198,18 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/version.h.in"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/config.h" @ONLY)
list(APPEND LIEF_PUBLIC_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/"
"${CMAKE_CURRENT_BINARY_DIR}/include/")
set(LIEF_PUBLIC_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/include/
${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/
${CMAKE_CURRENT_BINARY_DIR}/include/)
list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${LIEF_PUBLIC_INCLUDE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}")
set(LIEF_PRIVATE_INCLUDE_DIR
${LIEF_PUBLIC_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in
${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc @ONLY)
target_include_directories(LIB_LIEF
PUBLIC "$<BUILD_INTERFACE:${LIEF_PUBLIC_INCLUDE_DIR}>"
@@ -382,6 +234,7 @@ if(LIEF_ENABLE_JSON)
target_include_directories(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/)
endif()
target_compile_definitions(LIB_LIEF PRIVATE JSON_NOEXCEPTION)
endif()
if(LIEF_FROZEN_ENABLED)
@@ -423,7 +276,7 @@ endif()
if(LIEF_OPT_UTFCPP_EXTERNAL)
find_package(utf8cpp REQUIRED)
target_link_libraries(LIB_LIEF PRIVATE utf8cpp)
target_link_libraries(LIB_LIEF PRIVATE utf8cpp::utf8cpp)
else()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/internal/utfcpp/utf8.h
COMMAND
@@ -462,28 +315,23 @@ endif()
target_link_libraries(LIB_LIEF PRIVATE lief_spdlog)
if(ANDROID AND BUILD_SHARED_LIBS AND LIEF_LOGGING)
if(ANDROID AND LIEF_LOGGING)
target_link_libraries(LIB_LIEF PUBLIC log)
endif()
# Flags definition
# ----------------
# cmake-format: off
set_target_properties(
LIB_LIEF
set_target_properties(LIB_LIEF
PROPERTIES POSITION_INDEPENDENT_CODE ON
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
VISIBILITY_INLINES_HIDDEN ON
CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden)
# cmake-format: on
if(UNIX AND NOT APPLE)
set_property(
TARGET LIB_LIEF
APPEND
PROPERTY LINK_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
set_property(TARGET LIB_LIEF APPEND
PROPERTY LINK_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
endif()
target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)
@@ -497,7 +345,7 @@ if(LIEF_ASAN)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS -fsanitize=address)
target_link_libraries(LIB_LIEF INTERFACE asan)
target_link_libraries(LIB_LIEF INTERFACE libclang_rt.asan.so)
endif()
if(LIEF_LSAN)
@@ -539,27 +387,27 @@ endif()
if(LIEF_SANITIZER)
message("LIEF Sanitizer enabled: ${SANITIZER_FLAGS}")
target_compile_options(LIB_LIEF PUBLIC ${SANITIZER_FLAGS})
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/sanitizer")
add_subdirectory(tests/sanitizer)
endif()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Fuzzing options
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(LIEF_FUZZING)
set(FUZZING_FLAGS -fno-omit-frame-pointer -g -O2 -fsanitize=address,fuzzer-no-link)
set(FUZZING_LINKER_FLAGS -fsanitize=address,fuzzer-no-link)
set(FUZZING_FLAGS -fno-omit-frame-pointer -g -O2 -fsanitize=fuzzer-no-link)
set(FUZZING_LINKER_FLAGS -fsanitize=fuzzer-no-link)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS ${FUZZING_LINKER_FLAGS})
target_compile_options(LIB_LIEF PRIVATE ${FUZZING_FLAGS})
target_link_libraries(LIB_LIEF PUBLIC asan pthread)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/fuzzing")
target_link_libraries(LIB_LIEF PUBLIC pthread)
add_subdirectory(fuzzing)
endif()
include(LIEFCompilerFlags)
if(LIEF_PROFILING)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/profiling")
add_subdirectory(profiling)
endif()
set_target_properties(LIB_LIEF PROPERTIES
@@ -567,6 +415,12 @@ set_target_properties(LIB_LIEF PROPERTIES
EXPORT_NAME LIEF
CLEAN_DIRECT_OUTPUT 1)
if (LIEF_SO_VERSION)
set_target_properties(LIB_LIEF PROPERTIES
VERSION "${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH}"
SOVERSION "${LIEF_VERSION_MAJOR}"
)
endif()
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@@ -586,28 +440,15 @@ if(APPLE)
set_target_properties(LIB_LIEF PROPERTIES MACOSX_RPATH ON)
endif()
# API
# ======================
include(LIEFApi)
add_subdirectory(api)
# Examples
# ======================
if(LIEF_EXAMPLES)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/examples")
add_subdirectory(examples)
endif()
# Tests
# ======================
if(LIEF_TESTS)
enable_testing()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests")
endif()
# Documentation
# ======================
if(LIEF_DOC)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/doc)
add_subdirectory(tests)
endif()
# Post-build operations
@@ -638,10 +479,8 @@ if(LIEF_INSTALL)
# Find Package Config
# ======================
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEFConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEFConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake @ONLY)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
@@ -663,25 +502,6 @@ if(LIEF_INSTALL)
endif()
endif()
# Installation
# ======================
if(UNIX)
include(GNUInstallDirs)
set(CMAKE_INSTALL_LIBDIR "lib")
else()
if(WIN32)
set(CMAKE_INSTALL_LIBDIR "lib")
set(CMAKE_INSTALL_DATADIR "share")
set(CMAKE_INSTALL_INCLUDEDIR "include")
set(CMAKE_INSTALL_BINDIR "bin")
set(CMAKE_INSTALL_DATAROOTDIR "share")
message(STATUS "Setting installation destination on Windows to: ${CMAKE_INSTALL_PREFIX}")
else()
message(FATAL_ERROR "System not UNIX nor WIN32 - not implemented yet")
endif()
endif()
install(
TARGETS LIB_LIEF lief_spdlog
EXPORT LIEFExport
@@ -700,7 +520,7 @@ if(LIEF_INSTALL)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LIEF
COMPONENT config)
install(
@@ -717,7 +537,7 @@ if(LIEF_INSTALL)
install(
EXPORT LIEFExport
NAMESPACE LIEF::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LIEF
FILE LIEFExport-${lib_type}.cmake
COMPONENT config)
@@ -726,7 +546,5 @@ if(LIEF_INSTALL)
NAMESPACE LIEF::
FILE LIEFExport-${lib_type}.cmake)
# Package
# ======================
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package")
add_subdirectory(package)
endif()
+2 -2
View File
@@ -186,8 +186,8 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2017 - 2023 R. Thomas
Copyright 2017 - 2023 Quarkslab
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.
+96 -83
View File
@@ -1,87 +1,60 @@
<p align="center" >
<img width="90%" src="https://github.com/lief-project/LIEF/blob/master/.github/images/architecture.png"/><br />
<img width="90%" src="https://github.com/lief-project/LIEF/blob/main/.github/images/architecture.png"/><br />
</p>
<p align="center">
<a href="https://discord.gg/7hRFGWYedu">
<img src="https://img.shields.io/discord/1117013848914931762">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/linux-x86-64.yml">
<img alt="Linux x86-64 CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/linux-x86-64.yml?branch=master&label=Linux%20x86-64&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/linux-aarch64.yml">
<img alt="Linux AArch64 CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/linux-aarch64.yml?branch=master&label=Linux%20AArch64&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/android.yml">
<img alt="Android CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/android.yml?branch=master&label=Android&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/osx.yml">
<img alt="macOS CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/osx.yml?branch=master&label=macOS&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/ios.yml">
<img alt="iOS CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/ios.yml?branch=master&label=iOS&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/windows-all.yml">
<img alt="Windows CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/windows-all.yml?branch=master&label=Windows&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/releases">
<img src="https://img.shields.io/github/v/release/lief-project/LIEF?style=flat-square">
</a>
&nbsp;
<a href="https://twitter.com/LIEF_project">
<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/lief_project">
</a>
</p>
<br />
<p align="center">
<a href="https://lief-project.github.io/blog/"><b>Blog</b></a> •
<a href="https://lief-project.github.io/doc/latest/index.html"><b>Documentation</b></a> •
<a href="https://lief.re/blog/"><b>Blog</b></a> •
<a href="https://lief.re/doc/latest/index.html"><b>Documentation</b></a> •
<a href="#user-content-about-1"><b>About</b></a>
</p>
<br />
# About
The purpose of this project is to provide a cross platform library which can parse,
The purpose of this project is to provide a cross-platform library to parse,
modify and abstract ELF, PE and MachO formats.
Main features:
**Main features**:
* **Parsing**: LIEF can parse ELF, PE, MachO, OAT, DEX, VDEX, ART and provides an user-friendly API to access to format internals.
* **Modify**: LIEF enables to modify some parts of these formats
* **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, C++ and Python
* **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)
- [Sphinx](https://lief-project.github.io/doc/stable/index.html)
- [Doxygen](https://lief-project.github.io/doc/latest/doxygen/index.html)
- [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-project.github.io/doc/latest/tutorials/01_play_with_formats.html)
- [Create a PE from scratch](https://lief-project.github.io/doc/latest/tutorials/02_pe_from_scratch.html)
- [Play with ELF symbols](https://lief-project.github.io/doc/latest/tutorials/03_elf_change_symbols.html)
- [ELF Hooking](https://lief-project.github.io/doc/latest/tutorials/04_elf_hooking.html)
- [Infecting the plt/got](https://lief-project.github.io/doc/latest/tutorials/05_elf_infect_plt_got.html)
- [PE Hooking](https://lief-project.github.io/doc/latest/tutorials/06_pe_hooking.html)
- [PE Resources](https://lief-project.github.io/doc/latest/tutorials/07_pe_resource.html)
- [Transforming an ELF executable into a library](https://lief-project.github.io/doc/latest/tutorials/08_elf_bin2lib.html)
- [How to use frida on a non-rooted device](https://lief-project.github.io/doc/latest/tutorials/09_frida_lief.html)
- [Android formats](https://lief-project.github.io/doc/latest/tutorials/10_android_formats.html)
- [Mach-O modification](https://lief-project.github.io/doc/latest/tutorials/11_macho_modification.html)
- [ELF Coredump](https://lief-project.github.io/doc/latest/tutorials/12_elf_coredump.html)
- [PE Authenticode](https://lief-project.github.io/doc/latest/tutorials/13_pe_authenticode.html)
- [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)
@@ -90,12 +63,27 @@ Main features:
## Downloads / Install
First, make sure to have an updated version of setuptools:
## C++
```console
pip install setuptools --upgrade
```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.6"
```
## Python
To install the latest **version** (release):
```console
@@ -105,22 +93,23 @@ pip install lief
To install nightly build:
```console
pip install [--user] --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief==0.14.0.dev0
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.13.2**: https://github.com/lief-project/LIEF/releases/tag/0.13.2
- **v0.17.6**: https://github.com/lief-project/LIEF/releases/tag/0.17.6
Here are guides to install or integrate LIEF:
* [Python](https://lief-project.github.io/doc/latest/installation.html#python)
* [VisualStudio](https://lief-project.github.io/doc/latest/installation.html#visual-studio-integration)
* [XCode](https://lief-project.github.io/doc/latest/installation.html#xcode-integration)
* [CMake](https://lief-project.github.io/doc/latest/installation.html#cmake-integration)
* [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
@@ -131,15 +120,34 @@ import lief
# ELF
binary = lief.parse("/usr/bin/ls")
print(binary)
for section in binary.sections:
print(section.name, section.virtual_address)
# PE
binary = lief.parse("C:\\Windows\\explorer.exe")
print(binary)
if rheader := pe.rich_header:
print(rheader.key)
# Mach-O
binary = lief.parse("/usr/bin/ls")
print(binary)
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++
@@ -150,17 +158,23 @@ print(binary)
int main(int argc, char** argv) {
// ELF
if (std::unique_ptr<const LIEF::ELF::Binary> elf = LIEF::ELF::Parser::parse("/bin/ls")) {
std::cout << *elf << '\n';
for (const LIEF::ELF::Section& section : elf->sections()) {
std::cout << section->name() << ' ' << section->virtual_address() << '\n';
}
}
// PE
if (std::unique_ptr<const LIEF::PE::Binary> pe = LIEF::PE::Parser::parse("C:\\Windows\\explorer.exe")) {
std::cout << *pe << '\n';
if (const LIEF::PE::RichHeader* rheader : pe->rich_header()) {
std::cout << rheader->key() << '\n';
}
}
// Mach-O
if (std::unique_ptr<LIEF::MachO::FatBinary> macho = LIEF::MachO::Parser::parse("/bin/ls")) {
std::cout << *macho << '\n';
for (const LIEF::MachO::DyldChainedFixups& fixup : macho->dyld_chained_fixups()) {
std::cout << fixup << '\n';
}
}
return 0;
@@ -189,10 +203,9 @@ int main(int argc, char** argv) {
## Documentation
* [Main documentation](https://lief-project.github.io/doc/latest/index.html)
* [Tutorial](https://lief-project.github.io/doc/latest/tutorials/index.html)
* [API](https://lief-project.github.io/doc/latest/api/index.html)
* [Doxygen](https://lief-project.github.io/doc/latest/doxygen/index.html)
* [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
@@ -203,11 +216,11 @@ int main(int argc, char** argv) {
### Authors
Romain Thomas ([@rh0main](https://twitter.com/rh0main)) - [Quarkslab](https://www.quarkslab.com)
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.13.0/LICENSE).
LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.17.6/LICENSE).
### Bibtex
+12
View File
@@ -0,0 +1,12 @@
if (LIEF_PYTHON_API)
add_subdirectory(python)
endif()
if(LIEF_C_API)
add_subdirectory(c)
endif()
if(LIEF_RUST_API)
add_subdirectory(rust)
endif()
+9 -26
View File
@@ -1,32 +1,15 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
set(LIEF_C_INCLUDE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/LIEF.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/logging.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/types.h"
)
set(LIEF_C_SRC "${CMAKE_CURRENT_LIST_DIR}/logging.cpp")
if (LIEF_ELF)
include("${CMAKE_CURRENT_LIST_DIR}/ELF/CMakeLists.txt")
if(LIEF_ELF)
add_subdirectory(ELF)
endif()
if (LIEF_PE)
include("${CMAKE_CURRENT_LIST_DIR}/PE/CMakeLists.txt")
if(LIEF_PE)
add_subdirectory(PE)
endif()
if (LIEF_MACHO)
include("${CMAKE_CURRENT_LIST_DIR}/MachO/CMakeLists.txt")
if(LIEF_MACHO)
add_subdirectory(MachO)
endif()
source_group("Header Files\\C API" FILES ${LIEF_C_INCLUDE_FILES})
target_sources(LIB_LIEF PRIVATE "${LIEF_C_SRC}" ${LIEF_C_INCLUDE_FILES})
target_sources(LIB_LIEF PRIVATE logging.cpp)
target_include_directories(LIB_LIEF PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
+8 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -36,7 +36,7 @@ namespace LIEF {
namespace ELF {
void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->handler = reinterpret_cast<void*>(binary);
c_binary->type = static_cast<enum LIEF_ELF_ELF_CLASS>(binary->type());
c_binary->type = static_cast<uint32_t>(binary->type());
c_binary->interpreter = nullptr;
if (binary->has_interpreter()) {
const std::string& interp = binary->interpreter();
@@ -48,15 +48,12 @@ void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
reinterpret_cast<char*>(const_cast<char*>(c_binary->interpreter))[interp.size()] = '\0';
}
init_c_header(c_binary, binary);
init_c_sections(c_binary, binary);
init_c_segments(c_binary, binary);
init_c_dynamic_symbols(c_binary, binary);
init_c_static_symbols(c_binary, binary);
init_c_symtab_symbols(c_binary, binary);
init_c_dynamic_entries(c_binary, binary);
}
}
@@ -81,9 +78,9 @@ Elf_Binary_t* elf_parse(const char *file) {
int elf_binary_save_header(Elf_Binary_t* binary) {
Header& hdr = reinterpret_cast<Binary*>(binary->handler)->header();
hdr.file_type(static_cast<LIEF::ELF::E_TYPE>(binary->header.file_type));
hdr.machine_type(static_cast<LIEF::ELF::ARCH>(binary->header.machine_type));
hdr.object_file_version(static_cast<LIEF::ELF::VERSION>(binary->header.object_file_version));
hdr.file_type(LIEF::ELF::Header::FILE_TYPE(binary->header.file_type));
hdr.machine_type(LIEF::ELF::ARCH(binary->header.machine_type));
hdr.object_file_version(LIEF::ELF::Header::VERSION(binary->header.object_file_version));
hdr.program_headers_offset(binary->header.program_headers_offset);
hdr.section_headers_offset(binary->header.section_headers_offset);
hdr.processor_flag(binary->header.processor_flags);
@@ -104,7 +101,7 @@ void elf_binary_destroy(Elf_Binary_t* binary) {
destroy_sections(binary);
destroy_segments(binary);
destroy_dynamic_symbols(binary);
destroy_static_symbols(binary);
destroy_symtab_symbols(binary);
destroy_dynamic_entries(binary);
if (binary->interpreter != nullptr) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+8 -43
View File
@@ -1,44 +1,9 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
target_sources(LIB_LIEF PRIVATE
Symbol.cpp
Section.cpp
Segment.cpp
DynamicEntry.cpp
Header.cpp
Binary.cpp
utils.cpp
)
set(LIEF_C_ELF_SRC
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/utils.cpp"
)
set(LIEF_API_C_ELF_INCLUDE_FILES_CPP
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Symbol.hpp"
)
set(LIEF_API_C_ELF_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/DynamicEntry.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Header.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Segment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Symbol.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/utils.h"
)
set(LIEF_C_ELF_INC "${LIEF_API_C_ELF_INCLUDE_FILES_C}" "${LIEF_API_C_ELF_INCLUDE_FILES_CPP}")
source_group("Source Files\\C API\\ELF" FILES ${LIEF_API_C_ELF_SRC})
source_group("Header Files\\C API\\ELF" FILES ${LIEF_C_ELF_INC})
target_sources(LIB_LIEF PRIVATE "${LIEF_C_ELF_SRC}" "${LIEF_C_ELF_INC}")
+30 -59
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -34,13 +34,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
for (size_t i = 0; i < dyn_entries.size(); ++i) {
DynamicEntry& entry = dyn_entries[i];
switch(entry.tag()) {
case DYNAMIC_TAGS::DT_NEEDED:
case DynamicEntry::TAG::NEEDED:
{
auto* e = static_cast<Elf_DynamicEntry_Library_t*>(
malloc(sizeof(Elf_DynamicEntry_Library_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
e->name = reinterpret_cast<DynamicEntryLibrary*>(&entry)->name().c_str();
@@ -48,12 +47,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
break;
}
case DYNAMIC_TAGS::DT_SONAME:
case DynamicEntry::TAG::SONAME:
{
auto* e = static_cast<Elf_DynamicEntry_SharedObject_t*>(
malloc(sizeof(Elf_DynamicEntry_SharedObject_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
e->name = reinterpret_cast<DynamicSharedObject*>(&entry)->name().c_str();
@@ -61,42 +60,42 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
break;
}
case DYNAMIC_TAGS::DT_RPATH:
case DynamicEntry::TAG::RPATH:
{
auto* e = static_cast<Elf_DynamicEntry_Rpath_t*>(
malloc(sizeof(Elf_DynamicEntry_Rpath_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
e->rpath = reinterpret_cast<DynamicEntryRpath*>(&entry)->name().c_str();
e->rpath = reinterpret_cast<DynamicEntryRpath*>(&entry)->rpath().c_str();
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
break;
}
case DYNAMIC_TAGS::DT_RUNPATH:
case DynamicEntry::TAG::RUNPATH:
{
auto* e = static_cast<Elf_DynamicEntry_RunPath_t*>(
malloc(sizeof(Elf_DynamicEntry_RunPath_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
e->runpath = reinterpret_cast<DynamicEntryRunPath*>(&entry)->name().c_str();
e->runpath = reinterpret_cast<DynamicEntryRunPath*>(&entry)->runpath().c_str();
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
break;
}
case DYNAMIC_TAGS::DT_INIT_ARRAY:
case DYNAMIC_TAGS::DT_FINI_ARRAY:
case DYNAMIC_TAGS::DT_PREINIT_ARRAY:
case DynamicEntry::TAG::INIT_ARRAY:
case DynamicEntry::TAG::FINI_ARRAY:
case DynamicEntry::TAG::PREINIT_ARRAY:
{
auto* e = static_cast<Elf_DynamicEntry_Array_t*>(
malloc(sizeof(Elf_DynamicEntry_Array_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
const std::vector<uint64_t>& array = reinterpret_cast<DynamicEntryArray*>(&entry)->array();
e->array = static_cast<uint64_t*>(malloc((array.size() + 1) * sizeof(uint64_t)));
@@ -109,55 +108,33 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
break;
}
case DYNAMIC_TAGS::DT_FLAGS:
case DynamicEntry::TAG::FLAGS:
{
auto* e = static_cast<Elf_DynamicEntry_Flags_t*>(
malloc(sizeof(Elf_DynamicEntry_Flags_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
const DynamicEntryFlags::flags_list_t& flags = reinterpret_cast<DynamicEntryFlags*>(&entry)->flags();
e->flags = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS*>(malloc((flags.size() + 1) * sizeof(enum LIEF_ELF_DYNAMIC_FLAGS)));
e->flags_1 = nullptr;
auto it = std::begin(flags);
for (size_t i = 0; it != std::end(flags); ++i, ++it) {
e->flags[i] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS>(*it);
}
e->flags[flags.size()] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS>(0);
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
break;
}
case DYNAMIC_TAGS::DT_FLAGS_1:
case DynamicEntry::TAG::FLAGS_1:
{
auto* e = static_cast<Elf_DynamicEntry_Flags_t*>(
malloc(sizeof(Elf_DynamicEntry_Flags_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->tag = static_cast<uint64_t>(entry.tag());
e->value = entry.value();
const DynamicEntryFlags::flags_list_t& flags = reinterpret_cast<DynamicEntryFlags*>(&entry)->flags();
e->flags_1 = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1*>(malloc((flags.size() + 1) * sizeof(enum LIEF_ELF_DYNAMIC_FLAGS_1)));
e->flags = nullptr;
auto it = std::begin(flags);
for (size_t i = 0; it != std::end(flags); ++i, ++it) {
e->flags_1[i] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1>(*it);
}
e->flags_1[flags.size()] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1>(0);
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
break;
}
default:
{
c_binary->dynamic_entries[i] =
@@ -170,7 +147,6 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
}
c_binary->dynamic_entries[dyn_entries.size()] = nullptr;
}
@@ -179,34 +155,34 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
Elf_DynamicEntry_t **dynamic_entries = c_binary->dynamic_entries;
for (size_t idx = 0; dynamic_entries[idx] != nullptr; ++idx) {
switch(static_cast<DYNAMIC_TAGS>(dynamic_entries[idx]->tag)) {
case DYNAMIC_TAGS::DT_NEEDED:
switch(DynamicEntry::TAG(dynamic_entries[idx]->tag)) {
case DynamicEntry::TAG::NEEDED:
{
free(reinterpret_cast<Elf_DynamicEntry_Library_t*>(dynamic_entries[idx]));
break;
}
case DYNAMIC_TAGS::DT_SONAME:
case DynamicEntry::TAG::SONAME:
{
free(reinterpret_cast<Elf_DynamicEntry_SharedObject_t*>(dynamic_entries[idx]));
break;
}
case DYNAMIC_TAGS::DT_RPATH:
case DynamicEntry::TAG::RPATH:
{
free(reinterpret_cast<Elf_DynamicEntry_Rpath_t*>(dynamic_entries[idx]));
break;
}
case DYNAMIC_TAGS::DT_RUNPATH:
case DynamicEntry::TAG::RUNPATH:
{
free(reinterpret_cast<Elf_DynamicEntry_RunPath_t*>(dynamic_entries[idx]));
break;
}
case DYNAMIC_TAGS::DT_INIT_ARRAY:
case DYNAMIC_TAGS::DT_FINI_ARRAY:
case DYNAMIC_TAGS::DT_PREINIT_ARRAY:
case DynamicEntry::TAG::INIT_ARRAY:
case DynamicEntry::TAG::FINI_ARRAY:
case DynamicEntry::TAG::PREINIT_ARRAY:
{
Elf_DynamicEntry_Array_t* entry_array=reinterpret_cast<Elf_DynamicEntry_Array_t*>(dynamic_entries[idx]);
free(entry_array->array);
@@ -214,24 +190,21 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
break;
}
case DYNAMIC_TAGS::DT_FLAGS:
case DynamicEntry::TAG::FLAGS:
{
Elf_DynamicEntry_Flags_t* entry_flags=reinterpret_cast<Elf_DynamicEntry_Flags_t*>(dynamic_entries[idx]);
free(entry_flags->flags);
free(entry_flags);
break;
}
case DYNAMIC_TAGS::DT_FLAGS_1:
case DynamicEntry::TAG::FLAGS_1:
{
Elf_DynamicEntry_Flags_t* entry_flags=reinterpret_cast<Elf_DynamicEntry_Flags_t*>(dynamic_entries[idx]);
free(entry_flags->flags_1);
free(entry_flags);
break;
}
default:
{
free(dynamic_entries[idx]);
}
@@ -244,5 +217,3 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
-80
View File
@@ -1,80 +0,0 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
*/
#include "LIEF/ELF/EnumToString.h"
#include "LIEF/ELF/EnumToString.hpp"
#include "LIEF/ELF/enums.h"
#include "LIEF/ELF/enums.hpp"
extern "C"
{
const char* E_TYPE_to_string(enum LIEF_ELF_E_TYPE e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::E_TYPE>(e));
}
const char* SYMBOL_BINDINGS_to_string(enum LIEF_ELF_SYMBOL_BINDINGS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SYMBOL_BINDINGS>(e));
}
const char* VERSION_to_string(enum LIEF_ELF_VERSION e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::VERSION>(e));
}
const char* ARCH_to_string(enum LIEF_ELF_ARCH e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ARCH>(e));
}
const char* SEGMENT_TYPES_to_string(enum LIEF_ELF_SEGMENT_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SEGMENT_TYPES>(e));
}
const char* DYNAMIC_TAGS_to_string(enum LIEF_ELF_DYNAMIC_TAGS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_TAGS>(e));
}
const char* ELF_SECTION_TYPES_to_string(enum LIEF_ELF_ELF_SECTION_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SECTION_TYPES>(e));
}
const char* ELF_SECTION_FLAGS_to_string(enum LIEF_ELF_ELF_SECTION_FLAGS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SECTION_FLAGS>(e));
}
const char* ELF_SYMBOL_TYPES_to_string(enum LIEF_ELF_ELF_SYMBOL_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SYMBOL_TYPES>(e));
}
const char* ELF_CLASS_to_string(enum LIEF_ELF_ELF_CLASS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_CLASS>(e));
}
const char* ELF_DATA_to_string(enum LIEF_ELF_ELF_DATA e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_DATA>(e));
}
const char* OS_ABI_to_string(enum LIEF_ELF_OS_ABI e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::OS_ABI>(e));
}
const char* DYNAMIC_FLAGS_to_string(enum LIEF_ELF_DYNAMIC_FLAGS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_FLAGS>(e));
}
const char* DYNAMIC_FLAGS_1_to_string(enum LIEF_ELF_DYNAMIC_FLAGS_1 e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_FLAGS_1>(e));
}
}
+6 -9
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -21,9 +21,9 @@ namespace ELF {
void init_c_header(Elf_Binary_t* c_binary, Binary* binary) {
const Header& hdr = binary->header();
c_binary->header.file_type = static_cast<enum LIEF_ELF_E_TYPE>(hdr.file_type());
c_binary->header.machine_type = static_cast<enum LIEF_ELF_ARCH>(hdr.machine_type());
c_binary->header.object_file_version = static_cast<enum LIEF_ELF_VERSION>(hdr.object_file_version());
c_binary->header.file_type = static_cast<uint32_t>(hdr.file_type());
c_binary->header.machine_type = static_cast<uint32_t>(hdr.machine_type());
c_binary->header.object_file_version = static_cast<uint32_t>(hdr.object_file_version());
c_binary->header.program_headers_offset = hdr.program_headers_offset();
c_binary->header.section_headers_offset = hdr.section_headers_offset();
c_binary->header.processor_flags = hdr.processor_flag();
@@ -35,10 +35,7 @@ void init_c_header(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->header.name_string_table_idx = hdr.section_name_table_idx();
c_binary->header.entrypoint = hdr.entrypoint();
const Header::identity_t& ident = hdr.identity();
std::copy(
std::begin(ident),
std::end(ident),
c_binary->header.identity);
std::copy(std::begin(ident), std::end(ident), c_binary->header.identity);
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -31,7 +31,7 @@ void init_c_sections(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->sections[i]->name = b_section.fullname().c_str();
c_binary->sections[i]->flags = b_section.flags();
c_binary->sections[i]->type = static_cast<enum LIEF_ELF_ELF_SECTION_TYPES>(b_section.type());
c_binary->sections[i]->type = static_cast<uint32_t>(b_section.type());
c_binary->sections[i]->virtual_address = b_section.virtual_address();
c_binary->sections[i]->offset = b_section.file_offset();
c_binary->sections[i]->original_size = b_section.original_size();
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -6
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -29,7 +29,7 @@ void init_c_segments(Elf_Binary_t* c_binary, Binary* binary) {
span<const uint8_t> segment_content = segment.content();
c_binary->segments[i] = static_cast<Elf_Segment_t*>(malloc(sizeof(Elf_Segment_t)));
c_binary->segments[i]->type = static_cast<enum LIEF_ELF_SEGMENT_TYPES>(segment.type());
c_binary->segments[i]->type = static_cast<uint32_t>(segment.type());
c_binary->segments[i]->flags = static_cast<uint32_t>(segment.flags());
c_binary->segments[i]->virtual_address = segment.virtual_address();
c_binary->segments[i]->virtual_size = segment.virtual_size();
@@ -44,10 +44,7 @@ void init_c_segments(Elf_Binary_t* c_binary, Binary* binary) {
}
void destroy_segments(Elf_Binary_t* c_binary) {
Elf_Segment_t **segments = c_binary->segments;
for (size_t idx = 0; segments[idx] != nullptr; ++idx) {
free(segments[idx]);
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+24 -26
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -28,8 +28,8 @@ void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Symbol& b_sym = dyn_symb[i];
c_binary->dynamic_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
c_binary->dynamic_symbols[i]->name = b_sym.name().c_str();
c_binary->dynamic_symbols[i]->type = static_cast<enum LIEF_ELF_ELF_SYMBOL_TYPES>(b_sym.type());
c_binary->dynamic_symbols[i]->binding = static_cast<enum LIEF_ELF_SYMBOL_BINDINGS>(b_sym.binding());
c_binary->dynamic_symbols[i]->type = static_cast<uint32_t>(b_sym.type());
c_binary->dynamic_symbols[i]->binding = static_cast<uint32_t>(b_sym.binding());
c_binary->dynamic_symbols[i]->other = b_sym.other();
c_binary->dynamic_symbols[i]->shndx = b_sym.shndx();
c_binary->dynamic_symbols[i]->value = b_sym.value();
@@ -40,32 +40,30 @@ void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
}
c_binary->dynamic_symbols[dyn_symb.size()] = nullptr;
}
void init_c_static_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_static_symbols static_symb = binary->static_symbols();
void init_c_symtab_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_symtab_symbols static_symb = binary->symtab_symbols();
c_binary->static_symbols = static_cast<Elf_Symbol_t**>(
c_binary->symtab_symbols = static_cast<Elf_Symbol_t**>(
malloc((static_symb.size() + 1) * sizeof(Elf_Symbol_t**)));
for (size_t i = 0; i < static_symb.size(); ++i) {
Symbol& b_sym = static_symb[i];
c_binary->static_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
c_binary->static_symbols[i]->name = b_sym.name().c_str();
c_binary->static_symbols[i]->type = static_cast<enum LIEF_ELF_ELF_SYMBOL_TYPES>(b_sym.type());
c_binary->static_symbols[i]->binding = static_cast<enum LIEF_ELF_SYMBOL_BINDINGS>(b_sym.binding());
c_binary->static_symbols[i]->other = b_sym.other();
c_binary->static_symbols[i]->shndx = b_sym.shndx();
c_binary->static_symbols[i]->value = b_sym.value();
c_binary->static_symbols[i]->size = b_sym.size();
c_binary->static_symbols[i]->information = b_sym.information();
c_binary->static_symbols[i]->is_exported = b_sym.is_exported();
c_binary->static_symbols[i]->is_imported = b_sym.is_imported();
c_binary->symtab_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
c_binary->symtab_symbols[i]->name = b_sym.name().c_str();
c_binary->symtab_symbols[i]->type = static_cast<uint32_t>(b_sym.type());
c_binary->symtab_symbols[i]->binding = static_cast<uint32_t>(b_sym.binding());
c_binary->symtab_symbols[i]->other = b_sym.other();
c_binary->symtab_symbols[i]->shndx = b_sym.shndx();
c_binary->symtab_symbols[i]->value = b_sym.value();
c_binary->symtab_symbols[i]->size = b_sym.size();
c_binary->symtab_symbols[i]->information = b_sym.information();
c_binary->symtab_symbols[i]->is_exported = b_sym.is_exported();
c_binary->symtab_symbols[i]->is_imported = b_sym.is_imported();
}
c_binary->static_symbols[static_symb.size()] = nullptr;
c_binary->symtab_symbols[static_symb.size()] = nullptr;
}
@@ -80,12 +78,12 @@ void destroy_dynamic_symbols(Elf_Binary_t* c_binary) {
}
void destroy_static_symbols(Elf_Binary_t* c_binary) {
Elf_Symbol_t **static_symbols = c_binary->static_symbols;
for (size_t idx = 0; static_symbols[idx] != nullptr; ++idx) {
free(static_symbols[idx]);
void destroy_symtab_symbols(Elf_Binary_t* c_binary) {
Elf_Symbol_t **symtab_symbols = c_binary->symtab_symbols;
for (size_t idx = 0; symtab_symbols[idx] != nullptr; ++idx) {
free(symtab_symbols[idx]);
}
free(c_binary->static_symbols);
free(c_binary->symtab_symbols);
}
}
+4 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -26,10 +26,10 @@ namespace LIEF {
namespace ELF {
void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary);
void init_c_static_symbols(Elf_Binary_t* c_binary, Binary* binary);
void init_c_symtab_symbols(Elf_Binary_t* c_binary, Binary* binary);
void destroy_dynamic_symbols(Elf_Binary_t* c_binary);
void destroy_static_symbols(Elf_Binary_t* c_binary);
void destroy_symtab_symbols(Elf_Binary_t* c_binary);
}
}
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -16,7 +16,7 @@
#include "LIEF/ELF/utils.hpp"
#include "LIEF/ELF/utils.h"
bool is_elf(const char* file) {
uint8_t is_elf(const char* file) {
return LIEF::ELF::is_elf(file);
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+8 -44
View File
@@ -1,45 +1,9 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
target_sources(LIB_LIEF PRIVATE
Parser.cpp
LoadCommand.cpp
Segment.cpp
Symbol.cpp
Section.cpp
Header.cpp
Binary.cpp
)
set(LIEF_API_C_MACHO_SRC
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Parser.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LoadCommand.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
)
set(LIEF_API_C_MACHO_INCLUDE_FILES_CPP
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
"${CMAKE_CURRENT_LIST_DIR}/LoadCommand.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Segment.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Symbol.hpp"
)
set(LIEF_API_C_MACHO_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Header.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/LoadCommand.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Segment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Symbol.h"
)
set(LIEF_C_MACHO_INC "${LIEF_API_C_MACHO_INCLUDE_FILES_C}" "${LIEF_API_C_MACHO_INCLUDE_FILES_CPP}")
source_group("Source Files\\C API\\MachO" FILES ${LIEF_API_C_MACHO_SRC})
source_group("Header Files\\C API\\MachO" FILES ${LIEF_C_MACHO_INC})
target_sources(LIB_LIEF PRIVATE "${LIEF_API_C_MACHO_SRC}" ${LIEF_C_MACHO_INC})
-76
View File
@@ -1,76 +0,0 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
*/
#include "LIEF/MachO/EnumToString.h"
#include "LIEF/MachO/EnumToString.hpp"
#include "LIEF/MachO/enums.hpp"
#include "LIEF/MachO/enums.h"
extern "C"
{
const char* LOAD_COMMAND_TYPES_to_string(enum LIEF_MACHO_LOAD_COMMAND_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::LOAD_COMMAND_TYPES>(e));
}
const char* MACHO_TYPES_to_string(enum LIEF_MACHO_MACHO_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_TYPES>(e));
}
const char* FILE_TYPES_to_string(enum LIEF_MACHO_FILE_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::FILE_TYPES>(e));
}
const char* CPU_TYPES_to_string(enum LIEF_MACHO_CPU_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::CPU_TYPES>(e));
}
const char* HEADER_FLAGS_to_string(enum LIEF_MACHO_HEADER_FLAGS e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::HEADER_FLAGS>(e));
}
const char* MACHO_SECTION_TYPES_to_string(enum LIEF_MACHO_MACHO_SECTION_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_SECTION_TYPES>(e));
}
const char* MACHO_SYMBOL_TYPES_to_string(enum LIEF_MACHO_MACHO_SYMBOL_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_SYMBOL_TYPES>(e));
}
const char* N_LIST_TYPES_to_string(enum LIEF_MACHO_N_LIST_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::N_LIST_TYPES>(e));
}
const char* SYMBOL_DESCRIPTIONS_to_string(enum LIEF_MACHO_SYMBOL_DESCRIPTIONS e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::SYMBOL_DESCRIPTIONS>(e));
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -27,7 +27,7 @@ void init_c_commands(Macho_Binary_t* c_binary, Binary* binary) {
LoadCommand& cmd = commands[i];
c_binary->commands[i] = static_cast<Macho_Command_t*>(malloc(sizeof(Macho_Command_t)));
const std::vector<uint8_t>& cmd_content = cmd.data();
const span<const uint8_t> cmd_content = cmd.data();
auto* content = static_cast<uint8_t*>(malloc(cmd_content.size() * sizeof(uint8_t)));
std::copy(
std::begin(cmd_content),
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -36,7 +36,7 @@ void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
c_binary->sections[i]->alignment = section.alignment();
c_binary->sections[i]->relocation_offset = section.relocation_offset();
c_binary->sections[i]->numberof_relocations = section.numberof_relocations();
c_binary->sections[i]->flags = section.flags();
c_binary->sections[i]->flags = section.raw_flags();
c_binary->sections[i]->type = static_cast<enum LIEF_MACHO_MACHO_SECTION_TYPES>(section.type());
c_binary->sections[i]->reserved1 = section.reserved1();
c_binary->sections[i]->reserved2 = section.reserved2();
@@ -53,7 +53,6 @@ void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
}
void destroy_sections(Macho_Binary_t* c_binary) {
Macho_Section_t **sections = c_binary->sections;
for (size_t idx = 0; sections[idx] != nullptr; ++idx) {
@@ -67,4 +66,3 @@ void destroy_sections(Macho_Binary_t* c_binary) {
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -29,7 +29,7 @@ void init_c_symbols(Macho_Binary_t* c_binary, Binary* binary) {
c_binary->symbols[i] = static_cast<Macho_Symbol_t*>(malloc(sizeof(Macho_Symbol_t)));
c_binary->symbols[i]->name = symbol.name().c_str();
c_binary->symbols[i]->type = symbol.type();
c_binary->symbols[i]->type = symbol.raw_type();
c_binary->symbols[i]->numberof_sections = symbol.numberof_sections();
c_binary->symbols[i]->description = symbol.description();
c_binary->symbols[i]->value = symbol.value();
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+9 -47
View File
@@ -1,48 +1,10 @@
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
target_sources(LIB_LIEF PRIVATE
Binary.cpp
DosHeader.cpp
Header.cpp
OptionalHeader.cpp
Section.cpp
DataDirectory.cpp
Import.cpp
ImportEntry.cpp
)
set(LIEF_API_C_PE_SRC
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
"${CMAKE_CURRENT_LIST_DIR}/DosHeader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/OptionalHeader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
"${CMAKE_CURRENT_LIST_DIR}/DataDirectory.cpp"
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Import.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ImportEntry.cpp"
)
set(LIEF_API_C_PE_INCLUDE_FILES_CPP
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DataDirectory.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DosHeader.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
"${CMAKE_CURRENT_LIST_DIR}/OptionalHeader.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Import.hpp"
"${CMAKE_CURRENT_LIST_DIR}/ImportEntry.hpp"
)
set(LIEF_API_C_PE_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/DataDirectory.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/DosHeader.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Header.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/OptionalHeader.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Import.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/ImportEntry.h"
)
set(LIEF_C_PE_INC "${LIEF_API_C_PE_INCLUDE_FILES_C}" "${LIEF_API_C_PE_INCLUDE_FILES_CPP}")
source_group("Source Files\\C API\\PE" FILES ${LIEF_API_C_PE_SRC})
source_group("Header Files\\C API\\PE" FILES ${LIEF_C_PE_INC})
target_sources(LIB_LIEF PRIVATE "${LIEF_API_C_PE_SRC}" "${LIEF_C_PE_INC}")
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+4 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LIEF_PE_DATA_DIRECTORY_CPP_C_API_
#define LIEF_PE_DATA_DIRECTORY_CPP_C_API_
#ifndef LIEF_PE_DATA_DIRECTORY_CPP_C_API
#define LIEF_PE_DATA_DIRECTORY_CPP_C_API
#include "LIEF/PE/Binary.h"
#include "LIEF/PE/Binary.hpp"
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -20,7 +20,7 @@ namespace PE {
void init_c_dos_header(Pe_Binary_t* c_binary, Binary* binary) {
const DosHeader& dos_header = binary->dos_header();
c_binary->dos_header.magic = dos_header.magic();
c_binary->dos_header.used_bytes_in_the_last_page = dos_header.used_bytes_in_the_last_page();
c_binary->dos_header.used_bytes_in_last_page = dos_header.used_bytes_in_last_page();
c_binary->dos_header.file_size_in_pages = dos_header.file_size_in_pages();
c_binary->dos_header.numberof_relocation = dos_header.numberof_relocation();
c_binary->dos_header.header_size_in_paragraphs = dos_header.header_size_in_paragraphs();
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -14
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -20,21 +20,10 @@
#include "LIEF/PE/enums.h"
extern "C"
{
extern "C" {
const char* PE_TYPES_to_string(enum LIEF_PE_PE_TYPES e) {
return LIEF::PE::to_string(static_cast<LIEF::PE::PE_TYPE>(e));
}
const char* MACHINE_TYPES_to_string(enum LIEF_PE_MACHINE_TYPES e) {
return LIEF::PE::to_string(static_cast<LIEF::PE::MACHINE_TYPES>(e));
}
const char* SUBSYSTEM_to_string(enum LIEF_PE_SUBSYSTEM e) {
return LIEF::PE::to_string(static_cast<LIEF::PE::SUBSYSTEM>(e));
}
}
+13 -6
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -32,11 +32,18 @@ void init_c_header(Pe_Binary_t* c_binary, Binary* binary) {
c_binary->header.sizeof_optional_header = header.sizeof_optional_header();
c_binary->header.characteristics = static_cast<uint16_t>(header.characteristics());
std::copy(
std::begin(signature),
std::end(signature),
c_binary->header.signature);
std::copy(std::begin(signature), std::end(signature),
c_binary->header.signature);
}
}
}
const char* lief_pe_header_machine_str(enum LIEF_PE_MACHINE_TYPES e) {
return LIEF::PE::to_string(static_cast<LIEF::PE::Header::MACHINE_TYPES>(e));
}
const char* lief_pe_header_characteristics_str(enum LIEF_PE_HEADER_CHARACTERISTICS e) {
return LIEF::PE::to_string(static_cast<LIEF::PE::Header::CHARACTERISTICS>(e));
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+9 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "OptionalHeader.hpp"
#include "LIEF/PE/OptionalHeader.h"
namespace LIEF {
namespace PE {
@@ -21,7 +22,7 @@ namespace PE {
void init_c_optional_header(Pe_Binary_t* c_binary, Binary* binary) {
const OptionalHeader& optional_header = binary->optional_header();
c_binary->optional_header.magic = static_cast<enum LIEF_PE_PE_TYPES>(optional_header.magic());
c_binary->optional_header.magic = static_cast<uint16_t>(optional_header.magic());
c_binary->optional_header.major_linker_version = optional_header.major_linker_version();
c_binary->optional_header.minor_linker_version = optional_header.minor_linker_version();
c_binary->optional_header.sizeof_code = optional_header.sizeof_code();
@@ -59,3 +60,8 @@ void init_c_optional_header(Pe_Binary_t* c_binary, Binary* binary) {
}
}
const char* lief_pe_subsytem_str(enum LIEF_PE_SUBSYSTEM e) {
return LIEF::PE::to_string(static_cast<LIEF::PE::OptionalHeader::SUBSYSTEM>(e));
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+3 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -16,13 +16,11 @@
#ifndef C_LIEF_ELF_H_
#define C_LIEF_ELF_H_
/** @defgroup elf_c_api ELF C API */
#include "LIEF/ELF/Binary.h"
#include "LIEF/ELF/Symbol.h"
#include "LIEF/ELF/Section.h"
#include "LIEF/ELF/Header.h"
#include "LIEF/ELF/DynamicEntry.h"
#include "LIEF/ELF/EnumToString.h"
#include "LIEF/ELF/utils.h"
#endif
+9 -26
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,16 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_BINARY_H_
#define C_LIEF_ELF_BINARY_H_
/** @defgroup elf_binary_c_api Binary
* @ingroup elf_c_api
* @addtogroup elf_binary_c_api
* @brief Binary C API
*
* @{
*/
#ifndef LIEF_C_ELF_BINARY_H
#define LIEF_C_ELF_BINARY_H
#include <stddef.h>
@@ -40,40 +32,31 @@
extern "C" {
#endif
/** @brief LIEF::ELF::Binary C Handler */
/** LIEF::ELF::Binary C Handler */
struct Elf_Binary_t {
void* handler;
const char* name;
const char* interpreter;
enum LIEF_ELF_ELF_CLASS type;
uint32_t type;
Elf_Header_t header;
Elf_Section_t **sections;
Elf_Segment_t **segments;
Elf_DynamicEntry_t **dynamic_entries;
Elf_Symbol_t **dynamic_symbols;
Elf_Symbol_t **static_symbols;
Elf_Symbol_t **symtab_symbols;
};
typedef struct Elf_Binary_t Elf_Binary_t;
/** @brief Wrapper for LIEF::ELF::Parser::parse */
/** Wrapper for LIEF::ELF::Parser::parse */
LIEF_API Elf_Binary_t* elf_parse(const char *file);
LIEF_API void elf_binary_destroy(Elf_Binary_t* binary);
/* ELF::Binary methods
* ==================
*/
/** @brief Update LIEF::ELF::Header object */
/** Update LIEF::ELF::Header object */
LIEF_API int elf_binary_save_header(Elf_Binary_t* binary);
#ifdef __cplusplus
}
#endif
/** @} */
#endif
+4 -19
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,22 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_DYNAMIC_ENTRY_H_
#define C_LIEF_ELF_DYNAMIC_ENTRY_H_
#ifndef LIEF_C_ELF_DYNAMIC_ENTRY_H
#define LIEF_C_ELF_DYNAMIC_ENTRY_H
#include <stdint.h>
#include "LIEF/ELF/enums.h"
/** @defgroup elf_dynamic_entry_c_api Dynamic Entry
* @ingroup elf_c_api
* @addtogroup elf_dynamic_entry_c_api
* @brief Dynamic Entry C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,12 +57,9 @@ struct Elf_DynamicEntry_RunPath_t {
const char* runpath;
};
struct Elf_DynamicEntry_Flags_t {
uint64_t tag;
uint64_t value;
enum LIEF_ELF_DYNAMIC_FLAGS *flags;
enum LIEF_ELF_DYNAMIC_FLAGS_1 *flags_1;
};
typedef struct Elf_DynamicEntry_t Elf_DynamicEntry_t;
@@ -88,5 +74,4 @@ typedef struct Elf_DynamicEntry_Flags_t Elf_DynamicEntry_Flags_t;
}
#endif
/** @} */
#endif
-47
View File
@@ -1,47 +0,0 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 C_LIEF_ELF_ENUM_TO_STRING_H_
#define C_LIEF_ELF_ENUM_TO_STRING_H_
#include "LIEF/visibility.h"
#include "LIEF/ELF/enums.h"
#ifdef __cplusplus
extern "C" {
#endif
LIEF_API const char* SYMBOL_BINDINGS_to_string(enum LIEF_ELF_SYMBOL_BINDINGS e);
LIEF_API const char* E_TYPE_to_string(enum LIEF_ELF_E_TYPE e);
LIEF_API const char* VERSION_to_string(enum LIEF_ELF_VERSION e);
LIEF_API const char* ARCH_to_string(enum LIEF_ELF_ARCH e);
LIEF_API const char* SEGMENT_TYPES_to_string(enum LIEF_ELF_SEGMENT_TYPES e);
LIEF_API const char* DYNAMIC_TAGS_to_string(enum LIEF_ELF_DYNAMIC_TAGS e);
LIEF_API const char* ELF_SECTION_TYPES_to_string(enum LIEF_ELF_ELF_SECTION_TYPES e);
LIEF_API const char* ELF_SECTION_FLAGS_to_string(enum LIEF_ELF_ELF_SECTION_FLAGS e);
LIEF_API const char* ELF_SYMBOL_TYPES_to_string(enum LIEF_ELF_ELF_SYMBOL_TYPES e);
LIEF_API const char* ELF_CLASS_to_string(enum LIEF_ELF_ELF_CLASS e);
LIEF_API const char* ELF_DATA_to_string(enum LIEF_ELF_ELF_DATA e);
LIEF_API const char* OS_ABI_to_string(enum LIEF_ELF_OS_ABI e);
LIEF_API const char* DYNAMIC_FLAGS_to_string(enum LIEF_ELF_DYNAMIC_FLAGS e);
LIEF_API const char* DYNAMIC_FLAGS_1_to_string(enum LIEF_ELF_DYNAMIC_FLAGS_1 e);
#ifdef __cplusplus
}
#endif
#endif
+18 -26
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,38 +13,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_HEADER_H_
#define C_LIEF_ELF_HEADER_H_
#ifndef LIEF_C_ELF_HEADER_H
#define LIEF_C_ELF_HEADER_H
#include <inttypes.h>
#include "LIEF/ELF/enums.h"
/** @defgroup elf_header_c_api Header
* @ingroup elf_c_api
* @addtogroup elf_header_c_api
* @brief Header C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Elf_Header_t {
uint8_t identity[LIEF_ELF_EI_NIDENT];
enum LIEF_ELF_E_TYPE file_type;
enum LIEF_ELF_ARCH machine_type;
enum LIEF_ELF_VERSION object_file_version;
uint64_t entrypoint;
uint64_t program_headers_offset;
uint64_t section_headers_offset;
uint32_t processor_flags;
uint32_t header_size;
uint32_t program_header_size;
uint32_t numberof_segments;
uint32_t section_header_size;
uint32_t numberof_sections;
uint32_t name_string_table_idx;
uint8_t identity[LIEF_EI_NIDENT];
uint32_t file_type;
uint32_t machine_type;
uint32_t object_file_version;
uint64_t entrypoint;
uint64_t program_headers_offset;
uint64_t section_headers_offset;
uint32_t processor_flags;
uint32_t header_size;
uint32_t program_header_size;
uint32_t numberof_segments;
uint32_t section_header_size;
uint32_t numberof_sections;
uint32_t name_string_table_idx;
};
typedef struct Elf_Header_t Elf_Header_t;
@@ -54,5 +47,4 @@ typedef struct Elf_Header_t Elf_Header_t;
}
#endif
/** @} */
#endif
+17 -28
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,39 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_SECTION_H_
#define C_LIEF_ELF_SECTION_H_
#ifndef LIEF_C_ELF_SECTION_H
#define LIEF_C_ELF_SECTION_H
#include <stdint.h>
#include "LIEF/ELF/enums.h"
/** @defgroup elf_section_c_api Section
* @ingroup elf_c_api
* @addtogroup elf_section_c_api
* @brief Section C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Elf_Section_t {
const char* name;
uint32_t flags;
enum LIEF_ELF_ELF_SECTION_TYPES type;
uint64_t virtual_address;
uint64_t offset;
uint64_t original_size;
uint32_t link;
uint32_t info;
uint64_t alignment;
uint64_t entry_size;
uint64_t size;
uint8_t* content;
double entropy;
const char* name;
uint32_t flags;
uint32_t type;
uint64_t virtual_address;
uint64_t offset;
uint64_t original_size;
uint32_t link;
uint32_t info;
uint64_t alignment;
uint64_t entry_size;
uint64_t size;
uint8_t* content;
double entropy;
};
typedef struct Elf_Section_t Elf_Section_t;
@@ -54,5 +44,4 @@ typedef struct Elf_Section_t Elf_Section_t;
}
#endif
/** @} */
#endif
+12 -21
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,33 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_SEGMENT_H_
#define C_LIEF_ELF_SEGMENT_H_
#ifndef LIEF_C_ELF_SEGMENT_H_
#define LIEF_C_ELF_SEGMENT_H_
#include <stdint.h>
#include "LIEF/ELF/enums.h"
/** @defgroup elf_segment_c_api Segment
* @ingroup elf_c_api
* @addtogroup elf_segment_c_api
* @brief Segment C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Elf_Segment_t {
enum LIEF_ELF_SEGMENT_TYPES type;
uint32_t flags;
uint64_t virtual_address;
uint64_t virtual_size;
uint64_t offset;
uint64_t alignment;
uint64_t size;
uint8_t* content;
uint32_t type;
uint32_t flags;
uint64_t virtual_address;
uint64_t virtual_size;
uint64_t offset;
uint64_t alignment;
uint64_t size;
uint8_t* content;
};
typedef struct Elf_Segment_t Elf_Segment_t;
@@ -48,5 +40,4 @@ typedef struct Elf_Segment_t Elf_Segment_t;
}
#endif
/** @} */
#endif
+14 -24
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,36 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_SYMBOL_H_
#define C_LIEF_ELF_SYMBOL_H_
#ifndef LIEF_C_ELF_SYMBOL_H
#define LIEF_C_ELF_SYMBOL_H
#include <stdint.h>
#include "LIEF/ELF/enums.h"
#include "LIEF/types.h"
/** @defgroup elf_symbol_c_api Symbol
* @ingroup elf_c_api
* @addtogroup elf_symbol_c_api
* @brief Symbol C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Elf_Symbol_t {
const char* name;
enum LIEF_ELF_ELF_SYMBOL_TYPES type;
enum LIEF_ELF_SYMBOL_BINDINGS binding;
uint8_t information;
uint8_t other;
uint16_t shndx;
uint64_t value;
uint64_t size;
bool is_exported; /**< Whether or not the symbol is exported */
bool is_imported; /**< Whether or not the symbol is imported */
const char* name;
uint32_t type;
uint32_t binding;
uint8_t information;
uint8_t other;
uint16_t shndx;
uint64_t value;
uint64_t size;
uint8_t is_exported; /**< Whether or not the symbol is exported */
uint8_t is_imported; /**< Whether or not the symbol is imported */
};
typedef struct Elf_Symbol_t Elf_Symbol_t;
@@ -51,5 +42,4 @@ typedef struct Elf_Symbol_t Elf_Symbol_t;
}
#endif
/** @} */
#endif
File diff suppressed because it is too large Load Diff
+6 -14
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,18 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_ELF_UTILS_H_
#define C_LIEF_ELF_UTILS_H_
/** @defgroup elf_utils_c_api Utils
* @ingroup elf_c_api
* @addtogroup elf_utils_c_api
* @brief Utils C API
*
* @{
*/
#ifndef LIEF_C_ELF_UTILS_H
#define LIEF_C_ELF_UTILS_H
#include <stddef.h>
#include <stdint.h>
#include "LIEF/visibility.h"
#include "LIEF/types.h"
@@ -35,12 +28,11 @@ extern "C" {
#endif
/** @brief Check if the given file is an ELF one. */
LIEF_API bool is_elf(const char* file);
LIEF_API uint8_t is_elf(const char* file);
#ifdef __cplusplus
}
#endif
/** @} */
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
+2 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -16,13 +16,10 @@
#ifndef C_LIEF_MACHO_H_
#define C_LIEF_MACHO_H_
/** @defgroup macho_c_api MachO C API */
#include "LIEF/MachO/Binary.h"
#include "LIEF/MachO/Symbol.h"
#include "LIEF/MachO/Segment.h"
#include "LIEF/MachO/Section.h"
#include "LIEF/MachO/LoadCommand.h"
#include "LIEF/MachO/Header.h"
#include "LIEF/MachO/EnumToString.h"
#endif
+2 -12
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -16,14 +16,6 @@
#ifndef C_LIEF_MACHO_BINARY_H_
#define C_LIEF_MACHO_BINARY_H_
/** @defgroup macho_binary_c_api Binary
* @ingroup macho_c_api
* @addtogroup macho_binary_c_api
* @brief Binary C API
*
* @{
*/
#include <stdint.h>
#include "LIEF/visibility.h"
@@ -41,7 +33,6 @@ extern "C" {
/** @brief LIEF::MachO::Binary C Handler */
struct Macho_Binary_t {
void* handler;
const char* name;
uint64_t imagebase;
Macho_Header_t header;
Macho_Command_t** commands;
@@ -63,5 +54,4 @@ LIEF_API void macho_binaries_destroy(Macho_Binary_t** binaries);
#endif
/** @} */
#endif
-41
View File
@@ -1,41 +0,0 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 C_LIEF_MACHO_ENUM_TO_STRING_H_
#define C_LIEF_MACHO_ENUM_TO_STRING_H_
#include "LIEF/visibility.h"
#include "LIEF/MachO/enums.h"
#ifdef __cplusplus
extern "C" {
#endif
LIEF_API const char* LOAD_COMMAND_TYPES_to_string(enum LIEF_MACHO_LOAD_COMMAND_TYPES e);
LIEF_API const char* MACHO_TYPES_to_string(enum LIEF_MACHO_MACHO_TYPES e);
LIEF_API const char* FILE_TYPES_to_string(enum LIEF_MACHO_FILE_TYPES e);
LIEF_API const char* CPU_TYPES_to_string(enum LIEF_MACHO_CPU_TYPES e);
LIEF_API const char* HEADER_FLAGS_to_string(enum LIEF_MACHO_HEADER_FLAGS e);
LIEF_API const char* MACHO_SECTION_TYPES_to_string(enum LIEF_MACHO_MACHO_SECTION_TYPES e);
LIEF_API const char* MACHO_SYMBOL_TYPES_to_string(enum LIEF_MACHO_MACHO_SYMBOL_TYPES e);
LIEF_API const char* N_LIST_TYPES_to_string(enum LIEF_MACHO_N_LIST_TYPES e);
LIEF_API const char* SYMBOL_DESCRIPTIONS_to_string(enum LIEF_MACHO_SYMBOL_DESCRIPTIONS e);
#ifdef __cplusplus
}
#endif
#endif
+2 -10
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -18,13 +18,6 @@
#include <inttypes.h>
#include "LIEF/MachO/enums.h"
/** @defgroup macho_header_c_api Header
* @ingroup macho_c_api
* @addtogroup macho_header_c_api
* @brief Header C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
@@ -48,5 +41,4 @@ typedef struct Macho_Header_t Macho_Header_t;
}
#endif
/** @} */
#endif
+2 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -18,14 +18,6 @@
#include <inttypes.h>
#include "LIEF/MachO/enums.h"
/** @defgroup macho_load_command_c_api Header
* @ingroup macho_c_api
* @addtogroup macho_load_command_c_api
* @brief Load Command C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,5 +36,4 @@ typedef struct Macho_Command_t Macho_Command_t;
}
#endif
/** @} */
#endif
+2 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -18,14 +18,6 @@
#include <inttypes.h>
#include "LIEF/MachO/enums.h"
/** @defgroup macho_section_c_api Header
* @ingroup macho_c_api
* @addtogroup macho_section_c_api
* @brief Section C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
@@ -55,5 +47,4 @@ typedef struct Macho_Section_t Macho_Section_t;
}
#endif
/** @} */
#endif
+3 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -18,14 +18,7 @@
#include <inttypes.h>
#include "LIEF/MachO/enums.h"
/** @defgroup macho_segment_c_api Header
* @ingroup macho_c_api
* @addtogroup macho_segment_c_api
* @brief Segment C API
*
* @{
*/
#include "LIEF/MachO/Section.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -52,5 +45,4 @@ typedef struct Macho_Segment_t Macho_Segment_t;
}
#endif
/** @} */
#endif
+2 -10
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -18,13 +18,6 @@
#include <inttypes.h>
#include "LIEF/MachO/enums.h"
/** @defgroup macho_symbol_c_api Header
* @ingroup macho_c_api
* @addtogroup macho_symbol_c_api
* @brief Symbol C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
@@ -45,5 +38,4 @@ typedef struct Macho_Symbol_t Macho_Symbol_t;
}
#endif
/** @} */
#endif
-1
View File
@@ -1,6 +1,5 @@
#ifndef LIEF_MACHO_C_ENUMS_H_
#define LIEF_MACHO_C_ENUMS_H_
#include "LIEF/MachO/undef.h"
#ifdef __cplusplus
extern "C" {
+2 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -16,8 +16,5 @@
#ifndef C_LIEF_PE_H_
#define C_LIEF_PE_H_
/** @defgroup pe_c_api PE C API */
#include "LIEF/PE/Binary.h"
#include "LIEF/PE/EnumToString.h"
#endif
+2 -13
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -16,14 +16,6 @@
#ifndef C_LIEF_PE_BINARY_H_
#define C_LIEF_PE_BINARY_H_
/** @defgroup pe_binary_c_api Binary
* @ingroup pe_c_api
* @addtogroup pe_binary_c_api
* @brief Binary C API
*
* @{
*/
#include <stddef.h>
#include "LIEF/visibility.h"
@@ -44,7 +36,6 @@ extern "C" {
/** @brief LIEF::PE::Binary C Handler */
struct Pe_Binary_t {
void* handler;
const char* name;
Pe_DosHeader_t dos_header;
Pe_Header_t header;
Pe_OptionalHeader_t optional_header;
@@ -64,6 +55,4 @@ LIEF_API void pe_binary_destroy(Pe_Binary_t* binary);
}
#endif
/** @} */
#endif
+27 -13
View File
@@ -1,7 +1,7 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* Copyright 2017 - 2025 R. Thomas
* Copyright 2017 - 2025 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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
*
@@ -13,24 +13,39 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_PE_DATA_DIRECTORY_H_
#define C_LIEF_PE_DATA_DIRECTORY_H_
#ifndef C_LIEF_PE_DATA_DIRECTORY_H
#define C_LIEF_PE_DATA_DIRECTORY_H
#include <inttypes.h>
#include "LIEF/PE/enums.h"
/** @defgroup pe_data_directory_c_api Section
* @ingroup pe_c_api
* @addtogroup pe_data_directory_c_api
* @brief Data directory C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
enum LIEF_PE_DATA_DIRECTORY {
LIEF_PE_DATA_DIR_EXPORT_TABLE = 0,
LIEF_PE_DATA_DIR_IMPORT_TABLE,
LIEF_PE_DATA_DIR_RESOURCE_TABLE,
LIEF_PE_DATA_DIR_EXCEPTION_TABLE,
LIEF_PE_DATA_DIR_CERTIFICATE_TABLE,
LIEF_PE_DATA_DIR_BASE_RELOCATION_TABLE,
LIEF_PE_DATA_DIR_DEBUG,
LIEF_PE_DATA_DIR_ARCHITECTURE,
LIEF_PE_DATA_DIR_GLOBAL_PTR,
LIEF_PE_DATA_DIR_TLS_TABLE,
LIEF_PE_DATA_DIR_LOAD_CONFIG_TABLE,
LIEF_PE_DATA_DIR_BOUND_IMPORT,
LIEF_PE_DATA_DIR_IAT,
LIEF_PE_DATA_DIR_DELAY_IMPORT_DESCRIPTOR,
LIEF_PE_DATA_DIR_CLR_RUNTIME_HEADER,
LIEF_PE_DATA_DIR_RESERVED,
LIEF_PE_DATA_DIR_NONE,
};
struct Pe_DataDirectory_t {
uint32_t rva;
uint32_t size;
@@ -43,5 +58,4 @@ typedef struct Pe_DataDirectory_t Pe_DataDirectory_t;
}
#endif
/** @} */
#endif
+3 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -18,13 +18,6 @@
#include <inttypes.h>
#include "LIEF/ELF/enums.h"
/** @defgroup pe_dos_header_c_api DosHeader
* @ingroup pe_c_api
* @addtogroup pe_dos_header_c_api
* @brief Dos Header C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
@@ -32,7 +25,7 @@ extern "C" {
struct Pe_DosHeader_t {
uint16_t magic ;
uint16_t used_bytes_in_the_last_page;
uint16_t used_bytes_in_last_page;
uint16_t file_size_in_pages;
uint16_t numberof_relocation;
uint16_t header_size_in_paragraphs;
@@ -59,5 +52,4 @@ typedef struct Pe_DosHeader_t Pe_DosHeader_t;
}
#endif
/** @} */
#endif
+2 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -24,10 +24,7 @@
extern "C" {
#endif
LIEF_API const char* PE_TYPES_to_string(enum LIEF_PE_PE_TYPES e);
LIEF_API const char* MACHINE_TYPES_to_string(enum LIEF_PE_MACHINE_TYPES e);
LIEF_API const char* SUBSYSTEM_to_string(enum LIEF_PE_SUBSYSTEM e);
#ifdef __cplusplus
}
+55 -13
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,24 +13,65 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_PE_HEADER_H_
#define C_LIEF_PE_HEADER_H_
#ifndef C_LIEF_PE_HEADER_H
#define C_LIEF_PE_HEADER_H
#include <inttypes.h>
#include "LIEF/PE/enums.h"
/** @defgroup pe_header_c_api Header
* @ingroup pe_c_api
* @addtogroup pe_header_c_api
* @brief Header C API
*
* @{
*/
#include "LIEF/visibility.h"
#ifdef __cplusplus
extern "C" {
#endif
enum LIEF_PE_MACHINE_TYPES {
LIEF_PE_MACHINE_UNKNOWN = 0x0,
LIEF_PE_MACHINE_AM33 = 0x1D3, /**< Matsushita AM33 */
LIEF_PE_MACHINE_AMD64 = 0x8664, /**< AMD x64 */
LIEF_PE_MACHINE_ARM = 0x1C0, /**< ARM little endian */
LIEF_PE_MACHINE_ARMNT = 0x1C4, /**< ARMv7 Thumb mode only */
LIEF_PE_MACHINE_ARM64 = 0xAA64, /**< ARMv8 in 64-bits mode */
LIEF_PE_MACHINE_EBC = 0xEBC, /**< EFI byte code */
LIEF_PE_MACHINE_I386 = 0x14C, /**< Intel 386 or later */
LIEF_PE_MACHINE_IA64 = 0x200, /**< Intel Itanium processor family */
LIEF_PE_MACHINE_M32R = 0x9041, /**< Mitsubishi M32R little endian */
LIEF_PE_MACHINE_MIPS16 = 0x266, /**< MIPS16 */
LIEF_PE_MACHINE_MIPSFPU = 0x366, /**< MIPS with FPU */
LIEF_PE_MACHINE_MIPSFPU16 = 0x466, /**< MIPS16 with FPU */
LIEF_PE_MACHINE_POWERPC = 0x1F0, /**< Power PC little endian */
LIEF_PE_MACHINE_POWERPCFP = 0x1F1, /**< Power PC with floating point */
LIEF_PE_MACHINE_POWERPCBE = 0x1F2, /**< Power PC big endian */
LIEF_PE_MACHINE_R4000 = 0x166, /**< MIPS with little endian */
LIEF_PE_MACHINE_RISCV32 = 0x5032, /**< RISC-V 32-bit address space */
LIEF_PE_MACHINE_RISCV64 = 0x5064, /**< RISC-V 64-bit address space */
LIEF_PE_MACHINE_RISCV128 = 0x5128, /**< RISC-V 128-bit address space */
LIEF_PE_MACHINE_SH3 = 0x1A2, /**< Hitachi SH3 */
LIEF_PE_MACHINE_SH3DSP = 0x1A3, /**< Hitachi SH3 DSP */
LIEF_PE_MACHINE_SH4 = 0x1A6, /**< Hitachi SH4 */
LIEF_PE_MACHINE_SH5 = 0x1A8, /**< Hitachi SH5 */
LIEF_PE_MACHINE_THUMB = 0x1C2, /**< ARM or Thumb */
LIEF_PE_MACHINE_WCEMIPSV2 = 0x169 /**< MIPS little-endian WCE v2 */
};
enum LIEF_PE_HEADER_CHARACTERISTICS {
LIEF_PE_HEADER_CHARACTERISTICS_INVALID = 0x0000,
LIEF_PE_HEADER_CHARACTERISTICS_RELOCS_STRIPPED = 0x0001, /**< The file does not contain base relocations and must be loaded at its preferred base. If this cannot be done, the loader will error.*/
LIEF_PE_HEADER_CHARACTERISTICS_EXECUTABLE_IMAGE = 0x0002, /**< The file is valid and can be run.*/
LIEF_PE_HEADER_CHARACTERISTICS_LINE_NUMS_STRIPPED = 0x0004, /**< COFF line numbers have been stripped. This is deprecated and should be 0*/
LIEF_PE_HEADER_CHARACTERISTICS_LOCAL_SYMS_STRIPPED = 0x0008, /**< COFF symbol table entries for local symbols have been removed. This is deprecated and should be 0.*/
LIEF_PE_HEADER_CHARACTERISTICS_AGGRESSIVE_WS_TRIM = 0x0010, /**< Aggressively trim working set. This is deprecated and must be 0.*/
LIEF_PE_HEADER_CHARACTERISTICS_LARGE_ADDRESS_AWARE = 0x0020, /**< Image can handle > 2GiB addresses. */
LIEF_PE_HEADER_CHARACTERISTICS_BYTES_REVERSED_LO = 0x0080, /**< Little endian: the LSB precedes the MSB in memory. This is deprecated and should be 0.*/
LIEF_PE_HEADER_CHARACTERISTICS_32BIT_MACHINE = 0x0100, /**< Machine is based on a 32bit word architecture. */
LIEF_PE_HEADER_CHARACTERISTICS_DEBUG_STRIPPED = 0x0200, /**< Debugging info has been removed. */
LIEF_PE_HEADER_CHARACTERISTICS_REMOVABLE_RUN_FROM_SWAP = 0x0400, /**< If the image is on removable media, fully load it and copy it to swap. */
LIEF_PE_HEADER_CHARACTERISTICS_NET_RUN_FROM_SWAP = 0x0800, /**< If the image is on network media, fully load it and copy it to swap. */
LIEF_PE_HEADER_CHARACTERISTICS_SYSTEM = 0x1000, /**< The image file is a system file, not a user program.*/
LIEF_PE_HEADER_CHARACTERISTICS_DLL = 0x2000, /**< The image file is a DLL. */
LIEF_PE_HEADER_CHARACTERISTICS_UP_SYSTEM_ONLY = 0x4000, /**< This file should only be run on a uniprocessor machine. */
LIEF_PE_HEADER_CHARACTERISTICS_BYTES_REVERSED_HI = 0x8000 /**< Big endian: the MSB precedes the LSB in memory. This is deprecated */
};
struct Pe_Header_t {
uint8_t signature[4];
enum LIEF_PE_MACHINE_TYPES machine;
@@ -44,10 +85,11 @@ struct Pe_Header_t {
typedef struct Pe_Header_t Pe_Header_t;
LIEF_API const char* lief_pe_header_machine_str(enum LIEF_PE_MACHINE_TYPES e);
LIEF_API const char* lief_pe_header_characteristics_str(enum LIEF_PE_HEADER_CHARACTERISTICS e);
#ifdef __cplusplus
}
#endif
/** @} */
#endif
+2 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -21,14 +21,6 @@
#include "LIEF/PE/enums.h"
#include "LIEF/PE/ImportEntry.h"
/** @defgroup pe_import_c_api Import
* @ingroup pe_c_api
* @addtogroup pe_import_c_api
* @brief Import C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
@@ -49,5 +41,4 @@ typedef struct Pe_Import_t Pe_Import_t;
}
#endif
/** @} */
#endif
+3 -12
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -22,20 +22,12 @@
#include "LIEF/PE/enums.h"
/** @defgroup pe_import_entry_c_api Import Entry
* @ingroup pe_c_api
* @addtogroup pe_import_entry_c_api
* @brief Import Entry C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Pe_ImportEntry_t {
bool is_ordinal;
uint8_t is_ordinal;
const char* name;
uint16_t ordinal;
uint64_t hint_name_rva;
@@ -52,5 +44,4 @@ typedef struct Pe_ImportEntry_t Pe_ImportEntry_t;
}
#endif
/** @} */
#endif
+38 -13
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -13,25 +13,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef C_LIEF_PE_OPTIONAL_HEADER_H_
#define C_LIEF_PE_OPTIONAL_HEADER_H_
#ifndef C_LIEF_PE_OPTIONAL_HEADER_H
#define C_LIEF_PE_OPTIONAL_HEADER_H
#include <inttypes.h>
#include "LIEF/PE/enums.h"
/** @defgroup pe_optional_header_c_api OptionalHeader
* @ingroup pe_c_api
* @addtogroup pe_optional_header_c_api
* @brief OptionalHeader C API
*
* @{
*/
#include "LIEF/visibility.h"
#ifdef __cplusplus
extern "C" {
#endif
enum LIEF_PE_DLL_CHARACTERISTICS {
LIEF_PE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020, /**< ASLR with 64 bit address space. */
LIEF_PE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040, /**< DLL can be relocated at load time. */
LIEF_PE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080, /**< Code integrity checks are enforced. */
LIEF_PE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100, /**< Image is NX compatible. */
LIEF_PE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200, /**< Isolation aware, but do not isolate the image. */
LIEF_PE_DLL_CHARACTERISTICS_NO_SEH = 0x0400, /**< Does not use structured exception handling (SEH). No SEH handler may be called in this image. */
LIEF_PE_DLL_CHARACTERISTICS_NO_BIND = 0x0800, /**< Do not bind the image. */
LIEF_PE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000, /**< Image should execute in an AppContainer. */
LIEF_PE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000, /**< A WDM driver. */
LIEF_PE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000, /**< Image supports Control Flow Guard. */
LIEF_PE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000 /**< Terminal Server aware. */
};
enum LIEF_PE_SUBSYSTEM {
LIEF_PE_SUBSYSTEM_UNKNOWN = 0, /**< An unknown subsystem. */
LIEF_PE_SUBSYSTEM_NATIVE = 1, /**< Device drivers and native Windows processes */
LIEF_PE_SUBSYSTEM_WINDOWS_GUI = 2, /**< The Windows GUI subsystem. */
LIEF_PE_SUBSYSTEM_WINDOWS_CUI = 3, /**< The Windows character subsystem. */
LIEF_PE_SUBSYSTEM_OS2_CUI = 5, /**< The OS/2 character subsytem. */
LIEF_PE_SUBSYSTEM_POSIX_CUI = 7, /**< The POSIX character subsystem. */
LIEF_PE_SUBSYSTEM_NATIVE_WINDOWS = 8, /**< Native Windows 9x driver. */
LIEF_PE_SUBSYSTEM_WINDOWS_CE_GUI = 9, /**< Windows CE. */
LIEF_PE_SUBSYSTEM_EFI_APPLICATION = 10, /**< An EFI application. */
LIEF_PE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, /**< An EFI driver with boot services. */
LIEF_PE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, /**< An EFI driver with run-time services. */
LIEF_PE_SUBSYSTEM_EFI_ROM = 13, /**< An EFI ROM image. */
LIEF_PE_SUBSYSTEM_XBOX = 14, /**< XBOX. */
LIEF_PE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 /**< A BCD application. */
};
struct Pe_OptionalHeader_t {
enum LIEF_PE_PE_TYPES magic;
uint16_t magic;
uint8_t major_linker_version;
uint8_t minor_linker_version;
uint32_t sizeof_code;
@@ -65,10 +90,10 @@ struct Pe_OptionalHeader_t {
typedef struct Pe_OptionalHeader_t Pe_OptionalHeader_t;
LIEF_API const char* lief_pe_subsytem_str(enum LIEF_PE_SUBSYSTEM e);
#ifdef __cplusplus
}
#endif
/** @} */
#endif
+41 -11
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 Quarkslab
/* 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.
@@ -19,18 +19,50 @@
#include <inttypes.h>
#include "LIEF/PE/enums.h"
/** @defgroup pe_section_c_api Section
* @ingroup pe_c_api
* @addtogroup pe_section_c_api
* @brief Section C API
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
enum LIEF_PE_SECTION_CHARACTERISTICS {
LIEF_PE_SECTION_CHARACTERISTICS_TYPE_NO_PAD = 0x00000008,
LIEF_PE_SECTION_CHARACTERISTICS_CNT_CODE = 0x00000020,
LIEF_PE_SECTION_CHARACTERISTICS_CNT_INITIALIZED_DATA = 0x00000040,
LIEF_PE_SECTION_CHARACTERISTICS_CNT_UNINITIALIZED_DATA = 0x00000080,
LIEF_PE_SECTION_CHARACTERISTICS_LNK_OTHER = 0x00000100,
LIEF_PE_SECTION_CHARACTERISTICS_LNK_INFO = 0x00000200,
LIEF_PE_SECTION_CHARACTERISTICS_LNK_REMOVE = 0x00000800,
LIEF_PE_SECTION_CHARACTERISTICS_LNK_COMDAT = 0x00001000,
LIEF_PE_SECTION_CHARACTERISTICS_GPREL = 0x00008000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_PURGEABLE = 0x00010000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_16BIT = 0x00020000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_LOCKED = 0x00040000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_PRELOAD = 0x00080000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_1BYTES = 0x00100000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_2BYTES = 0x00200000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_4BYTES = 0x00300000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_8BYTES = 0x00400000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_16BYTES = 0x00500000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_32BYTES = 0x00600000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_64BYTES = 0x00700000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_128BYTES = 0x00800000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_256BYTES = 0x00900000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_512BYTES = 0x00A00000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_1024BYTES = 0x00B00000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_2048BYTES = 0x00C00000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_4096BYTES = 0x00D00000,
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_8192BYTES = 0x00E00000,
LIEF_PE_SECTION_CHARACTERISTICS_LNK_NRELOC_OVFL = 0x01000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_DISCARDABLE = 0x02000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_NOT_CACHED = 0x04000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_NOT_PAGED = 0x08000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_SHARED = 0x10000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_EXECUTE = 0x20000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_READ = 0x40000000,
LIEF_PE_SECTION_CHARACTERISTICS_MEM_WRITE = 0x80000000
};
struct Pe_Section_t {
const char* name;
uint64_t virtual_address;
@@ -50,10 +82,8 @@ struct Pe_Section_t {
typedef struct Pe_Section_t Pe_Section_t;
#ifdef __cplusplus
}
#endif
/** @} */
#endif
+1 -1
View File
@@ -1,6 +1,5 @@
#ifndef LIEF_PE_C_ENUMS_H_
#define LIEF_PE_C_ENUMS_H_
#include "LIEF/PE/undef.h"
#ifdef __cplusplus
extern "C" {
@@ -16,6 +15,7 @@ extern "C" {
#undef _LIEF_EN_2
#undef _LIEF_EI
#ifdef __cplusplus
}
#endif

Some files were not shown because too many files have changed in this diff Show More