pub fn new(
        filename: PathBuf,
        do_relocations: bool,
        just_interpreter: bool,
        ld_paths: Option<Vec<PathBuf>>,
    ) -> Result<ElfLinker> {
        let mut file = File::open(&filename)?;
        let mut buf = Vec::new();
        file.read_to_end(&mut buf)?;

        // get the endianness of this elf for the memory model
        let mut endian = Endian::Big;
        if let goblin::Object::Elf(elf_peek) = goblin::Object::parse(&buf)? {
            if elf_peek.header.endianness()?.is_little() {
                endian = Endian::Little;
            }
        } else {
            bail!(format!("{} was not an Elf", filename.to_str().unwrap()));
        }

        let mut elf_linker = ElfLinker {
            filename: filename.clone(),
            loaded: BTreeMap::new(),
            memory: Memory::new(endian),
            symbols: BTreeMap::new(),
            next_lib_address: DEFAULT_LIB_BASE,
            user_functions: Vec::new(),
            do_relocations,
            just_interpreter,
            ld_paths,
        };

        elf_linker.load_elf(&filename, 0)?;

        Ok(elf_linker)
    }
/// Create a new ElfLinker.
///
/// It is recommended you use ElfLinkerBuilder to build an ElfLinker.
Create a new ElfLinker.
It is recommended you use ElfLinkerBuilder to build an ElfLinker.
Create a new ElfLinker . It is recommended you use ElfLinkerBuilder to build an ElfLinker .
pub fn new(
        filename: PathBuf,
        do_relocations: bool,
        just_interpreter: bool,
        ld_paths: Option<Vec<PathBuf>>,
    ) -> Result<ElfLinker> {
        let mut file = File::open(&filename)?;
        let mut buf = Vec::new();
        file.read_to_end(&mut buf)?;
        // get the endianness of this elf for the memory model
        let mut endian = Endian::Big;
        if let goblin::Object::Elf(elf_peek) = goblin::Object::parse(&buf)? {
            if elf_peek.header.endianness()?.is_little() {
                endian = Endian::Little;
            }
        } else {
            bail!(format!("{} was not an Elf", filename.to_str().unwrap()));
        }
        let mut elf_linker = ElfLinker {
            filename: filename.clone(),
            loaded: BTreeMap::new(),
            memory: Memory::new(endian),
            symbols: BTreeMap::new(),
            next_lib_address: DEFAULT_LIB_BASE,
            user_functions: Vec::new(),
            do_relocations,
            just_interpreter,
            ld_paths,
        };
        elf_linker.load_elf(&filename, 0)?;
        Ok(elf_linker)
    }
pub fn new ( filename : PathBuf , do_relocations : bool , just_interpreter : bool , ld_paths : Option < Vec < PathBuf > > , ) -> Result < ElfLinker > { let mut file = File :: open ( & filename ) ? ; let mut buf = Vec :: new ( ) ; file . read_to_end ( & mut buf ) ? ; // get the endianness of this elf for the memory model let mut endian = Endian :: Big ; if let goblin :: Object :: Elf ( elf_peek ) = goblin :: Object :: parse ( & buf ) ? { if elf_peek . header . endianness ( ) ? . is_little ( ) { endian = Endian :: Little ; } } else { bail ! ( format ( " " filename to_str ( ) unwrap ( ) ) ) ; } let mut elf_linker = ElfLinker { filename : filename . clone ( ) , loaded : BTreeMap :: new ( ) , memory : Memory :: new ( endian ) , symbols : BTreeMap :: new ( ) , next_lib_address : DEFAULT_LIB_BASE , user_functions : Vec :: new ( ) , do_relocations , just_interpreter , ld_paths , } ; elf_linker . load_elf ( & filename , 0 ) ? ; Ok ( elf_linker ) }
Create a new ElfLinker.
Create a new ElfLinker .
filename
PathBuf
do_relocations
bool
just_interpreter
bool
ld_paths
Option<Vec<PathBuf>>
filename
PathBuf
do_relocations
bool
just_interpreter
bool
ld_paths
Option<Vec<PathBuf>>