Commit Graph

519 Commits

Author SHA1 Message Date
Romain Thomas 69219fdbe7 pe: add setters for iat_value/ilt_value 2026-03-20 16:27:47 +01:00
Romain Thomas 347b1b9c8f tests: add pytest slow marker with --skip-slow option 2026-03-19 18:19:40 +01:00
lief-agent 35de7f3592 Improve testing log API 2026-03-19 17:08:49 +01:00
Romain Thomas 1f190a9fa1 Change level to info 2026-03-19 09:04:58 +01:00
Romain Thomas 7ac083bb73 Add contextmanager API for log level 2026-03-19 07:56:02 +01:00
Romain Thomas 3d86f07199 Improve typing 2026-03-19 07:02:21 +01:00
Romain Thomas daa4b238f4 Resolve #743 2026-03-19 06:41:04 +01:00
Romain Thomas d295ee4d8b tests: fix alignment 2026-03-18 06:04:07 +01:00
Romain Thomas f986c6dd17 Resolve #1318 2026-03-17 17:11:44 +01:00
Romain Thomas cfdcc42fcd Fix warnings 2026-03-17 17:11:39 +01:00
Romain Thomas bff40d626c 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:01:23 +01:00
Romain Thomas 87cfc06382 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:00:51 +01:00
Romain Thomas 6c2e39cfc0 modernize python API 2026-03-17 14:00:48 +01:00
Romain Thomas 70c842f726 enhance testing 2026-03-17 09:01:40 +01:00
Romain Thomas e1844d4ecc Add check_layout for ELF
This commit implements the check_layout function for ELF binaries
similar to PE and Mach-O. This function aims to ensure that the
ELF binary is consistent according to various loader (e.g., Linux, Android)
2026-03-17 08:30:21 +01:00
Itamar Gafni 6f21d3902a 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-16 09:45:25 +01:00
Romain Thomas 3847142f1e add support to create a FAT MachO from binaries
Resolve: #1271
2026-03-08 14:10:57 +01:00
lief-agent 83bdf9c8d4 Add support for ELF DT_AUXILIARY and DT_FILTER
Resolve #1159
2026-03-08 11:33:50 +01:00
Romain Thomas 136aeff77e 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 07:50:27 +01:00
Romain Thomas cf890cee8d Fix test 2026-03-07 15:05:04 +01:00
lief-agent cb2a0948d4 Fix ruff lint warnings 2026-03-07 13:50:12 +01:00
Romain Thomas 8b659ba3ec better support for EFI/PE-COFF binary like bzImage
resolve #1293
2026-02-15 17:20:45 +01:00
Romain Thomas ef3694ba7e Fix typing 2026-02-14 20:29:29 +01:00
Romain Thomas e4ceecd6c4 Add support to insert an import at a specific position
close #1298
2026-02-14 11:09:22 +01:00
Romain Thomas 9c4204a358 Enhance API for MachO fileset
Fix #1297
2026-02-14 11:09:17 +01:00
Romain Thomas f36b5a5410 Enhance testing 2026-02-14 11:09:05 +01:00
Romain Thomas a89d452efa Add API to access a PDB from its index 2026-02-14 10:55:28 +01:00
Romain Thomas 986b7d0177 Update pytest to 9.0.2 2026-02-14 09:47:49 +01:00
Javier Lopez-Gomez 59298ccdc7 Fix MachO::Binary::virtual_address_to_offset() for non-file-backed segment (#1301)
Fix #1299.
2026-02-14 09:19:47 +01:00
Javier Lopez-Gomez 81feabd209 Fix LIEF::MachO::Binary::patch_relocation() for tagged pointers (#1302)
Fixes #1300.
2026-02-14 09:18:37 +01:00
Romain Thomas 7eab46d68b Fix Github action 2026-01-31 14:48:20 +01:00
Romain Thomas 3d699730c2 Add API to select a Mach-O binary by architecture from a FAT binary
Close #1283
2026-01-25 13:34:07 +01:00
Romain Thomas fd6b2c70c5 LLVM 22 Update 2026-01-24 17:18:48 +01:00
Romain Thomas c9afeaa030 Update catch2 to 3.12.0 2026-01-24 09:42:20 +01:00
Romain Thomas cd41d7a8dd Resolve #1284 - explicitly provides RVA/VA 2026-01-24 09:35:02 +01:00
Romain Thomas 21cf565261 Update copyright 2026-01-11 22:04:09 +01:00
Alex Kiecker f1f5f447f2 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 20:58:55 +01:00
Romain Thomas 107d9c51c5 Resolve #1265 2026-01-01 20:20:11 +01:00
Romain Thomas 81bd5d7ea0 Fix #1277 2026-01-01 14:24:07 +01:00
chengyongru cda7684767 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 14:23:39 +01:00
Trevor Elkins 7c3bf681c8 Fix #1262 2025-11-11 22:18:54 +01:00
Tim Schumacher 21eafecbf5 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:42:31 +01:00
Romain Thomas 5ae6a55929 Resolve #1261 2025-11-08 13:24:49 +01:00
Romain Thomas 6f8ec24955 Add function to find enum entry by value 2025-11-08 13:24:49 +01:00
Romain Thomas de95d5f49c Some refactoring and add tests 2025-11-08 12:01:25 +01:00
Romain Thomas 5e10f16dd0 Fix #1259 2025-11-01 20:20:12 +01:00
Romain Thomas 7b36cbd8aa Expose is_stack_based for DWARF variables 2025-10-12 10:40:37 +02:00
Romain Thomas 7fbc31cd81 Add support for DWARF Enum entries 2025-10-04 18:49:51 +02:00
Romain Thomas 754fb35780 Resolve #1251 2025-10-04 18:45:42 +02:00
Romain Thomas 55878992fc Add LIEF::COFF:Section::coff_string 2025-10-04 07:57:42 +02:00