LCOV - code coverage report
Current view: top level - src/macho/commands - dylinker.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 100.0 % 19 19
Test Date: 2024-10-27:00:00:00 Functions: 100.0 % 4 4

            Line data    Source code
       1              : use super::Command;
       2              : use crate::common::FromFFI;
       3              : use lief_ffi as ffi;
       4              : use std::marker::PhantomData;
       5              : 
       6              : /// Structure that represents the Mach-O linker, also named loader.
       7              : /// Most of the time, [`Dylinker::name`] should return `/usr/lib/dyld`
       8              : pub struct Dylinker<'a> {
       9              :     ptr: cxx::UniquePtr<ffi::MachO_Dylinker>,
      10              :     _owner: PhantomData<&'a ffi::MachO_Binary>,
      11              : }
      12              : 
      13              : impl std::fmt::Debug for Dylinker<'_> {
      14           64 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      15           64 :         let base = self as &dyn Command;
      16           64 :         f.debug_struct("Dylinker")
      17           64 :             .field("base", &base)
      18           64 :             .field("name", &self.name())
      19           64 :             .finish()
      20           64 :     }
      21              : }
      22              : 
      23              : impl Dylinker<'_> {
      24              :     /// Path to the linker (or loader)
      25           64 :     pub fn name(&self) -> String {
      26           64 :         self.ptr.name().to_string()
      27           64 :     }
      28              : }
      29              : 
      30              : impl FromFFI<ffi::MachO_Dylinker> for Dylinker<'_> {
      31           64 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_Dylinker>) -> Self {
      32           64 :         Self {
      33           64 :             ptr: cmd,
      34           64 :             _owner: PhantomData,
      35           64 :         }
      36           64 :     }
      37              : }
      38              : 
      39              : impl Command for Dylinker<'_> {
      40          256 :     fn get_base(&self) -> &ffi::MachO_Command {
      41          256 :         self.ptr.as_ref().unwrap().as_ref()
      42          256 :     }
      43              : }
        

Generated by: LCOV version 2.1-1