pub fn parse<Elf: FileHeader>(
        endian: Elf::Endian,
        sections: &SectionTable<Elf>,
        symbol_section: usize,
    ) -> read::Result<Self> {
        let mut relocations = vec![0; sections.len()];
        for (index, section) in sections.iter().enumerate().rev() {
            let sh_type = section.sh_type(endian);
            if sh_type == elf::SHT_REL || sh_type == elf::SHT_RELA {
                // The symbol indices used in relocations must be for the symbol table
                // we are expecting to use.
                let sh_link = section.sh_link(endian) as usize;
                if sh_link != symbol_section {
                    continue;
                }

                let sh_info = section.sh_info(endian) as usize;
                if sh_info == 0 {
                    // Skip dynamic relocations.
                    continue;
                }
                if sh_info >= relocations.len() {
                    return Err(Error("Invalid ELF sh_info for relocation section"));
                }

                // Handle multiple relocation sections by chaining them.
                let next = relocations[sh_info];
                relocations[sh_info] = index;
                relocations[index] = next;
            }
        }
        Ok(Self { relocations })
    }
/// Create a new mapping using the section table.
///
/// Skips relocation sections that do not use the given symbol table section.
Create a new mapping using the section table.
Skips relocation sections that do not use the given symbol table section.
Create a new mapping using the section table . Skips relocation sections that do not use the given symbol table section .
pub fn parse<Elf: FileHeader>(
        endian: Elf::Endian,
        sections: &SectionTable<Elf>,
        symbol_section: usize,
    ) -> read::Result<Self> {
        let mut relocations = vec![0; sections.len()];
        for (index, section) in sections.iter().enumerate().rev() {
            let sh_type = section.sh_type(endian);
            if sh_type == elf::SHT_REL || sh_type == elf::SHT_RELA {
                // The symbol indices used in relocations must be for the symbol table
                // we are expecting to use.
                let sh_link = section.sh_link(endian) as usize;
                if sh_link != symbol_section {
                    continue;
                }
                let sh_info = section.sh_info(endian) as usize;
                if sh_info == 0 {
                    // Skip dynamic relocations.
                    continue;
                }
                if sh_info >= relocations.len() {
                    return Err(Error("Invalid ELF sh_info for relocation section"));
                }
                // Handle multiple relocation sections by chaining them.
                let next = relocations[sh_info];
                relocations[sh_info] = index;
                relocations[index] = next;
            }
        }
        Ok(Self { relocations })
    }
pub fn parse < Elf : FileHeader > ( endian : Elf :: Endian , sections : & SectionTable < Elf > , symbol_section : usize , ) -> read :: Result < Self > { let mut relocations = vec ! [ 0 sections len ( ) ] ; for ( index , section ) in sections . iter ( ) . enumerate ( ) . rev ( ) { let sh_type = section . sh_type ( endian ) ; if sh_type == elf :: SHT_REL || sh_type == elf :: SHT_RELA { // The symbol indices used in relocations must be for the symbol table // we are expecting to use. let sh_link = section . sh_link ( endian ) as usize ; if sh_link != symbol_section { continue ; } let sh_info = section . sh_info ( endian ) as usize ; if sh_info == 0 { // Skip dynamic relocations. continue ; } if sh_info >= relocations . len ( ) { return Err ( Error ( " " ) ) ; } // Handle multiple relocation sections by chaining them. let next = relocations [ sh_info ] ; relocations [ sh_info ] = index ; relocations [ index ] = next ; } } Ok ( Self { relocations } ) }
Create a new mapping using the section table.
Create a new mapping using the section table .
endian
Elf::Endian
sections
&SectionTable<Elf>
symbol_section
usize
endian
Elf::Endian
sections
&SectionTable<Elf>
symbol_section
usize