Commit Graph

10 Commits

Author SHA1 Message Date
Romain Thomas bc6a8514e3 compilation: enable precompiled headers (PCH)
Add precompiled headers to the main library, Python bindings,
and unit tests to improve compilation times.
2026-03-28 17:24:44 +01:00
Romain Thomas 21cf565261 Update copyright 2026-01-11 22:04:09 +01: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 3f35394efa Make sure we raise an exception if the value is not valid 2025-02-22 07:42:10 +01:00
Romain Thomas 2c0bf31cc0 ++year 2025-01-01 09:49:21 +01:00
Romain Thomas de49dceba9 Update nanobind
Resolve: #1128
2024-11-30 05:30:21 +01:00
Romain Thomas 9502c2b7ec Update copyrights 2024-02-04 05:50:39 +01:00
Romain Thomas 6ddc7e4145 Resolve #956 2023-11-25 11:46:31 +01:00
Romain Thomas e37ffa9ec8 Switch the bindings to nanobind (and update the CI) 2023-07-09 21:33:43 +02:00
Romain Thomas 9da2466609 Improve the LIEF Python build system by using pyproject.toml
- It also provides typing info (close #650)
- Enhance the test suite
- Remove deprecated PE functions
2023-02-19 20:19:03 +01:00