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-11-30: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           80 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      15           80 :         let base = self as &dyn Command;
      16           80 :         f.debug_struct("Dylinker")
      17           80 :             .field("base", &base)
      18           80 :             .field("name", &self.name())
      19           80 :             .finish()
      20           80 :     }
      21              : }
      22              : 
      23              : impl Dylinker<'_> {
      24              :     /// Path to the linker (or loader)
      25           80 :     pub fn name(&self) -> String {
      26           80 :         self.ptr.name().to_string()
      27           80 :     }
      28              : }
      29              : 
      30              : impl FromFFI<ffi::MachO_Dylinker> for Dylinker<'_> {
      31           80 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_Dylinker>) -> Self {
      32           80 :         Self {
      33           80 :             ptr: cmd,
      34           80 :             _owner: PhantomData,
      35           80 :         }
      36           80 :     }
      37              : }
      38              : 
      39              : impl Command for Dylinker<'_> {
      40          320 :     fn get_base(&self) -> &ffi::MachO_Command {
      41          320 :         self.ptr.as_ref().unwrap().as_ref()
      42          320 :     }
      43              : }
        

Generated by: LCOV version 2.1-1