LCOV - code coverage report
Current view: top level - src/macho - parser_config.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 38 0
Test Date: 2026-04-12:00:00:00 Functions: 0.0 % 8 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : /// This structure is used to tweak the MachO parser:
       4              : /// [`crate::macho::FatBinary::parse_with_config`]
       5            0 : #[derive(Debug, Clone, PartialEq, Eq, Hash)]
       6              : pub struct Config {
       7              :     /// Parse the Dyld export trie
       8              :     pub parse_dyld_exports: bool,
       9              : 
      10              :     /// Parse the Dyld binding opcodes
      11              :     pub parse_dyld_bindings: bool,
      12              : 
      13              :     /// Parse the Dyld rebase opcodes
      14              :     pub parse_dyld_rebases: bool,
      15              : 
      16              :     /// Whether the overlay data should be parsed
      17              :     pub parse_overlay: bool,
      18              : 
      19              :     /// When parsing Mach-O from memory, this option
      20              :     /// can be used to *undo* relocations and symbols bindings.
      21              :     ///
      22              :     /// When activated, this option requires `parse_dyld_bindings`
      23              :     /// and `parse_dyld_rebases` to be enabled.
      24              :     pub fix_from_memory: bool,
      25              : 
      26              :     /// Whether the binary is coming/extracted from Dyld shared cache
      27              :     pub from_dyld_shared_cache: bool,
      28              : }
      29              : 
      30              : impl Default for Config {
      31            0 :     fn default() -> Config {
      32            0 :         Config {
      33            0 :             parse_dyld_exports: true,
      34            0 :             parse_dyld_bindings: true,
      35            0 :             parse_dyld_rebases: true,
      36            0 :             parse_overlay: true,
      37            0 :             fix_from_memory: false,
      38            0 :             from_dyld_shared_cache: false,
      39            0 :         }
      40            0 :     }
      41              : }
      42              : 
      43              : impl Config {
      44              :     #[doc(hidden)]
      45            0 :     pub fn to_ffi(&self) -> cxx::UniquePtr<ffi::MachO_ParserConfig> {
      46            0 :         let mut ptr = ffi::MachO_ParserConfig::create();
      47            0 :         ptr.pin_mut()
      48            0 :             .set_parse_dyld_exports(self.parse_dyld_exports);
      49            0 :         ptr.pin_mut()
      50            0 :             .set_parse_dyld_bindings(self.parse_dyld_bindings);
      51            0 :         ptr.pin_mut()
      52            0 :             .set_parse_dyld_rebases(self.parse_dyld_rebases);
      53            0 :         ptr.pin_mut().set_parse_overlay(self.parse_overlay);
      54            0 :         ptr.pin_mut().set_fix_from_memory(self.fix_from_memory);
      55            0 :         ptr.pin_mut()
      56            0 :             .set_from_dyld_shared_cache(self.from_dyld_shared_cache);
      57            0 :         ptr
      58            0 :     }
      59              : 
      60              :     /// Configuration that parses all supported MachO structures (deep parse).
      61            0 :     pub fn deep() -> Self {
      62            0 :         Self::default()
      63            0 :     }
      64              : 
      65              :     /// Configuration for a quick parse of the most important MachO structures.
      66            0 :     pub fn quick() -> Self {
      67            0 :         Self {
      68            0 :             parse_dyld_exports: true,
      69            0 :             parse_dyld_bindings: false,
      70            0 :             parse_dyld_rebases: false,
      71            0 :             parse_overlay: true,
      72            0 :             fix_from_memory: false,
      73            0 :             from_dyld_shared_cache: false,
      74            0 :         }
      75            0 :     }
      76              : }
        

Generated by: LCOV version 2.1-1