pub fn dt_needed(&self) -> Result<Vec<String>> {
        let mut v = Vec::new();

        let elf = self.elf();
        if let Some(dynamic) = elf.dynamic {
            // We need that strtab, and we have to do this one manually.
            // Get the strtab address
            let mut strtab_address = None;
            for dyn_ in &dynamic.dyns {
                if dyn_.d_tag == goblin::elf::dynamic::DT_STRTAB {
                    strtab_address = Some(dyn_.d_val);
                    break;
                }
            }
            if strtab_address.is_none() {
                return Ok(v);
            }
            let strtab_address = strtab_address.unwrap();
            // We're going to make a pretty safe assumption that strtab is all
            // in one section
            for section_header in &elf.section_headers {
                if section_header.sh_addr > 0
                    && section_header.sh_addr <= strtab_address
                    && section_header.sh_addr + section_header.sh_size > strtab_address
                {
                    let start =
                        section_header.sh_offset + (strtab_address - section_header.sh_addr);
                    let size = section_header.sh_size - (start - section_header.sh_offset);
                    let start = start as usize;
                    let size = size as usize;
                    let strtab_bytes = self.bytes.get(start..(start + size)).unwrap();
                    let strtab = goblin::strtab::Strtab::new(strtab_bytes, 0);
                    for dyn_ in dynamic.dyns {
                        if dyn_.d_tag == goblin::elf::dynamic::DT_NEEDED {
                            let so_name = &strtab[dyn_.d_val as usize];
                            v.push(so_name.to_string());
                        }
                    }
                    return Ok(v);
                }
            }
            // if we got here, we didn't return a vector (I think ;))
            panic!("Failed to get Dynamic strtab");
        }

        Ok(v)
    }
/// Return the strings from the DT_NEEDED entries.
Return the strings from the DT_NEEDED entries.
Return the strings from the DT_NEEDED entries .
pub fn dt_needed(&self) -> Result<Vec<String>> {
        let mut v = Vec::new();
        let elf = self.elf();
        if let Some(dynamic) = elf.dynamic {
            // We need that strtab, and we have to do this one manually.
            // Get the strtab address
            let mut strtab_address = None;
            for dyn_ in &dynamic.dyns {
                if dyn_.d_tag == goblin::elf::dynamic::DT_STRTAB {
                    strtab_address = Some(dyn_.d_val);
                    break;
                }
            }
            if strtab_address.is_none() {
                return Ok(v);
            }
            let strtab_address = strtab_address.unwrap();
            // We're going to make a pretty safe assumption that strtab is all
            // in one section
            for section_header in &elf.section_headers {
                if section_header.sh_addr > 0
                    && section_header.sh_addr <= strtab_address
                    && section_header.sh_addr + section_header.sh_size > strtab_address
                {
                    let start =
                        section_header.sh_offset + (strtab_address - section_header.sh_addr);
                    let size = section_header.sh_size - (start - section_header.sh_offset);
                    let start = start as usize;
                    let size = size as usize;
                    let strtab_bytes = self.bytes.get(start..(start + size)).unwrap();
                    let strtab = goblin::strtab::Strtab::new(strtab_bytes, 0);
                    for dyn_ in dynamic.dyns {
                        if dyn_.d_tag == goblin::elf::dynamic::DT_NEEDED {
                            let so_name = &strtab[dyn_.d_val as usize];
                            v.push(so_name.to_string());
                        }
                    }
                    return Ok(v);
                }
            }
            // if we got here, we didn't return a vector (I think ;))
            panic!("Failed to get Dynamic strtab");
        }
        Ok(v)
    }
pub fn dt_needed ( & self ) -> Result < Vec < String > > { let mut v = Vec :: new ( ) ; let elf = self . elf ( ) ; if let Some ( dynamic ) = elf . dynamic { // We need that strtab, and we have to do this one manually. // Get the strtab address let mut strtab_address = None ; for dyn_ in & dynamic . dyns { if dyn_ . d_tag == goblin :: elf :: dynamic :: DT_STRTAB { strtab_address = Some ( dyn_ . d_val ) ; break ; } } if strtab_address . is_none ( ) { return Ok ( v ) ; } let strtab_address = strtab_address . unwrap ( ) ; // We're going to make a pretty safe assumption that strtab is all // in one section for section_header in & elf . section_headers { if section_header . sh_addr > 0 && section_header . sh_addr <= strtab_address && section_header . sh_addr + section_header . sh_size > strtab_address { let start = section_header . sh_offset + ( strtab_address - section_header . sh_addr ) ; let size = section_header . sh_size - ( start - section_header . sh_offset ) ; let start = start as usize ; let size = size as usize ; let strtab_bytes = self . bytes . get ( start .. ( start + size ) ) . unwrap ( ) ; let strtab = goblin :: strtab :: Strtab :: new ( strtab_bytes , 0 ) ; for dyn_ in dynamic . dyns { if dyn_ . d_tag == goblin :: elf :: dynamic :: DT_NEEDED { let so_name = & strtab [ dyn_ . d_val as usize ] ; v . push ( so_name . to_string ( ) ) ; } } return Ok ( v ) ; } } // if we got here, we didn't return a vector (I think ;)) panic ! ( " " ) ; } Ok ( v ) }
Return the strings from the DT_NEEDED entries.
Return the strings from the DT_NEEDED entries .
&self
&self